Add ability to failover to a series of global URLs in the Mac installer. [b = 84122; r = ssu; sr= alecf; a = drivers]

This commit is contained in:
sgehani%netscape.com 2001-06-22 14:58:18 +00:00
Родитель fffedf28a1
Коммит 57cfad048d
5 изменённых файлов: 54 добавлений и 29 удалений

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

@ -1,6 +1,6 @@
[General]
Subfolder=Mozilla Folder
URL=ftp://ftp.mozilla.org/pub/mozilla/nightly/<#buildID>/mac-xpi/
URL0=ftp://ftp.mozilla.org/pub/mozilla/nightly/<#buildID>/mac-xpi/
[Dialog License]

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

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

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

@ -111,15 +111,15 @@ pascal void* Install(void* unused)
/* 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);
if (gControls->cfg->globalURL[0])
DisposeHandle(gControls->cfg->globalURL[0]);
gControls->cfg->globalURL[0] = NewHandleClear(kValueMaxLen);
siteIndex = gControls->opt->siteChoice - 1;
HLock(gControls->cfg->globalURL);
HLock(gControls->cfg->globalURL[0]);
HLock(gControls->cfg->site[siteIndex].domain);
strcpy(*(gControls->cfg->globalURL), *(gControls->cfg->site[siteIndex].domain));
HUnlock(gControls->cfg->globalURL);
strcpy(*(gControls->cfg->globalURL[0]), *(gControls->cfg->site[siteIndex].domain));
HUnlock(gControls->cfg->globalURL[0]);
HUnlock(gControls->cfg->site[siteIndex].domain);
}
@ -259,7 +259,7 @@ DownloadXPIs(short destVRefNum, long destDirID)
short dlPathLen = 0;
int i, compsDone = 0, instChoice = gControls->opt->instChoice-1, resPos = 0;
Boolean bResuming = false;
int markedIndex = 0;
int markedIndex = 0, currGlobalURLIndex = 0;
GetFullPath(destVRefNum, destDirID, "\p", &dlPathLen, &dlPath);
DLMarkerGetCurrent(&markedIndex, &compsDone);
@ -298,13 +298,17 @@ DownloadXPIs(short destVRefNum, long destDirID)
gControls->resPos = resPos;
gControls->state = eResuming;
}
rv = DownloadFile(dlPath, dlPathLen, gControls->cfg->comp[i].archive, resPos);
TRY_DOWNLOAD:
rv = DownloadFile(dlPath, dlPathLen, gControls->cfg->comp[i].archive, resPos, currGlobalURLIndex);
if (rv == nsFTPConn::E_USER_CANCEL)
{
break;
}
if (rv != 0)
{
if (++currGlobalURLIndex < gControls->cfg->numGlobalURLs)
goto TRY_DOWNLOAD;
ErrorHandler(rv);
break;
}
@ -327,7 +331,7 @@ const char kHTTP[8] = "http://";
const char kFTP[7] = "ftp://";
short
DownloadFile(Handle destFolder, long destFolderLen, Handle archive, int resPos)
DownloadFile(Handle destFolder, long destFolderLen, Handle archive, int resPos, int urlIndex)
{
short rv = 0;
char *URL = 0, *proxyServerURL = 0, *destFile = 0, *destFolderCopy = 0;
@ -338,12 +342,12 @@ DownloadFile(Handle destFolder, long destFolderLen, Handle archive, int resPos)
// make URL using globalURL
HLock(archive);
DLMarkerSetCurrent(*archive);
HLock(gControls->cfg->globalURL);
globalURLLen = strlen(*gControls->cfg->globalURL);
HLock(gControls->cfg->globalURL[urlIndex]);
globalURLLen = strlen(*gControls->cfg->globalURL[urlIndex]);
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);
sprintf(URL, "%s%s", *gControls->cfg->globalURL[urlIndex], *archive);
HUnlock(gControls->cfg->globalURL[urlIndex]);
// set up for dl progress callback
sCurrURL = URL;
@ -439,6 +443,9 @@ DownloadFile(Handle destFolder, long destFolderLen, Handle archive, int resPos)
if (bGetTried && rv != 0)
{
if (++urlIndex < gControls->cfg->numGlobalURLs)
return eDLFailed; // don't pase yet: continue trying failover URLs
/* the get failed before completing; simulate pause */
SetPausedState();
rv = nsFTPConn::E_USER_CANCEL;
@ -996,9 +1003,9 @@ GenerateIDIFromOpt(Str255 idiName, long dirID, short vRefNum, FSSpec *idiSpec)
strcat(buf, "\t0=");
// tack on URL to xpi directory // \t0=<URL>
HLock(gControls->cfg->globalURL);
strcat(buf, *gControls->cfg->globalURL);
HUnlock(gControls->cfg->globalURL);
HLock(gControls->cfg->globalURL[0]);
strcat(buf, *gControls->cfg->globalURL[0]);
HUnlock(gControls->cfg->globalURL[0]);
// tack on 'archive\r' // \t0=<URL>/archive\r
HLock(gControls->cfg->comp[i].archive);

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

