Hook libxpnet into the mac installer (and UI polish friends).

This commit is contained in:
sgehani%netscape.com 2001-03-14 06:58:44 +00:00
Родитель 249a4a6681
Коммит eb141506a3
18 изменённых файлов: 1131 добавлений и 773 удалений

Просмотреть файл

@ -9,7 +9,7 @@ License File=License
[Dialog Welcome]
; *** LOCALIZE ME BABY ***
Message0= Welcome to the Mozilla Installer
Message0=Welcome to the Mozilla Installer
; *** LOCALIZE ME BABY ***
Message1=It is strongly recommended that you quit all applications before running this installer.
; *** LOCALIZE ME BABY ***
@ -21,7 +21,7 @@ Message2=Click Continue to proceed with this installation.
; *** LOCALIZE ME BABY ***
Description Short=Typical Install
; *** LOCALIZE ME BABY ***
Description Long=Click Continue to install the following components:
Description Long=Installs the most common options. Quickest to download; recommended for most users.
C0=Component0
C1=Component1
C2=Component2

Двоичные данные
xpinstall/wizard/mac/macbuild/MIW.mcp

Двоичный файл не отображается.

Просмотреть файл

@ -9,7 +9,7 @@ License File=License
[Dialog Welcome]
; *** LOCALIZE ME BABY ***
Message0= Welcome to the Mozilla Installer
Message0=Welcome to the Mozilla Installer
; *** LOCALIZE ME BABY ***
Message1=It is strongly recommended that you quit all applications before running this installer.
; *** LOCALIZE ME BABY ***
@ -21,7 +21,7 @@ Message2=Click Continue to proceed with this installation.
; *** LOCALIZE ME BABY ***
Description Short=Typical Install
; *** LOCALIZE ME BABY ***
Description Long=Click Continue to install the following components:
Description Long=Installs the most common options. Quickest to download; recommended for most users.
C0=Component0
C1=Component1
C2=Component2

Двоичные данные
xpinstall/wizard/mac/rsrc/MIWCommon.rsrc

Двоичный файл не отображается.

Двоичные данные
xpinstall/wizard/mac/rsrc/Mozilla.rsrc

Двоичный файл не отображается.

Двоичные данные
xpinstall/wizard/mac/rsrc/Netscape.rsrc

Двоичный файл не отображается.

Просмотреть файл

