Changeset 1539 for trunk/gsinstaller
- Timestamp:
- 2000-09-12T13:36:44+12:00 (24 years ago)
- Location:
- trunk/gsinstaller
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsinstaller/FilePath.h
r1536 r1539 2 2 #define _FILEPATH_H_ 3 3 #include <string> 4 5 // use the standard namespace 6 #if !defined (GSDL_NAMESPACE_BROKEN) 7 #if defined(GSDL_USE_OBJECTSPACE) 8 using namespace ospace::std; 9 #else 4 10 using namespace std; 11 #endif 12 #endif 5 13 6 14 class FilePath -
trunk/gsinstaller/configFile.h
r1475 r1539 2 2 #define _CONFIG_H_ 3 3 #include <string> 4 5 // use the standard namespace 6 #if !defined (GSDL_NAMESPACE_BROKEN) 7 #if defined(GSDL_USE_OBJECTSPACE) 8 using namespace ospace::std; 9 #else 4 10 using namespace std; 11 #endif 12 #endif 5 13 6 14 #include <stdio.h> … … 10 18 11 19 typedef struct 12 { char label[32]; 13 char data[64]; 20 { 21 char label[32]; 22 char data[64]; 14 23 } config_item; 15 24 16 25 typedef struct 17 { int count; 26 { 27 int count; 18 28 config_item item[1]; 19 29 } config_str; … … 21 31 class configureFile 22 32 { 23 24 config_str *configstr;25 33 private: 34 config_str *configstr; 35 bool valid; 26 36 27 28 29 30 31 32 33 34 35 36 37 37 bool scan(char *buffer, unsigned int &pos, unsigned int length); 38 public: 39 configureFile(char *name); 40 char *filename(char *base); 41 bool put(char *label, char *value); 42 bool concat(char *label, char *buffer, unsigned int &space); 43 string getString(string label); 44 void get(char *label, char **to); 45 bool store(char *); 46 bool isValid(); 47 ~configureFile(); 38 48 }; 39 49 #endif -
trunk/gsinstaller/configurable.h
r1397 r1539 1 1 #ifndef _CONFIGURE_H_ 2 3 #include <map> // just here to include "bool" for extremely 4 // stupid compilers (i.e. older versions of VC++) 5 2 6 class configurable 3 { private: 4 protected: 5 public: 6 configurable(); 7 configurable(char *prompt); 8 configurable(char *prompt, char *optPrompt); 7 { 8 private: 9 protected: 10 public: 11 configurable(); 12 configurable(char *prompt); 13 configurable(char *prompt, char *optPrompt); 9 14 10 11 12 13 14 15 16 17 booloption;18 boolfinal;19 15 void setFinal(bool isFinal); 16 bool isFinal(); 17 18 void setOption(bool to); 19 bool getOption(); 20 21 char *prompt; 22 bool option; 23 bool final; 24 char *optPrompt; 20 25 }; 21 26 #define _CONFIGURE_H_ 1 -
trunk/gsinstaller/file.h
r1536 r1539 2 2 #include <vector> 3 3 #include <string> 4 5 // use the standard namespace 6 #if !defined (GSDL_NAMESPACE_BROKEN) 7 #if defined(GSDL_USE_OBJECTSPACE) 8 using namespace ospace::std; 9 #else 4 10 using namespace std; 11 #endif 12 #endif 5 13 6 14 #include "DiskSpace.h" -
trunk/gsinstaller/gs16bit.cpp
r1538 r1539 1 #include "Splash.h" 2 3 4 5 UINT timer; 6 7 HWND splash_window; 8 9 BOOL splash_done; 10 11 HBITMAP splash_bmp; 12 13 int splash_bmpheight; 14 15 16 17 void CALLBACK splash_timerproc(HWND Window, UINT Message, UINT id, DWORD time) 18 19 { splash_done = TRUE; 20 21 KillTimer(NULL, 0); 22 23 } 24 25 26 27 long FAR PASCAL _export splash_windproc(HWND Window, UINT Message, WPARAM wParameter, LPARAM lParameter) 28 29 { switch (Message) 30 31 { case WM_CREATE: 32 33 { timer = SetTimer(NULL, 0, 3000, (TIMERPROC) splash_timerproc); 34 35 } 36 37 break; 38 39 40 41 case WM_TIMER: // valid id; just kill window after timer elapses 42 43 splash_done = TRUE; 44 45 KillTimer(Window, 0); 46 47 break; 48 49 50 51 case WM_DESTROY: 52 53 splash_window = 0; 54 55 break; 56 57 58 59 case WM_PAINT: 60 61 { PAINTSTRUCT PaintInfo; 62 63 HDC dc, bmpDC; 64 65 BITMAP bmpData; 66 67 POINT origin, size; 68 69 70 71 dc = BeginPaint(Window, &PaintInfo); 72 73 bmpDC = CreateCompatibleDC(dc); 74 75 SelectObject(bmpDC, splash_bmp); 76 77 78 79 GetObject(splash_bmp, sizeof(BITMAP), (LPVOID) &bmpData); 80 81 82 83 size.x = bmpData.bmWidth; 84 85 size.y = bmpData.bmHeight; 86 87 DPtoLP(dc, &size, 1); 88 89 90 91 origin.x = 0; 92 93 origin.y = 0; 94 95 DPtoLP(dc, &origin, 1); 96 97 98 99 BitBlt(dc, 0, 0, size.x, size.y, 100 101 bmpDC, origin.x, origin.y, SRCCOPY); 102 103 104 105 DeleteDC(bmpDC); 106 107 EndPaint(Window, &PaintInfo); 108 109 } 110 111 break; 112 113 114 115 case WM_COMMAND: 116 117 break; 118 119 120 121 default: 122 123 return(DefWindowProc(Window, Message, wParameter, lParameter)); 124 125 } 126 127 return 0L; 128 129 } 130 131 132 133 void splash_register(HINSTANCE instance) 134 135 { WNDCLASS Class; 136 137 static bool registered = false; 138 139 if (registered == false) 140 141 { Class.lpszClassName = "Generic:Splash"; 142 143 Class.hInstance = instance; 144 145 Class.lpfnWndProc = (WNDPROC) splash_windproc; 146 147 Class.hCursor = LoadCursor(NULL, IDC_ARROW); 148 149 Class.hIcon = NULL; 150 151 Class.lpszMenuName = NULL; 152 153 Class.hbrBackground = (HBRUSH) (COLOR_WINDOW+1); 154 155 Class.style = NULL; 156 157 Class.cbClsExtra = 0; 158 159 Class.cbWndExtra = 0; 160 161 RegisterClass(&Class); 162 163 registered = TRUE; 164 165 } 166 167 } 168 169 170 171 void _export splash_show(HINSTANCE instance, unsigned int time) 172 173 { MSG msg; 174 175 RECT r; 176 177 BITMAP bmpData; 178 179 POINT size; 180 181 int sx, sy; 182 183 HDC dc; 184 185 186 187 splash_register(instance); 188 189 190 191 splash_bmp = LoadBitmap(instance, (LPCSTR) MAKEINTRESOURCE(9007)); 192 193 splash_done = FALSE; 194 195 196 197 GetObject(splash_bmp, sizeof(BITMAP), (LPVOID) &bmpData); 198 199 size.x = bmpData.bmWidth; 200 201 size.y = bmpData.bmHeight; 202 203 204 205 r.left = 0; 206 207 r.top = 0; 208 209 r.right = size.x; 210 211 r.bottom = size.y; 212 213 AdjustWindowRect(&r, 0, TRUE); 214 215 216 217 splash_bmpheight = size.y; 218 219 dc = GetDC(GetDesktopWindow()); 220 221 sx = GetDeviceCaps(dc, HORZRES); 222 223 sy = GetDeviceCaps(dc, VERTRES); 224 225 ReleaseDC(GetDesktopWindow(), dc); 226 227 228 229 splash_window = CreateWindow("Generic:Splash", "Greenstone Installer", 230 231 WS_DLGFRAME | WS_VISIBLE, 232 233 (sx - r.right + r.left) / 2, 234 235 (sy - r.bottom + r.top) / 2, 236 237 r.right-r.left, r.bottom-r.top, 238 239 0, 0, instance, NULL); 240 241 while (GetMessage(&msg, NULL, NULL, NULL) && 242 243 splash_done == FALSE) 244 245 { if (msg.message == WM_TIMER) 246 247 { msg.hwnd = splash_window; 248 249 } 250 251 TranslateMessage(&msg); 252 253 DispatchMessage(&msg); 254 255 } 256 257 DestroyWindow(splash_window); 258 259 } 260 261 262 1 263 #include <windows.h> 2 264 -
trunk/gsinstaller/gsManifest.cpp
r1536 r1539 8 8 gsManifest::gsManifest(installManager &manager) 9 9 : installAgent(manager) 10 { // do nothing! 10 { 11 // do nothing! 11 12 } 12 13 13 14 gsManifest::gsManifest(installManager &manager, FilePath &root) 14 15 : installAgent(manager), fileCopyMonitor() 15 { this->getManifest(root); 16 this->expandGroups(); 16 { 17 this->getManifest(root); 18 this->expandGroups(); 17 19 } 18 20 19 21 bool gsManifest::getManifest(FilePath &root) 20 { FilePath *manifestPath = new FilePath((char *) root.cString(), "manifest.cfg"); 21 FILE * file; 22 DWORD fileSize; 23 string currentgroup; 24 char * buffer; 25 char * line; 26 char * eol; 27 28 // open file handle for read access 22 { 23 FilePath *manifestPath = new FilePath((char *) root.cString(), "manifest.cfg"); 24 FILE *file; 25 DWORD fileSize; 26 string currentgroup; 27 char *buffer; 28 char *line; 29 char *eol; 30 31 // open file handle for read access 29 32 file = fopen(manifestPath->cString(), "rb"); 30 if (file == NULL) 31 { return false; 32 } 33 if (file == NULL) 34 { 35 return false; 36 } 33 37 34 38 // get size of file 35 39 File f(manifestPath->cString()); 36 fileSize 40 fileSize = f.getFileSize(); 37 41 38 42 // allocate buffer for whole file and read it in 39 buffer= new char[fileSize];43 buffer = new char[fileSize]; 40 44 if (fread(buffer, 1, fileSize, file) < fileSize) 41 { // TODO: error handling 42 } 45 { 46 // TODO: error handling 47 } 43 48 fclose(file); 44 49 45 50 //parse file into lines and send to the line fn 46 51 line = buffer; 47 while ((eol = strchr(line, '\x0a')) != NULL) // use 0a for the eol to remove 48 // dependency on dos 0d,0a eol 49 { *eol = '\0'; 50 51 this->getManifestLine(line, currentgroup); 52 53 line = eol + 1; 54 } 52 while ((eol = strchr(line, '\x0a')) != NULL) 53 // use 0a for the eol to remove 54 // dependency on dos 0d,0a eol 55 { 56 *eol = '\0'; 57 58 this->getManifestLine(line, currentgroup); 59 60 line = eol + 1; 61 } 55 62 this->getManifestLine(line, currentgroup); 56 63 57 64 delete buffer; 58 65 return true; 59 66 } 60 67 61 68 bool gsManifest::getManifestLine(char *line, string &group) 62 { char *eol; // we (potentially) need to clean up the end of 63 // line, and we won't use the eol from the main 64 // getManifest fn. as for the last line it'd be 65 // null. 66 67 // clean up the start of the line 68 while (*line <= ' ' && *line != '\0') 69 { line ++; 70 } 69 { 70 char *eol; // we (potentially) need to clean up the end of 71 // line, and we won't use the eol from the main 72 // getManifest fn. as for the last line it'd be 73 // null. 74 75 // clean up the start of the line 76 while (*line <= ' ' && *line != '\0') 77 { 78 line ++; 79 } 71 80 72 81 // it's a blank line - don't bother! 73 if (line == '\0') 74 { return true; 75 } 82 if (*line == '\0') 83 { 84 return true; 85 } 76 86 77 87 // clean up the end of line 78 eol 88 eol = line + strlen(line) - 1; 79 89 while (*eol <= ' ' && eol >= line) 80 { *eol = '\0'; 81 eol --; 82 } 90 { 91 *eol = '\0'; 92 eol --; 93 } 83 94 84 95 // does the line end with a colon?; if so take it as a group definition 85 96 if (*eol == ':') 86 { if (eol == line) // if it's literally just a colon do nothing 87 { return true; 88 } 89 90 // note the new group name 91 string newgroup(line, 0, eol - line); 92 group = newgroup; 93 } 97 { 98 if (eol == line) // if it's literally just a colon do nothing 99 { 100 return true; 101 } 102 103 // note the new group name 104 string newgroup(line, 0, eol - line); 105 group = newgroup; 106 } 94 107 // if it starts with a hash it's just a comment line; skip it 95 108 else if (*line == '#') 96 { // do nothing! 97 } 109 { 110 // do nothing! 111 } 98 112 // an actual line of member items; read them in 99 113 else 100 { stringArray array; 101 array = stringArray::words(line); 102 103 if (group.length() == 0) 104 { this->manifests["all"].add(array); 105 } 106 else 107 { this->manifests[group].add(array); 108 } 109 } 114 { 115 stringArray array; 116 array = stringArray::words(line); 117 118 if (group.length() == 0) 119 { 120 this->manifests["all"].add(array); 121 } 122 else 123 { 124 this->manifests[group].add(array); 125 } 126 } 110 127 return true; 111 128 } … … 209 226 210 227 void gsManifest::clearSelection() 211 { this->selected.empty(); 228 { 229 this->selected.empty(); 212 230 } 213 231 … … 226 244 */ 227 245 bool gsManifest::copy(FilePath *source) 228 { fileCopier copy(this); 229 230 pathStringArrayMap::iterator here = this->selected.begin(); 231 pathStringArrayMap::iterator end = this->selected.end(); 246 { 247 fileCopier copy(this); 248 249 pathStringArrayMap::iterator here = this->selected.begin(); 250 pathStringArrayMap::iterator end = this->selected.end(); 232 251 233 252 // add all the sets to copy to the manifest 234 253 while (here != end) 235 { FileVector *fileList; 236 stringArray &array = (*here).second; 237 FilePath path((*here).first); 238 239 // TODO: eliminate inefficiency; we're doing FilePath->string->FilePath in 240 // effect between constructing the copy lists, and then the sets, as far 241 // as the destinations go 242 fileList = this->selection(*source, array); 243 fileCopySet copySet(*fileList, *source, path); 244 copy.addSet(copySet); 245 delete fileList; 246 here ++; 247 } 254 { 255 FileVector *fileList; 256 stringArray &array = (*here).second; 257 FilePath path((*here).first); 258 259 // TODO: eliminate inefficiency; we're doing FilePath->string->FilePath in 260 // effect between constructing the copy lists, and then the sets, as far 261 // as the destinations go 262 fileList = this->selection(*source, array); 263 fileCopySet copySet(*fileList, *source, path); 264 copy.addSet(copySet); 265 delete fileList; 266 here ++; 267 } 248 268 249 269 // check that we've got enough space @ the destination(s) 250 270 if (!copy.checkSpace()) 251 { return false; 252 } 271 { 272 return false; 273 } 253 274 254 275 // do the actual copying … … 258 279 259 280 void gsManifest::copied(string from, string to, bool isDir) 260 { if (isDir) 261 { this->logAction("Manifest.CreateDir", to); 262 } 281 { 282 if (isDir) 283 { 284 this->logAction("Manifest.CreateDir", to); 285 } 263 286 else 264 { this->logAction("Manifest.CopyFile", from, to); 265 } 287 { 288 this->logAction("Manifest.CopyFile", from, to); 289 } 266 290 } 267 291 268 292 void gsManifest::logAction(string actionName, string file) 269 { unInstallCommand command(actionName); 270 command.addParameter(file); 293 { 294 unInstallCommand command(actionName); 295 command.addParameter(file); 271 296 manager->storeCommand(command); 272 297 } 273 298 274 299 void gsManifest::logAction(string actionName, string source, string dest) 275 { unInstallCommand command(actionName); 276 command.addParameter(source); 300 { 301 unInstallCommand command(actionName); 302 command.addParameter(source); 277 303 command.addParameter(dest); 278 304 manager->storeCommand(command); … … 280 306 281 307 bool gsManifest::undoAction(string actionName, stringArray ¶ms) 282 { if (actionName == "Manifest.CreateDir" || actionName == "CreateDir") 283 { RemoveDirectory(params[0].c_str()); 284 return true; 285 } 308 { 309 if (actionName == "Manifest.CreateDir" || actionName == "CreateDir") 310 { 311 RemoveDirectory(params[0].c_str()); 312 return true; 313 } 286 314 else if (actionName == "Manifest.CopyFile" || actionName == "CopyFile") 287 { DeleteFile(params[1].c_str()); 288 return true; 289 } 315 { 316 DeleteFile(params[1].c_str()); 317 return true; 318 } 290 319 return false; 291 320 } 292 321 293 322 FileVector *gsManifest::selection(FilePath &root, stringArray &array) 294 { FileVector *reply = new FileVector(); 323 { 324 FileVector *reply = new FileVector(); 295 325 296 326 for (unsigned int i = 0; i < array.size(); i++) 297 { FilePath fileName(root.pathString(), array[i]); 298 File file(fileName.pathString()); 299 reply->push_back(file); 327 { 328 FilePath fileName(root.pathString(), array[i]); 329 File file(fileName.pathString()); 330 reply->push_back(file); 300 331 } 301 332 return reply; … … 303 334 304 335 FileVector *gsManifest::selection(FilePath &source, FilePath &destination) 305 { return this->selection(source, this->selected[destination]); 306 } 307 336 { 337 return this->selection(source, this->selected[destination]); 338 } 339 -
trunk/gsinstaller/gsManifest.h
r1536 r1539 2 2 #define _GSMANIFEST_H_ 3 3 #include <map> 4 5 // use the standard namespace 6 #if !defined (GSDL_NAMESPACE_BROKEN) 7 #if defined(GSDL_USE_OBJECTSPACE) 8 using namespace ospace::std; 9 #else 4 10 using namespace std; 11 #endif 12 #endif 5 13 6 14 #include "File.h" -
trunk/gsinstaller/gsPlatform.h
r1536 r1539 2 2 #define _GSPLATFORM_H_ 3 3 #include <string> 4 5 // use the standard namespace 6 #if !defined (GSDL_NAMESPACE_BROKEN) 7 #if defined(GSDL_USE_OBJECTSPACE) 8 using namespace ospace::std; 9 #else 4 10 using namespace std; 11 #endif 12 #endif 13 5 14 #include <windows.h> 6 15 -
trunk/gsinstaller/gsProfile.h
r1475 r1539 2 2 #define _GSPROFILE_H_ 3 3 #include <string> 4 5 // use the standard namespace 6 #if !defined (GSDL_NAMESPACE_BROKEN) 7 #if defined(GSDL_USE_OBJECTSPACE) 8 using namespace ospace::std; 9 #else 4 10 using namespace std; 11 #endif 12 #endif 13 5 14 #include <windows.h> 6 15 … … 10 19 class gsProfile : public installAgent 11 20 { 12 13 21 private: 22 string fileName; 14 23 15 16 17 18 19 20 21 22 23 24 void logAction(string action, string sectionName, string item, string value); 25 protected: 26 public: 27 gsProfile(installManager &manager, string fileName); 28 bool ensureListMember(string sectionName, string listName, string listMember); 29 bool removeListMember(string sectionName, string listName, string listMember); 30 bool addListMember(string sectionName, string listName, string listMember); 31 bool writeString(string sectionName, string itemName, string itemValue); 32 bool undoAction(string actionName, stringArray ¶ms); 24 33 }; 25 34 #endif -
trunk/gsinstaller/gsRegistry.h
r1475 r1539 2 2 #define _GSREGISTRY_H_ 3 3 #include <string> 4 5 // use the standard namespace 6 #if !defined (GSDL_NAMESPACE_BROKEN) 7 #if defined(GSDL_USE_OBJECTSPACE) 8 using namespace ospace::std; 9 #else 4 10 using namespace std; 11 #endif 12 #endif 5 13 6 14 #include "registry.h" … … 11 19 12 20 class gsRegistry : public installAgent 13 { private: 14 string volumeKey; 15 string collectKey; 21 { 22 private: 23 string volumeKey; 24 string collectKey; 16 25 17 18 19 20 bool storeKeyString(HKEY base, string path, string item, string value);21 boolcollectionInstalled();22 boolvolumeInstalled();23 boolensureKeysExist();24 boolensureKeyExists( HKEY base, string key);25 booldestroyKey(HKEY base, string key);26 booldestroyItem(HKEY base, string key, string name);27 stringcollectKeyId();28 stringvolumeKeyId();29 stringexeKeyId(string exeName);30 stringuninstallKeyId(string collectName);31 32 33 // Path();26 bool logAction(string action, HKEY base, string path, string item, string value); 27 public: 28 gsRegistry(installManager &manager, configureFile &configFileb); 29 bool storeKeyString(HKEY base, string path, string item, string value); 30 bool collectionInstalled(); 31 bool volumeInstalled(); 32 bool ensureKeysExist(); 33 bool ensureKeyExists( HKEY base, string key); 34 bool destroyKey(HKEY base, string key); 35 bool destroyItem(HKEY base, string key, string name); 36 string collectKeyId(); 37 string volumeKeyId(); 38 string exeKeyId(string exeName); 39 string uninstallKeyId(string collectName); 40 FilePath *collectionPath(); 41 bool undoAction(string ActionName, stringArray ¶ms); 42 // Path(); 34 43 }; 35 44 #endif -
trunk/gsinstaller/gsinstall.cpp
r1536 r1539 1 1 #include <vector> 2 2 #include <string> 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 3 9 using namespace std; 10 #endif 11 #endif 4 12 5 13 #include <stdlib.h> -
trunk/gsinstaller/launchApp.h
r1498 r1539 3 3 #include <string> 4 4 #include <map> 5 6 // use the standard namespace 7 #if !defined (GSDL_NAMESPACE_BROKEN) 8 #if defined(GSDL_USE_OBJECTSPACE) 9 using namespace ospace::std; 10 #else 5 11 using namespace std; 12 #endif 13 #endif 6 14 7 15 #include "FilePath.h" … … 10 18 11 19 class launchApp 12 { private: 13 _exeMap exeMap; 14 string commandline; 15 public: 16 launchApp(FilePath &appsrc); 17 void platformApp(string platform, FilePath &appsrc); 18 void setCommandLine(string commands); 19 int run(bool test, int deftest, string prompt, string title, bool wait); 20 { 21 private: 22 _exeMap exeMap; 23 string commandline; 24 public: 25 launchApp(FilePath &appsrc); 26 void platformApp(string platform, FilePath &appsrc); 27 void setCommandLine(string commands); 28 int run(bool test, int deftest, string prompt, string title, bool wait); 20 29 }; 21 30 #endif -
trunk/gsinstaller/stringArray.h
r1536 r1539 4 4 #include <vector> 5 5 #include <map> 6 7 // use the standard namespace 8 #if !defined (GSDL_NAMESPACE_BROKEN) 9 #if defined(GSDL_USE_OBJECTSPACE) 10 using namespace ospace::std; 11 #else 6 12 using namespace std; 13 #endif 14 #endif 15 7 16 #include <string.h> 8 17 -
trunk/gsinstaller/unInstall.h
r1536 r1539 4 4 #include <vector> 5 5 #include <map> 6 7 // use the standard namespace 8 #if !defined (GSDL_NAMESPACE_BROKEN) 9 #if defined(GSDL_USE_OBJECTSPACE) 10 using namespace ospace::std; 11 #else 6 12 using namespace std; 13 #endif 14 #endif 7 15 8 16 #include <stdio.h>
Note:
See TracChangeset
for help on using the changeset viewer.