? abi/src/ask/gendata/win/ask_gendata_data_Win32.c ? abi/src/pkg/win/setup/setup.rc2 Index: abi/src/ask/gendata/win/Makefile =================================================================== RCS file: /cvsroot/abi/src/ask/gendata/win/Makefile,v retrieving revision 1.5 diff -u -r1.5 Makefile --- abi/src/ask/gendata/win/Makefile 2000/06/02 15:17:40 1.5 +++ abi/src/ask/gendata/win/Makefile 2000/09/09 14:57:13 @@ -22,7 +22,7 @@ include $(ABI_ROOT)/src/config/abi_defs.mk -CSRCS= ask_gendata_main_Win32.c +CSRCS= ask_gendata_main_Win32.c ask_gendata_data_Win32.c PROGRAM= $(BINDIR)/ask_gendata.exe @@ -37,6 +37,12 @@ GARBAGE= ask_gendata.map ask_gendata.pdb TARGETS= $(PROGRAM) + +ifeq ($(OS_NAME), WIN32) +INCLUDES= -I$(ABI_XX_ROOT)/src/ask/lib/xp +else +INCLUDES= -I$(ABI_ROOT)/src/ask/lib/xp +endif include $(ABI_ROOT)/src/config/abi_rules.mk Index: abi/src/ask/gendata/win/ask_gendata_main_Win32.c =================================================================== RCS file: /cvsroot/abi/src/ask/gendata/win/ask_gendata_main_Win32.c,v retrieving revision 1.1 diff -u -r1.1 ask_gendata_main_Win32.c --- abi/src/ask/gendata/win/ask_gendata_main_Win32.c 1999/05/11 21:47:34 1.1 +++ abi/src/ask/gendata/win/ask_gendata_main_Win32.c 2000/09/09 14:57:13 @@ -15,6 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include int main(int argc, char**argv) { Index: abi/src/ask/gendata/xp/ask_gendata.c =================================================================== RCS file: /cvsroot/abi/src/ask/gendata/xp/ask_gendata.c,v retrieving revision 1.4 diff -u -r1.4 ask_gendata.c --- abi/src/ask/gendata/xp/ask_gendata.c 1999/05/15 02:37:06 1.4 +++ abi/src/ask/gendata/xp/ask_gendata.c 2000/09/09 14:57:15 @@ -442,6 +442,7 @@ fprintf(fpOut, "/* This file was automatically generated by the AbiSource Setup Kit. */\n"); fprintf(fpOut, "#include \"ask.h\"\n\n"); + ASK_PlatformSpecificInstructions(fpOut); parseInputFile(argv[1], fpOut); @@ -461,7 +462,7 @@ pCurrentSet = pFirstSet; while (pCurrentSet) { - int iNumFilesInSet = 0; + long iNumFilesInSet = 0; fprintf(fpOut, "\nASK_DataFile* _fileset%05d_files[] = {\n", iSetNum); { struct data_file_list_node* pNode = pCurrentSet->pHead; @@ -480,7 +481,7 @@ fprintf(fpOut, "\t\"%s\",\n", pCurrentSet->szDefaultPath); fprintf(fpOut, "\t\"%s\",\n", pCurrentSet->szDirName); fprintf(fpOut, "\t\"%s\",\n", pCurrentSet->szKeyword); - fprintf(fpOut, "\t%d,\n", iNumFilesInSet); + fprintf(fpOut, "\t%ld,\n", iNumFilesInSet); fprintf(fpOut, "\t%d,\n", pCurrentSet->bFixedPath); fprintf(fpOut, "\t_fileset%05d_files\n", iSetNum); fprintf(fpOut, "};\n"); Index: abi/src/ask/lib/win/ask_lib_Win32.c =================================================================== RCS file: /cvsroot/abi/src/ask/lib/win/ask_lib_Win32.c,v retrieving revision 1.9 diff -u -r1.9 ask_lib_Win32.c --- abi/src/ask/lib/win/ask_lib_Win32.c 2000/04/13 23:55:06 1.9 +++ abi/src/ask/lib/win/ask_lib_Win32.c 2000/09/09 14:57:23 @@ -50,6 +50,8 @@ HFONT g_hfontMain; +static int s_bInstallationSuccessfull = 0; + #define ID_PANE 1000 #define ID_BTN_NEXT 1001 #define ID_BTN_CANCEL 1002 @@ -163,9 +165,18 @@ DWORD iNumberOfFreeClusters; DWORD iTotalNumberOfClusters; DWORD iBytes; + int iResult; if (g_pSet_BrowseDir->pszDirName &&g_pSet_BrowseDir->pszDirName[0]) { + /* The disk root directory path ends with '\' but deeper path do not */ + int iPathLength = strlen(pszPath); + if(pszPath[iPathLength - 1] == '\\') + { + /* Eliminate the '\' as we will build the complete path again */ + pszPath[iPathLength - 1] = '\0'; + } + sprintf(g_szBrowseDir, "%s/%s", pszPath, g_pSet_BrowseDir->pszDirName); } else @@ -184,17 +195,30 @@ p++; *p = 0; - GetDiskFreeSpace(szBuf, + iResult = GetDiskFreeSpace(szBuf, &iSectorsPerCluster, &iBytesPerSector, &iNumberOfFreeClusters, &iTotalNumberOfClusters); - iBytes = iNumberOfFreeClusters * iSectorsPerCluster * iBytesPerSector; + iBytes = (iResult != 0 ? iNumberOfFreeClusters : 0) + * iSectorsPerCluster * iBytesPerSector; // and set it into the static text display ASK_convertBytesToString(iBytes, szBuf); SetWindowText(g_hwndStatic_DiskSpace, szBuf); + + if(iResult == 0) + { + EnableWindow(g_hwndButtonNext, FALSE); + MessageBox(g_hwndMain, + "The selected disk is not available.", "Error", + MB_ICONEXCLAMATION | MB_OK); + } + else + { + EnableWindow(g_hwndButtonNext, TRUE); + } } static void _png_read(png_structp png_ptr, png_bytep data, png_size_t length) @@ -334,7 +358,7 @@ { g_iWhichButton = ID_BTN_CANCEL; QuitEventLoop(); - return 0; + return 1; } else { @@ -380,7 +404,7 @@ bi.pidlRoot = pidlPrograms; bi.pszDisplayName = lpBuffer; bi.lpszTitle = "Please choose a folder"; - bi.ulFlags = 0; + bi.ulFlags = BIF_RETURNONLYFSDIRS; bi.lpfn = NULL; bi.lParam = 0; @@ -422,7 +446,8 @@ } else if (wParam == 27) { - return try_cancel(); + try_cancel(); + return 0; } else { @@ -439,7 +464,8 @@ case BN_CLICKED: if (wID == ID_BTN_CANCEL) { - return try_cancel(); + try_cancel(); + return 0; } else if (wID == ID_BTN_NEXT) { @@ -467,6 +493,21 @@ return 0; } + + case WM_CLOSE: + { + if(s_bInstallationSuccessfull) + { + QuitEventLoop(); + PostQuitMessage(0); + return 0; + } + else + { + return ! try_cancel(); + } + } + case WM_DESTROY: { PostQuitMessage(0); @@ -609,7 +650,7 @@ #define GRAPHIC_WIDTH 200 -int ASK_Win32_Init(HINSTANCE hInstance) +int ASK_Win32_Init(HINSTANCE hInstance, long iIconId) { int iScreenWidth; int iScreenHeight; @@ -633,7 +674,7 @@ g_wndclassMain.cbClsExtra = 0; g_wndclassMain.cbWndExtra = 0; g_wndclassMain.hInstance = hInstance; - g_wndclassMain.hIcon = LoadIcon(NULL, IDI_APPLICATION); + g_wndclassMain.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(iIconId)); g_wndclassMain.hCursor = LoadCursor(NULL, IDC_ARROW); g_wndclassMain.hbrBackground = GetSysColorBrush(COLOR_BTNFACE); g_wndclassMain.lpszMenuName = NULL; @@ -701,7 +742,7 @@ g_hwndMain = CreateWindow("AbiSetup_MainWindow", "AbiSetup", - WS_BORDER | WS_VISIBLE | WS_CLIPCHILDREN, + WS_BORDER | WS_VISIBLE | WS_CLIPCHILDREN | WS_SYSMENU, (iScreenWidth - MAINWIN_WIDTH) / 2, (iScreenHeight - MAINWIN_HEIGHT) /2, MAINWIN_WIDTH, @@ -957,6 +998,9 @@ int iHeight; RECT r; + HCURSOR hcursorHourGlass; + HCURSOR hcursorPrev; + if (pSet->bFixedPath) { // just do the fixed default path, but check for special names @@ -973,6 +1017,9 @@ return 1; } + hcursorHourGlass = LoadCursor(NULL, IDC_WAIT); + hcursorPrev = SetCursor(hcursorHourGlass); + sprintf(buf, "Choose directory for \"%s\"", pSet->pszName); SetWindowText(g_hwndMain, buf); @@ -1057,13 +1104,13 @@ SendMessage(hwndStatic_Dir, WM_SETFONT, (WPARAM) g_hfontMain, 0); SendMessage(hwndStatic_Space, WM_SETFONT, (WPARAM) g_hfontMain, 0); - ASK_convertBytesToString(ASK_getFileSetTotalSizeInBytes(pSet), buf2); + ASK_convertBytesToString(ASK_getFileSetTotalSizeInBytesToCopy(pSet), buf2); sprintf(buf, "\r\nPlease select a directory where '%s' will be installed.\r\n\r\nThe set '%s' contains %d files,\r\na total of %s.\r\n\r\n", pSet->pszName, pSet->pszName, - pSet->iNumFilesInSet, + ASK_getFileSetTotalFilesToCopy(pSet), buf2); SetWindowText(hwndStatic_Top, buf); @@ -1071,6 +1118,8 @@ g_hwndStatic_BrowseDir = hwndStatic_Dir; g_hwndStatic_DiskSpace = hwndStatic_Space; + SetCursor(hcursorPrev); + _updateDirAndSpace(g_pSet_BrowseDir->pszDefaultPath); result = DoEventLoop(); @@ -1105,8 +1154,8 @@ { ASK_FileSet* pSet = ppSets[ndxSet]; - iTotalBytes += ASK_getFileSetTotalSizeInBytes(pSet); - iTotalNumFiles += pSet->iNumFilesInSet; + iTotalBytes += ASK_getFileSetTotalSizeInBytesToCopy(pSet); + iTotalNumFiles += ASK_getFileSetTotalFilesToCopy(pSet); } ASK_convertBytesToString(iTotalBytes, buf2); @@ -1151,7 +1200,8 @@ etc. */ - int result; + int bCopyCancelled = 0; + int bErrorOccured = 0; int ndxSet; int ndxFile; @@ -1177,8 +1227,8 @@ { ASK_FileSet* pSet = ppSets[ndxSet]; - iTotalBytes += ASK_getFileSetTotalSizeInBytes(pSet); - iTotalNumFiles += pSet->iNumFilesInSet; + iTotalBytes += ASK_getFileSetTotalSizeInBytesToCopy(pSet); + iTotalNumFiles += ASK_getFileSetTotalFilesToCopy(pSet); } GetClientRect(g_hwndPane, &r); @@ -1258,7 +1308,7 @@ ); SetWindowText(hwndStatic_Top, buf); - for (ndxSet=0; ndxSetszInstallPath); ASK_verifyDirExists(pSet->szInstallPath); - for (ndxFile=0; ndxFileiNumFilesInSet; ndxFile++) + for (ndxFile=0; ndxFileiNumFilesInSet && bCopyCancelled == 0; ndxFile++) { - ASK_DataFile* pFile = pSet->aFiles[ndxFile]; - - iCurFile++; - - sprintf(buf, "Copying file %d of %d (%s)", - iCurFile, - iTotalNumFiles, - pFile->pszFileName - ); - SetWindowText(hwndStatic_CurFile, buf); - + if(pSet->aFiles[ndxFile]->bNoCopy == 0) { - int err; - - if (pFile->pszRelPath) - { - char szRelDir[ASK_MAX_PATH + 1]; - - sprintf(szRelDir, "%s/%s", pSet->szInstallPath, pFile->pszRelPath); - ASK_fixSlashes(szRelDir); - ASK_verifyDirExists(szRelDir); - - sprintf(pFile->szInstallPath, "%s/%s/%s", pSet->szInstallPath, pFile->pszRelPath, pFile->pszFileName); - } - else - { - sprintf(pFile->szInstallPath, "%s/%s", pSet->szInstallPath, pFile->pszFileName); - } - - ASK_fixSlashes(pFile->szInstallPath); + ASK_DataFile* pFile = pSet->aFiles[ndxFile]; - // TODO check to see if the file and/or its directory exist. + iCurFile++; - err = ASK_decompressAndWriteFile(pFile); - if (err < 0) + sprintf(buf, "Copying file %d of %d (%s)", + iCurFile, + iTotalNumFiles, + pFile->pszFileName + ); + SetWindowText(hwndStatic_CurFile, buf); + { - char szErr[ASK_MAX_PATH+1]; + int err; + int bKeepExistingFile = 0; - sprintf(szErr, "Attempt to write file '%s' failed", pFile->szInstallPath); - - MessageBox(g_hwndMain, szErr, "Error", MB_ICONEXCLAMATION | MB_OK); - } + if (pFile->pszRelPath) + { + char szRelDir[ASK_MAX_PATH + 1]; + + sprintf(szRelDir, "%s/%s", pSet->szInstallPath, pFile->pszRelPath); + ASK_fixSlashes(szRelDir); + ASK_verifyDirExists(szRelDir); + + sprintf(pFile->szInstallPath, "%s/%s/%s", pSet->szInstallPath, pFile->pszRelPath, pFile->pszFileName); + } + else + { + sprintf(pFile->szInstallPath, "%s/%s", pSet->szInstallPath, pFile->pszFileName); + } - if ( - !(pFile->bNoCopy) - && !(pFile->bNoRemove)) - { - ASK_addToRemoveFile(pFile->szInstallPath); + ASK_fixSlashes(pFile->szInstallPath); + + if(ASK_isFileNewer(pFile->szInstallPath, pFile->iModTime)) + { + sprintf(buf, "A file on your system is newer than the one supplied with this\r\n\ +installation. It is recommanded to keep the existing file.\r\n\ +\r\n\ +File name:\t'%s'\r\n\ +\r\n\ +Do you want to keep this file?", + pFile->szInstallPath); + + if(IDYES == MessageBox(g_hwndMain, buf, "Version conflict", + MB_ICONEXCLAMATION | MB_YESNO)) + { + bKeepExistingFile = 1; + iCurBytes += pFile->iOriginalLength; + } + } + + if(bKeepExistingFile == 0) + { + err = ASK_decompressAndWriteFile(pFile); + if (err < 0) + { + sprintf(buf, "Attempt to write file '%s' failed", pFile->szInstallPath); + + bErrorOccured = 1; + if(IDCANCEL == MessageBox(g_hwndMain, buf, "Error", + MB_ICONEXCLAMATION | MB_OKCANCEL)) + { + if(bCopyCancelled = try_cancel()) + { + break; + } + } + } + else + { + iCurBytes += pFile->iOriginalLength; + } + } + + sprintf(buf, "Processed %d of %d bytes (%d%%)",iCurBytes, iTotalBytes, (iCurBytes * 100 / iTotalBytes)); + SetWindowText(hwndStatic_CurBytes, buf); + + SendMessage(hwndProgress, PBM_SETPOS, (WPARAM) (iCurBytes * 100 / iTotalBytes), (LPARAM) 0); + + if ( + !(pFile->bNoCopy) + && !(pFile->bNoRemove)) + { + ASK_addToRemoveFile(pFile->szInstallPath); + } } } - - iCurBytes += pFile->iOriginalLength; - - sprintf(buf, "Copied %d of %d bytes (%d%%)",iCurBytes, iTotalBytes, (iCurBytes * 100 / iTotalBytes)); - SetWindowText(hwndStatic_CurBytes, buf); - - SendMessage(hwndProgress, PBM_SETPOS, (WPARAM) (iCurBytes * 100 / iTotalBytes), (LPARAM) 0); } } - sprintf(buf, - "\r\nCopying is now complete. Click the 'Next' button below to continue." - ); - SetWindowText(hwndStatic_Top, buf); - - SetWindowText(g_hwndMain, "Done Copying Files"); - EnableWindow(g_hwndButtonCancel, FALSE); + if(bErrorOccured == 0) + { + sprintf(buf, + "\r\nCopying is now complete. Click the 'Next' button below to continue." + ); + SetWindowText(hwndStatic_Top, buf); - ShowWindow(hwndProgress, SW_HIDE); - - result = DoEventLoop(); + SetWindowText(g_hwndMain, "Done Copying Files"); + EnableWindow(g_hwndButtonCancel, FALSE); - EnableWindow(g_hwndButtonCancel, TRUE); + ShowWindow(hwndProgress, SW_HIDE); + + s_bInstallationSuccessfull = 1; + DoEventLoop(); + } + else + { + EnableWindow(g_hwndButtonNext, FALSE); + EnableWindow(g_hwndButtonCancel, FALSE); + } DestroyWindow(hwndStatic_Top); DestroyWindow(hwndStatic_CurSet); @@ -1351,7 +1439,7 @@ DestroyWindow(hwndStatic_CurBytes); DestroyWindow(hwndProgress); - return result; + return bErrorOccured; } int ASK_DoScreen_license(char* pszText) @@ -1361,7 +1449,7 @@ HWND hwndStatic; RECT r; - SetWindowText(g_hwndMain, "You must accept this license in order to install the software."); + SetWindowText(g_hwndMain, "GNU General Public License."); GetClientRect(g_hwndPane, &r); @@ -1392,12 +1480,9 @@ SendMessage(hwndStatic, WM_SETFONT, (WPARAM) g_hfontMain, 0); SendMessage(hwndText, WM_SETFONT, (WPARAM) g_hfontMain, 0); - SetWindowText(hwndStatic, "Do you accept the terms of this license?"); + SetWindowText(hwndStatic, "Theses are the terms of the license"); SetWindowText(hwndText, pszText); - - SetWindowText(g_hwndButtonNext, "Yes"); - SetWindowText(g_hwndButtonCancel, "No"); result = DoEventLoop(); Index: abi/src/ask/lib/xp/ask.h =================================================================== RCS file: /cvsroot/abi/src/ask/lib/xp/ask.h,v retrieving revision 1.2 diff -u -r1.2 ask.h --- abi/src/ask/lib/xp/ask.h 1999/05/15 02:37:08 1.2 +++ abi/src/ask/lib/xp/ask.h 2000/09/09 14:57:23 @@ -79,12 +79,17 @@ int ASK_decompressAndWriteFile(ASK_DataFile* pDataFile); long ASK_getFileSetTotalSizeInBytes(ASK_FileSet* pFileSet); +long ASK_getFileSetTotalSizeInBytesToCopy(ASK_FileSet* pFileSet); +long ASK_getFileSetTotalFilesToCopy(ASK_FileSet* pFileSet); void ASK_convertBytesToString(long n, char* pszStrings); +int ASK_isFileNewer(char* pszFileName, unsigned int iModTime); /* Functions implemented in platform code */ +void ASK_createRemoveFile(char* pszName); +void ASK_registerForRemove(void); unsigned int ASK_getFileModTime(const char* pszFileName); void ASK_setFileModTime(const char* pszFileName, unsigned int iModTime); unsigned int ASK_getFileAttributes(const char* pszFileName); @@ -108,6 +113,9 @@ int ASK_YesNo(char* pszTitle, char* pszMessage); void ASK_PopulateStartMenu(char* pszGroupName, int iNumSets, ASK_FileSet** ppSets); + +void ASK_PlatformSpecificInstructions(FILE* fpOut); +int lib_main(int argc, char** argv); #endif /* ASK_H */ Index: abi/src/ask/lib/xp/ask_lib.c =================================================================== RCS file: /cvsroot/abi/src/ask/lib/xp/ask_lib.c,v retrieving revision 1.3 diff -u -r1.3 ask_lib.c --- abi/src/ask/lib/xp/ask_lib.c 1999/05/14 01:29:22 1.3 +++ abi/src/ask/lib/xp/ask_lib.c 2000/09/09 14:57:24 @@ -225,6 +225,38 @@ return len; } +long ASK_getFileSetTotalSizeInBytesToCopy(ASK_FileSet* pFileSet) +{ + long len = 0; + int i; + + for (i=0; iiNumFilesInSet; i++) + { + if(pFileSet->aFiles[i]->bNoCopy == 0) + { + len += pFileSet->aFiles[i]->iOriginalLength; + } + } + + return len; +} + +long ASK_getFileSetTotalFilesToCopy(ASK_FileSet* pFileSet) +{ + long count = 0; + int i; + + for (i=0; iiNumFilesInSet; i++) + { + if(pFileSet->aFiles[i]->bNoCopy == 0) + { + count++; + } + } + + return count; +} + void ASK_convertBytesToString(long n, char* pszStrings) { if (n < 1024) @@ -244,3 +276,18 @@ sprintf(pszStrings, "%4.1f MB", n / (1024 * 1024.0)); } +int ASK_isFileNewer(char* pszFileName, unsigned int iModTime) +{ + if(ASK_fileExists(pszFileName)) + { + if(ASK_getFileModTime(pszFileName) <= iModTime) + { + return 0; + } + else + { + return 1; + } + } + return 0; +} Index: abi/src/pkg/win/setup/setup.c =================================================================== RCS file: /cvsroot/abi/src/pkg/win/setup/setup.c,v retrieving revision 1.1 diff -u -r1.1 setup.c --- abi/src/pkg/win/setup/setup.c 1999/05/11 21:47:44 1.1 +++ abi/src/pkg/win/setup/setup.c 2000/09/09 14:57:33 @@ -21,14 +21,16 @@ #include "ask.h" -extern int ASK_Win32_Init(HINSTANCE hInstance); +#include "setup.rc2" +extern int ASK_Win32_Init(HINSTANCE hInstance, long iIconId); + int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { int result; - if (0 != ASK_Win32_Init(hInstance)) + if (0 != ASK_Win32_Init(hInstance, AP_ICON_SETUP)) { return -1; } @@ -99,7 +101,8 @@ if (err != 0) { - // TODO inform the user of the error + MessageBox(NULL, "Installation is not complete", "AbiSetup", MB_OK); + goto all_done; } } Index: abi/src/pkg/win/setup/setup.rc =================================================================== RCS file: /cvsroot/abi/src/pkg/win/setup/setup.rc,v retrieving revision 1.1 diff -u -r1.1 setup.rc --- abi/src/pkg/win/setup/setup.rc 1999/05/17 20:41:10 1.1 +++ abi/src/pkg/win/setup/setup.rc 2000/09/09 14:57:33 @@ -19,16 +19,4 @@ #include -#ifdef RC_INVOKED - -#ifdef ABISOURCE_LICENSED_TRADEMARKS - -10000 ICON DISCARDABLE "setup_tm.ico" - -#else - -10000 ICON DISCARDABLE "setup.ico" - -#endif - -#endif +#include