@ -94,7 +94,7 @@ ShowAdditionsWin(void)
SetPt( &cSize, 0, 0);
gControls->aw->compList = LNew((const Rect*)&gControls->aw->compListBox, (const Rect*)&dataBounds,
cSize, rCheckboxLDEF, gWPtr, true, false, false, true);
(*gControls->aw->compList)->selFlags = 68; /* NOTE: 64 (aka lExtendDrag) + 4 (aka lUseSense) = 68 */
(*gControls->aw->compList)->selFlags = lExtendDrag + lUseSense + lDoVAutoscroll;
HLock((Handle)gControls->aw->compDescBox);
SetRect(&viewRect, (*gControls->aw->compDescBox)->contrlRect.left,
@ -139,7 +139,17 @@ ShowAdditionsWin(void)
// default highlight first row
AddInitRowHighlight(0);
#if 0
RGBColor backColorOld;
Rect adjustedRect, *clRect = &gControls->aw->compListBox;
SetRect(&adjustedRect, clRect->left, clRect->top+1, clRect->right, clRect->bottom-1);
GetBackColor(&backColorOld);
BackColor(whiteColor);
EraseRect(&adjustedRect);
RGBBackColor(&backColorOld);
#endif
SetPort(oldPort);
}
@ -197,7 +207,7 @@ InAdditionsContent(EventRecord* evt, WindowPtr wCurrPtr)
SetRect(&r, gControls->aw->compListBox.right, gControls->aw->compListBox.top,
gControls->aw->compListBox.right + kScrollBarWidth, gControls->aw->compListBox.bottom);
if ((evt->what == mouseUp) && (PtInRect( localPt, &r)))
{
{
LClick(localPt, evt->modifiers, gControls->aw->compList);
SetRect(&r, gControls->aw->compListBox.left, gControls->aw->compListBox.top,
@ -209,6 +219,7 @@ InAdditionsContent(EventRecord* evt, WindowPtr wCurrPtr)
if ((evt->what == mouseUp) && (PtInRect( localPt, &gControls->aw->compListBox)))
{
LClick(localPt, evt->modifiers, gControls->aw->compList);
AddUpdateRowHighlight(localPt);
/* invert the checkbox rect */
for (i=0; i<numRows; i++)
@ -310,6 +321,9 @@ InAdditionsContent(EventRecord* evt, WindowPtr wCurrPtr)
part = TrackControl(gControls->nextB, evt->where, NULL);
if (part)
{
if (!VerifyDiskSpace())
return;
gControls->aw->compListBox.top = 0;
EraseRect(&gControls->aw->compListBox);
ClearDiskSpaceMsgs();
@ -337,6 +351,17 @@ UpdateAdditionsWin(void)
HLock(gControls->cfg->selAddMsg);
DrawString( CToPascal(*gControls->cfg->selAddMsg));
HUnlock(gControls->cfg->selAddMsg);
#if 0
RGBColor backColorOld;
Rect adjustedRect, *clRect = &gControls->aw->compListBox;
SetRect(&adjustedRect, clRect->left, clRect->top+1, clRect->right, clRect->bottom-1);
GetBackColor(&backColorOld);
BackColor(whiteColor);
EraseRect(&adjustedRect);
RGBBackColor(&backColorOld);
#endif
LUpdate( (*gControls->aw->compList)->port->visRgn, gControls->aw->compList);
SetRect(&r, gControls->aw->compListBox.left, gControls->aw->compListBox.top,
gControls->aw->compListBox.right + 1, gControls->aw->compListBox.bottom);
@ -368,28 +393,6 @@ UpdateAdditionsWin(void)
SetPort(oldPort);
}
void
MouseMovedInAdditionsWin(EventRecord *evt)
{
Point localPt;
GrafPtr oldPort;
GetPort(&oldPort);
if (gWPtr)
SetPort(gWPtr);
localPt = evt->where;
GlobalToLocal( &localPt );
/* if within list box rect */
if (PtInRect( localPt, &((*gControls->aw->compList)->rView) ))
{
AddUpdateRowHighlight(localPt);
}
SetPort(oldPort);
}
short
AddGetCompRow(int compIdx)
{

Просмотреть файл

@ -57,9 +57,7 @@ Draw(Boolean selected,Rect *cellRect,Cell theCell,SInt16 dataLen,
if (dataLen > 0 && componentName)
{
EraseRect(cellRect);
Highlight(cellRect, selected);
SetRect(&nameRect, cellRect->left+20, cellRect->top,
cellRect->right, cellRect->bottom);
TETextBox((char*)componentName, dataLen, &nameRect, teFlushDefault);

Просмотреть файл

@ -89,13 +89,13 @@ ShowComponentsWin(void)
(gControls->cfg->st[instChoice].comp[i] == kInSetupType))
totalRows++;
}
SetRect(&dataBounds, 0, 0, 1, totalRows);
SetPt( &cSize, 0, 0);
gControls->cw->compList = LNew((const Rect*)&gControls->cw->compListBox, (const Rect*)&dataBounds,
cSize, rCheckboxLDEF, gWPtr, true, false, false, true);
(*gControls->cw->compList)->selFlags = 68; /* NOTE: 64 (aka lExtendDrag) + 4 (aka lUseSense) = 68 */
(*gControls->cw->compList)->selFlags = lExtendDrag + lUseSense;
HLock((Handle)gControls->cw->compDescBox);
SetRect(&viewRect, (*gControls->cw->compDescBox)->contrlRect.left,
(*gControls->cw->compDescBox)->contrlRect.top,
@ -139,10 +139,17 @@ ShowComponentsWin(void)
// default highlight first row
InitRowHighlight(0);
//if (selCompMsg)
// DisposePtr((Ptr) selCompMsg);
#if 0
RGBColor backColorOld;
Rect adjustedRect, *clRect = &gControls->cw->compListBox;
SetRect(&adjustedRect, clRect->left, clRect->top+1, clRect->right, clRect->bottom-1);
GetBackColor(&backColorOld);
BackColor(whiteColor);
EraseRect(&adjustedRect);
RGBBackColor(&backColorOld);
#endif
SetPort(oldPort);
}
@ -192,6 +199,17 @@ UpdateCompWin(void)
HLock(gControls->cfg->selCompMsg);
DrawString( CToPascal(*gControls->cfg->selCompMsg));
HUnlock(gControls->cfg->selCompMsg);
#if 0
RGBColor backColorOld;
Rect adjustedRect, *clRect = &gControls->cw->compListBox;
SetRect(&adjustedRect, clRect->left, clRect->top+1, clRect->right, clRect->bottom-1);
GetBackColor(&backColorOld);
BackColor(whiteColor);
EraseRect(&adjustedRect);
RGBBackColor(&backColorOld);
#endif
LUpdate( (*gControls->cw->compList)->port->visRgn, gControls->cw->compList);
SetRect(&r, gControls->cw->compListBox.left, gControls->cw->compListBox.top,
gControls->cw->compListBox.right + 1, gControls->cw->compListBox.bottom);
@ -205,12 +223,11 @@ UpdateCompWin(void)
(*gControls->cw->compDescTxt)->viewRect.top,
(*gControls->cw->compDescTxt)->viewRect.right,
(*gControls->cw->compDescTxt)->viewRect.bottom);
HUnlock((Handle)gControls->cw->compDescTxt);
TEUpdate(&r, gControls->cw->compDescTxt);
HUnlock((Handle)gControls->cw->compDescTxt);
}
DrawDiskSpaceMsgs( gControls->opt->vRefNum );
for (i = 0; i < numRows; i++)
{
if (gControls->cfg->comp[rowToComp[i]].highlighted)
@ -219,7 +236,7 @@ UpdateCompWin(void)
break;
}
}
SetPort(oldPort);
}
@ -258,6 +275,7 @@ InComponentsContent(EventRecord* evt, WindowPtr wCurrPtr)
if ((evt->what == mouseUp) && (PtInRect( localPt, &gControls->cw->compListBox)))
{
LClick(localPt, evt->modifiers, gControls->cw->compList);
UpdateRowHighlight(localPt);
/* invert the checkbox rect */
for (i=0; i<numRows; i++)
@ -359,6 +377,13 @@ InComponentsContent(EventRecord* evt, WindowPtr wCurrPtr)
part = TrackControl(gControls->nextB, evt->where, NULL);
if (part)
{
/* if no additions perform disk space check */
if (!gControls->cfg->bAdditionsExist)
{
if (!VerifyDiskSpace())
return;
}
gControls->cw->compListBox.top = 0;
EraseRect(&gControls->cw->compListBox);
ClearDiskSpaceMsgs();
@ -374,28 +399,6 @@ InComponentsContent(EventRecord* evt, WindowPtr wCurrPtr)
SetPort(oldPort);
}
void
MouseMovedInComponentsWin(EventRecord *evt)
{
Point localPt;
GrafPtr oldPort;
GetPort(&oldPort);
if (gWPtr)
SetPort(gWPtr);
localPt = evt->where;
GlobalToLocal( &localPt );
/* if within list box rect */
if (PtInRect( localPt, &((*gControls->cw->compList)->rView) ))
{
UpdateRowHighlight(localPt);
}
SetPort(oldPort);
}
void
InitRowHighlight(int row)
{
@ -600,7 +603,7 @@ UpdateLongDesc(int row)
HLock(gControls->cfg->comp[rowToComp[row]].longDesc);
TESetText( *gControls->cfg->comp[rowToComp[row]].longDesc,
strlen(*gControls->cfg->comp[rowToComp[row]].longDesc), gControls->cw->compDescTxt);
TEUpdate( &viewRect, gControls->cw->compDescTxt);
TEUpdate(&viewRect, gControls->cw->compDescTxt);
HUnlock(gControls->cfg->comp[rowToComp[row]].longDesc);
}

Просмотреть файл

@ -125,11 +125,11 @@ void HandleKeyDown(EventRecord* evt)
switch(gCurrWin)
{
case kLicenseID:
case kWelcomeID:
KillControls(gWPtr);
ShowWelcomeWin();
ShowLicenseWin();
return;
case kWelcomeID:
case kLicenseID:
KillControls(gWPtr);
ShowSetupTypeWin();
return;
@ -160,7 +160,7 @@ void HandleKeyDown(EventRecord* evt)
if (!gInstallStarted)
{
DisableNavButtons();
ClearSiteSelector();
ClearDownloadSettings();
gInstallStarted = true;
SpawnSDThread(Install, &tid);
}
@ -180,6 +180,7 @@ void HandleKeyDown(EventRecord* evt)
{
case 'Q':
case 'q':
case '.':
gDone = true;
break;
@ -230,8 +231,9 @@ void HandleUpdateEvt(EventRecord* evt)
switch(gCurrWin)
{
case kLicenseID:
case kWelcomeID:
break;
case kLicenseID:
ShowTxt();
break;
case kSetupTypeID:
@ -333,18 +335,7 @@ void HandleOSEvt(EventRecord* evt)
InvalRect(&gWPtr->portRect);
}
case mouseMovedMessage:
switch(gCurrWin)
{
case kComponentsID:
MouseMovedInComponentsWin(evt);
break;
case kAdditionsID:
MouseMovedInAdditionsWin(evt);
break;
default:
break;
}
default:
break;
}
@ -352,6 +343,9 @@ void HandleOSEvt(EventRecord* evt)
void React2InContent(EventRecord* evt, WindowPtr wCurrPtr)
{
if (DidUserCancel(evt))
return;
switch (gCurrWin)
{
case kLicenseID:
@ -383,3 +377,34 @@ void React2InContent(EventRecord* evt, WindowPtr wCurrPtr)
break;
}
}
Boolean
DidUserCancel(EventRecord *evt)
{
GrafPtr oldPort;
Boolean bUserCancelled = false;
Point localPt;
Rect r;
ControlPartCode part;
GetPort(&oldPort);
SetPort(gWPtr);
localPt = evt->where;
GlobalToLocal(&localPt);
HLock((Handle)gControls->cancelB);
r = (**(gControls->cancelB)).contrlRect;
HUnlock((Handle)gControls->cancelB);
if (PtInRect(localPt, &r))
{
part = TrackControl(gControls->cancelB, evt->where, NULL);
if (part)
{
gDone = true;
bUserCancelled = true;
}
}
SetPort(oldPort);
return bUserCancelled;
}

Просмотреть файл

@ -22,28 +22,34 @@
#include "MacInstallWizard.h"
#include "nsFTPConn.h"
#include "nsHTTPConn.h"
/*-----------------------------------------------------------*
* Install Action
*-----------------------------------------------------------*/
static Boolean bXPIsExisted = true;
static long sCurrTotalDLSize = 0;
// info for download progress callback
static int sCurrComp = 0;
static Handle sCurrFullPath = 0;
static int sCurrFullPathLen = 0;
static char *sCurrURL = 0;
static time_t sCurrStartTime; /* start of download of current file */
pascal void* Install(void* unused)
{
short vRefNum, srcVRefNum;
long dirID, srcDirID, modulesDirID;
OSErr err;
FSSpec idiSpec, coreFileSpec;
#if MOZILLA == 0
FSSpec redirectSpec;
HRESULT dlErr;
FSSpec coreFileSpec;
short dlErr;
short siteIndex;
#endif
#ifdef MIW_DEBUG
FSSpec tmpSpec;
#endif /* MIW_DEBUG */
SDISTRUCT sdistruct;
Str255 pIDIfname, pModulesDir;
StringPtr coreFile = NULL;
THz ourHZ = NULL;
@ -97,71 +103,32 @@ pascal void* Install(void* unused)
GetIndString(pIDIfname, rStringList, sTempIDIName);
/* preparing to download */
gSDDlg = true;
ourHZ = GetZone();
GetPort(&oldPort);
#if MOZILLA == 0
HLock(gControls->cfg->redirect.subpath);
if (gControls->cfg->redirect.subpath && *(gControls->cfg->redirect.subpath))
{
HUnlock(gControls->cfg->redirect.subpath);
/* replace global URL from redirect.ini */
if (DownloadRedirect(vRefNum, dirID, &redirectSpec))
ParseRedirect(&redirectSpec);
}
else
{
HUnlock(gControls->cfg->redirect.subpath);
/* otherwise if site selector exists, replace global URL with selected site */
if (gControls->cfg->numSites > 0)
{
if (gControls->cfg->globalURL)
DisposeHandle(gControls->cfg->globalURL);
gControls->cfg->globalURL = NewHandleClear(kValueMaxLen);
siteIndex = gControls->opt->siteChoice - 1;
HLock(gControls->cfg->globalURL);
HLock(gControls->cfg->site[siteIndex].domain);
strcpy(*(gControls->cfg->globalURL), *(gControls->cfg->site[siteIndex].domain));
HUnlock(gControls->cfg->globalURL);
HUnlock(gControls->cfg->site[siteIndex].domain);
}
/* otherwise if site selector exists, replace global URL with selected site */
if (gControls->cfg->numSites > 0)
{
if (gControls->cfg->globalURL)
DisposeHandle(gControls->cfg->globalURL);
gControls->cfg->globalURL = NewHandleClear(kValueMaxLen);
siteIndex = gControls->opt->siteChoice - 1;
HLock(gControls->cfg->globalURL);
HLock(gControls->cfg->site[siteIndex].domain);
strcpy(*(gControls->cfg->globalURL), *(gControls->cfg->site[siteIndex].domain));
HUnlock(gControls->cfg->globalURL);
HUnlock(gControls->cfg->site[siteIndex].domain);
}
#endif /* MOZILLA == 0 */
/* generate idi */
if (!GenerateIDIFromOpt(pIDIfname, dirID, vRefNum, &idiSpec))
{
ErrorHandler(err);
return (void*) nil;
}
/* populate SDI struct */
sdistruct.dwStructSize = sizeof(SDISTRUCT);
sdistruct.fsIDIFile = idiSpec;
sdistruct.dlDirVRefNum = srcVRefNum;
sdistruct.dlDirID = srcDirID;
sdistruct.hwndOwner = NULL;
/* call SDI_NetInstall */
#if MOZILLA == 0
#if SDINST_IS_DLL == 1
dlErr = gInstFunc(&sdistruct);
#else
dlErr = SDI_NetInstall(&sdistruct);
#endif /* SDINST_IS_DLL */
InitDLProgControls();
dlErr = DownloadXPIs(srcVRefNum, srcDirID);
if (dlErr != 0)
{
if (dlErr != 0x800704C7)
ErrorHandler(dlErr);
else
gDone = true;
ErrorHandler(dlErr);
return (void*) nil;
}
#endif /* MOZILLA */
ClearDLProgControls();
SetPort(oldPort);
@ -179,10 +146,7 @@ pascal void* Install(void* unused)
SetPort(oldPort);
}
SetZone(ourHZ);
gSDDlg = false;
FSpDelete(&idiSpec);
}
}
else
bCoreExists = true;
/* otherwise core exists in cwd:InstallerModules, different from extraction location */
@ -214,7 +178,7 @@ pascal void* Install(void* unused)
DisposePtr((Ptr)coreFile);
return (void*) nil;
}
/* run all .xpi's through XPInstall */
err = RunAllXPIs(srcVRefNum, srcDirID, vRefNum, dirID);
if (err!=noErr)
@ -235,11 +199,9 @@ pascal void* Install(void* unused)
if (err == noErr && gControls->cfg->numRunApps > 0)
RunApps();
#if MOZILLA == 0
/* cleanup downloaded .xpis */
// cleanup downloaded .xpis
if (!gControls->opt->saveBits && !bXPIsExisted)
DeleteXPIs(srcVRefNum, srcDirID); /* "Installer Modules" folder location is supplied */
#endif
DeleteXPIs(srcVRefNum, srcDirID); // "Installer Modules" folder location is supplied
/* wind down app */
gDone = true;
@ -247,207 +209,397 @@ pascal void* Install(void* unused)
return (void*) 0;
}
#define GETRED_BUF_SIZE 512
Boolean
DownloadRedirect(short vRefNum, long dirID, FSSpecPtr redirectINI)
long
ComputeTotalDLSize(void)
{
Boolean bSuccess = true;
char buf[GETRED_BUF_SIZE], *leaf = NULL;
FSSpec getRedirectIDI;
short refNum;
long count;
SDISTRUCT sdistruct;
StringPtr pLeaf = NULL;
OSErr err = noErr;
/* generate IDI */
memset(buf, 0, GETRED_BUF_SIZE);
int i, compsDone, instChoice;
long totalDLSize = 0;
compsDone = 0;
instChoice = gControls->opt->instChoice-1;
/*
[Netscape Install]
no_ads=true
silent=false
confirm_install=true
execution=false
*/
strcpy(buf, "[Netscape Install]\r");
strcat(buf, "no_ads=true\r");
strcat(buf, "silent=false\r");
strcat(buf, "confirm_install=true\r");
strcat(buf, "execution=false\r\r");
/* [File0] */
strcat(buf, "[File0]\r");
strcat(buf, "desc=");
HLock(gControls->cfg->redirect.desc);
strcat(buf, *(gControls->cfg->redirect.desc));
HUnlock(gControls->cfg->redirect.desc);
strcat(buf, "\r");
/* 1=URL */
strcat(buf, "1=");
// loop through 0 to kMaxComponents
for(i=0; i<kMaxComponents; i++)
{
// general test: if component in setup type
if ( (gControls->cfg->st[instChoice].comp[i] == kInSetupType) &&
(compsDone < gControls->cfg->st[instChoice].numComps) )
{
// if custom and selected -or- not custom setup type
if ( ((instChoice == gControls->cfg->numSetupTypes-1) &&
(gControls->cfg->comp[i].selected == true)) ||
(instChoice < gControls->cfg->numSetupTypes-1) )
{
totalDLSize += gControls->cfg->comp[i].size;
compsDone++;
}
}
else if (compsDone >= gControls->cfg->st[instChoice].numComps)
break;
}
return totalDLSize;
}
/* get domain of selected site */
HLock(gControls->cfg->site[gControls->opt->siteChoice-1].domain);
strcat(buf, *(gControls->cfg->site[gControls->opt->siteChoice-1].domain));
HUnlock(gControls->cfg->site[gControls->opt->siteChoice-1].domain);
short
DownloadXPIs(short destVRefNum, long destDirID)
{
short rv = 0;
Handle dlPath;
short dlPathLen = 0;
int i, compsDone, instChoice;
GetFullPath(destVRefNum, destDirID, "\p", &dlPathLen, &dlPath);
compsDone = 0;
instChoice = gControls->opt->instChoice-1;
/* tack on redirect subpath (usually just the file leaf name) */
HLock(gControls->cfg->redirect.subpath);
strcat(buf, *(gControls->cfg->redirect.subpath));
HUnlock(gControls->cfg->redirect.subpath);
strcat(buf, "\r");
/* write out buffer to temp location */
err = FSMakeFSSpec(vRefNum, dirID, "\pGetRedirect.idi", &getRedirectIDI);
if (err == noErr)
FSpDelete(&getRedirectIDI);
err = FSpCreate(&getRedirectIDI, 'NSCP', 'TEXT', smSystemScript);
if ((err != noErr) && (err != dupFNErr))
// loop through 0 to kMaxComponents
for(i=0; i<kMaxComponents; i++)
{
ErrorHandler(err);
return false;
}
err = FSpOpenDF(&getRedirectIDI, fsRdWrPerm, &refNum);
if (err != noErr)
{
bSuccess = false;
goto BAIL;
}
count = strlen(buf);
if (count <= 0)
{
bSuccess = false;
goto BAIL;
}
err = FSWrite(refNum, &count, (void*) buf);
if (err != noErr)
bSuccess = false;
FSClose(refNum);
if (!bSuccess)
goto BAIL;
/* populate SDI struct */
sdistruct.dwStructSize = sizeof(SDISTRUCT);
sdistruct.fsIDIFile = getRedirectIDI;
sdistruct.dlDirVRefNum = vRefNum;
sdistruct.dlDirID = dirID;
sdistruct.hwndOwner = NULL;
/* call SDI_NetInstall */
#if MOZILLA == 0
#if SDINST_IS_DLL == 1
gInstFunc(&sdistruct);
#else
SDI_NetInstall(&sdistruct);
#endif /* SDINST_IS_DLL */
#endif /* MOZILLA */
bSuccess = false;
/* verify redirect.ini existence */
HLock(gControls->cfg->redirect.subpath);
leaf = strrchr(*(gControls->cfg->redirect.subpath), '/');
if (!leaf)
leaf = *(gControls->cfg->redirect.subpath);
else
leaf++;
pLeaf = CToPascal(leaf);
HUnlock(gControls->cfg->redirect.subpath);
err = FSMakeFSSpec(vRefNum, dirID, pLeaf, redirectINI);
if (err == noErr)
bSuccess = true;
BAIL:
if (!bSuccess)
FSMakeFSSpec(0, 0, "\p", redirectINI);
// general test: if component in setup type
if ( (gControls->cfg->st[instChoice].comp[i] == kInSetupType) &&
(compsDone < gControls->cfg->st[instChoice].numComps) )
{
// if custom and selected -or- not custom setup type
if ( ((instChoice == gControls->cfg->numSetupTypes-1) &&
(gControls->cfg->comp[i].selected == true)) ||
(instChoice < gControls->cfg->numSetupTypes-1) )
{
// set up vars for dl callback to use
sCurrComp = i;
sCurrFullPath = dlPath;
sCurrFullPathLen = dlPathLen;
// download given full path and archive name
rv = DownloadFile(dlPath, dlPathLen, gControls->cfg->comp[i].archive);
if (rv != 0)
{
ErrorHandler(rv);
break;
}
compsDone++;
}
}
else if (compsDone >= gControls->cfg->st[instChoice].numComps)
break;
}
return rv;
}
if (pLeaf)
DisposePtr((Ptr)pLeaf);
return bSuccess;
const char kHTTP[8] = "http://";
const char kFTP[7] = "ftp://";
short
DownloadFile(Handle destFolder, long destFolderLen, Handle archive)
{
short rv = 0;
char *URL = 0, *proxyServerURL = 0, *destFile = 0, *destFolderCopy = 0;
int globalURLLen, archiveLen, proxyServerURLLen;
char *ftpHost = 0, *ftpPath = 0;
// make URL using globalURL
HLock(archive);
HLock(gControls->cfg->globalURL);
globalURLLen = strlen(*gControls->cfg->globalURL);
archiveLen = strlen(*archive);
URL = (char *) malloc(globalURLLen + archiveLen + 1); // add 1 for NULL termination
sprintf(URL, "%s%s", *gControls->cfg->globalURL, *archive);
HUnlock(gControls->cfg->globalURL);
// set up for dl progress callback
sCurrURL = URL;
// make dest file using dest folder and archive name
HLock(destFolder);
destFolderCopy = (char *) malloc(destFolderLen + 1); // GetFullPath doesn't NULL terminate
if (! destFolderCopy)
{
HUnlock(destFolder);
return eMem;
}
strncpy(destFolderCopy, *destFolder, destFolderLen);
*(destFolderCopy + destFolderLen) = 0;
HUnlock(destFolder);
destFile = (char *) malloc(destFolderLen + archiveLen + 1);
sprintf(destFile, "%s%s", destFolderCopy, *archive);
HUnlock(archive);
// was proxy info specified?
if (gControls->opt->proxyHost && gControls->opt->proxyPort)
{
// make HTTP URL with "http://proxyHost:proxyPort"
proxyServerURLLen = strlen(kHTTP) + strlen(gControls->opt->proxyHost) + 1 +
strlen(gControls->opt->proxyPort) + 1;
proxyServerURL = (char *) malloc(proxyServerURLLen);
sprintf(proxyServerURL, "%s%s:%s", kHTTP, gControls->opt->proxyHost, gControls->opt->proxyPort);
nsHTTPConn *conn = new nsHTTPConn(proxyServerURL);
// set proxy info: proxied URL, username, password
conn->SetProxyInfo(URL, gControls->opt->proxyUsername, gControls->opt->proxyPassword);
// open an HTTP connection
rv = conn->Open();
if (rv == nsHTTPConn::OK)
{
sCurrStartTime = time(NULL);
rv = conn->Get(DLProgressCB, destFile);
conn->Close();
}
}
// else do we have an HTTP URL?
else if (strncmp(URL, kHTTP, strlen(kHTTP)) == 0)
{
// open an HTTP connection
nsHTTPConn *conn = new nsHTTPConn(URL);
rv = conn->Open();
if (rv == nsHTTPConn::OK)
{
sCurrStartTime = time(NULL);
rv = conn->Get(DLProgressCB, destFile);
conn->Close();
}
}
// else do we have an FTP URL?
else if (strncmp(URL, kFTP, strlen(kFTP)) == 0)
{
rv = ParseFTPURL(URL, &ftpHost, &ftpPath);
if ((0 == strlen(ftpHost)) || (0 == strlen(ftpPath)))
{
rv = nsHTTPConn::E_MALFORMED_URL;
}
else
{
// open an FTP connection
nsFTPConn *conn = new nsFTPConn(ftpHost);
rv = conn->Open();
if (rv == nsFTPConn::OK)
{
sCurrStartTime = time(NULL);
rv = conn->Get(ftpPath, destFile, nsFTPConn::BINARY, 1, DLProgressCB);
conn->Close();
}
}
if (ftpHost)
free(ftpHost);
if (ftpPath)
free(ftpPath);
}
// else not supported so report an error
else
rv = nsHTTPConn::E_MALFORMED_URL;
return rv;
}
int
ParseFTPURL(char *aURL, char **aHost, char **aPath)
{
char *pos, *nextSlash, *nextColon, *end, *hostEnd;
int protoLen = strlen(kFTP);
if (!aURL || !aHost || !aPath)
return -1;
if (strncmp(aURL, kFTP, protoLen) != 0)
return nsHTTPConn::E_MALFORMED_URL;
pos = aURL + protoLen;
nextColon = strchr(pos, ':');
nextSlash = strchr(pos, '/');
// only host in URL, assume '/' for path
if (!nextSlash)
{
int copyLen;
if (nextColon)
copyLen = nextColon - pos;
else
copyLen = strlen(pos);
*aHost = (char *) malloc(copyLen + 1); // to NULL terminate
if (!aHost)
return eMem;
memset(*aHost, 0, copyLen + 1);
strncpy(*aHost, pos, copyLen);
*aPath = (char *) malloc(2);
strcpy(*aPath, "/");
return 0;
}
// normal parsing: both host and path exist
if (nextColon)
hostEnd = nextColon;
else
hostEnd = nextSlash;
*aHost = (char *) malloc(hostEnd - pos + 1); // to NULL terminate
if (!*aHost)
return eMem;
memset(*aHost, 0, hostEnd - pos + 1);
strncpy(*aHost, pos, hostEnd - pos);
*(*aHost + (hostEnd - pos)) = 0; // NULL terminate
pos = nextSlash;
end = aURL + strlen(aURL);
*aPath = (char *) malloc(end - pos + 1);
if (!*aPath)
{
if (*aHost)
free(*aHost);
return eMem;
}
memset(*aPath, 0, end - pos + 1);
strncpy(*aPath, pos, end - pos);
return 0;
}
void
ParseRedirect(FSSpecPtr redirectINI)
CompressToFit(char *origStr, char *outStr, int outStrLen)
{
short fileRefNum;
OSErr err = noErr;
long dataSize;
char *text = NULL, *cId = NULL, *cSection = NULL;
Str255 pSection;
int siteIndex;
Handle domainH = NULL;
/* read in text from downloaded site selector */
err = FSpOpenDF(redirectINI, fsRdPerm, &fileRefNum);
if (err != noErr)
int origStrLen;
int halfOutStrLen;
char *lastPart; // last origStr part start
if (!origStr || !outStr || outStrLen <= 0)
return;
err = GetEOF(fileRefNum, &dataSize);
if (err != noErr)
return;
if (dataSize > 0)
{
text = (char*) NewPtrClear(dataSize + 1);
if (!text)
return;
err = FSRead(fileRefNum, &dataSize, text);
if (err != noErr)
origStrLen = strlen(origStr);
halfOutStrLen = outStrLen/2;
lastPart = origStr + origStrLen - halfOutStrLen;
strncpy(outStr, origStr, halfOutStrLen);
*(outStr + halfOutStrLen) = 0;
strcat(outStr, "É");
strncat(outStr, lastPart, strlen(lastPart));
*(outStr + outStrLen + 1) = 0;
}
float
ComputeRate(int bytes, time_t startTime, time_t endTime)
{
double period = difftime(endTime, startTime);
float rate = bytes/period;
rate /= 1024; // convert from bytes/sec to KB/sec
return rate;
}
#define kProgMsgLen 51
int
DLProgressCB(int aBytesSoFar, int aTotalFinalSize)
{
static int yielder = 0, yieldFrequency = 64;
int len;
char compressedStr[kProgMsgLen + 1]; // add one for NULL termination
char *fullPathCopy = 0; // GetFullPath doesn't null terminate
float rate = 0;
time_t now;
Rect teRect;
if (aTotalFinalSize != sCurrTotalDLSize)
{
sCurrTotalDLSize = aTotalFinalSize;
if (gControls->tw->dlProgressBar)
SetControlMaximum(gControls->tw->dlProgressBar, (aTotalFinalSize/1024));
// set short desc name of package being downloaded in Downloading field
if (gControls->cfg->comp[sCurrComp].shortDesc)
{
FSClose(fileRefNum);
goto BAIL;
HLock(gControls->cfg->comp[sCurrComp].shortDesc);
if (*(gControls->cfg->comp[sCurrComp].shortDesc) && gControls->tw->dlProgressMsgs[0])
{
HLock((Handle)gControls->tw->dlProgressMsgs[0]);
teRect = (**(gControls->tw->dlProgressMsgs[0])).viewRect;
HUnlock((Handle)gControls->tw->dlProgressMsgs[0]);
len = strlen(*(gControls->cfg->comp[sCurrComp].shortDesc));
TESetText(*(gControls->cfg->comp[sCurrComp].shortDesc), len,
gControls->tw->dlProgressMsgs[0]);
TEUpdate(&teRect, gControls->tw->dlProgressMsgs[0]);
}
HUnlock(gControls->cfg->comp[sCurrComp].shortDesc);
}
// compress URL string and insert in From field
if (sCurrURL && gControls->tw->dlProgressMsgs[1])
{
HLock((Handle)gControls->tw->dlProgressMsgs[1]);
teRect = (**(gControls->tw->dlProgressMsgs[1])).viewRect;
HUnlock((Handle)gControls->tw->dlProgressMsgs[1]);
CompressToFit(sCurrURL, compressedStr, kProgMsgLen);
TESetText(compressedStr, kProgMsgLen, gControls->tw->dlProgressMsgs[1]);
TEUpdate(&teRect, gControls->tw->dlProgressMsgs[1]);
}
// compress fullpath string and insert in To field
if (sCurrFullPath)
{
HLock(sCurrFullPath);
if (*sCurrFullPath && gControls->tw->dlProgressMsgs[2])
{
fullPathCopy = (char *)malloc(sCurrFullPathLen + 1);
if (fullPathCopy)
{
strncpy(fullPathCopy, (*sCurrFullPath), sCurrFullPathLen);
*(fullPathCopy + sCurrFullPathLen) = 0;
HLock((Handle)gControls->tw->dlProgressMsgs[2]);
teRect = (**(gControls->tw->dlProgressMsgs[2])).viewRect;
HUnlock((Handle)gControls->tw->dlProgressMsgs[2]);
CompressToFit(fullPathCopy, compressedStr, kProgMsgLen);
TESetText(compressedStr, kProgMsgLen, gControls->tw->dlProgressMsgs[2]);
TEUpdate(&teRect, gControls->tw->dlProgressMsgs[2]);
free(fullPathCopy);
}
}
HUnlock(sCurrFullPath);
}
}
FSClose(fileRefNum);
/* parse text for selected site replacing teh global URL
* with the identifed site's URL in the redirect.ini
*/
if (gControls->cfg->numSites > 0)
{
siteIndex = gControls->opt->siteChoice - 1;
if (!gControls->cfg->site[siteIndex].id)
goto BAIL;
HLock(gControls->cfg->site[siteIndex].id);
cId = NewPtrClear(strlen(*(gControls->cfg->site[siteIndex].id)) + 1); // add 1 for null termination
strcpy(cId, *(gControls->cfg->site[siteIndex].id));
HUnlock(gControls->cfg->site[siteIndex].id);
GetIndString(pSection, rParseKeys, sSiteSelector);
cSection = PascalToC(pSection);
if (!cSection || !cId)
goto BAIL;
domainH = NewHandleClear(kValueMaxLen);
if (!domainH )
goto BAIL;
if (FillKeyValueUsingName(cSection, cId, domainH, text))
{
if (gControls->cfg->globalURL)
DisposeHandle(gControls->cfg->globalURL);
gControls->cfg->globalURL = NewHandleClear(kValueMaxLen);
HLock(domainH);
HLock(gControls->cfg->globalURL);
strcpy(*(gControls->cfg->globalURL), *domainH);
HUnlock(domainH);
HUnlock(gControls->cfg->globalURL);
}
if (domainH)
DisposeHandle(domainH);
}
BAIL:
if (text)
DisposePtr((Ptr) text);
if (cId)
DisposePtr((Ptr) cId);
if (cSection)
DisposePtr((Ptr) cSection);
if (gControls->tw->dlProgressBar)
{
if (++yielder == yieldFrequency)
{
SetControlValue(gControls->tw->dlProgressBar, (aBytesSoFar/1024));
// update rate info
now = time(NULL);
rate = ComputeRate(aBytesSoFar, sCurrStartTime, now);
sprintf(compressedStr, "%d KB of %d KB (%.2f KB/sec)",
aBytesSoFar/1024, aTotalFinalSize/1024, rate);
HLock((Handle)gControls->tw->dlProgressMsgs[3]);
teRect = (**(gControls->tw->dlProgressMsgs[3])).viewRect;
HUnlock((Handle)gControls->tw->dlProgressMsgs[3]);
TESetText(compressedStr, strlen(compressedStr), gControls->tw->dlProgressMsgs[3]);
TEUpdate(&teRect, gControls->tw->dlProgressMsgs[3]);
yielder = 0;
YieldToAnyThread();
}
}
return 0;
}
void
@ -878,6 +1030,90 @@ DeleteXPIs(short vRefNum, long dirID)
}
}
const int kNumDLFields = 4;
void
InitDLProgControls(void)
{
Boolean indeterminateFlag = false;
Rect r;
GrafPtr oldPort;
GetPort(&oldPort);
int i;
if (gWPtr)
{
SetPort(gWPtr);
gControls->tw->dlProgressBar = GetNewControl(rDLProgBar, gWPtr);
if (gControls->tw->dlProgressBar)
{
SetControlData(gControls->tw->dlProgressBar, kControlNoPart, kControlProgressBarIndeterminateTag,
sizeof(indeterminateFlag), (Ptr) &indeterminateFlag);
Draw1Control(gControls->tw->dlProgressBar);
// draw labels
Str255 labelStr;
for (i = 0; i < kNumDLFields; ++i)
{
gControls->tw->dlLabels[i] = GetNewControl(rLabDloading + i, gWPtr);
if (gControls->tw->dlLabels[i])
{
GetIndString(labelStr, rStringList, sLabDloading + i);
SetControlData(gControls->tw->dlLabels[i], kControlNoPart,
kControlStaticTextTextTag, labelStr[0], (Ptr)&labelStr[1]);
ShowControl(gControls->tw->dlLabels[i]);
}
}
TextFace(normal);
TextSize(9);
TextFont(applFont);
for (i = 0; i < kNumDLFields; ++i)
{
SetRect(&r, (*gControls->tw->dlLabels[i])->contrlRect.right,
(*gControls->tw->dlLabels[i])->contrlRect.top + 1,
(*gControls->tw->dlLabels[i])->contrlRect.right + 310,
(*gControls->tw->dlLabels[i])->contrlRect.bottom + 1 );
gControls->tw->dlProgressMsgs[i] = TENew(&r, &r);
}
TextSize(12);
TextFont(systemFont);
}
}
SetPort(oldPort);
}
void
ClearDLProgControls(void)
{
Rect teRect;
for (int i = 0; i < kNumDLFields; ++i)
{
if (gControls->tw->dlLabels[i])
DisposeControl(gControls->tw->dlLabels[i]);
if (gControls->tw->dlProgressMsgs[i])
{
HLock((Handle)gControls->tw->dlProgressMsgs[i]);
teRect = (**(gControls->tw->dlProgressMsgs[i])).viewRect;
HUnlock((Handle)gControls->tw->dlProgressMsgs[i]);
EraseRect(&teRect);
TEDispose(gControls->tw->dlProgressMsgs[i]);
}
}
if (gControls->tw->dlProgressBar)
{
DisposeControl(gControls->tw->dlProgressBar);
gControls->tw->dlProgressBar = NULL;
}
}
void
InitProgressBar(void)
{
@ -946,69 +1182,3 @@ InitProgressBar(void)
SetPort(oldPort);
}
Boolean
InitSDLib(void)
{
Str255 libName, pModulesDir;
FSSpec libSpec;
short vRefNum;
long dirID, cwdDirID;
Boolean isDir = false;
OSErr err;
ERR_CHECK_RET(GetCWD(&cwdDirID, &vRefNum), false);
/* get the "Installer Modules" relative subdir */
GetIndString(pModulesDir, rStringList, sInstModules);
GetDirectoryID(vRefNum, cwdDirID, pModulesDir, &dirID, &isDir);
if (!isDir) /* bail if we can't find the "Installer Modules" dir */
return false;
/* initialize SDI lib and struct */
GetIndString(libName, rStringList, sSDLib);
ERR_CHECK_RET(FSMakeFSSpec(vRefNum, dirID, libName, &libSpec), false);
if (!LoadSDLib(libSpec, &gInstFunc, &gSDIEvtHandler, &gConnID))
{
ErrorHandler(eLoadLib);
return false;
}
return true;
}
Boolean
LoadSDLib(FSSpec libSpec, SDI_NETINSTALL *outSDNFunc, EventProc *outEvtProc, CFragConnectionID *outConnID)
{
OSErr err;
Str255 errName;
Ptr mainAddr;
Ptr symAddr;
CFragSymbolClass symClass;
ERR_CHECK_RET(GetDiskFragment(&libSpec, 0, kCFragGoesToEOF, nil, kReferenceCFrag, outConnID, &mainAddr, errName), false);
if (*outConnID != NULL)
{
ERR_CHECK_RET(FindSymbol(*outConnID, "\pSDI_NetInstall", &symAddr, &symClass), false);
*outSDNFunc = (SDI_NETINSTALL) symAddr;
ERR_CHECK_RET(FindSymbol(*outConnID, "\pSDI_HandleEvent", &symAddr, &symClass), false);
*outEvtProc = (EventProc) symAddr;
}
return true;
}
Boolean
UnloadSDLib(CFragConnectionID *connID)
{
if (*connID != NULL)
{
CloseConnection(connID);
*connID = NULL;
}
else
return false;
return true;
}

