Ignore:
Timestamp:
2000-09-13T15:31:38+12:00 (24 years ago)
Author:
sjboddie
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsinstaller/gsinstall.cpp

    r1541 r1543  
    213213 */
    214214void GSInstall::getSourcePath()
    215 { static char filename[512];
    216     FilePath     *exePath;
     215{
     216  static char filename[512];
     217  FilePath *exePath;
    217218
    218219  // get the filepath of this executable
    219220  GetModuleFileName(0, filename, 512);
    220   exePath   = new FilePath(filename);
     221  exePath = new FilePath(filename);
    221222
    222223  // get the parent (i.e. the folder containing this executable) for the source
    223224  // folder
    224   this->sourcePath  = exePath->parent();
     225  this->sourcePath = exePath->parent();
    225226
    226227  // get the gsdl source path
    227   this->gsdlSourcePath  = new FilePath(this->sourcePath->pathString(), "gsdl");
     228  this->gsdlSourcePath = new FilePath(this->sourcePath->pathString(), "gsdl");
    228229  delete exePath;
    229230}
     
    235236 */
    236237bool GSInstall::copyFiles()
    237 {   // ensure that we have got the required destination and that we can write there
     238{
     239  // ensure that we have got the required destination and that we can write there
    238240  if (this->installExe)
    239   { this->destinationPath->ensureWriteablePath();
    240   }
     241    {
     242      this->destinationPath->ensureWriteablePath();
     243    }
    241244
    242245  // ensure that the destination path for the collection itself is available
    243246  if (this->installVolume)
    244   { this->dataDestPath->ensureWriteablePath();
    245   }
     247    {
     248      this->dataDestPath->ensureWriteablePath();
     249    }
    246250
    247251  // do the copy
    248     this->manifest->copy(this->gsdlSourcePath);
     252  this->manifest->copy(this->gsdlSourcePath);
    249253
    250254  return true;
     
    256260 */
    257261bool GSInstall::updateRegistry()
    258 { // don't do registry stuff under windows 32s
    259     if (this->platform.isWindows32s() && FALSE)
    260     {   return true;
    261   }
     262{
     263  // don't do registry stuff under windows 32s
     264  if (this->platform.isWindows32s() && FALSE)
     265    {
     266      return true;
     267    }
    262268
    263269  // ensure all pertinent keys already exist for this volume/collection
    264     this->gsRegister->ensureKeysExist();
     270  this->gsRegister->ensureKeysExist();
    265271
    266272  // now move on to add key items
    267     if (this->installExe)
    268   { FilePath *serverPath    = new FilePath(this->destinationPath->pathString(), "server.exe");
    269     FilePath *setupPath     = new FilePath(this->destinationPath->pathString(), "gssetup.exe");
    270       FilePath *logPath = new FilePath(this->destinationPath->pathString(), "install.log");
    271     string exeKeyPath, uninstallCmd, uninstallKeyPath;
    272     gsPlatform platform;
    273 
    274     // store the normal collection key information
    275     this->gsRegister->storeKeyString(   HKEY_LOCAL_MACHINE,
    276                                                                         this->gsRegister->collectKeyId(),
    277                                       "library",
    278                                       serverPath->pathString());
    279 
    280     // This test is in fact for 9x or NT 4+; we're worried about the registry
    281     // format, not about the shell as such
    282     if (platform.isExplorerShell())
    283     { // get special app path key for windows 9x
    284         exeKeyPath  =   this->gsRegister->exeKeyId("library.exe");
    285 
    286       // ensure that the exe key exists
    287         this->gsRegister->ensureKeyExists(HKEY_LOCAL_MACHINE, exeKeyPath);
    288 
    289         // store default key for this application
    290         this->gsRegister->storeKeyString(   HKEY_LOCAL_MACHINE,
    291                                                                         exeKeyPath,
    292                                           "",
    293                                         serverPath->pathString());
    294 
    295       // store path for this application
    296         this->gsRegister->storeKeyString(   HKEY_LOCAL_MACHINE,
    297                                                                         exeKeyPath,
    298                                           "path",
    299                                         this->destinationPath->pathString());
    300 
    301       // create uninstall command line
    302       uninstallCmd = setupPath->pathString() + " -u " + logPath->pathString();
    303       uninstallKeyPath = this->gsRegister->uninstallKeyId(this->configFile->getString("CollectionName"));
    304 
    305       // ensure uninstall key exists
    306       this->gsRegister->ensureKeyExists(HKEY_LOCAL_MACHINE, uninstallKeyPath);
    307 
    308       this->gsRegister->storeKeyString(HKEY_LOCAL_MACHINE, uninstallKeyPath,
    309                                                                         "DisplayName",
    310                                         this->configFile->getString("CollectionName"));
    311       this->gsRegister->storeKeyString(HKEY_LOCAL_MACHINE, uninstallKeyPath,
    312                                                                         "UninstallString", uninstallCmd);
    313     }
    314     delete setupPath;
    315     delete serverPath;
    316       delete logPath;
    317   }
     273  if (this->installExe)
     274    {
     275      //      FilePath *serverPath = new FilePath(this->destinationPath->pathString(), "server.exe");
     276      FilePath *serverPath = new FilePath(this->destinationPath->pathString(), "library.exe");
     277      FilePath *setupPath = new FilePath(this->destinationPath->pathString(), "gssetup.exe");
     278      FilePath *logPath = new FilePath(this->destinationPath->pathString(), "install.log");
     279      string exeKeyPath, uninstallCmd, uninstallKeyPath;
     280      gsPlatform platform;
     281
     282      // store the normal collection key information
     283      this->gsRegister->storeKeyString(HKEY_LOCAL_MACHINE,
     284                       this->gsRegister->collectKeyId(),
     285                       "library",
     286                       serverPath->pathString());
     287
     288      // This test is in fact for 9x or NT 4+; we're worried about the registry
     289      // format, not about the shell as such
     290      if (platform.isExplorerShell())
     291    {
     292      // get special app path key for windows 9x
     293      exeKeyPath = this->gsRegister->exeKeyId("library.exe");
     294
     295      // ensure that the exe key exists
     296      this->gsRegister->ensureKeyExists(HKEY_LOCAL_MACHINE, exeKeyPath);
     297
     298      // store default key for this application
     299      this->gsRegister->storeKeyString(HKEY_LOCAL_MACHINE,
     300                       exeKeyPath,
     301                       "",
     302                       serverPath->pathString());
     303
     304      // store path for this application
     305      this->gsRegister->storeKeyString(HKEY_LOCAL_MACHINE,
     306                       exeKeyPath,
     307                       "path",
     308                       this->destinationPath->pathString());
     309
     310      // create uninstall command line
     311      uninstallCmd = setupPath->pathString() + " -u " + logPath->pathString();
     312      uninstallKeyPath = this->gsRegister->uninstallKeyId(this->configFile->getString("CollectionName"));
     313
     314      // ensure uninstall key exists
     315      this->gsRegister->ensureKeyExists(HKEY_LOCAL_MACHINE, uninstallKeyPath);
     316     
     317      this->gsRegister->storeKeyString(HKEY_LOCAL_MACHINE, uninstallKeyPath,
     318                       "DisplayName",
     319                       this->configFile->getString("CollectionName"));
     320      this->gsRegister->storeKeyString(HKEY_LOCAL_MACHINE, uninstallKeyPath,
     321                       "UninstallString", uninstallCmd);
     322    }
     323      delete setupPath;
     324      delete serverPath;
     325      delete logPath;
     326    }
    318327
    319328  if (this->installVolume || this->installFullVolume)
    320   { // no actual key items are held in the volume key; for future use
    321   }
     329    {   
     330      // no actual key items are held in the volume key; for future use
     331    }
    322332  return true;
    323333}
     
    327337 */
    328338void GSInstall::setDestination()
    329 { // get configuration from the install wizard pages
    330     this->destinationPath       = new FilePath(this->selectedDirs[0]->selectedPath());
    331     this->installFullVolume = this->selectedDirs[1]->getOption();
     339{
     340  // get configuration from the install wizard pages
     341  this->destinationPath = new FilePath(this->selectedDirs[0]->selectedPath());
     342  this->installFullVolume = this->selectedDirs[1]->getOption();
    332343  if (this->installFullVolume || true)  // NB: always take path from 2nd dialog
    333   { this->dataDestPath  = new FilePath(this->selectedDirs[1]->selectedPath());
    334   }
     344    {
     345      this->dataDestPath = new FilePath(this->selectedDirs[1]->selectedPath());
     346    }
    335347  else
    336   { this->dataDestPath  = this->destinationPath;
    337   }
     348    {
     349      this->dataDestPath = this->destinationPath;
     350    }
    338351
    339352  // open the log for writing
     
    344357
    345358bool GSInstall::setUninstall()
    346 { char tempPathStr[MAX_PATH];
     359{
     360  char tempPathStr[MAX_PATH];
    347361
    348362  // if we failed to get the Windows temporary directory, abort
    349363  if (GetTempPath(MAX_PATH, tempPathStr) == 0)
    350   { // TODO: abort!
    351     return false;
    352   }
     364    {
     365      // TODO: abort!
     366      return false;
     367    }
    353368
    354369  FilePath tempPath(tempPathStr);
     
    357372  // and the installation log to the temporary directory and run them there
    358373  if (*this->sourcePath != tempPath)
    359   { // copy this and install.log to temporary directory and restart
    360     FilePath exePath(*this->sourcePath, "gssetup.exe");
    361     FilePath logPath(*this->sourcePath, "install.log");
    362 
    363     FilePath exeDest(tempPath, "gssetup.exe");
    364     FilePath logDest(tempPath, "install.log");
    365 
    366     CopyFile(exePath.cString(), exeDest.cString(), false);
    367     CopyFile(logPath.cString(), logDest.cString(), false);
    368 
    369     // now run the gssetup in the temporary directory
    370     launchApp launchUninstall(exeDest);
    371     launchUninstall.setCommandLine(" -u " + logPath.pathString());
    372     launchUninstall.run(false, 0, "", "", false);
    373 
    374     return false;
    375   }
     374    {
     375      // copy this and install.log to temporary directory and restart
     376      FilePath exePath(*this->sourcePath, "gssetup.exe");
     377      FilePath logPath(*this->sourcePath, "install.log");
     378
     379      FilePath exeDest(tempPath, "gssetup.exe");
     380      FilePath logDest(tempPath, "install.log");
     381     
     382      CopyFile(exePath.cString(), exeDest.cString(), false);
     383      CopyFile(logPath.cString(), logDest.cString(), false);
     384
     385      // now run the gssetup in the temporary directory
     386      launchApp launchUninstall(exeDest);
     387      launchUninstall.setCommandLine(" -u " + logPath.pathString());
     388      launchUninstall.run(false, 0, "", "", false);
     389
     390      return false;
     391    }
    376392
    377393  // open the log for reading from the directory this exe is now in (which
     
    380396  this->openLog(logPath->pathString(), false);
    381397  delete logPath;
    382 
     398 
    383399  return true;
    384400}
    385401
    386402void GSInstall::uninstall()
    387 { FilePath *iniPath;
    388     string      command;
     403{
     404  FilePath *iniPath;
     405  string command;
    389406  stringArray params;
    390407
    391     this->manifest = new gsManifest(*this); // get a manifest manager
    392 
    393   iniPath   = new FilePath(this->collectPath->pathString(), "gsdl.ini");
    394     gsProfile gsdlProfile(*this, iniPath->pathString());
    395 
    396     while ((command = this->popCommand(params)) != "")
    397   { if (!this->manifest->undoAction(command, params))
    398     { if (!gsdlProfile.undoAction(command, params))
    399         { if (!this->gsRegister->undoAction(command, params))
    400         { if (!this->progman->undoAction(command, params))
    401             {
    402           }
    403         }
    404       }
    405     }
    406   }
     408  this->manifest = new gsManifest(*this); // get a manifest manager
     409
     410  iniPath = new FilePath(this->collectPath->pathString(), "gsdl.ini");
     411  gsProfile gsdlProfile(*this, iniPath->pathString());
     412
     413  while ((command = this->popCommand(params)) != "")
     414    {
     415      if (!this->manifest->undoAction(command, params))
     416    {
     417      if (!gsdlProfile.undoAction(command, params))
     418        {
     419          if (!this->gsRegister->undoAction(command, params))
     420        {
     421          if (!this->progman->undoAction(command, params))
     422            {
     423            }
     424        }
     425        }
     426    }
     427    }
    407428}
    408429
     
    411432 */
    412433void GSInstall::setManifest()
    413 {   if (this->installExe)
    414     {   this->manifest->selectGroup("library", *this->destinationPath);
    415   }
     434{
     435  if (this->installExe)
     436    {
     437      this->manifest->selectGroup("library", *this->destinationPath);
     438    }
    416439  if (this->installFullVolume)
    417   { this->manifest->selectGroup("collection", *this->dataDestPath);
    418   }
     440    {   
     441      this->manifest->selectGroup("collection", *this->dataDestPath);
     442    }
    419443  else
    420   { this->manifest->selectGroup("database", *this->dataDestPath);
    421   }
     444    {   
     445      this->manifest->selectGroup("database", *this->dataDestPath);
     446    }
    422447}
    423448
     
    427452 */
    428453bool GSInstall::updateProgman()
    429 { string groupName;
     454{
     455  string groupName;
    430456
    431457  // if we managed to get a connection to the program manager (or explorer
    432458  // shell) then do the requisite updates
    433459  if (this->progman->connect())
    434   { // get group name from folders
    435     groupName = this->configFile->getString("ProgramGroupName");
    436       if (groupName == "")
    437     {   // TODO: error handling
    438         this->progman->disconnect();
    439         return false;
    440       }
    441 
    442       // add the group
    443         if (!this->progman->addProgramGroup(groupName))
    444       { this->progman->disconnect();
    445         return false;
     460    {
     461      // get group name from folders
     462      groupName = this->configFile->getString("ProgramGroupName");
     463      if (groupName == "")
     464    {
     465      // TODO: error handling
     466      this->progman->disconnect();
     467      return false;
     468    }
     469     
     470      // add the group
     471      if (!this->progman->addProgramGroup(groupName))
     472    {
     473      this->progman->disconnect();
     474      return false;
    446475    }
    447 
    448     // add a "server" icon
    449     FilePath libraryPath(this->destinationPath->pathString(), "library.exe");
    450       if (!this->progman->addIcon(groupName, "Library (without nextwork support)", libraryPath.pathString(), ""))
    451     { // assume that it may be there already
    452       }
    453 
    454     // check for server existence
    455     FilePath serverPath(this->destinationPath->pathString(), "server.exe");
    456     if (serverPath.exists())
    457     { if (!this->progman->addIcon(groupName, "Server", serverPath.pathString(), ""))
    458         {   // assume that it may be there already
    459       }
    460       }
    461 
    462     FilePath readMePath(this->destinationPath->pathString(), "readme.txt");
    463       if (!this->progman->addIcon(groupName, "ReadMe", readMePath.pathString(), ""))
     476     
     477      // add a "server" icon
     478      FilePath libraryPath(this->destinationPath->pathString(), "library.exe");
     479      if (!this->progman->addIcon(groupName, "Library", libraryPath.pathString(), ""))
    464480    {
    465       }
    466 
    467     FilePath supportPath(this->destinationPath->pathString(), "support.html");
    468       if (!this->progman->addIcon(groupName, "Technical Support", supportPath.pathString(), ""))
     481      // assume that it may be there already
     482    }
     483
     484      // check for server existence
     485      //      FilePath serverPath(this->destinationPath->pathString(), "server.exe");
     486      //      if (serverPath.exists())
     487      //    {
     488      //      if (!this->progman->addIcon(groupName, "Server", serverPath.pathString(), ""))
     489      //        {
     490          // assume that it may be there already
     491      //        }
     492      //    }
     493     
     494      FilePath readMePath(this->destinationPath->pathString(), "readme.txt");
     495      if (!this->progman->addIcon(groupName, "ReadMe", readMePath.pathString(), ""))
    469496    {
    470       }
    471 
    472     // TODO: uninstall icon
    473     // FilePath uninstallPath(this->destinationPath->pathString(), "gssetup.exe");
    474 
    475     // disconnect from program manager
    476     this->progman->disconnect();
    477   }
     497    }
     498
     499      FilePath supportPath(this->destinationPath->pathString(), "support.html");
     500      if (!this->progman->addIcon(groupName, "Technical Support", supportPath.pathString(), ""))
     501    {
     502    }
     503
     504      // TODO: uninstall icon
     505      // FilePath uninstallPath(this->destinationPath->pathString(), "gssetup.exe");
     506     
     507      // disconnect from program manager
     508      this->progman->disconnect();
     509    }
    478510  return true;
    479511}
     
    486518 */
    487519bool GSInstall::updateProfiles()
    488 { FilePath *exePath;
    489     FilePath *dataPath;
     520{
     521  FilePath *exePath;
     522  FilePath *dataPath;
    490523  FilePath *iniPath;
    491524
     
    493526  // folder of this installation sequence;  if not, then we pick it up from
    494527  // the existing location of that folder
    495     if (this->installExe)
    496     {   exePath = this->destinationPath;
    497   }
     528  if (this->installExe)
     529    {
     530      exePath = this->destinationPath;
     531    }
    498532  else
    499     {   exePath = this->collectPath;
    500   }
    501   iniPath   = new FilePath(exePath->pathString(), "gsdl.ini");
     533    {
     534      exePath = this->collectPath;
     535    }
     536  iniPath = new FilePath(exePath->pathString(), "gsdl.ini");
    502537
    503538  // TODO: check if this 'if' structure is correct; suspect that it isn't quite
     
    507542  //       This all needs investigating
    508543  if (this->installVolume)
    509   { // Manufacture the appropriate section name now; an equivalent string
    510     // is also constructed
    511     string volumeSectionString = this->configFile->getString("CollectionName") +
    512                                                              "#" + this->configFile->getString("CollectionVolume");
    513 
    514     // if we're installing the full data for the collection, then take the
    515     // data path to be at the selected destination directory for the collection
    516     // files; otherwise take the data path to be on the CD/distribution media
    517     if (this->installFullVolume)
    518     {   dataPath    =   this->dataDestPath;
    519     }
    520     else
    521     {   dataPath    = this->gsdlSourcePath;
    522     }
    523 
    524     // create a profile object to write to the gsdl.ini file
    525     gsProfile gsdlProfile(*this, iniPath->pathString());
    526 
    527     // if installing the executable, add the database and greenstone home
    528     // directories
    529     if (this->installExe)
    530     {   // set the correct exe entries in gsdl.ini (in the gsdl section)
    531             gsdlProfile.writeString("gsdl", "gsdlhome", dataPath->pathString());
    532       gsdlProfile.writeString("gsdl", "gdbmhome", this->dataDestPath->pathString());
    533     }
    534 
    535     // set the correct collection volume entries in gsdl.ini
    536     if (this->installVolume)
    537     { // note the collection in the general gsdl section; and add the undo item too
    538         gsdlProfile.ensureListMember("gsdl", gsdl_COLLIST, volumeSectionString);
    539 
    540       // note the volume data in its own section
    541         gsdlProfile.writeString(volumeSectionString, "gsdlhome", dataPath->pathString());
    542         gsdlProfile.writeString(volumeSectionString, "gdbmhome", this->dataDestPath->pathString());
    543         gsdlProfile.writeString(volumeSectionString, "staticpath", dataPath->pathString());
    544     }
    545   }
    546 
     544    {
     545      // Manufacture the appropriate section name now; an equivalent string
     546      // is also constructed
     547      string volumeSectionString = this->configFile->getString("CollectionName") +
     548    "#" + this->configFile->getString("CollectionVolume");
     549
     550      // if we're installing the full data for the collection, then take the
     551      // data path to be at the selected destination directory for the collection
     552      // files; otherwise take the data path to be on the CD/distribution media
     553      if (this->installFullVolume)
     554    {
     555      dataPath = this->dataDestPath;
     556    }
     557      else
     558    {
     559      dataPath = this->gsdlSourcePath;
     560    }
     561
     562      // create a profile object to write to the gsdl.ini file
     563      gsProfile gsdlProfile(*this, iniPath->pathString());
     564
     565      // if installing the executable, add the database and greenstone home
     566      // directories
     567      if (this->installExe)
     568    {
     569      // set the correct exe entries in gsdl.ini (in the gsdl section)
     570      gsdlProfile.writeString("gsdl", "gsdlhome", dataPath->pathString());
     571      gsdlProfile.writeString("gsdl", "gdbmhome", this->dataDestPath->pathString());
     572    }
     573
     574      // set the correct collection volume entries in gsdl.ini
     575      if (this->installVolume)
     576    {
     577      // note the collection in the general gsdl section; and add the undo item too
     578      gsdlProfile.ensureListMember("gsdl", gsdl_COLLIST, volumeSectionString);
     579
     580      // note the volume data in its own section
     581      gsdlProfile.writeString(volumeSectionString, "gsdlhome", dataPath->pathString());
     582      gsdlProfile.writeString(volumeSectionString, "gdbmhome", this->dataDestPath->pathString());
     583      gsdlProfile.writeString(volumeSectionString, "staticpath", dataPath->pathString());
     584    }
     585    }
     586 
    547587  // clean up
    548588  delete iniPath;
    549 
     589 
    550590  return true;
    551591}
     
    556596 */
    557597bool GSInstall::updateSetupExe()
    558 { FilePath *destExePath;
     598{
     599  FilePath *destExePath;
    559600  FilePath srcExeFile(*this->sourcePath, "gssetup.exe");
    560601
    561     if (this->installExe)
    562     {   destExePath = this->destinationPath;
    563   }
     602  if (this->installExe)
     603    {
     604      destExePath = this->destinationPath;
     605    }
    564606  else
    565     {   destExePath = this->collectPath;
    566   }
    567     FilePath destExeFile(*destExePath, "gssetup.exe");
     607    {
     608      destExePath = this->collectPath;
     609    }
     610  FilePath destExeFile(*destExePath, "gssetup.exe");
    568611
    569612  if (!CopyFile(srcExeFile.cString(), destExeFile.cString(), false))
    570   { return false;
    571   }
     613    {
     614      return false;
     615    }
    572616  return true;
    573617}
    574618
    575619bool GSInstall::installNetscape()
    576 {   FilePath    netscape32Path(this->sourcePath->pathString(), "netscape\\n32e405.exe");
    577   FilePath  netscape16Path(this->sourcePath->pathString(), "netscape\\n16e405.exe");
     620{
     621  FilePath netscape32Path(this->sourcePath->pathString(), "netscape\\n32e405.exe");
     622  FilePath netscape16Path(this->sourcePath->pathString(), "netscape\\n16e405.exe");
    578623
    579624  launchApp launchNetscape(netscape32Path);
    580625  launchNetscape.platformApp(gsPlatform_WINDOWS32S, netscape16Path);
    581626  if (launchNetscape.run(true, 1,
    582                                                 "This library is displayed using a web browser.  If you don't "
    583                               "currently have a web browser installed on your machine you may "
    584                               "install the Netscape 4.05 browser now.\n\n"
    585                               "Note that if your current browser was provided by your internet "
    586                               "service provider, you should install Netscape in a different "
    587                               "directory.\n\n"
    588                               "Would you like to install the Netscape 4.05 browser now?",
    589                               "Greenstone Installer", false) < 0)
    590   { MessageBox(0, "Error", app_name, MB_OK);
    591     return false;
    592   }
     627             "This library is displayed using a web browser.  If you don't "
     628             "currently have a web browser installed on your machine you may "
     629             "install the Netscape 4.05 browser now.\n\n"
     630             "Note that if your current browser was provided by your internet "
     631             "service provider, you should install Netscape in a different "
     632             "directory.\n\n"
     633             "Would you like to install the Netscape 4.05 browser now?",
     634             "Greenstone Installer", false) < 0)
     635    {
     636      MessageBox(0, "Error", app_name, MB_OK);
     637      return false;
     638    }
    593639  return true;
    594640}
    595641
    596642FilePath *GSInstall::collectionPath()
    597 {   return this->collectPath;
     643{
     644  return this->collectPath;
    598645}
    599646
    600647FilePath *GSInstall::installPath()
    601 {   return this->installToPath;
     648{
     649  return this->installToPath;
    602650}
    603651
    604652void GSInstall::addSelectedDir(dirSelector *selector)
    605 {   this->selectedDirs.push_back(selector);
     653{
     654  this->selectedDirs.push_back(selector);
    606655}
    607656
    608657typedef struct
    609 { dirSelector * dirSelect;
     658{
     659  dirSelector * dirSelect;
    610660} GSInstall_dirPathData;
    611661
    612662HGLOBAL loadDirBrowser()
    613 { HRSRC resHdl;
    614 
    615     resHdl = FindResource(app_instance, "MySaveAsDlg", RT_DIALOG);
     663{
     664  HRSRC resHdl;
     665
     666  resHdl = FindResource(app_instance, "MySaveAsDlg", RT_DIALOG);
    616667  return LoadResource(app_instance, resHdl);
    617668}
     
    622673  int sx, sy;
    623674  int dx, dy;
    624 
     675 
    625676  gsInstall_getDesktopExt(&sx, &sy);
    626677  GetWindowRect(dialog, &rect);
     
    632683
    633684BOOL FAR PASCAL GSInstall_dlgproc(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
    634 { static bool first = true;     // static variable to hack the position of the
     685{
     686  static bool first = true;   // static variable to hack the position of the
    635687                              // whole wizard; note doing this in the wizard
    636688                              // property sheet initialisation DOES NOT WORK
    637689
    638     switch (Message)
    639     {   case WM_INITDIALOG:
    640     {   dirSelector *selector = (dirSelector *) ((PROPSHEETPAGE *) lParam)->lParam;
     690  switch (Message)
     691    {
     692    case WM_INITDIALOG:
     693      {
     694    dirSelector *selector = (dirSelector *) ((PROPSHEETPAGE *) lParam)->lParam;
    641695
    642696        SetDlgItemText(Dialog, dirpath_PROMPT, selector->prompt);
    643       if (selector->optPrompt != NULL)
    644       { SetDlgItemText(Dialog, dirpath_OPTION, selector->optPrompt);
    645           EnableWindow(GetDlgItem(Dialog, dirpath_BROWSE), true); // was false
    646         EnableWindow(GetDlgItem(Dialog, dirpath_PATH), true);       // was false
     697    if (selector->optPrompt != NULL)
     698      {
     699        SetDlgItemText(Dialog, dirpath_OPTION, selector->optPrompt);
     700        EnableWindow(GetDlgItem(Dialog, dirpath_BROWSE), true); // was false
     701        EnableWindow(GetDlgItem(Dialog, dirpath_PATH), true); // was false
     702      }
     703    else
     704      {
     705        ShowWindow(GetDlgItem(Dialog, dirpath_OPTION), SW_HIDE);
     706      }
     707    SetWindowLong(Dialog, GWL_USERDATA, ((PROPSHEETPAGE *) lParam)->lParam);
     708    SetDlgItemText(Dialog, dirpath_PATH, selector->selectedPath());
     709   
     710    // if this is the first time this function is called, then centre the
     711    // wizard into the centre of our screen.
     712    if (first)
     713      {
     714        gsInstall_wizard_centre(GetParent(Dialog));
     715        first = false;
     716      }
    647717      }
    648       else
    649       { ShowWindow(GetDlgItem(Dialog, dirpath_OPTION), SW_HIDE);
    650       }
    651       SetWindowLong(Dialog, GWL_USERDATA, ((PROPSHEETPAGE *) lParam)->lParam);
    652       SetDlgItemText(Dialog, dirpath_PATH, selector->selectedPath());
    653 
    654       // if this is the first time this function is called, then centre the
    655       // wizard into the centre of our screen.
    656       if (first)
    657       { gsInstall_wizard_centre(GetParent(Dialog));
    658         first = false;
    659       }
    660     }
    661     return TRUE;
    662 
     718      return TRUE;
     719     
    663720    case WM_COMMAND:
    664         switch (LOWORD(wParam))
    665       { case dirpath_BROWSE:
    666             ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA))->requestPath(Dialog, "Select Directory");
     721      switch (LOWORD(wParam))
     722    {
     723    case dirpath_BROWSE:
     724      ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA))->requestPath(Dialog, "Select Directory");
    667725          SetDlgItemText(Dialog, dirpath_PATH, ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA))->selectedPath());
    668         break;
     726      break;
    669727
    670728        case dirpath_OPTION:
    671             ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA))->setOption(IsDlgButtonChecked(Dialog, dirpath_OPTION));
    672             if (HIWORD(wParam) == BN_CLICKED && false) // don't do the enable/disable these days
    673           { EnableWindow(GetDlgItem(Dialog, dirpath_BROWSE), IsDlgButtonChecked(Dialog, dirpath_OPTION));
    674             EnableWindow(GetDlgItem(Dialog, dirpath_PATH), IsDlgButtonChecked(Dialog, dirpath_OPTION));
    675           }
    676         break;
    677       }
    678     break;
    679 
     729      ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA))->setOption(IsDlgButtonChecked(Dialog, dirpath_OPTION));
     730      if (HIWORD(wParam) == BN_CLICKED && false)
     731        // don't do the enable/disable these days
     732        {
     733          EnableWindow(GetDlgItem(Dialog, dirpath_BROWSE), IsDlgButtonChecked(Dialog, dirpath_OPTION));
     734          EnableWindow(GetDlgItem(Dialog, dirpath_PATH), IsDlgButtonChecked(Dialog, dirpath_OPTION));
     735        }
     736      break;
     737    }
     738      break;
     739     
    680740    case WM_NOTIFY:
    681         switch (((LPNMHDR) lParam)->code)
    682       { case PSN_SETACTIVE:
    683         {   dirSelector *selector = ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA));
    684 
    685             // bodge to set the dialogue path to the correct value
    686             if (selector != rootSelector)
    687           { selector->setPath(rootSelector->selectedPath());
    688             SetDlgItemText(Dialog, dirpath_PATH, selector->selectedPath());
    689           }
    690 
    691             if (selector->isFinal())
    692             { PropSheet_SetWizButtons(GetParent(Dialog), PSWIZB_BACK | PSWIZB_FINISH);
    693             }
    694           else
    695             { PropSheet_SetWizButtons(GetParent(Dialog), PSWIZB_BACK | PSWIZB_NEXT);
    696           }
    697         }
    698         break;
    699 
     741      switch (((LPNMHDR) lParam)->code)
     742    {
     743    case PSN_SETACTIVE:
     744      {
     745        dirSelector *selector = ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA));
     746       
     747        // bodge to set the dialogue path to the correct value
     748        if (selector != rootSelector)
     749          {
     750        selector->setPath(rootSelector->selectedPath());
     751        SetDlgItemText(Dialog, dirpath_PATH, selector->selectedPath());
     752          }
     753       
     754        if (selector->isFinal())
     755          {
     756        PropSheet_SetWizButtons(GetParent(Dialog), PSWIZB_BACK | PSWIZB_FINISH);
     757          }
     758        else
     759          {
     760        PropSheet_SetWizButtons(GetParent(Dialog), PSWIZB_BACK | PSWIZB_NEXT);
     761          }
     762      }
     763      break;
     764     
    700765        case PSN_KILLACTIVE:
    701         break;
    702 
    703                 case PSN_WIZNEXT:
    704           { // note the path from the dialog
    705             dirSelector *selector = ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA));
    706             selector->setPathFromEdit(GetDlgItem(Dialog, dirpath_PATH));
    707 
    708             // create a new FilePath object to check on the proposed destination
    709                     FilePath *path = new FilePath(selector->selectedPath());
    710 
    711           // if the proposed destination doesn't exist, ask the user whether to
    712           // create it now.  TODO: actually create it if asked!
    713           if (path->exists() == false)
    714           { char buffer[128];
    715 
     766      break;
     767     
     768    case PSN_WIZNEXT:
     769      {
     770        // note the path from the dialog
     771        dirSelector *selector = ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA));
     772        selector->setPathFromEdit(GetDlgItem(Dialog, dirpath_PATH));
     773
     774        // create a new FilePath object to check on the proposed destination
     775        FilePath *path = new FilePath(selector->selectedPath());
     776
     777        // if the proposed destination doesn't exist, ask the user whether to
     778        // create it now.  TODO: actually create it if asked!
     779        if (path->exists() == false)
     780          {
     781        char buffer[128];
     782       
    716783            sprintf(buffer, "Directory %s does not exist - create it?", selector->selectedPath());
    717784
    718             // if the user cancelled that, then don't permit them to go to the next
    719             // page of the wizard
     785        // if the user cancelled that, then don't permit them to go to the next
     786        // page of the wizard
    720787            if (MessageBox(0, buffer, app_name, MB_YESNO | MB_TOPMOST) == IDNO)
    721             {   delete path;
    722                 SetWindowLong(Dialog, DWL_MSGRESULT, TRUE);
    723               return TRUE;
    724             }
    725           }
    726           delete path;
     788          {
     789            delete path;
     790            SetWindowLong(Dialog, DWL_MSGRESULT, TRUE);
     791            return TRUE;
     792          }
    727793          }
    728         break;
    729 
     794        delete path;
     795      }
     796      break;
     797     
    730798        case PSN_WIZFINISH:
    731           { // Finish the activity now
    732             config_complete = true;
     799      {
     800        // Finish the activity now
     801        config_complete = true;
    733802          }
    734         break;
    735       }
    736     break;
    737   }
    738     return FALSE;
     803      break;
     804    }
     805      break;
     806    }
     807  return FALSE;
    739808}
    740809
    741810void GSInstall_init_propertySheet(PROPSHEETPAGE &ppage, char *prompt, char *optPrompt,
    742                                                                     char *title, GSInstall &installer, bool isFinal)
    743 { GSInstall_dirPathData *data = new GSInstall_dirPathData;
    744 
    745     // create the directory Selector
    746     data->dirSelect     = new dirSelector(prompt, optPrompt, title, installer.installPath());
     811                  char *title, GSInstall &installer, bool isFinal)
     812{
     813  GSInstall_dirPathData *data = new GSInstall_dirPathData;
     814
     815  // create the directory Selector
     816  data->dirSelect = new dirSelector(prompt, optPrompt, title, installer.installPath());
    747817  data->dirSelect->setFinal(isFinal);
    748818
    749819  // if there is no extant root selector, make this it
    750820  if (rootSelector == NULL)
    751   { rootSelector = data->dirSelect;
    752   }
     821    {
     822      rootSelector = data->dirSelect;
     823    }
    753824
    754825  // add this directory selector to the installer
     
    756827
    757828  // set up the rest of the page
    758     ppage.dwSize        = sizeof(PROPSHEETPAGE);
    759     ppage.dwFlags       = PSP_USETITLE;
    760   ppage.hInstance   = app_instance;
    761   ppage.pszTemplate = "getDirPath";
    762   ppage.pszIcon         = 0;
    763   ppage.pszTitle        = app_name;
    764   ppage.pfnDlgProc  = (DLGPROC) GSInstall_dlgproc;
    765     ppage.lParam      = (LPARAM) data->dirSelect;
    766   ppage.pfnCallback = NULL;
     829  ppage.dwSize = sizeof(PROPSHEETPAGE);
     830  ppage.dwFlags = PSP_USETITLE;
     831  ppage.hInstance = app_instance;
     832  ppage.pszTemplate = "getDirPath";
     833  ppage.pszIcon = 0;
     834  ppage.pszTitle = app_name;
     835  ppage.pfnDlgProc = (DLGPROC) GSInstall_dlgproc;
     836  ppage.lParam = (LPARAM) data->dirSelect;
     837  ppage.pfnCallback = NULL;
    767838}
    768839
    769840int CALLBACK GSInstall_wizardProc(HWND dialog, UINT Message, LPARAM lParameter)
    770 { switch (Message)
    771     { case PSCB_INITIALIZED :
    772             // Process PSCB_INITIALIZED
     841{
     842  switch (Message)
     843    {
     844    case PSCB_INITIALIZED :
     845      // Process PSCB_INITIALIZED
    773846      gsInstall_wizard_centre(dialog);
    774         break ;
    775 
    776         case PSCB_PRECREATE :
    777             // Process PSCB_PRECREATE
    778         break ;
    779 
    780         default :
    781             // Unknown message
    782         break ;
    783     }
     847      break ;
     848
     849    case PSCB_PRECREATE :
     850      // Process PSCB_PRECREATE
     851      break ;
     852
     853    default :
     854      // Unknown message
     855      break ;
     856    }
    784857  return 0;
    785858}
     
    847920
    848921    case WM_USER:
    849     {
    850       // uninstall action
    851       if (strstr(app_cmdLine, "-u") != NULL)
    852         {
    853       // skip past the -u option itself
    854       char *at = strstr(app_cmdLine, "-u");
    855       at += strlen("-u");
    856 
    857       // extract the log file path from the command line
    858       while (*at == ' ')
    859         {
    860           at ++;
    861         }
    862       string logPathString(at);
    863       FilePath logPath(logPathString);
    864 
    865       GSInstall install(true);
    866       // if we're running in the temporary directory, do the uninstall
    867       if (install.setUninstall())
    868         {
     922      {
     923    // uninstall action
     924    if (strstr(app_cmdLine, "-u") != NULL)
     925      {
     926        // skip past the -u option itself
     927        char *at = strstr(app_cmdLine, "-u");
     928        at += strlen("-u");
     929       
     930        // extract the log file path from the command line
     931        while (*at == ' ')
     932          {
     933        at ++;
     934          }
     935        string logPathString(at);
     936        FilePath logPath(logPathString);
     937       
     938        GSInstall install(true);
     939        // if we're running in the temporary directory, do the uninstall
     940        if (install.setUninstall())
     941          {
    869942          install.uninstall();
    870 
     943         
    871944          // close the log to write back all changes to the log; if the file
    872945          // will be deleted, it must be closed; copying may also fail, so it's
    873946          // safer to close it before doing either.
    874947          install.closeLog();
    875 
     948         
    876949          // if the install is empty, terminate all final items (currently the
    877950          // log and setup executables,
     
    880953          // delete the log file
    881954          DeleteFile(logPath.cString());
    882 
     955         
    883956          // get it's parent to find where the gssetup executable will be
    884957          FilePath *logParent = logPath.parent();
    885958          FilePath uninstallPath(*logParent, "gssetup.exe");
    886 
     959         
    887960          // delete the gssetup executable
    888961          DeleteFile(uninstallPath.cString());
    889 
     962         
    890963          // dispose of the parent directory information
    891964          delete logParent;
     
    896969          // do nothing - should be changed already!
    897970        }
    898         }
    899     }
    900       // install wizard
    901       else
    902     {   
    903       GSInstall install(false);
    904       GSInstall_init_wizard(install);
    905           if (config_complete == false)
    906         {
    907           MessageBox(0, "Install cancelled", app_name, MB_OK);
    908         }
    909       else
    910         {
    911           // configure the installation
    912           install.setDestination();
    913           install.setManifest();
    914 
    915           // perform installation
    916           install.copyFiles();
    917           install.updateProgman();
    918           install.updateRegistry();
    919           install.updateProfiles();
    920           install.updateSetupExe();
    921 
    922           // the log will need reopening (probably failed initially)
    923           install.reopenLog();
    924          
    925           // close log
    926           install.closeLog();
    927 
    928           // do further actions
    929           install.installNetscape();
    930         }
    931     }
    932       DestroyWindow(Window);
    933     }
    934     break;
    935    
     971          }
     972      }
     973    // install wizard
     974    else
     975      {
     976        GSInstall install(false);
     977        GSInstall_init_wizard(install);
     978        if (config_complete == false)
     979          {
     980        MessageBox(0, "Install cancelled", app_name, MB_OK);
     981          }
     982        else
     983          {
     984        // configure the installation
     985        install.setDestination();
     986        install.setManifest();
     987       
     988        // perform installation
     989        install.copyFiles();
     990        install.updateProgman();
     991        install.updateRegistry();
     992        install.updateProfiles();
     993        install.updateSetupExe();
     994       
     995        // the log will need reopening (probably failed initially)
     996        install.reopenLog();
     997       
     998        // close log
     999        install.closeLog();
     1000       
     1001        // do further actions
     1002        install.installNetscape();
     1003          }
     1004    }
     1005    DestroyWindow(Window);
     1006      }
     1007      break;
     1008     
    9361009    case WM_CLOSE:
    9371010      /*if (!file_ischanged || IDCANCEL != file_query(Window, file_name))*/
     
    9441017      }
    9451018      break;
    946 
     1019     
    9471020    default:
    9481021      return(DefWindowProc(Window, Message, wParameter, lParameter));
     
    9521025
    9531026void GSInstall_init(HINSTANCE instance, int Show)
    954 { int sx, sy;
    955 
    956     gsInstall_getDesktopExt(&sx, &sy);
    957 
    958     app_window = CreateWindow("GSInstall:Main", "GreenStone Installer",
    959                                                             WS_OVERLAPPEDWINDOW | WS_MAXIMIZE | CS_DBLCLKS,
    960                                                             0, 0,
    961                                                             sx, sy,
    962                                                             NULL,
    963                                                             NULL,
    964                                                             app_instance,
    965                                                             NULL);
    966 
    967     ShowWindow(app_window, Show);
    968 
     1027{
     1028  int sx, sy;
     1029
     1030  gsInstall_getDesktopExt(&sx, &sy);
     1031 
     1032  app_window = CreateWindow("GSInstall:Main", "GreenStone Installer",
     1033                WS_OVERLAPPEDWINDOW | WS_MAXIMIZE | CS_DBLCLKS,
     1034                0, 0,
     1035                sx, sy,
     1036                NULL,
     1037                NULL,
     1038                app_instance,
     1039                NULL);
     1040 
     1041  ShowWindow(app_window, Show);
     1042 
    9691043  PostMessage(app_window, WM_USER, 0, 0L);
    9701044}
Note: See TracChangeset for help on using the changeset viewer.