diff --git a/xpinstall/wizard/windows/nsinstall/nsinstall.cpp b/xpinstall/wizard/windows/nsinstall/nsinstall.cpp index 8cb56f58c6c2..5885fa34b56b 100644 --- a/xpinstall/wizard/windows/nsinstall/nsinstall.cpp +++ b/xpinstall/wizard/windows/nsinstall/nsinstall.cpp @@ -378,6 +378,18 @@ CenterWindow(HWND hWndDlg) ///////////////////////////////////////////////////////////////////////////// // Extract Files Dialog +// This routine processes windows messages that are in queue +void ProcessWindowsMessages() +{ + MSG msg; + + while(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } +} + // This routine updates the status string in the extracting dialog static void SetStatusLine(LPCTSTR lpszStatus) @@ -540,6 +552,8 @@ ExtractFilesProc(HANDLE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG lParam) { DWORD dwBytesToWrite, dwBytesWritten; + ProcessWindowsMessages(); + dwBytesToWrite = dwSizeUnCmp > 4096 ? 4096 : dwSizeUnCmp; if (!WriteFile(hFile, lpBytesUnCmp, dwBytesToWrite, &dwBytesWritten, NULL)) { @@ -768,33 +782,15 @@ RunInstaller() WaitForInputIdle(pi.hProcess, 3000); // wait up to 3 seconds if(dwMode != SILENT) { - DestroyWindow(dlgInfo.hWndDlg); + ShowWindow(dlgInfo.hWndDlg, SW_HIDE); } // Wait for the installer to complete WaitForSingleObject(pi.hProcess, INFINITE); CloseHandle(pi.hProcess); - // That was just the installer bootstrapper. Now we need to wait for the - // installer itself. We can find the process ID by looking for a window of - // class ISINSTALLSCLASS - HWND hWnd = FindWindow("ISINSTALLSCLASS", NULL); + DestroyWindow(dlgInfo.hWndDlg); - if (hWnd) { - DWORD dwProcessId; - HANDLE hProcess; - - // Get the associated process handle and wait for it to terminate - GetWindowThreadProcessId(hWnd, &dwProcessId); - - // We need the process handle to use WaitForSingleObject - hProcess = OpenProcess(STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE, FALSE, dwProcessId); - - if (hProcess) { - WaitForSingleObject(hProcess, INFINITE); - CloseHandle(hProcess); - } - } // Delete the files from the temp directory EnumResourceNames(NULL, "FILE", (ENUMRESNAMEPROC)DeleteTempFilesProc, 0); @@ -815,22 +811,40 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS hInst = hInstance; LoadString(hInst, IDS_TITLE, szTitle, MAX_BUF); + /* Allow only one instance of nsinstall to run. + * Detect a previous instance of nsinstall, bring it to the + * foreground, and quit current instance */ + if(FindWindow("NSExtracting", "Extracting...") != NULL) + return(1); + // Parse the command line ParseCommandLine(lpCmdLine); // Figure out the total size of the resources EnumResourceNames(NULL, "FILE", (ENUMRESNAMEPROC)SizeOfResourcesProc, 0); + // Register a class for the gauge + memset(&wc, 0, sizeof(wc)); + wc.lpfnWndProc = (WNDPROC)GaugeWndProc; + wc.hInstance = hInstance; + wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); + wc.lpszClassName = "NSGauge"; + RegisterClass(&wc); + + // Register a class for the main dialog + memset(&wc, 0, sizeof(wc)); + wc.style = CS_DBLCLKS | CS_SAVEBITS | CS_BYTEALIGNWINDOW; + wc.lpfnWndProc = DefDlgProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = DLGWINDOWEXTRA; + wc.hInstance = hInstance; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + wc.lpszClassName = "NSExtracting"; + RegisterClass(&wc); + if(dwMode != SILENT) { - // Register a class for the gauge - memset(&wc, 0, sizeof(wc)); - wc.lpfnWndProc = (WNDPROC)GaugeWndProc; - wc.hInstance = hInstance; - wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); - wc.lpszClassName = "NSGauge"; - RegisterClass(&wc); - // Display the dialog box dlgInfo.hWndDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EXTRACTING), NULL, (DLGPROC)DialogProc); UpdateWindow(dlgInfo.hWndDlg); diff --git a/xpinstall/wizard/windows/nsinstall/nsinstall.rc b/xpinstall/wizard/windows/nsinstall/nsinstall.rc index 82db22ac0acb..4c89f44a773f 100644 --- a/xpinstall/wizard/windows/nsinstall/nsinstall.rc +++ b/xpinstall/wizard/windows/nsinstall/nsinstall.rc @@ -20,7 +20,7 @@ * Copyright (C) 1999 Netscape Communications Corporation. All * Rights Reserved. * - * Contributor(s): + * Contributor(s): * Troy Chevalier * Sean Su */ @@ -33,6 +33,7 @@ // Generated from the TEXTINCLUDE 2 resource. // + ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -53,6 +54,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US IDD_EXTRACTING DIALOG DISCARDABLE 0, 0, 193, 61 STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Extracting..." +CLASS "NSExtracting" FONT 8, "MS Sans Serif" BEGIN LTEXT "",IDC_STATUS,9,13,159,8 diff --git a/xpinstall/wizard/windows/setup/dialogs.c b/xpinstall/wizard/windows/setup/dialogs.c index 41d4780043fd..8717ed99b7ff 100644 --- a/xpinstall/wizard/windows/setup/dialogs.c +++ b/xpinstall/wizard/windows/setup/dialogs.c @@ -1791,6 +1791,7 @@ void ProcessWindowsMessages() DispatchMessage(&msg); } } + void ShowMessage(LPSTR szMessage, BOOL bShow) { char szBuf[MAX_BUF]; diff --git a/xpinstall/wizard/windows/setup/extra.c b/xpinstall/wizard/windows/setup/extra.c index b9d8898142ec..87d1083eba35 100644 --- a/xpinstall/wizard/windows/setup/extra.c +++ b/xpinstall/wizard/windows/setup/extra.c @@ -1001,69 +1001,79 @@ long RetrieveRedirectFile() char szIndex0[MAX_BUF]; char szFileIdiGetRedirect[MAX_BUF]; char szKUrl[MAX_BUF]; + char szFileIniRedirect[MAX_BUF]; - GetPrivateProfileString("Redirect", "Status", "", szBuf, MAX_BUF, szFileIniConfig); - if(lstrcmpi(szBuf, "ENABLED") != 0) - return(0); + lstrcpy(szFileIniRedirect, szTempDir); + AppendBackSlash(szFileIniRedirect, sizeof(szFileIniRedirect)); + lstrcat(szFileIniRedirect, FILE_INI_REDIRECT); - if(GetTotalArchivesToDownload() == 0) - return(0); - - lstrcpy(szFileIdiGetRedirect, szTempDir); - AppendBackSlash(szFileIdiGetRedirect, sizeof(szFileIdiGetRedirect)); - lstrcat(szFileIdiGetRedirect, FILE_IDI_GETREDIRECT); - - GetPrivateProfileString("Redirect", "Description", "", szBuf, MAX_BUF, szFileIniConfig); - WritePrivateProfileString("File0", "desc", szBuf, szFileIdiGetRedirect); - - dwIndex0 = 0; - itoa(dwIndex0, szIndex0, 10); - lstrcpy(szKUrl, "url"); - lstrcat(szKUrl, szIndex0); - GetPrivateProfileString("Redirect", szKUrl, "", szBufUrl, MAX_BUF, szFileIniConfig); - while(*szBufUrl != '\0') + if(FileExists(szFileIniRedirect)) + UpdateSiteSelector(); + else { - if(WritePrivateProfileString("File0", szIndex0, szBufUrl, szFileIdiGetRedirect) == 0) - { - char szEWPPS[MAX_BUF]; + GetPrivateProfileString("Redirect", "Status", "", szBuf, MAX_BUF, szFileIniConfig); + if(lstrcmpi(szBuf, "ENABLED") != 0) + return(0); - if(NS_LoadString(hSetupRscInst, IDS_ERROR_WRITEPRIVATEPROFILESTRING, szEWPPS, MAX_BUF) == WIZ_OK) - { - wsprintf(szBufTemp, "%s\n [%s]\n %s=%s", szFileIdiGetRedirect, "File0", szIndex0, szBufUrl); - wsprintf(szBuf, szEWPPS, szBufTemp); - PrintError(szBuf, ERROR_CODE_SHOW); - } - return(1); - } + if(GetTotalArchivesToDownload() == 0) + return(0); - ++dwIndex0; - itoa(dwIndex0, szIndex0, 10); + lstrcpy(szFileIdiGetRedirect, szTempDir); + AppendBackSlash(szFileIdiGetRedirect, sizeof(szFileIdiGetRedirect)); + lstrcat(szFileIdiGetRedirect, FILE_IDI_GETREDIRECT); + + GetPrivateProfileString("Redirect", "Description", "", szBuf, MAX_BUF, szFileIniConfig); + WritePrivateProfileString("File0", "desc", szBuf, szFileIdiGetRedirect); + + dwIndex0 = 0; + itoa(dwIndex0, szIndex0, 10); lstrcpy(szKUrl, "url"); lstrcat(szKUrl, szIndex0); GetPrivateProfileString("Redirect", szKUrl, "", szBufUrl, MAX_BUF, szFileIniConfig); - } + while(*szBufUrl != '\0') + { + if(WritePrivateProfileString("File0", szIndex0, szBufUrl, szFileIdiGetRedirect) == 0) + { + char szEWPPS[MAX_BUF]; - /* the existance of the getarchives.idi file determines if there are - any jar files needed to be downloaded */ - if(FileExists(szFileIdiGetRedirect)) - { - DecryptString(szBuf, siSDObject.szXpcomDir); - lstrcpy(siSDObject.szXpcomDir, szBuf); + if(NS_LoadString(hSetupRscInst, IDS_ERROR_WRITEPRIVATEPROFILESTRING, szEWPPS, MAX_BUF) == WIZ_OK) + { + wsprintf(szBufTemp, "%s\n [%s]\n %s=%s", szFileIdiGetRedirect, "File0", szIndex0, szBufUrl); + wsprintf(szBuf, szEWPPS, szBufTemp); + PrintError(szBuf, ERROR_CODE_SHOW); + } + return(1); + } - WritePrivateProfileString("Netscape Install", "core_file", siSDObject.szXpcomFile, szFileIdiGetRedirect); - WritePrivateProfileString("Netscape Install", "core_dir", siSDObject.szXpcomDir, szFileIdiGetRedirect); - WritePrivateProfileString("Netscape Install", "no_ads", siSDObject.szNoAds, szFileIdiGetRedirect); - WritePrivateProfileString("Netscape Install", "silent", siSDObject.szSilent, szFileIdiGetRedirect); - WritePrivateProfileString("Netscape Install", "execution", siSDObject.szExecution, szFileIdiGetRedirect); - WritePrivateProfileString("Netscape Install", "confirm_install", siSDObject.szConfirmInstall, szFileIdiGetRedirect); - WritePrivateProfileString("Netscape Install", "extract_msg", siSDObject.szExtractMsg, szFileIdiGetRedirect); - WritePrivateProfileString("Execution", "exe", siSDObject.szExe, szFileIdiGetRedirect); - WritePrivateProfileString("Execution", "exe_param", siSDObject.szExeParam, szFileIdiGetRedirect); + ++dwIndex0; + itoa(dwIndex0, szIndex0, 10); + lstrcpy(szKUrl, "url"); + lstrcat(szKUrl, szIndex0); + GetPrivateProfileString("Redirect", szKUrl, "", szBufUrl, MAX_BUF, szFileIniConfig); + } - if((lResult = SdArchives(szFileIdiGetRedirect, szTempDir)) != 0) - return(lResult); + /* the existance of the getarchives.idi file determines if there are + any jar files needed to be downloaded */ + if(FileExists(szFileIdiGetRedirect)) + { + DecryptString(szBuf, siSDObject.szXpcomDir); + lstrcpy(siSDObject.szXpcomDir, szBuf); - UpdateSiteSelector(); + WritePrivateProfileString("Netscape Install", "core_file", siSDObject.szXpcomFile, szFileIdiGetRedirect); + WritePrivateProfileString("Netscape Install", "core_dir", siSDObject.szXpcomDir, szFileIdiGetRedirect); + WritePrivateProfileString("Netscape Install", "no_ads", siSDObject.szNoAds, szFileIdiGetRedirect); + WritePrivateProfileString("Netscape Install", "silent", siSDObject.szSilent, szFileIdiGetRedirect); + WritePrivateProfileString("Netscape Install", "execution", siSDObject.szExecution, szFileIdiGetRedirect); + WritePrivateProfileString("Netscape Install", "confirm_install", siSDObject.szConfirmInstall, szFileIdiGetRedirect); + WritePrivateProfileString("Netscape Install", "extract_msg", siSDObject.szExtractMsg, szFileIdiGetRedirect); + WritePrivateProfileString("Execution", "exe", siSDObject.szExe, szFileIdiGetRedirect); + WritePrivateProfileString("Execution", "exe_param", siSDObject.szExeParam, szFileIdiGetRedirect); + + if((lResult = SdArchives(szFileIdiGetRedirect, szTempDir)) != 0) + return(lResult); + + UpdateSiteSelector(); + } } return(0); @@ -1136,6 +1146,10 @@ long RetrieveArchives() WritePrivateProfileString("Execution", "exe", siSDObject.szExe, szFileIdiGetArchives); WritePrivateProfileString("Execution", "exe_param", siSDObject.szExeParam, szFileIdiGetArchives); + /* proxy support */ +// WritePrivateProfileString("Proxy", "server", "chainsaw.mcom.com", szFileIdiGetArchives); +// WritePrivateProfileString("Proxy", "port", "8288", szFileIdiGetArchives); + if((lResult = SdArchives(szFileIdiGetArchives, szTempDir)) != 0) return(lResult); } @@ -5232,6 +5246,8 @@ void DeleteArchives() ++dwIndex0; siCObject = SiCNodeGetObject(dwIndex0, TRUE, AC_ALL); } + + DeleteIniRedirect(); } } @@ -5240,7 +5256,6 @@ void CleanTempFiles() DeleteIdiGetConfigIni(); DeleteIdiGetArchives(); DeleteIdiGetRedirect(); - DeleteIniRedirect(); /* do not delete config.ini file. if it was uncompressed from the self-extracting .exe file,