diff --git a/xpinstall/wizard/mac/src/ComponentsWin.c b/xpinstall/wizard/mac/src/ComponentsWin.c index 69121dadbf0..7ef9244a6f4 100644 --- a/xpinstall/wizard/mac/src/ComponentsWin.c +++ b/xpinstall/wizard/mac/src/ComponentsWin.c @@ -43,7 +43,7 @@ ShowComponentsWin(void) SetPort(gWPtr); - gCurrWin = COMPONENTS; + gCurrWin = kComponentsID; /* gControls->cw = (CompWin *) NewPtrClear(sizeof(CompWin)); */ GetIndString(next, rStringList, sNextBtn); @@ -51,16 +51,16 @@ ShowComponentsWin(void) // get controls listBoxRect = Get1Resource('RECT', rCompListBox); - reserr = ResError(); //dougt: this does not do what you think - if (reserr == noErr) + reserr = ResError(); + if (reserr == noErr && listBoxRect != NULL) { - HLockHi((Handle)listBoxRect); //dougt: no hi. + HLock((Handle)listBoxRect); gControls->cw->compListBox = (Rect) **((Rect **)listBoxRect); HUnlock((Handle)listBoxRect); - ErrorHandler(); } else { + ErrorHandler(); return; } gControls->cw->compDescBox = GetNewControl(rCompDescBox, gWPtr); @@ -68,8 +68,8 @@ ShowComponentsWin(void) gControls->cw->compListBox.right -= kScrollBarWidth; SetRect(&dataBounds, 0, 0, 1, gControls->cfg->numComps); SetPt( &cSize, 0, 0); - gControls->cw->compList = lnew(&gControls->cw->compListBox, &dataBounds, //dougt: what is this call!! it should be LNew()?? - &cSize, 0, gWPtr, TRUE, FALSE, FALSE, TRUE); + gControls->cw->compList = LNew((const Rect*)&gControls->cw->compListBox, (const Rect*)&dataBounds, + cSize, 0, gWPtr, true, false, false, true); // populate controls bCellSelected = PopulateCompInfo(); diff --git a/xpinstall/wizard/mac/src/Deflation.c b/xpinstall/wizard/mac/src/Deflation.c index 2fb8f71b874..d97b556eb61 100644 --- a/xpinstall/wizard/mac/src/Deflation.c +++ b/xpinstall/wizard/mac/src/Deflation.c @@ -19,16 +19,18 @@ * Contributors: * Samir Gehani */ - #include "MacInstallWizard.h" + #define STANDALONE 1 #define XP_MAC 1 #include "zipstub.h" #include "zipfile.h" #include "nsAppleSingleDecoder.h" +static FSSpec coreFileList[kMaxCoreFiles]; +static short currCoreFile = 0; /*-----------------------------------------------------------* * Deflation @@ -58,7 +60,11 @@ ExtractCoreFile(void) { /* make local copy and unlock handle */ coreFile = CToPascal(*gControls->cfg->coreFile); - // XXX memory check + if (!coreFile) + { + err= memFullErr; + goto cleanup; + } } else return fnfErr; @@ -69,7 +75,11 @@ ExtractCoreFile(void) if (*gControls->cfg->coreDir != NULL) { coreDirPath = CToPascal(*gControls->cfg->coreDir); - // XXX memory check + if (!coreDirPath) + { + err = memFullErr; + goto cleanup; + } } HUnlock(gControls->cfg->coreDir); @@ -104,7 +114,10 @@ ExtractCoreFile(void) { rv = ZIP_FindNext( hFind, filename, 255 ); if (rv==ZIP_ERR_FNF) + { bFoundAll = true; + break; + } else if (rv!=ZIP_OK) return rv; @@ -147,40 +160,57 @@ ExtractCoreFile(void) // if there's a coreDir specified move the file into it if (coreDirPath[0] > 0) { - if (*dir) // coreDir:extractedDir: + if (*dir) // coreDir:extractedDir: { err = DirCreate(coreDirFSp.vRefNum, coreDirID, pdir, &extractedDirID); - if (err!=noErr && err!=dupFNErr) - return err; + if (err==noErr) + FSMakeFSSpec(outFSp.vRefNum, coreDirID, pdir, &coreFileList[currCoreFile]); // track for deletion + else if (err!=dupFNErr) + goto cleanup; ERR_CHECK_RET(ForceMoveFile(outFSp.vRefNum, outFSp.parID, outFSp.name, extractedDirID), err); + FSMakeFSSpec(outFSp.vRefNum, extractedDirID, outFSp.name, &coreFileList[currCoreFile]); } - // else coreDir: - else + else // else coreDir: + { ERR_CHECK_RET(ForceMoveFile(outFSp.vRefNum, outFSp.parID, outFSp.name, coreDirID), err); + FSMakeFSSpec(outFSp.vRefNum, coreDirID, outFSp.name, &coreFileList[currCoreFile]); + } } - else if (*dir) // extractedDir: + else if (*dir) // extractedDir: { err = FSMakeFSSpec(tgtVRefNum, tgtDirID, pdir, &extractedDir); if (err==noErr) // already created err = FSpGetDirectoryID(&extractedDir, &extractedDirID, &isDir); - else // otherwise mkdir + else // otherwise mkdir + { err = FSpDirCreate(&extractedDir, smSystemScript, &extractedDirID); + FSMakeFSSpec(tgtVRefNum, tgtDirID, pdir, &coreFileList[currCoreFile]); // track for deletion + } if (err!=noErr && err!=dupFNErr) - return err; + goto cleanup; ERR_CHECK_RET(ForceMoveFile(outFSp.vRefNum, outFSp.parID, outFSp.name, extractedDirID), err); + FSMakeFSSpec(outFSp.vRefNum, extractedDirID, outFSp.name, &coreFileList[currCoreFile]); + } + else // just cwd: + { + FSMakeFSSpec(outFSp.vRefNum, outFSp.parID, outFSp.name, &coreFileList[currCoreFile]); } - if (*dir) + if (*dir && pdir) DisposePtr((Ptr) pdir); - DisposePtr((Ptr)extractedFile); + if (extractedFile) + DisposePtr((Ptr)extractedFile); + + currCoreFile++; } -// XXX need to make all returns go through cleanup -// cleanup: +cleanup: // dispose of coreFile, coreDirPath - DisposePtr((Ptr) coreFile); - DisposePtr((Ptr) coreDirPath); + if (coreFile) + DisposePtr((Ptr) coreFile); + if (coreDirPath) + DisposePtr((Ptr) coreDirPath); return err; } @@ -195,6 +225,9 @@ AppleSingleDecode(FSSpecPtr fd, FSSpecPtr outfd) { // decode it decoder = new nsAppleSingleDecoder(fd, outfd); + if (!decoder) + return memFullErr; + ERR_CHECK_RET(decoder->Decode(), err); } @@ -240,4 +273,38 @@ ForceMoveFile(short vRefNum, long parID, ConstStr255Param name, long newDirID) return err; } - \ No newline at end of file +OSErr +CleanupExtractedFiles(void) +{ + OSErr err = noErr; + FSSpec coreDirFSp; + StringPtr pcoreDir; + short i = 0; + + HLock(gControls->cfg->coreDir); + if (*gControls->cfg->coreDir != NULL && **gControls->cfg->coreDir != NULL) + { + // just need to delete the core dir and its contents + + pcoreDir = CToPascal(*gControls->cfg->coreDir); + err = FSMakeFSSpec(gControls->opt->vRefNum, gControls->opt->dirID, pcoreDir, &coreDirFSp); + if (err == noErr) + { + err = FSpDelete( &coreDirFSp ); + return err; + } + else + return err; + } + HUnlock(gControls->cfg->coreDir); + + // otherwise iterate through coreFileList deleteing each individually + for (i=0; imessage & charCodeMask; +#ifdef DEBUG if ( (keyPressed == 'z') || (keyPressed == 'Z')) - gDone = true; // backdoor exit //dougt: Get rid of this. (or make it debug only) + gDone = true; // backdoor exit +#endif if (keyPressed == '\r') //dougt: what about tab, esc, arrows, doublebyte? { switch(gCurrWin) { - case LICENSE: + case kLicenseID: KillControls(gWPtr); ShowWelcomeWin(); return; - case WELCOME: + case kWelcomeID: KillControls(gWPtr); ShowSetupTypeWin(); return; - case SETUP_TYPE: + case kSetupTypeID: KillControls(gWPtr); /* treat last setup type selection as custom */ @@ -122,11 +124,11 @@ void HandleKeyDown(EventRecord* evt) else ShowTerminalWin(); return; - case COMPONENTS: + case kComponentsID: KillControls(gWPtr); ShowTerminalWin(); return; - case TERMINAL: + case kTerminalID: SpawnSDThread(Install, &tid); return; default: @@ -137,55 +139,54 @@ void HandleKeyDown(EventRecord* evt) void HandleUpdateEvt(EventRecord* evt) { - WindowPtr wCurrPtr; - SInt16 cntlPartCode; Rect bounds; GrafPtr oldPort; GetPort(&oldPort); SetPort( gWPtr ); - - cntlPartCode = FindWindow( evt->where, &wCurrPtr ); - //dougt: check for null - BeginUpdate( gWPtr ); - DrawControls( gWPtr ); - ShowLogo(); - - switch(gCurrWin) + + if (gWPtr != NULL) { - case LICENSE: - case WELCOME: - ShowTxt(); - break; - case SETUP_TYPE: - ShowSetupDescTxt(); - break; - case COMPONENTS: - UpdateCompWin(); - break; - case TERMINAL: - UpdateTerminalWin(); - break; - default: - break; - } + BeginUpdate( gWPtr ); + DrawControls( gWPtr ); + ShowLogo(); + + switch(gCurrWin) + { + case kLicenseID: + case kWelcomeID: + ShowTxt(); + break; + case kSetupTypeID: + ShowSetupDescTxt(); + break; + case kComponentsID: + UpdateCompWin(); + break; + case kTerminalID: + UpdateTerminalWin(); + break; + default: + break; + } - if (gControls->nextB) - { - HLockHi( (Handle) gControls->nextB); + if (gControls->nextB) + { + HLockHi( (Handle) gControls->nextB); - bounds = (*(gControls->nextB))->contrlRect; - PenMode(patCopy); - ForeColor(blackColor); - InsetRect( &bounds, -4, -4 ); - FrameGreyButton( &bounds ); + bounds = (*(gControls->nextB))->contrlRect; + PenMode(patCopy); + ForeColor(blackColor); + InsetRect( &bounds, -4, -4 ); + FrameGreyButton( &bounds ); - HUnlock( (Handle)gControls->nextB ); + HUnlock( (Handle)gControls->nextB ); + } + + EndUpdate( gWPtr ); } - EndUpdate( gWPtr ); - SetPort(oldPort); } @@ -196,26 +197,26 @@ void HandleActivateEvt(EventRecord* evt) void HandleOSEvt(EventRecord* evt) { - switch ( (evt->message >> 24) & 0x000000FF) //dougt: Okay, what is this? + switch ( (evt->message >> 24) & 0x000000FF) { case suspendResumeMessage: if ((evt->message & resumeFlag) == 1) { switch(gCurrWin) { - case LICENSE: + case kLicenseID: EnableLicenseWin(); break; - case WELCOME: + case kWelcomeID: EnableWelcomeWin(); break; - case SETUP_TYPE: + case kSetupTypeID: EnableSetupTypeWin(); break; - case COMPONENTS: + case kComponentsID: EnableComponentsWin(); break; - case TERMINAL: + case kTerminalID: EnableTerminalWin(); break; } @@ -226,19 +227,19 @@ void HandleOSEvt(EventRecord* evt) { switch(gCurrWin) { - case LICENSE: + case kLicenseID: DisableLicenseWin(); break; - case WELCOME: + case kWelcomeID: DisableWelcomeWin(); break; - case SETUP_TYPE: + case kSetupTypeID: DisableSetupTypeWin(); break; - case COMPONENTS: + case kComponentsID: DisableComponentsWin(); break; - case TERMINAL: + case kTerminalID: DisableTerminalWin(); break; } @@ -252,28 +253,28 @@ void React2InContent(EventRecord* evt, WindowPtr wCurrPtr) { switch (gCurrWin) { - case LICENSE: + case kLicenseID: InLicenseContent(evt, gWPtr); break; - case WELCOME: + case kWelcomeID: InWelcomeContent(evt, gWPtr); break; - case SETUP_TYPE: + case kSetupTypeID: InSetupTypeContent(evt, gWPtr); break; - case COMPONENTS: + case kComponentsID: InComponentsContent(evt, gWPtr); break; - case TERMINAL: + case kTerminalID: InTerminalContent(evt, gWPtr); break; default: - gDone = true; //dougt: are you sure you want to do this? + gDone = true; break; } } diff --git a/xpinstall/wizard/mac/src/InstAction.c b/xpinstall/wizard/mac/src/InstAction.c index b390c91ac2c..c08e3212f34 100644 --- a/xpinstall/wizard/mac/src/InstAction.c +++ b/xpinstall/wizard/mac/src/InstAction.c @@ -32,11 +32,12 @@ pascal void* Install(void* unused) short vRefNum; long dirID; OSErr err; - FSSpec idiSpec, xpiSpec, tgtDirSpec, coreFileSpec; + FSSpec idiSpec, coreFileSpec; SDISTRUCT sdistruct; Str255 pIDIfname; StringPtr coreFile; - + THz ourHZ; + ERR_CHECK_RET( GetCWD(&dirID, &vRefNum), (void*)0 ); GetIndString(pIDIfname, rStringList, sTempIDIName); @@ -65,11 +66,17 @@ pascal void* Install(void* unused) sdistruct.hwndOwner = NULL; /* call SDI_NetInstall */ + gSDDlg = true; + // YieldToAnyThread(); /* force gSDDlg to be picked up by Main Thread */ + ourHZ = GetZone(); #if SDINST_IS_DLL == 1 gInstFunc(&sdistruct); #else SDI_NetInstall(&sdistruct); #endif + SetZone(ourHZ); + gSDDlg = false; + FSpDelete(&idiSpec); /* check if coreFile was downloaded */ @@ -82,21 +89,25 @@ pascal void* Install(void* unused) err = FSMakeFSSpec(vRefNum, dirID, coreFile, &coreFileSpec); if (err==noErr) /* core file was downloaded */ { + /* extract contents of downloaded core file */ err = ExtractCoreFile(); - if (err!=noErr) SysBeep(10); - -#if 0 // XXX commented out for QA buid: LoadXPIStub crashes still... - sleep(15); - - /* call XPInstall */ - err = FSMakeFSSpec(vRefNum, dirID, "\pmozilla.jar", &xpiSpec); - err = FSMakeFSSpec(vRefNum, dirID, 0, &tgtDirSpec); - if (err==noErr) - err = RunXPI(xpiSpec, tgtDirSpec); - elsesss + if (err!=noErr) + { + ErrorHandler(); + return (void*) nil; + } + + sleep(1); + + /* run all .xpi's through XPInstall */ + err = RunAllXPIs(vRefNum, dirID); + if (err!=noErr) ErrorHandler(); -#endif } + + CleanupExtractedFiles(); + if (coreFile) + DisposePtr((Ptr)coreFile); } /* wind down app */ diff --git a/xpinstall/wizard/mac/src/LicenseWin.c b/xpinstall/wizard/mac/src/LicenseWin.c index d5935215b1b..f804ed68dda 100644 --- a/xpinstall/wizard/mac/src/LicenseWin.c +++ b/xpinstall/wizard/mac/src/LicenseWin.c @@ -20,7 +20,6 @@ * Samir Gehani */ - #include "MacInstallWizard.h" @@ -41,8 +40,7 @@ ShowLicenseWin(void) SetPort(gWPtr); -//dougt: nitpick, your use of the define LICENSE is vage. I had no initial idea of what it was. How about kLicenseID? - gCurrWin = LICENSE; + gCurrWin = kLicenseID; /* gControls->lw = (LicWin *) NewPtrClear(sizeof(LicWin)); */ GetIndString(accept, rStringList, sAcceptBtn); @@ -50,12 +48,10 @@ ShowLicenseWin(void) gControls->lw->scrollBar = GetNewControl( rLicScrollBar, gWPtr); gControls->lw->licBox = GetNewControl( rLicBox, gWPtr); -//dougt: what happens if these fail? don't you want to bail instead of just checking on the next line? + if(gControls->lw->scrollBar && gControls->lw->licBox) { - //dougt: you don't need to lock hi here. - - HLockHi( (Handle) gControls->lw->scrollBar); + HLock( (Handle) gControls->lw->scrollBar); sbRect = (*(gControls->lw->licBox))->contrlRect; sbWidth = (*(gControls->lw->scrollBar))->contrlRect.right - @@ -68,6 +64,11 @@ ShowLicenseWin(void) (*(gControls->lw->scrollBar))->contrlRect.bottom = sbRect.bottom + kScrollBarPad; HUnlock( (Handle) gControls->lw->scrollBar); } + else + { + ErrorHandler(); + return; + } InitLicTxt(); ShowNavButtons( decline, accept); @@ -95,16 +96,15 @@ InitLicTxt(void) ERR_CHECK(GetCWD(&dirID, &vRefNum)); /* open and read license file */ -//dougt: no need to lock hi., - HLockHi(gControls->cfg->licFileName); + HLock(gControls->cfg->licFileName); if(**gControls->cfg->licFileName != nil) { cLicFName = (unsigned char*)NewPtrClear(strlen(*gControls->cfg->licFileName)); cLicFName = CToPascal(*gControls->cfg->licFileName); ERR_CHECK(FSMakeFSSpec(vRefNum, dirID, cLicFName, &licFile)); -//dougt: on any dispose, check for null! - DisposePtr((char*)cLicFName); + if (cLicFName) + DisposePtr((char*)cLicFName); } else /* assume default license filename from str rsrc */ { @@ -120,7 +120,10 @@ InitLicTxt(void) if (dataSize > 0) { if (!(text = NewHandle(dataSize))) - ErrorHandler(); //dougt: since errorhandler() return, you will crash on the next line + { + ErrorHandler(); + return; + } ERR_CHECK(FSRead(dataRef, &dataSize, *text)); } else @@ -186,14 +189,14 @@ ShowTxt(void) { switch (gCurrWin) { - case LICENSE: + case kLicenseID: if(gControls->lw->licTxt) { // InvalRect(&(**(gControls->lw->licTxt)).viewRect); TEUpdate( &(**(gControls->lw->licTxt)).viewRect, gControls->lw->licTxt); } break; - case WELCOME: + case kWelcomeID: if(gControls->ww->welcTxt) { // InvalRect(&(**(gControls->lw->licTxt)).viewRect); @@ -201,7 +204,6 @@ ShowTxt(void) } break; default: - ErrorHandler(); //dougt: i don;t think so tim, break; } } @@ -215,25 +217,34 @@ ShowLogo(void) Handle logoRectH; /* initialize Netscape logo */ - logoPicH = GetPicture(rNSLogo); //dougt: isn;t this something that should be pulled from an ini file? Also, what about - // better error handling? - - /* draw Netscape logo */ - if (logoPicH != nil) - { - logoRectH = Get1Resource('RECT', rNSLogoBox); - //dougt: check failure - HLockHi(logoRectH);//dougt: no lock hi - derefd = (Rect) **((Rect**)logoRectH); - SetRect(&logoRect, derefd.left, derefd.top, derefd.bottom, derefd.right); - HUnlock(logoRectH); - reserr = ResError(); //dougt: checking this does not gaurentee you the correct ResError(). - if (reserr == noErr) + logoPicH = GetPicture(rNSLogo); + reserr = ResError(); + + if (reserr == noErr) + { + /* draw Netscape logo */ + if (logoPicH != nil) { - DrawPicture(logoPicH, &logoRect); - ReleaseResource((Handle)logoPicH); + logoRectH = Get1Resource('RECT', rNSLogoBox); + reserr = ResError(); + if (reserr == noErr) + { + HLock(logoRectH); + derefd = (Rect) **((Rect**)logoRectH); + SetRect(&logoRect, derefd.left, derefd.top, derefd.bottom, derefd.right); + HUnlock(logoRectH); + reserr = ResError(); + if (reserr == noErr) + { + DrawPicture(logoPicH, &logoRect); + ReleaseResource((Handle)logoPicH); + } + } } } + + if (reserr != noErr) + ErrorHandler(); } void @@ -356,10 +367,10 @@ InitScrollBar(ControlHandle sb) switch(gCurrWin) { - case LICENSE: + case kLicenseID: currTE = gControls->lw->licTxt; break; - case WELCOME: + case kWelcomeID: currTE = gControls->ww->welcTxt; break; default: @@ -387,10 +398,10 @@ DoScrollProc(ControlHandle theControl, short part) if ( part != 0 ) { switch (gCurrWin) { - case LICENSE: + case kLicenseID: te = *(gControls->lw->licTxt); break; - case WELCOME: + case kWelcomeID: te = *(gControls->ww->welcTxt); break; default: @@ -440,7 +451,7 @@ ShowNavButtons(unsigned char* backTitle, unsigned char* nextTitle) gControls->backB = GetNewControl( rBackBtn, gWPtr); gControls->nextB = GetNewControl( rNextBtn, gWPtr); -//dougt: check for failure... + if( gControls->backB != NULL) { SetControlTitle( gControls->backB, backTitle); @@ -451,8 +462,8 @@ ShowNavButtons(unsigned char* backTitle, unsigned char* nextTitle) { SetControlTitle( gControls->nextB, nextTitle); ShowControl( gControls->nextB); -//dougt: no hi. - HLockHi( (Handle) gControls->nextB); + + HLock( (Handle) gControls->nextB); bounds = (*(gControls->nextB))->contrlRect; PenMode(patCopy); diff --git a/xpinstall/wizard/mac/src/MacInstallWizard.c b/xpinstall/wizard/mac/src/MacInstallWizard.c index 5eb2e539c41..4fed817cdf2 100644 --- a/xpinstall/wizard/mac/src/MacInstallWizard.c +++ b/xpinstall/wizard/mac/src/MacInstallWizard.c @@ -22,14 +22,17 @@ #include "MacInstallWizard.h" + /*-----------------------------------------------------------* * globals *-----------------------------------------------------------*/ -//dougt: maybe you should init these here to null -Boolean gDone; -WindowPtr gWPtr; -short gCurrWin; -InstWiz *gControls; + +Boolean gDone = false; +Boolean gSDDlg = false; +WindowPtr gWPtr = NULL; +short gCurrWin = 0; +InstWiz *gControls = NULL; +static Boolean bInShutdown = false; EventProc gSDIEvtHandler; /* SDI */ SDI_NETINSTALL gInstFunc; @@ -51,12 +54,10 @@ void Init(void) Str255 winTitle; ThreadID tid; ThreadState state; - OSErr err; gDone = false; InitManagers(); InitControlsObject(); - InitOptObject(); #ifdef SDINST_IS_DLL if (!InitSDLib()) @@ -72,7 +73,6 @@ void Init(void) ErrorHandler(); return; } -//dougt: will sd put up some ui while the main thread blocks? /* block/busy wait till download finishes */ while (1) @@ -90,11 +90,12 @@ void Init(void) gWPtr = GetNewCWindow(rRootWin, NULL, (WindowPtr) -1); GetIndString( winTitle, rStringList, sNSInstTitle); - //pstrcpy(winTitle, "\pNetscape Installer Dude"); SetWTitle( gWPtr, winTitle ); + SetWRefCon(gWPtr, kMIWMagic); MakeMenus(); ParseConfig(); + InitOptObject(); ShowLicenseWin(); ShowWindow(gWPtr); @@ -133,11 +134,22 @@ InitOptObject(void) OSErr err=noErr; gControls->opt = (Options*)NewPtrClear(sizeof(Options)); -//dougt: what happens when allocation fails! + + if (!gControls->opt) + { + ErrorHandler(); + return; + } + /* SetupTypeWin options */ gControls->opt->instChoice = 1; gControls->opt->folder = (unsigned char *)NewPtrClear(64*sizeof(unsigned char)); -//dougt: what happens when allocation fails! + if (!gControls->opt->folder) + { + ErrorHandler(); + return; + } + ERR_CHECK(GetCWD(&gControls->opt->dirID, &gControls->opt->vRefNum)); ERR_CHECK(FSMakeFSSpec(gControls->opt->vRefNum, gControls->opt->dirID, NULL, &tmp)); @@ -145,19 +157,37 @@ InitOptObject(void) /* ComponentsWin options */ for (i=0; iopt->compSelected[i] = kNotSelected; + { + if (gControls->cfg->st[0].comp[i] == kNotInSetupType) + gControls->opt->compSelected[i] = kNotSelected; + else if (gControls->cfg->st[0].comp[i] == kInSetupType) + gControls->opt->compSelected[i] = kSelected; + } } void InitControlsObject(void) { gControls = (InstWiz *) NewPtrClear(sizeof(InstWiz)); + if (!gControls) + { + ErrorHandler(); + return; + } + gControls->lw = (LicWin *) NewPtrClear(sizeof(LicWin)); gControls->ww = (WelcWin *) NewPtrClear(sizeof(WelcWin)); gControls->stw = (SetupTypeWin *) NewPtrClear(sizeof(SetupTypeWin)); gControls->cw = (CompWin *) NewPtrClear(sizeof(CompWin)); gControls->tw = (TermWin*) NewPtrClear(sizeof(TermWin)); -//dougt: what happens when allocation fails! + + if (!gControls->lw || !gControls->ww || !gControls->stw || + !gControls->cw || !gControls->tw) + { + ErrorHandler(); + } + + return; } void InitManagers(void) @@ -178,14 +208,17 @@ void InitManagers(void) void MakeMenus(void) { -//dougt: the use of ErrorHandler is wrong here. Since it will not 'exit to shell', execution will continue which is not desired. Handle mbarHdl; MenuHandle menuHdl; OSErr err; if ( !(mbarHdl = GetNewMBar( rMBar)) ) + { ErrorHandler(); - SetMenuBar(mbarHdl); //dougt: if mbarHdl allocation failes above, poof. + return; + } + + SetMenuBar(mbarHdl); if (menuHdl = GetMenuHandle(mApple)) { @@ -215,20 +248,30 @@ void MainEventLoop(void) { EventRecord evt; Boolean notHandled = true; + THz ourHZ; while (!gDone) - { - YieldToAnyThread(); /* SmartDownload dialog thread */ + { + if (gSDDlg) + YieldToAnyThread(); /* SmartDownload dialog thread */ - if (!gDone) /* after cx switch back ensure not done */ + if (!gDone && !bInShutdown) /* after cx switch back ensure not done */ { if(WaitNextEvent(everyEvent, &evt, 0, NULL)) { + if (gSDDlg) + { + ourHZ = GetZone(); #ifdef SDINST_IS_DLL - notHandled = gSDIEvtHandler(&evt); + notHandled = gSDIEvtHandler(&evt); #else - notHandled = SDI_HandleEvent(&evt); + notHandled = SDI_HandleEvent(&evt); #endif + SetZone(ourHZ); + } + else + notHandled = true; + if (notHandled) HandleNextEvent(&evt); } @@ -247,6 +290,12 @@ void ErrorHandler(void) void Shutdown(void) { + WindowPtr frontWin; + long MIWMagic = 0; + + bInShutdown = true; + UnloadSDLib(&gConnID); + /* deallocate config object */ // TO DO @@ -254,17 +303,37 @@ void Shutdown(void) // TO DO /* deallocate all controls */ -//dougt: check for null before deleting! - DisposePtr( (char*) gControls->lw); - // DisposeControl(gControls->nextB); - // DisposeControl(gControls->backB); - DisposePtr( (char*) gControls->ww); - DisposePtr( (char*) gControls->stw); - DisposePtr( (char*) gControls->cw); - DisposePtr( (char*) gControls->tw); + +#if 0 +/* XXX gets dispose by DisposeWindow() ? */ + if (gControls->nextB) + DisposeControl(gControls->nextB); + if (gControls->backB) + DisposeControl(gControls->backB); +#endif - DisposePtr( (char*) gControls); - DisposeWindow(gWPtr); + if (gControls->lw) + DisposePtr( (char*) gControls->lw); + if (gControls->ww) + DisposePtr( (char*) gControls->ww); + if (gControls->stw) + DisposePtr( (char*) gControls->stw); + if (gControls->cw) + DisposePtr( (char*) gControls->cw); + if (gControls->tw) + DisposePtr( (char*) gControls->tw); - UnloadSDLib(&gConnID); + if (gControls) + DisposePtr( (char*) gControls); + + frontWin = FrontWindow(); + MIWMagic = GetWRefCon(frontWin); + if (MIWMagic != kMIWMagic) + if (gWPtr) + BringToFront(gWPtr); + if (gWPtr) + { + HideWindow(gWPtr); + DisposeWindow(gWPtr); + } } \ No newline at end of file diff --git a/xpinstall/wizard/mac/src/MacInstallWizard.h b/xpinstall/wizard/mac/src/MacInstallWizard.h index 143fd4f1b2b..8bd48998ef9 100644 --- a/xpinstall/wizard/mac/src/MacInstallWizard.h +++ b/xpinstall/wizard/mac/src/MacInstallWizard.h @@ -78,11 +78,13 @@ if (err) \ #define NUM_WINS 5 -#define LICENSE 0 /* window object ids */ -#define WELCOME 1 -#define SETUP_TYPE 2 -#define COMPONENTS 3 -#define TERMINAL 4 +#define kLicenseID 0 /* window object ids */ +#define kWelcomeID 1 +#define kSetupTypeID 2 +#define kComponentsID 3 +#define kTerminalID 4 + +#define kMIWMagic 0x0F00BAA0 #define NGINST 1 /* event handling modes */ #define SDI 2 @@ -120,7 +122,8 @@ if (err) \ #define kNotSelected 0 #define kSelected 1 #define kNotInSetupType 0 -#define kInSetupType 1 /* end constants */ +#define kInSetupType 1 +#define kMaxCoreFiles 256 /* end constants */ #define rRootWin 128 /* widget rsrc ids */ @@ -369,6 +372,7 @@ extern WindowPtr gWPtr; extern short gCurrWin; extern InstWiz *gControls; extern Boolean gDone; +extern Boolean gSDDlg; extern EventProc gSDIEvtHandler; extern SDI_NETINSTALL gInstFunc; @@ -509,10 +513,12 @@ OSErr ExtractCoreFile(void); OSErr AppleSingleDecode(FSSpecPtr, FSSpecPtr); void ResolveDirs(char *, char*); OSErr ForceMoveFile(short, long, ConstStr255Param, long); +OSErr CleanupExtractedFiles(void); /*-----------------------------------------------------------* * XPInstallGlue *-----------------------------------------------------------*/ +OSErr RunAllXPIs(short vRefNum, long dirID); OSErr RunXPI(FSSpec&, FSSpec&); /* NB: ** See XPInstallGlue.c for rest of prototypes diff --git a/xpinstall/wizard/mac/src/Parser.c b/xpinstall/wizard/mac/src/Parser.c index 77e8f08c548..cc8d15c63db 100644 --- a/xpinstall/wizard/mac/src/Parser.c +++ b/xpinstall/wizard/mac/src/Parser.c @@ -20,7 +20,6 @@ * Samir Gehani */ - #include "MacInstallWizard.h" @@ -65,10 +64,9 @@ ParseConfig(void) OSErr err; char *cfgText; - gControls->cfg = (Config*) NewPtrClear(sizeof(Config)); -//dougt: what happens when allocation fails! + gControls->cfg = (Config*) NewPtrClear(sizeof(Config)); - if(!ReadConfigFile(&cfgText)) + if(!gControls->cfg || !ReadConfigFile(&cfgText)) { ErrorHandler(); return; @@ -88,43 +86,42 @@ ParseConfig(void) Boolean ReadConfigFile(char **text) { -//dougt: nitpick, I would have the initial bSuccess set to false, and only change to true when this function really -// succeeds. If you also set text to null from the get go, you can return the else statement during the read -// of the file. - Boolean bSuccess = true; + Boolean bSuccess = false; OSErr err; FSSpec cfgFile; long dirID, dataSize; - short vRefNum; + short vRefNum, fileRefNum; Str255 fname; + *text = nil; + ERR_CHECK_RET(GetCWD(&dirID, &vRefNum), false); /* open config.ini file */ GetIndString(fname, rStringList, sConfigFName); if (err = FSMakeFSSpec(vRefNum, dirID, fname, &cfgFile) ) return false; - if (err = FSpOpenDF( &cfgFile, fsRdPerm, &vRefNum)) + if (err = FSpOpenDF( &cfgFile, fsRdPerm, &fileRefNum)) return false; /* read in entire text */ - if (err = GetEOF(vRefNum, &dataSize)) + if (err = GetEOF(fileRefNum, &dataSize)) bSuccess = false; if (dataSize > 0) { *text = (char*) NewPtrClear(dataSize); -//dougt: what happens when allocation fails! - if (err = FSRead(vRefNum, &dataSize, *text)) - bSuccess = false; + if (!(*text)) + { + ErrorHandler(); + return false; + } + + if ((err = FSRead(fileRefNum, &dataSize, *text)) == noErr) + bSuccess = true; } - else - { - *text = nil; - bSuccess = false; - } - + /* close file */ - if (err = FSClose(vRefNum)) + if (!bSuccess || (err = FSClose(fileRefNum))) return false; return bSuccess; @@ -137,7 +134,12 @@ PopulateLicWinKeys(char *cfgText) /* LicenseWin: license file name */ gControls->cfg->licFileName = NewHandleClear(kValueMaxLen); -//dougt: what happens when allocation fails! + if (!gControls->cfg->licFileName) + { + ErrorHandler(); + return eParseFailed; + } + if (!FillKeyValueUsingResID(sLicDlg, sLicFile, gControls->cfg->licFileName, cfgText)) err = eParseFailed; @@ -151,21 +153,41 @@ PopulateWelcWinKeys(char *cfgText) /* WelcomeWin: message strings */ gControls->cfg->welcMsg[0] = NewHandleClear(kValueMaxLen); -//dougt: what happens when allocation fails! + if (!gControls->cfg->welcMsg[0]) + { + ErrorHandler(); + return eParseFailed; + } + if (!FillKeyValueUsingResID(sWelcDlg, sMsg0, gControls->cfg->welcMsg[0], cfgText)) - err = eParseFailed; //dougt: shouldn't you return now? + { + ErrorHandler(); + return eParseFailed; + } gControls->cfg->welcMsg[1] = NewHandleClear(kValueMaxLen); -//dougt: what happens when allocation fails! + if (!gControls->cfg->welcMsg[1]) + { + ErrorHandler(); + return eParseFailed; + } -//dougt: why don;t you care about the error in this case? FillKeyValueUsingResID(sWelcDlg, sMsg1, gControls->cfg->welcMsg[1], cfgText); gControls->cfg->welcMsg[2] = NewHandleClear(kValueMaxLen); -//dougt: what happens when allocation fails! + if (!gControls->cfg->welcMsg[2]) + { + ErrorHandler(); + return eParseFailed; + } -//dougt: why don;t you care about the error in this case? -FillKeyValueUsingResID(sWelcDlg, sMsg2, gControls->cfg->welcMsg[2], cfgText); + FillKeyValueUsingResID(sWelcDlg, sMsg2, gControls->cfg->welcMsg[2], cfgText); + /* + ** NOTE: + ** We don't care if the second and third messages are not filled since by + ** definition we require only one message string to be specified in the INI + ** file. Msgs 2 and 3 are optional. + */ return err; } @@ -498,14 +520,17 @@ FillKeyValueUsingName(char *sectionName, char *keyName, Handle dest, char *cfgTe Boolean bFound = false; value = (char*) NewPtrClear(kValueMaxLen); -//dougt: what happens when allocation fails! + if (!value) + { + ErrorHandler(); + return false; + } + if (FindKeyValue(cfgText, sectionName, keyName, value)) { HLock(dest); len = strlen(value); strncpy(*dest, value, len); -//dougt: would it be better here to do the accual allocation, PtrToHandle()? -// This way we could reduce the mem footprint by not having to allocate the max each time. HUnlock(dest); bFound = true; } @@ -519,27 +544,27 @@ FindKeyValue(const char *cfg, const char *inSectionName, const char *inKey, char { char *sectionName, *section, *key, *cfgPtr[1], *sectionPtr[1]; - *cfgPtr = cfg; + *cfgPtr = (char*) cfg; sectionName = (char *) NewPtrClear( kSNameMaxLen ); section = (char *) NewPtrClear( kSectionMaxLen ); key = (char *) NewPtrClear( kKeyMaxLen ); -//dougt: what happens when allocation fails! + if (!sectionName || !section || !key) + { + ErrorHandler(); + return false; + } /* find next section [cfgPtr moved past next section per iteration] */ -//dougt: you are passing a pointer (cfgPtr) to a function that wants a char**. evil while(GetNextSection(cfgPtr, sectionName, section)) - { -//dougt: why not use strcmp here? + { if (strncmp(sectionName, inSectionName, strlen(inSectionName)) == 0) { *sectionPtr = section; /* find next key [sectionPtr moved past next key per iteration] */ -//dougt: you are passing a pointer (sectionPtr) to a function that wants a char**. evil while(GetNextKeyVal(sectionPtr, key, outValue)) { -//dougt: why not use strcmp here? if (strncmp(key, inKey, strlen(key)) == 0) { if(key) @@ -697,9 +722,6 @@ GetNextKeyVal(char **inSection, char *outKey, char *outVal) * Makes a copy of the C string, converts the copy to a Pascal string, * and returns the Pascal string copy */ - -//dougt: can you use the toolbox routines? what about double bite chars? - unsigned char *CToPascal(char *str) { register char *p,*q; @@ -725,6 +747,8 @@ char *PascalToC(unsigned char *str) unsigned char * cpy; cpy = (unsigned char*)NewPtrClear( ((long)*str+1) ); + if (!cpy) + return 0; strncpy((char*)cpy, (char*) str, (long)*str+1); end = cpy + *cpy; q = (p=cpy) + 1; diff --git a/xpinstall/wizard/mac/src/SetupTypeWin.c b/xpinstall/wizard/mac/src/SetupTypeWin.c index a3e645905dc..9d56760b80c 100644 --- a/xpinstall/wizard/mac/src/SetupTypeWin.c +++ b/xpinstall/wizard/mac/src/SetupTypeWin.c @@ -20,11 +20,9 @@ * Samir Gehani */ - #include "MacInstallWizard.h" - /*-----------------------------------------------------------* * Setup Type Window *-----------------------------------------------------------*/ @@ -47,57 +45,61 @@ ShowSetupTypeWin(void) Str255 instLocTitle, selectFolder; GrafPtr oldPort; GetPort(&oldPort); - //dougt: check gWPtr for null.. - SetPort(gWPtr); - //dougt: change this naming scheme before I pop. - gCurrWin = SETUP_TYPE; - /* gControls->stw = (SetupTypeWin *) NewPtrClear(sizeof(SetupTypeWin)); */ - - GetIndString(next, rStringList, sNextBtn); - GetIndString(back, rStringList, sBackBtn); - - // malloc and get controls - gControls->stw->instType = GetNewControl( rInstType, gWPtr); - gControls->stw->instDescBox = GetNewControl( rInstDescBox, gWPtr); - gControls->stw->destLocBox = GetNewControl( rDestLocBox, gWPtr); - gControls->stw->destLoc = GetNewControl(rDestLoc, gWPtr); - //dougt: check for failure; - - // populate popup button menus - //dougt: no hi - HLockHi((Handle)gControls->stw->instType); - pvtDataHdl = (PopupPrivateData **) (*(gControls->stw->instType))->contrlData; - popupMenu = (MenuHandle) (**pvtDataHdl).mHandle; - for (i=0; icfg->numSetupTypes; i++) + if (gWPtr != NULL) { - //dougt: no hi. - HLockHi(gControls->cfg->st[i].shortDesc); - currMenuItem = CToPascal(*gControls->cfg->st[i].shortDesc); - HUnlock(gControls->cfg->st[i].shortDesc); - InsertMenuItem( popupMenu, currMenuItem, i); - } - HUnlock((Handle)gControls->stw->instType); - SetControlMaximum(gControls->stw->instType, gControls->cfg->numSetupTypes); - SetControlValue(gControls->stw->instType, gControls->opt->instChoice); - //Draw1Control(gControls->stw->instType); + SetPort(gWPtr); - // setup type desc TE init and default item desc display - HLockHi((Handle)gControls->stw->instDescBox); - viewRect = (*(gControls->stw->instDescBox))->contrlRect; - HUnlock((Handle)gControls->stw->instDescBox); - InsetRect(&viewRect, kTxtRectPad, kTxtRectPad); + gCurrWin = kSetupTypeID; + /* gControls->stw = (SetupTypeWin *) NewPtrClear(sizeof(SetupTypeWin)); */ - gControls->stw->instDescTxt = (TEHandle) NewPtrClear(sizeof(TEPtr)); - TextFont(systemFont); - TextFace(normal); - TextSize(12); - gControls->stw->instDescTxt = TENew( &viewRect, &viewRect); - HLockHi(gControls->cfg->st[gControls->opt->instChoice - 1].longDesc); - txtSize = strlen(*gControls->cfg->st[gControls->opt->instChoice - 1].longDesc); - TEInsert( *gControls->cfg->st[gControls->opt->instChoice - 1].longDesc, txtSize, gControls->stw->instDescTxt); - TESetAlignment( teFlushDefault, gControls->stw->instDescTxt); - HUnlock(gControls->cfg->st[gControls->opt->instChoice - 1].longDesc); + GetIndString(next, rStringList, sNextBtn); + GetIndString(back, rStringList, sBackBtn); + + // malloc and get controls + gControls->stw->instType = GetNewControl( rInstType, gWPtr); + gControls->stw->instDescBox = GetNewControl( rInstDescBox, gWPtr); + gControls->stw->destLocBox = GetNewControl( rDestLocBox, gWPtr); + gControls->stw->destLoc = GetNewControl(rDestLoc, gWPtr); + if (!gControls->stw->instType || !gControls->stw->instDescBox || + !gControls->stw->destLocBox || !gControls->stw->destLoc) + { + ErrorHandler(); + return; + } + + // populate popup button menus + HLock((Handle)gControls->stw->instType); + pvtDataHdl = (PopupPrivateData **) (*(gControls->stw->instType))->contrlData; + popupMenu = (MenuHandle) (**pvtDataHdl).mHandle; + for (i=0; icfg->numSetupTypes; i++) + { + HLock(gControls->cfg->st[i].shortDesc); + currMenuItem = CToPascal(*gControls->cfg->st[i].shortDesc); + HUnlock(gControls->cfg->st[i].shortDesc); + InsertMenuItem( popupMenu, currMenuItem, i); + } + HUnlock((Handle)gControls->stw->instType); + SetControlMaximum(gControls->stw->instType, gControls->cfg->numSetupTypes); + SetControlValue(gControls->stw->instType, gControls->opt->instChoice); + //Draw1Control(gControls->stw->instType); + + // setup type desc TE init and default item desc display + HLockHi((Handle)gControls->stw->instDescBox); + viewRect = (*(gControls->stw->instDescBox))->contrlRect; + HUnlock((Handle)gControls->stw->instDescBox); + InsetRect(&viewRect, kTxtRectPad, kTxtRectPad); + + gControls->stw->instDescTxt = (TEHandle) NewPtrClear(sizeof(TEPtr)); + TextFont(systemFont); + TextFace(normal); + TextSize(12); + gControls->stw->instDescTxt = TENew( &viewRect, &viewRect); + HLockHi(gControls->cfg->st[gControls->opt->instChoice - 1].longDesc); + txtSize = strlen(*gControls->cfg->st[gControls->opt->instChoice - 1].longDesc); + TEInsert( *gControls->cfg->st[gControls->opt->instChoice - 1].longDesc, txtSize, gControls->stw->instDescTxt); + TESetAlignment( teFlushDefault, gControls->stw->instDescTxt); + HUnlock(gControls->cfg->st[gControls->opt->instChoice - 1].longDesc); /* volName = (unsigned char **)NewPtrClear(sizeof(unsigned char *)); @@ -118,17 +120,18 @@ ShowSetupTypeWin(void) SetControlMaximum(gControls->stw->destLoc, numVols+2); // 2 extra for divider and "Select Folder..." item SetControlValue(gControls->stw->destLoc, 1); */ - GetIndString(selectFolder, rStringList, sSelectFolder); - SetControlTitle(gControls->stw->destLoc, selectFolder); - GetIndString(instLocTitle, rStringList, sInstLocTitle); - SetControlTitle(gControls->stw->destLocBox, instLocTitle); + GetIndString(selectFolder, rStringList, sSelectFolder); + SetControlTitle(gControls->stw->destLoc, selectFolder); + GetIndString(instLocTitle, rStringList, sInstLocTitle); + SetControlTitle(gControls->stw->destLocBox, instLocTitle); - // show controls - ShowControl(gControls->stw->instType); - ShowControl(gControls->stw->destLoc); - ShowNavButtons( back, next ); + // show controls + ShowControl(gControls->stw->instType); + ShowControl(gControls->stw->destLoc); + ShowNavButtons( back, next ); - DrawDiskNFolder(gControls->opt->vRefNum, gControls->opt->folder); + DrawDiskNFolder(gControls->opt->vRefNum, gControls->opt->folder); + } SetPort(oldPort); } @@ -154,7 +157,12 @@ OurNavEventFunction(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBa WindowPtr windowPtr; windowPtr = (WindowPtr) callBackParms->eventData.eventDataParms.event->message; - //dougt: check for null + if (!windowPtr) + { + ErrorHandler(); + return; + } + switch(callBackSelector) { case kNavCBEvent: @@ -270,7 +278,7 @@ InSetupTypeContent(EventRecord* evt, WindowPtr wCurrPtr) return; } - HLockHi((Handle)gControls->backB); + HLock((Handle)gControls->backB); r = (**(gControls->backB)).contrlRect; HUnlock((Handle)gControls->backB); if (PtInRect( localPt, &r)) @@ -285,7 +293,7 @@ InSetupTypeContent(EventRecord* evt, WindowPtr wCurrPtr) } } - HLockHi((Handle)gControls->nextB); + HLock((Handle)gControls->nextB); r = (**(gControls->nextB)).contrlRect; HUnlock((Handle)gControls->nextB); if (PtInRect( localPt, &r)) diff --git a/xpinstall/wizard/mac/src/TerminalWin.c b/xpinstall/wizard/mac/src/TerminalWin.c index 60a1319c748..39b7f3f6762 100644 --- a/xpinstall/wizard/mac/src/TerminalWin.c +++ b/xpinstall/wizard/mac/src/TerminalWin.c @@ -20,9 +20,9 @@ * Samir Gehani */ - #include "MacInstallWizard.h" + /*-----------------------------------------------------------* * Terminal Window *-----------------------------------------------------------*/ @@ -36,41 +36,47 @@ ShowTerminalWin(void) short reserr; GrafPtr oldPort; GetPort(&oldPort); - //dougt: check for gWPtr being null - SetPort(gWPtr); - - //dougt: think about changing the constant to something more readable. - gCurrWin = TERMINAL; - /* gControls->tw = (TermWin*) NewPtrClear(sizeof(TermWin)); */ - - GetIndString(next, rStringList, sInstallBtn); - GetIndString(back, rStringList, sBackBtn); - - // malloc and get control - rectH = Get1Resource('RECT', rStartMsgBox); - reserr = ResError(); //dougt: this does not do what you thing. It does not always return the last error. - if (reserr == noErr) - viewRect = (Rect) **((Rect **)rectH); - else + + if (gWPtr != NULL) { - ErrorHandler(); - return; + SetPort(gWPtr); + + gCurrWin = kTerminalID; + /* gControls->tw = (TermWin*) NewPtrClear(sizeof(TermWin)); */ + + GetIndString(next, rStringList, sInstallBtn); + GetIndString(back, rStringList, sBackBtn); + + // malloc and get control + rectH = Get1Resource('RECT', rStartMsgBox); + reserr = ResError(); + if (reserr == noErr && rectH != NULL) + viewRect = (Rect) **((Rect **)rectH); + else + { + ErrorHandler(); + return; + } + + gControls->tw->startMsgBox = viewRect; + + gControls->tw->startMsg = TENew(&viewRect, &viewRect); + if (gControls->tw->startMsg == NULL) + { + ErrorHandler(); + return; + } + + // populate control + HLock(gControls->cfg->startMsg); + TESetText(*gControls->cfg->startMsg, strlen(*gControls->cfg->startMsg), + gControls->tw->startMsg); + HUnlock(gControls->cfg->startMsg); + + // show controls + TEUpdate(&viewRect, gControls->tw->startMsg); + ShowNavButtons( back, next ); } - gControls->tw->startMsgBox = viewRect; - - gControls->tw->startMsg = TENew(&viewRect, &viewRect); - //dougt: check for null - - // populate control - //dougt: remove hi. - HLockHi(gControls->cfg->startMsg); - TESetText(*gControls->cfg->startMsg, strlen(*gControls->cfg->startMsg), - gControls->tw->startMsg); - HUnlock(gControls->cfg->startMsg); - - // show controls - TEUpdate(&viewRect, gControls->tw->startMsg); - ShowNavButtons( back, next); SetPort(oldPort); } diff --git a/xpinstall/wizard/mac/src/WelcomeWin.c b/xpinstall/wizard/mac/src/WelcomeWin.c index 9c2342f764c..cbbc08e785a 100644 --- a/xpinstall/wizard/mac/src/WelcomeWin.c +++ b/xpinstall/wizard/mac/src/WelcomeWin.c @@ -38,42 +38,44 @@ ShowWelcomeWin(void) GrafPtr oldPort; GetPort(&oldPort); - SetPort(gWPtr); - -//dougt: think about changing this to a constant that is more understandable. - gCurrWin = WELCOME; - /* gControls->ww = (WelcWin *) NewPtrClear(sizeof(WelcWin)); */ - - GetIndString(next, rStringList, sNextBtn); - GetIndString(back, rStringList, sBackBtn); - - gControls->ww->scrollBar = GetNewControl( rLicScrollBar, gWPtr); - gControls->ww->welcBox = GetNewControl( rLicBox, gWPtr); -//dougt: you may want to do something in addition to a check for failure - if(gControls->ww->scrollBar && gControls->ww->welcBox) + if (gWPtr != NULL) { - //dougt: no hi. - HLockHi( (Handle) gControls->ww->scrollBar); - sbRect = (*(gControls->ww->welcBox))->contrlRect; - - sbWidth = (*(gControls->ww->scrollBar))->contrlRect.right - - (*(gControls->ww->scrollBar))->contrlRect.left; - - (*(gControls->ww->scrollBar))->contrlRect.right = sbRect.right + kScrollBarPad; - (*(gControls->ww->scrollBar))->contrlRect.left = sbRect.right + kScrollBarPad - - sbWidth; - (*(gControls->ww->scrollBar))->contrlRect.top = sbRect.top - kScrollBarPad; - (*(gControls->ww->scrollBar))->contrlRect.bottom = sbRect.bottom + kScrollBarPad; - HUnlock( (Handle) gControls->ww->scrollBar); - } - InitWelcTxt(); + SetPort(gWPtr); - ShowNavButtons( back, next); - ShowControl( gControls->ww->scrollBar); - ShowControl( gControls->ww->welcBox); - ShowTxt(); - InitScrollBar( gControls->ww->scrollBar); + gCurrWin = kWelcomeID; + /* gControls->ww = (WelcWin *) NewPtrClear(sizeof(WelcWin)); */ + GetIndString(next, rStringList, sNextBtn); + GetIndString(back, rStringList, sBackBtn); + + gControls->ww->scrollBar = GetNewControl( rLicScrollBar, gWPtr); + gControls->ww->welcBox = GetNewControl( rLicBox, gWPtr); + + if(gControls->ww->scrollBar && gControls->ww->welcBox) + { + HLock( (Handle) gControls->ww->scrollBar); + sbRect = (*(gControls->ww->welcBox))->contrlRect; + + sbWidth = (*(gControls->ww->scrollBar))->contrlRect.right - + (*(gControls->ww->scrollBar))->contrlRect.left; + + (*(gControls->ww->scrollBar))->contrlRect.right = sbRect.right + kScrollBarPad; + (*(gControls->ww->scrollBar))->contrlRect.left = sbRect.right + kScrollBarPad - + sbWidth; + (*(gControls->ww->scrollBar))->contrlRect.top = sbRect.top - kScrollBarPad; + (*(gControls->ww->scrollBar))->contrlRect.bottom = sbRect.bottom + kScrollBarPad; + HUnlock( (Handle) gControls->ww->scrollBar); + } + InitWelcTxt(); + + ShowNavButtons( back, next); + ShowControl( gControls->ww->scrollBar); + ShowControl( gControls->ww->welcBox); + ShowTxt(); + InitScrollBar( gControls->ww->scrollBar); + } + + SetPort(oldPort); } void @@ -82,12 +84,9 @@ InitWelcTxt(void) Rect viewRect, destRect; long welcStrLen; int i; - char * newPara; /* TE specific init */ - - //dougt: no hi. - HLockHi( (Handle) gControls->ww->welcBox); + HLock( (Handle) gControls->ww->welcBox); viewRect = (*(gControls->ww->welcBox))->contrlRect; HUnlock( (Handle) gControls->ww->welcBox); @@ -96,26 +95,25 @@ InitWelcTxt(void) destRect.right = viewRect.right; destRect.top = viewRect.top; destRect.bottom = viewRect.bottom * kNumWelcScrns; /* XXX: hack */ - - gControls->ww->welcTxt = (TEHandle) NewPtrClear(sizeof(TEPtr)); - //dougt: check for null TextFont(applFont); TextFace(normal); TextSize(12); - - newPara = "\r\r"; //dougt why this constant? gControls->ww->welcTxt = TENew( &destRect, &viewRect); - //dougt: check for null. + if (!gControls->ww->welcTxt) + { + ErrorHandler(); + return; + } for (i=0; icfg->welcMsg[i]); + HLock(gControls->cfg->welcMsg[i]); welcStrLen = strlen( *gControls->cfg->welcMsg[i]); TEInsert( *gControls->cfg->welcMsg[i], welcStrLen, gControls->ww->welcTxt); HUnlock(gControls->cfg->welcMsg[i]); - TEInsert( newPara, strlen(newPara), gControls->ww->welcTxt); + TEInsert( "\r\r", 2, gControls->ww->welcTxt); } TextFont(systemFont); @@ -147,11 +145,10 @@ InWelcomeContent(EventRecord* evt, WindowPtr wCurrPtr) case kControlDownButtonPart: case kControlPageUpPart: case kControlPageDownPart: - //dougt: this point never gets destroyed. evil scrollActionFunctionUPP = NewControlActionProc((ProcPtr) DoScrollProc); value = TrackControl(scrollBar, localPt, scrollActionFunctionUPP); + DisposeRoutineDescriptor(scrollActionFunctionUPP); return; - break; case kControlIndicatorPart: value = GetControlValue(scrollBar); @@ -165,10 +162,9 @@ InWelcomeContent(EventRecord* evt, WindowPtr wCurrPtr) } } return; - break; } - //dougt: remove the hi. - HLockHi((Handle)gControls->backB); + + HLock((Handle)gControls->backB); r = (**(gControls->backB)).contrlRect; HUnlock((Handle)gControls->backB); if (PtInRect( localPt, &r)) @@ -182,8 +178,7 @@ InWelcomeContent(EventRecord* evt, WindowPtr wCurrPtr) } } - //dougt: remove the hi. - HLockHi((Handle)gControls->nextB); + HLock((Handle)gControls->nextB); r = (**(gControls->nextB)).contrlRect; HUnlock((Handle)gControls->nextB); if (PtInRect( localPt, &r)) diff --git a/xpinstall/wizard/mac/src/XPInstallGlue.c b/xpinstall/wizard/mac/src/XPInstallGlue.c index 11d0bc35e21..487ec3822da 100644 --- a/xpinstall/wizard/mac/src/XPInstallGlue.c +++ b/xpinstall/wizard/mac/src/XPInstallGlue.c @@ -22,6 +22,7 @@ #include "MacInstallWizard.h" + #define XP_MAC 1 #include "xpistub.h" @@ -50,16 +51,16 @@ void xpicbStart(const char *URL, const char* UIName); void xpicbProgress(const char* msg, PRInt32 val, PRInt32 max); void xpicbFinal(const char *URL, PRInt32 finalStatus); -//dougt: has nothing to do with xpcom. Use the one in MacInstallWizard.h. -#define XPCOM_ERR_CHECK(_call) \ +#define XPI_ERR_CHECK(_call) \ rv = _call; \ if (NS_FAILED(rv)) \ { \ ErrorHandler(); \ return rv; \ } -//dougt: should be pulled from an ini file. This file may have a different name. -#define XPISTUB_DLL "\pxpistubDebug.shlb"; + +/* XXX temporary... */ +#define XPISTUB_DLL "\pxpistubDebug.shlb" void @@ -86,6 +87,25 @@ xpicbFinal(const char *URL, PRInt32 finalStatus) return; } +OSErr +RunAllXPIs(short vRefNum, long dirID) +{ + OSErr err = noErr; + FSSpec tgtDirSpec, xpiSpec; + + // TO DO + // enumerate through all .xpi's + + err = FSMakeFSSpec(vRefNum, dirID, "\pmozilla.jar", &xpiSpec); + err = FSMakeFSSpec(vRefNum, dirID, 0, &tgtDirSpec); + if (err==noErr) + err = RunXPI(xpiSpec, tgtDirSpec); + else + ErrorHandler(); + + return err; +} + OSErr RunXPI(FSSpec& aXPI, FSSpec& aTargetDir) { @@ -99,9 +119,9 @@ RunXPI(FSSpec& aXPI, FSSpec& aTargetDir) ERR_CHECK_RET(LoadXPIStub(&xpi_initProc, &xpi_installProc, &xpi_exitProc, &connID, aTargetDir), err); - XPCOM_ERR_CHECK(xpi_initProc( aTargetDir, xpicbStart, xpicbProgress, xpicbFinal )); + XPI_ERR_CHECK(xpi_initProc( aTargetDir, xpicbStart, xpicbProgress, xpicbFinal )); - XPCOM_ERR_CHECK(xpi_installProc( aXPI, "", flags )); + XPI_ERR_CHECK(xpi_installProc( aXPI, "", flags )); xpi_exitProc(); UnloadXPIStub(&connID); @@ -134,8 +154,8 @@ LoadXPIStub(XPI_InitProc* pfnInit, XPI_InstallProc* pfnInstall, XPI_ExitProc* pf err = FSMakeFSSpec(currVRefNum, currDirID, fragName, &fslib); if (err!=noErr) return err; - //dougt: verify the use of the constant kPrivateCFragCopy. - err = GetDiskFragment(&fslib, kWholeFork, kCFragGoesToEOF, nil, kPrivateCFragCopy/*kReferenceCFrag*/, connID, &mainAddr, errName); + + err = GetDiskFragment(&fslib, 0, kCFragGoesToEOF, nil, /*kPrivateCFragCopy*/kReferenceCFrag, connID, &mainAddr, errName); if ( err == noErr && *connID != NULL) { @@ -155,12 +175,11 @@ LoadXPIStub(XPI_InitProc* pfnInit, XPI_InstallProc* pfnInstall, XPI_ExitProc* pf Boolean UnloadXPIStub(CFragConnectionID* connID) { -//dougt: what happens if connID is null... evil - if (*connID != NULL) + if ((connID != NULL) && (*connID != NULL)) { CloseConnection(connID); *connID = NULL; - return true; + return true; } return false;