changeset 10212:08251403c871

[gaim-migrate @ 11336] Both the installer and gaim make checks to see if an instance of gaim is already running. committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Sat, 20 Nov 2004 00:42:42 +0000
parents bce48f8324b3
children c1b581074aaf
files gaim-installer.nsi src/win32/nsis/langmacros.nsh src/win32/nsis/translations/english.nsh src/win_gaim.c
diffstat 4 files changed, 47 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/gaim-installer.nsi	Fri Nov 19 22:52:47 2004 +0000
+++ b/gaim-installer.nsi	Sat Nov 20 00:42:42 2004 +0000
@@ -1004,7 +1004,29 @@
   done:
 FunctionEnd
 
+Function RunCheck
+  System::Call 'kernel32::OpenMutex(i 2031617, b 0, t "gaim_is_running") i .R0'
+  IntCmp $R0 0 done
+  MessageBox MB_OK|MB_ICONEXCLAMATION $(GAIM_IS_RUNNING) IDOK
+    Abort
+  done:
+FunctionEnd
+
+Function un.RunCheck
+  System::Call 'kernel32::OpenMutex(i 2031617, b 0, t "gaim_is_running") i .R0'
+  IntCmp $R0 0 done
+  MessageBox MB_OK|MB_ICONEXCLAMATION $(GAIM_IS_RUNNING) IDOK
+    Abort
+  done:
+FunctionEnd
+
 Function .onInit
+  System::Call 'kernel32::CreateMutexA(i 0, i 0, t "gaim_installer_running") i .r1 ?e'
+  Pop $R0
+  StrCmp $R0 0 +3
+    MessageBox MB_OK|MB_ICONEXCLAMATION $(INSTALLER_IS_RUNNING)
+    Abort
+  Call RunCheck
   StrCpy $name "Gaim ${GAIM_VERSION}"
   StrCpy $GTK_THEME_SEL ${SecGtkWimp}
   StrCpy $ISSILENT "/NOUI"
@@ -1045,6 +1067,7 @@
 FunctionEnd
 
 Function un.onInit
+  Call un.RunCheck
   StrCpy $name "Gaim ${GAIM_VERSION}"
 
   ; Get stored language prefrence
@@ -1278,3 +1301,4 @@
     IntOp $LANG_IS_SET 0 + 1
   next:
 FunctionEnd
+
--- a/src/win32/nsis/langmacros.nsh	Fri Nov 19 22:52:47 2004 +0000
+++ b/src/win32/nsis/langmacros.nsh	Sat Nov 20 00:42:42 2004 +0000
@@ -25,11 +25,13 @@
   !include "${GAIM_DEFAULT_LANGFILE}"
   !undef INSERT_DEFAULT
 
-  ; GAIM Language file Version 2
+  ; GAIM Language file Version 3
   ; String labels should match those from the default language file.
 
-  ; Startup GTK+ check
-  !insertmacro GAIM_MACRO_LANGSTRING_INSERT GTK_INSTALLER_NEEDED		${CUR_LANG}
+  ; Startup checks
+  !insertmacro GAIM_MACRO_LANGSTRING_INSERT INSTALLER_IS_RUNNING			${CUR_LANG}
+  !insertmacro GAIM_MACRO_LANGSTRING_INSERT GAIM_IS_RUNNING				${CUR_LANG}
+  !insertmacro GAIM_MACRO_LANGSTRING_INSERT GTK_INSTALLER_NEEDED			${CUR_LANG}
 
   ; License Page
   !insertmacro GAIM_MACRO_LANGSTRING_INSERT GAIM_LICENSE_BUTTON			${CUR_LANG}
@@ -64,7 +66,7 @@
 
   ; GTK+ Section Prompts
   !insertmacro GAIM_MACRO_LANGSTRING_INSERT GTK_INSTALL_ERROR			${CUR_LANG}
-  !insertmacro GAIM_MACRO_LANGSTRING_INSERT GTK_BAD_INSTALL_PATH		${CUR_LANG}
+  !insertmacro GAIM_MACRO_LANGSTRING_INSERT GTK_BAD_INSTALL_PATH			${CUR_LANG}
 
   ; GTK+ Themes section
   !insertmacro GAIM_MACRO_LANGSTRING_INSERT GTK_NO_THEME_INSTALL_RIGHTS		${CUR_LANG}
--- a/src/win32/nsis/translations/english.nsh	Fri Nov 19 22:52:47 2004 +0000
+++ b/src/win32/nsis/translations/english.nsh	Sat Nov 20 00:42:42 2004 +0000
@@ -4,14 +4,16 @@
 ;;  Default language strings for the Windows Gaim NSIS installer.
 ;;  Windows Code page: 1252
 ;;
-;;  Version 2
+;;  Version 3
 ;;  Note: If translating this file, replace "!insertmacro GAIM_MACRO_DEFAULT_STRING"
 ;;  with "!define".
 
 ; Make sure to update the GAIM_MACRO_LANGUAGEFILE_END macro in
 ; langmacros.nsh when updating this file
 
-; Startup GTK+ check
+; Startup Checks
+!insertmacro GAIM_MACRO_DEFAULT_STRING INSTALLER_IS_RUNNING			"The installer is already running."
+!insertmacro GAIM_MACRO_DEFAULT_STRING GAIM_IS_RUNNING			"An instance of Gaim is currently running. Exit Gaim then try again."
 !insertmacro GAIM_MACRO_DEFAULT_STRING GTK_INSTALLER_NEEDED			"The GTK+ runtime environment is either missing or needs to be upgraded.$\rPlease install v${GTK_VERSION} or higher of the GTK+ runtime"
 
 ; License Page
--- a/src/win_gaim.c	Fri Nov 19 22:52:47 2004 +0000
+++ b/src/win_gaim.c	Sat Nov 20 00:42:42 2004 +0000
@@ -245,6 +245,17 @@
         putenv(envstr);
 }
 
+static BOOL wgaim_set_running() {
+	HANDLE h;
+
+	if((h=CreateMutex(NULL, FALSE, "gaim_is_running"))) {
+		if(GetLastError() == ERROR_ALREADY_EXISTS) {
+			MessageBox(NULL, "An instance of Gaim is already running", NULL, MB_OK | MB_TOPMOST);
+			return FALSE;
+		}
+	}
+	return TRUE;
+}
 
 #ifdef __GNUC__
 #  ifndef _stdcall
@@ -293,6 +304,8 @@
                 dll_prep();
 
         wgaim_set_locale();
+		if(!wgaim_set_running())
+			return 0;
 
         /* Now we are ready for Gaim .. */
         if((hmod=LoadLibrary("gaim.dll"))) {