diff --git a/mozilla/cck/driver/WizardMachine.cpp b/mozilla/cck/driver/WizardMachine.cpp index 642f6909208..698f1c502c6 100644 --- a/mozilla/cck/driver/WizardMachine.cpp +++ b/mozilla/cck/driver/WizardMachine.cpp @@ -35,6 +35,9 @@ #include "NewConfigDialog.h" #include "ProgDlgThread.h" +// for CopyDir +#include "winbase.h" + #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE @@ -763,6 +766,43 @@ void CWizardMachineApp::ExecuteAction(char action) } } +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); +} + void CWizardMachineApp::ExecuteCommand(char *command, int showflag) { STARTUPINFO startupInfo; @@ -788,6 +828,7 @@ CString CWizardMachineApp::replaceVars(char *str, char *listval) char buf[MIN_SIZE]; char *b = buf; char *v; + CString v1; while (*str) { @@ -806,7 +847,15 @@ CString CWizardMachineApp::replaceVars(char *str, char *listval) { WIDGET *w = findWidget(n); if (w) - v = (char *) (LPCSTR) w->value; + { + if (w->control && w->control->m_hWnd) + { + v1 = CWizardUI::GetScreenValue(w); + v = (char *) (LPCSTR) v1; + } + else + v = (char *) (LPCSTR) w->value; + } else v = ""; } @@ -841,7 +890,7 @@ BOOL CWizardMachineApp::IterateListBox(char *parms) if (!w || w->type != "ListBox") return FALSE; - if (w->control) + if (w->control && w->control->m_hWnd) { // Widget is still visible on screen, get temporary copy of current value // (from here, we depend on UpdataData() having been called somewhere upstream) @@ -1024,6 +1073,18 @@ BOOL CWizardMachineApp::interpret(CString cmds, WIDGET *curWidget) if (curWidget) CWizardUI::NewConfig(curWidget); } + + 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); + } + } } // This is an extra free... //free(pcmd); diff --git a/mozilla/cck/driver/WizardMachine.h b/mozilla/cck/driver/WizardMachine.h index c2c9175b77a..5711fa80c50 100644 --- a/mozilla/cck/driver/WizardMachine.h +++ b/mozilla/cck/driver/WizardMachine.h @@ -53,6 +53,7 @@ public: char* GetSectionBuffer(CString iniFile, CString section); void ExecuteAction(char action); CString replaceVars(char *str, char *listval); + void CopyDir(CString from, CString to); void ExecuteCommand(char *command, int showflag); BOOL IterateListBox(char *parms); BOOL interpret(CString cmd, WIDGET *curWidget); diff --git a/mozilla/cck/driver/WizardUI.cpp b/mozilla/cck/driver/WizardUI.cpp index 774c74ec558..a143ddf2c4e 100644 --- a/mozilla/cck/driver/WizardUI.cpp +++ b/mozilla/cck/driver/WizardUI.cpp @@ -685,6 +685,35 @@ BOOL CWizardUI::OnCommand(WPARAM wParam, LPARAM lParam) { if (curWidget->action.function == "command") theApp.interpret(curWidget->action.parameters, curWidget); + else if (curWidget->action.function == "NewConfig") { + CNewConfigDialog newDlg; + newDlg.DoModal(); + CString configField = newDlg.GetConfigName(); + CString newDir = CString(customizationPath); + newDir += configField; + _mkdir(newDir); + + /** + char srcCache[250]; + char destCache[250]; + strcpy(srcCache, Path); + strcat(srcCache, "cck.che"); + strcpy(destCache, newDir); + strcat(destCache, "\\cck.che"); + CopyFile(srcCache, destCache, FALSE); + **/ + + WIDGET* tmpWidget = theApp.findWidget((char*) (LPCTSTR)curWidget->target); + CString tmpFunction = tmpWidget->action.function; + CString params = CString(tmpWidget->action.parameters); + theApp.GenerateList(tmpFunction, tmpWidget, params); + + ((CComboBox*)tmpWidget->control)->SelectString(0, configField); + + + // remembering the widget name for subsequent .che file operations + //customizationWidgetName = tmpWidget->name; + } } else Progress();