*** NOT PART OF BUILD ***

Fixed bug 11216: Cascading dependencies feature
   
Fixed bug 14320: Parser and action support for the LAUNCHAPP atribute
   
Fixed bug 14322: Mouse over displays component description
   
Fixed bug 16224: Mac Install Wizard crashing when installing custom components


git-svn-id: svn://10.0.0.236/trunk@50667 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
sgehani%netscape.com
1999-10-14 08:30:29 +00:00
parent e33d697bbd
commit 04a7745986
7 changed files with 364 additions and 81 deletions

View File

@@ -33,6 +33,9 @@
LMSetHiliteMode(hiliteVal); \
InvertRect(_rectPtr);
static int rowToComp[kMaxComponents];
static int numRows = 0;
void
ShowComponentsWin(void)
{
@@ -40,10 +43,12 @@ ShowComponentsWin(void)
Str255 compDescTitle;
StringPtr selCompMsg;
Handle listBoxRect;
Rect dataBounds, listBoxFrame, viewRect;
Rect dataBounds, listBoxFrame, viewRect, firstCellRect;
short reserr;
int totalRows = 0, i, instChoice;
Point cSize;
Cell firstCell;
UInt8 hiliteVal;
Boolean bCellSelected;
GrafPtr oldPort;
GetPort(&oldPort);
@@ -134,19 +139,19 @@ ShowComponentsWin(void)
FrameRect(&listBoxFrame);
ShowNavButtons( back, next);
if (bCellSelected)
SetOptInfo();
SetOptInfo(NULL);
else
DrawDiskSpaceMsgs( gControls->opt->vRefNum );
// default highlight first row
InitRowHighlight(0);
//if (selCompMsg)
// DisposePtr((Ptr) selCompMsg);
SetPort(oldPort);
}
static int rowToComp[kMaxComponents];
static int numRows = 0;
Boolean
PopulateCompInfo(void)
{
@@ -183,6 +188,7 @@ UpdateCompWin(void)
{
Rect r;
Cell c;
int i;
GrafPtr oldPort;
GetPort(&oldPort);
@@ -192,8 +198,7 @@ UpdateCompWin(void)
HLock(gControls->cfg->selCompMsg);
DrawString( CToPascal(*gControls->cfg->selCompMsg));
HUnlock(gControls->cfg->selCompMsg);
LUpdate( (*gControls->cw->compList)->port->visRgn,
gControls->cw->compList);
LUpdate( (*gControls->cw->compList)->port->visRgn, gControls->cw->compList);
FrameRect(&gControls->cw->compListBox);
SetPt(&c, 0, 0);
@@ -210,6 +215,15 @@ UpdateCompWin(void)
DrawDiskSpaceMsgs( gControls->opt->vRefNum );
for (i = 0; i < numRows; i++)
{
if (gControls->cfg->comp[rowToComp[i]].highlighted)
{
InitRowHighlight(i);
break;
}
}
SetPort(oldPort);
}
@@ -243,10 +257,11 @@ InComponentsContent(EventRecord* evt, WindowPtr wCurrPtr)
SetRect(&checkbox, currCellRect.left+4, currCellRect.top+2,
currCellRect.left+16, currCellRect.top+14);
INVERT_HIGHLIGHT(&checkbox);
break;
}
}
SetOptInfo();
SetOptInfo(evt);
}
HLock((Handle)gControls->backB);
@@ -255,7 +270,7 @@ InComponentsContent(EventRecord* evt, WindowPtr wCurrPtr)
if (PtInRect( localPt, &r))
{
/* reset all rows to be not highlighted */
for (i=0; i<numRows; i++)
for (i=1; i<numRows; i++)
gControls->cfg->comp[rowToComp[i]].highlighted = false;
part = TrackControl(gControls->backB, evt->where, NULL);
@@ -302,10 +317,6 @@ void
MouseMovedInComponentsWin(EventRecord *evt)
{
Point localPt;
Rect currCellRect, oldCellRect, checkbox;
int i, j;
Cell currCell, oldCell;
UInt8 hiliteVal;
GrafPtr oldPort;
GetPort(&oldPort);
@@ -318,36 +329,119 @@ MouseMovedInComponentsWin(EventRecord *evt)
/* if within list box rect */
if (PtInRect( localPt, &((*gControls->cw->compList)->rView) ))
{
for (i=0; i<numRows; i++)
{
/* note: numComps above includes invisible components */
SetPt(&currCell, 0, i);
LRect(&currCellRect, currCell, gControls->cw->compList);
UpdateRowHighlight(localPt);
}
SetPort(oldPort);
}
void
InitRowHighlight(int row)
{
Cell hlCell;
Rect hlCellRect;
UInt8 hiliteVal;
int i = 0;
/* reset all highlighted markers */
for (i=0; i<numRows; i++)
{
gControls->cfg->comp[rowToComp[i]].highlighted = false;
}
/* highlight and set marker for row to init */
SetPt(&hlCell, 0, row);
LRect(&hlCellRect, hlCell, gControls->cw->compList);
INVERT_HIGHLIGHT(&hlCellRect);
UpdateLongDesc(row);
gControls->cfg->comp[rowToComp[row]].highlighted = true;
}
void
UpdateRowHighlight(Point localPt)
{
int i, j;
Rect currCellRect, oldCellRect;
Cell currCell, oldCell;
UInt8 hiliteVal;
for (i=0; i<numRows; i++)
{
/* note: numComps above includes invisible components */
SetPt(&currCell, 0, i);
LRect(&currCellRect, currCell, gControls->cw->compList);
/* mouse move landed over this cell */
if (PtInRect( localPt, &currCellRect ))
{
if (!gControls->cfg->comp[rowToComp[i]].highlighted)
{
/* highlight this cell */
INVERT_HIGHLIGHT(&currCellRect);
UpdateLongDesc(i);
/* mouse move landed over this cell */
if (PtInRect( localPt, &currCellRect ))
{
if (!gControls->cfg->comp[rowToComp[i]].highlighted)
{
/* highlight this cell */
INVERT_HIGHLIGHT(&currCellRect);
UpdateLongDesc(i);
/* unhighlight old one */
for (j=0; j<numRows; j++)
/* unhighlight old one */
for (j=0; j<numRows; j++)
{
if (gControls->cfg->comp[rowToComp[j]].highlighted)
{
if (gControls->cfg->comp[rowToComp[j]].highlighted)
{
SetPt(&oldCell, 0, j);
LRect(&oldCellRect, oldCell, gControls->cw->compList);
SetPt(&oldCell, 0, j);
LRect(&oldCellRect, oldCell, gControls->cw->compList);
INVERT_HIGHLIGHT(&oldCellRect);
gControls->cfg->comp[rowToComp[j]].highlighted = false;
}
INVERT_HIGHLIGHT(&oldCellRect);
gControls->cfg->comp[rowToComp[j]].highlighted = false;
}
}
/* mark this row highlighted to prevent incorrect inversion */
gControls->cfg->comp[rowToComp[i]].highlighted = true;
}
}
}
}
void
UpdateDependencies(int row, EventRecord* evt)
{
int i;
short currRow;
Cell currCell;
Rect currCellRect;
Point currCellPt;
GrafPtr oldPort;
GetPort(&oldPort);
if (gWPtr)
SetPort(gWPtr);
// if row is selected
if (gControls->cfg->comp[rowToComp[row]].selected)
{
// loop through all components numComps
for (i=0; i<gControls->cfg->numComps; i++)
{
// if kDependencyOn for curr dep component --> comp[rowToComp[row]].dep[i]
if (gControls->cfg->comp[rowToComp[row]].dep[i] == kDependencyOn)
{
// if curr dep component isn't on
if (gControls->cfg->comp[i].selected == kNotSelected)
{
// set curr dep comp to kSelected
gControls->cfg->comp[i].selected = kSelected;
// if curr dep comp is in currently displayed comps
currRow = GetCompRow(i);
if (currRow != kInvalidCompIdx)
{
// LClick the row to check curr dep comp's checkbox
SetPt(&currCell, 0, currRow);
LRect(&currCellRect, currCell, gControls->cw->compList);
SetPt(&currCellPt, currCellRect.left+1, currCellRect.top+1);
LClick(currCellPt, evt->modifiers, gControls->cw->compList);
}
/* mark this row highlighted to prevent incorrect inversion */
gControls->cfg->comp[rowToComp[i]].highlighted = true;
// resolve its dependencies
UpdateDependencies(currRow, evt);
}
}
}
@@ -356,26 +450,26 @@ MouseMovedInComponentsWin(EventRecord *evt)
SetPort(oldPort);
}
short
GetCompRow(int compIdx)
{
short i = kInvalidCompIdx;
for (i=0; i<numRows; i++)
{
if (rowToComp[i] == compIdx)
break;
}
return i;
}
void
SetOptInfo(void)
SetOptInfo(EventRecord* evt)
{
Boolean isCellSelected;
Cell currCell;
int i;
Rect viewRect;
HLock((Handle)gControls->cw->compDescBox);
SetRect(&viewRect, (*gControls->cw->compDescBox)->contrlRect.left,
(*gControls->cw->compDescBox)->contrlRect.top,
(*gControls->cw->compDescBox)->contrlRect.right,
(*gControls->cw->compDescBox)->contrlRect.bottom);
HUnlock((Handle)gControls->cw->compDescBox);
viewRect.top += kInterWidgetPad;
SetRect(&viewRect, viewRect.left + kTxtRectPad,
viewRect.top + kTxtRectPad,
viewRect.right - kTxtRectPad,
viewRect.bottom - kTxtRectPad);
EraseRect(&viewRect);
for(i=0; i<numRows; i++)
{
@@ -388,6 +482,9 @@ SetOptInfo(void)
{
gControls->cfg->comp[rowToComp[i]].selected = true;
gControls->opt->numCompSelected++;
if (evt)
UpdateDependencies(i, evt);
}
if (!gControls->cw->compDescBox)
@@ -434,9 +531,9 @@ UpdateLongDesc(int row)
void
EnableComponentsWin(void)
{
{
EnableNavButtons();
// TO DO
}

View File

@@ -58,7 +58,6 @@ ExtractCoreFile(short tgtVRefNum, long tgtDirID)
Ptr fullPathStr = 0;
PRInt32 rv = 0;
void *hZip = 0, *hFind = 0;
/* if there's a core file... */
HLock(gControls->cfg->coreFile);
@@ -89,14 +88,11 @@ ExtractCoreFile(short tgtVRefNum, long tgtDirID)
rv = ZIP_OpenArchive( fullPathStr, &hZip );
/* dispose mem used so we can reuse the ptr and handle */
HUnlock(fullPathH);
if (fullPathH)
DisposeHandle(fullPathH);
if (rv!=ZIP_OK) return rv;
/* initialize the search */
hFind = ZIP_FindInit( hZip, NULL ); /* NULL to match all files in archive */
hFind = ZIP_FindInit( hZip, 0 ); /* null to match all files in archive */
/* --- i n f l a t e a l l f i l e s --- */
@@ -109,8 +105,8 @@ ExtractCoreFile(short tgtVRefNum, long tgtDirID)
/* --- c l o s e a r c h i v e --- */
cleanup:
if (hFind)
rv = ZIP_FindFree( hFind );
//if (hFind)
// rv = ZIP_FindFree( hFind );
#ifdef MIW_DEBUG
if (rv!=ZIP_OK) SysBeep(10);
#endif
@@ -121,6 +117,8 @@ cleanup:
#endif
if (coreFile)
DisposePtr((Ptr)coreFile);
if (fullPathH)
DisposeHandle(fullPathH);
if (fullPathStr)
DisposePtr(fullPathStr);
@@ -233,22 +231,15 @@ OSErr
AppleSingleDecode(FSSpecPtr fd, FSSpecPtr outfd)
{
OSErr err = noErr;
nsAppleSingleDecoder *decoder;
// if file is AppleSingled
if (nsAppleSingleDecoder::IsAppleSingleFile(fd))
{
// decode it
decoder = new nsAppleSingleDecoder(fd, outfd);
if (!decoder)
return memFullErr;
nsAppleSingleDecoder decoder(fd, outfd);
ERR_CHECK_RET(decoder->Decode(), err);
ERR_CHECK_RET(decoder.Decode(), err);
}
if (decoder)
delete decoder;
return err;
}
@@ -357,11 +348,12 @@ CleanupExtractedFiles(short tgtVRefNum, long tgtDirID)
if (err == noErr)
{
err = FSpDelete( &coreDirFSp );
return err;
}
else
return err;
}
HUnlock(gControls->cfg->coreDir);
return err;
}
HUnlock(gControls->cfg->coreDir);
// otherwise iterate through coreFileList deleteing each individually

View File

@@ -163,10 +163,13 @@ pascal void* Install(void* unused)
if (err!=noErr) SysBeep(10);
#endif
}
if (coreFile)
DisposePtr((Ptr)coreFile);
}
/* launch the downloaded apps who had the LAUNCHAPP attr set */
LaunchApps(vRefNum, dirID);
/* wind down app */
gDone = true;
@@ -231,6 +234,8 @@ GenerateIDIFromOpt(Str255 idiName, long dirID, short vRefNum, FSSpec *idiSpec)
pcurrArchive = CToPascal(*gControls->cfg->comp[i].archive);
HUnlock(gControls->cfg->comp[i].archive);
err = FSMakeFSSpec(vRefNum, dirID, pcurrArchive, &fsExists);
// if file doesn't exist
if (err == fnfErr)
{
// get file number from STR# resource
@@ -375,6 +380,67 @@ AddKeyToIDI(short key, Handle val, char *ostream)
DisposePtr(keybuf);
}
void
LaunchApps(short vRefNum, long dirID)
{
int compsDone = 0, i;
int instChoice = gControls->opt->instChoice-1;
FSSpec fsCurrArchive, fsCurrApp;
OSErr err = noErr;
StringPtr pArchiveName;
LaunchParamBlockRec launchPB;
// 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
// add file to buffer
if ( ((instChoice == gControls->cfg->numSetupTypes-1) &&
(gControls->cfg->comp[i].selected == true)) ||
(instChoice < gControls->cfg->numSetupTypes-1) )
{
// if the LAUNCHAPP attr was set
if (gControls->cfg->comp[i].launchapp)
{
// AppleSingle decode the app
HLock(gControls->cfg->comp[i].archive);
pArchiveName = CToPascal(*gControls->cfg->comp[i].archive);
HUnlock(gControls->cfg->comp[i].archive);
err = FSMakeFSSpec(vRefNum, dirID, pArchiveName, &fsCurrArchive);
if (err == noErr) /* archive exists */
{
err = AppleSingleDecode(&fsCurrArchive, &fsCurrApp);
if (err == noErr) /* AppleSingle decoded successfully */
{
// launch the decoded app
launchPB.launchAppSpec = & fsCurrApp;
launchPB.launchAppParameters = NULL;
launchPB.launchBlockID = extendedBlock;
launchPB.launchEPBLength = extendedBlockLen;
launchPB.launchFileFlags = NULL;
launchPB.launchControlFlags = launchContinue + launchNoFileFlags + launchUseMinimum;
launchPB.launchControlFlags += launchDontSwitch;
err = LaunchApplication( &launchPB );
#ifdef MIW_DEBUG
if (err!=noErr) SysBeep(10);
#endif
}
}
}
}
}
compsDone++;
}
}
void
InitProgressBar(void)
{

View File

@@ -54,7 +54,7 @@ typedef Boolean (*EventProc)(const EventRecord*);
#define SDINST_IS_DLL 1 /* if on, load SDInstLib as code fragment */
#define MOZILLA 0 /* if on, draws the Mozilla logo, not NS,
and doesn't use sdinst.dll */
#define PRE_BETA_HACKERY 1 /* if on, extracts core to selected folder
#define PRE_BETA_HACKERY 0 /* if on, extracts core to selected folder
instead of Temporary Items */
/*-----------------------------------------------------------*
@@ -127,6 +127,9 @@ if (err) \
#define kSelected 1
#define kNotInSetupType 0
#define kInSetupType 1
#define kDependencyOff 0
#define kDependencyOn 1
#define kInvalidCompIdx -999
#define kMaxCoreFiles 256
#define kMaxProgUnits 100.0 /* end constants */
@@ -252,6 +255,7 @@ if (err) \
#define sInstSize 24
#define sAttributes 25
#define sURL 26
#define sDependency 31
#define sTermDlg 27
@@ -281,6 +285,12 @@ typedef struct InstComp {
/* attributes */
Boolean selected;
Boolean invisible;
Boolean launchapp;
/* dependencies */
Handle depName[kMaxComponents];
short dep[kMaxComponents];
short numDeps;
/* UI highlighting */
Boolean highlighted;
@@ -441,6 +451,8 @@ OSErr PopulateSetupTypeWinKeys(char *);
OSErr PopulateCompWinKeys(char *);
OSErr PopulateTermWinKeys(char *);
OSErr PopulateIDIKeys(char *);
OSErr MapDependencies(void);
short GetComponentIndex(Handle);
Boolean FillKeyValueForIDIKey(short, Handle, char *);
Boolean FillKeyValueUsingResID(short, short, Handle, char *);
Boolean FillKeyValueUsingSLID(short, short, short, Handle, char *);
@@ -515,8 +527,12 @@ Boolean PopulateCompInfo(void);
void UpdateCompWin(void);
void InComponentsContent(EventRecord*, WindowPtr);
void MouseMovedInComponentsWin(EventRecord *);
void SetOptInfo(void);
short GetCompRow(int);
void SetOptInfo(EventRecord* evt);
void InitRowHighlight(int);
void UpdateRowHighlight(Point);
void UpdateLongDesc(int);
void UpdateDependencies(int, EventRecord*);
void EnableComponentsWin(void);
void DisableComponentsWin(void);
@@ -536,6 +552,7 @@ void DisableTerminalWin(void);
pascal void *Install(void*);
Boolean GenerateIDIFromOpt(Str255, long, short, FSSpec *);
void AddKeyToIDI(short, Handle, char *);
void LaunchApps(short, long);
void InitProgressBar(void);
Boolean InitSDLib(void);
Boolean LoadSDLib(FSSpec, SDI_NETINSTALL *, EventProc *, CFragConnectionID *);

View File

@@ -79,6 +79,8 @@ ParseConfig(void)
ERR_CHECK(PopulateTermWinKeys(cfgText));
ERR_CHECK(PopulateIDIKeys(cfgText));
ERR_CHECK(MapDependencies());
if (cfgText)
DisposePtr(cfgText);
}
@@ -127,6 +129,8 @@ ReadConfigFile(char **text)
return bSuccess;
}
#pragma mark -
OSErr
PopulateLicWinKeys(char *cfgText)
{
@@ -200,6 +204,7 @@ PopulateCompWinKeys(char *cfgText)
Ptr currSNameBuf, currSName, currKeyBuf, currKey, idxCh;
Str255 pSName, pkey, pidx;
char eof[1];
char *currDepNum;
eof[0] = 0;
@@ -280,7 +285,7 @@ PopulateCompWinKeys(char *cfgText)
DisposeHandle(sizeH);
DisposePtr(currKey);
/* attributes (SELECTED|INVISIBLE) */
/* attributes (SELECTED|INVISIBLE|LAUNCHAPP) */
GetIndString(pkey, rParseKeys, sAttributes);
currKey = PascalToC(pkey);
Handle attrValH = NewHandleClear(255);
@@ -306,7 +311,16 @@ PopulateCompWinKeys(char *cfgText)
gControls->cfg->comp[i].invisible = false;
if (attrType)
DisposePtr(attrType);
GetIndString(pkey, rParseKeys, sLAUNCHAPP);
attrType = PascalToC(pkey);
if (NULL != strstr(*attrValH, attrType))
gControls->cfg->comp[i].launchapp = true;
else
gControls->cfg->comp[i].launchapp = false;
if (attrType)
DisposePtr(attrType);
HUnlock(attrValH);
}
if (attrValH)
@@ -337,8 +351,42 @@ PopulateCompWinKeys(char *cfgText)
break;
}
gControls->cfg->comp[i].numURLs++;
DisposePtr(currKey);
if (currKey)
DisposePtr(currKey);
if (currKeyBuf)
DisposePtr(currKeyBuf);
}
/* dependencies on other components */
gControls->cfg->comp[i].numDeps = 0;
GetIndString(pkey, rParseKeys, sDependency);
currKeyBuf = PascalToC(pkey);
for (j=0; j<kMaxComponents; j++)
{
// currKey = "Dependency<j>"
currDepNum = ltoa(j);
currKey = NewPtrClear(strlen(currKeyBuf) + strlen(currDepNum));
strncpy(currKey, currKeyBuf, strlen(currKeyBuf));
strncat(currKey, currDepNum, strlen(currDepNum));
gControls->cfg->comp[i].depName[j] = NewHandleClear(kValueMaxLen);
if (!FillKeyValueUsingName(currSName, currKey, gControls->cfg->comp[i].depName[j], cfgText))
{
if (currKey)
DisposePtr(currKey);
if (currDepNum)
free(currDepNum);
break;
}
gControls->cfg->comp[i].numDeps++;
if (currKey)
DisposePtr(currKey);
if (currDepNum)
free(currDepNum);
}
if (currKeyBuf)
DisposePtr(currKeyBuf);
}
gControls->cfg->numComps = i;
@@ -503,6 +551,61 @@ PopulateIDIKeys(char *cfgText)
return err;
}
OSErr
MapDependencies()
{
OSErr err = noErr;
int i, j, compIdx;
for (i=0; i<gControls->cfg->numComps; i++)
{
for (j=0; j<kMaxComponents; j++)
{
gControls->cfg->comp[i].dep[j] = kDependencyOff;
}
for(j=0; j<gControls->cfg->comp[i].numDeps; j++)
{
compIdx = GetComponentIndex(gControls->cfg->comp[i].depName[j]);
if (compIdx != kInvalidCompIdx)
{
gControls->cfg->comp[i].dep[compIdx] = kDependencyOn;
// turn on dependencies
if (gControls->cfg->comp[i].selected == kSelected)
gControls->cfg->comp[compIdx].selected = kSelected;
}
}
}
return err;
}
short
GetComponentIndex(Handle compName)
{
int i;
short compIdx = kInvalidCompIdx;
HLock(compName);
for (i=0; i<gControls->cfg->numComps; i++)
{
HLock(gControls->cfg->comp[i].shortDesc);
if (0==strncmp(*gControls->cfg->comp[i].shortDesc, *compName, strlen(*gControls->cfg->comp[i].shortDesc)))
{
compIdx = i;
HUnlock(gControls->cfg->comp[i].shortDesc);
break;
}
HUnlock(gControls->cfg->comp[i].shortDesc);
}
HUnlock(compName);
return compIdx;
}
#pragma mark -
Boolean
FillKeyValueUsingResID(short dlgID, short keyID, Handle dest, char *cfgText)
@@ -574,6 +677,8 @@ FillKeyValueUsingName(char *sectionName, char *keyName, Handle dest, char *cfgTe
return bFound;
}
#pragma mark -
Boolean
FindKeyValue(const char *cfg, const char *inSectionName, const char *inKey, char *outValue)
{
@@ -600,7 +705,7 @@ FindKeyValue(const char *cfg, const char *inSectionName, const char *inKey, char
/* find next key [sectionPtr moved past next key per iteration] */
while(GetNextKeyVal(sectionPtr, key, outValue))
{
if (strncmp(key, inKey, strlen(key)) == 0)
if (0<strlen(key) && strncmp(key, inKey, strlen(key)) == 0)
{
if(key)
DisposePtr(key);
@@ -749,9 +854,13 @@ GetNextKeyVal(char **inSection, char *outKey, char *outVal)
*inSection = sbuf; /* capture current position in section for future GetNextKeyValue() */
if (*outKey == NULL)
exists = false;
return exists;
}
#pragma mark -
/*
* Makes a copy of the C string, converts the copy to a Pascal string,

View File

@@ -226,6 +226,8 @@ RunAllXPIs(short vRefNum, long dirID)
(gControls->cfg->comp[i].selected == true)) ||
(instChoice < gControls->cfg->numSetupTypes-1) )
{
// if LAUNCHAPP attr wasn't set
if (!gControls->cfg->comp[i].launchapp)
HLock(gControls->cfg->comp[i].archive);
pcurrArchive = CToPascal(*gControls->cfg->comp[i].archive);
HUnlock(gControls->cfg->comp[i].archive);