Changeset 1475 for trunk/gsinstaller/gsinstall.cpp
- Timestamp:
- 2000-08-31T00:42:59+12:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsinstaller/gsinstall.cpp
r1397 r1475 29 29 30 30 bool config_complete = false; 31 // static char app_tmptext[100] = "George";32 31 33 32 typedef vector<dirSelector *> dirSelVector; 34 33 35 class GSInstall 34 class GSInstall : public installManager 36 35 { private: 37 configureFile * configFile; 38 FilePath * collectPath; 39 FilePath * installToPath; 40 FilePath * sourcePath; 41 FilePath * gsdlSourcePath; 42 FilePath * destinationPath; 43 FilePath * dataDestPath; 36 configureFile * configFile; // the installation configure file 37 38 FilePath * collectPath; // where the collection is currently installed 39 FilePath * installToPath; // the first cut at a destination folder 40 FilePath * sourcePath; // the root source folder 41 FilePath * gsdlSourcePath; // the gsdl folder in the source area 42 FilePath * destinationPath; // where the executables will be installed to 43 FilePath * dataDestPath; // where the collection data files will go 44 45 bool installVolume; // whether to install collection data 46 bool installFullVolume;// whether to install all collection data 47 48 dirSelVector selectedDirs; // configuration objects 49 50 gsPlatform platform; // platform information 51 gsRegistry * gsRegister; // registry 52 gsManifest * manifest; // manifest of files 53 gsProgramManager * progman; // program manager connection 54 55 void getSourcePath(); 56 void getExistingInstall(); 57 public: 44 58 bool installExe; 45 bool installVolume; 46 bool installFullVolume; 47 gsPlatform platform; 48 unInstaller * unInstall; 49 50 dirSelVector selectedDirs; 51 52 gsRegistry * gsRegister; 53 gsManifest * manifest; 54 55 void getSourcePath(); 56 public: 57 GSInstall(); 59 60 GSInstall(bool uninstall); 58 61 FilePath * collectionPath(); 59 62 FilePath * installPath(); … … 64 67 bool installNetscape(); 65 68 void setDestination(); 69 void setUninstall(); 70 void uninstall(); 66 71 void setManifest(); 67 72 void addSelectedDir(dirSelector *selector); … … 87 92 * THe source path is also discovered. 88 93 */ 89 GSInstall::GSInstall() 90 { gsPlatform platform; 91 92 // get the installation configuration file 94 GSInstall::GSInstall(bool uninstall) 95 : installManager() 96 { // get the installation configuration file 93 97 this->configFile = new configureFile("install.cfg"); 94 98 95 // initialise the pointers that we test later this fn. 96 this->unInstall = NULL; 99 // set up "default" installation bits 100 this->installToPath = new FilePath("C:\\GSDL"); 101 this->collectPath = NULL; 102 this->installExe = true; // we must install the exe files 97 103 98 104 // don't attempt this with windows 3.1 99 if (! platform.isWindows32s() || TRUE)105 if (!this->platform.isWindows32s()) 100 106 { // get the registry 101 this->gsRegister = new gsRegistry(*this->configFile); 102 103 // TODO: in windows 3.1 we can't use the register as it isn't fully/properly 107 this->gsRegister = new gsRegistry(*this, *this->configFile); 108 } 109 else 110 { // TODO: in windows 3.1 we can't use the register as it isn't fully/properly 104 111 // implemented; we must get the existing path information from elsewhere 105 if (gsRegister->collectionInstalled()) 106 { // TODO: check if receptionist etc should be replaced or not 107 108 // TODO: check build version of the volume 109 110 // Get location of the library executable from the registry; this 111 // is thence used to get the location of gsdl.ini etc. 112 this->collectPath = this->gsRegister->collectionPath(); 113 this->installToPath = this->collectPath; 114 115 // TODO: if collectPath == NULL generate error 116 117 // get uninstall information from destination location 118 FilePath *uninstallPath = new FilePath(this->collectPath->cString(), "uninstl.cfg"); 119 this->unInstall = new unInstaller(uninstallPath->cString()); 120 delete uninstallPath; 121 122 // we don't need to install the exe files 123 this->installExe = false||true; 124 } 125 else 126 { this->installToPath = new FilePath("C:\\GSDL"); 127 this->collectPath = NULL; 128 // we must install the exe files 129 this->installExe = true; 130 } 131 } 132 else 133 { // TODO: do windows 3.1 stuff here 134 this->installToPath = new FilePath("C:\\GSDL"); 135 this->installExe = true; 136 this->collectPath = NULL; 137 } 138 139 if (this->unInstall == NULL) 140 { this->unInstall = new unInstaller(""); 112 this->gsRegister = new gsRegistry(*this, *this->configFile); 141 113 } 142 114 … … 145 117 this->installFullVolume = true; 146 118 119 // detect any existing installation; unnecessary in uninstall (it's the 120 // "source" directory - see later 121 if (uninstall == false) 122 { this->getExistingInstall(); 123 } 124 147 125 // get where we are installing from 148 126 this->getSourcePath(); 149 127 150 // get the manifest 151 this->manifest = new gsManifest(*this->sourcePath); 128 // if doing an uninstall we now know where the "uninstall" is 129 if (uninstall == true) 130 { this->collectPath = this->sourcePath; 131 } 132 133 // get the manifest and program manager objects 134 if (uninstall) 135 { this->manifest = new gsManifest(*this); 136 } 137 else 138 { this->manifest = new gsManifest(*this, *this->sourcePath); 139 } 140 this->progman = new gsProgramManager(*this); 152 141 153 142 // tell manifest the number of bits in the raw windows environment; this may … … 165 154 } 166 155 */ 167 // inform manifests of collection directory name 168 char *buffer; 169 this->configFile->get("CollectionDirName", &buffer); 170 this->manifest->expandMacro("COLDIRNAME", buffer); 171 delete buffer; 156 // inform manifest of collection directory name 157 string colDir; 158 colDir = this->configFile->getString("CollectionDirName"); 159 if (colDir != "") 160 { this->manifest->expandMacro("COLDIRNAME", colDir); 161 } 162 } 163 164 /** 165 * Detect the presence of an existing installation 166 */ 167 void GSInstall::getExistingInstall() 168 { if (!this->platform.isWindows32s()) 169 { if (gsRegister->collectionInstalled()) 170 { // TODO: check if receptionist etc should be replaced or not 171 172 // TODO: check build version of the volume 173 174 // Get location of the library executable from the registry; this 175 // is thence used to get the location of gsdl.ini etc. 176 this->collectPath = this->gsRegister->collectionPath(); 177 if (this->collectPath != "") 178 { this->installToPath = this->collectPath; 179 180 // we don't need to install the exe files 181 this->installExe = false; 182 } 183 } 184 } 172 185 } 173 186 … … 189 202 190 203 // get the gsdl source path 191 this->gsdlSourcePath = new FilePath(this->sourcePath-> cString(), "gsdl");204 this->gsdlSourcePath = new FilePath(this->sourcePath->pathString(), "gsdl"); 192 205 delete exePath; 193 206 } … … 199 212 */ 200 213 bool GSInstall::copyFiles() 201 { FileVector *fileList; 202 203 // ensure that we have got the required destination and that we can write there 214 { // ensure that we have got the required destination and that we can write there 204 215 if (this->installExe) 205 216 { this->destinationPath->ensureWriteablePath(); … … 232 243 // now move on to add key items 233 244 if (this->installExe) 234 { FilePath *serverPath = new FilePath((char *) this->destinationPath->cString(), "server.exe"); 235 char *exeKeyPath; 245 { FilePath *serverPath = new FilePath(this->destinationPath->pathString(), "server.exe"); 246 FilePath *setupPath = new FilePath(this->destinationPath->pathString(), "gssetup.exe"); 247 FilePath *logPath = new FilePath(this->destinationPath->pathString(), "install.log"); 248 string exeKeyPath, uninstallCmd, uninstallKeyPath; 236 249 gsPlatform platform; 237 250 … … 240 253 this->gsRegister->collectKeyId(), 241 254 "library", 242 serverPath-> cString());255 serverPath->pathString()); 243 256 244 257 // This test is in fact for 9x or NT 4+; we're worried about the registry … … 254 267 this->gsRegister->storeKeyString( HKEY_LOCAL_MACHINE, 255 268 exeKeyPath, 256 NULL,257 serverPath-> cString());269 "", 270 serverPath->pathString()); 258 271 259 272 // store path for this application … … 261 274 exeKeyPath, 262 275 "path", 263 this->destinationPath->cString()); 264 // delete the windows 9x speciall app path key 265 delete exeKeyPath; 266 267 // TODO: set up uninstall option 276 this->destinationPath->pathString()); 277 278 // create uninstall command line 279 uninstallCmd = setupPath->pathString() + " -u " + logPath->pathString(); 280 uninstallKeyPath = this->gsRegister->uninstallKeyId(this->configFile->getString("CollectionName")); 281 282 // ensure uninstall key exists 283 this->gsRegister->ensureKeyExists(HKEY_LOCAL_MACHINE, uninstallKeyPath); 284 285 this->gsRegister->storeKeyString(HKEY_LOCAL_MACHINE, uninstallKeyPath, 286 "DisplayName", 287 this->configFile->getString("CollectionName")); 288 this->gsRegister->storeKeyString(HKEY_LOCAL_MACHINE, uninstallKeyPath, 289 "UninstallString", uninstallCmd); 268 290 } 291 delete setupPath; 269 292 delete serverPath; 293 delete logPath; 270 294 } 271 295 … … 280 304 */ 281 305 void GSInstall::setDestination() 282 { this->destinationPath = new FilePath(this->selectedDirs[0]->selectedPath()); 306 { // get configuration from the install wizard pages 307 this->destinationPath = new FilePath(this->selectedDirs[0]->selectedPath()); 283 308 this->installFullVolume = this->selectedDirs[1]->getOption(); 284 309 if (this->installFullVolume || true) // NB: always take path from 2nd dialog … … 287 312 else 288 313 { this->dataDestPath = this->destinationPath; 314 } 315 316 // open the log for writing 317 FilePath *logPath = new FilePath(this->destinationPath->pathString(), "install.log"); 318 this->openLog(logPath->pathString(), true); 319 delete logPath; 320 } 321 322 void GSInstall::setUninstall() 323 { 324 // open the log for reading 325 FilePath *logPath = new FilePath(this->collectPath->pathString(), "install.log"); 326 this->openLog(logPath->pathString(), false); 327 delete logPath; 328 } 329 330 void GSInstall::uninstall() 331 { FilePath *iniPath; 332 string command; 333 stringArray params; 334 335 this->manifest = new gsManifest(*this); // get a manifest manager 336 337 iniPath = new FilePath(this->collectPath->pathString(), "gsdl.ini"); 338 gsProfile gsdlProfile(*this, iniPath->pathString()); 339 340 while ((command = this->readCommand(params)) != "") 341 { if (!this->manifest->undoAction(command, params)) 342 { if (!gsdlProfile.undoAction(command, params)) 343 { if (!this->gsRegister->undoAction(command, params)) 344 { if (!this->progman->undoAction(command, params)) 345 { 346 } 347 } 348 } 349 } 289 350 } 290 351 } … … 295 356 void GSInstall::setManifest() 296 357 { if (this->installExe) 297 { this->manifest->selectGroup("library", this->destinationPath->pathString());358 { this->manifest->selectGroup("library", *this->destinationPath); 298 359 } 299 360 if (this->installFullVolume) 300 { this->manifest->selectGroup("collection", this->dataDestPath->pathString());361 { this->manifest->selectGroup("collection", *this->dataDestPath); 301 362 } 302 363 else 303 { this->manifest->selectGroup("database", this->dataDestPath->pathString());364 { this->manifest->selectGroup("database", *this->dataDestPath); 304 365 } 305 366 } … … 310 371 */ 311 372 bool GSInstall::updateProgman() 312 { gsProgramManager progman; 313 char * groupName = NULL; 373 { string groupName; 314 374 315 375 // if we managed to get a connection to the program manager (or explorer 316 376 // shell) then do the requisite updates 317 if ( progman.connect())377 if (this->progman->connect()) 318 378 { // get group name from folders 319 this->configFile->get("ProgramGroupName", &groupName);320 if (groupName == NULL)379 groupName = this->configFile->getString("ProgramGroupName"); 380 if (groupName == "") 321 381 { // TODO: error handling 322 progman.disconnect(); 323 delete groupName; 382 this->progman->disconnect(); 324 383 return false; 325 384 } 326 385 327 386 // add the group 328 if (!progman.addProgramGroup(groupName)) 329 { progman.disconnect(); 330 delete groupName; 387 if (!this->progman->addProgramGroup(groupName)) 388 { this->progman->disconnect(); 331 389 return false; 332 390 } 333 391 334 392 // add a "server" icon 335 FilePath libraryPath(this->destinationPath->cString(), "library.exe"); 336 if (!progman.addIcon(groupName, "Library (without nextwork support)", libraryPath.cString(), "")) 337 { progman.disconnect(); 338 delete groupName; 339 return false; 393 FilePath libraryPath(this->destinationPath->pathString(), "library.exe"); 394 if (!this->progman->addIcon(groupName, "Library (without nextwork support)", libraryPath.pathString(), "")) 395 { // assume that it may be there already 340 396 } 341 397 342 // TODO:check for server existence343 FilePath serverPath(this->destinationPath-> cString(), "server.exe");344 if (!progman.addIcon(groupName, "Server", serverPath.cString(), ""))345 { progman.disconnect();346 delete groupName; 347 return false;398 // check for server existence 399 FilePath serverPath(this->destinationPath->pathString(), "server.exe"); 400 if (serverPath.exists()) 401 { if (!this->progman->addIcon(groupName, "Server", serverPath.pathString(), "")) 402 { // assume that it may be there already 403 } 348 404 } 349 405 350 FilePath readMePath(this->destinationPath->cString(), "readme.txt"); 351 if (!progman.addIcon(groupName, "ReadMe", readMePath.cString(), "")) 352 { progman.disconnect(); 353 delete groupName; 354 return false; 406 FilePath readMePath(this->destinationPath->pathString(), "readme.txt"); 407 if (!this->progman->addIcon(groupName, "ReadMe", readMePath.pathString(), "")) 408 { 355 409 } 356 410 357 FilePath supportPath(this->destinationPath->cString(), "support.html"); 358 if (!progman.addIcon(groupName, "Technical Support", supportPath.cString(), "")) 359 { progman.disconnect(); 360 delete groupName; 361 return false; 411 FilePath supportPath(this->destinationPath->pathString(), "support.html"); 412 if (!this->progman->addIcon(groupName, "Technical Support", supportPath.pathString(), "")) 413 { 362 414 } 363 415 364 // TODO: add uninstall support 365 366 // dispose of group name 367 delete groupName; 416 // TODO: uninstall icon 417 // FilePath uninstallPath(this->destinationPath->pathString(), "gssetup.exe"); 368 418 369 419 // disconnect from program manager 370 progman.disconnect();420 this->progman->disconnect(); 371 421 } 372 422 return true; … … 393 443 { exePath = this->collectPath; 394 444 } 395 iniPath = new FilePath( (char *) exePath->cString(), "gsdl.ini");445 iniPath = new FilePath(exePath->pathString(), "gsdl.ini"); 396 446 397 447 // TODO: check if this 'if' structure is correct; suspect that it isn't quite … … 401 451 // This all needs investigating 402 452 if (this->installVolume) 403 { char volumeSectionName[100] = "\0"; 404 unsigned int space = 99; 405 406 // Manufacture the appropriate section name now; an equivalent string 453 { // Manufacture the appropriate section name now; an equivalent string 407 454 // is also constructed 408 this->configFile->concat("CollectionName", volumeSectionName, space); 409 strcat(volumeSectionName, "#"); 410 space --; 411 this->configFile->concat("CollectionVolume", volumeSectionName, space); 412 string volumeSectionString(volumeSectionName); 455 string volumeSectionString = this->configFile->getString("CollectionName") + 456 "#" + this->configFile->getString("CollectionVolume"); 413 457 414 458 // if we're installing the full data for the collection, then take the … … 423 467 424 468 // create a profile object to write to the gsdl.ini file 425 gsProfile gsdlProfile( iniPath->cString());469 gsProfile gsdlProfile(*this, iniPath->pathString()); 426 470 427 471 // if installing the executable, add the database and greenstone home … … 429 473 if (this->installExe) 430 474 { // set the correct exe entries in gsdl.ini (in the gsdl section) 431 gsdlProfile.writeString("gsdl", "gsdlhome", dataPath->cString()); 432 gsdlProfile.writeString("gsdl", "gdbmhome", this->dataDestPath->cString()); 433 434 this->unInstall->record("gsdl", "profilewrite", 2, &gsdl_VLHOME, 435 &dataPath->pathString()); 436 this->unInstall->record("gsdl", "profilewrite", 2, &gsdl_DBHOME, 437 &this->dataDestPath->pathString()); 475 gsdlProfile.writeString("gsdl", "gsdlhome", dataPath->pathString()); 476 gsdlProfile.writeString("gsdl", "gdbmhome", this->dataDestPath->pathString()); 438 477 } 439 478 … … 441 480 if (this->installVolume) 442 481 { // note the collection in the general gsdl section; and add the undo item too 443 gsdlProfile.ensureListMember("gsdl", gsdl_COLLIST.c_str(), volumeSectionName); 444 this->unInstall->record("gsdl", "proflistensure", 2, &gsdl_COLLIST, &volumeSectionString); 482 gsdlProfile.ensureListMember("gsdl", gsdl_COLLIST, volumeSectionString); 445 483 446 484 // note the volume data in its own section 447 gsdlProfile.writeString(volumeSectionName, "gsdlhome", dataPath->cString()); 448 gsdlProfile.writeString(volumeSectionName, "gdbmhome", this->dataDestPath->cString()); 449 gsdlProfile.writeString(volumeSectionName, "staticpath", dataPath->cString()); 450 451 this->unInstall->record(volumeSectionName, "profilewrite", 2, &gsdl_VLHOME, &dataPath->pathString()); 452 this->unInstall->record(volumeSectionName, "profilewrite", 2, &gsdl_DBHOME, &this->dataDestPath->pathString()); 453 this->unInstall->record(volumeSectionName, "profilewrite", 2, &gsdl_STATIC, &dataPath->pathString()); 485 gsdlProfile.writeString(volumeSectionString, "gsdlhome", dataPath->pathString()); 486 gsdlProfile.writeString(volumeSectionString, "gdbmhome", this->dataDestPath->pathString()); 487 gsdlProfile.writeString(volumeSectionString, "staticpath", dataPath->pathString()); 454 488 } 455 489 } … … 462 496 463 497 bool GSInstall::installNetscape() 464 { FilePath netscape32Path(this->sourcePath-> cString(), "netscape\\n32e405.exe");465 FilePath netscape16Path(this->sourcePath-> cString(), "netscape\\n16e405.exe");498 { FilePath netscape32Path(this->sourcePath->pathString(), "netscape\\n32e405.exe"); 499 FilePath netscape16Path(this->sourcePath->pathString(), "netscape\\n16e405.exe"); 466 500 467 501 launchApp launchNetscape(netscape32Path); … … 580 614 581 615 case PSN_KILLACTIVE: 582 { // note the path from the dialog 616 break; 617 618 case PSN_WIZNEXT: 619 { // note the path from the dialog 583 620 dirSelector *selector = ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA)); 584 621 selector->setPathFromEdit(GetDlgItem(Dialog, dirpath_PATH)); … … 586 623 // create a new FilePath object to check on the proposed destination 587 624 FilePath *path = new FilePath(selector->selectedPath()); 625 626 // if the proposed destination doesn't exist, ask the user whether to 627 // create it now. TODO: actually create it if asked! 588 628 if (path->exists() == false) 589 629 { char buffer[128]; … … 600 640 } 601 641 delete path; 602 }603 break;604 605 case PSN_WIZNEXT:606 { if (((LPNMHDR) lParam)->idFrom == 0)607 { // TODO: note a default here608 }609 642 } 610 643 break; … … 673 706 pshead.nPages = 2; 674 707 pshead.nStartPage = 0; 675 pshead.ppsp = ppage; 708 if (install.installExe == true) 709 { pshead.ppsp = ppage; 710 } 711 else // cheat as the executable etc. is already installed 712 { pshead.ppsp = &ppage[1]; 713 } 676 714 pshead.pfnCallback = GSInstall_wizardProc; 677 715 … … 705 743 switch(Message) 706 744 { case WM_CREATE: 707 { 745 { ShowWindow(Window, SW_MAXIMIZE); 708 746 } 709 747 break; … … 713 751 714 752 case WM_USER: 715 { //dirSelector selector("Choose a Greenstone directory", "Select directory"); 716 717 //selector.requestPath(Window, "Select directory"); 718 GSInstall install; 719 GSInstall_init_wizard(install); 720 if (config_complete == false) 721 { MessageBox(0, "Install cancelled", app_name, MB_OK); 722 } 753 { // uninstall action 754 if (strstr(app_cmdLine, "-u") != NULL || true) 755 { char *at = strstr(app_cmdLine, "-u"); 756 at += strlen("-u") + 1; 757 758 GSInstall install(true); 759 install.setUninstall(); 760 install.uninstall(); 761 } 762 // install wizard 723 763 else 724 { install.setDestination(); 725 install.setManifest(); 726 install.copyFiles(); 727 install.updateProgman(); 728 install.updateRegistry(); 729 install.updateProfiles(); 730 install.installNetscape(); 764 { GSInstall install(false); 765 GSInstall_init_wizard(install); 766 if (config_complete == false) 767 { MessageBox(0, "Install cancelled", app_name, MB_OK); 768 } 769 else 770 { // configure the installation 771 install.setDestination(); 772 install.setManifest(); 773 774 // perform installation 775 install.copyFiles(); 776 install.updateProgman(); 777 install.updateRegistry(); 778 install.updateProfiles(); 779 780 // do further actions 781 install.installNetscape(); 782 } 731 783 } 732 784 DestroyWindow(Window);
Note:
See TracChangeset
for help on using the changeset viewer.