From a6d31a63a8093564b8832c935af63fb0b1e18648 Mon Sep 17 00:00:00 2001 From: sje Date: Fri, 17 Nov 2006 13:57:37 +0000 Subject: applied Eblis' patch for 'wait longer' dialog smaller progress bar git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@48 4f64403b-2f21-0410-a795-97e2b3489a10 --- updater/extern.cpp | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 12 deletions(-) (limited to 'updater/extern.cpp') diff --git a/updater/extern.cpp b/updater/extern.cpp index 2d220df..ad34bd9 100644 --- a/updater/extern.cpp +++ b/updater/extern.cpp @@ -350,15 +350,39 @@ extern "C" void __declspec(dllexport) CALLBACK ExternalUpdate(HWND hwnd, HINSTAN HANDLE hMiranda = OpenProcess(SYNCHRONIZE | PROCESS_TERMINATE, FALSE, mpi); if(hMiranda) { - if(WaitForSingleObjectEx(hMiranda, 20 * 1000, FALSE) == WAIT_TIMEOUT) { + int mbFlags, idRetry, idCancel, idContinue; + const int MAX_SIZE = 2048; + TCHAR message[MAX_SIZE]; + int exitStatus; + + OSVERSIONINFO vi = {0}; + vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&vi); + _tcsncpy(message, _T("Miranda did not exit - cannot install or restart.\n"), MAX_SIZE); + + if (vi.dwMajorVersion = 5) { + //windows 2000+ + mbFlags = 0x00000006L; //MB_CANCELTRYCONTINUE; + idRetry = 10; //IDTRYAGAIN + idCancel = IDCANCEL; + idContinue = 11; //IDCONTINUE + _tcsncat(message, _T("Press 'Try again' to check Miranda's status again, press 'Continue' to kill the process or press 'Cancel' to abort."), MAX_SIZE); + } else { + //windows 98, me + mbFlags = MB_ABORTRETRYIGNORE; + idRetry = IDRETRY; + idCancel = IDCANCEL; + idContinue = IDIGNORE; + _tcsncat(message, _T("Press 'Retry' to check Miranda's status again, press 'Ignore' to kill the process or press 'Abort' to abort."), MAX_SIZE); + } + + while ((exitStatus = WaitForSingleObjectEx(hMiranda, 20 * 1000, FALSE)) == WAIT_TIMEOUT) { + int res = MessageBox(0, message, _T("Updater Error"), mbFlags | MB_ICONERROR); - if(MessageBox(0, _T("Miranda did not exit - cannot install or restart.\n") - _T("Press OK to kill the process, ") - _T("or press Cancel to abort."), _T("Updater Error"), MB_OKCANCEL | MB_ICONERROR) == IDOK) - { + if (res == idContinue) { + //if the user chooses Continue then kill the application TerminateProcess(hMiranda, 1); - - if(WaitForSingleObjectEx(hMiranda, 5 * 1000, FALSE) == WAIT_TIMEOUT) { + if((exitStatus = WaitForSingleObjectEx(hMiranda, 5 * 1000, FALSE)) == WAIT_TIMEOUT) { //hMiranda = OpenProcess(SYNCHRONIZE, FALSE, mpi); //if(hMiranda) { //CloseHandle(hMiranda); @@ -367,17 +391,21 @@ extern "C" void __declspec(dllexport) CALLBACK ExternalUpdate(HWND hwnd, HINSTAN #ifdef _UD_LOGGING mWriteFile(hDatFile, "Wait for miranda processs to 'Terminate' interrupted - assuming it exited"); #endif - exited = true; + } + } else { + if (res == idRetry) { + //if the user selected 'Try again' then wait a bit more. + continue; //wait again } } - CloseHandle(hMiranda); - } else { + + break; //don't update anymore (happens when user choses 'Continue' or 'Cacel' + } #ifdef _UD_LOGGING mWriteFile(hDatFile, "Wait for miranda processs interrupted - assuming it exited"); #endif - exited = true; + exited = (exitStatus != WAIT_TIMEOUT); CloseHandle(hMiranda); - } } else { #ifdef _UD_LOGGING mWriteFile(hDatFile, "Could not open miranda processs - assuming it exited"); -- cgit v1.2.3