[1536] | 1 | #include <vector>
|
---|
| 2 | #include <string>
|
---|
[1539] | 3 |
|
---|
| 4 | // use the standard namespace
|
---|
| 5 | #if !defined (GSDL_NAMESPACE_BROKEN)
|
---|
| 6 | #if defined(GSDL_USE_OBJECTSPACE)
|
---|
| 7 | using namespace ospace::std;
|
---|
| 8 | #else
|
---|
[1536] | 9 | using namespace std;
|
---|
[1539] | 10 | #endif
|
---|
| 11 | #endif
|
---|
[1536] | 12 |
|
---|
| 13 | #include <stdlib.h>
|
---|
| 14 | #include <stdio.h>
|
---|
| 15 | #include <windows.h>
|
---|
| 16 | #include <commctrl.h>
|
---|
| 17 |
|
---|
| 18 | #include "dirSelector.h"
|
---|
| 19 | #include "common.h"
|
---|
| 20 | #include "configFile.h"
|
---|
| 21 | #include "File.h"
|
---|
| 22 | #include "FilePath.h"
|
---|
| 23 | #include "FileCopier.h"
|
---|
| 24 | #include "launchApp.h"
|
---|
| 25 | #include "unInstall.h"
|
---|
| 26 |
|
---|
| 27 | #include "gsRegistry.h"
|
---|
| 28 | #include "gsPlatform.h"
|
---|
| 29 | #include "gsProgman.h"
|
---|
| 30 | #include "gsProfile.h"
|
---|
| 31 | #include "gsManifest.h"
|
---|
| 32 |
|
---|
| 33 | char *app_cmdLine;
|
---|
| 34 | static char app_name[] = "Greenstone Installer";
|
---|
| 35 | HINSTANCE app_instance;
|
---|
| 36 | HWND app_window;
|
---|
| 37 |
|
---|
| 38 | bool config_complete = false;
|
---|
| 39 |
|
---|
[1541] | 40 | dirSelector *rootSelector = NULL;
|
---|
| 41 |
|
---|
[1536] | 42 | typedef vector<dirSelector *> dirSelVector;
|
---|
| 43 |
|
---|
| 44 | class GSInstall : public installManager
|
---|
[1541] | 45 | {
|
---|
[1536] | 46 | private:
|
---|
| 47 | configureFile *configFile; // the installation configure file
|
---|
| 48 |
|
---|
| 49 | FilePath *collectPath; // where the collection is currently installed
|
---|
| 50 | FilePath *installToPath; // the first cut at a destination folder
|
---|
| 51 | FilePath *sourcePath; // the root source folder
|
---|
| 52 | FilePath *gsdlSourcePath; // the gsdl folder in the source area
|
---|
| 53 | FilePath *destinationPath; // where the executables will be installed to
|
---|
| 54 | FilePath *dataDestPath; // where the collection data files will go
|
---|
| 55 |
|
---|
| 56 | bool installVolume; // whether to install collection data
|
---|
| 57 | bool installFullVolume; // whether to install all collection data
|
---|
| 58 |
|
---|
| 59 | dirSelVector selectedDirs; // configuration objects
|
---|
| 60 |
|
---|
| 61 | gsPlatform platform; // platform information
|
---|
| 62 | gsRegistry *gsRegister; // registry
|
---|
| 63 | gsManifest *manifest; // manifest of files
|
---|
| 64 | gsProgramManager *progman; // program manager connection
|
---|
| 65 |
|
---|
[2063] | 66 | string setupExe; // form to use for gs(s)setup.exe
|
---|
| 67 |
|
---|
[1536] | 68 | void getSourcePath();
|
---|
| 69 | void getExistingInstall();
|
---|
| 70 | public:
|
---|
| 71 | bool installExe;
|
---|
| 72 |
|
---|
| 73 | GSInstall(bool uninstall);
|
---|
| 74 | FilePath *collectionPath();
|
---|
[2013] | 75 | FilePath *installPath();
|
---|
[2063] | 76 | FilePath *installSourcePath() { return this->sourcePath; }
|
---|
| 77 | string setupExeLeaf() { return this->setupExe; }
|
---|
[1536] | 78 | bool copyFiles();
|
---|
| 79 | bool updateRegistry();
|
---|
| 80 | bool updateProfiles();
|
---|
| 81 | bool updateProgman();
|
---|
| 82 | bool updateSetupExe();
|
---|
[2013] | 83 | bool installNetscape();
|
---|
| 84 | bool removeFailed(string file) { return this->manifest->undoFailed(file); }
|
---|
[1536] | 85 | void setDestination();
|
---|
| 86 | bool setUninstall();
|
---|
| 87 | void uninstall();
|
---|
| 88 | void setManifest();
|
---|
| 89 | void addSelectedDir(dirSelector *selector);
|
---|
| 90 | };
|
---|
| 91 |
|
---|
| 92 | static string gsdl_DBHOME = "gdbmhome";
|
---|
| 93 | static string gsdl_VLHOME = "gsdlhome";
|
---|
| 94 | static string gsdl_STATIC = "staticpath";
|
---|
| 95 | static string gsdl_COLLIST= "collections";
|
---|
| 96 |
|
---|
| 97 | void gsInstall_getDesktopExt(int *sx, int *sy)
|
---|
| 98 | {
|
---|
| 99 | HDC dc = GetDC(GetDesktopWindow());
|
---|
| 100 | *sx = GetDeviceCaps(dc, HORZRES);
|
---|
| 101 | *sy = GetDeviceCaps(dc, VERTRES);
|
---|
| 102 | ReleaseDC(GetDesktopWindow(), dc);
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | /**
|
---|
| 106 | * Get various and nefarious details before we start trying an installation.
|
---|
| 107 | * The installation configuration file is read, we seek for an existing
|
---|
| 108 | * installation and reconfigure the default install settings appropriately.
|
---|
| 109 | * THe source path is also discovered.
|
---|
| 110 | */
|
---|
| 111 | GSInstall::GSInstall(bool uninstall)
|
---|
| 112 | : installManager()
|
---|
[2063] | 113 | {
|
---|
[1536] | 114 | // get the installation configuration file
|
---|
| 115 | this->configFile = new configureFile("install.cfg");
|
---|
| 116 |
|
---|
| 117 | // set up "default" installation bits
|
---|
| 118 | this->installToPath = new FilePath("C:\\GSDL");
|
---|
| 119 | this->collectPath = NULL;
|
---|
| 120 | this->installExe = true; // we must install the exe files
|
---|
| 121 |
|
---|
| 122 | // don't attempt this with windows 3.1
|
---|
| 123 | if (!this->platform.isWindows32s())
|
---|
[2063] | 124 | {
|
---|
[1536] | 125 | // get the registry
|
---|
| 126 | this->gsRegister = new gsRegistry(*this, *this->configFile);
|
---|
[2063] | 127 | this->setupExe = "gssetup.exe";
|
---|
[1536] | 128 | }
|
---|
| 129 | else
|
---|
[2063] | 130 | {
|
---|
[1536] | 131 | // TODO: in windows 3.1 we can't use the register as it isn't fully/properly
|
---|
| 132 | // implemented; we must get the existing path information from elsewhere
|
---|
| 133 | this->gsRegister = new gsRegistry(*this, *this->configFile);
|
---|
[2063] | 134 | this->setupExe = "gsetup.exe";
|
---|
[1536] | 135 | }
|
---|
| 136 |
|
---|
| 137 | // assume for now we will install the full volume and the database
|
---|
| 138 | this->installVolume = true;
|
---|
| 139 | this->installFullVolume = true;
|
---|
| 140 |
|
---|
| 141 | // detect any existing installation; unnecessary in uninstall (it's the
|
---|
| 142 | // "source" directory - see later
|
---|
| 143 | if (uninstall == false)
|
---|
[2063] | 144 | {
|
---|
[1536] | 145 | this->getExistingInstall();
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | // get where we are installing from
|
---|
| 149 | this->getSourcePath();
|
---|
| 150 |
|
---|
| 151 | // if doing an uninstall we now know where the "uninstall" is
|
---|
| 152 | if (uninstall == true)
|
---|
[2063] | 153 | {
|
---|
[1536] | 154 | this->collectPath = this->sourcePath;
|
---|
| 155 | }
|
---|
| 156 |
|
---|
| 157 | // get the manifest and program manager objects
|
---|
| 158 | if (uninstall)
|
---|
[2063] | 159 | {
|
---|
[1536] | 160 | this->manifest = new gsManifest(*this);
|
---|
| 161 | }
|
---|
| 162 | else
|
---|
[2063] | 163 | {
|
---|
[1536] | 164 | this->manifest = new gsManifest(*this, *this->sourcePath);
|
---|
| 165 | }
|
---|
| 166 | this->progman = new gsProgramManager(*this);
|
---|
| 167 |
|
---|
| 168 | // tell manifest the number of bits in the raw windows environment; this may
|
---|
| 169 | // be required for loading certain modules such as winsock; the number of
|
---|
| 170 | // macros is over-the-top, but is more robust to unforeseen future requirements
|
---|
| 171 | /* if (platform.isWindows32s())
|
---|
| 172 | { this->manifest->expandMacro("WINBITS", "16");
|
---|
| 173 | this->manifest->expandMacro("WIN16", "16");
|
---|
| 174 | this->manifest->expandMacro("WIN32", "32");
|
---|
| 175 | }
|
---|
| 176 | else
|
---|
| 177 | { this->manifest->expandMacro("WINBITS", "32");
|
---|
| 178 | this->manifest->expandMacro("WIN16", "");
|
---|
| 179 | this->manifest->expandMacro("WIN32", "32");
|
---|
| 180 | }
|
---|
| 181 | */
|
---|
| 182 | // inform manifest of collection directory name
|
---|
| 183 | string colDir;
|
---|
| 184 | colDir = this->configFile->getString("CollectionDirName");
|
---|
| 185 | if (colDir != "")
|
---|
| 186 | {
|
---|
| 187 | this->manifest->expandMacro("COLDIRNAME", colDir);
|
---|
| 188 | }
|
---|
| 189 | }
|
---|
| 190 |
|
---|
| 191 | /**
|
---|
| 192 | * Detect the presence of an existing installation
|
---|
| 193 | */
|
---|
| 194 | void GSInstall::getExistingInstall()
|
---|
| 195 | {
|
---|
| 196 | if (!this->platform.isWindows32s())
|
---|
| 197 | {
|
---|
| 198 | if (gsRegister->collectionInstalled())
|
---|
| 199 | {
|
---|
| 200 | // TODO: check if receptionist etc should be replaced or not
|
---|
| 201 |
|
---|
| 202 | // TODO: check build version of the volume
|
---|
| 203 |
|
---|
| 204 | // Get location of the library executable from the registry; this
|
---|
[2073] | 205 | // is thence used to get the location of gsdlsite.cfg etc.
|
---|
[1536] | 206 | this->collectPath = this->gsRegister->collectionPath();
|
---|
| 207 | if (this->collectPath->pathString() != "")
|
---|
| 208 | {
|
---|
| 209 | this->installToPath = this->collectPath;
|
---|
| 210 | // we don't need to install the exe files
|
---|
| 211 | this->installExe = false;
|
---|
| 212 | }
|
---|
| 213 | }
|
---|
| 214 | }
|
---|
| 215 | }
|
---|
| 216 |
|
---|
| 217 | /**
|
---|
| 218 | * get the source path for this install; we derive this from the path of this
|
---|
| 219 | * executable (the installer)
|
---|
| 220 | */
|
---|
| 221 | void GSInstall::getSourcePath()
|
---|
[1543] | 222 | {
|
---|
| 223 | static char filename[512];
|
---|
| 224 | FilePath *exePath;
|
---|
[1536] | 225 |
|
---|
| 226 | // get the filepath of this executable
|
---|
| 227 | GetModuleFileName(0, filename, 512);
|
---|
[1543] | 228 | exePath = new FilePath(filename);
|
---|
[1536] | 229 |
|
---|
| 230 | // get the parent (i.e. the folder containing this executable) for the source
|
---|
| 231 | // folder
|
---|
[1543] | 232 | this->sourcePath = exePath->parent();
|
---|
[1536] | 233 |
|
---|
| 234 | // get the gsdl source path
|
---|
[1543] | 235 | this->gsdlSourcePath = new FilePath(this->sourcePath->pathString(), "gsdl");
|
---|
[1536] | 236 | delete exePath;
|
---|
| 237 | }
|
---|
| 238 |
|
---|
| 239 | /**
|
---|
| 240 | * Controls the actual copying of the files; manifests of what to install
|
---|
| 241 | * are read in from a configuration on the hard drive - this should be basically
|
---|
| 242 | * greenstone dependent, and void of any collection-specific rubbish!
|
---|
| 243 | */
|
---|
| 244 | bool GSInstall::copyFiles()
|
---|
[1543] | 245 | {
|
---|
| 246 | // ensure that we have got the required destination and that we can write there
|
---|
[1536] | 247 | if (this->installExe)
|
---|
[1543] | 248 | {
|
---|
[1588] | 249 | // this->destinationPath->ensureWriteablePath();
|
---|
[1543] | 250 | }
|
---|
[1536] | 251 |
|
---|
| 252 | // ensure that the destination path for the collection itself is available
|
---|
| 253 | if (this->installVolume)
|
---|
[1543] | 254 | {
|
---|
[1588] | 255 | // this->dataDestPath->ensureWriteablePath();
|
---|
[1543] | 256 | }
|
---|
[1536] | 257 |
|
---|
| 258 | // do the copy
|
---|
[1543] | 259 | this->manifest->copy(this->gsdlSourcePath);
|
---|
[1536] | 260 |
|
---|
| 261 | return true;
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | /**
|
---|
| 265 | * Fulfill registry update requirements; first the keys are set up, then they
|
---|
| 266 | * are filled with key item/value pairs.
|
---|
| 267 | */
|
---|
| 268 | bool GSInstall::updateRegistry()
|
---|
[1543] | 269 | {
|
---|
| 270 | // don't do registry stuff under windows 32s
|
---|
[1765] | 271 | // TODO: actually reinstate what is required
|
---|
| 272 | if (this->platform.isWindows32s())
|
---|
[1543] | 273 | {
|
---|
| 274 | return true;
|
---|
| 275 | }
|
---|
[1536] | 276 |
|
---|
| 277 | // ensure all pertinent keys already exist for this volume/collection
|
---|
[1543] | 278 | this->gsRegister->ensureKeysExist();
|
---|
[1536] | 279 |
|
---|
| 280 | // now move on to add key items
|
---|
[1543] | 281 | if (this->installExe)
|
---|
| 282 | {
|
---|
| 283 | // FilePath *serverPath = new FilePath(this->destinationPath->pathString(), "server.exe");
|
---|
[1657] | 284 | FilePath *serverPath = new FilePath(this->destinationPath->pathString(), "server.exe");
|
---|
[2063] | 285 | FilePath *setupPath = new FilePath(this->destinationPath->pathString(), this->setupExe);
|
---|
[1543] | 286 | FilePath *logPath = new FilePath(this->destinationPath->pathString(), "install.log");
|
---|
| 287 | string exeKeyPath, uninstallCmd, uninstallKeyPath;
|
---|
| 288 | gsPlatform platform;
|
---|
[1536] | 289 |
|
---|
[1543] | 290 | // store the normal collection key information
|
---|
| 291 | this->gsRegister->storeKeyString(HKEY_LOCAL_MACHINE,
|
---|
| 292 | this->gsRegister->collectKeyId(),
|
---|
| 293 | "library",
|
---|
| 294 | serverPath->pathString());
|
---|
[1536] | 295 |
|
---|
[1543] | 296 | // This test is in fact for 9x or NT 4+; we're worried about the registry
|
---|
| 297 | // format, not about the shell as such
|
---|
| 298 | if (platform.isExplorerShell())
|
---|
| 299 | {
|
---|
| 300 | // get special app path key for windows 9x
|
---|
[1657] | 301 | exeKeyPath = this->gsRegister->exeKeyId("server.exe");
|
---|
[1536] | 302 |
|
---|
[1543] | 303 | // ensure that the exe key exists
|
---|
| 304 | this->gsRegister->ensureKeyExists(HKEY_LOCAL_MACHINE, exeKeyPath);
|
---|
[1536] | 305 |
|
---|
[1543] | 306 | // store default key for this application
|
---|
| 307 | this->gsRegister->storeKeyString(HKEY_LOCAL_MACHINE,
|
---|
| 308 | exeKeyPath,
|
---|
| 309 | "",
|
---|
| 310 | serverPath->pathString());
|
---|
[1536] | 311 |
|
---|
[1543] | 312 | // store path for this application
|
---|
| 313 | this->gsRegister->storeKeyString(HKEY_LOCAL_MACHINE,
|
---|
| 314 | exeKeyPath,
|
---|
| 315 | "path",
|
---|
| 316 | this->destinationPath->pathString());
|
---|
[1536] | 317 |
|
---|
[1543] | 318 | // create uninstall command line
|
---|
| 319 | uninstallCmd = setupPath->pathString() + " -u " + logPath->pathString();
|
---|
| 320 | uninstallKeyPath = this->gsRegister->uninstallKeyId(this->configFile->getString("CollectionName"));
|
---|
[1536] | 321 |
|
---|
[1543] | 322 | // ensure uninstall key exists
|
---|
| 323 | this->gsRegister->ensureKeyExists(HKEY_LOCAL_MACHINE, uninstallKeyPath);
|
---|
| 324 |
|
---|
| 325 | this->gsRegister->storeKeyString(HKEY_LOCAL_MACHINE, uninstallKeyPath,
|
---|
| 326 | "DisplayName",
|
---|
| 327 | this->configFile->getString("CollectionName"));
|
---|
| 328 | this->gsRegister->storeKeyString(HKEY_LOCAL_MACHINE, uninstallKeyPath,
|
---|
| 329 | "UninstallString", uninstallCmd);
|
---|
| 330 | }
|
---|
| 331 | delete setupPath;
|
---|
| 332 | delete serverPath;
|
---|
| 333 | delete logPath;
|
---|
[1536] | 334 | }
|
---|
| 335 |
|
---|
| 336 | if (this->installVolume || this->installFullVolume)
|
---|
[1543] | 337 | {
|
---|
| 338 | // no actual key items are held in the volume key; for future use
|
---|
| 339 | }
|
---|
[1536] | 340 | return true;
|
---|
| 341 | }
|
---|
| 342 |
|
---|
| 343 | /**
|
---|
| 344 | * Set the destination directory details
|
---|
| 345 | */
|
---|
| 346 | void GSInstall::setDestination()
|
---|
[1543] | 347 | {
|
---|
| 348 | // get configuration from the install wizard pages
|
---|
| 349 | this->destinationPath = new FilePath(this->selectedDirs[0]->selectedPath());
|
---|
| 350 | this->installFullVolume = this->selectedDirs[1]->getOption();
|
---|
[1536] | 351 | if (this->installFullVolume || true) // NB: always take path from 2nd dialog
|
---|
[1543] | 352 | {
|
---|
| 353 | this->dataDestPath = new FilePath(this->selectedDirs[1]->selectedPath());
|
---|
| 354 | }
|
---|
[1536] | 355 | else
|
---|
[1543] | 356 | {
|
---|
| 357 | this->dataDestPath = this->destinationPath;
|
---|
| 358 | }
|
---|
[1657] | 359 |
|
---|
| 360 |
|
---|
| 361 | // set the log for writing
|
---|
| 362 |
|
---|
| 363 | FilePath *logPath = new FilePath(this->destinationPath->pathString(), "install.log");
|
---|
| 364 |
|
---|
| 365 | this->setLogFile(logPath->pathString());
|
---|
| 366 |
|
---|
| 367 | this->readLog();
|
---|
| 368 |
|
---|
| 369 | delete logPath;
|
---|
| 370 |
|
---|
[1639] | 371 | }
|
---|
[1536] | 372 |
|
---|
| 373 | bool GSInstall::setUninstall()
|
---|
[1543] | 374 | {
|
---|
| 375 | char tempPathStr[MAX_PATH];
|
---|
[1536] | 376 |
|
---|
| 377 | // if we failed to get the Windows temporary directory, abort
|
---|
| 378 | if (GetTempPath(MAX_PATH, tempPathStr) == 0)
|
---|
[1543] | 379 | {
|
---|
| 380 | // TODO: abort!
|
---|
| 381 | return false;
|
---|
| 382 | }
|
---|
[1536] | 383 |
|
---|
| 384 | FilePath tempPath(tempPathStr);
|
---|
| 385 |
|
---|
| 386 | // if we are not running in the Windows temporary directory, copy this exe
|
---|
| 387 | // and the installation log to the temporary directory and run them there
|
---|
| 388 | if (*this->sourcePath != tempPath)
|
---|
[1543] | 389 | {
|
---|
| 390 | // copy this and install.log to temporary directory and restart
|
---|
[2063] | 391 | FilePath exePath(*this->sourcePath, this->setupExe);
|
---|
[1543] | 392 | FilePath logPath(*this->sourcePath, "install.log");
|
---|
[1536] | 393 |
|
---|
[2063] | 394 | FilePath exeDest(tempPath, this->setupExe);
|
---|
[1543] | 395 | FilePath logDest(tempPath, "install.log");
|
---|
[2013] | 396 |
|
---|
[1543] | 397 | CopyFile(exePath.cString(), exeDest.cString(), false);
|
---|
| 398 | CopyFile(logPath.cString(), logDest.cString(), false);
|
---|
[1536] | 399 |
|
---|
[1543] | 400 | // now run the gssetup in the temporary directory
|
---|
| 401 | launchApp launchUninstall(exeDest);
|
---|
| 402 | launchUninstall.setCommandLine(" -u " + logPath.pathString());
|
---|
| 403 | launchUninstall.run(false, 0, "", "", false);
|
---|
[1536] | 404 |
|
---|
[1543] | 405 | return false;
|
---|
| 406 | }
|
---|
[1536] | 407 |
|
---|
| 408 | // open the log for reading from the directory this exe is now in (which
|
---|
| 409 | // will in fact be the temporary directory as outlined above)
|
---|
[1657] | 410 | FilePath *logPath = new FilePath(this->sourcePath->pathString(), "install.log");
|
---|
| 411 |
|
---|
[1638] | 412 | this->setLogFile(logPath->pathString());
|
---|
| 413 | this->readLog();
|
---|
[1536] | 414 | delete logPath;
|
---|
[1543] | 415 |
|
---|
[1536] | 416 | return true;
|
---|
| 417 | }
|
---|
| 418 |
|
---|
| 419 | void GSInstall::uninstall()
|
---|
[1543] | 420 | {
|
---|
| 421 | FilePath *iniPath;
|
---|
| 422 | string command;
|
---|
[1536] | 423 | stringArray params;
|
---|
| 424 |
|
---|
[1543] | 425 | this->manifest = new gsManifest(*this); // get a manifest manager
|
---|
[1536] | 426 |
|
---|
[2288] | 427 | iniPath = new FilePath(this->installRoot(), "gsdlsite.cfg");
|
---|
[1543] | 428 | gsProfile gsdlProfile(*this, iniPath->pathString());
|
---|
[1536] | 429 |
|
---|
[1543] | 430 | while ((command = this->popCommand(params)) != "")
|
---|
| 431 | {
|
---|
| 432 | if (!this->manifest->undoAction(command, params))
|
---|
| 433 | {
|
---|
| 434 | if (!gsdlProfile.undoAction(command, params))
|
---|
| 435 | {
|
---|
| 436 | if (!this->gsRegister->undoAction(command, params))
|
---|
| 437 | {
|
---|
| 438 | if (!this->progman->undoAction(command, params))
|
---|
| 439 | {
|
---|
| 440 | }
|
---|
| 441 | }
|
---|
| 442 | }
|
---|
| 443 | }
|
---|
[2013] | 444 | }
|
---|
| 445 |
|
---|
[1536] | 446 | }
|
---|
| 447 |
|
---|
| 448 | /**
|
---|
| 449 | * Collate the manifest for installation
|
---|
| 450 | */
|
---|
| 451 | void GSInstall::setManifest()
|
---|
[1543] | 452 | {
|
---|
| 453 | if (this->installExe)
|
---|
| 454 | {
|
---|
| 455 | this->manifest->selectGroup("library", *this->destinationPath);
|
---|
| 456 | }
|
---|
[1536] | 457 | if (this->installFullVolume)
|
---|
[1543] | 458 | {
|
---|
| 459 | this->manifest->selectGroup("collection", *this->dataDestPath);
|
---|
| 460 | }
|
---|
[1536] | 461 | else
|
---|
[1543] | 462 | {
|
---|
| 463 | this->manifest->selectGroup("database", *this->dataDestPath);
|
---|
| 464 | }
|
---|
[1536] | 465 | }
|
---|
| 466 |
|
---|
| 467 | /**
|
---|
| 468 | * Update the program manager/explorer shell with icons, groups etc for this
|
---|
| 469 | * collection/application
|
---|
| 470 | */
|
---|
| 471 | bool GSInstall::updateProgman()
|
---|
[1543] | 472 | {
|
---|
| 473 | string groupName;
|
---|
[1657] | 474 | string collectionName;
|
---|
[1536] | 475 |
|
---|
| 476 | // if we managed to get a connection to the program manager (or explorer
|
---|
| 477 | // shell) then do the requisite updates
|
---|
| 478 | if (this->progman->connect())
|
---|
[1543] | 479 | {
|
---|
| 480 | // get group name from folders
|
---|
| 481 | groupName = this->configFile->getString("ProgramGroupName");
|
---|
| 482 | if (groupName == "")
|
---|
| 483 | {
|
---|
| 484 | // TODO: error handling
|
---|
| 485 | this->progman->disconnect();
|
---|
| 486 | return false;
|
---|
| 487 | }
|
---|
[1657] | 488 | collectionName = this->configFile->getString("CollectionName");
|
---|
| 489 | if (collectionName == "")
|
---|
| 490 | {
|
---|
| 491 | // TODO: error handling
|
---|
| 492 | this->progman->disconnect();
|
---|
| 493 | return false;
|
---|
| 494 | }
|
---|
[1584] | 495 |
|
---|
[1543] | 496 | // add the group
|
---|
| 497 | if (!this->progman->addProgramGroup(groupName))
|
---|
| 498 | {
|
---|
| 499 | this->progman->disconnect();
|
---|
| 500 | return false;
|
---|
[1536] | 501 | }
|
---|
[1584] | 502 |
|
---|
[1543] | 503 | // add a "server" icon
|
---|
[1657] | 504 | FilePath libraryPath(this->destinationPath->pathString(), "server.exe");
|
---|
| 505 | if (!this->progman->addIcon(groupName, collectionName, libraryPath.pathString(), "", ""))
|
---|
[1543] | 506 | {
|
---|
| 507 | }
|
---|
[1536] | 508 |
|
---|
[1543] | 509 | FilePath readMePath(this->destinationPath->pathString(), "readme.txt");
|
---|
[1657] | 510 | if (!this->progman->addIcon(groupName, "ReadMe", readMePath.pathString(), "", ""))
|
---|
[1536] | 511 | {
|
---|
[1543] | 512 | }
|
---|
[1536] | 513 |
|
---|
[1657] | 514 | FilePath supportPath(this->destinationPath->pathString(), "Support.htm");
|
---|
| 515 | if (!this->progman->addIcon(groupName, "Technical Support", supportPath.pathString(), "", ""))
|
---|
[1536] | 516 | {
|
---|
[1543] | 517 | }
|
---|
[1536] | 518 |
|
---|
[1588] | 519 |
|
---|
[2063] | 520 | FilePath uninstallPath(this->destinationPath->pathString(), this->setupExe);
|
---|
[2013] | 521 | FilePath logPath(this->destinationPath->pathString(), "install.log");
|
---|
| 522 | if (this->platform.isWindows32s() == false) // NB: don't add this shortcut under
|
---|
[1765] | 523 | // Windows32s as it causes a crash
|
---|
[2063] | 524 | //
|
---|
[1765] | 525 | // TODO: reinstate this with Win3.1
|
---|
| 526 | // happy code
|
---|
| 527 | {
|
---|
[1657] | 528 | if (!this->progman->addIcon(groupName, "Uninstall", uninstallPath.pathString(), " -u " + logPath.pathString(),
|
---|
| 529 | "Remove this Greenstone collection"))
|
---|
[1581] | 530 | {
|
---|
[1588] | 531 | }
|
---|
[2013] | 532 | }
|
---|
| 533 | else
|
---|
[2063] | 534 | { if (!this->progman->addIcon(groupName, "Uninstall", uninstallPath.pathString() + " -u " + logPath.pathString(), "",
|
---|
| 535 | "Remove this Greenstone collection"))
|
---|
| 536 | {
|
---|
| 537 | }
|
---|
[1765] | 538 | }
|
---|
[1543] | 539 | // disconnect from program manager
|
---|
| 540 | this->progman->disconnect();
|
---|
| 541 | }
|
---|
[1536] | 542 | return true;
|
---|
| 543 | }
|
---|
| 544 |
|
---|
| 545 | /**
|
---|
| 546 | * Update the profile (ini) files associated with the program; these changes
|
---|
| 547 | * must be made after copying to files in the destination/executable folders
|
---|
| 548 | * as we can't write to CD-ROM (or at least we shouldn't - the install would
|
---|
| 549 | * become tainted).
|
---|
| 550 | */
|
---|
| 551 | bool GSInstall::updateProfiles()
|
---|
[1543] | 552 | {
|
---|
| 553 | FilePath *exePath;
|
---|
| 554 | FilePath *dataPath;
|
---|
[1536] | 555 | FilePath *iniPath;
|
---|
| 556 |
|
---|
| 557 | // if we're installing the exe, then the exe path leads to the destination
|
---|
| 558 | // folder of this installation sequence; if not, then we pick it up from
|
---|
| 559 | // the existing location of that folder
|
---|
[1543] | 560 | if (this->installExe)
|
---|
| 561 | {
|
---|
| 562 | exePath = this->destinationPath;
|
---|
| 563 | }
|
---|
[1536] | 564 | else
|
---|
[1543] | 565 | {
|
---|
| 566 | exePath = this->collectPath;
|
---|
| 567 | }
|
---|
[2073] | 568 | iniPath = new FilePath(exePath->pathString(), "gsdlsite.cfg");
|
---|
[1536] | 569 |
|
---|
| 570 | // TODO: check if this 'if' structure is correct; suspect that it isn't quite
|
---|
| 571 | // as we may not be installing the volume, but exe etc individually;
|
---|
| 572 | // may be okay now but not future proof; also the destination directory
|
---|
| 573 | // may or may not be tied to the exe directory if that existed already.
|
---|
| 574 | // This all needs investigating
|
---|
| 575 | if (this->installVolume)
|
---|
[1543] | 576 | {
|
---|
| 577 | // Manufacture the appropriate section name now; an equivalent string
|
---|
| 578 | // is also constructed
|
---|
| 579 | string volumeSectionString = this->configFile->getString("CollectionName") +
|
---|
| 580 | "#" + this->configFile->getString("CollectionVolume");
|
---|
[1536] | 581 |
|
---|
[1543] | 582 | // if we're installing the full data for the collection, then take the
|
---|
| 583 | // data path to be at the selected destination directory for the collection
|
---|
| 584 | // files; otherwise take the data path to be on the CD/distribution media
|
---|
| 585 | if (this->installFullVolume)
|
---|
| 586 | {
|
---|
| 587 | dataPath = this->dataDestPath;
|
---|
| 588 | }
|
---|
| 589 | else
|
---|
| 590 | {
|
---|
| 591 | dataPath = this->gsdlSourcePath;
|
---|
| 592 | }
|
---|
[1536] | 593 |
|
---|
[2073] | 594 | // create a profile object to write to the gsdlsite.cfg file
|
---|
[1543] | 595 | gsProfile gsdlProfile(*this, iniPath->pathString());
|
---|
[1536] | 596 |
|
---|
[1543] | 597 | // if installing the executable, add the database and greenstone home
|
---|
| 598 | // directories
|
---|
| 599 | if (this->installExe)
|
---|
| 600 | {
|
---|
[2073] | 601 | // set the correct exe entries in gsdlsite.cfg (in the gsdl section)
|
---|
[1543] | 602 | gsdlProfile.writeString("gsdl", "gsdlhome", dataPath->pathString());
|
---|
| 603 | gsdlProfile.writeString("gsdl", "gdbmhome", this->dataDestPath->pathString());
|
---|
| 604 | }
|
---|
[1536] | 605 |
|
---|
[2073] | 606 | // set the correct collection volume entries in gsdlsite.cfg
|
---|
[1543] | 607 | if (this->installVolume)
|
---|
| 608 | {
|
---|
| 609 | // note the collection in the general gsdl section; and add the undo item too
|
---|
| 610 | gsdlProfile.ensureListMember("gsdl", gsdl_COLLIST, volumeSectionString);
|
---|
[1536] | 611 |
|
---|
[1543] | 612 | // note the volume data in its own section
|
---|
| 613 | gsdlProfile.writeString(volumeSectionString, "gsdlhome", dataPath->pathString());
|
---|
| 614 | gsdlProfile.writeString(volumeSectionString, "gdbmhome", this->dataDestPath->pathString());
|
---|
| 615 | gsdlProfile.writeString(volumeSectionString, "staticpath", dataPath->pathString());
|
---|
| 616 | }
|
---|
[1536] | 617 | }
|
---|
[1543] | 618 |
|
---|
[1536] | 619 | // clean up
|
---|
| 620 | delete iniPath;
|
---|
[1543] | 621 |
|
---|
[1536] | 622 | return true;
|
---|
| 623 | }
|
---|
| 624 |
|
---|
| 625 | /**
|
---|
| 626 | * Ensure that we've installed the very latest setup executable @ the destination/
|
---|
| 627 | * greenstone folder
|
---|
| 628 | */
|
---|
| 629 | bool GSInstall::updateSetupExe()
|
---|
[1543] | 630 | {
|
---|
| 631 | FilePath *destExePath;
|
---|
[1536] | 632 | FilePath srcExeFile(*this->sourcePath, "gssetup.exe");
|
---|
| 633 |
|
---|
[1543] | 634 | if (this->installExe)
|
---|
| 635 | {
|
---|
| 636 | destExePath = this->destinationPath;
|
---|
| 637 | }
|
---|
[1536] | 638 | else
|
---|
[1543] | 639 | {
|
---|
| 640 | destExePath = this->collectPath;
|
---|
| 641 | }
|
---|
[2063] | 642 | FilePath destExeFile(*destExePath, this->setupExe);
|
---|
[1536] | 643 |
|
---|
[1765] | 644 | if (this->platform.isWindows32s() == false) // NB: Don't copy the setup executable
|
---|
| 645 | // to Windows32s as it causes a hang!
|
---|
| 646 | { if (!CopyFile(srcExeFile.cString(), destExeFile.cString(), false))
|
---|
| 647 | {
|
---|
| 648 | return false;
|
---|
| 649 | }
|
---|
| 650 | }
|
---|
[2063] | 651 | else
|
---|
| 652 | { // Windows 3.1 has a peculiar behaviour on calling CopyFile on an .exe;
|
---|
| 653 | // it doesn't. (Copy the file); thus we copy to an non-exe file and then
|
---|
| 654 | // rename it into an exe file; this works.
|
---|
| 655 | FilePath intExeFile(*destExePath, "gsetup.ex");
|
---|
| 656 | if (!CopyFile(srcExeFile.cString(), intExeFile.cString(), false))
|
---|
| 657 | {
|
---|
| 658 | return false;
|
---|
| 659 | }
|
---|
| 660 | MoveFile(intExeFile.cString(), destExeFile.cString());
|
---|
| 661 | }
|
---|
[1536] | 662 | return true;
|
---|
| 663 | }
|
---|
| 664 |
|
---|
| 665 | bool GSInstall::installNetscape()
|
---|
[1543] | 666 | {
|
---|
| 667 | FilePath netscape32Path(this->sourcePath->pathString(), "netscape\\n32e405.exe");
|
---|
| 668 | FilePath netscape16Path(this->sourcePath->pathString(), "netscape\\n16e405.exe");
|
---|
[1536] | 669 |
|
---|
| 670 | launchApp launchNetscape(netscape32Path);
|
---|
| 671 | launchNetscape.platformApp(gsPlatform_WINDOWS32S, netscape16Path);
|
---|
[1584] | 672 | launchNetscape.platformApp(gsPlatform_WINDOWS, netscape16Path);
|
---|
[1536] | 673 | if (launchNetscape.run(true, 1,
|
---|
[1543] | 674 | "This library is displayed using a web browser. If you don't "
|
---|
| 675 | "currently have a web browser installed on your machine you may "
|
---|
| 676 | "install the Netscape 4.05 browser now.\n\n"
|
---|
| 677 | "Note that if your current browser was provided by your internet "
|
---|
| 678 | "service provider, you should install Netscape in a different "
|
---|
| 679 | "directory.\n\n"
|
---|
| 680 | "Would you like to install the Netscape 4.05 browser now?",
|
---|
| 681 | "Greenstone Installer", false) < 0)
|
---|
| 682 | {
|
---|
[1657] | 683 | // MessageBox(0, "Error", app_name, MB_OK);
|
---|
[1543] | 684 | return false;
|
---|
| 685 | }
|
---|
[1536] | 686 | return true;
|
---|
| 687 | }
|
---|
| 688 |
|
---|
| 689 | FilePath *GSInstall::collectionPath()
|
---|
[1543] | 690 | {
|
---|
| 691 | return this->collectPath;
|
---|
[1536] | 692 | }
|
---|
| 693 |
|
---|
| 694 | FilePath *GSInstall::installPath()
|
---|
[1543] | 695 | {
|
---|
| 696 | return this->installToPath;
|
---|
[1536] | 697 | }
|
---|
| 698 |
|
---|
| 699 | void GSInstall::addSelectedDir(dirSelector *selector)
|
---|
[1543] | 700 | {
|
---|
| 701 | this->selectedDirs.push_back(selector);
|
---|
[1536] | 702 | }
|
---|
| 703 |
|
---|
| 704 | typedef struct
|
---|
[1543] | 705 | {
|
---|
| 706 | dirSelector * dirSelect;
|
---|
[1536] | 707 | } GSInstall_dirPathData;
|
---|
| 708 |
|
---|
| 709 | HGLOBAL loadDirBrowser()
|
---|
[1543] | 710 | {
|
---|
| 711 | HRSRC resHdl;
|
---|
[1536] | 712 |
|
---|
[1543] | 713 | resHdl = FindResource(app_instance, "MySaveAsDlg", RT_DIALOG);
|
---|
[1536] | 714 | return LoadResource(app_instance, resHdl);
|
---|
| 715 | }
|
---|
| 716 |
|
---|
| 717 | void gsInstall_wizard_centre(HWND dialog)
|
---|
| 718 | {
|
---|
| 719 | RECT rect;
|
---|
| 720 | int sx, sy;
|
---|
| 721 | int dx, dy;
|
---|
[1543] | 722 |
|
---|
[1536] | 723 | gsInstall_getDesktopExt(&sx, &sy);
|
---|
| 724 | GetWindowRect(dialog, &rect);
|
---|
| 725 |
|
---|
| 726 | dx = (sx - rect.right + rect.left) >> 1;
|
---|
| 727 | dy = (sy - rect.bottom + rect.top) >> 1;
|
---|
| 728 | SetWindowPos(dialog, 0, dx, dy, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
|
---|
| 729 | }
|
---|
| 730 |
|
---|
| 731 | BOOL FAR PASCAL GSInstall_dlgproc(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
|
---|
[1543] | 732 | {
|
---|
| 733 | static bool first = true; // static variable to hack the position of the
|
---|
[1536] | 734 | // whole wizard; note doing this in the wizard
|
---|
| 735 | // property sheet initialisation DOES NOT WORK
|
---|
| 736 |
|
---|
[1543] | 737 | switch (Message)
|
---|
| 738 | {
|
---|
| 739 | case WM_INITDIALOG:
|
---|
| 740 | {
|
---|
| 741 | dirSelector *selector = (dirSelector *) ((PROPSHEETPAGE *) lParam)->lParam;
|
---|
[1536] | 742 |
|
---|
| 743 | SetDlgItemText(Dialog, dirpath_PROMPT, selector->prompt);
|
---|
[1543] | 744 | if (selector->optPrompt != NULL)
|
---|
| 745 | {
|
---|
| 746 | SetDlgItemText(Dialog, dirpath_OPTION, selector->optPrompt);
|
---|
| 747 | EnableWindow(GetDlgItem(Dialog, dirpath_BROWSE), true); // was false
|
---|
| 748 | EnableWindow(GetDlgItem(Dialog, dirpath_PATH), true); // was false
|
---|
| 749 | }
|
---|
| 750 | else
|
---|
| 751 | {
|
---|
| 752 | ShowWindow(GetDlgItem(Dialog, dirpath_OPTION), SW_HIDE);
|
---|
| 753 | }
|
---|
| 754 | SetWindowLong(Dialog, GWL_USERDATA, ((PROPSHEETPAGE *) lParam)->lParam);
|
---|
| 755 | SetDlgItemText(Dialog, dirpath_PATH, selector->selectedPath());
|
---|
| 756 |
|
---|
| 757 | // if this is the first time this function is called, then centre the
|
---|
| 758 | // wizard into the centre of our screen.
|
---|
| 759 | if (first)
|
---|
| 760 | {
|
---|
| 761 | gsInstall_wizard_centre(GetParent(Dialog));
|
---|
| 762 | first = false;
|
---|
| 763 | }
|
---|
[1536] | 764 | }
|
---|
[1543] | 765 | return TRUE;
|
---|
[1584] | 766 |
|
---|
[1536] | 767 | case WM_COMMAND:
|
---|
[1543] | 768 | switch (LOWORD(wParam))
|
---|
| 769 | {
|
---|
| 770 | case dirpath_BROWSE:
|
---|
| 771 | ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA))->requestPath(Dialog, "Select Directory");
|
---|
[1536] | 772 | SetDlgItemText(Dialog, dirpath_PATH, ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA))->selectedPath());
|
---|
[1543] | 773 | break;
|
---|
[1536] | 774 |
|
---|
| 775 | case dirpath_OPTION:
|
---|
[2013] | 776 | ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA))->setOption(IsDlgButtonChecked(Dialog, dirpath_OPTION) == BST_CHECKED);
|
---|
[1765] | 777 | if (HIWORD(wParam) == BN_CLICKED && false)
|
---|
[1543] | 778 | // don't do the enable/disable these days
|
---|
| 779 | {
|
---|
| 780 | EnableWindow(GetDlgItem(Dialog, dirpath_BROWSE), IsDlgButtonChecked(Dialog, dirpath_OPTION));
|
---|
| 781 | EnableWindow(GetDlgItem(Dialog, dirpath_PATH), IsDlgButtonChecked(Dialog, dirpath_OPTION));
|
---|
| 782 | }
|
---|
| 783 | break;
|
---|
| 784 | }
|
---|
| 785 | break;
|
---|
| 786 |
|
---|
[1536] | 787 | case WM_NOTIFY:
|
---|
[1543] | 788 | switch (((LPNMHDR) lParam)->code)
|
---|
| 789 | {
|
---|
| 790 | case PSN_SETACTIVE:
|
---|
| 791 | {
|
---|
| 792 | dirSelector *selector = ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA));
|
---|
| 793 |
|
---|
| 794 | // bodge to set the dialogue path to the correct value
|
---|
| 795 | if (selector != rootSelector)
|
---|
| 796 | {
|
---|
| 797 | selector->setPath(rootSelector->selectedPath());
|
---|
| 798 | SetDlgItemText(Dialog, dirpath_PATH, selector->selectedPath());
|
---|
| 799 | }
|
---|
| 800 |
|
---|
| 801 | if (selector->isFinal())
|
---|
| 802 | {
|
---|
| 803 | PropSheet_SetWizButtons(GetParent(Dialog), PSWIZB_BACK | PSWIZB_FINISH);
|
---|
| 804 | }
|
---|
| 805 | else
|
---|
| 806 | {
|
---|
| 807 | PropSheet_SetWizButtons(GetParent(Dialog), PSWIZB_BACK | PSWIZB_NEXT);
|
---|
| 808 | }
|
---|
| 809 | }
|
---|
| 810 | break;
|
---|
| 811 |
|
---|
[1536] | 812 | case PSN_KILLACTIVE:
|
---|
[1543] | 813 | break;
|
---|
[1765] | 814 |
|
---|
[1543] | 815 | case PSN_WIZNEXT:
|
---|
| 816 | {
|
---|
| 817 | // note the path from the dialog
|
---|
| 818 | dirSelector *selector = ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA));
|
---|
| 819 | selector->setPathFromEdit(GetDlgItem(Dialog, dirpath_PATH));
|
---|
[1536] | 820 |
|
---|
[1543] | 821 | // create a new FilePath object to check on the proposed destination
|
---|
| 822 | FilePath *path = new FilePath(selector->selectedPath());
|
---|
[1536] | 823 |
|
---|
[1543] | 824 | // if the proposed destination doesn't exist, ask the user whether to
|
---|
| 825 | // create it now. TODO: actually create it if asked!
|
---|
| 826 | if (path->exists() == false)
|
---|
| 827 | {
|
---|
| 828 | char buffer[128];
|
---|
[1584] | 829 |
|
---|
[1536] | 830 | sprintf(buffer, "Directory %s does not exist - create it?", selector->selectedPath());
|
---|
| 831 |
|
---|
[1543] | 832 | // if the user cancelled that, then don't permit them to go to the next
|
---|
| 833 | // page of the wizard
|
---|
[1536] | 834 | if (MessageBox(0, buffer, app_name, MB_YESNO | MB_TOPMOST) == IDNO)
|
---|
[1543] | 835 | {
|
---|
| 836 | delete path;
|
---|
| 837 | SetWindowLong(Dialog, DWL_MSGRESULT, TRUE);
|
---|
| 838 | return TRUE;
|
---|
| 839 | }
|
---|
[1536] | 840 | }
|
---|
[1543] | 841 | delete path;
|
---|
| 842 | }
|
---|
| 843 | break;
|
---|
| 844 |
|
---|
[1536] | 845 | case PSN_WIZFINISH:
|
---|
[1543] | 846 | {
|
---|
| 847 | // Finish the activity now
|
---|
| 848 | config_complete = true;
|
---|
[1536] | 849 | }
|
---|
[1543] | 850 | break;
|
---|
| 851 | }
|
---|
| 852 | break;
|
---|
| 853 | }
|
---|
| 854 | return FALSE;
|
---|
[1536] | 855 | }
|
---|
| 856 |
|
---|
| 857 | void GSInstall_init_propertySheet(PROPSHEETPAGE &ppage, char *prompt, char *optPrompt,
|
---|
[1543] | 858 | char *title, GSInstall &installer, bool isFinal)
|
---|
| 859 | {
|
---|
| 860 | GSInstall_dirPathData *data = new GSInstall_dirPathData;
|
---|
[1536] | 861 |
|
---|
[1543] | 862 | // create the directory Selector
|
---|
| 863 | data->dirSelect = new dirSelector(prompt, optPrompt, title, installer.installPath());
|
---|
[1536] | 864 | data->dirSelect->setFinal(isFinal);
|
---|
| 865 |
|
---|
[1541] | 866 | // if there is no extant root selector, make this it
|
---|
| 867 | if (rootSelector == NULL)
|
---|
[1543] | 868 | {
|
---|
| 869 | rootSelector = data->dirSelect;
|
---|
| 870 | }
|
---|
[1541] | 871 |
|
---|
| 872 | // add this directory selector to the installer
|
---|
[1536] | 873 | installer.addSelectedDir(data->dirSelect);
|
---|
| 874 |
|
---|
[1541] | 875 | // set up the rest of the page
|
---|
[1543] | 876 | ppage.dwSize = sizeof(PROPSHEETPAGE);
|
---|
| 877 | ppage.dwFlags = PSP_USETITLE;
|
---|
| 878 | ppage.hInstance = app_instance;
|
---|
| 879 | ppage.pszTemplate = "getDirPath";
|
---|
| 880 | ppage.pszIcon = 0;
|
---|
| 881 | ppage.pszTitle = app_name;
|
---|
| 882 | ppage.pfnDlgProc = (DLGPROC) GSInstall_dlgproc;
|
---|
| 883 | ppage.lParam = (LPARAM) data->dirSelect;
|
---|
| 884 | ppage.pfnCallback = NULL;
|
---|
[1536] | 885 | }
|
---|
| 886 |
|
---|
| 887 | int CALLBACK GSInstall_wizardProc(HWND dialog, UINT Message, LPARAM lParameter)
|
---|
[1543] | 888 | {
|
---|
| 889 | switch (Message)
|
---|
| 890 | {
|
---|
| 891 | case PSCB_INITIALIZED :
|
---|
| 892 | // Process PSCB_INITIALIZED
|
---|
[1536] | 893 | gsInstall_wizard_centre(dialog);
|
---|
[1543] | 894 | break ;
|
---|
[1536] | 895 |
|
---|
[1543] | 896 | case PSCB_PRECREATE :
|
---|
| 897 | // Process PSCB_PRECREATE
|
---|
| 898 | break ;
|
---|
[1536] | 899 |
|
---|
[1543] | 900 | default :
|
---|
| 901 | // Unknown message
|
---|
| 902 | break ;
|
---|
| 903 | }
|
---|
[1536] | 904 | return 0;
|
---|
| 905 | }
|
---|
| 906 |
|
---|
| 907 | bool GSInstall_init_wizard(GSInstall &install)
|
---|
| 908 | {
|
---|
| 909 | PROPSHEETHEADER pshead;
|
---|
| 910 | PROPSHEETPAGE ppage[2];
|
---|
| 911 | bool reply;
|
---|
| 912 |
|
---|
| 913 | ZeroMemory(&pshead, sizeof(PROPSHEETHEADER));
|
---|
| 914 | pshead.dwSize = sizeof(PROPSHEETHEADER);
|
---|
| 915 | pshead.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_USEHICON | PSH_WIZARD;
|
---|
| 916 | pshead.hwndParent = app_window;
|
---|
| 917 | pshead.hInstance = app_instance;
|
---|
| 918 | pshead.hIcon = NULL;
|
---|
| 919 | pshead.pszCaption = "Greenstone Installer";
|
---|
| 920 | pshead.nPages = 2;
|
---|
| 921 | pshead.nStartPage = 0;
|
---|
| 922 | if (install.installExe == true)
|
---|
| 923 | {
|
---|
| 924 | pshead.ppsp = ppage;
|
---|
| 925 | }
|
---|
| 926 | else // cheat as the executable etc. is already installed
|
---|
[1541] | 927 | {
|
---|
[1536] | 928 | pshead.ppsp = &ppage[1];
|
---|
| 929 | }
|
---|
| 930 | pshead.pfnCallback = GSInstall_wizardProc;
|
---|
| 931 |
|
---|
| 932 | GSInstall_init_propertySheet( ppage[0],
|
---|
| 933 | "Choose a directory to install your "
|
---|
| 934 | "GreenStone software to.", NULL,
|
---|
| 935 | "Select", install, false);
|
---|
| 936 | GSInstall_init_propertySheet(ppage[1],
|
---|
| 937 | "Choose a directory to install the collection "
|
---|
| 938 | "files to.\n\n"
|
---|
| 939 | "You can also choose to install all the collection "
|
---|
| 940 | "files onto your computer hard drive.\n\n"
|
---|
| 941 | "If you do this, you will not have to load the "
|
---|
| 942 | "CD-ROM each time you use your Greenstone software "
|
---|
| 943 | "but more of your hard disk will be used.\n\n"
|
---|
| 944 | "Some collection files must be installed on your "
|
---|
| 945 | "computer.\n\n",
|
---|
| 946 | "Install all collection files",
|
---|
| 947 | "Select", install, true);
|
---|
| 948 |
|
---|
| 949 | reply = (PropertySheet (&pshead) >= 0);
|
---|
| 950 | return reply;
|
---|
| 951 | }
|
---|
| 952 |
|
---|
| 953 | long FAR PASCAL GSInstallWindProc(HWND Window, WORD Message, WPARAM wParameter, LPARAM lParameter)
|
---|
[1541] | 954 | {
|
---|
[1536] | 955 | long reply = 0;
|
---|
| 956 |
|
---|
| 957 | switch(Message)
|
---|
| 958 | {
|
---|
| 959 | case WM_CREATE:
|
---|
| 960 | {
|
---|
| 961 | ShowWindow(Window, SW_MAXIMIZE);
|
---|
| 962 | }
|
---|
| 963 | break;
|
---|
| 964 |
|
---|
| 965 | case WM_COMMAND:
|
---|
| 966 | break;
|
---|
| 967 |
|
---|
| 968 | case WM_USER:
|
---|
[1543] | 969 | {
|
---|
[1545] | 970 | if (strstr(app_cmdLine, "-u") != NULL)
|
---|
| 971 | {
|
---|
[1543] | 972 | // uninstall action
|
---|
[1545] | 973 |
|
---|
[1543] | 974 | // skip past the -u option itself
|
---|
| 975 | char *at = strstr(app_cmdLine, "-u");
|
---|
| 976 | at += strlen("-u");
|
---|
[1545] | 977 |
|
---|
[1543] | 978 | // extract the log file path from the command line
|
---|
| 979 | while (*at == ' ')
|
---|
[1545] | 980 | {
|
---|
[1543] | 981 | at ++;
|
---|
| 982 | }
|
---|
| 983 | string logPathString(at);
|
---|
| 984 | FilePath logPath(logPathString);
|
---|
[2013] | 985 |
|
---|
[1543] | 986 | GSInstall install(true);
|
---|
| 987 | // if we're running in the temporary directory, do the uninstall
|
---|
| 988 | if (install.setUninstall())
|
---|
| 989 | {
|
---|
[1536] | 990 | install.uninstall();
|
---|
[1545] | 991 |
|
---|
[1536] | 992 | // close the log to write back all changes to the log; if the file
|
---|
| 993 | // will be deleted, it must be closed; copying may also fail, so it's
|
---|
| 994 | // safer to close it before doing either.
|
---|
[1638] | 995 | install.recordLog();
|
---|
[1545] | 996 |
|
---|
[1536] | 997 | // if the install is empty, terminate all final items (currently the
|
---|
| 998 | // log and setup executables,
|
---|
| 999 | if (install.isEmpty())
|
---|
| 1000 | {
|
---|
| 1001 | // delete the log file
|
---|
| 1002 | DeleteFile(logPath.cString());
|
---|
[1545] | 1003 |
|
---|
[1536] | 1004 | // get it's parent to find where the gssetup executable will be
|
---|
| 1005 | FilePath *logParent = logPath.parent();
|
---|
[2063] | 1006 | FilePath uninstallPath(*logParent, install.setupExeLeaf());
|
---|
[2013] | 1007 |
|
---|
[1536] | 1008 | // delete the gssetup executable
|
---|
| 1009 | DeleteFile(uninstallPath.cString());
|
---|
[2013] | 1010 |
|
---|
[2063] | 1011 | // kill the original log parent directory if it should have died
|
---|
[2013] | 1012 | if (install.removeFailed(logParent->pathString()))
|
---|
| 1013 | {
|
---|
| 1014 | RemoveDirectory(logParent->cString());
|
---|
| 1015 | }
|
---|
| 1016 |
|
---|
[1536] | 1017 | // dispose of the parent directory information
|
---|
[2013] | 1018 | delete logParent;
|
---|
[1536] | 1019 | }
|
---|
[2013] | 1020 |
|
---|
[1536] | 1021 | // if not, then overwrite the original log with the modified one
|
---|
| 1022 | else
|
---|
| 1023 | {
|
---|
| 1024 | // do nothing - should be changed already!
|
---|
| 1025 | }
|
---|
[1543] | 1026 | }
|
---|
| 1027 | }
|
---|
| 1028 | // install wizard
|
---|
| 1029 | else
|
---|
[1545] | 1030 | {
|
---|
[1543] | 1031 | GSInstall install(false);
|
---|
| 1032 | GSInstall_init_wizard(install);
|
---|
| 1033 | if (config_complete == false)
|
---|
| 1034 | {
|
---|
| 1035 | MessageBox(0, "Install cancelled", app_name, MB_OK);
|
---|
| 1036 | }
|
---|
| 1037 | else
|
---|
[1765] | 1038 | {
|
---|
[1543] | 1039 | // configure the installation
|
---|
| 1040 | install.setDestination();
|
---|
| 1041 | install.setManifest();
|
---|
[1765] | 1042 |
|
---|
| 1043 | install.copyFiles(); // caused page fault; Windows 3.1
|
---|
| 1044 | install.updateProgman(); // caused divide overflow; Windows 3.1
|
---|
[2013] | 1045 | install.updateRegistry();
|
---|
[1543] | 1046 | install.updateProfiles();
|
---|
[1765] | 1047 | install.updateSetupExe(); // caused bomb-out of Windows; 3.1
|
---|
[1584] | 1048 |
|
---|
[1543] | 1049 | // close log
|
---|
[1638] | 1050 | install.recordLog();
|
---|
[1584] | 1051 |
|
---|
[1543] | 1052 | // do further actions
|
---|
| 1053 | install.installNetscape();
|
---|
| 1054 | }
|
---|
[1536] | 1055 | }
|
---|
[1543] | 1056 | DestroyWindow(Window);
|
---|
| 1057 | }
|
---|
| 1058 | break;
|
---|
| 1059 |
|
---|
[1545] | 1060 | case WM_USER + 1:
|
---|
| 1061 | break;
|
---|
| 1062 |
|
---|
[1536] | 1063 | case WM_CLOSE:
|
---|
| 1064 | /*if (!file_ischanged || IDCANCEL != file_query(Window, file_name))*/
|
---|
| 1065 | DestroyWindow(Window);
|
---|
| 1066 | return 0L;
|
---|
[1765] | 1067 |
|
---|
[1536] | 1068 | case WM_DESTROY:
|
---|
| 1069 | {
|
---|
| 1070 | PostQuitMessage(0);
|
---|
| 1071 | }
|
---|
| 1072 | break;
|
---|
[1543] | 1073 |
|
---|
[1536] | 1074 | default:
|
---|
| 1075 | return(DefWindowProc(Window, Message, wParameter, lParameter));
|
---|
| 1076 | }
|
---|
| 1077 | return reply;
|
---|
| 1078 | }
|
---|
| 1079 |
|
---|
| 1080 | void GSInstall_init(HINSTANCE instance, int Show)
|
---|
[1543] | 1081 | {
|
---|
| 1082 | int sx, sy;
|
---|
[1536] | 1083 |
|
---|
[1543] | 1084 | gsInstall_getDesktopExt(&sx, &sy);
|
---|
| 1085 |
|
---|
| 1086 | app_window = CreateWindow("GSInstall:Main", "GreenStone Installer",
|
---|
| 1087 | WS_OVERLAPPEDWINDOW | WS_MAXIMIZE | CS_DBLCLKS,
|
---|
| 1088 | 0, 0,
|
---|
| 1089 | sx, sy,
|
---|
| 1090 | NULL,
|
---|
| 1091 | NULL,
|
---|
| 1092 | app_instance,
|
---|
| 1093 | NULL);
|
---|
[1545] | 1094 |
|
---|
[1543] | 1095 | ShowWindow(app_window, Show);
|
---|
[1545] | 1096 |
|
---|
[1536] | 1097 | PostMessage(app_window, WM_USER, 0, 0L);
|
---|
| 1098 | }
|
---|
| 1099 |
|
---|
| 1100 | void WinClassInit(void)
|
---|
[1545] | 1101 | {
|
---|
[1536] | 1102 | WNDCLASS Class;
|
---|
| 1103 |
|
---|
| 1104 | Class.lpszClassName = "GSInstall:Main";
|
---|
| 1105 | Class.hInstance = app_instance;
|
---|
| 1106 | Class.lpfnWndProc = (WNDPROC) GSInstallWindProc;
|
---|
| 1107 | Class.hCursor = LoadCursor(NULL, IDC_ARROW);
|
---|
| 1108 | Class.hIcon = NULL; //LoadIcon(app_instance, "GSInstall");
|
---|
| 1109 | Class.lpszMenuName = NULL;
|
---|
| 1110 | Class.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE+1);
|
---|
| 1111 | Class.style = 0;
|
---|
| 1112 | Class.cbClsExtra = 0;
|
---|
| 1113 | Class.cbWndExtra = 0;
|
---|
| 1114 | RegisterClass(&Class);
|
---|
| 1115 | }
|
---|
| 1116 |
|
---|
| 1117 | int PASCAL WinMain(HINSTANCE Current,
|
---|
| 1118 | HINSTANCE Previous,
|
---|
| 1119 | LPSTR CmdLine,
|
---|
| 1120 | int CmdShow)
|
---|
[2063] | 1121 | {
|
---|
[1536] | 1122 | MSG msg;
|
---|
| 1123 |
|
---|
[2063] | 1124 | gsPlatform p;
|
---|
[1536] | 1125 |
|
---|
[2063] | 1126 | if (p.isWindows32s())
|
---|
| 1127 | {
|
---|
| 1128 | char filename[512];
|
---|
| 1129 | FilePath *exePath;
|
---|
| 1130 | FilePath *dirPath;
|
---|
| 1131 |
|
---|
| 1132 | // get the filepath of this executable
|
---|
| 1133 | GetModuleFileName(0, filename, 512);
|
---|
| 1134 | exePath = new FilePath(filename);
|
---|
| 1135 |
|
---|
| 1136 | // get the parent (i.e. the folder containing this executable) for the source
|
---|
| 1137 | // folder
|
---|
| 1138 | dirPath = exePath->parent();
|
---|
| 1139 | delete exePath;
|
---|
| 1140 |
|
---|
| 1141 | exePath = new FilePath(dirPath->cString(), "install.log");
|
---|
| 1142 |
|
---|
| 1143 | if (exePath->exists())
|
---|
| 1144 | { app_cmdLine = (char *) malloc(256);
|
---|
| 1145 | lstrcpy(app_cmdLine, "gsetup.exe -u ");
|
---|
| 1146 | lstrcat(app_cmdLine, exePath->cString());
|
---|
| 1147 | }
|
---|
| 1148 | else
|
---|
| 1149 | { app_cmdLine = (char *) malloc(1);
|
---|
| 1150 | app_cmdLine[0] = '\0';
|
---|
| 1151 | }
|
---|
| 1152 |
|
---|
| 1153 | delete exePath;
|
---|
| 1154 | delete dirPath;
|
---|
| 1155 | }
|
---|
| 1156 | else
|
---|
| 1157 | { app_cmdLine = (char *) malloc(lstrlen(CmdLine) + 1);
|
---|
| 1158 | lstrcpy(app_cmdLine, CmdLine);
|
---|
| 1159 | }
|
---|
| 1160 |
|
---|
[1536] | 1161 | app_instance = Current;
|
---|
| 1162 | /* -- init application */
|
---|
| 1163 | if (!Previous)
|
---|
| 1164 | {
|
---|
| 1165 | WinClassInit();
|
---|
| 1166 | InitCommonControls();
|
---|
| 1167 | }
|
---|
[1545] | 1168 |
|
---|
[1536] | 1169 | /* -- init instance */
|
---|
| 1170 | GSInstall_init(Current, CmdShow);
|
---|
[1541] | 1171 |
|
---|
[1536] | 1172 | while (GetMessage(&msg, NULL, 0, 0))
|
---|
| 1173 | {
|
---|
| 1174 | TranslateMessage(&msg);
|
---|
| 1175 | DispatchMessage(&msg);
|
---|
| 1176 | }
|
---|
| 1177 | return (int) msg.wParam;
|
---|
| 1178 | }
|
---|