@ -145,7 +145,8 @@ if (err) \
#define kMaxProgUnits 100.0
#define kMaxRunApps 32
#define kMaxLegacyChecks 32
#define kMaxSites 32 /* end constants */
#define kMaxSites 32
#define kMaxGlobalURLs 5 /* end constants */
#define rRootWin 128 /* widget rsrc ids */
@ -316,6 +317,7 @@ if (err) \
#define eCfgRead 12
#define eDownload 13
#define eInstRead 6 // installer.ini read failed
#define eDLFailed 14
#define instErrsNum 13 /* number of the install.ini errors */
@ -465,7 +467,8 @@ typedef struct Config {
/* General */
Handle targetSubfolder;
Handle globalURL;
Handle globalURL[kMaxGlobalURLs];
short numGlobalURLs;
/* LicenseWin */
Handle licFileName;
@ -830,7 +833,7 @@ void SetResumedState(void);
pascal void *Install(void*);
long ComputeTotalDLSize(void);
short DownloadXPIs(short, long);
short DownloadFile(Handle, long, Handle, int);
short DownloadFile(Handle, long, Handle, int, int);
OSErr DLMarkerSetCurrent(char *);
OSErr DLMarkerGetCurrent(int *, int*);
OSErr DLMarkerDelete(void);

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

@ -179,7 +179,10 @@ PopulateInstallKeys(char *instText)
OSErr
PopulateGeneralKeys(char *cfgText)
{
OSErr err = noErr;
short rv;
int i;
char cSection[255], cKeyRoot[255], cKey[255];
Str255 pSection, pKeyRoot;
/* General section: subdir */
gControls->cfg->targetSubfolder = NewHandleClear(kValueMaxLen);
@ -193,17 +196,29 @@ PopulateGeneralKeys(char *cfgText)
FillKeyValueUsingResID(sGeneral, sSubfolder, gControls->cfg->targetSubfolder, cfgText);
/* General section: global URL */
gControls->cfg->globalURL = NewHandleClear(kValueMaxLen);
if (!gControls->cfg->globalURL)
GetIndString(pSection, rParseKeys, sGeneral);
GetIndString(pKeyRoot, rParseKeys, sURL);
CopyPascalStrToC(pKeyRoot, cKeyRoot);
CopyPascalStrToC(pSection, cSection);
gControls->cfg->numGlobalURLs = 0;
for (i = 0; i < kMaxGlobalURLs; ++i)
{
ErrorHandler(eMem);
return eParseFailed;
gControls->cfg->globalURL[i] = NewHandleClear(kValueMaxLen);
if (!gControls->cfg->globalURL[i])
{
ErrorHandler(eMem);
return eParseFailed;
}
/* not compulsory */
sprintf(cKey, "%s%d", cKeyRoot, i); // URL0, URL1, ... URL4
rv = FillKeyValueUsingName(cSection, cKey, gControls->cfg->globalURL[i], cfgText);
if (rv == false)
break;
gControls->cfg->numGlobalURLs++;
}
/* not compulsory since mozilla doesn't download */
FillKeyValueUsingResID(sGeneral, sURL, gControls->cfg->globalURL, cfgText);
return err;
return noErr;
}
OSErr