From 179bf39b6ae8fe0bbeb534c1e2ed15f3be1c73ea Mon Sep 17 00:00:00 2001 From: "selmer%netscape.com" Date: Mon, 30 Aug 1999 19:56:34 +0000 Subject: [PATCH] Fixes to handle case where no customization directories exist git-svn-id: svn://10.0.0.236/trunk@45158 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/cck/cckwiz/iniFiles/CheckList.ini | 2 +- mozilla/cck/driver/WizardMachine.cpp | 110 +++++++++++++++++----- mozilla/cck/driver/WizardMachine.h | 5 +- mozilla/cck/driver/WizardUI.cpp | 25 ----- 4 files changed, 89 insertions(+), 53 deletions(-) diff --git a/mozilla/cck/cckwiz/iniFiles/CheckList.ini b/mozilla/cck/cckwiz/iniFiles/CheckList.ini index f3695e343f0..4515d72a41d 100644 --- a/mozilla/cck/cckwiz/iniFiles/CheckList.ini +++ b/mozilla/cck/cckwiz/iniFiles/CheckList.ini @@ -22,7 +22,7 @@ Title=Welcome Caption=1st level node [Navigation Controls] -onNext=Reload(Customizations\%CustomizationList%) +onNext=VerifySet(%CustomizationList%,Choose an existing configuration or create a new one);Reload(Customizations\%CustomizationList%) Help=ChecklistHelp.ini [Image 1] diff --git a/mozilla/cck/driver/WizardMachine.cpp b/mozilla/cck/driver/WizardMachine.cpp index c5d743d7a68..3db666adc47 100644 --- a/mozilla/cck/driver/WizardMachine.cpp +++ b/mozilla/cck/driver/WizardMachine.cpp @@ -111,7 +111,9 @@ BOOL CWizardMachineApp::InitInstance() strcpy(currDirPath, Path); CString outputFile = Path + "output.dat"; - out = OpenAFile(outputFile, "w"); + out = fopen(outputFile, "w"); + if (!out) + exit( 3 ); //char buffer[MID_SIZE]; char **argv; @@ -211,7 +213,8 @@ BOOL CWizardMachineApp::InitInstance() if (FileExists(CachePath)) { UseCache = TRUE; - FillGlobalWidgetArray(CachePath); + if (!FillGlobalWidgetArray(CachePath)) + exit(10); } fprintf(out, "___________________________________________________________\n\n"); @@ -764,6 +767,67 @@ CString CWizardMachineApp::replaceVars(char *str) return CString(buf); } +BOOL CWizardMachineApp::interpret(CString cmd) +{ + // Make modifiable copy of string's buffer + char buf[MAX_SIZE]; + strcpy(buf, (char *)(LPCTSTR) cmd); + + // Format of commandList is: ;;... + // Format of command is: (,,...) + int numCmds = 0; + char *cmdList[100]; + char *pcmdL = strtok(buf, ";"); + while (pcmdL) + { + cmdList[numCmds] = strdup(pcmdL); + pcmdL = strtok(NULL, ";"); + numCmds++; + if (numCmds >= 100) + { + fprintf(out, "Skipping command interpretation, too many commands.\n"); + return FALSE; + } + } + + int i; + for (i=0; inavControls->onNextAction) - { - char buf[MIN_SIZE]; - strcpy(buf, (char *)(LPCTSTR) CurrentNode->navControls->onNextAction); - char *pcmd = strtok(buf, "("); - if (pcmd) - { - char *parms = strtok(NULL, ")"); - if (strcmp(pcmd, "Reload") == 0) - { - CString newDir = replaceVars(parms); - CachePath = Path + newDir + "\\" + CacheFile; - FillGlobalWidgetArray(CachePath); - } - } - } + if (!interpret(CurrentNode->navControls->onNextAction)) + return; //---------------------------------------------------------------------------------------------- NODE* tmpParentNode; @@ -949,20 +1000,20 @@ void CWizardMachineApp::ExitApp() } +/* +This routine isn't useful since the messagebox isn't usually appropriate anymore FILE* CWizardMachineApp::OpenAFile(CString outputFile, CString mode) { if( !( filePtr = fopen( outputFile, mode ) ) ) { CWnd myWnd; - myWnd.MessageBox("Unable to open file" + outputFile, "ERROR", MB_OK); - //fprintf(out, "--------------** TERMINATED - Can't open output file **----------------\n"); - exit( 3 ); } return filePtr; } +*/ void CWizardMachineApp::PrintNodeInfo(NODE* node) { @@ -1014,13 +1065,15 @@ BOOL CWizardMachineApp::FileExists(CString file) return TRUE; } -void CWizardMachineApp::FillGlobalWidgetArray(CString file) +BOOL CWizardMachineApp::FillGlobalWidgetArray(CString file) { char buffer[MAX_SIZE] = {'\0'}; CString name = ""; CString value = ""; - globs = OpenAFile(file, "r"); + globs = fopen(file, "r"); + if (!globs) + return FALSE; while(!feof(globs)) { @@ -1040,16 +1093,23 @@ void CWizardMachineApp::FillGlobalWidgetArray(CString file) } fclose(globs); + + return TRUE; } -void CWizardMachineApp::FillGlobalWidgetArray() +BOOL CWizardMachineApp::FillGlobalWidgetArray() { - FillGlobalWidgetArray(CachePath); + return FillGlobalWidgetArray(CachePath); } void CWizardMachineApp::CreateNewCache() { - globs = OpenAFile(CachePath, "w"); + globs = fopen(CachePath, "w"); + if (!globs) + { + fprintf(out, "--------------** TERMINATED - Can't open cache file **----------------\n"); + exit( 3 ); + } for(int i=0; i< GlobalArrayIndex; i++) { diff --git a/mozilla/cck/driver/WizardMachine.h b/mozilla/cck/driver/WizardMachine.h index dcadb8e3529..dc5b5dcf8da 100644 --- a/mozilla/cck/driver/WizardMachine.h +++ b/mozilla/cck/driver/WizardMachine.h @@ -161,6 +161,7 @@ public: char* GetSectionBuffer(CString iniFile, CString section); void ExecuteAction(char action); CString replaceVars(char *str); + BOOL interpret(CString cmd); void GoToNextNode(); void GoToPrevNode(); void ExitApp(); @@ -169,8 +170,8 @@ public: void PrintNodeInfo(NODE* node); void CheckIniFileExistence(CString file); BOOL FileExists(CString file); - void FillGlobalWidgetArray(CString file); - void FillGlobalWidgetArray(); + BOOL FillGlobalWidgetArray(CString file); + BOOL FillGlobalWidgetArray(); void CreateNewCache(); BOOL IsLastNode(NODE* treeNode); BOOL IsFirstNode(NODE* treeNode); diff --git a/mozilla/cck/driver/WizardUI.cpp b/mozilla/cck/driver/WizardUI.cpp index 0fd9cf65726..01d0e8d0acc 100644 --- a/mozilla/cck/driver/WizardUI.cpp +++ b/mozilla/cck/driver/WizardUI.cpp @@ -1202,35 +1202,10 @@ void CWizardUI::UpdateGlobals() } if (widgetType == "ComboBox") { - /** - curWidget = CurrentNode->pageWidgets[i]; - **/ int selectedIndex = ((CComboBox*)curWidget->control)->GetCurSel(); char tmpStr[MIN_SIZE]; - //itoa(selectedIndex, tmpStr, 10); ((CComboBox*)curWidget->control)->GetLBText(selectedIndex, tmpStr); curWidget->value = tmpStr; - - /** - int selIndex = ((CComboBox*)curWidget->control)->GetCurSel(); - ((CComboBox*)curWidget->control)->GetLBText(selIndex, (char *)(LPCTSTR) selectedCustomization); - - theApp.FillGlobalWidgetArray(); - **/ - /** - if (selectedCustomization != "") - { - FILE *custFile; - - custFile = fopen(topLevelCacheFileName, "w"); - fprintf(custFile, "[CCK]\n"); - fprintf(custFile, "val="); - fprintf(custFile, "%s", (char *)(LPCTSTR)selectedCustomization); - fclose(custFile); - - theApp.FillGlobalWidgetArray((char *)(LPCTSTR)selectedCustomization); - } - **/ } } }