зеркало из https://github.com/mozilla/gecko-dev.git
Add pause/resume to mac installer download. (b=77979; r=ssu; sr=mscott)
This commit is contained in:
Родитель
4a0d5c8e46
Коммит
35dcb93929
|
@ -34,7 +34,7 @@ instStrSelectSite=Select a download site:
|
|||
instStrDownloading=Downloading:
|
||||
instStrFrom= From:
|
||||
instStrTo= To:
|
||||
instStrRate= Rate:
|
||||
instStrRate= Status:
|
||||
instStrTimeLeft= Time left:
|
||||
instStrDownloadKB= %d1 KB of %d2 KB (%.2f KB/sec)
|
||||
instBtnDelete=Delete
|
||||
|
|
|
@ -34,7 +34,7 @@ instStrSelectSite=Select a download site:
|
|||
instStrDownloading=Downloading:
|
||||
instStrFrom= From:
|
||||
instStrTo= To:
|
||||
instStrRate= Rate:
|
||||
instStrRate= Status:
|
||||
instStrTimeLeft= Time left:
|
||||
instStrDownloadKB= %d1 KB of %d2 KB (%.2f KB/sec)
|
||||
instBtnDelete=Delete
|
||||
|
|
|
@ -104,7 +104,6 @@ void HandleMouseDown(EventRecord* evt)
|
|||
void HandleKeyDown(EventRecord* evt)
|
||||
{
|
||||
char keyPressed;
|
||||
ThreadID tid;
|
||||
unsigned long finalTicks;
|
||||
|
||||
keyPressed = evt->message & charCodeMask;
|
||||
|
@ -162,10 +161,7 @@ void HandleKeyDown(EventRecord* evt)
|
|||
case kTerminalID:
|
||||
if (!gInstallStarted)
|
||||
{
|
||||
DisableNavButtons();
|
||||
ClearDownloadSettings();
|
||||
gInstallStarted = true;
|
||||
SpawnSDThread(Install, &tid);
|
||||
BeginInstall();
|
||||
}
|
||||
return;
|
||||
default:
|
||||
|
@ -392,6 +388,8 @@ DidUserCancel(EventRecord *evt)
|
|||
r = (**(gControls->cancelB)).contrlRect;
|
||||
HUnlock((Handle)gControls->cancelB);
|
||||
if (PtInRect(localPt, &r))
|
||||
{
|
||||
if (gControls->state == eInstallNotStarted)
|
||||
{
|
||||
part = TrackControl(gControls->cancelB, evt->where, NULL);
|
||||
if (part)
|
||||
|
@ -400,6 +398,7 @@ DidUserCancel(EventRecord *evt)
|
|||
bUserCancelled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetPort(oldPort);
|
||||
return bUserCancelled;
|
||||
|
|
|
@ -39,6 +39,8 @@ static int sCurrFullPathLen = 0;
|
|||
static char *sCurrURL = 0;
|
||||
static time_t sCurrStartTime; /* start of download of current file */
|
||||
|
||||
ConstStr255Param kDLMarker = "\pCurrent Download";
|
||||
|
||||
pascal void* Install(void* unused)
|
||||
{
|
||||
short vRefNum, srcVRefNum;
|
||||
|
@ -121,14 +123,20 @@ pascal void* Install(void* unused)
|
|||
HUnlock(gControls->cfg->site[siteIndex].domain);
|
||||
}
|
||||
|
||||
if (gControls->state != eResuming)
|
||||
InitDLProgControls();
|
||||
dlErr = DownloadXPIs(srcVRefNum, srcDirID);
|
||||
if (dlErr == nsFTPConn::E_USER_CANCEL)
|
||||
{
|
||||
return (void *) nil;
|
||||
}
|
||||
if (dlErr != 0)
|
||||
{
|
||||
ErrorHandler(dlErr);
|
||||
return (void*) nil;
|
||||
}
|
||||
ClearDLProgControls();
|
||||
DisableNavButtons();
|
||||
|
||||
SetPort(oldPort);
|
||||
|
||||
|
@ -149,7 +157,7 @@ pascal void* Install(void* unused)
|
|||
}
|
||||
else
|
||||
bCoreExists = true;
|
||||
/* otherwise core exists in cwd:InstallerModules, different from extraction location */
|
||||
/* otherwise core exists in cwd:Installer Modules, different from extraction location */
|
||||
|
||||
|
||||
/* check if coreFile was downloaded */
|
||||
|
@ -230,6 +238,7 @@ ComputeTotalDLSize(void)
|
|||
(gControls->cfg->comp[i].selected == true)) ||
|
||||
(instChoice < gControls->cfg->numSetupTypes-1) )
|
||||
{
|
||||
// XXX should this change to look at archive size instead?
|
||||
totalDLSize += gControls->cfg->comp[i].size;
|
||||
|
||||
compsDone++;
|
||||
|
@ -248,15 +257,17 @@ DownloadXPIs(short destVRefNum, long destDirID)
|
|||
short rv = 0;
|
||||
Handle dlPath;
|
||||
short dlPathLen = 0;
|
||||
int i, compsDone, instChoice;
|
||||
int i, compsDone = 0, instChoice = gControls->opt->instChoice-1, resPos = 0;
|
||||
Boolean bResuming = false;
|
||||
int markedIndex = 0;
|
||||
|
||||
GetFullPath(destVRefNum, destDirID, "\p", &dlPathLen, &dlPath);
|
||||
|
||||
compsDone = 0;
|
||||
instChoice = gControls->opt->instChoice-1;
|
||||
DLMarkerGetCurrent(&markedIndex, &compsDone);
|
||||
if (markedIndex >= 0)
|
||||
resPos = GetResPos(&gControls->cfg->comp[markedIndex]);
|
||||
|
||||
// loop through 0 to kMaxComponents
|
||||
for(i=0; i<kMaxComponents; i++)
|
||||
for(i = 0; i < kMaxComponents; i++)
|
||||
{
|
||||
// general test: if component in setup type
|
||||
if ( (gControls->cfg->st[instChoice].comp[i] == kInSetupType) &&
|
||||
|
@ -267,19 +278,38 @@ DownloadXPIs(short destVRefNum, long destDirID)
|
|||
(gControls->cfg->comp[i].selected == true)) ||
|
||||
(instChoice < gControls->cfg->numSetupTypes-1) )
|
||||
{
|
||||
// stat file even if index is less than markedIndex
|
||||
// and download file if it isn't locally there;
|
||||
// this can happen if a new setup type was selected
|
||||
if (i < markedIndex)
|
||||
{
|
||||
if (noErr == ExistsXPI(i))
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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 (i == markedIndex && resPos > 0)
|
||||
{
|
||||
gControls->resPos = resPos;
|
||||
gControls->state = eResuming;
|
||||
}
|
||||
rv = DownloadFile(dlPath, dlPathLen, gControls->cfg->comp[i].archive, resPos);
|
||||
if (rv == nsFTPConn::E_USER_CANCEL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (rv != 0)
|
||||
{
|
||||
ErrorHandler(rv);
|
||||
break;
|
||||
}
|
||||
|
||||
resPos = 0; // reset after first file was resumed in the middle
|
||||
gControls->state = eDownloading;
|
||||
compsDone++;
|
||||
}
|
||||
}
|
||||
|
@ -287,6 +317,9 @@ DownloadXPIs(short destVRefNum, long destDirID)
|
|||
break;
|
||||
}
|
||||
|
||||
if (rv == 0)
|
||||
DLMarkerDelete();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -294,15 +327,17 @@ const char kHTTP[8] = "http://";
|
|||
const char kFTP[7] = "ftp://";
|
||||
|
||||
short
|
||||
DownloadFile(Handle destFolder, long destFolderLen, Handle archive)
|
||||
DownloadFile(Handle destFolder, long destFolderLen, Handle archive, int resPos)
|
||||
{
|
||||
short rv = 0;
|
||||
char *URL = 0, *proxyServerURL = 0, *destFile = 0, *destFolderCopy = 0;
|
||||
int globalURLLen, archiveLen, proxyServerURLLen;
|
||||
char *ftpHost = 0, *ftpPath = 0;
|
||||
Boolean bGetTried = false;
|
||||
|
||||
// make URL using globalURL
|
||||
HLock(archive);
|
||||
DLMarkerSetCurrent(*archive);
|
||||
HLock(gControls->cfg->globalURL);
|
||||
globalURLLen = strlen(*gControls->cfg->globalURL);
|
||||
archiveLen = strlen(*archive);
|
||||
|
@ -348,7 +383,8 @@ DownloadFile(Handle destFolder, long destFolderLen, Handle archive)
|
|||
if (rv == nsHTTPConn::OK)
|
||||
{
|
||||
sCurrStartTime = time(NULL);
|
||||
rv = conn->Get(DLProgressCB, destFile);
|
||||
bGetTried = true;
|
||||
rv = conn->Get(DLProgressCB, destFile, resPos);
|
||||
conn->Close();
|
||||
}
|
||||
}
|
||||
|
@ -363,7 +399,8 @@ DownloadFile(Handle destFolder, long destFolderLen, Handle archive)
|
|||
if (rv == nsHTTPConn::OK)
|
||||
{
|
||||
sCurrStartTime = time(NULL);
|
||||
rv = conn->Get(DLProgressCB, destFile);
|
||||
bGetTried = true;
|
||||
rv = conn->Get(DLProgressCB, destFile, resPos);
|
||||
conn->Close();
|
||||
}
|
||||
}
|
||||
|
@ -385,7 +422,8 @@ DownloadFile(Handle destFolder, long destFolderLen, Handle archive)
|
|||
if (rv == nsFTPConn::OK)
|
||||
{
|
||||
sCurrStartTime = time(NULL);
|
||||
rv = conn->Get(ftpPath, destFile, nsFTPConn::BINARY, 1, DLProgressCB);
|
||||
bGetTried = true;
|
||||
rv = conn->Get(ftpPath, destFile, nsFTPConn::BINARY, resPos, 1, DLProgressCB);
|
||||
conn->Close();
|
||||
}
|
||||
}
|
||||
|
@ -399,9 +437,238 @@ DownloadFile(Handle destFolder, long destFolderLen, Handle archive)
|
|||
else
|
||||
rv = nsHTTPConn::E_MALFORMED_URL;
|
||||
|
||||
if (bGetTried && rv != 0)
|
||||
{
|
||||
/* the get failed before completing; simulate pause */
|
||||
SetPausedState();
|
||||
rv = nsFTPConn::E_USER_CANCEL;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
OSErr
|
||||
DLMarkerSetCurrent(char *aXPIName)
|
||||
{
|
||||
OSErr err = noErr;
|
||||
short vRefNum = 0;
|
||||
long dirID = 0;
|
||||
FSSpec fsMarker;
|
||||
short markerRefNum;
|
||||
long count = 0;
|
||||
|
||||
if (!aXPIName)
|
||||
return paramErr;
|
||||
|
||||
err = GetInstallerModules(&vRefNum, &dirID);
|
||||
if (err != noErr)
|
||||
return err;
|
||||
|
||||
// check if marker file exists
|
||||
err = FSMakeFSSpec(vRefNum, dirID, kDLMarker, &fsMarker);
|
||||
|
||||
// delete old marker and recreate it so we truncate to 0
|
||||
if (err == noErr)
|
||||
FSpDelete(&fsMarker);
|
||||
|
||||
err = FSpCreate(&fsMarker, 'ttxt', 'TEXT', smSystemScript);
|
||||
if (err != noErr)
|
||||
return err;
|
||||
|
||||
// open data fork
|
||||
err = FSpOpenDF(&fsMarker, fsWrPerm, &markerRefNum);
|
||||
if (err != noErr)
|
||||
goto BAIL;
|
||||
|
||||
// write xpi name into marker's data fork at offset 0
|
||||
count = strlen(aXPIName);
|
||||
err = FSWrite(markerRefNum, &count, (void *) aXPIName);
|
||||
|
||||
BAIL:
|
||||
// close marker file
|
||||
FSClose(markerRefNum);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
OSErr
|
||||
DLMarkerGetCurrent(int *aMarkedIndex, int *aCompsDone)
|
||||
{
|
||||
OSErr err = noErr;
|
||||
char xpiName[255];
|
||||
short vRefNum = 0;
|
||||
long dirID = 0;
|
||||
long count = 0;
|
||||
FSSpec fsMarker;
|
||||
short markerRefNum;
|
||||
|
||||
if (!aMarkedIndex || !aCompsDone)
|
||||
return paramErr;
|
||||
|
||||
err = GetInstallerModules(&vRefNum, &dirID);
|
||||
if (err != noErr)
|
||||
return err;
|
||||
|
||||
// check if marker file exists
|
||||
err = FSMakeFSSpec(vRefNum, dirID, kDLMarker, &fsMarker);
|
||||
if (err == noErr)
|
||||
{
|
||||
// open for reading
|
||||
err = FSpOpenDF(&fsMarker, fsRdPerm, &markerRefNum);
|
||||
if (err != noErr)
|
||||
goto CLOSE_FILE;
|
||||
|
||||
// get file size
|
||||
err = GetEOF(markerRefNum, &count);
|
||||
if (err != noErr)
|
||||
goto CLOSE_FILE;
|
||||
|
||||
// read file contents
|
||||
err = FSRead(markerRefNum, &count, (void *) xpiName);
|
||||
if (err == noErr)
|
||||
{
|
||||
if (count <= 0)
|
||||
err = readErr;
|
||||
else
|
||||
{
|
||||
xpiName[count] = 0; // ensure only reading 'count' bytes
|
||||
err = GetIndexFromName(xpiName, aMarkedIndex, aCompsDone);
|
||||
}
|
||||
}
|
||||
|
||||
CLOSE_FILE:
|
||||
// close file
|
||||
FSClose(markerRefNum);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
OSErr
|
||||
DLMarkerDelete(void)
|
||||
{
|
||||
OSErr err;
|
||||
short vRefNum = 0;
|
||||
long dirID = 0;
|
||||
FSSpec fsMarker;
|
||||
|
||||
err = GetInstallerModules(&vRefNum, &dirID);
|
||||
if (err == noErr)
|
||||
{
|
||||
err = FSMakeFSSpec(vRefNum, dirID, kDLMarker, &fsMarker);
|
||||
if (err == noErr)
|
||||
FSpDelete(&fsMarker);
|
||||
}
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
OSErr
|
||||
GetIndexFromName(char *aXPIName, int *aIndex, int *aCompsDone)
|
||||
{
|
||||
OSErr err = noErr;
|
||||
int i, compsDone = 0, instChoice = gControls->opt->instChoice - 1;
|
||||
|
||||
if (!aXPIName || !aIndex || !aCompsDone)
|
||||
return paramErr;
|
||||
|
||||
// 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) )
|
||||
{
|
||||
HLock(gControls->cfg->comp[i].archive);
|
||||
if (strncmp(aXPIName, (*(gControls->cfg->comp[i].archive)), strlen(aXPIName)) == 0)
|
||||
{
|
||||
HUnlock(gControls->cfg->comp[i].archive);
|
||||
*aIndex = i;
|
||||
*aCompsDone = compsDone;
|
||||
break;
|
||||
}
|
||||
else
|
||||
HUnlock(gControls->cfg->comp[i].archive);
|
||||
compsDone++;
|
||||
}
|
||||
}
|
||||
else if (compsDone >= gControls->cfg->st[instChoice].numComps)
|
||||
{
|
||||
err = userDataItemNotFound;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
GetResPos(InstComp *aComp)
|
||||
{
|
||||
OSErr err = noErr;
|
||||
int resPos = 0;
|
||||
short vRefNum = 0;
|
||||
long dirID = 0;
|
||||
Str255 pArchiveName;
|
||||
long dataSize = 0, rsrcSize = 0;
|
||||
|
||||
if (!aComp)
|
||||
return 0;
|
||||
|
||||
err = GetInstallerModules(&vRefNum, &dirID);
|
||||
if (err == noErr)
|
||||
{
|
||||
HLock(aComp->archive);
|
||||
my_c2pstrcpy(*(aComp->archive), pArchiveName);
|
||||
HUnlock(aComp->archive);
|
||||
|
||||
err = GetFileSize(vRefNum, dirID, pArchiveName, &dataSize, &rsrcSize);
|
||||
if (err == noErr && dataSize > 0)
|
||||
resPos = dataSize;
|
||||
}
|
||||
|
||||
return resPos;
|
||||
}
|
||||
|
||||
OSErr
|
||||
GetInstallerModules(short *aVRefNum, long *aDirID)
|
||||
{
|
||||
short cwdVRefNum = 0;
|
||||
long cwdDirID = 0, imDirID = 0;
|
||||
OSErr err;
|
||||
Boolean isDir = false;
|
||||
Str255 pIMFolder; // "Installer Modules" fodler
|
||||
|
||||
if (!aVRefNum || !aDirID)
|
||||
return paramErr;
|
||||
|
||||
*aVRefNum = 0;
|
||||
*aDirID = 0;
|
||||
|
||||
err = GetCWD(&cwdDirID, &cwdVRefNum);
|
||||
if (err != noErr)
|
||||
return err;
|
||||
|
||||
GetIndString(pIMFolder, rStringList, sInstModules);
|
||||
err = GetDirectoryID(cwdVRefNum, cwdDirID, pIMFolder, &imDirID, &isDir);
|
||||
if (err != noErr)
|
||||
return err;
|
||||
|
||||
if (isDir)
|
||||
{
|
||||
*aVRefNum = cwdVRefNum;
|
||||
*aDirID = imDirID;
|
||||
}
|
||||
else
|
||||
return dirNFErr;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
ParseFTPURL(char *aURL, char **aHost, char **aPath)
|
||||
{
|
||||
|
@ -481,6 +748,14 @@ CompressToFit(char *origStr, char *outStr, int outStrLen)
|
|||
halfOutStrLen = outStrLen/2;
|
||||
lastPart = origStr + origStrLen - halfOutStrLen;
|
||||
|
||||
// don't truncate if already less than acceptable max len
|
||||
if (origStrLen < outStrLen)
|
||||
{
|
||||
strcpy(outStr, origStr);
|
||||
*(outStr + strlen(origStr)) = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
strncpy(outStr, origStr, halfOutStrLen);
|
||||
*(outStr + halfOutStrLen) = 0;
|
||||
strcat(outStr, "É");
|
||||
|
@ -500,11 +775,12 @@ ComputeRate(int bytes, time_t startTime, time_t endTime)
|
|||
}
|
||||
|
||||
#define kProgMsgLen 51
|
||||
#define kLowRateThreshold ((float)20)
|
||||
|
||||
int
|
||||
DLProgressCB(int aBytesSoFar, int aTotalFinalSize)
|
||||
{
|
||||
static int yielder = 0, yieldFrequency = 64;
|
||||
static int yielder = 0, yieldFrequency = 8;
|
||||
int len;
|
||||
char compressedStr[kProgMsgLen + 1]; // add one for NULL termination
|
||||
char *fullPathCopy = 0; // GetFullPath doesn't null terminate
|
||||
|
@ -514,6 +790,11 @@ DLProgressCB(int aBytesSoFar, int aTotalFinalSize)
|
|||
Str255 dlStr;
|
||||
char tmp[kKeyMaxLen];
|
||||
|
||||
if (gControls->state == ePaused)
|
||||
{
|
||||
return nsFTPConn::E_USER_CANCEL;
|
||||
}
|
||||
|
||||
if (aTotalFinalSize != sCurrTotalDLSize)
|
||||
{
|
||||
sCurrTotalDLSize = aTotalFinalSize;
|
||||
|
@ -579,18 +860,21 @@ DLProgressCB(int aBytesSoFar, int aTotalFinalSize)
|
|||
|
||||
if (gControls->tw->dlProgressBar)
|
||||
{
|
||||
if (++yielder == yieldFrequency)
|
||||
{
|
||||
SetControlValue(gControls->tw->dlProgressBar, (aBytesSoFar/1024));
|
||||
|
||||
// update rate info
|
||||
now = time(NULL);
|
||||
rate = ComputeRate(aBytesSoFar, sCurrStartTime, now);
|
||||
|
||||
if ((rate < kLowRateThreshold) || ((++yielder) == yieldFrequency))
|
||||
{
|
||||
int adjustedBytesSoFar = aBytesSoFar;
|
||||
if (gControls->state == eResuming)
|
||||
adjustedBytesSoFar += gControls->resPos;
|
||||
SetControlValue(gControls->tw->dlProgressBar, (adjustedBytesSoFar/1024));
|
||||
|
||||
// create processing string "%d KB of %d KB (%.2f KB/sec)"
|
||||
GetResourcedString(dlStr, rInstList, sDownloadKB);
|
||||
strcpy(compressedStr, PascalToC(dlStr));
|
||||
sprintf(tmp, "%d", aBytesSoFar/1024);
|
||||
sprintf(tmp, "%d", adjustedBytesSoFar/1024);
|
||||
strtran(compressedStr, "%d1", tmp);
|
||||
sprintf(tmp, "%d", aTotalFinalSize/1024);
|
||||
strtran(compressedStr, "%d2", tmp);
|
||||
|
@ -854,6 +1138,30 @@ ExistArchives(short vRefNum, long dirID)
|
|||
return bAllExist;
|
||||
}
|
||||
|
||||
OSErr
|
||||
ExistsXPI(int aIndex)
|
||||
{
|
||||
OSErr err = noErr;
|
||||
FSSpec fsComp;
|
||||
short vRefNum = 0;
|
||||
long dirID = 0;
|
||||
Str255 pArchive;
|
||||
|
||||
if (aIndex < 0)
|
||||
return paramErr;
|
||||
|
||||
err = GetInstallerModules(&vRefNum, &dirID);
|
||||
if (err == noErr)
|
||||
{
|
||||
HLock(gControls->cfg->comp[aIndex].archive);
|
||||
my_c2pstrcpy(*(gControls->cfg->comp[aIndex].archive), pArchive);
|
||||
HUnlock(gControls->cfg->comp[aIndex].archive);
|
||||
err = FSMakeFSSpec(vRefNum, dirID, pArchive, &fsComp);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void
|
||||
LaunchApps(short vRefNum, long dirID)
|
||||
{
|
||||
|
|
|
@ -201,6 +201,8 @@ InitControlsObject(void)
|
|||
ErrorHandler(eMem);
|
||||
}
|
||||
|
||||
gControls->state = eInstallNotStarted;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -211,14 +211,12 @@ if (err) \
|
|||
|
||||
#define rAboutBox 128
|
||||
|
||||
|
||||
#define rStringList 140 // common strings
|
||||
#define sConfigFName 1
|
||||
#define sInstallFName 2
|
||||
#define sTempIDIName 3
|
||||
#define sConfigIDIName 4
|
||||
#define sInstModules 5
|
||||
#define eInstRead 6 //install.ini read failed
|
||||
|
||||
#define rTitleStrList 170
|
||||
#define sNSInstTitle 1
|
||||
|
@ -316,6 +314,7 @@ if (err) \
|
|||
#define eMenuHdl 11
|
||||
#define eCfgRead 12
|
||||
#define eDownload 13
|
||||
#define eInstRead 6 // installer.ini read failed
|
||||
|
||||
#define instErrsNum 13 /* number of the install.ini errors */
|
||||
|
||||
|
@ -365,8 +364,10 @@ if (err) \
|
|||
#define sSpaceMsg1 43
|
||||
#define sSpaceMsg2 44
|
||||
#define sSpaceMsg3 45
|
||||
#define sPauseBtn 46
|
||||
#define sResumeBtn 47
|
||||
|
||||
#define instKeysNum 45 /* number of the install.ini keys */
|
||||
#define instKeysNum 47 /* number of installer.ini keys */
|
||||
|
||||
#define rInstMenuList 146
|
||||
#define sMenuGeneral 1
|
||||
|
@ -534,6 +535,7 @@ typedef struct Options {
|
|||
char *proxyPort;
|
||||
char *proxyUsername;
|
||||
char *proxyPassword;
|
||||
|
||||
} Options;
|
||||
|
||||
typedef struct LicWin {
|
||||
|
@ -587,6 +589,15 @@ typedef struct TermWin {
|
|||
ControlHandle proxySettingsBtn;
|
||||
} TermWin;
|
||||
|
||||
typedef enum {
|
||||
eInstallNotStarted = 0,
|
||||
eDownloading,
|
||||
ePaused,
|
||||
eResuming,
|
||||
eExtracting,
|
||||
eInstalling
|
||||
} InstallState;
|
||||
|
||||
typedef struct InstWiz {
|
||||
|
||||
/* config.ini options parsed */
|
||||
|
@ -607,6 +618,10 @@ typedef struct InstWiz {
|
|||
ControlHandle backB;
|
||||
ControlHandle nextB;
|
||||
ControlHandle cancelB;
|
||||
|
||||
InstallState state;
|
||||
int resPos;
|
||||
|
||||
} InstWiz;
|
||||
|
||||
typedef struct InstINIRes {
|
||||
|
@ -728,7 +743,7 @@ static OSErr FindAppOnVolume (OSType, short, FSSpec *);
|
|||
OSErr GetSysVolume (short *);
|
||||
OSErr GetIndVolume (short, short *);
|
||||
OSErr GetLastModDateTime(const FSSpec *, unsigned long *);
|
||||
void InitNewMenu();
|
||||
void InitNewMenu(void);
|
||||
|
||||
/*-----------------------------------------------------------*
|
||||
* SetupTypeWin
|
||||
|
@ -792,6 +807,7 @@ void DisableAdditionsWin(void);
|
|||
*-----------------------------------------------------------*/
|
||||
void ShowTerminalWin(void);
|
||||
short GetRectFromRes(Rect *, short);
|
||||
void BeginInstall(void);
|
||||
void my_c2pstrcpy(const char *, Str255);
|
||||
void InTerminalContent(EventRecord*, WindowPtr);
|
||||
void UpdateTerminalWin(void);
|
||||
|
@ -801,6 +817,10 @@ void ClearDownloadSettings(void);
|
|||
void ClearSaveBitsMsg(void);
|
||||
void EnableTerminalWin(void);
|
||||
void DisableTerminalWin(void);
|
||||
void SetupPauseResumeButtons(void);
|
||||
void SetPausedState(void);
|
||||
void SetResumedState(void);
|
||||
|
||||
|
||||
/*-----------------------------------------------------------*
|
||||
* InstAction
|
||||
|
@ -808,7 +828,13 @@ void DisableTerminalWin(void);
|
|||
pascal void *Install(void*);
|
||||
long ComputeTotalDLSize(void);
|
||||
short DownloadXPIs(short, long);
|
||||
short DownloadFile(Handle, long, Handle);
|
||||
short DownloadFile(Handle, long, Handle, int);
|
||||
OSErr DLMarkerSetCurrent(char *);
|
||||
OSErr DLMarkerGetCurrent(int *, int*);
|
||||
OSErr DLMarkerDelete(void);
|
||||
int GetResPos(InstComp *);
|
||||
OSErr GetInstallerModules(short *, long *);
|
||||
OSErr GetIndexFromName(char *, int *, int *);
|
||||
int ParseFTPURL(char *, char **, char **);
|
||||
void CompressToFit(char *, char *, int);
|
||||
float ComputeRate(int, time_t, time_t);
|
||||
|
@ -817,6 +843,7 @@ void IfRemoveOldCore(short, long);
|
|||
Boolean GenerateIDIFromOpt(Str255, long, short, FSSpec *);
|
||||
void AddKeyToIDI(short, Handle, char *);
|
||||
Boolean ExistArchives(short, long);
|
||||
OSErr ExistsXPI(int);
|
||||
void LaunchApps(short, long);
|
||||
void RunApps(void);
|
||||
void DeleteXPIs(short, long);
|
||||
|
|
|
@ -1040,11 +1040,11 @@ VerifyDiskSpace(void)
|
|||
sprintf(dsAvailStr, "%d", sDSAvailK);
|
||||
|
||||
GetResourcedString(pMessage, rInstList, sSpaceMsg1);
|
||||
pstrcat(pMessage, CToPascal(dsNeededStr));
|
||||
pstrcat(pMessage, CToPascal("KB. \r"));
|
||||
pstrcat(pMessage, CToPascal(dsAvailStr));
|
||||
pstrcat(pMessage, CToPascal("KB \r"));
|
||||
GetResourcedString(pStr, rInstList, sSpaceMsg2);
|
||||
pstrcat(pStr, CToPascal(dsAvailStr));
|
||||
pstrcat(pStr, CToPascal("KB. \r\r"));
|
||||
pstrcat(pStr, CToPascal(dsNeededStr));
|
||||
pstrcat(pStr, CToPascal("KB \r\r"));
|
||||
pstrcat(pMessage, pStr);
|
||||
GetResourcedString(pStr, rInstList, sSpaceMsg3);
|
||||
pstrcat(pMessage, pStr);
|
||||
|
|
|
@ -284,7 +284,6 @@ InTerminalContent(EventRecord* evt, WindowPtr wCurrPtr)
|
|||
ControlPartCode part;
|
||||
ControlHandle currCntl;
|
||||
short checkboxVal;
|
||||
ThreadID tid;
|
||||
GrafPtr oldPort;
|
||||
GetPort(&oldPort);
|
||||
|
||||
|
@ -349,6 +348,9 @@ InTerminalContent(EventRecord* evt, WindowPtr wCurrPtr)
|
|||
{
|
||||
part = TrackControl(gControls->backB, evt->where, NULL);
|
||||
if (part)
|
||||
{
|
||||
/* before install has started */
|
||||
if (gControls->state == eInstallNotStarted)
|
||||
{
|
||||
KillControls(gWPtr);
|
||||
if (&gControls->tw->startMsgBox)
|
||||
|
@ -375,6 +377,13 @@ InTerminalContent(EventRecord* evt, WindowPtr wCurrPtr)
|
|||
ShowSetupTypeWin();
|
||||
return;
|
||||
}
|
||||
|
||||
/* pause button pressed */
|
||||
else if (gControls->state == eDownloading || gControls->state == eResuming)
|
||||
{
|
||||
SetPausedState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HLock((Handle)gControls->nextB);
|
||||
|
@ -388,14 +397,32 @@ InTerminalContent(EventRecord* evt, WindowPtr wCurrPtr)
|
|||
part = TrackControl(gControls->nextB, evt->where, NULL);
|
||||
if (part)
|
||||
{
|
||||
DisableNavButtons();
|
||||
BeginInstall();
|
||||
}
|
||||
}
|
||||
|
||||
SetPort(oldPort);
|
||||
}
|
||||
|
||||
void
|
||||
BeginInstall(void)
|
||||
{
|
||||
ThreadID tid;
|
||||
|
||||
/* starting download first time or resume download */
|
||||
if (gControls->state == eInstallNotStarted || gControls->state == ePaused)
|
||||
{
|
||||
if (gControls->state == eInstallNotStarted)
|
||||
{
|
||||
SetupPauseResumeButtons();
|
||||
ClearDownloadSettings();
|
||||
gInstallStarted = true;
|
||||
}
|
||||
else if (gControls->state == ePaused)
|
||||
SetResumedState();
|
||||
|
||||
SpawnSDThread(Install, &tid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
SetPort(oldPort);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -632,6 +659,8 @@ ClearSaveBitsMsg(void)
|
|||
void
|
||||
EnableTerminalWin(void)
|
||||
{
|
||||
if (gControls->state == eInstallNotStarted)
|
||||
{
|
||||
EnableNavButtons();
|
||||
|
||||
if (gControls->tw->siteSelector)
|
||||
|
@ -640,6 +669,25 @@ EnableTerminalWin(void)
|
|||
HiliteControl(gControls->tw->saveBitsCheckbox, kEnableControl);
|
||||
if (gControls->tw->proxySettingsBtn)
|
||||
HiliteControl(gControls->tw->proxySettingsBtn, kEnableControl);
|
||||
}
|
||||
else if (gControls->state == eDownloading || gControls->state == eResuming)
|
||||
{
|
||||
if (gControls->nextB)
|
||||
HiliteControl(gControls->nextB, kDisableControl);
|
||||
if (gControls->backB)
|
||||
HiliteControl(gControls->backB, kEnableControl);
|
||||
if (gControls->cancelB)
|
||||
HiliteControl(gControls->cancelB, kDisableControl);
|
||||
}
|
||||
else if (gControls->state == ePaused)
|
||||
{
|
||||
if (gControls->nextB)
|
||||
HiliteControl(gControls->nextB, kEnableControl);
|
||||
if (gControls->backB)
|
||||
HiliteControl(gControls->backB, kDisableControl);
|
||||
if (gControls->cancelB)
|
||||
HiliteControl(gControls->cancelB, kDisableControl);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -654,3 +702,66 @@ DisableTerminalWin(void)
|
|||
if (gControls->tw->proxySettingsBtn)
|
||||
HiliteControl(gControls->tw->proxySettingsBtn, kDisableControl);
|
||||
}
|
||||
|
||||
void
|
||||
SetupPauseResumeButtons(void)
|
||||
{
|
||||
Str255 pPauseLabel, pResumeLabel;
|
||||
|
||||
/* rename labels to pause/resume */
|
||||
if (gControls->backB)
|
||||
{
|
||||
GetResourcedString(pPauseLabel, rInstList, sPauseBtn);
|
||||
SetControlTitle(gControls->backB, pPauseLabel);
|
||||
ShowControl(gControls->backB);
|
||||
}
|
||||
|
||||
if (gControls->nextB)
|
||||
{
|
||||
GetResourcedString(pResumeLabel, rInstList, sResumeBtn);
|
||||
SetControlTitle(gControls->nextB, pResumeLabel);
|
||||
ShowControl(gControls->nextB);
|
||||
}
|
||||
|
||||
/* disable cancel button */
|
||||
if (gControls->cancelB)
|
||||
HiliteControl(gControls->cancelB, kDisableControl);
|
||||
|
||||
/* disable pause button */
|
||||
if (gControls->nextB)
|
||||
HiliteControl(gControls->nextB, kDisableControl);
|
||||
|
||||
/* enable resume button */
|
||||
if (gControls->backB)
|
||||
HiliteControl(gControls->backB, kEnableControl);
|
||||
|
||||
gControls->state = eDownloading;
|
||||
}
|
||||
|
||||
void
|
||||
SetPausedState(void)
|
||||
{
|
||||
/* disable resume button */
|
||||
if (gControls->backB)
|
||||
HiliteControl(gControls->backB, kDisableControl);
|
||||
|
||||
/* enable pause button */
|
||||
if (gControls->nextB)
|
||||
HiliteControl(gControls->nextB, kEnableControl);
|
||||
|
||||
gControls->state = ePaused;
|
||||
}
|
||||
|
||||
void
|
||||
SetResumedState(void)
|
||||
{
|
||||
/* disable pause button */
|
||||
if (gControls->nextB)
|
||||
HiliteControl(gControls->nextB, kDisableControl);
|
||||
|
||||
/* enable resume button */
|
||||
if (gControls->backB)
|
||||
HiliteControl(gControls->backB, kEnableControl);
|
||||
|
||||
gControls->state = eResuming;
|
||||
}
|
Загрузка…
Ссылка в новой задаче