Added install progress bar and minor bug fixes.

This commit is contained in:
sgehani%netscape.com 1999-09-14 21:44:40 +00:00
Родитель 7e59f54807
Коммит 3efdfca397
9 изменённых файлов: 248 добавлений и 26 удалений

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

@ -207,6 +207,8 @@ ExtractCoreFile(short tgtVRefNum, long tgtDirID)
DisposePtr((Ptr)extractedFile);
currCoreFile++;
if (gWPtr)
IdleControls(gWPtr); // progress bar (roll the barber poll)
}
cleanup:

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

@ -150,7 +150,7 @@ void HandleUpdateEvt(EventRecord* evt)
{
BeginUpdate( gWPtr );
DrawControls( gWPtr );
ShowLogo();
ShowLogo(false);
switch(gCurrWin)
{

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

@ -38,6 +38,7 @@ pascal void* Install(void* unused)
StringPtr coreFile;
THz ourHZ;
Boolean isDir = false;
GrafPtr oldPort;
#if CORRECT_DL_LOCATION == 1
/* get "Temporary Items" folder path */
@ -86,11 +87,21 @@ pascal void* Install(void* unused)
/* call SDI_NetInstall */
gSDDlg = true;
ourHZ = GetZone();
GetPort(&oldPort);
#if SDINST_IS_DLL == 1
gInstFunc(&sdistruct);
#else
SDI_NetInstall(&sdistruct);
#endif
SetPort(oldPort);
if (gWPtr)
{
BeginUpdate(gWPtr);
DrawControls(gWPtr);
ShowLogo(true);
UpdateTerminalWin();
EndUpdate(gWPtr);
}
SetZone(ourHZ);
gSDDlg = false;
@ -111,6 +122,8 @@ pascal void* Install(void* unused)
err = FSMakeFSSpec(vRefNum, dirID, coreFile, &coreFileSpec);
if (err==noErr) /* core file was downloaded */
{
InitProgressBar();
/* extract contents of downloaded core file */
err = ExtractCoreFile(vRefNum, dirID);
if (err!=noErr)
@ -130,7 +143,7 @@ pascal void* Install(void* unused)
if (coreFile)
DisposePtr((Ptr)coreFile);
}
/* wind down app */
gDone = true;
@ -326,6 +339,62 @@ AddKeyToIDI(short key, Handle val, char *ostream)
DisposePtr(keybuf);
}
void
InitProgressBar(void)
{
Boolean indeterminateFlag = true;
Rect r;
Str255 extractingStr;
GrafPtr oldPort;
GetPort(&oldPort);
if (gWPtr)
{
SetPort(gWPtr);
gControls->tw->progressBar = NULL;
gControls->tw->progressBar = GetNewControl(rInstProgBar, gWPtr);
if (gControls->tw->progressBar)
{
SetControlData(gControls->tw->progressBar, kControlNoPart, kControlProgressBarIndeterminateTag,
sizeof(indeterminateFlag), (Ptr) &indeterminateFlag);
Draw1Control(gControls->tw->progressBar);
gControls->tw->progressMsg = NULL;
HLock((Handle)gControls->tw->progressBar);
SetRect(&r, (*gControls->tw->progressBar)->contrlRect.left,
(*gControls->tw->progressBar)->contrlRect.top - 42,
(*gControls->tw->progressBar)->contrlRect.right,
(*gControls->tw->progressBar)->contrlRect.top - 26 );
HUnlock((Handle)gControls->tw->progressBar);
gControls->tw->progressMsg = TENew(&r, &r);
if (gControls->tw->progressMsg)
{
GetIndString(extractingStr, rStringList, sExtracting);
TEInsert(&extractingStr[1], extractingStr[0], gControls->tw->progressMsg);
}
TextFace(normal);
TextSize(9);
TextFont(applFont);
gControls->tw->xpiProgressMsg = NULL; /* used by XPInstall progress callback */
HLock((Handle)gControls->tw->progressBar);
SetRect(&r, (*gControls->tw->progressBar)->contrlRect.left,
(*gControls->tw->progressBar)->contrlRect.top - 21,
(*gControls->tw->progressBar)->contrlRect.right,
(*gControls->tw->progressBar)->contrlRect.top - 5 );
HUnlock((Handle)gControls->tw->progressBar);
gControls->tw->xpiProgressMsg = TENew(&r, &r);
TextFont(systemFont); /* restore systemFont */
TextSize(12);
}
}
SetPort(oldPort);
}
Boolean
InitSDLib(void)
{

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

@ -76,7 +76,7 @@ ShowLicenseWin(void)
ShowControl( gControls->lw->licBox);
ShowTxt();
InitScrollBar( gControls->lw->scrollBar);
ShowLogo();
ShowLogo(false);
SetPort(oldPort);
}
@ -209,7 +209,7 @@ ShowTxt(void)
}
void
ShowLogo(void)
ShowLogo(Boolean bEraseRect)
{
short reserr;
Rect derefd, logoRect;
@ -235,7 +235,12 @@ ShowLogo(void)
HUnlock(logoRectH);
reserr = ResError();
if (reserr == noErr)
{
{
if (bEraseRect)
{
EraseRect(&logoRect);
InvalRect(&logoRect);
}
DrawPicture(logoPicH, &logoRect);
ReleaseResource((Handle)logoPicH);
}

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

@ -254,7 +254,7 @@ void MainEventLoop(void)
THz ourHZ;
while (!gDone)
{
{
if (gSDDlg)
YieldToAnyThread(); /* SmartDownload dialog thread */

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

@ -96,7 +96,7 @@ if (err) \
#define END_SECTION ']'
#define KV_DELIM '='
#define TEMP_DIR "\pTemp NSInstall"
#define TEMP_DIR "\pTemp NSInstall" // XXX must go away (wrong dl location)
#define kScrollBarPad 3 /* constants */
#define kTxtRectPad 5
@ -125,7 +125,8 @@ if (err) \
#define kSelected 1
#define kNotInSetupType 0
#define kInSetupType 1
#define kMaxCoreFiles 256 /* end constants */
#define kMaxCoreFiles 256
#define kMaxProgUnits 100.0 /* end constants */
#define rRootWin 128 /* widget rsrc ids */
@ -150,6 +151,7 @@ if (err) \
#define rCompDescBox 151
#define rStartMsgBox 160
#define rInstProgBar 161
#define rMBar 128 /* menu rsrc ids */
#define mApple 150
@ -188,7 +190,11 @@ if (err) \
#define sFolderDlgMsg 18
#define sDiskSpcAvail 19
#define sDiskSpcNeeded 20
#define sKilobytes 21 /* end i18n strings */
#define sKilobytes 21
#define sExtracting 23
#define sInstalling 24
#define sFileSp 25
#define sSpOfSp 26 /* end i18n strings */
#define rParseKeys 141 /* parse keys in config.ini */
@ -341,8 +347,11 @@ typedef struct CompWin {
} CompWin;
typedef struct TermWin {
TEHandle startMsg;
Rect startMsgBox;
TEHandle startMsg;
Rect startMsgBox;
ControlHandle progressBar;
TEHandle progressMsg;
TEHandle xpiProgressMsg;
} TermWin;
typedef struct InstWiz {
@ -441,7 +450,7 @@ void EnableLicenseWin(void);
void DisableLicenseWin(void);
void InitLicTxt(void);
void ShowTxt(void);
void ShowLogo(void);
void ShowLogo(Boolean);
void InitScrollBar(ControlHandle);
pascal void DoScrollProc(ControlHandle, short);
void CalcChange(ControlHandle, short *);
@ -504,6 +513,7 @@ void DisableTerminalWin(void);
pascal void *Install(void*);
Boolean GenerateIDIFromOpt(Str255, long, short, FSSpec *);
void AddKeyToIDI(short, Handle, char *);
void InitProgressBar(void);
Boolean InitSDLib(void);
Boolean LoadSDLib(FSSpec, SDI_NETINSTALL *, EventProc *, CFragConnectionID *);
Boolean UnloadSDLib(CFragConnectionID *);

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

@ -82,7 +82,6 @@ ShowSetupTypeWin(void)
HUnlock((Handle)gControls->stw->instType);
SetControlMaximum(gControls->stw->instType, gControls->cfg->numSetupTypes);
SetControlValue(gControls->stw->instType, gControls->opt->instChoice);
//Draw1Control(gControls->stw->instType);
// setup type desc TE init and default item desc display
HLock((Handle)gControls->stw->instDescBox);
@ -384,12 +383,13 @@ DrawDiskSpaceMsgs(short vRefNum)
HVolumeParam pb;
OSErr err, reserr;
long freeSpace;
short msglen = 0;
TEHandle dsAvailH, dsNeededH;
Rect instDescBox, viewRect;
Handle instDescRectH;
Str255 msg;
Str15 kb;
char *cmsg, *ckb, *cfreeSpace, *cSpaceNeeded;
char *cstr, *cmsg, *ckb, *cfreeSpace, *cSpaceNeeded;
pb.ioCompletion = NULL;
pb.ioVolIndex = 0;
@ -431,23 +431,36 @@ DrawDiskSpaceMsgs(short vRefNum)
/* Get the "Disk Space Available: " string */
GetIndString( msg, rStringList, sDiskSpcAvail );
cmsg = PascalToC(msg);
cstr = PascalToC(msg);
msglen = strlen(cstr);
cmsg = (char*)malloc(msglen+255);
strncpy(cmsg, cstr, msglen);
cmsg[msglen] = '\0';
/* tack on the actual disk space in KB */
cfreeSpace = ltoa(freeSpace);
msglen += strlen(cfreeSpace);
strcat( cmsg, cfreeSpace );
cmsg[msglen] = '\0';
/* tack on the "kilobyte" string: generally "K" but is rsrc'd */
GetIndString( kb, rStringList, sKilobytes );
ckb = PascalToC(kb);
msglen += strlen(ckb);
strcat( cmsg, ckb );
cmsg[msglen] = '\0';
/* draw the disk space available string */
TEInsert( cmsg, strlen(cmsg), dsAvailH );
TEUpdate( &viewRect, dsAvailH );
/* recycle msg pointer */
DisposePtr((char*)cmsg);
/* recycle pointers */
if (cstr)
DisposePtr((Ptr)cstr);
if (cmsg)
free(cmsg);
if (ckb)
DisposePtr((Ptr)ckb);
SetRect( &viewRect, instDescBox.right - 150, instDescBox.bottom + 2,
instDescBox.right, instDescBox.bottom + 12 );
@ -461,16 +474,24 @@ DrawDiskSpaceMsgs(short vRefNum)
/* Get the "Disk Space Needed: " string */
GetIndString( msg, rStringList, sDiskSpcNeeded );
cmsg = PascalToC(msg);
cstr = PascalToC(msg);
msglen = strlen(cstr);
cmsg = (char*)malloc(msglen+255);
strncpy(cmsg, cstr, msglen);
cmsg[msglen] = '\0';
/* tack on space needed in KB */
cSpaceNeeded = DiskSpaceNeeded();
msglen += strlen(cSpaceNeeded);
strcat( cmsg, cSpaceNeeded );
cmsg[msglen] = '\0';
/* tack on the "kilobyte" string: generally "K" but is rsrc'd */
GetIndString( kb, rStringList, sKilobytes );
ckb = PascalToC(kb);
msglen += strlen(ckb);
strcat( cmsg, ckb );
cmsg[msglen] = '\0';
/* draw the disk space available string */
TEInsert( cmsg, strlen(cmsg), dsNeededH );
@ -486,9 +507,11 @@ DrawDiskSpaceMsgs(short vRefNum)
if (cSpaceNeeded)
free(cSpaceNeeded); // malloc'd, not NewPtrClear'd
if (cfreeSpace)
free(cfreeSpace); // malloc'd, not NewPtrClear'd
free(cfreeSpace);
if (cstr)
DisposePtr((Ptr)cstr);
if (cmsg)
DisposePtr((Ptr)cmsg);
free(cmsg);
TextFont(systemFont);
TextSize(12);
}

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

@ -85,10 +85,22 @@ void
UpdateTerminalWin(void)
{
GrafPtr oldPort;
Rect instMsgRect;
GetPort(&oldPort);
SetPort(gWPtr);
TEUpdate(&gControls->tw->startMsgBox, gControls->tw->startMsg);
if (gControls->tw->progressMsg)
{
HLock((Handle)gControls->tw->progressMsg);
SetRect(&instMsgRect, (*gControls->tw->progressMsg)->viewRect.left,
(*gControls->tw->progressMsg)->viewRect.top,
(*gControls->tw->progressMsg)->viewRect.right,
(*gControls->tw->progressMsg)->viewRect.bottom );
HUnlock((Handle)gControls->tw->progressMsg);
TEUpdate(&instMsgRect, gControls->tw->progressMsg);
}
SetPort(oldPort);
}

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

@ -22,7 +22,6 @@
#include "MacInstallWizard.h"
#define XP_MAC 1
#include "xpistub.h"
@ -64,21 +63,121 @@ if (NS_FAILED(rv)) \
#else
#define XPISTUB_DLL "\pxpistub.shlb"
#endif
static Boolean bMaxDiscovered = false;
void
xpicbStart(const char *URL, const char* UIName)
{
// TO DO
// SysBeep(10);
Rect r;
Str255 installingStr;
if (gControls->tw->progressMsg)
{
HLock((Handle)gControls->tw->progressMsg);
SetRect(&r, (*gControls->tw->progressMsg)->viewRect.left,
(*gControls->tw->progressMsg)->viewRect.top,
(*gControls->tw->progressMsg)->viewRect.right,
(*gControls->tw->progressMsg)->viewRect.bottom );
HUnlock((Handle)gControls->tw->progressMsg);
/* Installing <UIName> */
GetIndString(installingStr, rStringList, sInstalling);
EraseRect(&r);
if (installingStr[0] > 0)
TESetText(&installingStr[1], installingStr[0], gControls->tw->progressMsg);
if (UIName)
TEInsert(UIName, strlen(UIName), gControls->tw->progressMsg);
TEUpdate(&r, gControls->tw->progressMsg);
}
return;
}
void
xpicbProgress(const char* msg, PRInt32 val, PRInt32 max)
{
// TO DO
// SysBeep(10);
Boolean indeterminateFlag = false;
Rect r;
Str255 installingStr, fileStr, ofStr;
char *valStr, *maxStr;
GrafPtr oldPort;
GetPort(&oldPort);
if (gWPtr)
{
SetPort(gWPtr);
if (gControls->tw->progressBar)
{
if (max!=0 && !bMaxDiscovered)
{
SetControlData(gControls->tw->progressBar, kControlNoPart, kControlProgressBarIndeterminateTag,
sizeof(indeterminateFlag), (Ptr) &indeterminateFlag);
SetControlMaximum(gControls->tw->progressBar, max);
bMaxDiscovered = true;
}
else if (!bMaxDiscovered)
{
if (gWPtr)
IdleControls(gWPtr);
if (gControls->tw->xpiProgressMsg)
{
HLock((Handle)gControls->tw->xpiProgressMsg);
SetRect(&r, (*gControls->tw->xpiProgressMsg)->viewRect.left,
(*gControls->tw->xpiProgressMsg)->viewRect.top,
(*gControls->tw->xpiProgressMsg)->viewRect.right,
(*gControls->tw->xpiProgressMsg)->viewRect.bottom );
HUnlock((Handle)gControls->tw->xpiProgressMsg);
if (msg)
{
EraseRect(&r);
TESetText(msg, strlen(msg), gControls->tw->xpiProgressMsg);
TEUpdate(&r, gControls->tw->xpiProgressMsg);
}
}
}
if (bMaxDiscovered)
{
SetControlValue(gControls->tw->progressBar, val);
if (gControls->tw->xpiProgressMsg)
{
GetIndString(installingStr, rStringList, sInstalling);
GetIndString(fileStr, rStringList, sFileSp);
GetIndString(ofStr, rStringList, sSpOfSp);
HLock((Handle)gControls->tw->xpiProgressMsg);
SetRect(&r, (*gControls->tw->xpiProgressMsg)->viewRect.left,
(*gControls->tw->xpiProgressMsg)->viewRect.top,
(*gControls->tw->xpiProgressMsg)->viewRect.right,
(*gControls->tw->xpiProgressMsg)->viewRect.bottom );
HUnlock((Handle)gControls->tw->xpiProgressMsg);
valStr = ltoa(val);
maxStr = ltoa(max);
EraseRect(&r);
if (valStr && maxStr)
{
TESetText(&installingStr[1], installingStr[0], gControls->tw->xpiProgressMsg);
TEInsert(&fileStr[1], fileStr[0], gControls->tw->xpiProgressMsg);
TEInsert(valStr, strlen(valStr), gControls->tw->xpiProgressMsg);
TEInsert(&ofStr[1], ofStr[0], gControls->tw->xpiProgressMsg);
TEInsert(maxStr, strlen(maxStr), gControls->tw->xpiProgressMsg);
TEUpdate(&r, gControls->tw->xpiProgressMsg);
}
if (valStr)
free(valStr);
if (maxStr)
free(maxStr);
}
}
}
}
SetPort(oldPort);
return;
}
@ -87,6 +186,8 @@ xpicbFinal(const char *URL, PRInt32 finalStatus)
{
// TO DO
// SysBeep(10);
bMaxDiscovered = false;
return;
}