Changeset 1475
- Timestamp:
- 2000-08-31T00:42:59+12:00 (24 years ago)
- Location:
- trunk/gsinstaller
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsinstaller/FilePath.cpp
r1397 r1475 103 103 this->path = filePath; 104 104 105 // if it didn't have a concluding divider, then add one 106 if (this->path[filePath.length()-1] != divider) 105 // if it didn't have a concluding divider, then add one; note that if 106 // filePath is empty, we're not actually going to add any divider at 107 // all 108 if (filePath.length() > 0 && 109 this->path[filePath.length()-1] != divider) 107 110 { this->path.append(dividerStr); 108 111 } -
trunk/gsinstaller/configFile.cpp
r1397 r1475 43 43 space -= strlen(configstr->item[loop].data); 44 44 return true; 45 } 46 47 string configureFile::getString(string label) 48 { for (int loop = 0; loop < configstr->count; loop ++) 49 { if (strcmp(configstr->item[loop].label, label.c_str()) == 0) 50 { return configstr->item[loop].data; 51 } 52 } 53 return ""; 45 54 } 46 55 … … 88 97 } 89 98 90 bool configureFile::scan(char *block, unsigned int &pos) 99 /** 100 * Scan one line of the configuration file 101 */ 102 bool configureFile::scan(char *block, unsigned int &pos, unsigned int length) 91 103 { int off = 0; 92 104 void *newstr; 93 105 106 if (pos == length) 107 { return true; 108 } 109 110 // if it's a comment line, skip it straightaway 111 if (block[pos] == '#') 112 { while (block[pos] >= ' ') 113 { block ++; 114 } 115 while (block[pos] < ' ') 116 { block ++; 117 if (block[pos-1] == '\0') 118 { break; 119 } 120 } 121 return true; 122 } 123 124 // otherwise create a new struct to cope with the list of configuration items 94 125 newstr = realloc(configstr, sizeof(config_str) + 95 126 sizeof(config_item) * configstr->count); … … 101 132 configstr = (config_str *) newstr; 102 133 103 while (block[pos] != ':') 134 // scan to the colon to get the label 135 while (pos < length && block[pos] != ':') 104 136 { configstr->item[configstr->count].label[off] = block[pos]; 105 137 off ++; … … 108 140 configstr->item[configstr->count].label[off] = '\0'; 109 141 142 // read until we get past any leading whitespace or tabs 110 143 off = 0; 111 do 112 { pos ++; 113 } while (block[pos] <= ' ' && block[pos] != '\x0a' && block[pos] != '\x0d'); 114 115 while(block[pos] >= ' ') 144 if (pos < length) 145 { do 146 { pos ++; 147 } 148 while (block[pos] <= ' ' && block[pos] != '\x0a' && block[pos] != '\x0d'); 149 } 150 151 // read until we reach a "magic" character - this is where we read the value 152 while(pos < length && block[pos] >= ' ') 116 153 { configstr->item[configstr->count].data[off] = block[pos]; 117 154 pos ++; … … 120 157 configstr->item[configstr->count].data[off] = '\0'; 121 158 122 do 123 { pos ++; 124 } 125 while (block[pos] <= ' '); 126 159 // skip any magic characters 160 if (pos < length) 161 { do 162 { pos ++; 163 } 164 while (block[pos] <= ' ' && pos < length); 165 } 166 167 // remember that we've added to the list 127 168 configstr->count ++; 128 169 return true; … … 190 231 position = 0; 191 232 while (position < length) 192 { this->scan(block, position );233 { this->scan(block, position, length); 193 234 } 194 235 195 236 fclose(fhandle); 237 238 free(block); 239 240 this->valid = true; 196 241 } 197 242 else 198 243 { // No config file MessageBox(0, "oops", "oops", MB_OK); 199 } 200 201 free(block); 244 this->valid = false; 245 } 202 246 //Acorn: free(varval); 203 247 204 this->valid = true;205 248 } 206 249 -
trunk/gsinstaller/configFile.h
r1397 r1475 1 1 #ifndef _CONFIG_H_ 2 2 #define _CONFIG_H_ 3 #include <string> 4 using namespace std; 5 3 6 #include <stdio.h> 4 7 #include <string.h> … … 22 25 bool valid; 23 26 24 bool scan(char *buffer, unsigned int &pos );27 bool scan(char *buffer, unsigned int &pos, unsigned int length); 25 28 public: 26 29 configureFile(char *name); … … 28 31 bool put(char *label, char *value); 29 32 bool concat(char *label, char *buffer, unsigned int &space); 33 string getString(string label); 30 34 void get(char *label, char **to); 31 35 bool store(char *); -
trunk/gsinstaller/copyProgress.cpp
r1397 r1475 7 7 8 8 extern HINSTANCE app_instance; 9 extern gsInstall_getDesktopExt(int *x, int *y); 9 10 10 11 LRESULT CALLBACK copyProgressBar_windowProc( HWND window, UINT message, … … 85 86 void copyProgressBar::show() 86 87 { long params[2]; 88 int sx, sy, dx, dy; 87 89 88 90 params[0] = (long) this; 89 91 params[1] = (long) "Copying files...."; 90 92 this->registerClass(); 91 this->progressParent = CreateWindowEx(WS_EX_APPWINDOW, "CopyProgressBar", "GreenStone Installer", WS_VISIBLE, 92 CW_USEDEFAULT, CW_USEDEFAULT, 200, 80, 0, (HMENU) 0, 93 app_instance, (void *) params); 93 94 gsInstall_getDesktopExt(&sx, &sy); 95 96 dx = (sx - 200) >> 1; 97 dy = (sy - 80) >> 1; 98 99 this->progressParent = CreateWindowEx( WS_EX_APPWINDOW, "CopyProgressBar", 100 "GreenStone Installer", WS_VISIBLE, 101 dx, dy, 200, 80, 102 0, (HMENU) 0, 103 app_instance, (void *) params); 94 104 this->progressBar = CreateWindowEx(0, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE, 95 10, 30, 180, GetSystemMetrics(SM_CYVSCROLL), this->progressParent, (HMENU) 0, 105 10, 30, 180, GetSystemMetrics(SM_CYVSCROLL), 106 this->progressParent, (HMENU) 0, 96 107 app_instance, NULL); 97 108 } -
trunk/gsinstaller/fileCopier.cpp
r1397 r1475 14 14 this->sourceDir = from; 15 15 this->destDir = to; 16 this->dataSize = 0; 16 17 17 18 FileVector::iterator here = files.begin(); … … 43 44 * Copy a particular file to its destination 44 45 */ 45 bool fileCopySet::copyFile(File *file, copyProgressBar &progressBar)46 bool fileCopySet::copyFile(File *file, fileCopyMonitor *monitor, copyProgressBar &progressBar) 46 47 { unsigned long copied = 0; 47 48 unsigned long bytes_read, bytes_written; … … 89 90 90 91 // free destination filename text 92 if (monitor != NULL) 93 { monitor->copied(file->getFileName(), destination, false); 94 } 91 95 delete destination; 92 96 return true; … … 97 101 * destination 98 102 */ 99 void fileCopySet::copy(File *file, copyProgressBar &progressBar)103 void fileCopySet::copy(File *file, fileCopyMonitor *monitor, copyProgressBar &progressBar) 100 104 { // just skip this file if it doesn't exist 101 105 if (file->exists() == false) … … 116 120 vector<File>::iterator end = file->childEnd(); 117 121 while (here != end) 118 { this->copy(here, progressBar);122 { this->copy(here, monitor, progressBar); 119 123 here ++; 120 124 } 125 126 if (monitor != NULL) 127 { monitor->copied(file->getFileName(), thisDestDir, true); 128 } 121 129 122 130 // delete constructed destination name … … 126 134 else 127 135 { // copy file itself 128 this->copyFile(file, progressBar);136 this->copyFile(file, monitor, progressBar); 129 137 } 130 138 progressBar.done(file->getRawFileSize()); 131 139 } 132 140 133 void fileCopySet::copy( copyProgressBar &progressBar)141 void fileCopySet::copy(fileCopyMonitor *monitor, copyProgressBar &progressBar) 134 142 { FileVector::iterator here = fileList.begin(); 135 143 FileVector::iterator end = fileList.end(); 136 144 137 145 while (here != end) 138 { this->copy(here, progressBar);146 { this->copy(here, monitor, progressBar); 139 147 here ++; 140 148 } … … 173 181 174 182 // get destination root and use it to obtain space check information 175 char buffer[120];176 183 FilePath *destRoot = localSet[0].destDir.root(); 177 strcpy(buffer, destRoot->cString());178 MessageBox(0, buffer, "A", MB_OK);179 184 DiskSpace space(destRoot->cString()); 180 185 … … 230 235 } 231 236 232 fileCopier::fileCopier(fileCopy SetList &_list)237 fileCopier::fileCopier(fileCopyMonitor *monitor, fileCopySetList &_list) 233 238 { this->list = _list; 234 239 this->dataSize = 0; 235 240 this->copied = 0; 236 } 237 238 fileCopier::fileCopier() 241 this->monitor = monitor; 242 } 243 244 fileCopier::fileCopier(fileCopyMonitor *monitor) 239 245 { this->dataSize = 0; 240 246 this->copied = 0; 247 this->monitor = monitor; 241 248 } 242 249 … … 247 254 this->progressBar.show(); 248 255 while (here != end) 249 { here->copy(this-> progressBar);256 { here->copy(this->monitor, this->progressBar); 250 257 here ++; 251 258 } -
trunk/gsinstaller/fileCopier.h
r1397 r1475 4 4 #include "copyProgress.h" 5 5 #include "diskSpace.h" 6 7 class fileCopyMonitor 8 { public: 9 fileCopyMonitor() {}; 10 virtual void copied(string from, string to, bool isDir) = 0; 11 }; 6 12 7 13 class fileCopySet … … 17 23 unsigned long getOriginalSize(); 18 24 unsigned long getCopiedSize(DiskSpace &space); 19 bool copyFile(File *file, copyProgressBar &progressBar);20 void copy(File *file, copyProgressBar &progressBar);21 void copy( copyProgressBar &progressBar);25 bool copyFile(File *file, fileCopyMonitor *monitor, copyProgressBar &progressBar); 26 void copy(File *file, fileCopyMonitor *monitor, copyProgressBar &progressBar); 27 void copy(fileCopyMonitor *monitor, copyProgressBar &progressBar); 22 28 }; 23 29 … … 30 36 unsigned long copied; 31 37 copyProgressBar progressBar; 38 fileCopyMonitor *monitor; 32 39 protected: 33 40 public: 34 fileCopier::fileCopier(fileCopy SetList &list);35 fileCopier::fileCopier( );41 fileCopier::fileCopier(fileCopyMonitor *monitor, fileCopySetList &list); 42 fileCopier::fileCopier(fileCopyMonitor *monitor); 36 43 void fileCopier::addSet(fileCopySet &set) { this->list.push_back(set); } 37 44 bool checkSpace(); -
trunk/gsinstaller/gsManifest.cpp
r1397 r1475 1 1 #include "gsManifest.h" 2 #include "fileCopier.h"3 2 4 3 #include <string.h> … … 7 6 #include <windows.h> 8 7 9 gsManifest::gsManifest(FilePath &root) 8 gsManifest::gsManifest(installManager &manager) 9 : installAgent(manager) 10 { // do nothing! 11 } 12 13 gsManifest::gsManifest(installManager &manager, FilePath &root) 14 : installAgent(manager), fileCopyMonitor() 10 15 { this->getManifest(root); 11 16 this->expandGroups(); … … 87 92 group = newgroup; 88 93 } 94 // if it starts with a hash it's just a comment line; skip it 95 else if (*line == '#') 96 { // do nothing! 97 } 98 // an actual line of member items; read them in 89 99 else 90 100 { stringArray array; … … 186 196 } 187 197 188 void gsManifest::selectGroup(string &groupName, FilePath &destination)198 void gsManifest::selectGroup(string groupName, FilePath &destination) 189 199 { stringArray &groupArray = this->manifests[groupName]; 190 200 … … 193 203 } 194 204 205 /** 206 * Copy the manifest 207 */ 195 208 bool gsManifest::copy(FilePath *source) 196 { fileCopier copy ;209 { fileCopier copy(this); 197 210 198 211 pathStringArrayMap::iterator here = this->selected.begin(); 199 212 pathStringArrayMap::iterator end = this->selected.end(); 200 213 214 // add all the sets to copy to the manifest 201 215 while (here != end) 202 216 { FileVector *fileList; … … 205 219 206 220 // TODO: eliminate inefficiency; we're doing FilePath->string->FilePath in 207 // effect between constructing the copy lists, and then the sets as far221 // effect between constructing the copy lists, and then the sets, as far 208 222 // as the destinations go 209 fileList = this->selection( array);223 fileList = this->selection(*source, array); 210 224 fileCopySet copySet(*fileList, *source, path); 211 225 copy.addSet(copySet); … … 214 228 } 215 229 230 // check that we've got enough space @ the destination(s) 216 231 if (!copy.checkSpace()) 217 232 { return false; 218 233 } 234 235 // do the actual copying 219 236 copy.copy(); 220 237 return true; 221 238 } 222 239 223 FileVector *gsManifest::selection(stringArray &array) 240 void gsManifest::copied(string from, string to, bool isDir) 241 { if (isDir) 242 { this->logAction("Manifest.CreateDir", to); 243 } 244 else 245 { this->logAction("Manifest.CopyFile", from, to); 246 } 247 } 248 249 void gsManifest::logAction(string actionName, string file) 250 { manager->writeString(actionName); 251 manager->writeSeparator(); 252 manager->writeString(file); 253 manager->writeString("\n"); 254 } 255 256 void gsManifest::logAction(string actionName, string source, string dest) 257 { manager->writeString(actionName); 258 manager->writeSeparator(); 259 manager->writeString(source); 260 manager->writeSeparator(); 261 manager->writeString(dest); 262 manager->writeString("\n"); 263 } 264 265 bool gsManifest::undoAction(string actionName, stringArray ¶ms) 266 { if (actionName == "Manifest.CreateDir" || actionName == "CreateDir") 267 { RemoveDirectory(params[0].c_str()); 268 return true; 269 } 270 else if (actionName == "Manifest.CopyFile" || actionName == "CopyFile") 271 { DeleteFile(params[1].c_str()); 272 return true; 273 } 274 return false; 275 } 276 277 FileVector *gsManifest::selection(FilePath &root, stringArray &array) 224 278 { FileVector *reply = new FileVector(); 225 279 226 280 for (unsigned int i = 0; i < array.size(); i++) 227 { File file(array[i]); 281 { FilePath fileName(root.pathString(), array[i]); 282 File file(fileName.pathString()); 228 283 reply->push_back(file); 229 284 } … … 231 286 } 232 287 233 FileVector *gsManifest::selection(FilePath & destination)234 { return this->selection( this->selected[destination]);235 } 236 288 FileVector *gsManifest::selection(FilePath &source, FilePath &destination) 289 { return this->selection(source, this->selected[destination]); 290 } 291 -
trunk/gsinstaller/gsManifest.h
r1397 r1475 6 6 #include "File.h" 7 7 #include "FilePath.h" 8 #include "FileCopier.h" 8 9 #include "stringArray.h" 10 #include "uninstall.h" 9 11 10 12 typedef map<FilePath, stringArray, less<FilePath> > pathStringArrayMap; 11 13 12 class gsManifest 14 class gsManifest : public installAgent, fileCopyMonitor 13 15 { private: 14 16 protected: 15 17 strArrayMap manifests; 16 18 pathStringArrayMap selected; 19 20 bool getManifestLine(char *line, string ¯o); 17 21 public: 18 gsManifest(FilePath &path); 22 gsManifest(installManager &manager, FilePath &path); // used for install 23 gsManifest(installManager &manager); // used for uninstall 19 24 bool getManifest(FilePath &path); 20 bool getManifestLine(char *line, string ¯o); 25 void logAction(string actionName, string file); 26 void logAction(string actionName, string source, string dest); 27 bool undoAction(string actionName, stringArray ¶ms); 21 28 void expandGroupInstance(string parent, string child); 22 29 void expandGroup(string &group); … … 26 33 void clearSelection(); 27 34 bool copy(FilePath *source); 28 void selectGroup(string &groupName, FilePath &destination);29 FileVector *selection( stringArray &array);30 FileVector *selection(FilePath & destination);35 void selectGroup(string groupName, FilePath &destination); 36 FileVector *selection(FilePath &source, stringArray &array); 37 FileVector *selection(FilePath &source, FilePath &destination); 31 38 bool selectCheckSpace(); 39 40 void copied(string from, string to, bool isDir); // from fileCopyMonitor 32 41 }; 33 42 #endif; -
trunk/gsinstaller/gsProfile.cpp
r1397 r1475 2 2 3 3 #include <stdio.h> 4 #include "stringArray.h"5 4 6 gsProfile::gsProfile(const char *fileName) 5 gsProfile::gsProfile(installManager &manager, string fileName) 6 : installAgent(manager) 7 7 { this->fileName = fileName; 8 8 } 9 9 10 bool gsProfile::ensureListMember(const char *sectionName, const char *listName, 11 const char *listMember) 10 void gsProfile::logAction(string action, string sectionName, string item, 11 string value) 12 { manager->writeString(action); 13 manager->writeSeparator(); 14 manager->writeString(this->fileName); 15 manager->writeSeparator(); 16 manager->writeString(sectionName); 17 manager->writeSeparator(); 18 manager->writeString(item); 19 manager->writeSeparator(); 20 manager->writeString(value); 21 manager->writeString("\n"); 22 } 23 24 bool gsProfile::undoAction(string actionName, stringArray ¶ms) 25 { if (actionName == "ProfileAddListMember") 26 { this->removeListMember(params[0], params[1], params[2]); 27 return true; 28 } 29 return false; 30 } 31 32 bool gsProfile::ensureListMember(string sectionName, string listName, 33 string listMember) 12 34 { char buffer[256] = "\0"; 13 35 stringArray *members; 36 bool reply = true; 14 37 15 if (GetPrivateProfileString(sectionName , listName, "",16 buffer, 256, this->fileName ) <= 0)38 if (GetPrivateProfileString(sectionName.c_str(), listName.c_str(), "", 39 buffer, 256, this->fileName.c_str()) <= 0) 17 40 { buffer[0] = '\0'; 18 41 } … … 22 45 { members->add(listMember); 23 46 members->writeToCString(buffer, ";", 256); 24 delete members; 25 return WritePrivateProfileString(sectionName, listName, buffer, this->fileName); 47 48 reply = this->writeString(sectionName, listName, buffer); 49 if (reply) 50 { this->logAction("ProfileAddListMember", sectionName, listName, listMember); 51 } 26 52 } 27 53 delete members; 28 return true;54 return reply; 29 55 } 30 56 31 bool gsProfile::addListMember( const char *sectionName, const char *listName, const char *listMember)57 bool gsProfile::addListMember(string sectionName, string listName, string listMember) 32 58 { char buffer[256]; 33 59 stringArray *members; 34 60 35 GetPrivateProfileString(sectionName , listName, "",36 buffer, 256, this->fileName );61 GetPrivateProfileString(sectionName.c_str(), listName.c_str(), "", 62 buffer, 256, this->fileName.c_str()); 37 63 // straightforward, unthinking, add 38 64 members = new stringArray(buffer, ";"); … … 40 66 members->writeToCString(buffer, ";", 256); 41 67 delete members; 42 return WritePrivateProfileString(sectionName, listName, buffer, this->fileName);68 return this->writeString(sectionName, listName, buffer); 43 69 } 44 70 45 bool gsProfile::removeListMember( const char *sectionName, const char *listName, const char *listMember)71 bool gsProfile::removeListMember(string sectionName, string listName, string listMember) 46 72 { char buffer[256]; 47 73 stringArray *members; 48 74 49 GetPrivateProfileString(sectionName , listName, "",50 buffer, 256, this->fileName );75 GetPrivateProfileString(sectionName.c_str(), listName.c_str(), "", 76 buffer, 256, this->fileName.c_str()); 51 77 // straightforward, unthinking, removal - if it isn't there, we won't need to 52 78 // worry! … … 56 82 delete members; 57 83 58 return WritePrivateProfileString(sectionName, listName, buffer, this->fileName);84 return this->writeString(sectionName, listName, buffer); 59 85 } 60 86 61 bool gsProfile::writeString(const char *sectionName, const char *itemName, const char *itemValue) 62 { if (!WritePrivateProfileString(sectionName, itemName, itemValue, this->fileName)) 87 bool gsProfile::writeString(string sectionName, string itemName, string itemValue) 88 { if (!WritePrivateProfileString( sectionName.c_str(), itemName.c_str(), 89 itemValue.c_str(), this->fileName.c_str())) 63 90 { DWORD error = GetLastError(); 64 91 char buffer[20]; -
trunk/gsinstaller/gsProfile.h
r1397 r1475 1 1 #ifndef _GSPROFILE_H_ 2 2 #define _GSPROFILE_H_ 3 #include <string> 4 using namespace std; 3 5 #include <windows.h> 4 class gsProfile 6 7 #include "uninstall.h" 8 #include "stringarray.h" 9 10 class gsProfile : public installAgent 5 11 { 6 12 private: 7 const char *fileName; 13 string fileName; 14 15 void logAction(string action, string sectionName, string item, string value); 8 16 protected: 9 17 public: 10 gsProfile(const char *fileName); 11 bool ensureListMember(const char *sectionName, const char *listName, const char *listMember); 12 bool removeListMember(const char *sectionName, const char *listName, const char *listMember); 13 bool addListMember(const char *sectionName, const char *listName, const char *listMember); 14 bool writeString(const char *sectionName, const char *itemName, const char *itemValue); 18 gsProfile(installManager &manager, string fileName); 19 bool ensureListMember(string sectionName, string listName, string listMember); 20 bool removeListMember(string sectionName, string listName, string listMember); 21 bool addListMember(string sectionName, string listName, string listMember); 22 bool writeString(string sectionName, string itemName, string itemValue); 23 bool undoAction(string actionName, stringArray ¶ms); 15 24 }; 16 25 #endif -
trunk/gsinstaller/gsProgman.cpp
r1397 r1475 80 80 } 81 81 82 gsProgramManager::gsProgramManager() 82 gsProgramManager::gsProgramManager(installManager &manager) 83 : installAgent(manager) 83 84 { this->platform = new gsPlatform(); 84 85 this->connected = false; 86 } 87 88 void gsProgramManager::logAction(string actionName, string group) 89 { manager->writeString(actionName); 90 manager->writeSeparator(); 91 manager->writeString(group); 92 manager->writeString("\n"); 93 } 94 95 void gsProgramManager::logAction(string actionName, string group, string item, string parameter) 96 { manager->writeString(actionName); 97 manager->writeSeparator(); 98 manager->writeString(group); 99 manager->writeSeparator(); 100 manager->writeString(item); 101 manager->writeSeparator(); 102 manager->writeString(parameter); 103 manager->writeString("\n"); 104 } 105 106 bool gsProgramManager::undoAction(string actionName, stringArray ¶ms) 107 { if (actionName == "ProgManCreateGroup") 108 { this->removeProgramGroup(params[0]); 109 return true; 110 } 111 else if (actionName == "ProgManAddIcon") 112 { this->removeIcon(params[0], params[1]); 113 return true; 114 } 115 return false; 85 116 } 86 117 … … 123 154 } 124 155 125 bool gsProgramManager::addProgramGroup( const char *groupName)156 bool gsProgramManager::addProgramGroup(string groupName) 126 157 { //CreateGroup(groupName); 127 158 char buffer[256]; … … 147 178 else 148 179 { // add using program manager DDE 149 sprintf(buffer, "[CreateGroup (%s)]", groupName );180 sprintf(buffer, "[CreateGroup (%s)]", groupName.c_str()); 150 181 if (!DDEShellCommand(this->instance, buffer)) 151 182 { // flag error by returning false … … 153 184 } 154 185 } 186 187 this->logAction("ProgManCreateGroup", groupName); 155 188 return true; 156 189 } 157 190 158 bool gsProgramManager::addIcon( const char *groupName, // group of the icon159 const char *iconName,// name of the icon160 const char *iconDestination,// destination file of the icon161 const char *description)// the textual description162 191 bool gsProgramManager::addIcon( string groupName, // group of the icon 192 string iconName, // name of the icon 193 string iconDestination, // destination file of the icon 194 string description) // the textual description 195 // of the icon (not usually displayed) 163 196 { bool reply = false; 164 197 char buffer[MAX_PATH]; … … 176 209 177 210 SHGetPathFromIDList(pidl, buffer); 178 fullPath = new FilePath(4, buffer, groupName , iconName, "!.lnk");211 fullPath = new FilePath(4, buffer, groupName.c_str(), iconName.c_str(), ".lnk"); 179 212 180 213 // Get a pointer to the IShellLink interface. … … 186 219 // Set the path to the shortcut target, and add the 187 220 // description. 188 psl->SetPath(iconDestination );189 190 psl->SetDescription(description );221 psl->SetPath(iconDestination.c_str()); 222 223 psl->SetDescription(description.c_str()); 191 224 192 225 // Query IShellLink for the IPersistFile interface for saving the … … 214 247 // ensure that the requisite group is active; the add icon command will 215 248 // use the active group. 216 sprintf(buffer, "[ShowGroup(%s,5)]", groupName );249 sprintf(buffer, "[ShowGroup(%s,5)]", groupName.c_str()); 217 250 if (!DDEShellCommand(this->instance, buffer)) 218 251 { // TODO: articulate/determine possible errors; expand error handling … … 221 254 222 255 // and now add the item itself to the active (given) group 223 sprintf(buffer, "[AddItem(%s,%s)]", iconDestination , iconName);256 sprintf(buffer, "[AddItem(%s,%s)]", iconDestination.c_str(), iconName.c_str()); 224 257 if (!DDEShellCommand(this->instance, buffer)) 225 258 { // TODO: again work out what the problems could be … … 228 261 reply = true; 229 262 } 263 264 if (reply) 265 { this->logAction("ProgManAddItem", groupName, iconName, iconDestination); 266 } 230 267 return reply; 231 268 } 232 269 233 bool gsProgramManager::removeProgramGroup( const char *groupName)270 bool gsProgramManager::removeProgramGroup(string groupName) 234 271 { //CreateGroup(groupName); 235 272 char buffer[256]; … … 255 292 else 256 293 { // add using program manager DDE 257 sprintf(buffer, "[DeleteGroup (%s)]", groupName );294 sprintf(buffer, "[DeleteGroup (%s)]", groupName.c_str()); 258 295 if (!DDEShellCommand(this->instance, buffer)) 259 296 { // flag error by returning false … … 264 301 } 265 302 266 bool gsProgramManager::removeIcon( const char *groupName, // group of the icon267 const char *iconName) // name of the icon303 bool gsProgramManager::removeIcon(string groupName, // group of the icon 304 string iconName) // name of the icon 268 305 { bool reply = false; 269 306 char buffer[MAX_PATH]; … … 281 318 282 319 SHGetPathFromIDList(pidl, buffer); 283 fullPath = new FilePath(4, buffer, groupName , iconName, "!.lnk");320 fullPath = new FilePath(4, buffer, groupName.c_str(), iconName.c_str(), "!.lnk"); 284 321 285 322 // TODO: delete file … … 290 327 // ensure that the requisite group is active; the add icon command will 291 328 // use the active group. 292 sprintf(buffer, "[ShowGroup(%s,5)]", groupName );329 sprintf(buffer, "[ShowGroup(%s,5)]", groupName.c_str()); 293 330 if (!DDEShellCommand(this->instance, buffer)) 294 331 { // TODO: articulate/determine possible errors; expand error handling … … 297 334 298 335 // and now add the item itself to the active (given) group 299 sprintf(buffer, "[DeleteItem(%s)]", iconName );336 sprintf(buffer, "[DeleteItem(%s)]", iconName.c_str()); 300 337 if (!DDEShellCommand(this->instance, buffer)) 301 338 { // TODO: again work out what the problems could be -
trunk/gsinstaller/gsProgman.h
r1397 r1475 4 4 5 5 #include "gsPlatform.h" 6 #include "uninstall.h" 7 #include "stringArray.h" 6 8 7 class gsProgramManager 9 class gsProgramManager : public installAgent 8 10 { 9 11 private: … … 11 13 DWORD instance; 12 14 bool connected; 15 16 void logAction(string actionName, string group); 17 void logAction(string actionName, string group, string item, string parameter); 13 18 protected: 14 19 public: 15 20 // constructor 16 gsProgramManager( );21 gsProgramManager(installManager &manager); 17 22 18 23 // connect/disconnect activity … … 20 25 bool disconnect(); 21 26 22 bool addProgramGroup(const char *name); 23 bool removeProgramGroup(const char *name); 24 bool addIcon( const char *groupName, const char *iconName, const char *iconDestination, 25 const char *description); 26 bool removeIcon( const char *groupName, const char *iconName); 27 bool addProgramGroup(string name); 28 bool removeProgramGroup(string name); 29 bool addIcon( string groupName, string iconName, string iconDestination, 30 string description); 31 bool removeIcon( string groupName, string iconName); 32 33 bool undoAction(string actionName, stringArray ¶ms); 27 34 }; 28 35 #endif -
trunk/gsinstaller/gsRegistry.cpp
r1397 r1475 1 1 #include "gsRegistry.h" 2 2 3 gsRegistry::gsRegistry(configureFile &configFile) 3 gsRegistry::gsRegistry(installManager &manager, configureFile &configFile) 4 : installAgent(manager) 4 5 { unsigned int space; 5 6 6 7 // Create string for volume key 7 strcpy(volumeKey, "Software\\"); 8 space = 255 - strlen(volumeKey); 9 10 configFile.concat("CompanyName", volumeKey, space); 11 strcat(volumeKey, "\\"); 12 configFile.concat("CollectionName", volumeKey, space); 13 strcat(volumeKey, "\\"); 14 configFile.concat("CollectionVolume", volumeKey, space); 15 strcat(volumeKey, "\\"); 16 configFile.concat("CollectionVersion", volumeKey, space); 8 volumeKey = "Software\\" + configFile.getString("CompanyName") + "\\" + 9 configFile.getString("CollectionName") + "\\" + 10 configFile.getString("CollectionVolume") + "\\" + 11 configFile.getString("CollectionVersion"); 17 12 18 13 // Create string for collection key 19 strcpy(collectKey, "Software\\"); 20 space = 255 - strlen(collectKey); 21 22 configFile.concat("CompanyName", collectKey, space); 23 strcat(collectKey, "\\"); 24 configFile.concat("CollectionName", collectKey, space); 25 strcat(collectKey, "\\"); 26 configFile.concat("CollectionVersion", collectKey, space); 14 collectKey = "Software\\" + configFile.getString("CompanyName") + "\\" + 15 configFile.getString("CollectionName") + "\\" + 16 configFile.getString("CollectionVersion"); 27 17 } 28 18 29 bool gsRegistry::ensureKeysExist() 30 { if (registry_ensureKeyExists(HKEY_LOCAL_MACHINE, this->collectKey) == false) 31 { return false; 19 bool gsRegistry::logAction(string action, HKEY base, string path, string item, string value) 20 { manager->writeString(action); 21 manager->writeSeparator(); 22 manager->writeString(path); 23 if (item != "" || value != "") 24 { manager->writeSeparator(); 25 if (item == "") 26 { manager->writeString("{Default}"); 27 } 28 else 29 { manager->writeString(item); 30 } 31 manager->writeSeparator(); 32 manager->writeString(value); 32 33 } 33 if (registry_ensureKeyExists(HKEY_LOCAL_MACHINE, this->volumeKey) == false) 34 { return false; 34 manager->writeString("\n"); 35 } 36 37 bool gsRegistry::undoAction(string actionName, stringArray ¶ms) 38 { if (actionName == "RegistryCreateKey") 39 { this->destroyKey(HKEY_LOCAL_MACHINE, params[0]); 40 } 41 else if (actionName == "RegistrySetString") 42 { this->destroyItem(HKEY_LOCAL_MACHINE, params[0], params[1]); 43 } 44 else 45 { return false; 35 46 } 36 47 return true; 37 48 } 38 49 39 bool gsRegistry::ensureKeyExists(HKEY base, const char *key) 40 { return(registry_ensureKeyExists(base, key)); 50 bool gsRegistry::ensureKeysExist() 51 { if (!this->ensureKeyExists(HKEY_LOCAL_MACHINE, this->collectKey)) 52 { return false; 53 } 54 return this->ensureKeyExists(HKEY_LOCAL_MACHINE, this->volumeKey); 41 55 } 42 56 43 bool gsRegistry::storeKeyString(HKEY base, const char *path, const char *item, const char *string) 57 bool gsRegistry::ensureKeyExists(HKEY base, string key) 58 { if (!registry_keyExists(base, key.c_str())) 59 { if (!registry_ensureKeyExists(base, key.c_str())) 60 { return false; 61 } 62 this->logAction("RegistryCreateKey", base, key, "", ""); 63 } 64 return true; 65 } 66 67 bool gsRegistry::destroyKey(HKEY base, string key) 68 { registry_deletekey(base, key.c_str()); 69 } 70 71 bool gsRegistry::storeKeyString(HKEY base, string path, string item, string value) 44 72 { HKEY local; 45 73 bool reply; 46 74 47 if (!registry_openkey(base, (char *) path, &local))75 if (!registry_openkey(base, path.c_str(), &local)) 48 76 { return false; 49 77 } 50 reply = registry_setstring(local, item, string); 78 reply = registry_setstring(local, item.c_str(), value.c_str()); 79 if (reply) 80 { this->logAction("RegistrySetString", base, path, item, value); 81 } 51 82 registry_closekey(local); 52 83 return reply; 53 84 } 54 85 86 bool gsRegistry::destroyItem(HKEY base, string path, string item) 87 { HKEY local; 88 89 if (!registry_openkey(base, path.c_str(), &local)) 90 { return false; 91 } 92 registry_deleteitem(local, item.c_str()); 93 registry_closekey(local); 94 } 95 55 96 bool gsRegistry::collectionInstalled() 56 { return registry_keyExists(HKEY_LOCAL_MACHINE, this->collectKey );97 { return registry_keyExists(HKEY_LOCAL_MACHINE, this->collectKey.c_str()); 57 98 } 58 99 59 100 bool gsRegistry::volumeInstalled() 60 { return registry_keyExists(HKEY_LOCAL_MACHINE, this->volumeKey );101 { return registry_keyExists(HKEY_LOCAL_MACHINE, this->volumeKey.c_str()); 61 102 } 62 103 63 char *gsRegistry::collectKeyId()104 string gsRegistry::collectKeyId() 64 105 { return this->collectKey; 65 106 } 66 107 67 char *gsRegistry::volumeKeyId()108 string gsRegistry::volumeKeyId() 68 109 { return this->volumeKey; 69 110 } 70 111 71 char *gsRegistry::exeKeyId(char *exename) 72 { char *reply = new char[256]; 112 string gsRegistry::exeKeyId(string exename) 113 { string reply = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\"; 114 reply += exename; 115 return reply; 116 } 73 117 74 // Create string for exe path 75 strcpy(reply, "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\"); 76 strcat(reply, exename); 77 return reply; 118 string gsRegistry::uninstallKeyId(string collectName) 119 { return "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + collectName; 78 120 } 79 121 … … 83 125 HKEY key; 84 126 85 if (registry_openkey(HKEY_LOCAL_MACHINE, this->collectKey , &key))127 if (registry_openkey(HKEY_LOCAL_MACHINE, this->collectKey.c_str(), &key)) 86 128 { if (registry_getstring(key, "library", &path)) 87 129 { // get leaf (\library.exe) and remove it to give a path -
trunk/gsinstaller/gsRegistry.h
r1397 r1475 1 1 #ifndef _GSREGISTRY_H_ 2 2 #define _GSREGISTRY_H_ 3 #include <string> 4 using namespace std; 5 3 6 #include "registry.h" 4 7 #include "configFile.h" 5 8 #include "FilePath.h" 9 #include "uninstall.h" 10 #include "stringArray.h" 6 11 7 class gsRegistry 12 class gsRegistry : public installAgent 8 13 { private: 9 char volumeKey[256]; 10 char collectKey[256]; 14 string volumeKey; 15 string collectKey; 16 17 bool logAction(string action, HKEY base, string path, string item, string value); 11 18 public: 12 gsRegistry(configureFile &configFileb); 13 bool storeKeyString( HKEY base, const char *path, 14 const char *item, const char *string); 19 gsRegistry(installManager &manager, configureFile &configFileb); 20 bool storeKeyString( HKEY base, string path, string item, string value); 15 21 bool collectionInstalled(); 16 22 bool volumeInstalled(); 17 23 bool ensureKeysExist(); 18 bool ensureKeyExists( HKEY base, const char *key); 19 char * collectKeyId(); 20 char * volumeKeyId(); 21 char * exeKeyId(char *exeName); 24 bool ensureKeyExists( HKEY base, string key); 25 bool destroyKey(HKEY base, string key); 26 bool destroyItem(HKEY base, string key, string name); 27 string collectKeyId(); 28 string volumeKeyId(); 29 string exeKeyId(string exeName); 30 string uninstallKeyId(string collectName); 22 31 FilePath *collectionPath(); 23 Path(); 32 bool undoAction(string ActionName, stringArray ¶ms); 33 // Path(); 24 34 }; 25 35 #endif -
trunk/gsinstaller/gsinstall.cpp
r1397 r1475 29 29 30 30 bool config_complete = false; 31 // static char app_tmptext[100] = "George";32 31 33 32 typedef vector<dirSelector *> dirSelVector; 34 33 35 class GSInstall 34 class GSInstall : public installManager 36 35 { private: 37 configureFile * configFile; 38 FilePath * collectPath; 39 FilePath * installToPath; 40 FilePath * sourcePath; 41 FilePath * gsdlSourcePath; 42 FilePath * destinationPath; 43 FilePath * dataDestPath; 36 configureFile * configFile; // the installation configure file 37 38 FilePath * collectPath; // where the collection is currently installed 39 FilePath * installToPath; // the first cut at a destination folder 40 FilePath * sourcePath; // the root source folder 41 FilePath * gsdlSourcePath; // the gsdl folder in the source area 42 FilePath * destinationPath; // where the executables will be installed to 43 FilePath * dataDestPath; // where the collection data files will go 44 45 bool installVolume; // whether to install collection data 46 bool installFullVolume;// whether to install all collection data 47 48 dirSelVector selectedDirs; // configuration objects 49 50 gsPlatform platform; // platform information 51 gsRegistry * gsRegister; // registry 52 gsManifest * manifest; // manifest of files 53 gsProgramManager * progman; // program manager connection 54 55 void getSourcePath(); 56 void getExistingInstall(); 57 public: 44 58 bool installExe; 45 bool installVolume; 46 bool installFullVolume; 47 gsPlatform platform; 48 unInstaller * unInstall; 49 50 dirSelVector selectedDirs; 51 52 gsRegistry * gsRegister; 53 gsManifest * manifest; 54 55 void getSourcePath(); 56 public: 57 GSInstall(); 59 60 GSInstall(bool uninstall); 58 61 FilePath * collectionPath(); 59 62 FilePath * installPath(); … … 64 67 bool installNetscape(); 65 68 void setDestination(); 69 void setUninstall(); 70 void uninstall(); 66 71 void setManifest(); 67 72 void addSelectedDir(dirSelector *selector); … … 87 92 * THe source path is also discovered. 88 93 */ 89 GSInstall::GSInstall() 90 { gsPlatform platform; 91 92 // get the installation configuration file 94 GSInstall::GSInstall(bool uninstall) 95 : installManager() 96 { // get the installation configuration file 93 97 this->configFile = new configureFile("install.cfg"); 94 98 95 // initialise the pointers that we test later this fn. 96 this->unInstall = NULL; 99 // set up "default" installation bits 100 this->installToPath = new FilePath("C:\\GSDL"); 101 this->collectPath = NULL; 102 this->installExe = true; // we must install the exe files 97 103 98 104 // don't attempt this with windows 3.1 99 if (! platform.isWindows32s() || TRUE)105 if (!this->platform.isWindows32s()) 100 106 { // get the registry 101 this->gsRegister = new gsRegistry(*this->configFile); 102 103 // TODO: in windows 3.1 we can't use the register as it isn't fully/properly 107 this->gsRegister = new gsRegistry(*this, *this->configFile); 108 } 109 else 110 { // TODO: in windows 3.1 we can't use the register as it isn't fully/properly 104 111 // implemented; we must get the existing path information from elsewhere 105 if (gsRegister->collectionInstalled()) 106 { // TODO: check if receptionist etc should be replaced or not 107 108 // TODO: check build version of the volume 109 110 // Get location of the library executable from the registry; this 111 // is thence used to get the location of gsdl.ini etc. 112 this->collectPath = this->gsRegister->collectionPath(); 113 this->installToPath = this->collectPath; 114 115 // TODO: if collectPath == NULL generate error 116 117 // get uninstall information from destination location 118 FilePath *uninstallPath = new FilePath(this->collectPath->cString(), "uninstl.cfg"); 119 this->unInstall = new unInstaller(uninstallPath->cString()); 120 delete uninstallPath; 121 122 // we don't need to install the exe files 123 this->installExe = false||true; 124 } 125 else 126 { this->installToPath = new FilePath("C:\\GSDL"); 127 this->collectPath = NULL; 128 // we must install the exe files 129 this->installExe = true; 130 } 131 } 132 else 133 { // TODO: do windows 3.1 stuff here 134 this->installToPath = new FilePath("C:\\GSDL"); 135 this->installExe = true; 136 this->collectPath = NULL; 137 } 138 139 if (this->unInstall == NULL) 140 { this->unInstall = new unInstaller(""); 112 this->gsRegister = new gsRegistry(*this, *this->configFile); 141 113 } 142 114 … … 145 117 this->installFullVolume = true; 146 118 119 // detect any existing installation; unnecessary in uninstall (it's the 120 // "source" directory - see later 121 if (uninstall == false) 122 { this->getExistingInstall(); 123 } 124 147 125 // get where we are installing from 148 126 this->getSourcePath(); 149 127 150 // get the manifest 151 this->manifest = new gsManifest(*this->sourcePath); 128 // if doing an uninstall we now know where the "uninstall" is 129 if (uninstall == true) 130 { this->collectPath = this->sourcePath; 131 } 132 133 // get the manifest and program manager objects 134 if (uninstall) 135 { this->manifest = new gsManifest(*this); 136 } 137 else 138 { this->manifest = new gsManifest(*this, *this->sourcePath); 139 } 140 this->progman = new gsProgramManager(*this); 152 141 153 142 // tell manifest the number of bits in the raw windows environment; this may … … 165 154 } 166 155 */ 167 // inform manifests of collection directory name 168 char *buffer; 169 this->configFile->get("CollectionDirName", &buffer); 170 this->manifest->expandMacro("COLDIRNAME", buffer); 171 delete buffer; 156 // inform manifest of collection directory name 157 string colDir; 158 colDir = this->configFile->getString("CollectionDirName"); 159 if (colDir != "") 160 { this->manifest->expandMacro("COLDIRNAME", colDir); 161 } 162 } 163 164 /** 165 * Detect the presence of an existing installation 166 */ 167 void GSInstall::getExistingInstall() 168 { if (!this->platform.isWindows32s()) 169 { if (gsRegister->collectionInstalled()) 170 { // TODO: check if receptionist etc should be replaced or not 171 172 // TODO: check build version of the volume 173 174 // Get location of the library executable from the registry; this 175 // is thence used to get the location of gsdl.ini etc. 176 this->collectPath = this->gsRegister->collectionPath(); 177 if (this->collectPath != "") 178 { this->installToPath = this->collectPath; 179 180 // we don't need to install the exe files 181 this->installExe = false; 182 } 183 } 184 } 172 185 } 173 186 … … 189 202 190 203 // get the gsdl source path 191 this->gsdlSourcePath = new FilePath(this->sourcePath-> cString(), "gsdl");204 this->gsdlSourcePath = new FilePath(this->sourcePath->pathString(), "gsdl"); 192 205 delete exePath; 193 206 } … … 199 212 */ 200 213 bool GSInstall::copyFiles() 201 { FileVector *fileList; 202 203 // ensure that we have got the required destination and that we can write there 214 { // ensure that we have got the required destination and that we can write there 204 215 if (this->installExe) 205 216 { this->destinationPath->ensureWriteablePath(); … … 232 243 // now move on to add key items 233 244 if (this->installExe) 234 { FilePath *serverPath = new FilePath((char *) this->destinationPath->cString(), "server.exe"); 235 char *exeKeyPath; 245 { FilePath *serverPath = new FilePath(this->destinationPath->pathString(), "server.exe"); 246 FilePath *setupPath = new FilePath(this->destinationPath->pathString(), "gssetup.exe"); 247 FilePath *logPath = new FilePath(this->destinationPath->pathString(), "install.log"); 248 string exeKeyPath, uninstallCmd, uninstallKeyPath; 236 249 gsPlatform platform; 237 250 … … 240 253 this->gsRegister->collectKeyId(), 241 254 "library", 242 serverPath-> cString());255 serverPath->pathString()); 243 256 244 257 // This test is in fact for 9x or NT 4+; we're worried about the registry … … 254 267 this->gsRegister->storeKeyString( HKEY_LOCAL_MACHINE, 255 268 exeKeyPath, 256 NULL,257 serverPath-> cString());269 "", 270 serverPath->pathString()); 258 271 259 272 // store path for this application … … 261 274 exeKeyPath, 262 275 "path", 263 this->destinationPath->cString()); 264 // delete the windows 9x speciall app path key 265 delete exeKeyPath; 266 267 // TODO: set up uninstall option 276 this->destinationPath->pathString()); 277 278 // create uninstall command line 279 uninstallCmd = setupPath->pathString() + " -u " + logPath->pathString(); 280 uninstallKeyPath = this->gsRegister->uninstallKeyId(this->configFile->getString("CollectionName")); 281 282 // ensure uninstall key exists 283 this->gsRegister->ensureKeyExists(HKEY_LOCAL_MACHINE, uninstallKeyPath); 284 285 this->gsRegister->storeKeyString(HKEY_LOCAL_MACHINE, uninstallKeyPath, 286 "DisplayName", 287 this->configFile->getString("CollectionName")); 288 this->gsRegister->storeKeyString(HKEY_LOCAL_MACHINE, uninstallKeyPath, 289 "UninstallString", uninstallCmd); 268 290 } 291 delete setupPath; 269 292 delete serverPath; 293 delete logPath; 270 294 } 271 295 … … 280 304 */ 281 305 void GSInstall::setDestination() 282 { this->destinationPath = new FilePath(this->selectedDirs[0]->selectedPath()); 306 { // get configuration from the install wizard pages 307 this->destinationPath = new FilePath(this->selectedDirs[0]->selectedPath()); 283 308 this->installFullVolume = this->selectedDirs[1]->getOption(); 284 309 if (this->installFullVolume || true) // NB: always take path from 2nd dialog … … 287 312 else 288 313 { this->dataDestPath = this->destinationPath; 314 } 315 316 // open the log for writing 317 FilePath *logPath = new FilePath(this->destinationPath->pathString(), "install.log"); 318 this->openLog(logPath->pathString(), true); 319 delete logPath; 320 } 321 322 void GSInstall::setUninstall() 323 { 324 // open the log for reading 325 FilePath *logPath = new FilePath(this->collectPath->pathString(), "install.log"); 326 this->openLog(logPath->pathString(), false); 327 delete logPath; 328 } 329 330 void GSInstall::uninstall() 331 { FilePath *iniPath; 332 string command; 333 stringArray params; 334 335 this->manifest = new gsManifest(*this); // get a manifest manager 336 337 iniPath = new FilePath(this->collectPath->pathString(), "gsdl.ini"); 338 gsProfile gsdlProfile(*this, iniPath->pathString()); 339 340 while ((command = this->readCommand(params)) != "") 341 { if (!this->manifest->undoAction(command, params)) 342 { if (!gsdlProfile.undoAction(command, params)) 343 { if (!this->gsRegister->undoAction(command, params)) 344 { if (!this->progman->undoAction(command, params)) 345 { 346 } 347 } 348 } 349 } 289 350 } 290 351 } … … 295 356 void GSInstall::setManifest() 296 357 { if (this->installExe) 297 { this->manifest->selectGroup("library", this->destinationPath->pathString());358 { this->manifest->selectGroup("library", *this->destinationPath); 298 359 } 299 360 if (this->installFullVolume) 300 { this->manifest->selectGroup("collection", this->dataDestPath->pathString());361 { this->manifest->selectGroup("collection", *this->dataDestPath); 301 362 } 302 363 else 303 { this->manifest->selectGroup("database", this->dataDestPath->pathString());364 { this->manifest->selectGroup("database", *this->dataDestPath); 304 365 } 305 366 } … … 310 371 */ 311 372 bool GSInstall::updateProgman() 312 { gsProgramManager progman; 313 char * groupName = NULL; 373 { string groupName; 314 374 315 375 // if we managed to get a connection to the program manager (or explorer 316 376 // shell) then do the requisite updates 317 if ( progman.connect())377 if (this->progman->connect()) 318 378 { // get group name from folders 319 this->configFile->get("ProgramGroupName", &groupName);320 if (groupName == NULL)379 groupName = this->configFile->getString("ProgramGroupName"); 380 if (groupName == "") 321 381 { // TODO: error handling 322 progman.disconnect(); 323 delete groupName; 382 this->progman->disconnect(); 324 383 return false; 325 384 } 326 385 327 386 // add the group 328 if (!progman.addProgramGroup(groupName)) 329 { progman.disconnect(); 330 delete groupName; 387 if (!this->progman->addProgramGroup(groupName)) 388 { this->progman->disconnect(); 331 389 return false; 332 390 } 333 391 334 392 // add a "server" icon 335 FilePath libraryPath(this->destinationPath->cString(), "library.exe"); 336 if (!progman.addIcon(groupName, "Library (without nextwork support)", libraryPath.cString(), "")) 337 { progman.disconnect(); 338 delete groupName; 339 return false; 393 FilePath libraryPath(this->destinationPath->pathString(), "library.exe"); 394 if (!this->progman->addIcon(groupName, "Library (without nextwork support)", libraryPath.pathString(), "")) 395 { // assume that it may be there already 340 396 } 341 397 342 // TODO:check for server existence343 FilePath serverPath(this->destinationPath-> cString(), "server.exe");344 if (!progman.addIcon(groupName, "Server", serverPath.cString(), ""))345 { progman.disconnect();346 delete groupName; 347 return false;398 // check for server existence 399 FilePath serverPath(this->destinationPath->pathString(), "server.exe"); 400 if (serverPath.exists()) 401 { if (!this->progman->addIcon(groupName, "Server", serverPath.pathString(), "")) 402 { // assume that it may be there already 403 } 348 404 } 349 405 350 FilePath readMePath(this->destinationPath->cString(), "readme.txt"); 351 if (!progman.addIcon(groupName, "ReadMe", readMePath.cString(), "")) 352 { progman.disconnect(); 353 delete groupName; 354 return false; 406 FilePath readMePath(this->destinationPath->pathString(), "readme.txt"); 407 if (!this->progman->addIcon(groupName, "ReadMe", readMePath.pathString(), "")) 408 { 355 409 } 356 410 357 FilePath supportPath(this->destinationPath->cString(), "support.html"); 358 if (!progman.addIcon(groupName, "Technical Support", supportPath.cString(), "")) 359 { progman.disconnect(); 360 delete groupName; 361 return false; 411 FilePath supportPath(this->destinationPath->pathString(), "support.html"); 412 if (!this->progman->addIcon(groupName, "Technical Support", supportPath.pathString(), "")) 413 { 362 414 } 363 415 364 // TODO: add uninstall support 365 366 // dispose of group name 367 delete groupName; 416 // TODO: uninstall icon 417 // FilePath uninstallPath(this->destinationPath->pathString(), "gssetup.exe"); 368 418 369 419 // disconnect from program manager 370 progman.disconnect();420 this->progman->disconnect(); 371 421 } 372 422 return true; … … 393 443 { exePath = this->collectPath; 394 444 } 395 iniPath = new FilePath( (char *) exePath->cString(), "gsdl.ini");445 iniPath = new FilePath(exePath->pathString(), "gsdl.ini"); 396 446 397 447 // TODO: check if this 'if' structure is correct; suspect that it isn't quite … … 401 451 // This all needs investigating 402 452 if (this->installVolume) 403 { char volumeSectionName[100] = "\0"; 404 unsigned int space = 99; 405 406 // Manufacture the appropriate section name now; an equivalent string 453 { // Manufacture the appropriate section name now; an equivalent string 407 454 // is also constructed 408 this->configFile->concat("CollectionName", volumeSectionName, space); 409 strcat(volumeSectionName, "#"); 410 space --; 411 this->configFile->concat("CollectionVolume", volumeSectionName, space); 412 string volumeSectionString(volumeSectionName); 455 string volumeSectionString = this->configFile->getString("CollectionName") + 456 "#" + this->configFile->getString("CollectionVolume"); 413 457 414 458 // if we're installing the full data for the collection, then take the … … 423 467 424 468 // create a profile object to write to the gsdl.ini file 425 gsProfile gsdlProfile( iniPath->cString());469 gsProfile gsdlProfile(*this, iniPath->pathString()); 426 470 427 471 // if installing the executable, add the database and greenstone home … … 429 473 if (this->installExe) 430 474 { // set the correct exe entries in gsdl.ini (in the gsdl section) 431 gsdlProfile.writeString("gsdl", "gsdlhome", dataPath->cString()); 432 gsdlProfile.writeString("gsdl", "gdbmhome", this->dataDestPath->cString()); 433 434 this->unInstall->record("gsdl", "profilewrite", 2, &gsdl_VLHOME, 435 &dataPath->pathString()); 436 this->unInstall->record("gsdl", "profilewrite", 2, &gsdl_DBHOME, 437 &this->dataDestPath->pathString()); 475 gsdlProfile.writeString("gsdl", "gsdlhome", dataPath->pathString()); 476 gsdlProfile.writeString("gsdl", "gdbmhome", this->dataDestPath->pathString()); 438 477 } 439 478 … … 441 480 if (this->installVolume) 442 481 { // note the collection in the general gsdl section; and add the undo item too 443 gsdlProfile.ensureListMember("gsdl", gsdl_COLLIST.c_str(), volumeSectionName); 444 this->unInstall->record("gsdl", "proflistensure", 2, &gsdl_COLLIST, &volumeSectionString); 482 gsdlProfile.ensureListMember("gsdl", gsdl_COLLIST, volumeSectionString); 445 483 446 484 // note the volume data in its own section 447 gsdlProfile.writeString(volumeSectionName, "gsdlhome", dataPath->cString()); 448 gsdlProfile.writeString(volumeSectionName, "gdbmhome", this->dataDestPath->cString()); 449 gsdlProfile.writeString(volumeSectionName, "staticpath", dataPath->cString()); 450 451 this->unInstall->record(volumeSectionName, "profilewrite", 2, &gsdl_VLHOME, &dataPath->pathString()); 452 this->unInstall->record(volumeSectionName, "profilewrite", 2, &gsdl_DBHOME, &this->dataDestPath->pathString()); 453 this->unInstall->record(volumeSectionName, "profilewrite", 2, &gsdl_STATIC, &dataPath->pathString()); 485 gsdlProfile.writeString(volumeSectionString, "gsdlhome", dataPath->pathString()); 486 gsdlProfile.writeString(volumeSectionString, "gdbmhome", this->dataDestPath->pathString()); 487 gsdlProfile.writeString(volumeSectionString, "staticpath", dataPath->pathString()); 454 488 } 455 489 } … … 462 496 463 497 bool GSInstall::installNetscape() 464 { FilePath netscape32Path(this->sourcePath-> cString(), "netscape\\n32e405.exe");465 FilePath netscape16Path(this->sourcePath-> cString(), "netscape\\n16e405.exe");498 { FilePath netscape32Path(this->sourcePath->pathString(), "netscape\\n32e405.exe"); 499 FilePath netscape16Path(this->sourcePath->pathString(), "netscape\\n16e405.exe"); 466 500 467 501 launchApp launchNetscape(netscape32Path); … … 580 614 581 615 case PSN_KILLACTIVE: 582 { // note the path from the dialog 616 break; 617 618 case PSN_WIZNEXT: 619 { // note the path from the dialog 583 620 dirSelector *selector = ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA)); 584 621 selector->setPathFromEdit(GetDlgItem(Dialog, dirpath_PATH)); … … 586 623 // create a new FilePath object to check on the proposed destination 587 624 FilePath *path = new FilePath(selector->selectedPath()); 625 626 // if the proposed destination doesn't exist, ask the user whether to 627 // create it now. TODO: actually create it if asked! 588 628 if (path->exists() == false) 589 629 { char buffer[128]; … … 600 640 } 601 641 delete path; 602 }603 break;604 605 case PSN_WIZNEXT:606 { if (((LPNMHDR) lParam)->idFrom == 0)607 { // TODO: note a default here608 }609 642 } 610 643 break; … … 673 706 pshead.nPages = 2; 674 707 pshead.nStartPage = 0; 675 pshead.ppsp = ppage; 708 if (install.installExe == true) 709 { pshead.ppsp = ppage; 710 } 711 else // cheat as the executable etc. is already installed 712 { pshead.ppsp = &ppage[1]; 713 } 676 714 pshead.pfnCallback = GSInstall_wizardProc; 677 715 … … 705 743 switch(Message) 706 744 { case WM_CREATE: 707 { 745 { ShowWindow(Window, SW_MAXIMIZE); 708 746 } 709 747 break; … … 713 751 714 752 case WM_USER: 715 { //dirSelector selector("Choose a Greenstone directory", "Select directory"); 716 717 //selector.requestPath(Window, "Select directory"); 718 GSInstall install; 719 GSInstall_init_wizard(install); 720 if (config_complete == false) 721 { MessageBox(0, "Install cancelled", app_name, MB_OK); 722 } 753 { // uninstall action 754 if (strstr(app_cmdLine, "-u") != NULL || true) 755 { char *at = strstr(app_cmdLine, "-u"); 756 at += strlen("-u") + 1; 757 758 GSInstall install(true); 759 install.setUninstall(); 760 install.uninstall(); 761 } 762 // install wizard 723 763 else 724 { install.setDestination(); 725 install.setManifest(); 726 install.copyFiles(); 727 install.updateProgman(); 728 install.updateRegistry(); 729 install.updateProfiles(); 730 install.installNetscape(); 764 { GSInstall install(false); 765 GSInstall_init_wizard(install); 766 if (config_complete == false) 767 { MessageBox(0, "Install cancelled", app_name, MB_OK); 768 } 769 else 770 { // configure the installation 771 install.setDestination(); 772 install.setManifest(); 773 774 // perform installation 775 install.copyFiles(); 776 install.updateProgman(); 777 install.updateRegistry(); 778 install.updateProfiles(); 779 780 // do further actions 781 install.installNetscape(); 782 } 731 783 } 732 784 DestroyWindow(Window); -
trunk/gsinstaller/install.cfg
r1397 r1475 1 CompanyName: FAO2 CollectionName: Humanity Development Library3 CollectionDirName: HDL1 CompanyName:Demo 2 CollectionName:Demo Collection 3 CollectionDirName:demo 4 4 CollectionVersion:1.0 5 5 CollectionVolume:1 6 ProgramGroupName: FAO Library6 ProgramGroupName:Demo Collection -
trunk/gsinstaller/manifest.cfg
r1397 r1475 3 3 4 4 library: 5 gsdl.ini net32 net16 readme.html5 gsdl.ini library.exe Net32 Net16 readme.txt 6 6 7 7 database: -
trunk/gsinstaller/registry.cpp
r1397 r1475 21 21 reply = RegOpenKeyEx(key, name, NULL, KEY_QUERY_VALUE, keyout); 22 22 if (reply != ERROR_SUCCESS) 23 { return FALSE; 24 } 25 return TRUE; 23 { return false; 24 } 25 return true; 26 } 27 28 bool registry_deletekey(HKEY key, const char *name) 29 { if (RegDeleteKey(key, name) != ERROR_SUCCESS) 30 { return false; 31 } 32 return true; 26 33 } 27 34 … … 57 64 } 58 65 66 bool registry_deleteitem(HKEY key, const char *name) 67 { if (RegDeleteValue(key, name) != ERROR_SUCCESS) 68 { return false; 69 } 70 return true; 71 } 72 59 73 bool registry_setstring(HKEY key, const char *name, const char *value) 60 74 { LONG reply; … … 62 76 reply = RegSetValueEx(key, (LPCTSTR) name, NULL, REG_SZ, (CONST BYTE *) value, strlen(value) + 1); 63 77 if (reply != ERROR_SUCCESS) 64 { return FALSE;65 } 66 return TRUE;78 { return false; 79 } 80 return true; 67 81 } 68 82 -
trunk/gsinstaller/registry.h
r1397 r1475 8 8 bool registry_getstring(HKEY key, char *name, char **string); 9 9 bool registry_setstring(HKEY key, const char *name, const char *string); 10 bool registry_deleteitem(HKEY key, const char *name); 10 11 bool registry_createkey(HKEY key, const char *name, PHKEY keyout); 12 bool registry_deletekey(HKEY key, const char *name); 11 13 bool registry_closekey(HKEY key); 12 14 bool registry_keyExists(HKEY key, const char *name); -
trunk/gsinstaller/stringArray.cpp
r1397 r1475 50 50 for (int i = 0; i < other.size(); i ++) 51 51 { this->add(other[i]); 52 } 53 } 54 55 /** 56 * Insert a string at a given location 57 */ 58 void stringArray::insertAt(string s, unsigned int at) 59 { if (at >= this->size()) 60 { this->add(s); 61 } 62 else 63 { this->array.insert(this->array.begin() + at, s); 52 64 } 53 65 } -
trunk/gsinstaller/stringArray.h
r1397 r1475 17 17 void add(string member); 18 18 void add(stringArray &array); 19 void insertAt(string member, unsigned int at); 19 20 void remove(char *member); 20 21 void remove(string member); -
trunk/gsinstaller/unInstall.cpp
r1397 r1475 4 4 #include <stdarg.h> 5 5 #include "File.h" 6 7 bool installManager::openLog(string filename, bool write) 8 { if (this->logfile.rdbuf()->is_open()) 9 { this->logfile.close(); 10 } 11 this->logfile.open(filename.c_str(), (write ? ios::out : ios::in) | ios::app); 12 } 13 14 void installManager::setModule(string moduleName) 15 { this->currentModule = moduleName; 16 } 17 18 bool installManager::writeString(char *buffer) 19 { string s(buffer); 20 this->writeString(s); 21 } 22 23 bool installManager::writeString(string str) 24 { bool quote; 25 26 // TODO: check for space characters in str and quote if necessary 27 quote = str.find_first_of(' ') < str.length(); 28 29 if (quote) 30 { this->logfile << "\""; 31 } 32 this->logfile << str; 33 if (quote) 34 { this->logfile << "\""; 35 } 36 return true; 37 } 38 39 bool installManager::writeSeparator() 40 { this->logfile << " "; 41 return true; 42 } 43 44 string installManager::readString() 45 { string reply; 46 char c; 47 48 this->logfile >> c; 49 while (c <= ' ') 50 { this->logfile.get(); 51 } 52 if (c == '\"') 53 { do 54 { c = this->logfile.get(); 55 if (c != '\"') 56 { reply += c; 57 } 58 } 59 while (c != '\"'); 60 } 61 else 62 { /*while (c > ' ') 63 { reply += c; 64 c = this->logfile.get(); 65 }*/ 66 this->logfile.putback(c); 67 this->logfile >> reply; 68 } 69 return reply; 70 } 71 72 string installManager::readCommand(stringArray &array) 73 { string reply; 74 char c; 75 76 array.clear(); 77 78 reply = this->readString(); 79 while((c = this->logfile.get()) != '\n') 80 { this->logfile.putback(c); 81 array.add(this->readString()); 82 } 83 this->logfile.putback(c); 84 85 return reply; 86 } 87 88 installManager::~installManager() 89 { if (this->logfile.rdbuf()->is_open()) 90 { this->logfile.close(); 91 } 92 } 6 93 7 94 unInstaller::unInstaller(string &fileName) -
trunk/gsinstaller/unInstall.h
r1397 r1475 5 5 #include <map> 6 6 using namespace std; 7 8 #include <stdio.h> 9 #include <fstream.h> 7 10 8 11 #include "stringArray.h" … … 18 21 19 22 typedef map<string, unInstallCommandList, less<string> > unInstallCommandMap; 23 24 class installManager 25 { private: 26 fstream logfile; 27 string currentModule; 28 public: 29 installManager() { }; 30 bool openLog(string filename, bool write); 31 void setModule(string moduleName); 32 bool writeString(string str); 33 bool writeString(char *string); 34 bool writeSeparator(); 35 string readString(); 36 string readCommand(stringArray ¶ms); 37 ~installManager(); 38 }; 39 40 class installAgent 41 { protected: 42 installManager *manager; 43 public: 44 installAgent(installManager &useManager) { this->manager = &useManager; }; 45 virtual bool undoAction(string actionName, stringArray ¶ms) { return false; }; 46 // bool undo(string actionName); 47 }; 20 48 21 49 class unInstaller
Note:
See TracChangeset
for help on using the changeset viewer.