1999-02-03 16:39:50 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// WizardMachine.cpp : Defines the class behaviors for the application.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "WizardMachine.h"
|
|
|
|
#include <iostream.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <direct.h>
|
1999-05-19 03:31:11 +00:00
|
|
|
#include "HelpDlg.h"
|
|
|
|
#include "WizHelp.h"
|
1999-10-02 01:28:27 +00:00
|
|
|
#include "ImgDlg.h"
|
|
|
|
#include "SumDlg.h"
|
|
|
|
#include "NavText.h"
|
|
|
|
#include "NewDialog.h"
|
|
|
|
#include "NewConfigDialog.h"
|
|
|
|
#include "ProgDlgThread.h"
|
1999-02-03 16:39:50 +00:00
|
|
|
|
1999-10-05 02:22:36 +00:00
|
|
|
// for CopyDir
|
|
|
|
#include "winbase.h"
|
|
|
|
|
1999-02-03 16:39:50 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
#define new DEBUG_NEW
|
|
|
|
#undef THIS_FILE
|
|
|
|
static char THIS_FILE[] = __FILE__;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CWizardMachineApp
|
|
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CWizardMachineApp, CWinApp)
|
|
|
|
//{{AFX_MSG_MAP(CWizardMachineApp)
|
1999-05-19 03:31:11 +00:00
|
|
|
// NOTE - the Class\ard will add and remove mapping macros here.
|
1999-02-03 16:39:50 +00:00
|
|
|
// DO NOT EDIT what you see in these blocks of generated code!
|
|
|
|
//}}AFX_MSG
|
1999-05-19 03:31:11 +00:00
|
|
|
ON_COMMAND(ID_HELP, CWizardMachineApp::HelpWiz)
|
1999-02-03 16:39:50 +00:00
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CWizardMachineApp construction
|
|
|
|
|
|
|
|
CWizardMachineApp::CWizardMachineApp()
|
|
|
|
{
|
|
|
|
// TODO: add construction code here,
|
|
|
|
// Place all significant initialization in InitInstance
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// The one and only CWizardMachineApp object
|
|
|
|
CPropSheet* PropertySheetDlg;
|
|
|
|
|
|
|
|
CWizardMachineApp theApp;
|
|
|
|
NODE *GlobalDefaults;
|
|
|
|
NODE *WizardTree;
|
|
|
|
NODE *CurrentNode;
|
|
|
|
WIDGET GlobalWidgetArray[1000];
|
|
|
|
|
1999-05-25 07:42:48 +00:00
|
|
|
int GlobalArrayIndex;
|
1999-02-03 16:39:50 +00:00
|
|
|
int CurrentPageBaseIndex=100;
|
|
|
|
|
|
|
|
CString Path;
|
|
|
|
char currDirPath[MAX_SIZE];
|
|
|
|
char iniFilePath[MAX_SIZE];
|
|
|
|
char imagesPath[MAX_SIZE];
|
|
|
|
char rootPath[MAX_SIZE];
|
|
|
|
char customizationPath[MAX_SIZE];
|
1999-09-30 00:39:06 +00:00
|
|
|
char asePath[MAX_SIZE];
|
|
|
|
char nciPath[MAX_SIZE];
|
|
|
|
char tmpPath[MAX_SIZE];
|
1999-02-03 16:39:50 +00:00
|
|
|
|
|
|
|
CString CacheFile;
|
1999-08-29 21:30:16 +00:00
|
|
|
CString CachePath;
|
1999-02-03 16:39:50 +00:00
|
|
|
BOOL UseCache = FALSE;
|
|
|
|
extern CSingleLock prevLock;
|
|
|
|
extern BOOL isBuildInstaller;
|
|
|
|
//Output file pointer for QA purposes
|
1999-06-17 04:42:40 +00:00
|
|
|
// Optimize here on global pointers. This many not needed.
|
|
|
|
FILE *out, *globs, *filePtr;;
|
1999-02-03 16:39:50 +00:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CWizardMachineApp initialization
|
|
|
|
|
|
|
|
BOOL CWizardMachineApp::InitInstance()
|
|
|
|
{
|
|
|
|
// Standard initialization
|
|
|
|
// If you are not using these features and wish to reduce the size
|
|
|
|
// of your final executable, you should remove from the following
|
|
|
|
// the specific initialization routines you do not need.
|
|
|
|
|
|
|
|
#ifdef _AFXDLL
|
|
|
|
Enable3dControls(); // Call this when using MFC in a shared DLL
|
|
|
|
#else
|
|
|
|
Enable3dControlsStatic(); // Call this when linking to MFC statically
|
|
|
|
#endif
|
|
|
|
|
|
|
|
CWnd myWnd;
|
|
|
|
|
|
|
|
//Do initializations
|
|
|
|
//Check for comm existence
|
|
|
|
//declare a tree for nodes
|
|
|
|
|
|
|
|
Path = GetModulePath();
|
|
|
|
|
1999-02-05 01:02:27 +00:00
|
|
|
strcpy(currDirPath, Path);
|
1999-02-03 16:39:50 +00:00
|
|
|
|
|
|
|
CString outputFile = Path + "output.dat";
|
1999-08-30 19:56:34 +00:00
|
|
|
out = fopen(outputFile, "w");
|
|
|
|
if (!out)
|
|
|
|
exit( 3 );
|
1999-02-03 16:39:50 +00:00
|
|
|
|
|
|
|
//char buffer[MID_SIZE];
|
|
|
|
char **argv;
|
|
|
|
int argc;
|
|
|
|
|
|
|
|
// 10 argument limit
|
|
|
|
argv = (char **) GlobalAlloc(0, sizeof(char *) * 10);
|
|
|
|
|
|
|
|
int i=0;
|
|
|
|
// Each argument limited to 100 chars
|
|
|
|
argv[i] = (char *) GlobalAlloc(0, sizeof(char) * MIN_SIZE);
|
|
|
|
argv[i] = strtok(m_lpCmdLine," ");
|
|
|
|
while(argv[i])
|
|
|
|
{
|
|
|
|
argv[++i] = (char *) GlobalAlloc(0, sizeof(char) * MIN_SIZE);
|
|
|
|
argv[i] = strtok(NULL," ");
|
|
|
|
}
|
|
|
|
|
|
|
|
argc = --i;
|
|
|
|
|
|
|
|
CString iniFile;
|
|
|
|
CString action;
|
|
|
|
|
|
|
|
for (i=0; i < argc; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp(argv[i], "-i"))
|
|
|
|
iniFile = argv[i+1];
|
|
|
|
if (!strcmp(argv[i], "-p"))
|
|
|
|
action = argv[i+1];
|
|
|
|
}
|
|
|
|
|
1999-06-17 04:42:40 +00:00
|
|
|
if ((iniFile.IsEmpty()) || (iniFile.GetLength() < 5) || (iniFile.Right(4) != ".ini"))
|
1999-02-03 16:39:50 +00:00
|
|
|
{
|
1999-10-02 01:28:27 +00:00
|
|
|
// Make life easier on us for now
|
|
|
|
iniFile = "cck.ini";
|
|
|
|
|
|
|
|
/*
|
1999-02-03 16:39:50 +00:00
|
|
|
myWnd.MessageBox("Please provide a valid inifile name.", "ERROR", MB_OK);
|
|
|
|
fprintf(out, "----------------** TERMINATED - Invalid INI file name **---------------\n");
|
|
|
|
exit(1);
|
1999-10-02 01:28:27 +00:00
|
|
|
*/
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
1999-02-05 04:05:43 +00:00
|
|
|
|
|
|
|
for (i=iniFile.GetLength() -1; i >= 0 && iniFile[i] != '\\'; i--)
|
|
|
|
{
|
|
|
|
if (iniFile.GetAt(i) == '/' ) {
|
|
|
|
iniFile.SetAt(i,(TCHAR)'\\');
|
|
|
|
}
|
|
|
|
}
|
1999-02-03 16:39:50 +00:00
|
|
|
|
1999-06-17 04:42:40 +00:00
|
|
|
// Take care of absolute path to iniFiles and bitmaps
|
|
|
|
if (iniFile[1] == ':' && iniFile[2] == '\\')
|
|
|
|
{
|
|
|
|
int len = 0;
|
|
|
|
strcpy(iniFilePath, iniFile);
|
1999-02-03 16:39:50 +00:00
|
|
|
|
1999-06-17 04:42:40 +00:00
|
|
|
int extractPosition = iniFile.ReverseFind('\\');
|
|
|
|
extractPosition++;
|
|
|
|
extractPosition = (iniFile.GetLength()) - extractPosition;
|
|
|
|
iniFile = iniFile.Right(extractPosition);
|
1999-02-05 01:02:27 +00:00
|
|
|
|
1999-06-17 04:42:40 +00:00
|
|
|
len = strlen(iniFilePath);
|
1999-02-03 16:39:50 +00:00
|
|
|
|
1999-06-17 04:42:40 +00:00
|
|
|
while(iniFilePath[len] != '\\')
|
|
|
|
{
|
|
|
|
iniFilePath[len] = '\0';
|
|
|
|
len--;
|
|
|
|
}
|
1999-02-03 16:39:50 +00:00
|
|
|
|
1999-06-17 04:42:40 +00:00
|
|
|
strcpy(imagesPath, iniFilePath);
|
1999-02-03 16:39:50 +00:00
|
|
|
|
1999-06-17 04:42:40 +00:00
|
|
|
len--;
|
1999-02-03 16:39:50 +00:00
|
|
|
|
1999-06-17 04:42:40 +00:00
|
|
|
while(imagesPath[len] != '\\')
|
|
|
|
{
|
|
|
|
imagesPath[len] = '\0';
|
|
|
|
len--;
|
|
|
|
}
|
|
|
|
|
1999-09-30 00:39:06 +00:00
|
|
|
strcpy(asePath,imagesPath);
|
|
|
|
|
|
|
|
strcat(asePath,"ase\\");
|
|
|
|
|
|
|
|
strcpy(nciPath,asePath);
|
|
|
|
|
|
|
|
strcat(nciPath,"NCIFiles\\");
|
|
|
|
|
1999-06-17 04:42:40 +00:00
|
|
|
strcat(imagesPath, "bitmaps\\");
|
1999-09-30 00:39:06 +00:00
|
|
|
|
1999-06-17 04:42:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Take care of relative path to iniFiles and bitmaps
|
|
|
|
|
|
|
|
strcpy(iniFilePath, currDirPath);
|
|
|
|
strcat(iniFilePath, "iniFiles\\");
|
|
|
|
strcpy(imagesPath, currDirPath);
|
|
|
|
strcat(imagesPath, "bitmaps\\");
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
|
|
|
|
1999-06-17 04:42:40 +00:00
|
|
|
strcpy(customizationPath, currDirPath);
|
|
|
|
strcat(customizationPath, "customizations\\");
|
|
|
|
|
1999-02-03 16:39:50 +00:00
|
|
|
CString cacheExt = ".che";
|
1999-06-17 04:42:40 +00:00
|
|
|
CacheFile = CString(iniFile);
|
1999-02-03 16:39:50 +00:00
|
|
|
CacheFile = CacheFile.GetBufferSetLength(CacheFile.Find(".ini")) + cacheExt;
|
1999-08-29 21:30:16 +00:00
|
|
|
CachePath = Path + CacheFile;
|
1999-02-03 16:39:50 +00:00
|
|
|
|
|
|
|
char buffer[MAX_SIZE] = {'\0'};
|
1999-08-29 21:30:16 +00:00
|
|
|
if (FileExists(CachePath))
|
1999-02-03 16:39:50 +00:00
|
|
|
{
|
|
|
|
UseCache = TRUE;
|
1999-08-30 19:56:34 +00:00
|
|
|
if (!FillGlobalWidgetArray(CachePath))
|
|
|
|
exit(10);
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(out, "___________________________________________________________\n\n");
|
|
|
|
fprintf(out, "ACTION SEQUENCE : %s\n", action);
|
|
|
|
fprintf(out, "___________________________________________________________\n\n");
|
|
|
|
|
|
|
|
SetGlobalDefaults();
|
|
|
|
|
1999-06-17 04:42:40 +00:00
|
|
|
InitializeTree(CString(iniFile));
|
|
|
|
CreateFirstLeaf(WizardTree, CString(iniFilePath) + CString(iniFile));
|
1999-02-03 16:39:50 +00:00
|
|
|
|
|
|
|
//BEGIN - Command line QA enable code
|
|
|
|
/**
|
|
|
|
i=0;
|
|
|
|
while(i < action.GetLength())
|
|
|
|
{
|
|
|
|
ExecuteAction(action.GetAt(i));
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateNewCache();
|
|
|
|
|
|
|
|
fprintf(out, "---------------------**** END ****-------------------------\n");
|
|
|
|
|
|
|
|
myWnd.MessageBox(CurrentNode->localVars->pageName, "Netscape", MB_OK);
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
**/
|
|
|
|
//END - Command line QA enable code
|
|
|
|
|
|
|
|
//CProgressDialog ProgressDialog;
|
|
|
|
PropertySheetDlg = new CPropSheet(IDD_WIZARDMACHINE_DIALOG);
|
|
|
|
//CWizardMachineDlg* myWndTmp;
|
|
|
|
|
|
|
|
CWizardUI* pages[99];
|
|
|
|
//CMyProgressDlg ProgressDialog(myWndTmp);
|
|
|
|
//ProgressDialog.Create(IDD_PROGRESS_DLG);
|
|
|
|
//CMyProgressDlg *pProgressDlg = &ProgressDialog;
|
|
|
|
|
|
|
|
for (int x = 0; x < 99; x++) {
|
|
|
|
pages[x] = new CWizardUI;
|
|
|
|
PropertySheetDlg->AddPage (pages[x]);
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertySheetDlg->SetWizardMode();
|
|
|
|
int PageReturnValue = PropertySheetDlg->DoModal();
|
|
|
|
delete(PropertySheetDlg);
|
|
|
|
|
|
|
|
if (PageReturnValue == ID_WIZFINISH)
|
|
|
|
{
|
1999-05-25 07:42:48 +00:00
|
|
|
CreateRshell();
|
1999-02-03 16:39:50 +00:00
|
|
|
if (!isBuildInstaller) {
|
|
|
|
|
|
|
|
NODE* tmpNode = WizardTree->childNodes[0];
|
|
|
|
while (!tmpNode->numWidgets) {
|
|
|
|
tmpNode = tmpNode->childNodes[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
CurrentNode = tmpNode;
|
|
|
|
}
|
1999-06-17 04:42:40 +00:00
|
|
|
theApp.CreateNewCache();
|
|
|
|
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (PageReturnValue == IDCANCEL)
|
|
|
|
{
|
1999-05-19 03:31:11 +00:00
|
|
|
theApp.CreateNewCache();
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
1999-05-19 03:31:11 +00:00
|
|
|
if (PageReturnValue == ID_HELP)
|
|
|
|
{
|
|
|
|
|
|
|
|
CWnd Mywnd;
|
|
|
|
Mywnd.MessageBox("hello","hello",MB_OK);
|
|
|
|
}
|
|
|
|
//
|
1999-02-03 16:39:50 +00:00
|
|
|
|
|
|
|
//CreateNewCache();
|
|
|
|
|
|
|
|
fprintf(out, "---------------------**** END ****-------------------------\n");
|
|
|
|
|
|
|
|
|
|
|
|
// Since the dialog has been closed, return FALSE so that we exit the
|
|
|
|
// application, rather than start the application's message pump.
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
////Add Wizard machine functions here.
|
|
|
|
//Define OnEnter function
|
|
|
|
//Define OnExit function
|
|
|
|
//Define ExitApp function
|
|
|
|
//Define GoToNextNode function
|
|
|
|
//Define GoToPrevNode function
|
|
|
|
//Define GetGlobal function
|
|
|
|
//Define SetGlobal function
|
|
|
|
|
|
|
|
void CWizardMachineApp::InitializeTree(CString rootIniFile)
|
|
|
|
{
|
|
|
|
WizardTree = CreateNode(GlobalDefaults, rootIniFile);
|
|
|
|
PrintNodeInfo(WizardTree);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Create Node
|
|
|
|
NODE* CWizardMachineApp::CreateNode(NODE *parentNode, CString iniFile)
|
|
|
|
{
|
|
|
|
|
|
|
|
char buffer[MAX_SIZE]= { '\0' };
|
|
|
|
char visibility[MIN_SIZE] = {'\0'};
|
|
|
|
CString pagesSection = "Sub Pages";
|
|
|
|
CString varSection = "Local Variables";
|
|
|
|
CString navCtrlSection = "Navigation Controls";
|
|
|
|
CString widgetSection = "Widget";
|
|
|
|
CString imageSection = "Image";
|
|
|
|
CStringArray bufferArray;
|
|
|
|
NODE* NewNode = (NODE *) GlobalAlloc(0,sizeof(NODE) * 1);
|
|
|
|
|
1999-09-24 00:25:10 +00:00
|
|
|
// Initialize all the extra fields here...
|
|
|
|
NewNode->isWidgetsSorted = FALSE;
|
1999-05-19 03:31:11 +00:00
|
|
|
|
1999-02-03 16:39:50 +00:00
|
|
|
NewNode->parent = parentNode;
|
|
|
|
|
|
|
|
iniFile = CString(iniFilePath)+iniFile; //Path+iniFile;
|
|
|
|
|
|
|
|
CheckIniFileExistence(iniFile);
|
|
|
|
|
|
|
|
GetPrivateProfileString(pagesSection, NULL, "", buffer, MAX_SIZE, iniFile);
|
|
|
|
|
|
|
|
NewNode->numChildNodes = GetBufferCount(buffer);
|
|
|
|
NewNode->currNodeIndex = 0;
|
|
|
|
|
|
|
|
NewNode->subPages = new PAGE;
|
|
|
|
|
|
|
|
int numHidePages = 0;
|
|
|
|
for (int i=0; i < NewNode->numChildNodes ; i++)
|
|
|
|
{
|
|
|
|
CString page = GetBufferElement(buffer, i);
|
|
|
|
|
|
|
|
GetPrivateProfileString(pagesSection, page, "", visibility, MAX_SIZE, iniFile);
|
|
|
|
|
|
|
|
CString visible = CString(visibility);
|
|
|
|
CString tmpVisible = CString(visibility);
|
|
|
|
visible.MakeUpper();
|
|
|
|
visible.TrimRight();
|
|
|
|
if ( visible != "HIDE")
|
|
|
|
{
|
|
|
|
NewNode->subPages->pages.Add(page);
|
|
|
|
NewNode->subPages->visibility.Add(tmpVisible);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
numHidePages++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NewNode->numChildNodes = NewNode->numChildNodes - numHidePages;
|
|
|
|
|
|
|
|
NewNode->childNodes = (NODE **) GlobalAlloc(0,NewNode->numChildNodes * sizeof(NODE *));
|
|
|
|
|
|
|
|
for (i=0; i < NewNode->numChildNodes ; i++)
|
|
|
|
{
|
|
|
|
NewNode->childNodes[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
NewNode->localVars = new VARS;
|
|
|
|
GetPrivateProfileString(varSection, "Title", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
NewNode->localVars->title = buffer;
|
|
|
|
GetPrivateProfileString(varSection, "Caption", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
NewNode->localVars->caption = buffer;
|
|
|
|
GetPrivateProfileString(varSection, "Function", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
NewNode->localVars->functionality = buffer;
|
|
|
|
|
|
|
|
CString tempPageVar = "";
|
|
|
|
|
|
|
|
int index = iniFile.ReverseFind('\\');
|
|
|
|
if (index != -1)
|
|
|
|
{
|
|
|
|
for (int j=index+1 ; j < iniFile.GetLength() ; j++)
|
|
|
|
{
|
|
|
|
char element = iniFile.GetAt(j);
|
|
|
|
if (element == '.')
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tempPageVar += element;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NewNode->localVars->pageName = tempPageVar;
|
|
|
|
|
|
|
|
|
|
|
|
GetPrivateProfileString(varSection, "image", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
NewNode->localVars->image = buffer;
|
|
|
|
GetPrivateProfileString(varSection, "Visibility", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
NewNode->localVars->visibility = buffer;
|
|
|
|
|
|
|
|
NewNode->navControls = new CONTROLS;
|
|
|
|
GetPrivateProfileString(navCtrlSection, "OnNext", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
NewNode->navControls->onNextAction = buffer;
|
1999-09-30 00:39:06 +00:00
|
|
|
GetPrivateProfileString(navCtrlSection, "onEnter", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
NewNode->navControls->onEnter = buffer;
|
1999-02-03 16:39:50 +00:00
|
|
|
GetPrivateProfileString(navCtrlSection, "Help", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
NewNode->navControls->helpFile = buffer;
|
|
|
|
|
|
|
|
NewNode->pageWidgets = (WIDGET **) GlobalAlloc(0, MIN_SIZE * sizeof(WIDGET *));
|
|
|
|
NewNode->numWidgets = 0;
|
|
|
|
NewNode->currWidgetIndex = 0;
|
|
|
|
|
|
|
|
NewNode->pageBaseIndex = CurrentPageBaseIndex;
|
|
|
|
CurrentPageBaseIndex += MIN_SIZE;
|
|
|
|
|
|
|
|
// MAX 20 images/page ....?
|
|
|
|
NewNode->images = (IMAGE **) GlobalAlloc(0, 20 * sizeof(IMAGE *));
|
|
|
|
NewNode->numImages = 0;
|
|
|
|
|
|
|
|
char sectionBuffer[MID_SIZE];
|
|
|
|
GetPrivateProfileString(NULL, NULL, "", sectionBuffer, MAX_SIZE, iniFile);
|
|
|
|
char iniSection[MID_SIZE];
|
|
|
|
|
|
|
|
int idCounter=0;
|
|
|
|
for (i=0; i < GetBufferCount(sectionBuffer); i++)
|
|
|
|
{
|
|
|
|
strcpy(iniSection,GetBufferElement(sectionBuffer, i));
|
|
|
|
|
|
|
|
if(strstr(iniSection, widgetSection))
|
|
|
|
{
|
|
|
|
char localBuffer[MAX_SIZE] = {'\0'};
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Name", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
strcpy(localBuffer, buffer);
|
|
|
|
|
|
|
|
WIDGET* widgetEntry = findWidget(buffer);
|
|
|
|
|
|
|
|
if (widgetEntry)
|
|
|
|
{
|
|
|
|
if (!widgetEntry->cached)
|
|
|
|
{
|
|
|
|
prevLock.Lock();
|
|
|
|
CWnd myWnd;
|
|
|
|
myWnd.MessageBox("Duplicate Widget Entry " + CString(buffer) + " detected : "+ NewNode->localVars->pageName , "Error", MB_ICONSTOP | MB_SYSTEMMODAL);
|
|
|
|
prevLock.Unlock();
|
|
|
|
exit(7);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-08-29 22:07:39 +00:00
|
|
|
BOOL readValue = (widgetEntry->value == "");
|
1999-02-03 16:39:50 +00:00
|
|
|
BuildWidget(widgetEntry, iniSection, iniFile, NewNode->pageBaseIndex, readValue);
|
|
|
|
|
|
|
|
widgetEntry->cached = FALSE;
|
|
|
|
NewNode->pageWidgets[NewNode->numWidgets] = widgetEntry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BOOL readValue = TRUE;
|
|
|
|
GlobalWidgetArray[GlobalArrayIndex].cached = TRUE;
|
|
|
|
|
|
|
|
BuildWidget(&GlobalWidgetArray[GlobalArrayIndex], iniSection, iniFile, NewNode->pageBaseIndex, readValue);
|
|
|
|
GlobalWidgetArray[GlobalArrayIndex].cached = FALSE;
|
|
|
|
|
|
|
|
NewNode->pageWidgets[NewNode->numWidgets] = &GlobalWidgetArray[GlobalArrayIndex];
|
|
|
|
GlobalArrayIndex++;
|
|
|
|
}
|
|
|
|
|
|
|
|
(NewNode->numWidgets)++;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(strstr(iniSection, imageSection))
|
|
|
|
{
|
|
|
|
int index = NewNode->numImages;
|
|
|
|
|
|
|
|
// This allows dynamic buffer allocation to CString vars
|
|
|
|
NewNode->images[index] = new IMAGE;
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Name", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
NewNode->images[index]->name = CString(imagesPath) + CString(buffer);
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Value", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
NewNode->images[index]->value = buffer;
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "start_X", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
NewNode->images[index]->location.x = atoi(buffer);
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "start_Y", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
NewNode->images[index]->location.y = atoi(buffer);
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "width", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
NewNode->images[index]->size.width = atoi(buffer);
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "height", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
NewNode->images[index]->size.height = atoi(buffer);
|
|
|
|
|
|
|
|
NewNode->images[index]->hBitmap = (HBITMAP)LoadImage(NULL, NewNode->images[index]->name, IMAGE_BITMAP, 0, 0,
|
|
|
|
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
|
|
|
|
|
|
|
|
(NewNode->numImages)++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
parentNode->childNodes[parentNode->currNodeIndex] = NewNode;
|
|
|
|
|
|
|
|
CurrentNode = NewNode;
|
|
|
|
|
|
|
|
//PrintNodeInfo(CurrentNode);
|
|
|
|
|
|
|
|
return NewNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Create Node
|
|
|
|
void CWizardMachineApp::CreateNode()
|
|
|
|
{
|
|
|
|
GlobalDefaults = (NODE *) GlobalAlloc(0,sizeof(NODE) * 1);
|
|
|
|
|
|
|
|
GlobalDefaults->parent = NULL;
|
|
|
|
|
|
|
|
GlobalDefaults->childNodes = (NODE **) GlobalAlloc(0,1 * sizeof(NODE *));
|
|
|
|
GlobalDefaults->numChildNodes = 1;
|
|
|
|
GlobalDefaults->currNodeIndex = 0;
|
|
|
|
GlobalDefaults->childNodes[GlobalDefaults->currNodeIndex] = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
GlobalDefaults->localVars = new VARS;
|
|
|
|
GlobalDefaults->localVars->title = "Globals";
|
|
|
|
GlobalDefaults->localVars->caption = "Globals";
|
|
|
|
GlobalDefaults->localVars->pageName = "Globals";
|
|
|
|
GlobalDefaults->localVars->image = "Globals";
|
|
|
|
|
|
|
|
GlobalDefaults->subPages = NULL;
|
|
|
|
GlobalDefaults->navControls = NULL;
|
|
|
|
GlobalDefaults->pageWidgets = NULL;
|
|
|
|
GlobalDefaults->numWidgets = 0;
|
|
|
|
GlobalDefaults->currWidgetIndex = 0;
|
|
|
|
|
|
|
|
CurrentNode = GlobalDefaults;
|
|
|
|
|
|
|
|
PrintNodeInfo(CurrentNode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CWizardMachineApp::SetGlobalDefaults()
|
|
|
|
{
|
|
|
|
CreateNode();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWizardMachineApp::CreateFirstLeaf(NODE *parent, CString iniFile)
|
|
|
|
{
|
|
|
|
NODE* currNode = parent;
|
|
|
|
CString section = "Sub Pages";
|
|
|
|
char buffer[MAX_SIZE] = {'\0'};
|
|
|
|
CString iniName;
|
|
|
|
|
|
|
|
|
|
|
|
iniName = iniFile;
|
|
|
|
|
|
|
|
while (SectionFound(iniName, section))
|
|
|
|
{
|
|
|
|
CString visibleChild;
|
|
|
|
char localBuffer[MAX_SIZE];
|
|
|
|
int i = 0;
|
|
|
|
GetPrivateProfileString(section, NULL, "", buffer, MAX_SIZE, iniName);
|
|
|
|
GetPrivateProfileString(section, GetBufferElement(buffer, i), "", localBuffer, MAX_SIZE, iniName);
|
|
|
|
|
|
|
|
CString visible = CString(localBuffer);
|
|
|
|
visible.MakeUpper();
|
|
|
|
visible.TrimRight();
|
|
|
|
|
|
|
|
while (visible == "HIDE")
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
GetPrivateProfileString(section, GetBufferElement(buffer, i), "", localBuffer, MAX_SIZE, iniName);
|
|
|
|
|
|
|
|
visible = CString(localBuffer);
|
|
|
|
visible.MakeUpper();
|
|
|
|
}
|
|
|
|
|
|
|
|
visibleChild = GetBufferElement(buffer, i);
|
|
|
|
|
|
|
|
if (visibleChild + ".ini" == ".ini")
|
|
|
|
{
|
|
|
|
CWnd myWnd;
|
|
|
|
CString message = "No pages to display.....!";
|
|
|
|
myWnd.MessageBox(message, "ERROR", MB_OK);
|
|
|
|
fprintf(out, "------------** TERMINATED - No pages to display **----------------\n");
|
|
|
|
exit(8);
|
|
|
|
}
|
|
|
|
|
|
|
|
currNode->childNodes[0] = CreateNode(currNode, visibleChild + ".ini");
|
|
|
|
currNode = currNode->childNodes[0];
|
|
|
|
|
|
|
|
iniName = iniFilePath + visibleChild + ".ini";
|
|
|
|
|
|
|
|
PrintNodeInfo(CurrentNode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL CWizardMachineApp::SectionFound(CString iniFile, CString section)
|
|
|
|
{
|
|
|
|
char buffer[MAX_SIZE] = {'\0'};
|
|
|
|
|
|
|
|
CheckIniFileExistence(iniFile);
|
|
|
|
|
|
|
|
GetPrivateProfileString(section, NULL, "", buffer, MIN_SIZE, iniFile);
|
|
|
|
|
|
|
|
return (buffer[0] != '\0');
|
|
|
|
}
|
|
|
|
|
|
|
|
int CWizardMachineApp::GetBufferCount(char *buffer)
|
|
|
|
{
|
|
|
|
int i=0;
|
|
|
|
int j=0;
|
|
|
|
|
|
|
|
if (!buffer[1] && !buffer[2])
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
BOOL streamEnd = FALSE;
|
|
|
|
while (!streamEnd)
|
|
|
|
{
|
|
|
|
while (buffer[++i])
|
|
|
|
;
|
|
|
|
j++;
|
|
|
|
|
|
|
|
if (buffer[i+1] == '\0')
|
|
|
|
streamEnd = TRUE;
|
|
|
|
}
|
|
|
|
return j;
|
|
|
|
}
|
|
|
|
|
|
|
|
char* CWizardMachineApp::GetBufferElement(const char *buffer, int index)
|
|
|
|
{
|
|
|
|
static char localBuffer[MID_SIZE];
|
|
|
|
|
|
|
|
for (int i=0; i < MID_SIZE; i++)
|
|
|
|
localBuffer[i] = '\0';
|
|
|
|
|
|
|
|
int j=0, k=0;
|
|
|
|
i=0;
|
|
|
|
BOOL streamEnd = FALSE;
|
|
|
|
BOOL elementFound = FALSE;
|
|
|
|
while (!streamEnd)
|
|
|
|
{
|
|
|
|
while (buffer[i])
|
|
|
|
{
|
|
|
|
if (j == index)
|
|
|
|
{
|
|
|
|
localBuffer[k] = buffer[i];
|
|
|
|
elementFound = TRUE;
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (elementFound)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
j++;
|
|
|
|
|
|
|
|
if (buffer[i+1] == '\0')
|
|
|
|
streamEnd = TRUE;
|
|
|
|
else
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return localBuffer;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
char* CWizardMachineApp::GetSectionBuffer(CString iniFile, CString section)
|
|
|
|
{
|
|
|
|
static char localBuffer[MID_SIZE];
|
|
|
|
|
|
|
|
CheckIniFileExistence(iniFile);
|
|
|
|
|
|
|
|
for (int i=0; i < MID_SIZE; i++)
|
|
|
|
localBuffer[i] = '\0';
|
|
|
|
|
|
|
|
GetPrivateProfileString(section, NULL, "", localBuffer, MID_SIZE, iniFile);
|
|
|
|
|
|
|
|
return localBuffer;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWizardMachineApp::ExecuteAction(char action)
|
|
|
|
{
|
|
|
|
|
|
|
|
switch(action)
|
|
|
|
{
|
|
|
|
case 'n' :
|
|
|
|
fprintf(out, "** NEXT : Begin **\n");
|
|
|
|
fprintf(out, "-----------------------------------------------------------\n");
|
|
|
|
GoToNextNode();
|
|
|
|
fprintf(out, "** NEXT : End **\n");
|
|
|
|
fprintf(out, "-----------------------------------------------------------\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'b' :
|
|
|
|
fprintf(out, "** BACK : Begin **\n");
|
|
|
|
fprintf(out, "-----------------------------------------------------------\n");
|
|
|
|
GoToPrevNode();
|
|
|
|
fprintf(out, "** BACK : End **\n");
|
|
|
|
fprintf(out, "-----------------------------------------------------------\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'c':
|
|
|
|
fprintf(out, "---------------------*** CANCEL ***------------------------\n");
|
|
|
|
fprintf(out, "-----------------** TERMINATED - User Cancelled App **-----------------\n");
|
|
|
|
ExitApp();
|
|
|
|
exit(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default :
|
|
|
|
CWnd myWnd;
|
|
|
|
char temp[MIN_SIZE] = {action};
|
|
|
|
myWnd.MessageBox(strcat("Unknown Action : ", temp), "ERROR", MB_OK);
|
|
|
|
fprintf(out, "---------------** TERMINATED - Invalid Action Element **---------------\n");
|
|
|
|
exit(6);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-05 02:22:36 +00:00
|
|
|
void CWizardMachineApp::CopyDir(CString from, CString to)
|
|
|
|
{
|
|
|
|
WIN32_FIND_DATA data;
|
|
|
|
HANDLE d;
|
|
|
|
CString dot = ".";
|
|
|
|
CString dotdot = "..";
|
|
|
|
CString fchild, tchild;
|
|
|
|
CString pattern = from + "\\*.*";
|
|
|
|
int found;
|
|
|
|
DWORD tmp;
|
|
|
|
|
|
|
|
d = FindFirstFile((const char *) to, &data);
|
|
|
|
if (d == INVALID_HANDLE_VALUE)
|
|
|
|
mkdir(to);
|
|
|
|
|
|
|
|
d = FindFirstFile((const char *) pattern, &data);
|
|
|
|
found = (d != INVALID_HANDLE_VALUE);
|
|
|
|
|
|
|
|
while (found)
|
|
|
|
{
|
|
|
|
if (data.cFileName != dot && data.cFileName != dotdot)
|
|
|
|
{
|
|
|
|
fchild = from + "\\" + data.cFileName;
|
|
|
|
tchild = to + "\\" + data.cFileName;
|
|
|
|
tmp = data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
|
|
|
|
if (tmp == FILE_ATTRIBUTE_DIRECTORY)
|
|
|
|
CopyDir(fchild, tchild);
|
|
|
|
else
|
|
|
|
CopyFile((const char *) fchild, (const char *) tchild, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
found = FindNextFile(d, &data);
|
|
|
|
}
|
|
|
|
|
|
|
|
FindClose(d);
|
|
|
|
}
|
|
|
|
|
1999-10-02 01:28:27 +00:00
|
|
|
void CWizardMachineApp::ExecuteCommand(char *command, int showflag)
|
|
|
|
{
|
|
|
|
STARTUPINFO startupInfo;
|
|
|
|
PROCESS_INFORMATION processInfo;
|
|
|
|
|
|
|
|
memset(&startupInfo, 0, sizeof(startupInfo));
|
|
|
|
memset(&processInfo, 0, sizeof(processInfo));
|
|
|
|
|
|
|
|
startupInfo.cb = sizeof(STARTUPINFO);
|
|
|
|
startupInfo.dwFlags = STARTF_USESHOWWINDOW;
|
|
|
|
//startupInfo.wShowWindow = SW_SHOW;
|
|
|
|
startupInfo.wShowWindow = showflag;
|
|
|
|
|
|
|
|
BOOL executionSuccessful = CreateProcess(NULL, command, NULL, NULL, TRUE,
|
|
|
|
NORMAL_PRIORITY_CLASS, NULL, NULL,
|
|
|
|
&startupInfo, &processInfo);
|
|
|
|
DWORD error = GetLastError();
|
|
|
|
WaitForSingleObject(processInfo.hProcess, INFINITE);
|
|
|
|
}
|
|
|
|
|
|
|
|
CString CWizardMachineApp::replaceVars(char *str, char *listval)
|
1999-08-29 23:42:43 +00:00
|
|
|
{
|
|
|
|
char buf[MIN_SIZE];
|
|
|
|
char *b = buf;
|
1999-10-02 01:28:27 +00:00
|
|
|
char *v;
|
1999-10-05 02:22:36 +00:00
|
|
|
CString v1;
|
1999-09-30 00:39:06 +00:00
|
|
|
|
1999-08-29 23:42:43 +00:00
|
|
|
while (*str)
|
|
|
|
{
|
|
|
|
if (*str == '%')
|
|
|
|
{
|
|
|
|
char *n = ++str;
|
|
|
|
while (*str && *str != '%')
|
|
|
|
str++;
|
|
|
|
if (*str == '%')
|
|
|
|
{
|
|
|
|
*str = '\0';
|
1999-09-30 00:39:06 +00:00
|
|
|
|
1999-10-02 01:28:27 +00:00
|
|
|
if (listval && strlen(n) <= 0)
|
|
|
|
v = listval;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WIDGET *w = findWidget(n);
|
|
|
|
if (w)
|
1999-10-05 02:22:36 +00:00
|
|
|
{
|
|
|
|
if (w->control && w->control->m_hWnd)
|
|
|
|
{
|
|
|
|
v1 = CWizardUI::GetScreenValue(w);
|
|
|
|
v = (char *) (LPCSTR) v1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
v = (char *) (LPCSTR) w->value;
|
|
|
|
}
|
1999-10-02 01:28:27 +00:00
|
|
|
else
|
|
|
|
v = "";
|
|
|
|
}
|
|
|
|
strcpy(b, v);
|
|
|
|
b += strlen(v);
|
1999-08-29 23:42:43 +00:00
|
|
|
}
|
|
|
|
else
|
1999-10-02 01:28:27 +00:00
|
|
|
{
|
|
|
|
CWnd myWnd;
|
|
|
|
myWnd.MessageBox("Improperly terminated globals reference", "Error", MB_OK);
|
1999-08-29 23:42:43 +00:00
|
|
|
exit(12);
|
1999-10-02 01:28:27 +00:00
|
|
|
}
|
1999-08-29 23:42:43 +00:00
|
|
|
str++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*b++ = *str++;
|
|
|
|
}
|
|
|
|
*b = '\0';
|
|
|
|
|
|
|
|
return CString(buf);
|
|
|
|
}
|
|
|
|
|
1999-10-02 01:28:27 +00:00
|
|
|
BOOL CWizardMachineApp::IterateListBox(char *parms)
|
|
|
|
{
|
|
|
|
char *target = strtok(parms, ",");
|
|
|
|
char *showstr = strtok(NULL, ",");
|
|
|
|
char *cmd = strtok(NULL, "");
|
|
|
|
WIDGET *w = findWidget(target);
|
|
|
|
char indices[MAX_SIZE];
|
|
|
|
int showflag;
|
|
|
|
|
|
|
|
if (!w || w->type != "ListBox")
|
|
|
|
return FALSE;
|
|
|
|
|
1999-10-05 02:22:36 +00:00
|
|
|
if (w->control && w->control->m_hWnd)
|
1999-10-02 01:28:27 +00:00
|
|
|
{
|
|
|
|
// Widget is still visible on screen, get temporary copy of current value
|
|
|
|
// (from here, we depend on UpdataData() having been called somewhere upstream)
|
|
|
|
CString v = CWizardUI::GetScreenValue(w);
|
|
|
|
strcpy(indices, (char *) (LPCSTR) v);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strcpy(indices, w->value);
|
|
|
|
|
|
|
|
if (strcmp(showstr, "SHOW") == 0)
|
|
|
|
showflag = SW_SHOWDEFAULT;
|
|
|
|
else if (strcmp(showstr, "HIDE") == 0)
|
|
|
|
showflag = SW_HIDE;
|
|
|
|
else
|
|
|
|
showflag = SW_SHOWDEFAULT;
|
|
|
|
|
|
|
|
char *s = strtok(indices, ","); // Need to fix this, parm2 is a span rather than a literal!!!
|
|
|
|
for (; s; s=strtok(NULL, ","))
|
|
|
|
{
|
|
|
|
char *cmd_copy = strdup(cmd);
|
|
|
|
CString command = replaceVars(cmd_copy, s);
|
|
|
|
free(cmd_copy);
|
|
|
|
ExecuteCommand((char *) (LPCSTR) command, showflag);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL CWizardMachineApp::interpret(CString cmds, WIDGET *curWidget)
|
1999-08-30 19:56:34 +00:00
|
|
|
{
|
|
|
|
// Make modifiable copy of string's buffer
|
|
|
|
char buf[MAX_SIZE];
|
1999-10-02 01:28:27 +00:00
|
|
|
strcpy(buf, (char *)(LPCTSTR) cmds);
|
1999-08-30 19:56:34 +00:00
|
|
|
|
|
|
|
// Format of commandList is: <command1>;<command2>;...
|
|
|
|
// Format of command is: <command>(<parm1>,<parm2>,...)
|
|
|
|
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; i<numCmds; i++)
|
|
|
|
{
|
|
|
|
char *pcmd = strtok(cmdList[i], "(");
|
1999-10-02 01:28:27 +00:00
|
|
|
char *parms = strtok(NULL, ")");
|
1999-08-30 19:56:34 +00:00
|
|
|
if (pcmd)
|
|
|
|
{
|
1999-10-02 01:28:27 +00:00
|
|
|
if (strcmp(pcmd, "command") == 0)
|
|
|
|
{
|
|
|
|
CString p = replaceVars(parms, NULL);
|
|
|
|
ExecuteCommand((char *) (LPCSTR) p, SW_SHOWDEFAULT);
|
|
|
|
}
|
|
|
|
else if (strcmp(pcmd, "IterateListBox") == 0)
|
1999-08-30 19:56:34 +00:00
|
|
|
{
|
1999-10-02 01:28:27 +00:00
|
|
|
if (!IterateListBox(parms))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pcmd, "VerifySet") == 0)
|
|
|
|
{
|
|
|
|
// VerifySet checks to see if the first parameter has any value
|
|
|
|
// If (p1) then continue else show error dialog and return FALSE
|
|
|
|
|
1999-08-30 19:56:34 +00:00
|
|
|
char *p2 = strchr(parms, ',');
|
1999-09-30 00:39:06 +00:00
|
|
|
|
1999-08-30 19:56:34 +00:00
|
|
|
if (p2)
|
|
|
|
*p2++ = '\0';
|
|
|
|
else
|
|
|
|
p2 = "A message belongs here.";
|
1999-10-02 01:28:27 +00:00
|
|
|
CString value = replaceVars(parms, NULL);
|
1999-09-30 00:39:06 +00:00
|
|
|
|
1999-08-30 19:56:34 +00:00
|
|
|
if (!value || value.IsEmpty())
|
|
|
|
{
|
|
|
|
CWnd myWnd;
|
|
|
|
myWnd.MessageBox(p2, "Error", MB_OK);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp(pcmd, "Reload") == 0)
|
|
|
|
{
|
1999-10-02 01:28:27 +00:00
|
|
|
// Reload sets the CachePath and reloads the cache from the new file
|
|
|
|
CString newDir = replaceVars(parms, NULL);
|
1999-08-30 19:56:34 +00:00
|
|
|
CachePath = Path + newDir + "\\" + CacheFile;
|
|
|
|
FillGlobalWidgetArray(CachePath); // Ignore failure, we'll write one out later
|
|
|
|
}
|
1999-09-30 00:39:06 +00:00
|
|
|
else if (strcmp(pcmd, "VerifyVal") == 0)
|
|
|
|
{
|
1999-10-02 01:28:27 +00:00
|
|
|
CString Getval = replaceVars(parms, NULL);
|
1999-09-30 00:39:06 +00:00
|
|
|
if (Getval == "0")
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pcmd, "VerifyDir") == 0)
|
|
|
|
{
|
|
|
|
CFileFind tmpDir;
|
|
|
|
BOOL dirFound = tmpDir.FindFile(CString(nciPath)+"*.*");
|
|
|
|
if (!dirFound)
|
|
|
|
{
|
|
|
|
strcpy(tmpPath,asePath);
|
|
|
|
strcat(tmpPath,"NCIFiles");
|
|
|
|
_mkdir (tmpPath);
|
|
|
|
}
|
|
|
|
}
|
1999-10-02 01:28:27 +00:00
|
|
|
else if (strcmp(pcmd, "DisplayImage") == 0)
|
|
|
|
{
|
|
|
|
// This is to dsiplay an image in a separate dialog
|
|
|
|
CImgDlg imgDlg(parms);
|
|
|
|
int retVal = imgDlg.DoModal();
|
|
|
|
}
|
|
|
|
else if (strcmp(pcmd, "ShowSum") == 0)
|
|
|
|
{
|
|
|
|
CSumDlg sumdlg;
|
|
|
|
int retVal = sumdlg.DoModal();
|
|
|
|
}
|
|
|
|
else if (strcmp(pcmd, "ConfigDialog") == 0)
|
|
|
|
{
|
|
|
|
CString entryName;
|
|
|
|
CNewDialog newDlg;
|
|
|
|
newDlg.DoModal();
|
|
|
|
entryName = newDlg.GetData();
|
|
|
|
theApp.SetGlobal(parms, entryName);
|
|
|
|
}
|
|
|
|
else if (strcmp(pcmd, "inform") == 0)
|
|
|
|
{
|
|
|
|
CString entryName;
|
|
|
|
CWnd myWnd;
|
|
|
|
char localPath[MAX_SIZE] = {'\0'};
|
|
|
|
char infoPath[MAX_SIZE] = {'\0'};
|
|
|
|
strcpy(infoPath, currDirPath);
|
|
|
|
if (localPath) {
|
|
|
|
strcat(infoPath, localPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
entryName = GetGlobal(parms);
|
|
|
|
if (entryName != "") {
|
|
|
|
myWnd.MessageBox( entryName + " is saved in " + CString(infoPath), "Information", MB_OK);
|
|
|
|
}
|
|
|
|
// Delete the global var now...
|
|
|
|
}
|
|
|
|
else if (strcmp(pcmd, "GenerateFileList") == 0 || strcmp(pcmd, "GenerateDirList") == 0)
|
|
|
|
{
|
|
|
|
char *p2 = strchr(parms, ',');
|
|
|
|
|
|
|
|
if (p2)
|
|
|
|
*p2++ = '\0';
|
|
|
|
CString value = replaceVars(parms, NULL);
|
|
|
|
|
|
|
|
WIDGET *w;
|
|
|
|
if (strcmp(parms, "self") == 0)
|
|
|
|
w = curWidget;
|
|
|
|
else
|
|
|
|
w = findWidget(parms);
|
|
|
|
|
|
|
|
if (w)
|
|
|
|
GenerateList(pcmd, w, p2);
|
|
|
|
}
|
|
|
|
else if (strcmp(pcmd, "BrowseFile") == 0)
|
|
|
|
{
|
|
|
|
if (curWidget)
|
|
|
|
CWizardUI::BrowseFile(curWidget);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (strcmp(pcmd, "BrowseDir") == 0)
|
|
|
|
{
|
|
|
|
if (curWidget)
|
|
|
|
CWizardUI::BrowseDir(curWidget);
|
|
|
|
}
|
1999-09-30 00:39:06 +00:00
|
|
|
|
1999-10-02 01:28:27 +00:00
|
|
|
else if (strcmp(pcmd, "NewConfig") == 0)
|
|
|
|
{
|
|
|
|
if (curWidget)
|
|
|
|
CWizardUI::NewConfig(curWidget);
|
|
|
|
}
|
1999-10-05 02:22:36 +00:00
|
|
|
|
|
|
|
else if (strcmp(pcmd, "CopyDir") == 0)
|
|
|
|
{
|
|
|
|
char *p2 = strchr(parms, ',');
|
|
|
|
if (p2)
|
|
|
|
{
|
|
|
|
*p2++ = '\0';
|
|
|
|
CString from = replaceVars(parms, NULL);
|
|
|
|
CString to = replaceVars(p2, NULL);
|
|
|
|
CopyDir(from, to);
|
|
|
|
}
|
|
|
|
}
|
1999-08-30 19:56:34 +00:00
|
|
|
}
|
1999-09-30 00:39:06 +00:00
|
|
|
// This is an extra free...
|
1999-09-28 18:48:29 +00:00
|
|
|
//free(pcmd);
|
1999-08-30 19:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-09-30 00:39:06 +00:00
|
|
|
BOOL CWizardMachineApp::GoToNextNode()
|
1999-02-03 16:39:50 +00:00
|
|
|
{
|
|
|
|
//check if it is a container node
|
|
|
|
//for now check existence of display information
|
|
|
|
//go to first child and so on
|
|
|
|
|
1999-08-29 21:30:16 +00:00
|
|
|
//----------------------------------------------------------------------------------------------
|
|
|
|
// Handle OnNext processing before doing anything else
|
|
|
|
//----------------------------------------------------------------------------------------------
|
|
|
|
if (CurrentNode->navControls->onNextAction)
|
1999-10-02 01:28:27 +00:00
|
|
|
if (!interpret(CurrentNode->navControls->onNextAction, NULL))
|
1999-09-30 00:39:06 +00:00
|
|
|
return TRUE;
|
1999-02-03 16:39:50 +00:00
|
|
|
|
1999-08-29 21:30:16 +00:00
|
|
|
//----------------------------------------------------------------------------------------------
|
1999-02-03 16:39:50 +00:00
|
|
|
NODE* tmpParentNode;
|
|
|
|
|
|
|
|
tmpParentNode = CurrentNode->parent;
|
|
|
|
|
|
|
|
while (tmpParentNode->localVars->pageName != "Globals")
|
|
|
|
{
|
|
|
|
|
|
|
|
PrintNodeInfo(tmpParentNode);
|
|
|
|
|
|
|
|
if ((tmpParentNode->currNodeIndex + 1) < tmpParentNode->numChildNodes)
|
|
|
|
{
|
|
|
|
tmpParentNode->currNodeIndex++;
|
|
|
|
|
|
|
|
NODE* siblingNode = tmpParentNode->childNodes[tmpParentNode->currNodeIndex];
|
|
|
|
|
|
|
|
if (siblingNode)
|
|
|
|
{
|
|
|
|
CurrentNode = siblingNode;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-09-30 00:39:06 +00:00
|
|
|
CurrentNode = CreateNode(tmpParentNode,
|
|
|
|
tmpParentNode->subPages->pages.GetAt(tmpParentNode->currNodeIndex) + ".ini");
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
|
|
|
|
1999-09-30 00:39:06 +00:00
|
|
|
if (!CurrentNode)
|
1999-10-02 01:28:27 +00:00
|
|
|
0; /* ??? */
|
1999-02-03 16:39:50 +00:00
|
|
|
|
1999-10-02 01:28:27 +00:00
|
|
|
if (!interpret(CurrentNode->navControls->onEnter, NULL))
|
1999-09-30 00:39:06 +00:00
|
|
|
return FALSE;
|
1999-02-03 16:39:50 +00:00
|
|
|
|
|
|
|
BOOL isAContainerNode;
|
|
|
|
BOOL haveChildNodes = TRUE;
|
|
|
|
|
|
|
|
isAContainerNode = (CurrentNode->numWidgets == 0);
|
|
|
|
while(isAContainerNode && haveChildNodes)
|
|
|
|
{
|
|
|
|
NODE* containerNode = CurrentNode;
|
|
|
|
if (containerNode->numChildNodes > 0)
|
|
|
|
{
|
|
|
|
CurrentNode = containerNode->childNodes[0];
|
|
|
|
if (!CurrentNode)
|
|
|
|
{
|
1999-09-30 00:39:06 +00:00
|
|
|
CurrentNode = CreateNode(containerNode,
|
|
|
|
containerNode->subPages->pages.GetAt(0) + ".ini");
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
|
|
|
isAContainerNode = (CurrentNode->numWidgets == 0);
|
|
|
|
PrintNodeInfo(containerNode);
|
|
|
|
haveChildNodes = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
haveChildNodes = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PrintNodeInfo(CurrentNode);
|
|
|
|
if (haveChildNodes)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tmpParentNode = tmpParentNode->parent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tmpParentNode->localVars->pageName == "Globals")
|
|
|
|
{
|
|
|
|
CWnd myWnd;
|
|
|
|
myWnd.MessageBox("Can't go past the last node", "Error", MB_OK);
|
|
|
|
fprintf(out, "------------** TERMINATED - Can't go past the last page **----------------\n");
|
|
|
|
exit(10);
|
|
|
|
}
|
1999-09-30 00:39:06 +00:00
|
|
|
return TRUE;
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-30 00:39:06 +00:00
|
|
|
BOOL CWizardMachineApp::GoToPrevNode()
|
1999-02-03 16:39:50 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
//check if it is a container node
|
|
|
|
//for now check existence of display information
|
|
|
|
//go to last child and so on
|
|
|
|
|
|
|
|
|
|
|
|
NODE* tmpParentNode;
|
|
|
|
|
|
|
|
tmpParentNode = CurrentNode->parent;
|
|
|
|
|
|
|
|
while (tmpParentNode->localVars->pageName != "Globals")
|
|
|
|
{
|
|
|
|
|
|
|
|
PrintNodeInfo(tmpParentNode);
|
|
|
|
|
|
|
|
if (tmpParentNode->currNodeIndex > 0)
|
|
|
|
{
|
|
|
|
tmpParentNode->currNodeIndex--;
|
|
|
|
|
|
|
|
NODE* siblingNode = tmpParentNode->childNodes[tmpParentNode->currNodeIndex];
|
|
|
|
|
|
|
|
if (siblingNode)
|
|
|
|
{
|
|
|
|
CurrentNode = siblingNode;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-09-30 00:39:06 +00:00
|
|
|
CurrentNode = CreateNode(tmpParentNode,
|
|
|
|
tmpParentNode->subPages->pages.GetAt(tmpParentNode->currNodeIndex) + ".ini");
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
|
|
|
|
1999-09-30 00:39:06 +00:00
|
|
|
if (!CurrentNode)
|
1999-10-02 01:28:27 +00:00
|
|
|
0;/*then what*/
|
1999-09-30 00:39:06 +00:00
|
|
|
|
1999-10-02 01:28:27 +00:00
|
|
|
if (!interpret(CurrentNode->navControls->onEnter, NULL))
|
1999-09-30 00:39:06 +00:00
|
|
|
return FALSE;
|
|
|
|
|
1999-02-03 16:39:50 +00:00
|
|
|
BOOL isAContainerNode;
|
|
|
|
BOOL haveChildNodes = TRUE;
|
|
|
|
|
|
|
|
isAContainerNode = (CurrentNode->numWidgets == 0);
|
|
|
|
while(isAContainerNode && haveChildNodes)
|
|
|
|
{
|
|
|
|
NODE* containerNode = CurrentNode;
|
|
|
|
|
|
|
|
if (containerNode->numChildNodes > 0)
|
|
|
|
{
|
|
|
|
int index = containerNode->currNodeIndex;
|
|
|
|
CurrentNode = containerNode->childNodes[index];
|
|
|
|
if (!CurrentNode)
|
|
|
|
{
|
1999-09-30 00:39:06 +00:00
|
|
|
CurrentNode = CreateNode(containerNode,
|
|
|
|
containerNode->subPages->pages.GetAt(index) + ".ini");
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
|
|
|
isAContainerNode = (CurrentNode->numWidgets == 0);
|
|
|
|
PrintNodeInfo(containerNode);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
haveChildNodes = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PrintNodeInfo(CurrentNode);
|
|
|
|
if (haveChildNodes)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tmpParentNode = tmpParentNode->parent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tmpParentNode->localVars->pageName == "Globals")
|
|
|
|
{
|
|
|
|
CWnd myWnd;
|
|
|
|
myWnd.MessageBox("Can't go back from first node", "Error", MB_OK);
|
|
|
|
fprintf(out, "------------** TERMINATED - Can't go back from first page **----------------\n");
|
|
|
|
exit(9);
|
|
|
|
}
|
1999-09-30 00:39:06 +00:00
|
|
|
return TRUE;
|
1999-02-03 16:39:50 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWizardMachineApp::ExitApp()
|
|
|
|
{
|
|
|
|
CreateNewCache();
|
|
|
|
}
|
|
|
|
|
1999-06-17 04:42:40 +00:00
|
|
|
|
1999-08-30 19:56:34 +00:00
|
|
|
/*
|
|
|
|
This routine isn't useful since the messagebox isn't usually appropriate anymore
|
1999-02-03 16:39:50 +00:00
|
|
|
FILE* CWizardMachineApp::OpenAFile(CString outputFile, CString mode)
|
|
|
|
{
|
|
|
|
|
1999-06-17 04:42:40 +00:00
|
|
|
if( !( filePtr = fopen( outputFile, mode ) ) )
|
1999-02-03 16:39:50 +00:00
|
|
|
{
|
|
|
|
CWnd myWnd;
|
|
|
|
myWnd.MessageBox("Unable to open file" + outputFile, "ERROR", MB_OK);
|
|
|
|
}
|
|
|
|
|
1999-06-17 04:42:40 +00:00
|
|
|
return filePtr;
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
1999-08-30 19:56:34 +00:00
|
|
|
*/
|
1999-02-03 16:39:50 +00:00
|
|
|
|
|
|
|
void CWizardMachineApp::PrintNodeInfo(NODE* node)
|
|
|
|
{
|
|
|
|
if (node)
|
|
|
|
{
|
|
|
|
fprintf(out, "Node name : " + node->localVars->pageName + "\n\n");
|
|
|
|
fprintf(out, "Number of Sub pages : %d\n", node->numChildNodes);
|
|
|
|
fprintf(out, "Number of Widgets : %d\n", node->numWidgets);
|
|
|
|
|
|
|
|
/**
|
|
|
|
for (int i=0; i< node->numWidgets; i++)
|
|
|
|
{
|
|
|
|
fprintf(out, "Widget%d Name : " + node->pageWidgets[i]->name + "\n", i+1);
|
|
|
|
fprintf(out, "Widget%d Value : " + node->pageWidgets[i]->value + "\n", i+1);
|
|
|
|
|
|
|
|
}
|
|
|
|
**/
|
|
|
|
fprintf(out, "-----------------------------------------------------------\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWizardMachineApp::CheckIniFileExistence(CString file)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
//BOOL CheckIniFileExistence = FALSE;
|
|
|
|
|
|
|
|
if (! (f = fopen(file, "r") ))
|
|
|
|
{
|
|
|
|
CWnd myWnd;
|
|
|
|
CString message = "File " + file + " could not be opened ";
|
|
|
|
|
|
|
|
myWnd.MessageBox(message, "ERROR", MB_OK);
|
|
|
|
fprintf(out, "------------** TERMINATED - Missing File : " + file + " **----------------\n");
|
|
|
|
exit(4);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL CWizardMachineApp::FileExists(CString file)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
|
|
|
|
if (! (f = fopen(file, "r") ))
|
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-08-30 19:56:34 +00:00
|
|
|
BOOL CWizardMachineApp::FillGlobalWidgetArray(CString file)
|
1999-02-03 16:39:50 +00:00
|
|
|
{
|
|
|
|
char buffer[MAX_SIZE] = {'\0'};
|
1999-08-29 21:30:16 +00:00
|
|
|
CString name = "";
|
|
|
|
CString value = "";
|
1999-02-03 16:39:50 +00:00
|
|
|
|
1999-08-30 19:56:34 +00:00
|
|
|
globs = fopen(file, "r");
|
|
|
|
if (!globs)
|
|
|
|
return FALSE;
|
1999-02-03 16:39:50 +00:00
|
|
|
|
|
|
|
while(!feof(globs))
|
|
|
|
{
|
|
|
|
while(fgets(buffer, MAX_SIZE, globs))
|
|
|
|
{
|
|
|
|
if (strstr(buffer, "="))
|
|
|
|
{
|
1999-08-29 21:30:16 +00:00
|
|
|
name = CString(strtok(buffer,"="));
|
|
|
|
value = CString(strtok(NULL,"="));
|
|
|
|
value.TrimRight();
|
1999-02-03 16:39:50 +00:00
|
|
|
|
1999-08-29 21:30:16 +00:00
|
|
|
WIDGET* w = SetGlobal(name, value);
|
|
|
|
if (w)
|
|
|
|
w->cached = TRUE;
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-08-29 21:30:16 +00:00
|
|
|
|
|
|
|
fclose(globs);
|
1999-08-30 19:56:34 +00:00
|
|
|
|
|
|
|
return TRUE;
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
|
|
|
|
1999-08-30 19:56:34 +00:00
|
|
|
BOOL CWizardMachineApp::FillGlobalWidgetArray()
|
1999-08-29 21:30:16 +00:00
|
|
|
{
|
1999-08-30 19:56:34 +00:00
|
|
|
return FillGlobalWidgetArray(CachePath);
|
1999-08-29 21:30:16 +00:00
|
|
|
}
|
1999-02-03 16:39:50 +00:00
|
|
|
|
|
|
|
void CWizardMachineApp::CreateNewCache()
|
|
|
|
{
|
1999-08-30 19:56:34 +00:00
|
|
|
globs = fopen(CachePath, "w");
|
|
|
|
if (!globs)
|
|
|
|
{
|
|
|
|
fprintf(out, "--------------** TERMINATED - Can't open cache file **----------------\n");
|
|
|
|
exit( 3 );
|
|
|
|
}
|
1999-02-03 16:39:50 +00:00
|
|
|
|
|
|
|
for(int i=0; i< GlobalArrayIndex; i++)
|
|
|
|
{
|
|
|
|
if (GlobalWidgetArray[i].type != "RadioButton"
|
|
|
|
&& GlobalWidgetArray[i].type != "Text"
|
|
|
|
&& GlobalWidgetArray[i].type != "Button"
|
|
|
|
&& GlobalWidgetArray[i].type != "GroupBox" )
|
|
|
|
{
|
|
|
|
if (GlobalWidgetArray[i].name != "")
|
|
|
|
{
|
|
|
|
fprintf(globs, GlobalWidgetArray[i].name + "=" + GlobalWidgetArray[i].value);
|
|
|
|
fprintf(globs, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(globs);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL CWizardMachineApp::IsLastNode(NODE* treeNode)
|
|
|
|
{
|
|
|
|
|
|
|
|
NODE* tmpParent;
|
|
|
|
BOOL lastNode = TRUE;
|
|
|
|
|
|
|
|
if (treeNode)
|
|
|
|
{
|
|
|
|
tmpParent = treeNode->parent;
|
|
|
|
|
|
|
|
while(tmpParent->localVars->pageName != "Globals")
|
|
|
|
{
|
|
|
|
if (tmpParent->numChildNodes == (tmpParent->currNodeIndex+1))
|
|
|
|
tmpParent = tmpParent->parent;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lastNode = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lastNode = FALSE;
|
|
|
|
}
|
|
|
|
return lastNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL CWizardMachineApp::IsFirstNode(NODE* treeNode)
|
|
|
|
{
|
|
|
|
|
|
|
|
NODE* tmpParent;
|
|
|
|
NODE* tmpNode;
|
|
|
|
BOOL firstNode = TRUE;
|
|
|
|
|
|
|
|
tmpNode = treeNode;
|
|
|
|
tmpParent = treeNode->parent;
|
|
|
|
|
|
|
|
if (tmpParent->childNodes[0] == tmpNode)
|
|
|
|
{
|
|
|
|
while((tmpParent->localVars->pageName != "Globals"))
|
|
|
|
{
|
|
|
|
tmpNode = tmpParent;
|
|
|
|
tmpParent = tmpParent->parent;
|
|
|
|
|
|
|
|
if (!(tmpParent->childNodes[0] == tmpNode))
|
|
|
|
{
|
|
|
|
firstNode = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
firstNode = FALSE;
|
|
|
|
}
|
|
|
|
return firstNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
CString CWizardMachineApp::GetModulePath()
|
|
|
|
{
|
|
|
|
char currPath[MID_SIZE];
|
|
|
|
int i,numBytes;
|
|
|
|
|
|
|
|
// Get the path of the file that was executed
|
|
|
|
numBytes = GetModuleFileName(m_hInstance, currPath, MIN_SIZE);
|
|
|
|
|
|
|
|
// get the cmd path
|
|
|
|
// Remove the filename from the path
|
1999-02-05 04:05:43 +00:00
|
|
|
for (i=numBytes-1;i >= 0 && currPath[i] != '\\';i--);
|
1999-02-03 16:39:50 +00:00
|
|
|
// Terminate command line with 0
|
|
|
|
if (i >= 0)
|
|
|
|
currPath[i+1]= '\0';
|
|
|
|
|
|
|
|
return CString(currPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
CString CWizardMachineApp::GetGlobal(CString theName)
|
|
|
|
{
|
1999-09-30 00:39:06 +00:00
|
|
|
WIDGET *w = findWidget((char *) (LPCSTR) theName);
|
|
|
|
|
|
|
|
if (w)
|
|
|
|
return w->value;
|
1999-02-03 16:39:50 +00:00
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
CString CWizardMachineApp::GetGlobalOptions(CString theName)
|
|
|
|
{
|
|
|
|
CString temp="";
|
|
|
|
|
|
|
|
for (int i = 0; i <= GlobalArrayIndex; i++)
|
|
|
|
{
|
|
|
|
if (GlobalWidgetArray[i].name == theName) {
|
|
|
|
if (GlobalWidgetArray[i].numOfOptions > 0) {
|
|
|
|
for (int j = 0; j < GlobalWidgetArray[i].numOfOptions; j++) {
|
|
|
|
strcat((char*)(LPCTSTR)(temp), GlobalWidgetArray[i].options.value[j]);
|
|
|
|
strcat((char*)(LPCTSTR)(temp), ";");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
temp = GlobalWidgetArray[i].items;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
1999-08-29 21:30:16 +00:00
|
|
|
WIDGET* CWizardMachineApp::SetGlobal(CString theName, CString theValue)
|
1999-02-03 16:39:50 +00:00
|
|
|
{
|
1999-08-29 21:30:16 +00:00
|
|
|
WIDGET* w = findWidget((char *)(LPCTSTR) theName);
|
|
|
|
if (w == NULL)
|
1999-02-03 16:39:50 +00:00
|
|
|
{
|
1999-08-29 22:32:29 +00:00
|
|
|
// Make sure we can add this value
|
|
|
|
if (GlobalArrayIndex >= sizeof(GlobalWidgetArray))
|
1999-08-29 21:30:16 +00:00
|
|
|
{
|
|
|
|
fprintf(out, "----------------** TERMINATED - Out of Global Space **---------------\n");
|
|
|
|
exit(11);
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
1999-08-29 21:30:16 +00:00
|
|
|
|
1999-08-29 22:32:29 +00:00
|
|
|
GlobalWidgetArray[GlobalArrayIndex].name = theName;
|
1999-08-29 21:30:16 +00:00
|
|
|
GlobalWidgetArray[GlobalArrayIndex].value = theValue;
|
|
|
|
w = &GlobalWidgetArray[GlobalArrayIndex];
|
1999-08-29 22:32:29 +00:00
|
|
|
GlobalArrayIndex++;
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
1999-08-29 21:30:16 +00:00
|
|
|
else
|
|
|
|
w->value = theValue;
|
1999-02-03 16:39:50 +00:00
|
|
|
|
1999-08-29 21:30:16 +00:00
|
|
|
return w;
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WIDGET* CWizardMachineApp::findWidget(char *theName)
|
|
|
|
{
|
|
|
|
|
|
|
|
for (int i = 0; i <= GlobalArrayIndex; i++)
|
|
|
|
{
|
|
|
|
if (GlobalWidgetArray[i].name == theName) {
|
|
|
|
return (&GlobalWidgetArray[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWizardMachineApp::BuildWidget(WIDGET* aWidget, CString iniSection, CString iniFile, int pageBaseIndex, BOOL readValue)
|
|
|
|
{
|
|
|
|
static int idCounter = 0;
|
1999-02-26 18:36:04 +00:00
|
|
|
char buffer[MAX_SIZE] = {'\0'};
|
|
|
|
char largeBuffer[EXTD_MAX_SIZE] = {'\0'};
|
1999-02-03 16:39:50 +00:00
|
|
|
|
|
|
|
idCounter++;
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Name", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->name = buffer;
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Type", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->type = buffer;
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Options", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->items = buffer;
|
|
|
|
|
|
|
|
if (readValue)
|
|
|
|
{
|
1999-02-26 18:36:04 +00:00
|
|
|
GetPrivateProfileString(iniSection, "Value", "", largeBuffer, EXTD_MAX_SIZE, iniFile);
|
|
|
|
aWidget->value = largeBuffer;
|
1999-02-03 16:39:50 +00:00
|
|
|
aWidget->value.TrimRight();
|
|
|
|
}
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Title", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->title = buffer;
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Group", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->group = buffer;
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Target", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->target = buffer;
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Start_x", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->location.x = atoi(buffer);
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Start_y", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->location.y = atoi(buffer);
|
|
|
|
|
|
|
|
//aWidget->size = new DIMENSION;
|
|
|
|
GetPrivateProfileString(iniSection, "Width", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->size.width = atoi(buffer);
|
|
|
|
GetPrivateProfileString(iniSection, "Height", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->size.height = atoi(buffer);
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "dll", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->action.dll = buffer;
|
|
|
|
GetPrivateProfileString(iniSection, "function", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->action.function = buffer;
|
|
|
|
GetPrivateProfileString(iniSection, "parameters", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
strcpy(aWidget->action.parameters, buffer);
|
|
|
|
|
|
|
|
/// Dynamic ID allocation
|
|
|
|
aWidget->widgetID = pageBaseIndex + idCounter;
|
|
|
|
|
|
|
|
|
|
|
|
// As the number of entries in the subsection are not known, a generic loop
|
|
|
|
// has been created to read all existing name/value pairs in the subsection
|
|
|
|
// and store them in the options component of the control.
|
|
|
|
GetPrivateProfileString(iniSection, "subsection", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
if (strcmp(buffer, "") != 0) {
|
|
|
|
char* subSection;
|
|
|
|
subSection = new char[sizeof(buffer)];
|
|
|
|
strcpy(subSection, buffer);
|
|
|
|
|
|
|
|
if (aWidget->action.function == "")
|
|
|
|
{
|
|
|
|
int counter = 0;
|
|
|
|
int i = 0;
|
|
|
|
char* ComponentKey;
|
|
|
|
char ComponentKeyBuffer[MAX_SIZE];
|
|
|
|
if (GetPrivateProfileString(subSection, NULL, "", buffer, MAX_SIZE, iniFile) > 0)
|
|
|
|
{
|
|
|
|
while (buffer[i] != 0)
|
|
|
|
{
|
|
|
|
ComponentKey = &buffer[i];
|
|
|
|
if (GetPrivateProfileString(subSection, ComponentKey, "", ComponentKeyBuffer, MAX_SIZE, iniFile) > 0)
|
|
|
|
{
|
|
|
|
aWidget->options.name[counter] = new char[sizeof(ComponentKey)];
|
|
|
|
strcpy(aWidget->options.name[counter],ComponentKey);
|
|
|
|
aWidget->options.value[counter] = new char[sizeof(ComponentKeyBuffer)];
|
|
|
|
strcpy(aWidget->options.value[counter],ComponentKeyBuffer);
|
|
|
|
counter++;
|
|
|
|
}
|
|
|
|
while (buffer[i] != 0)
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aWidget->numOfOptions = counter;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aWidget->numOfOptions = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-19 03:31:11 +00:00
|
|
|
/*
|
|
|
|
void CWizardMachineApp::BuildHelpWidget(WIDGET* aWidget, CString iniSection, CString iniFile, int pageBaseIndex)
|
|
|
|
{
|
|
|
|
static int idCounter = 0;
|
|
|
|
char buffer[MAX_SIZE] = {'\0'};
|
|
|
|
char largeBuffer[EXTD_MAX_SIZE] = {'\0'};
|
|
|
|
|
|
|
|
idCounter++;
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Name", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->name = buffer;
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Type", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->type = buffer;
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Options", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->items = buffer;
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Value", "", largeBuffer, EXTD_MAX_SIZE, iniFile);
|
|
|
|
aWidget->value = largeBuffer;
|
|
|
|
aWidget->value.TrimRight();
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Title", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->title = buffer;
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Group", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->group = buffer;
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Target", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->target = buffer;
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Start_x", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->location.x = atoi(buffer);
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "Start_y", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->location.y = atoi(buffer);
|
|
|
|
|
|
|
|
//aWidget->size = new DIMENSION;
|
|
|
|
GetPrivateProfileString(iniSection, "Width", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->size.width = atoi(buffer);
|
|
|
|
GetPrivateProfileString(iniSection, "Height", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->size.height = atoi(buffer);
|
|
|
|
|
|
|
|
GetPrivateProfileString(iniSection, "dll", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->action.dll = buffer;
|
|
|
|
GetPrivateProfileString(iniSection, "function", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
aWidget->action.function = buffer;
|
|
|
|
GetPrivateProfileString(iniSection, "parameters", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
strcpy(aWidget->action.parameters, buffer);
|
|
|
|
|
|
|
|
/// Dynamic ID allocation
|
|
|
|
aWidget->widgetID = pageBaseIndex + idCounter;
|
|
|
|
|
|
|
|
|
|
|
|
// As the number of entries in the subsection are not known, a generic loop
|
|
|
|
// has been created to read all existing name/value pairs in the subsection
|
|
|
|
// and store them in the options component of the control.
|
|
|
|
GetPrivateProfileString(iniSection, "subsection", "", buffer, MAX_SIZE, iniFile);
|
|
|
|
if (strcmp(buffer, "") != 0) {
|
|
|
|
char* subSection;
|
|
|
|
subSection = new char[sizeof(buffer)];
|
|
|
|
strcpy(subSection, buffer);
|
|
|
|
|
|
|
|
if (aWidget->action.function == "")
|
|
|
|
{
|
|
|
|
int counter = 0;
|
|
|
|
int i = 0;
|
|
|
|
char* ComponentKey;
|
|
|
|
char ComponentKeyBuffer[MAX_SIZE];
|
|
|
|
if (GetPrivateProfileString(subSection, NULL, "", buffer, MAX_SIZE, iniFile) > 0)
|
|
|
|
{
|
|
|
|
while (buffer[i] != 0)
|
|
|
|
{
|
|
|
|
ComponentKey = &buffer[i];
|
|
|
|
if (GetPrivateProfileString(subSection, ComponentKey, "", ComponentKeyBuffer, MAX_SIZE, iniFile) > 0)
|
|
|
|
{
|
|
|
|
aWidget->options.name[counter] = new char[sizeof(ComponentKey)];
|
|
|
|
strcpy(aWidget->options.name[counter],ComponentKey);
|
|
|
|
aWidget->options.value[counter] = new char[sizeof(ComponentKeyBuffer)];
|
|
|
|
strcpy(aWidget->options.value[counter],ComponentKeyBuffer);
|
|
|
|
counter++;
|
|
|
|
}
|
|
|
|
while (buffer[i] != 0)
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aWidget->numOfOptions = counter;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aWidget->numOfOptions = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
1999-02-03 16:39:50 +00:00
|
|
|
void CWizardMachineApp::GenerateList(CString action, WIDGET* targetWidget, CString parentDirPath)
|
|
|
|
{
|
|
|
|
WIDGET* curWidget = targetWidget;
|
|
|
|
|
|
|
|
CFileFind fileList;
|
1999-02-05 01:02:27 +00:00
|
|
|
BOOL dirFound = fileList.FindFile(CString(currDirPath) + parentDirPath);
|
1999-02-03 16:39:50 +00:00
|
|
|
|
|
|
|
if(curWidget->type == "ListBox")
|
|
|
|
{
|
|
|
|
((CListBox*)curWidget->control)->ResetContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(curWidget->type == "ComboBox")
|
|
|
|
{
|
|
|
|
((CComboBox*)curWidget->control)->ResetContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while (dirFound)
|
|
|
|
{
|
|
|
|
dirFound = fileList.FindNextFile();
|
|
|
|
|
|
|
|
if (action == "GenerateFileList")
|
|
|
|
{
|
|
|
|
if (!fileList.IsDirectory()) // skip if this is a dir
|
|
|
|
{
|
|
|
|
CString tmpFile = fileList.GetFileName();
|
|
|
|
if(curWidget->type == "ListBox")
|
|
|
|
{
|
|
|
|
((CListBox*)curWidget->control)->AddString(tmpFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(curWidget->type == "ComboBox")
|
|
|
|
{
|
|
|
|
((CComboBox*)curWidget->control)->AddString(tmpFile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action == "GenerateDirList")
|
|
|
|
{
|
1999-08-29 22:07:39 +00:00
|
|
|
if (fileList.IsDirectory()) // skip if this is not a dir
|
1999-02-03 16:39:50 +00:00
|
|
|
{
|
|
|
|
CString tmpFile = fileList.GetFileName();
|
|
|
|
if (!(tmpFile == "." || tmpFile == "..")) {
|
|
|
|
if(curWidget->type == "ListBox")
|
|
|
|
{
|
|
|
|
((CListBox*)curWidget->control)->AddString(tmpFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(curWidget->type == "ComboBox")
|
|
|
|
{
|
|
|
|
((CComboBox*)curWidget->control)->AddString(tmpFile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fileList.Close();
|
1999-08-29 22:07:39 +00:00
|
|
|
|
|
|
|
if(curWidget->type == "ListBox")
|
|
|
|
{
|
1999-10-02 01:28:27 +00:00
|
|
|
if (curWidget->value && curWidget->value != "")
|
|
|
|
{
|
|
|
|
char indices[MAX_SIZE];
|
|
|
|
|
|
|
|
strcpy(indices, curWidget->value);
|
|
|
|
char *s = strtok(indices, ",");
|
|
|
|
for (; s; s=strtok(NULL, ","))
|
|
|
|
((CListBox*)curWidget->control)->SelectString(0, s);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
((CListBox*)curWidget->control)->SetCurSel(0);
|
1999-08-29 22:07:39 +00:00
|
|
|
}
|
|
|
|
else if(curWidget->type == "ComboBox")
|
|
|
|
{
|
1999-08-29 23:04:36 +00:00
|
|
|
if (curWidget->value && curWidget->value != "")
|
|
|
|
((CComboBox*)curWidget->control)->SelectString(-1, curWidget->value);
|
|
|
|
else
|
|
|
|
((CComboBox*)curWidget->control)->SetCurSel(0);
|
1999-08-29 22:07:39 +00:00
|
|
|
}
|
1999-02-03 16:39:50 +00:00
|
|
|
}
|
|
|
|
|
1999-05-19 03:31:11 +00:00
|
|
|
void CWizardMachineApp::HelpWiz()
|
|
|
|
{
|
|
|
|
|
1999-02-03 16:39:50 +00:00
|
|
|
|
1999-05-19 03:31:11 +00:00
|
|
|
CWizHelp hlpdlg;
|
|
|
|
hlpdlg.DoModal();
|
1999-08-29 21:30:16 +00:00
|
|
|
}
|