Просмотреть файл

@ -185,21 +185,26 @@ InitLicTxt(void)
void
ShowTxt(void)
{
{
switch (gCurrWin)
{
case kLicenseID:
if(gControls->lw->licTxt)
{
// InvalRect(&(**(gControls->lw->licTxt)).viewRect);
RGBColor backColorOld;
// get back color
GetBackColor(&backColorOld);
// set to white
BackColor(whiteColor);
// erase rect and update
EraseRect(&(**(gControls->lw->licTxt)).viewRect);
TEUpdate( &(**(gControls->lw->licTxt)).viewRect, gControls->lw->licTxt);
}
break;
case kWelcomeID:
if(gControls->ww->welcTxt)
{
// InvalRect(&(**(gControls->lw->licTxt)).viewRect);
TEUpdate( &(**(gControls->ww->welcTxt)).viewRect, gControls->ww->welcTxt);
// restore back color
RGBBackColor(&backColorOld);
}
break;
default:
@ -214,7 +219,15 @@ ShowLogo(Boolean bEraseRect)
Rect derefd, logoRect;
PicHandle logoPicH;
Handle logoRectH;
/* draw the image well */
ControlHandle imgWellH = GetNewControl(rLogoImgWell, gWPtr);
if (!imgWellH)
{
ErrorHandler(eMem);
return;
}
/* initialize Netscape logo */
logoPicH = GetPicture(rNSLogo);
reserr = ResError();
@ -230,7 +243,7 @@ ShowLogo(Boolean bEraseRect)
{
HLock(logoRectH);
derefd = (Rect) **((Rect**)logoRectH);
SetRect(&logoRect, derefd.left, derefd.top, derefd.bottom, derefd.right);
SetRect(&logoRect, derefd.left, derefd.top, derefd.right, derefd.bottom);
HUnlock(logoRectH);
reserr = ResError();
if (reserr == noErr)
@ -278,8 +291,7 @@ InLicenseContent(EventRecord* evt, WindowPtr wCurrPtr)
case kControlPageDownPart:
scrollActionFunctionUPP = NewControlActionProc((ProcPtr) DoScrollProc);
value = TrackControl(scrollBar, localPt, scrollActionFunctionUPP);
return;
break; /* <--- what is this for? */
return;
case kControlIndicatorPart:
value = GetControlValue(scrollBar);
@ -290,6 +302,7 @@ InLicenseContent(EventRecord* evt, WindowPtr wCurrPtr)
if (value)
{
TEScroll(0, value * kScrollAmount, gControls->lw->licTxt);
ShowTxt();
}
}
return;
@ -314,7 +327,7 @@ InLicenseContent(EventRecord* evt, WindowPtr wCurrPtr)
if (part)
{
KillControls(gWPtr);
ShowWelcomeWin();
ShowSetupTypeWin();
return;
}
}
@ -348,8 +361,6 @@ EnableLicenseWin(void)
void
DisableLicenseWin(void)
{
//SysBeep(10);
DisableNavButtons();
/*
@ -375,9 +386,6 @@ InitScrollBar(ControlHandle sb)
case kLicenseID:
currTE = gControls->lw->licTxt;
break;
case kWelcomeID:
currTE = gControls->ww->welcTxt;
break;
default:
ErrorHandler(eUnknownDlgID);
break;
@ -406,9 +414,6 @@ DoScrollProc(ControlHandle theControl, short part)
case kLicenseID:
te = *(gControls->lw->licTxt);
break;
case kWelcomeID:
te = *(gControls->ww->welcTxt);
break;
default:
ErrorHandler(eUnknownDlgID);
break;
@ -429,6 +434,7 @@ DoScrollProc(ControlHandle theControl, short part)
CalcChange(theControl, &amount);
if (amount) {
TEScroll(0, amount * kScrollAmount, &te);
ShowTxt();
}
}
}
@ -461,8 +467,8 @@ ShowNavButtons(unsigned char* backTitle, unsigned char* nextTitle)
{
SetControlTitle( gControls->backB, backTitle);
ShowControl( gControls->backB);
if (gCurrWin==kWelcomeID)
if (gCurrWin==kWelcomeID || gCurrWin==kSetupTypeID)
HiliteControl(gControls->backB, kDisableControl);
}
@ -481,6 +487,8 @@ ShowNavButtons(unsigned char* backTitle, unsigned char* nextTitle)
HUnlock( (Handle)gControls->nextB );
}
ShowCancelButton();
}
void
@ -491,7 +499,9 @@ EnableNavButtons(void)
if (gControls->nextB)
HiliteControl(gControls->nextB, kEnableControl);
// TO DO
if (gControls->cancelB)
HiliteControl(gControls->cancelB, kEnableControl);
}
void
@ -502,5 +512,6 @@ DisableNavButtons(void)
if(gControls->nextB)
HiliteControl(gControls->nextB, kDisableControl);
// TO DO
if (gControls->cancelB)
HiliteControl(gControls->cancelB, kDisableControl);
}

Просмотреть файл

@ -28,16 +28,11 @@
*-----------------------------------------------------------*/
Boolean gDone = false;
Boolean gSDDlg = false;
WindowPtr gWPtr = NULL;
short gCurrWin = 0;
InstWiz *gControls = NULL;
Boolean gInstallStarted = false;
EventProc gSDIEvtHandler; /* SDI */
SDI_NETINSTALL gInstFunc;
CFragConnectionID gConnID;
/*-----------------------------------------------------------*
* Application Setup
@ -89,10 +84,6 @@ VerifyEnv(void)
void Init(void)
{
Str255 winTitle;
#if CFG_IS_REMOTE == 1
ThreadID tid;
ThreadState state;
#endif
OSErr err = noErr;
gDone = false;
@ -100,35 +91,6 @@ void Init(void)
InitControlsObject();
CleanTemp();
#if (SDINST_IS_DLL == 1) && (MOZILLA == 0)
if (!InitSDLib())
{
ErrorHandler(eLoadLib);
return;
}
#endif
#if CFG_IS_REMOTE == 1
if (!SpawnSDThread(PullDownConfig, &tid))
{
ErrorHandler(eSpawn);
return;
}
/* block/busy wait till download finishes */
while (1)
{
GetThreadState(tid, &state);
if (state == kStoppedThreadState)
break;
else
sleep(1);
}
ERR_CHECK(DisposeThread(tid, (void*)nil, false));
#endif /* CFG_IS_REMOTE == 1 */
gWPtr = GetNewCWindow(rRootWin, NULL, (WindowPtr) -1);
GetIndString( winTitle, rTitleStrList, sNSInstTitle);
SetWTitle( gWPtr, winTitle );
@ -138,7 +100,8 @@ void Init(void)
ParseConfig();
InitOptObject();
ShowLicenseWin();
ShowWelcomeWin();
SetThemeWindowBackground(gWPtr, kThemeBrushDialogBackgroundActive, true);
}
OSErr
@ -405,14 +368,13 @@ void MainEventLoop(void)
{
EventRecord evt;
Boolean notHandled = true;
THz ourHZ;
RgnHandle mouseRgn;
mouseRgn = NewRgn();
while (!gDone)
{
YieldToAnyThread(); /* SmartDownload dialog thread */
YieldToAnyThread(); /* download thread */
if (!gDone) /* after cx switch back ensure not done */
{
@ -421,23 +383,7 @@ void MainEventLoop(void)
if (mouseRgn)
SetRectRgn(mouseRgn, evt.where.h, evt.where.v, evt.where.h + 1, evt.where.v + 1);
if (gSDDlg)
{
ourHZ = GetZone();
#if MOZILLA == 0
#if SDINST_IS_DLL==1
notHandled = gSDIEvtHandler(&evt);
#else
notHandled = SDI_HandleEvent(&evt);
#endif /* SDINST_IS_DLL */
#endif /* MOZILLA */
SetZone(ourHZ);
}
else
notHandled = true;
if (notHandled)
HandleNextEvent(&evt);
HandleNextEvent(&evt);
}
}
}
@ -496,13 +442,12 @@ void ErrorHandler(short errCode)
void Shutdown(void)
{
WindowPtr frontWin;
long MIWMagic = 0, i;
long MIWMagic = 0;
#if (SDINST_IS_DLL == 1) && (MOZILLA == 0)
UnloadSDLib(&gConnID);
#endif
NavUnload();
#if 0
/* deallocate config object */
if (gControls->cfg)
{
@ -565,13 +510,10 @@ void Shutdown(void)
/* deallocate all controls */
#if 0
/* XXX gets disposed by DisposeWindow() ? */
if (gControls->nextB)
DisposeControl(gControls->nextB);
if (gControls->backB)
DisposeControl(gControls->backB);
#endif
if (gControls->lw)
DisposePtr( (char*) gControls->lw);
@ -586,6 +528,8 @@ void Shutdown(void)
if (gControls)
DisposePtr( (char*) gControls);
#endif /* 0 */
frontWin = FrontWindow();
MIWMagic = GetWRefCon(frontWin);

Просмотреть файл

@ -43,6 +43,7 @@
#include <MacTypes.h>
#include <PLStringFuncs.h>
#include <Icons.h>
#include <Appearance.h>
#if TARGET_CARBON || (UNIVERSAL_INTERFACES_VERSION >= 0x0330)
#include <ControlDefinitions.h>
#endif
@ -52,24 +53,6 @@
#include "IterateDirectory.h"
#include "Threads.h"
/*-----------------------------------------------------------*
* SBI: SmartDownload administration
*-----------------------------------------------------------*/
#define WANT_WINTYPES 1
#define MACINTOSH 1
#ifndef _sdinst_h
#include "sdinst.h"
#endif
typedef HRESULT (_cdecl *SDI_NETINSTALL) (LPSDISTRUCT);
typedef Boolean (*EventProc)(const EventRecord*);
/*-----------------------------------------------------------*
* compile time switches [on=1; off=0]
*-----------------------------------------------------------*/
#define CFG_IS_REMOTE 0 /* if on, download remote config.ini file */
#define SDINST_IS_DLL 1 /* if on, load SDInstLib as code fragment */
/*-----------------------------------------------------------*
* defines
@ -168,12 +151,15 @@ if (err) \
#define rRootWin 128 /* widget rsrc ids */
#define rBackBtn 129
#define rNextBtn 130
#define rCancelBtn 174
#define rNSLogo 140
#define rNSLogoBox 130
#define rLogoImgWell 170
#define rLicBox 131
#define rLicScrollBar 132
#define rWelcMsgTextbox 171
#define rReadmeBtn 133
#define rInstType 140
@ -190,14 +176,25 @@ if (err) \
#define rAllProgBar 161
#define rPerXPIProgBar 162
#define rSiteSelector 163
#define rSiteSelMsg 179
#define rSaveCheckbox 164
#define rSaveBitsMsgBox 165
#define rProxySettgBtn 175
#define rDLSettingsGB 178
#define rDLProgBar 180
#define rLabDloading 181
#define rLabFrom 182
#define rLabTo 183
#define rLabRate 184
#define rLabTimeLeft 185
#define rGrayPixPattern 128
#define rAlrtDelOldInst 150
#define rAlrtOS85Reqd 160
#define rAlrtError 170
#define rWarnLessSpace 180
#define rDlgProxySettg 140
#define rMBar 128 /* menu rsrc ids */
@ -242,6 +239,15 @@ if (err) \
#define sProcessing 27
#define sReadme 28
#define sInstModules 29
#define sCancel 30
#define sProxySettings 31
#define sDLSettings 32
#define sSiteSelMsg 33
#define sLabDloading 34
#define sLabFrom 35
#define sLabTo 36
#define sLabRate 37
#define sTimeLeft 38
#define rTitleStrList 170
#define sNSInstTitle 1 /* end i18n strings */
@ -334,6 +340,7 @@ if (err) \
#define eSpawn 6
#define eMenuHdl 7
#define eCfgRead 8
#define eDownload 9
/* end errors */
@ -477,7 +484,10 @@ typedef struct Options {
/* from TerminalWin */
short siteChoice;
Boolean saveBits;
char *proxyHost;
char *proxyPort;
char *proxyUsername;
char *proxyPassword;
} Options;
typedef struct LicWin {
@ -487,9 +497,7 @@ typedef struct LicWin {
} LicWin;
typedef struct WelcWin {
ControlHandle welcBox;
ControlHandle scrollBar;
TEHandle welcTxt;
ControlHandle welcMsgCntl[kNumWelcMsgs];
ControlHandle readmeButton;
} WelcWin;
@ -512,14 +520,25 @@ typedef struct CompWin {
typedef struct TermWin {
TEHandle startMsg;
Rect startMsgBox;
ControlHandle dlProgressBar;
ControlHandle allProgressBar;
TEHandle allProgressMsg;
ControlHandle xpiProgressBar;
TEHandle xpiProgressMsg;
ControlHandle dlSettingsGB;
ControlHandle dlLabels[5];
TEHandle dlProgressMsgs[5];
ControlHandle siteSelector;
ControlHandle siteSelMsg;
ControlHandle saveBitsCheckbox;
TEHandle saveBitsMsg;
Rect saveBitsMsgBox;
ControlHandle proxySettingsBtn;
} TermWin;
typedef struct InstWiz {
@ -541,7 +560,7 @@ typedef struct InstWiz {
/* General wizard controls */
ControlHandle backB;
ControlHandle nextB;
ControlHandle cancelB;
} InstWiz;
@ -552,13 +571,8 @@ extern WindowPtr gWPtr;
extern short gCurrWin;
extern InstWiz *gControls;
extern Boolean gDone;
extern Boolean gSDDlg;
extern Boolean gInstallStarted;
extern EventProc gSDIEvtHandler;
extern SDI_NETINSTALL gInstFunc;
extern CFragConnectionID gConnID;
/*-----------------------------------------------------------*
* prototypes
@ -584,7 +598,6 @@ void Shutdown(void);
/*-----------------------------------------------------------*
* Parser
*-----------------------------------------------------------*/
pascal void *PullDownConfig(void*);
void ParseConfig(void);
Boolean ReadConfigFile(char **);
OSErr PopulateGeneralKeys(char *);
@ -621,6 +634,7 @@ void HandleUpdateEvt(EventRecord *);
void HandleActivateEvt(EventRecord *);
void HandleOSEvt(EventRecord *);
void React2InContent(EventRecord *, WindowPtr);
Boolean DidUserCancel(EventRecord *);
/*-----------------------------------------------------------*
* LicenseWin
@ -643,8 +657,9 @@ void DisableNavButtons(void);
* WelcomeWin
*-----------------------------------------------------------*/
void ShowWelcomeWin(void);
void InitWelcTxt(void);
void ShowWelcomeMsg(void);
void InWelcomeContent(EventRecord*, WindowPtr);
void ShowCancelButton(void);
void ShowReadmeButton(void);
void ShowReadme(void);
void EnableWelcomeWin(void);
@ -680,6 +695,7 @@ unsigned char* pstrcat(unsigned char*, unsigned char*);
void InSetupTypeContent(EventRecord *, WindowPtr);
Boolean LegacyFileCheck(short, long);
int CompareVersion(Handle, FSSpecPtr);
Boolean VerifyDiskSpace(void);
void EnableSetupTypeWin(void);
void DisableSetupTypeWin(void);
@ -690,7 +706,6 @@ void ShowComponentsWin(void);
Boolean PopulateCompInfo(void);
void UpdateCompWin(void);
void InComponentsContent(EventRecord*, WindowPtr);
void MouseMovedInComponentsWin(EventRecord *);
short GetCompRow(int);
void SetOptInfo(Boolean);
void InitRowHighlight(int);
@ -708,7 +723,6 @@ void ShowAdditionsWin(void);
Boolean AddPopulateCompInfo(void);
void InAdditionsContent(EventRecord*, WindowPtr);
void UpdateAdditionsWin(void);
void MouseMovedInAdditionsWin(EventRecord *);
short AddGetCompRow(int);
void AddSetOptInfo(Boolean);
void AddInitRowHighlight(int);
@ -721,10 +735,14 @@ void DisableAdditionsWin(void);
* TerminalWin
*-----------------------------------------------------------*/
void ShowTerminalWin(void);
short GetRectFromRes(Rect *, short);
void my_c2pstrcpy(const char *, Str255);
void InTerminalContent(EventRecord*, WindowPtr);
void UpdateTerminalWin(void);
void OpenProxySettings(void);
Boolean SpawnSDThread(ThreadEntryProcPtr, ThreadID *);
void ClearSiteSelector(void);
void ClearDownloadSettings(void);
void ClearSaveBitsMsg(void);
void EnableTerminalWin(void);
void DisableTerminalWin(void);
@ -732,8 +750,13 @@ void DisableTerminalWin(void);
* InstAction
*-----------------------------------------------------------*/
pascal void *Install(void*);
Boolean DownloadRedirect(short, long, FSSpecPtr);
void ParseRedirect(FSSpecPtr);
long ComputeTotalDLSize(void);
short DownloadXPIs(short, long);
short DownloadFile(Handle, long, Handle);
int ParseFTPURL(char *, char **, char **);
void CompressToFit(char *, char *, int);
float ComputeRate(int, time_t, time_t);
int DLProgressCB(int, int);
void IfRemoveOldCore(short, long);
Boolean GenerateIDIFromOpt(Str255, long, short, FSSpec *);
void AddKeyToIDI(short, Handle, char *);
@ -741,10 +764,9 @@ Boolean ExistArchives(short, long);
void LaunchApps(short, long);
void RunApps(void);
void DeleteXPIs(short, long);
void InitDLProgControls(void);
void ClearDLProgControls(void);
void InitProgressBar(void);
Boolean InitSDLib(void);
Boolean LoadSDLib(FSSpec, SDI_NETINSTALL *, EventProc *, CFragConnectionID *);
Boolean UnloadSDLib(CFragConnectionID *);
/*-----------------------------------------------------------*
* Inflation

Просмотреть файл

@ -27,38 +27,6 @@
* INI Parser
*-----------------------------------------------------------*/
pascal void *
PullDownConfig(void *unused)
{
short vRefNum;
long dirID;
OSErr err;
FSSpec idiSpec;
SDISTRUCT sdistruct;
Str255 pIDIfname;
ERR_CHECK_RET(GetCWD(&dirID, &vRefNum), (void*)0);
// XXX if we ever use this we need to pull down to "Installer Modules" now
GetIndString(pIDIfname, rStringList, sConfigIDIName);
/* get idi filepath */
ERR_CHECK_RET(FSMakeFSSpec(vRefNum, dirID, pIDIfname, &idiSpec), false);
/* populate SDI struct */
sdistruct.dwStructSize = sizeof(SDISTRUCT);
sdistruct.fsIDIFile = idiSpec;
sdistruct.dlDirVRefNum = vRefNum;
sdistruct.dlDirID = dirID;
sdistruct.hwndOwner = NULL;
/* call SDI_NetInstall */
gInstFunc(&sdistruct);
return (void*)true;
}
void
ParseConfig(void)
{

Просмотреть файл

@ -28,6 +28,9 @@
* Setup Type Window
*-----------------------------------------------------------*/
static long sDSNeededK = 0; /* disk space needed in KB */
static long sDSAvailK = 0; /* disk space available in KB */
void
ShowSetupTypeWin(void)
{
@ -102,12 +105,11 @@ ShowSetupTypeWin(void)
HLock(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);
InsertCompList(gControls->opt->instChoice - 1);
TESetAlignment( teFlushDefault, gControls->stw->instDescTxt);
HUnlock(gControls->cfg->st[gControls->opt->instChoice - 1].longDesc);
/*
volName = (unsigned char **)NewPtrClear(sizeof(unsigned char *));
/*
volName = (unsigned char **)NewPtrClear(sizeof(unsigned char *));
GetAllVInfo(volName, &numVols);
gControls->stw->numVols = numVols;
HLock((Handle)gControls->stw->destLoc);
@ -144,12 +146,12 @@ ShowSetupTypeWin(void)
void
ShowSetupDescTxt(void)
{
Rect r;
Rect teRect; /* TextEdit rect */
if (gControls->stw->instDescTxt)
{
r = (**(gControls->stw->instDescTxt)).viewRect;
TEUpdate( &r, gControls->stw->instDescTxt);
teRect = (**(gControls->stw->instDescTxt)).viewRect;
TEUpdate(&teRect, gControls->stw->instDescTxt);
}
DrawDiskNFolder(gControls->opt->vRefNum, gControls->opt->folder);
@ -234,9 +236,7 @@ InSetupTypeContent(EventRecord* evt, WindowPtr wCurrPtr)
len = strlen(*gControls->cfg->st[instChoice].longDesc);
TESetText( *gControls->cfg->st[instChoice].longDesc, len, gControls->stw->instDescTxt);
HUnlock(gControls->cfg->st[instChoice].longDesc);
InsertCompList(instChoice);
EraseRect( &r );
TEUpdate( &r, gControls->stw->instDescTxt);
@ -303,21 +303,6 @@ InSetupTypeContent(EventRecord* evt, WindowPtr wCurrPtr)
return;
}
HLock((Handle)gControls->backB);
r = (**(gControls->backB)).contrlRect;
HUnlock((Handle)gControls->backB);
if (PtInRect( localPt, &r))
{
part = TrackControl(gControls->backB, evt->where, NULL);
if (part)
{
ClearDiskSpaceMsgs();
KillControls(gWPtr);
ShowWelcomeWin();
return;
}
}
HLock((Handle)gControls->nextB);
r = (**(gControls->nextB)).contrlRect;
@ -335,6 +320,13 @@ InSetupTypeContent(EventRecord* evt, WindowPtr wCurrPtr)
return;
}
/* if not custom setup type then perform disk space check */
if (gControls->opt->instChoice < gControls->cfg->numSetupTypes)
{
if (!VerifyDiskSpace())
return;
}
ClearDiskSpaceMsgs();
KillControls(gWPtr);
/* treat last setup type selection as custom */
@ -488,7 +480,8 @@ DrawDiskSpaceMsgs(short vRefNum)
freeSpace = UInt64ToUnsignedWide(pb.ioVFreeBytes);
dFree = (freeSpace.hi * 4294967296) + freeSpace.lo; // 2^32 = 4294967296
lFree = (long) (dFree/1024);
sDSAvailK = lFree;
instDescRectH = NULL;
instDescRectH = Get1Resource('RECT', rCompListBox);
reserr = ResError();
@ -634,6 +627,7 @@ DiskSpaceNeeded(void)
}
cSpaceNeeded = ltoa(spaceNeeded);
sDSNeededK = spaceNeeded;
return cSpaceNeeded;
}
@ -1024,6 +1018,29 @@ au_revoir:
return diffLevel;
}
Boolean
VerifyDiskSpace(void)
{
char dsNeededStr[255], dsAvailStr[255];
short alertRV;
if (sDSNeededK > sDSAvailK)
{
sprintf(dsNeededStr, "%d", sDSNeededK);
sprintf(dsAvailStr, "%d", sDSAvailK);
ParamText(c2pstr(dsNeededStr), c2pstr(dsAvailStr), "\p", "\p");
alertRV = CautionAlert(rWarnLessSpace, nil);
if (alertRV == 2)
{
gDone = true;
}
return false;
}
return true;
}
void
EnableSetupTypeWin(void)
{

Просмотреть файл

@ -36,7 +36,6 @@ ShowTerminalWin(void)
Handle rectH;
Rect viewRect;
short reserr;
#if MOZILLA == 0
MenuHandle popupMenu;
PopupPrivateData ** pvtDataHdl;
unsigned char * currMenuItem;
@ -45,7 +44,6 @@ ShowTerminalWin(void)
Boolean isDir = false;
Str255 pModulesDir;
OSErr err = noErr;
#endif /* MOZILLA == 0 */
GrafPtr oldPort;
GetPort(&oldPort);
@ -79,42 +77,12 @@ ShowTerminalWin(void)
gControls->tw->startMsgBox = viewRect;
gControls->tw->startMsg = TENew(&viewRect, &viewRect);
if (gControls->tw->startMsg == NULL)
{
ErrorHandler(eMem);
return;
}
if (gControls->tw->startMsg == NULL)
{
ErrorHandler(eMem);
return;
}
#if MOZILLA == 0
// site selector
if (gControls->cfg->numSites > 0)
{
gControls->tw->siteSelector = GetNewControl( rSiteSelector, gWPtr );
if (!gControls->tw->siteSelector)
{
ErrorHandler(eMem);
return;
}
// populate popup button menus
HLock((Handle)gControls->tw->siteSelector);
pvtDataHdl = (PopupPrivateData **) (*(gControls->tw->siteSelector))->contrlData;
HLock((Handle)pvtDataHdl);
popupMenu = (MenuHandle) (**pvtDataHdl).mHandle;
for (i=0; i<gControls->cfg->numSites; i++)
{
HLock(gControls->cfg->site[i].desc);
currMenuItem = CToPascal(*gControls->cfg->site[i].desc);
HUnlock(gControls->cfg->site[i].desc);
InsertMenuItem( popupMenu, currMenuItem, i );
}
HUnlock((Handle)pvtDataHdl);
HUnlock((Handle)gControls->tw->siteSelector);
SetControlMaximum(gControls->tw->siteSelector, gControls->cfg->numSites);
SetControlValue(gControls->tw->siteSelector, gControls->opt->siteChoice);
ShowControl(gControls->tw->siteSelector);
}
// save bits after download and install
/* get the "Installer Modules" relative subdir */
@ -124,7 +92,57 @@ ShowTerminalWin(void)
if (isDir)
{
if (!ExistArchives(vRefNum, dirID)) // going to download
{
{
if (gControls->cfg->numSites > 0)
{
// download settings groupbox
Str255 dlSettingsGBTitle;
gControls->tw->dlSettingsGB = GetNewControl(rDLSettingsGB, gWPtr);
if (gControls->tw->dlSettingsGB)
{
GetIndString(dlSettingsGBTitle, rStringList, sDLSettings);
SetControlTitle(gControls->tw->dlSettingsGB, dlSettingsGBTitle);
ShowControl(gControls->tw->dlSettingsGB);
}
// site selector label
Str255 siteSelMsgStr;
gControls->tw->siteSelMsg = GetNewControl(rSiteSelMsg, gWPtr);
if (gControls->tw->siteSelMsg)
{
GetIndString(siteSelMsgStr, rStringList, sSiteSelMsg);
SetControlData(gControls->tw->siteSelMsg, kControlNoPart,
kControlStaticTextTextTag, siteSelMsgStr[0], (Ptr)&siteSelMsgStr[1]);
ShowControl(gControls->tw->siteSelMsg);
}
// site selector
gControls->tw->siteSelector = GetNewControl( rSiteSelector, gWPtr );
if (!gControls->tw->siteSelector)
{
ErrorHandler(eMem);
return;
}
// populate popup button menus
HLock((Handle)gControls->tw->siteSelector);
pvtDataHdl = (PopupPrivateData **) (*(gControls->tw->siteSelector))->contrlData;
HLock((Handle)pvtDataHdl);
popupMenu = (MenuHandle) (**pvtDataHdl).mHandle;
for (i=0; i<gControls->cfg->numSites; i++)
{
HLock(gControls->cfg->site[i].desc);
currMenuItem = CToPascal(*gControls->cfg->site[i].desc);
HUnlock(gControls->cfg->site[i].desc);
InsertMenuItem( popupMenu, currMenuItem, i );
}
HUnlock((Handle)pvtDataHdl);
HUnlock((Handle)gControls->tw->siteSelector);
SetControlMaximum(gControls->tw->siteSelector, gControls->cfg->numSites);
SetControlValue(gControls->tw->siteSelector, gControls->opt->siteChoice);
ShowControl(gControls->tw->siteSelector);
}
// show check box and message
gControls->tw->saveBitsCheckbox = GetNewControl( rSaveCheckbox, gWPtr );
if (!gControls->tw->saveBitsCheckbox)
@ -132,6 +150,8 @@ ShowTerminalWin(void)
ErrorHandler(eMem);
return;
}
if (gControls->opt->saveBits)
SetControlValue(gControls->tw->saveBitsCheckbox, 1);
ShowControl(gControls->tw->saveBitsCheckbox);
// get rect for save bits message
@ -160,13 +180,24 @@ ShowTerminalWin(void)
TESetText(*gControls->cfg->saveBitsMsg, strlen(*gControls->cfg->saveBitsMsg),
gControls->tw->saveBitsMsg);
HUnlock(gControls->cfg->saveBitsMsg);
// show controls
// show save bits msg
TEUpdate(&gControls->tw->saveBitsMsgBox, gControls->tw->saveBitsMsg);
}
// proxy settings button
gControls->tw->proxySettingsBtn = GetNewControl(rProxySettgBtn, gWPtr);
if (!gControls->tw->proxySettingsBtn)
{
ErrorHandler(eMem);
return;
}
Str255 proxySettingsTitle;
GetIndString(proxySettingsTitle, rStringList, sProxySettings);
SetControlTitle(gControls->tw->proxySettingsBtn, proxySettingsTitle);
ShowControl(gControls->tw->proxySettingsBtn);
}
}
#endif /* MOZILLA == 0 */
// populate control
HLock(gControls->cfg->startMsg);
TESetText(*gControls->cfg->startMsg, strlen(*gControls->cfg->startMsg),
@ -181,6 +212,32 @@ ShowTerminalWin(void)
SetPort(oldPort);
}
short
GetRectFromRes(Rect *outRect, short inResID)
{
Handle rectH;
short reserr;
if (!outRect)
return eParam;
// get rect for save bits message
rectH = Get1Resource('RECT', inResID);
reserr = ResError();
if (reserr == noErr && rectH != NULL)
{
*outRect = (Rect) **((Rect **)rectH);
DisposeHandle(rectH);
}
else
{
ErrorHandler(reserr);
return reserr;
}
return 0;
}
void
UpdateTerminalWin(void)
{
@ -189,8 +246,15 @@ UpdateTerminalWin(void)
GetPort(&oldPort);
SetPort(gWPtr);
TEUpdate(&gControls->tw->startMsgBox, gControls->tw->startMsg);
if (gControls->tw->allProgressMsg)
if (!gInstallStarted)
TEUpdate(&gControls->tw->startMsgBox, gControls->tw->startMsg);
if (gControls->tw->dlProgressBar)
{
// XXX TO DO
// update the dl TEs
}
else if (gControls->tw->allProgressMsg)
{
HLock((Handle)gControls->tw->allProgressMsg);
SetRect(&instMsgRect, (*gControls->tw->allProgressMsg)->viewRect.left,
@ -201,6 +265,13 @@ UpdateTerminalWin(void)
TEUpdate(&instMsgRect, gControls->tw->allProgressMsg);
}
else
{
if (gControls->tw->saveBitsMsg)
{
TEUpdate(&gControls->tw->saveBitsMsgBox, gControls->tw->saveBitsMsg);
}
}
SetPort(oldPort);
}
@ -211,10 +282,8 @@ InTerminalContent(EventRecord* evt, WindowPtr wCurrPtr)
Point localPt;
Rect r;
ControlPartCode part;
#if MOZILLA == 0
ControlHandle currCntl;
short checkboxVal;
#endif /* MOZILLA == 0 */
ThreadID tid;
GrafPtr oldPort;
GetPort(&oldPort);
@ -223,7 +292,6 @@ InTerminalContent(EventRecord* evt, WindowPtr wCurrPtr)
localPt = evt->where;
GlobalToLocal( &localPt);
#if MOZILLA == 0
if (gControls->tw->siteSelector)
{
HLock((Handle)gControls->tw->siteSelector);
@ -256,7 +324,20 @@ InTerminalContent(EventRecord* evt, WindowPtr wCurrPtr)
return;
}
}
#endif /* MOZILLA == 0 */
if (gControls->tw->proxySettingsBtn)
{
HLock((Handle)gControls->tw->proxySettingsBtn);
r = (**(gControls->tw->proxySettingsBtn)).contrlRect;
HUnlock((Handle)gControls->tw->proxySettingsBtn);
if (PtInRect(localPt, &r))
{
part = TrackControl(gControls->tw->proxySettingsBtn, evt->where, NULL);
if (part != 0)
OpenProxySettings();
return;
}
}
HLock((Handle)gControls->backB);
SetRect(&r, (**(gControls->backB)).contrlRect.left,
@ -280,6 +361,7 @@ InTerminalContent(EventRecord* evt, WindowPtr wCurrPtr)
ErrorHandler(eParam);
return;
}
ClearSaveBitsMsg();
/* treat last setup type selection as custom */
if (gControls->opt->instChoice == gControls->cfg->numSetupTypes)
@ -307,7 +389,7 @@ InTerminalContent(EventRecord* evt, WindowPtr wCurrPtr)
if (part)
{
DisableNavButtons();
ClearSiteSelector();
ClearDownloadSettings();
gInstallStarted = true;
SpawnSDThread(Install, &tid);
return;
@ -316,6 +398,148 @@ InTerminalContent(EventRecord* evt, WindowPtr wCurrPtr)
SetPort(oldPort);
}
void
my_c2pstrcpy(const char *aCStr, Str255 aPStr)
{
if (!aCStr)
return;
memcpy(&aPStr[1], aCStr, strlen(aCStr) > 255 ? 255 : strlen(aCStr));
aPStr[0] = strlen(aCStr);
}
#define rProxyHostItem 3
#define rProxyPortItem 4
#define rProxyUserItem 5
#define rProxyPswdItem 6
void
OpenProxySettings(void)
{
short itemHit = 999;
short itemType;
Handle item;
Rect itemBox;
Str255 itemText, pswdBuf, blindPswdText;
DialogPtr psDlg;
/* show dialog */
psDlg = GetNewDialog(rDlgProxySettg, NULL, (WindowPtr) -1);
/* pre-populate text fields */
if (gControls->opt->proxyHost)
{
my_c2pstrcpy(gControls->opt->proxyHost, itemText);
GetDialogItem(psDlg, rProxyHostItem, &itemType, &item, &itemBox);
SetDialogItemText(item, itemText);
}
if (gControls->opt->proxyPort)
{
my_c2pstrcpy(gControls->opt->proxyPort, itemText);
GetDialogItem(psDlg, rProxyPortItem, &itemType, &item, &itemBox);
SetDialogItemText(item, itemText);
}
if (gControls->opt->proxyUsername)
{
my_c2pstrcpy(gControls->opt->proxyUsername, itemText);
GetDialogItem(psDlg, rProxyUserItem, &itemType, &item, &itemBox);
SetDialogItemText(item, itemText);
}
if (gControls->opt->proxyPassword)
{
int pswdLen = strlen(gControls->opt->proxyPassword);
memset(&blindPswdText[1], '¥', pswdLen);
blindPswdText[0] = pswdLen;
GetDialogItem(psDlg, rProxyPswdItem, &itemType, &item, &itemBox);
SetDialogItemText(item, blindPswdText);
}
if (gControls->opt->proxyPassword)
my_c2pstrcpy(gControls->opt->proxyPassword, pswdBuf);
else
pswdBuf[0] = 0;
do
{
ModalDialog(NULL, &itemHit);
/* special handling for "blind" password field */
if (itemHit == rProxyPswdItem)
{
GetDialogItem(psDlg, rProxyPswdItem, &itemType, &item, &itemBox);
GetDialogItemText(item, itemText);
/* char deleted ? */
if (itemText[0] < pswdBuf[0])
{
/* truncate password buffer */
pswdBuf[0] = itemText[0];
}
else
{
/* store new char in password buffer */
pswdBuf[itemText[0]] = itemText[itemText[0]];
pswdBuf[0] = itemText[0];
}
memset(&blindPswdText[1], '¥', pswdBuf[0]);
blindPswdText[0] = itemText[0];
SetDialogItemText(item, blindPswdText);
}
} while(itemHit != 1 && itemHit != 2);
/* if OK was hit then take changed settings */
if (itemHit == 1)
{
GetDialogItem(psDlg, rProxyHostItem, &itemType, &item, &itemBox);
GetDialogItemText(item, itemText);
if (itemText[0] > 0)
{
if (gControls->opt->proxyHost)
free(gControls->opt->proxyHost);
gControls->opt->proxyHost = (char *) malloc(itemText[0] + 1);
strncpy(gControls->opt->proxyHost, (const char *)&itemText[1], itemText[0]);
*(gControls->opt->proxyHost + itemText[0]) = 0;
}
GetDialogItem(psDlg, rProxyPortItem, &itemType, &item, &itemBox);
GetDialogItemText(item, itemText);
if (itemText[0] > 0)
{
if (gControls->opt->proxyPort)
free(gControls->opt->proxyPort);
gControls->opt->proxyPort = (char *) malloc(itemText[0] + 1);
strncpy(gControls->opt->proxyPort, (const char *)&itemText[1], itemText[0]);
*(gControls->opt->proxyPort + itemText[0]) = 0;
}
GetDialogItem(psDlg, rProxyUserItem, &itemType, &item, &itemBox);
GetDialogItemText(item, itemText);
if (itemText[0] > 0)
{
if (gControls->opt->proxyUsername)
free(gControls->opt->proxyUsername);
gControls->opt->proxyUsername = (char *) malloc(itemText[0] + 1);
strncpy(gControls->opt->proxyUsername, (const char *)&itemText[1], itemText[0]);
*(gControls->opt->proxyUsername + itemText[0]) = 0;
}
if (pswdBuf[0] > 0)
{
if (gControls->opt->proxyPassword)
free(gControls->opt->proxyPassword);
gControls->opt->proxyPassword = (char *) malloc(pswdBuf[0] + 1);
strncpy(gControls->opt->proxyPassword, (const char *)&pswdBuf[1], pswdBuf[0]);
*(gControls->opt->proxyPassword + pswdBuf[0]) = 0;
}
}
DisposeDialog(psDlg);
}
Boolean
SpawnSDThread(ThreadEntryProcPtr threadProc, ThreadID *tid)
{
@ -335,15 +559,43 @@ SpawnSDThread(ThreadEntryProcPtr threadProc, ThreadID *tid)
}
void
ClearSiteSelector(void)
{
#if MOZILLA == 0
if (gControls->tw->siteSelector)
HideControl(gControls->tw->siteSelector);
#endif /* MOZILLA == 0*/
// erase the rect contents to get rid of the message
EraseRect(&gControls->tw->startMsgBox);
ClearDownloadSettings(void)
{
GrafPtr oldPort;
GetPort(&oldPort);
if (gWPtr)
{
SetPort(gWPtr);
if (gControls->tw->dlSettingsGB)
DisposeControl(gControls->tw->dlSettingsGB);
if (gControls->tw->startMsg)
EraseRect(&gControls->tw->startMsgBox);
if (gControls->tw->siteSelector)
DisposeControl(gControls->tw->siteSelector);
if (gControls->tw->siteSelMsg)
DisposeControl(gControls->tw->siteSelMsg);
if (gControls->tw->saveBitsMsg)
EraseRect(&gControls->tw->saveBitsMsgBox);
if (gControls->tw->saveBitsCheckbox)
DisposeControl(gControls->tw->saveBitsCheckbox);
if (gControls->tw->proxySettingsBtn)
DisposeControl(gControls->tw->proxySettingsBtn);
}
SetPort(oldPort);
}
void
ClearSaveBitsMsg(void)
{
if (gControls->tw->saveBitsMsg)
EraseRect(&gControls->tw->saveBitsMsgBox);
}
void
@ -351,10 +603,12 @@ EnableTerminalWin(void)
{
EnableNavButtons();
#if MOZILLA == 0
if (gControls->tw->siteSelector)
HiliteControl(gControls->tw->siteSelector, kEnableControl);
#endif /* MOZILLA == 0 */
if (gControls->tw->saveBitsCheckbox)
HiliteControl(gControls->tw->saveBitsCheckbox, kEnableControl);
if (gControls->tw->proxySettingsBtn)
HiliteControl(gControls->tw->proxySettingsBtn, kEnableControl);
}
void
@ -362,8 +616,10 @@ DisableTerminalWin(void)
{
DisableNavButtons();
#if MOZILLA == 0
if (gControls->tw->siteSelector)
HiliteControl(gControls->tw->siteSelector, kDisableControl);
#endif /* MOZILLA == 0 */
if (gControls->tw->saveBitsCheckbox)
HiliteControl(gControls->tw->saveBitsCheckbox, kDisableControl);
if (gControls->tw->proxySettingsBtn)
HiliteControl(gControls->tw->proxySettingsBtn, kDisableControl);
}

Просмотреть файл

@ -32,8 +32,6 @@ ShowWelcomeWin(void)
{
Str255 next;
Str255 back;
Rect sbRect;
int sbWidth;
GrafPtr oldPort;
GetPort(&oldPort);
@ -43,85 +41,65 @@ ShowWelcomeWin(void)
SetPort(gWPtr);
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);
ShowWelcomeMsg();
ShowNavButtons(back, next);
if (gControls->cfg->bReadme)
ShowReadmeButton();
ShowControl( gControls->ww->scrollBar);
ShowControl( gControls->ww->welcBox);
ShowTxt();
InitScrollBar( gControls->ww->scrollBar);
}
SetPort(oldPort);
}
void
InitWelcTxt(void)
{
Rect viewRect, destRect;
long welcStrLen;
int i;
/* TE specific init */
HLock( (Handle) gControls->ww->welcBox);
viewRect = (*(gControls->ww->welcBox))->contrlRect;
HUnlock( (Handle) gControls->ww->welcBox);
destRect.left = viewRect.left;
viewRect.right = (*(gControls->ww->scrollBar))->contrlRect.left;
destRect.right = viewRect.right - 1;
destRect.top = viewRect.top;
destRect.bottom = viewRect.bottom * kNumWelcScrns; /* XXX: hack */
TextFont(applFont);
TextFace(normal);
TextSize(12);
gControls->ww->welcTxt = TENew( &destRect, &viewRect);
if (!gControls->ww->welcTxt)
{
ErrorHandler(eMem);
return;
ShowWelcomeMsg(void)
{
int welcStrLen, i;
for (i = 0; i < kNumWelcMsgs; i++)
{
gControls->ww->welcMsgCntl[i] = GetNewControl(rWelcMsgTextbox+i, gWPtr);
if (!gControls->ww->welcMsgCntl)
{
ErrorHandler(eMem);
return;
}
}
ControlFontStyleRec fontStyle;
for (i=0; i<kNumWelcMsgs; 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( "\r\r", 2, gControls->ww->welcTxt);
fontStyle.flags = kControlUseSizeMask | kControlUseFaceMask;
fontStyle.size = 20;
fontStyle.style = bold;
SetControlFontStyle(gControls->ww->welcMsgCntl[0], &fontStyle);
HLock(gControls->cfg->welcMsg[0]);
welcStrLen = strlen(*gControls->cfg->welcMsg[0]);
HUnlock(gControls->cfg->welcMsg[0]);
SetControlData(gControls->ww->welcMsgCntl[0], kControlNoPart,
kControlStaticTextTextTag, welcStrLen, (Ptr)*gControls->cfg->welcMsg[0]);
fontStyle.flags = kControlUseSizeMask;
fontStyle.size = 12;
for (i = 1; i < kNumWelcMsgs; i++)
{
SetControlFontStyle(gControls->ww->welcMsgCntl[i], &fontStyle);
HLock(gControls->cfg->welcMsg[i]);
welcStrLen = strlen(*gControls->cfg->welcMsg[i]);
HUnlock(gControls->cfg->welcMsg[i]);
SetControlData(gControls->ww->welcMsgCntl[i], kControlNoPart,
kControlStaticTextTextTag, welcStrLen, (Ptr)*gControls->cfg->welcMsg[i]);
}
for (i = 0; i < kNumWelcMsgs; i++)
{
ShowControl(gControls->ww->welcMsgCntl[i]);
}
TextFont(systemFont);
TextSize(12);
TESetAlignment(teFlushDefault, gControls->ww->welcTxt);
}
void
@ -129,59 +107,14 @@ InWelcomeContent(EventRecord* evt, WindowPtr wCurrPtr)
{
Point localPt;
Rect r;
short code, value;
ControlPartCode part;
ControlHandle scrollBar;
ControlActionUPP scrollActionFunctionUPP;
GrafPtr oldPort;
GetPort(&oldPort);
SetPort(wCurrPtr);
localPt = evt->where;
GlobalToLocal( &localPt);
code = FindControl(localPt, wCurrPtr, &scrollBar);
switch (code)
{
case kControlUpButtonPart:
case kControlDownButtonPart:
case kControlPageUpPart:
case kControlPageDownPart:
scrollActionFunctionUPP = NewControlActionProc((ProcPtr) DoScrollProc);
value = TrackControl(scrollBar, localPt, scrollActionFunctionUPP);
DisposeRoutineDescriptor(scrollActionFunctionUPP);
return;
case kControlIndicatorPart:
value = GetControlValue(scrollBar);
code = TrackControl(scrollBar, localPt, nil);
if (code)
{
value -= GetControlValue(scrollBar);
if (value)
{
TEScroll(0, value * kScrollAmount, gControls->ww->welcTxt);
}
}
return;
}
#if 0
HLock((Handle)gControls->backB);
r = (**(gControls->backB)).contrlRect;
HUnlock((Handle)gControls->backB);
if (PtInRect( localPt, &r))
{
part = TrackControl(gControls->backB, evt->where, NULL);
if (part)
{
KillControls(gWPtr);
ShowLicenseWin();
return;
}
}
#endif
HLock((Handle)gControls->nextB);
r = (**(gControls->nextB)).contrlRect;
HUnlock((Handle)gControls->nextB);
@ -191,7 +124,7 @@ InWelcomeContent(EventRecord* evt, WindowPtr wCurrPtr)
if (part)
{
KillControls(gWPtr);
ShowSetupTypeWin();
ShowLicenseWin();
return;
}
}
@ -212,6 +145,20 @@ InWelcomeContent(EventRecord* evt, WindowPtr wCurrPtr)
SetPort(oldPort);
}
void
ShowCancelButton(void)
{
Str255 cancelStr;
GetIndString(cancelStr, rStringList, sCancel);
gControls->cancelB = GetNewControl(rCancelBtn, gWPtr);
if (gControls->cancelB != NULL)
{
SetControlTitle(gControls->cancelB, cancelStr);
ShowControl(gControls->cancelB);
}
}
void
ShowReadmeButton(void)
{
@ -284,9 +231,6 @@ EnableWelcomeWin(void)
if (gControls->cfg->bReadme)
if (gControls->ww->readmeButton)
HiliteControl(gControls->ww->readmeButton, kEnableControl);
if(gControls->ww->scrollBar)
HiliteControl(gControls->ww->scrollBar, kEnableControl);
}
void
@ -297,9 +241,6 @@ DisableWelcomeWin(void)
if (gControls->cfg->bReadme)
if (gControls->ww->readmeButton)
HiliteControl(gControls->ww->readmeButton, kDisableControl);
if(gControls->ww->scrollBar)
HiliteControl(gControls->ww->scrollBar, kDisableControl);
}
OSErr LaunchAppOpeningDoc (Boolean running, FSSpec *appSpec, ProcessSerialNumber *psn,