comparison pidgin/win32/winpidgin.c @ 21852:c8e37362179a

Allow the user to Retry if Pidgin is running when they start the installer. Fixes #4355
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 18 Dec 2007 02:26:44 +0000
parents c9c6f77f624e
children 6492a6ca4b03
comparison
equal deleted inserted replaced
21851:54e1f0e024d2 21852:c8e37362179a
443 } 443 }
444 444
445 #define PIDGIN_WM_FOCUS_REQUEST (WM_APP + 13) 445 #define PIDGIN_WM_FOCUS_REQUEST (WM_APP + 13)
446 #define PIDGIN_WM_PROTOCOL_HANDLE (WM_APP + 14) 446 #define PIDGIN_WM_PROTOCOL_HANDLE (WM_APP + 14)
447 447
448 static BOOL winpidgin_set_running() { 448 static BOOL winpidgin_set_running(BOOL fail_if_running) {
449 HANDLE h; 449 HANDLE h;
450 450
451 if ((h = CreateMutex(NULL, FALSE, "pidgin_is_running"))) { 451 if ((h = CreateMutex(NULL, FALSE, "pidgin_is_running"))) {
452 if (GetLastError() == ERROR_ALREADY_EXISTS) { 452 DWORD err = GetLastError();
453 if (err == ERROR_ALREADY_EXISTS && fail_if_running) {
453 HWND msg_win; 454 HWND msg_win;
454 455
455 printf("An instance of Pidgin is already running.\n"); 456 printf("An instance of Pidgin is already running.\n");
456 457
457 if((msg_win = FindWindowEx(HWND_MESSAGE, NULL, TEXT("WinpidginMsgWinCls"), NULL))) 458 if((msg_win = FindWindowEx(HWND_MESSAGE, NULL, TEXT("WinpidginMsgWinCls"), NULL)))
463 MessageBox(NULL, 464 MessageBox(NULL,
464 "An instance of Pidgin is already running", 465 "An instance of Pidgin is already running",
465 NULL, MB_OK | MB_TOPMOST); 466 NULL, MB_OK | MB_TOPMOST);
466 467
467 return FALSE; 468 return FALSE;
468 } 469 } else
470 printf("Error (%d) accessing \"pidgin_is_running\" mutex.\n", err);
469 } 471 }
470 return TRUE; 472 return TRUE;
471 } 473 }
472 474
473 #define PROTO_HANDLER_SWITCH "--protocolhandler=" 475 #define PROTO_HANDLER_SWITCH "--protocolhandler="
626 else if (!getenv("PIDGIN_NO_DLL_CHECK")) 628 else if (!getenv("PIDGIN_NO_DLL_CHECK"))
627 dll_prep(); 629 dll_prep();
628 630
629 winpidgin_set_locale(); 631 winpidgin_set_locale();
630 /* If help, version or multiple flag used, do not check Mutex */ 632 /* If help, version or multiple flag used, do not check Mutex */
631 if (!strstr(lpszCmdLine, "-h") && !strstr(lpszCmdLine, "-v") && !strstr(lpszCmdLine, "-m")) 633 if (!strstr(lpszCmdLine, "-h") && !strstr(lpszCmdLine, "-v"))
632 if (!getenv("PIDGIN_MULTI_INST") && !winpidgin_set_running()) 634 if (!winpidgin_set_running(getenv("PIDGIN_MULTI_INST") == NULL && strstr(lpszCmdLine, "-m") == NULL))
633 return 0; 635 return 0;
634 636
635 /* Now we are ready for Pidgin .. */ 637 /* Now we are ready for Pidgin .. */
636 if ((hmod = LoadLibrary("pidgin.dll"))) 638 if ((hmod = LoadLibrary("pidgin.dll")))
637 pidgin_main = (LPFNPIDGINMAIN) GetProcAddress(hmod, "pidgin_main"); 639 pidgin_main = (LPFNPIDGINMAIN) GetProcAddress(hmod, "pidgin_main");