Changeset 1536 for trunk/gsinstaller/gsinstall.cpp
- Timestamp:
- 2000-09-11T17:29:32+12:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsinstaller/gsinstall.cpp
r1502 r1536 23 23 #include "gsManifest.h" 24 24 25 char * 25 char *app_cmdLine; 26 26 static char app_name[] = "Greenstone Installer"; 27 HINSTANCE 28 HWND 29 30 bool 27 HINSTANCE app_instance; 28 HWND app_window; 29 30 bool config_complete = false; 31 31 32 32 typedef vector<dirSelector *> dirSelVector; 33 33 34 34 class GSInstall : public installManager 35 { private: 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: 58 bool installExe; 59 60 GSInstall(bool uninstall); 61 FilePath * collectionPath(); 62 FilePath * installPath(); 63 bool copyFiles(); 64 bool updateRegistry(); 65 bool updateProfiles(); 66 bool updateProgman(); 67 bool updateSetupExe(); 68 bool installNetscape(); 69 void setDestination(); 70 bool setUninstall(); 71 void uninstall(); 72 void setManifest(); 73 void addSelectedDir(dirSelector *selector); 35 { 36 private: 37 configureFile *configFile; // the installation configure file 38 39 FilePath *collectPath; // where the collection is currently installed 40 FilePath *installToPath; // the first cut at a destination folder 41 FilePath *sourcePath; // the root source folder 42 FilePath *gsdlSourcePath; // the gsdl folder in the source area 43 FilePath *destinationPath; // where the executables will be installed to 44 FilePath *dataDestPath; // where the collection data files will go 45 46 bool installVolume; // whether to install collection data 47 bool installFullVolume; // whether to install all collection data 48 49 dirSelVector selectedDirs; // configuration objects 50 51 gsPlatform platform; // platform information 52 gsRegistry *gsRegister; // registry 53 gsManifest *manifest; // manifest of files 54 gsProgramManager *progman; // program manager connection 55 56 void getSourcePath(); 57 void getExistingInstall(); 58 public: 59 bool installExe; 60 61 GSInstall(bool uninstall); 62 FilePath *collectionPath(); 63 FilePath *installPath(); 64 bool copyFiles(); 65 bool updateRegistry(); 66 bool updateProfiles(); 67 bool updateProgman(); 68 bool updateSetupExe(); 69 bool installNetscape(); 70 void setDestination(); 71 bool setUninstall(); 72 void uninstall(); 73 void setManifest(); 74 void addSelectedDir(dirSelector *selector); 74 75 }; 75 76 … … 81 82 void gsInstall_getDesktopExt(int *sx, int *sy) 82 83 { 83 84 HDC dc = GetDC(GetDesktopWindow()); 84 85 *sx = GetDeviceCaps(dc, HORZRES); 85 86 *sy = GetDeviceCaps(dc, VERTRES); … … 94 95 */ 95 96 GSInstall::GSInstall(bool uninstall) 96 : installManager() 97 { // get the installation configuration file 98 this->configFile = new configureFile("install.cfg"); 99 100 // set up "default" installation bits 101 this->installToPath = new FilePath("C:\\GSDL"); 102 this->collectPath = NULL; 103 this->installExe = true; // we must install the exe files 104 105 // don't attempt this with windows 3.1 97 : installManager() 98 { 99 // get the installation configuration file 100 this->configFile = new configureFile("install.cfg"); 101 102 // set up "default" installation bits 103 this->installToPath = new FilePath("C:\\GSDL"); 104 this->collectPath = NULL; 105 this->installExe = true; // we must install the exe files 106 107 // don't attempt this with windows 3.1 106 108 if (!this->platform.isWindows32s()) 107 { // get the registry 108 this->gsRegister = new gsRegistry(*this, *this->configFile); 109 } 109 { 110 // get the registry 111 this->gsRegister = new gsRegistry(*this, *this->configFile); 112 } 110 113 else 111 { // TODO: in windows 3.1 we can't use the register as it isn't fully/properly 112 // implemented; we must get the existing path information from elsewhere 113 this->gsRegister = new gsRegistry(*this, *this->configFile); 114 } 114 { 115 // TODO: in windows 3.1 we can't use the register as it isn't fully/properly 116 // implemented; we must get the existing path information from elsewhere 117 this->gsRegister = new gsRegistry(*this, *this->configFile); 118 } 115 119 116 120 // assume for now we will install the full volume and the database 117 this->installVolume 118 this->installFullVolume 119 120 121 this->installVolume = true; 122 this->installFullVolume = true; 123 124 // detect any existing installation; unnecessary in uninstall (it's the 121 125 // "source" directory - see later 122 126 if (uninstall == false) 123 { this->getExistingInstall(); 124 } 127 { 128 this->getExistingInstall(); 129 } 125 130 126 131 // get where we are installing from … … 129 134 // if doing an uninstall we now know where the "uninstall" is 130 135 if (uninstall == true) 131 { this->collectPath = this->sourcePath; 132 } 136 { 137 this->collectPath = this->sourcePath; 138 } 133 139 134 140 // get the manifest and program manager objects 135 141 if (uninstall) 136 { this->manifest = new gsManifest(*this); 137 } 142 { 143 this->manifest = new gsManifest(*this); 144 } 138 145 else 139 { this->manifest = new gsManifest(*this, *this->sourcePath); 140 } 146 { 147 this->manifest = new gsManifest(*this, *this->sourcePath); 148 } 141 149 this->progman = new gsProgramManager(*this); 142 150 … … 144 152 // be required for loading certain modules such as winsock; the number of 145 153 // macros is over-the-top, but is more robust to unforeseen future requirements 146 /* if (platform.isWindows32s())147 { this->manifest->expandMacro("WINBITS", "16");148 149 150 }151 else152 { this->manifest->expandMacro("WINBITS", "32");153 154 155 }156 */154 /* if (platform.isWindows32s()) 155 { this->manifest->expandMacro("WINBITS", "16"); 156 this->manifest->expandMacro("WIN16", "16"); 157 this->manifest->expandMacro("WIN32", "32"); 158 } 159 else 160 { this->manifest->expandMacro("WINBITS", "32"); 161 this->manifest->expandMacro("WIN16", ""); 162 this->manifest->expandMacro("WIN32", "32"); 163 } 164 */ 157 165 // inform manifest of collection directory name 158 166 string colDir; 159 167 colDir = this->configFile->getString("CollectionDirName"); 160 168 if (colDir != "") 161 { this->manifest->expandMacro("COLDIRNAME", colDir); 162 } 169 { 170 this->manifest->expandMacro("COLDIRNAME", colDir); 171 } 163 172 } 164 173 … … 167 176 */ 168 177 void GSInstall::getExistingInstall() 169 { if (!this->platform.isWindows32s()) 170 { if (gsRegister->collectionInstalled()) 171 { // TODO: check if receptionist etc should be replaced or not 172 173 // TODO: check build version of the volume 174 175 // Get location of the library executable from the registry; this 176 // is thence used to get the location of gsdl.ini etc. 177 this->collectPath = this->gsRegister->collectionPath(); 178 if (this->collectPath != "") 179 { this->installToPath = this->collectPath; 180 181 // we don't need to install the exe files 182 this->installExe = false; 183 } 184 } 185 } 178 { 179 if (!this->platform.isWindows32s()) 180 { 181 if (gsRegister->collectionInstalled()) 182 { 183 // TODO: check if receptionist etc should be replaced or not 184 185 // TODO: check build version of the volume 186 187 // Get location of the library executable from the registry; this 188 // is thence used to get the location of gsdl.ini etc. 189 this->collectPath = this->gsRegister->collectionPath(); 190 if (this->collectPath->pathString() != "") 191 { 192 this->installToPath = this->collectPath; 193 // we don't need to install the exe files 194 this->installExe = false; 195 } 196 } 197 } 186 198 } 187 199 … … 749 761 750 762 bool GSInstall_init_wizard(GSInstall &install) 751 { PROPSHEETHEADER pshead; 752 PROPSHEETPAGE ppage[2]; 753 bool reply; 754 755 ZeroMemory(&pshead, sizeof(PROPSHEETHEADER)); 756 pshead.dwSize = sizeof(PROPSHEETHEADER); 757 pshead.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_USEHICON | PSH_WIZARD; 758 pshead.hwndParent = app_window; 759 pshead.hInstance = app_instance; 760 pshead.hIcon = NULL; 761 pshead.pszCaption = "Greenstone Installer"; 762 pshead.nPages = 2; 763 pshead.nStartPage = 0; 763 { 764 PROPSHEETHEADER pshead; 765 PROPSHEETPAGE ppage[2]; 766 bool reply; 767 768 ZeroMemory(&pshead, sizeof(PROPSHEETHEADER)); 769 pshead.dwSize = sizeof(PROPSHEETHEADER); 770 pshead.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_USEHICON | PSH_WIZARD; 771 pshead.hwndParent = app_window; 772 pshead.hInstance = app_instance; 773 pshead.hIcon = NULL; 774 pshead.pszCaption = "Greenstone Installer"; 775 pshead.nPages = 2; 776 pshead.nStartPage = 0; 764 777 if (install.installExe == true) 765 { pshead.ppsp = ppage; 766 } 778 { 779 pshead.ppsp = ppage; 780 } 767 781 else // cheat as the executable etc. is already installed 768 { pshead.ppsp = &ppage[1]; 769 } 770 pshead.pfnCallback = GSInstall_wizardProc; 782 { 783 pshead.ppsp = &ppage[1]; 784 } 785 pshead.pfnCallback = GSInstall_wizardProc; 771 786 772 787 GSInstall_init_propertySheet( ppage[0], 773 788 "Choose a directory to install your " 774 789 "GreenStone software to.", NULL, 775 790 "Select", install, false); 776 791 GSInstall_init_propertySheet(ppage[1], 777 778 779 780 781 782 783 784 785 786 787 792 "Choose a directory to install the collection " 793 "files to.\n\n" 794 "You can also choose to install all the collection " 795 "files onto your computer hard drive.\n\n" 796 "If you do this, you will not have to load the " 797 "CD-ROM each time you use your Greenstone software " 798 "but more of your hard disk will be used.\n\n" 799 "Some collection files must be installed on your " 800 "computer.\n\n", 801 "Install all collection files", 802 "Select", install, true); 788 803 789 804 reply = (PropertySheet (&pshead) >= 0); … … 791 806 } 792 807 793 long FAR PASCAL GSInstallWindProc(HWND Window, 794 WORD Message, 795 WPARAM wParameter, 796 LPARAM lParameter) 797 { long reply = 0; 808 long FAR PASCAL GSInstallWindProc(HWND Window, WORD Message, WPARAM wParameter, LPARAM lParameter) 809 { 810 long reply = 0; 798 811 799 812 switch(Message) 800 { case WM_CREATE: 801 { ShowWindow(Window, SW_MAXIMIZE); 802 } 803 break; 804 805 case WM_COMMAND: 806 break; 813 { 814 case WM_CREATE: 815 { 816 ShowWindow(Window, SW_MAXIMIZE); 817 } 818 break; 819 820 case WM_COMMAND: 821 break; 807 822 808 823 case WM_USER: 809 { // uninstall action 810 if (strstr(app_cmdLine, "-u") != NULL) 811 { // skip past the -u option itself 812 char *at = strstr(app_cmdLine, "-u"); 813 at += strlen("-u"); 814 815 // extract the log file path from the command line 816 while (*at == ' ') 817 { at ++; 818 } 819 string logPathString(at); 820 FilePath logPath(logPathString); 821 822 GSInstall install(true); 823 // if we're running in the temporary directory, do the uninstall 824 if (install.setUninstall()) 825 { install.uninstall(); 826 827 // close the log to write back all changes to the log; if the file 828 // will be deleted, it must be closed; copying may also fail, so it's 829 // safer to close it before doing either. 830 install.closeLog(); 831 832 // if the install is empty, terminate all final items (currently the 833 // log and setup executables, 834 if (install.isEmpty()) 835 { // delete the log file 836 DeleteFile(logPath.cString()); 837 838 // get it's parent to find where the gssetup executable will be 839 FilePath *logParent = logPath.parent(); 840 FilePath uninstallPath(*logParent, "gssetup.exe"); 841 842 // delete the gssetup executable 843 DeleteFile(uninstallPath.cString()); 844 845 // dispose of the parent directory information 846 delete logParent; 847 } 848 // if not, then overwrite the original log with the modified one 849 else 850 { // do nothing - should be changed already! 851 } 852 } 853 } 824 { 825 // uninstall action 826 if (strstr(app_cmdLine, "-u") != NULL) 827 { 828 // skip past the -u option itself 829 char *at = strstr(app_cmdLine, "-u"); 830 at += strlen("-u"); 831 832 // extract the log file path from the command line 833 while (*at == ' ') 834 { 835 at ++; 836 } 837 string logPathString(at); 838 FilePath logPath(logPathString); 839 840 GSInstall install(true); 841 // if we're running in the temporary directory, do the uninstall 842 if (install.setUninstall()) 843 { 844 install.uninstall(); 845 846 // close the log to write back all changes to the log; if the file 847 // will be deleted, it must be closed; copying may also fail, so it's 848 // safer to close it before doing either. 849 install.closeLog(); 850 851 // if the install is empty, terminate all final items (currently the 852 // log and setup executables, 853 if (install.isEmpty()) 854 { 855 // delete the log file 856 DeleteFile(logPath.cString()); 857 858 // get it's parent to find where the gssetup executable will be 859 FilePath *logParent = logPath.parent(); 860 FilePath uninstallPath(*logParent, "gssetup.exe"); 861 862 // delete the gssetup executable 863 DeleteFile(uninstallPath.cString()); 864 865 // dispose of the parent directory information 866 delete logParent; 867 } 868 // if not, then overwrite the original log with the modified one 869 else 870 { 871 // do nothing - should be changed already! 872 } 873 } 874 } 854 875 // install wizard 855 876 else 856 { GSInstall install(false); 857 GSInstall_init_wizard(install); 877 { 878 GSInstall install(false); 879 GSInstall_init_wizard(install); 858 880 if (config_complete == false) 859 { MessageBox(0, "Install cancelled", app_name, MB_OK); 860 } 861 else 862 { // configure the installation 863 install.setDestination(); 864 install.setManifest(); 865 866 // perform installation 867 install.copyFiles(); 868 install.updateProgman(); 869 install.updateRegistry(); 870 install.updateProfiles(); 871 install.updateSetupExe(); 872 873 // the log will need reopening (probably failed initially) 874 install.reopenLog(); 875 876 // close log 877 install.closeLog(); 878 879 // do further actions 881 { 882 MessageBox(0, "Install cancelled", app_name, MB_OK); 883 } 884 else 885 { 886 // configure the installation 887 install.setDestination(); 888 install.setManifest(); 889 890 // perform installation 891 install.copyFiles(); 892 install.updateProgman(); 893 install.updateRegistry(); 894 install.updateProfiles(); 895 install.updateSetupExe(); 896 897 // the log will need reopening (probably failed initially) 898 install.reopenLog(); 899 900 // close log 901 install.closeLog(); 902 903 // do further actions 880 904 install.installNetscape(); 881 } 905 } 906 } 907 DestroyWindow(Window); 908 } 909 break; 910 911 case WM_CLOSE: 912 /*if (!file_ischanged || IDCANCEL != file_query(Window, file_name))*/ 913 DestroyWindow(Window); 914 return 0L; 915 916 case WM_DESTROY: 917 { 918 PostQuitMessage(0); 882 919 } 883 DestroyWindow(Window); 884 } 885 break; 886 887 case WM_CLOSE: 888 /* if (!file_ischanged || IDCANCEL != file_query(Window, file_name))*/ 889 DestroyWindow(Window); 890 return 0L; 891 892 case WM_DESTROY: 893 { PostQuitMessage(0); 894 } 895 break; 896 897 default: 898 return(DefWindowProc(Window, Message, wParameter, lParameter)); 899 } 920 break; 921 922 default: 923 return(DefWindowProc(Window, Message, wParameter, lParameter)); 924 } 900 925 return reply; 901 926 } … … 921 946 922 947 void WinClassInit(void) 923 { WNDCLASS Class; 924 925 Class.lpszClassName = "GSInstall:Main"; 926 Class.hInstance = app_instance; 927 Class.lpfnWndProc = (WNDPROC) GSInstallWindProc; 928 Class.hCursor = LoadCursor(NULL, IDC_ARROW); 929 Class.hIcon = NULL; //LoadIcon(app_instance, "GSInstall"); 930 Class.lpszMenuName = NULL; 931 Class.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE+1); 932 Class.style = NULL; 933 Class.cbClsExtra = 0; 934 Class.cbWndExtra = 0; 935 RegisterClass(&Class); 936 /* 937 Class.lpszClassName = "GSInstall:Splash"; 938 Class.hInstance = app_instance; 939 Class.lpfnWndProc = (WNDPROC) splash_windproc; 940 Class.hCursor = LoadCursor(NULL, IDC_ARROW); 941 Class.hIcon = NULL; 942 Class.lpszMenuName = NULL; 943 Class.hbrBackground = (HBRUSH) (COLOR_WINDOW+1); 944 Class.style = NULL; 945 Class.cbClsExtra = 0; 946 Class.cbWndExtra = 0; 947 RegisterClass(&Class);*/ 948 { 949 WNDCLASS Class; 950 951 Class.lpszClassName = "GSInstall:Main"; 952 Class.hInstance = app_instance; 953 Class.lpfnWndProc = (WNDPROC) GSInstallWindProc; 954 Class.hCursor = LoadCursor(NULL, IDC_ARROW); 955 Class.hIcon = NULL; //LoadIcon(app_instance, "GSInstall"); 956 Class.lpszMenuName = NULL; 957 Class.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE+1); 958 //Class.style = NULL; 959 Class.style = 0; 960 Class.cbClsExtra = 0; 961 Class.cbWndExtra = 0; 962 RegisterClass(&Class); 963 /* 964 Class.lpszClassName = "GSInstall:Splash"; 965 Class.hInstance = app_instance; 966 Class.lpfnWndProc = (WNDPROC) splash_windproc; 967 Class.hCursor = LoadCursor(NULL, IDC_ARROW); 968 Class.hIcon = NULL; 969 Class.lpszMenuName = NULL; 970 Class.hbrBackground = (HBRUSH) (COLOR_WINDOW+1); 971 Class.style = NULL; 972 Class.cbClsExtra = 0; 973 Class.cbWndExtra = 0; 974 RegisterClass(&Class);*/ 948 975 } 949 976 950 977 int PASCAL WinMain(HINSTANCE Current, 951 HINSTANCE Previous, 952 LPSTR CmdLine, 953 int CmdShow) 954 { MSG msg; 955 // HACCEL accel; 956 957 app_cmdLine = (char *) malloc(lstrlen(CmdLine) + 1); 958 lstrcpy(app_cmdLine, CmdLine); 959 960 app_instance = Current; 961 /* -- init application */ 962 if (!Previous) 963 { WinClassInit(); 964 InitCommonControls(); 965 // grbStatic_registerClass(Current); 966 } 967 968 /* -- init instance */ 978 HINSTANCE Previous, 979 LPSTR CmdLine, 980 int CmdShow) 981 { 982 MSG msg; 983 // HACCEL accel; 984 985 app_cmdLine = (char *) malloc(lstrlen(CmdLine) + 1); 986 lstrcpy(app_cmdLine, CmdLine); 987 988 app_instance = Current; 989 /* -- init application */ 990 if (!Previous) 991 { 992 WinClassInit(); 993 InitCommonControls(); 994 // grbStatic_registerClass(Current); 995 } 996 997 /* -- init instance */ 969 998 GSInstall_init(Current, CmdShow); 970 971 // config_init("ReTreeval"); 972 973 // accel = LoadAccelerators(Current, "ReTreevalMenu"); 974 975 while (GetMessage(&msg, NULL, 0, 0)) 976 { /*if (!TranslateAccelerator(app_window, accel, &msg)) 999 1000 // config_init("ReTreeval"); 1001 1002 // accel = LoadAccelerators(Current, "ReTreevalMenu"); 1003 1004 while (GetMessage(&msg, NULL, 0, 0)) 1005 { 1006 /*if (!TranslateAccelerator(app_window, accel, &msg)) 977 1007 { */ 978 979 980 /*}*/981 982 983 } 1008 TranslateMessage(&msg); 1009 DispatchMessage(&msg); 1010 /*}*/ 1011 } 1012 return (int) msg.wParam; 1013 }
Note:
See TracChangeset
for help on using the changeset viewer.