Changeset 1543 for trunk/gsinstaller/gsinstall.cpp
- Timestamp:
- 2000-09-13T15:31:38+12:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsinstaller/gsinstall.cpp
r1541 r1543 213 213 */ 214 214 void GSInstall::getSourcePath() 215 { static char filename[512]; 216 FilePath *exePath; 215 { 216 static char filename[512]; 217 FilePath *exePath; 217 218 218 219 // get the filepath of this executable 219 220 GetModuleFileName(0, filename, 512); 220 exePath 221 exePath = new FilePath(filename); 221 222 222 223 // get the parent (i.e. the folder containing this executable) for the source 223 224 // folder 224 this->sourcePath 225 this->sourcePath = exePath->parent(); 225 226 226 227 // get the gsdl source path 227 this->gsdlSourcePath 228 this->gsdlSourcePath = new FilePath(this->sourcePath->pathString(), "gsdl"); 228 229 delete exePath; 229 230 } … … 235 236 */ 236 237 bool 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 238 240 if (this->installExe) 239 { this->destinationPath->ensureWriteablePath(); 240 } 241 { 242 this->destinationPath->ensureWriteablePath(); 243 } 241 244 242 245 // ensure that the destination path for the collection itself is available 243 246 if (this->installVolume) 244 { this->dataDestPath->ensureWriteablePath(); 245 } 247 { 248 this->dataDestPath->ensureWriteablePath(); 249 } 246 250 247 251 // do the copy 248 252 this->manifest->copy(this->gsdlSourcePath); 249 253 250 254 return true; … … 256 260 */ 257 261 bool 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 } 262 268 263 269 // ensure all pertinent keys already exist for this volume/collection 264 270 this->gsRegister->ensureKeysExist(); 265 271 266 272 // 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 } 318 327 319 328 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 } 322 332 return true; 323 333 } … … 327 337 */ 328 338 void 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(); 332 343 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 } 335 347 else 336 { this->dataDestPath = this->destinationPath; 337 } 348 { 349 this->dataDestPath = this->destinationPath; 350 } 338 351 339 352 // open the log for writing … … 344 357 345 358 bool GSInstall::setUninstall() 346 { char tempPathStr[MAX_PATH]; 359 { 360 char tempPathStr[MAX_PATH]; 347 361 348 362 // if we failed to get the Windows temporary directory, abort 349 363 if (GetTempPath(MAX_PATH, tempPathStr) == 0) 350 { // TODO: abort! 351 return false; 352 } 364 { 365 // TODO: abort! 366 return false; 367 } 353 368 354 369 FilePath tempPath(tempPathStr); … … 357 372 // and the installation log to the temporary directory and run them there 358 373 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 } 376 392 377 393 // open the log for reading from the directory this exe is now in (which … … 380 396 this->openLog(logPath->pathString(), false); 381 397 delete logPath; 382 398 383 399 return true; 384 400 } 385 401 386 402 void GSInstall::uninstall() 387 { FilePath *iniPath; 388 string command; 403 { 404 FilePath *iniPath; 405 string command; 389 406 stringArray params; 390 407 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 } 407 428 } 408 429 … … 411 432 */ 412 433 void 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 } 416 439 if (this->installFullVolume) 417 { this->manifest->selectGroup("collection", *this->dataDestPath); 418 } 440 { 441 this->manifest->selectGroup("collection", *this->dataDestPath); 442 } 419 443 else 420 { this->manifest->selectGroup("database", *this->dataDestPath); 421 } 444 { 445 this->manifest->selectGroup("database", *this->dataDestPath); 446 } 422 447 } 423 448 … … 427 452 */ 428 453 bool GSInstall::updateProgman() 429 { string groupName; 454 { 455 string groupName; 430 456 431 457 // if we managed to get a connection to the program manager (or explorer 432 458 // shell) then do the requisite updates 433 459 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; 446 475 } 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(), "")) 464 480 { 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(), "")) 469 496 { 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 } 478 510 return true; 479 511 } … … 486 518 */ 487 519 bool GSInstall::updateProfiles() 488 { FilePath *exePath; 489 FilePath *dataPath; 520 { 521 FilePath *exePath; 522 FilePath *dataPath; 490 523 FilePath *iniPath; 491 524 … … 493 526 // folder of this installation sequence; if not, then we pick it up from 494 527 // 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 } 498 532 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"); 502 537 503 538 // TODO: check if this 'if' structure is correct; suspect that it isn't quite … … 507 542 // This all needs investigating 508 543 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 547 587 // clean up 548 588 delete iniPath; 549 589 550 590 return true; 551 591 } … … 556 596 */ 557 597 bool GSInstall::updateSetupExe() 558 { FilePath *destExePath; 598 { 599 FilePath *destExePath; 559 600 FilePath srcExeFile(*this->sourcePath, "gssetup.exe"); 560 601 561 if (this->installExe) 562 { destExePath = this->destinationPath; 563 } 602 if (this->installExe) 603 { 604 destExePath = this->destinationPath; 605 } 564 606 else 565 { destExePath = this->collectPath; 566 } 567 FilePath destExeFile(*destExePath, "gssetup.exe"); 607 { 608 destExePath = this->collectPath; 609 } 610 FilePath destExeFile(*destExePath, "gssetup.exe"); 568 611 569 612 if (!CopyFile(srcExeFile.cString(), destExeFile.cString(), false)) 570 { return false; 571 } 613 { 614 return false; 615 } 572 616 return true; 573 617 } 574 618 575 619 bool 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"); 578 623 579 624 launchApp launchNetscape(netscape32Path); 580 625 launchNetscape.platformApp(gsPlatform_WINDOWS32S, netscape16Path); 581 626 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 } 593 639 return true; 594 640 } 595 641 596 642 FilePath *GSInstall::collectionPath() 597 { return this->collectPath; 643 { 644 return this->collectPath; 598 645 } 599 646 600 647 FilePath *GSInstall::installPath() 601 { return this->installToPath; 648 { 649 return this->installToPath; 602 650 } 603 651 604 652 void GSInstall::addSelectedDir(dirSelector *selector) 605 { this->selectedDirs.push_back(selector); 653 { 654 this->selectedDirs.push_back(selector); 606 655 } 607 656 608 657 typedef struct 609 { dirSelector * dirSelect; 658 { 659 dirSelector * dirSelect; 610 660 } GSInstall_dirPathData; 611 661 612 662 HGLOBAL 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); 616 667 return LoadResource(app_instance, resHdl); 617 668 } … … 622 673 int sx, sy; 623 674 int dx, dy; 624 675 625 676 gsInstall_getDesktopExt(&sx, &sy); 626 677 GetWindowRect(dialog, &rect); … … 632 683 633 684 BOOL 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 635 687 // whole wizard; note doing this in the wizard 636 688 // property sheet initialisation DOES NOT WORK 637 689 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; 641 695 642 696 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 } 647 717 } 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 663 720 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"); 667 725 SetDlgItemText(Dialog, dirpath_PATH, ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA))->selectedPath()); 668 726 break; 669 727 670 728 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 680 740 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 700 765 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 716 783 sprintf(buffer, "Directory %s does not exist - create it?", selector->selectedPath()); 717 784 718 719 785 // if the user cancelled that, then don't permit them to go to the next 786 // page of the wizard 720 787 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 } 727 793 } 728 break; 729 794 delete path; 795 } 796 break; 797 730 798 case PSN_WIZFINISH: 731 { // Finish the activity now 732 config_complete = true; 799 { 800 // Finish the activity now 801 config_complete = true; 733 802 } 734 735 736 break;737 }738 803 break; 804 } 805 break; 806 } 807 return FALSE; 739 808 } 740 809 741 810 void 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()); 747 817 data->dirSelect->setFinal(isFinal); 748 818 749 819 // if there is no extant root selector, make this it 750 820 if (rootSelector == NULL) 751 { rootSelector = data->dirSelect; 752 } 821 { 822 rootSelector = data->dirSelect; 823 } 753 824 754 825 // add this directory selector to the installer … … 756 827 757 828 // set up the rest of the page 758 ppage.dwSize= sizeof(PROPSHEETPAGE);759 ppage.dwFlags= PSP_USETITLE;760 ppage.hInstance 761 ppage.pszTemplate 762 ppage.pszIcon 763 ppage.pszTitle 764 ppage.pfnDlgProc 765 ppage.lParam= (LPARAM) data->dirSelect;766 ppage.pfnCallback 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; 767 838 } 768 839 769 840 int 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 773 846 gsInstall_wizard_centre(dialog); 774 775 776 777 778 779 780 781 782 783 847 break ; 848 849 case PSCB_PRECREATE : 850 // Process PSCB_PRECREATE 851 break ; 852 853 default : 854 // Unknown message 855 break ; 856 } 784 857 return 0; 785 858 } … … 847 920 848 921 case WM_USER: 849 {850 851 852 853 // skip past the -u option itself854 char *at = strstr(app_cmdLine, "-u");855 at += strlen("-u");856 857 // extract the log file path from the command line858 while (*at == ' ')859 {860 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 uninstall867 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 { 869 942 install.uninstall(); 870 943 871 944 // close the log to write back all changes to the log; if the file 872 945 // will be deleted, it must be closed; copying may also fail, so it's 873 946 // safer to close it before doing either. 874 947 install.closeLog(); 875 948 876 949 // if the install is empty, terminate all final items (currently the 877 950 // log and setup executables, … … 880 953 // delete the log file 881 954 DeleteFile(logPath.cString()); 882 955 883 956 // get it's parent to find where the gssetup executable will be 884 957 FilePath *logParent = logPath.parent(); 885 958 FilePath uninstallPath(*logParent, "gssetup.exe"); 886 959 887 960 // delete the gssetup executable 888 961 DeleteFile(uninstallPath.cString()); 889 962 890 963 // dispose of the parent directory information 891 964 delete logParent; … … 896 969 // do nothing - should be changed already! 897 970 } 898 }899 }900 901 902 {903 GSInstall install(false);904 GSInstall_init_wizard(install);905 906 {907 908 }909 else910 {911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 }931 } 932 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 936 1009 case WM_CLOSE: 937 1010 /*if (!file_ischanged || IDCANCEL != file_query(Window, file_name))*/ … … 944 1017 } 945 1018 break; 946 1019 947 1020 default: 948 1021 return(DefWindowProc(Window, Message, wParameter, lParameter)); … … 952 1025 953 1026 void 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 969 1043 PostMessage(app_window, WM_USER, 0, 0L); 970 1044 }
Note:
See TracChangeset
for help on using the changeset viewer.