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