From df9a9f8821383c6b4fb37b4a5946941941646f4a Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Fri, 14 Apr 2017 18:50:17 -0500 Subject: [PATCH] Add UI for AFP over TCP options (not yet operational). --- afpcdev.c | 52 +++++++++++++++++++--- afpcdev.rez | 126 +++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 166 insertions(+), 12 deletions(-) diff --git a/afpcdev.c b/afpcdev.c index 98baffa..baf7cd3 100644 --- a/afpcdev.c +++ b/afpcdev.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "afpurlparser.h" #include "cdevutil.h" @@ -37,9 +38,16 @@ #define urlLine 3 #define saveAliasBtn 4 #define connectBtn 1 +#define optionsPopUp 6 +#define trianglePic 7 #define saveFilePrompt 100 +#define optionsMenu 300 +#define afpOverTCPOptionsItem 301 +#define useLargeReadsItem 302 +#define forceAFP22Item 303 + #define fstMissingError 3000 #define noEasyMountError 3001 #define tempFileError 3002 @@ -97,6 +105,11 @@ SFReplyRec2 sfReplyRec; Word modifiers = 0; +#define fLargeReads 0x0001 +#define fForceAFP22 0x0002 + +Word flags = fLargeReads; /* for AFP over TCP connections */ + void fillEasyMountRec(char *server, char *zone, char *volume, char *user, char *password, char *volpass) { @@ -420,8 +433,11 @@ err: } } -void DoHit(long ctlID) +void DoHit(long ctlID, CtlRecHndl ctlHandle) { + CtlRecHndl oldMenuBar; + Word menuItem; + if (!wPtr) /* shouldn't happen */ return; @@ -429,6 +445,21 @@ void DoHit(long ctlID) DoConnect(); } else if (ctlID == saveAliasBtn) { DoSave(); + } else if (ctlID == optionsPopUp) { + oldMenuBar = GetMenuBar(); + SetMenuBar(ctlHandle); + menuItem = GetCtlValue(ctlHandle); + + if (menuItem == useLargeReadsItem) { + flags ^= fLargeReads; + CheckMItem((flags & fLargeReads) ? TRUE : FALSE, useLargeReadsItem); + } else if (menuItem == forceAFP22Item) { + flags ^= fForceAFP22; + CheckMItem((flags & fForceAFP22) ? TRUE : FALSE, forceAFP22Item); + } + + SetCtlValue(afpOverTCPOptionsItem, ctlHandle); + SetMenuBar(oldMenuBar); } return; @@ -488,16 +519,25 @@ ret: SetPort(port); } +void DoCreate(WindowPtr windPtr) +{ + int mode; + + wPtr = windPtr; + mode = (GetMasterSCB() & scbColorMode) ? 640 : 320; + NewControl2(wPtr, resourceToResource, mode); +} + LongWord cdevMain (LongWord data2, LongWord data1, Word message) { long result = 0; switch(message) { - case MachineCDEV: result = DoMachine(); break; - case HitCDEV: DoHit(data2); break; - case EditCDEV: DoEdit(data1 & 0xFFFF); break; - case InitCDEV: wPtr = (WindowPtr)data1; break; - case CloseCDEV: wPtr = NULL; break; + case MachineCDEV: result = DoMachine(); break; + case HitCDEV: DoHit(data2, (CtlRecHndl)data1); break; + case EditCDEV: DoEdit(data1 & 0xFFFF); break; + case CreateCDEV: DoCreate((WindowPtr)data1); break; + case CloseCDEV: wPtr = NULL; break; case EventsCDEV: /* Now done in assembly for speed. Equivalent to: */ /* modifiers = ((EventRecordPtr)data1)->modifiers; */ break; diff --git a/afpcdev.rez b/afpcdev.rez index 9535252..a8bafb3 100644 --- a/afpcdev.rez +++ b/afpcdev.rez @@ -1,7 +1,7 @@ #include "types.rez" resource rCDEVFlags (1) { - wantMachine+wantHit+wantInit+wantClose+wantEvents+wantEdit, + wantMachine+wantHit+wantClose+wantEvents+wantEdit+wantCreate, 1, /* enabled */ 1, /* version */ 1, /* min ROM version */ @@ -68,28 +68,48 @@ resource rIcon (1) { #define urlLine 3 #define saveAliasBtn 4 #define connectBtn 1 +#define optionsPopUp 6 +#define trianglePic 7 #define helpTxt 5 #define saveFilePrompt 100 +#define optionsMenu 300 +#define afpOverTCPOptionsItem 301 +#define useLargeReadsItem 302 +#define forceAFP22Item 303 + /* - * Controls in the control panel window + * Controls in the control panel window (for 640 mode or 320 mode) */ -resource rControlList (1) { +resource rControlList (640) { { cdevWindow+serverAddressTxt, cdevWindow+urlLine, cdevWindow+saveAliasBtn, - cdevWindow+connectBtn + cdevWindow+connectBtn, + cdevWindow+trianglePic, + cdevWindow+optionsPopUp + }; +}; + +resource rControlList (320) { + { + cdevWindow+serverAddressTxt, + cdevWindow+urlLine, + cdevWindow+saveAliasBtn, + cdevWindow+connectBtn, + cdevWindow+trianglePic+320, + cdevWindow+optionsPopUp+320 }; }; resource rControlTemplate (cdevWindow+serverAddressTxt) { serverAddressTxt, /* control ID */ - {4, 10, 15, 310}, /* control rect */ + {4, 10, 15, 270}, /* control rect */ statTextControl {{ - 0, /* flags */ + fBlastText, /* flags */ $1000+RefIsResource, /* moreFlags */ 0, /* refCon */ cdevWindow+serverAddressTxt /* title ref */ @@ -142,6 +162,100 @@ resource rControlTemplate (cdevWindow+connectBtn) { resource rPString(cdevWindow+connectBtn) { "Connect" }; +/* Options menu pop-up -- separate versions for 640 mode and 320 mode */ +resource rControlTemplate (cdevWindow+optionsPopUp) { + optionsPopUp, + {5, 282, 13, 310 }, + PopUpControl {{ + fDontDrawTitle+fDontDrawResult, + fCtlProcNotPtr+RefIsResource/*+fDrawPopDownIcon*/, + 0, + 0, + optionsMenu, /* menu ref */ + afpOverTCPOptionsItem, /* initial value */ + 0 + }}; +}; + +resource rControlTemplate (cdevWindow+optionsPopUp+ 320) { + optionsPopUp, + {5, 296, 13, 310 }, + PopUpControl {{ + fDontDrawTitle+fDontDrawResult, + fCtlProcNotPtr+RefIsResource/*+fDrawPopDownIcon*/, + 0, + 0, + optionsMenu, /* menu ref */ + afpOverTCPOptionsItem, /* initial value */ + 0 + }}; +}; + +/* Triangle to draw on options pop-up */ +resource rControlTemplate (cdevWindow+trianglePic) { + trianglePic, + {7, 286, 11, 302}, + PictureControl {{ + CtlInactive, + fCtlProcNotPtr+RefIsResource, + 0, + trianglePic /* picture reference */ + }}; +}; + +resource rControlTemplate (cdevWindow+trianglePic+320) { + trianglePic, + {7, 298, 0, 0}, + PictureControl {{ + CtlInactive, + fCtlProcNotPtr+RefIsResource, + 0, + trianglePic /* picture reference */ + }}; +}; + +data rPicture (trianglePic) { + $"8000 0000 0000 0400 1000 1182 0100 0A00" + $"01C0 01C0 FF3F FF3F 9000 8000 0000 0400" + $"0000 0000 0400 1000 0000 0000 0400 1000" + $"0000 0000 0400 1000 0000 0000 0000 F000" + $"000F FF00 00FF FFF0 0FFF" +}; + +resource rMenu (optionsMenu) { + optionsMenu, /* menu ID */ + refIsResource*menuTitleRefShift + refIsResource*itemRefShift, + optionsMenu, /* menu title ref (not drawn) */ + {afpOverTCPOptionsItem, useLargeReadsItem, forceAFP22Item}; +}; +resource rPString(optionsMenu,noCrossBank) { "" }; + +resource rMenuItem (afpOverTCPOptionsItem) { + afpOverTCPOptionsItem, /* menu item ID */ + "","", + 0, + fDisabled+refIsResource*itemTitleRefShift, + afpOverTCPOptionsItem /* menu item title ref */ +}; +resource rPString(afpOverTCPOptionsItem,noCrossBank) { "AFP Over TCP Options:" }; + +resource rMenuItem (useLargeReadsItem) { + useLargeReadsItem, /* menu item ID */ + "","", + $12, + refIsResource*itemTitleRefShift, + useLargeReadsItem /* menu item title ref */ +}; +resource rPString(useLargeReadsItem,noCrossBank) { "Use Large Reads" }; + +resource rMenuItem (forceAFP22Item) { + forceAFP22Item, /* menu item ID */ + "","", + 0, + refIsResource*itemTitleRefShift, + forceAFP22Item /* menu item title ref */ +}; +resource rPString(forceAFP22Item,noCrossBank) { "Force AFP Version 2.2" }; /* * Controls in the help window