pidgin/win32/winpidgin.c

Sat, 15 Sep 2007 06:26:35 +0000

author
Sadrul Habib Chowdhury <sadrul@pidgin.im>
date
Sat, 15 Sep 2007 06:26:35 +0000
branch
sadrul.conv.persistent
changeset 20311
da3f849ce6e3
parent 19859
71d37b57eff2
child 20221
28e31ee832cd
permissions
-rw-r--r--

propagate from branch 'im.pidgin.pidgin' (head 7a408753ea6fcb06a8d7002498c1583ce6a5bcc7)
to branch 'im.pidgin.sadrul.conv.persistent' (head e6b980956cd23dd775a1b49bd600c1586f408212)

15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
1 /*
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
2 * winpidgin.c
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
3 *
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
4 * Date: June, 2002
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
5 * Description: Entry point for win32 pidgin, and various win32 dependant
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
6 * routines.
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
7 *
15931
716b5fac1895 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
8 * Pidgin is the legal property of its developers, whose names are too numerous
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
10 * source distribution.
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
11 *
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
15 * (at your option) any later version.
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
16 *
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
20 * GNU General Public License for more details.
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
21 *
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19081
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
25 *
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
26 */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
27
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
28 /* This is for ATTACH_PARENT_PROCESS */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
29 #ifndef _WIN32_WINNT
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
30 #define _WIN32_WINNT 0x501
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
31 #endif
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
32 #include <windows.h>
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
33 #include <fcntl.h>
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
34 #include <stdlib.h>
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
35 #include <string.h>
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
36 #include <stdio.h>
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
37
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
38 /* These will hopefully be in the win32api next time it is updated - at which point, we'll remove them */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
39 #ifndef LANG_PERSIAN
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
40 #define LANG_PERSIAN 0x29
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
41 #endif
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
42 #ifndef LANG_BOSNIAN
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
43 #define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN 0x05
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
44 #define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC 0x08
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
45 #endif
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
46 #ifndef SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
47 #define SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN 0x04
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
48 #endif
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
49 #ifndef LANG_XHOSA
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
50 #define LANG_XHOSA 0x34
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
51 #endif
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
52
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
53
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
54 typedef int (CALLBACK* LPFNPIDGINMAIN)(HINSTANCE, int, char**);
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
55 typedef void (CALLBACK* LPFNSETDLLDIRECTORY)(LPCTSTR);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
56 typedef BOOL (CALLBACK* LPFNATTACHCONSOLE)(DWORD);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
57
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
58 static BOOL portable_mode = FALSE;
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
59
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
60 /*
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
61 * PROTOTYPES
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
62 */
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
63 static LPFNPIDGINMAIN pidgin_main = NULL;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
64 static LPFNSETDLLDIRECTORY MySetDllDirectory = NULL;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
65
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
66 static const char *get_win32_error_message(DWORD err) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
67 static char err_msg[512];
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
68
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
69 FormatMessage(
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
70 FORMAT_MESSAGE_FROM_SYSTEM,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
71 NULL, err,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
72 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
73 (LPTSTR) &err_msg, sizeof(err_msg), NULL);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
74
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
75 return err_msg;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
76 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
77
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
78 static BOOL read_reg_string(HKEY key, char* sub_key, char* val_name, LPBYTE data, LPDWORD data_len) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
79 HKEY hkey;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
80 BOOL ret = FALSE;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
81 LONG retv;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
82
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
83 if (ERROR_SUCCESS == (retv = RegOpenKeyEx(key, sub_key, 0,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
84 KEY_QUERY_VALUE, &hkey))) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
85 if (ERROR_SUCCESS == (retv = RegQueryValueEx(hkey, val_name,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
86 NULL, NULL, data, data_len)))
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
87 ret = TRUE;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
88 else {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
89 const char *err_msg = get_win32_error_message(retv);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
90
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
91 printf("Could not read reg key '%s' subkey '%s' value: '%s'.\nMessage: (%ld) %s\n",
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
92 ((key == HKEY_LOCAL_MACHINE) ? "HKLM" :
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
93 (key == HKEY_CURRENT_USER) ? "HKCU" :
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
94 "???"),
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
95 sub_key, val_name, retv, err_msg);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
96 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
97 RegCloseKey(hkey);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
98 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
99 else {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
100 TCHAR szBuf[80];
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
101
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
102 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, retv, 0,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
103 (LPTSTR) &szBuf, sizeof(szBuf), NULL);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
104 printf("Could not open reg subkey: %s\nError: (%ld) %s\n",
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
105 sub_key, retv, szBuf);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
106 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
107
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
108 return ret;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
109 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
110
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
111 static void common_dll_prep(const char *path) {
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
112 HMODULE hmod;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
113 HKEY hkey;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
114
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
115 printf("GTK+ path found: %s\n", path);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
116
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
117 if ((hmod = GetModuleHandle("kernel32.dll"))) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
118 MySetDllDirectory = (LPFNSETDLLDIRECTORY) GetProcAddress(
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
119 hmod, "SetDllDirectoryA");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
120 if (!MySetDllDirectory)
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
121 printf("SetDllDirectory not supported\n");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
122 } else
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
123 printf("Error getting kernel32.dll module handle\n");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
124
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
125 /* For Windows XP SP1+ / Server 2003 we use SetDllDirectory to avoid dll hell */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
126 if (MySetDllDirectory) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
127 printf("Using SetDllDirectory\n");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
128 MySetDllDirectory(path);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
129 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
130
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
131 /* For the rest, we set the current directory and make sure
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
132 * SafeDllSearch is set to 0 where needed. */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
133 else {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
134 OSVERSIONINFO osinfo;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
135
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
136 printf("Setting current directory to GTK+ dll directory\n");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
137 SetCurrentDirectory(path);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
138 /* For Windows 2000 (SP3+) / WinXP (No SP):
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
139 * If SafeDllSearchMode is set to 1, Windows system directories are
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
140 * searched for dlls before the current directory. Therefore we set it
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
141 * to 0.
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
142 */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
143 osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
144 GetVersionEx(&osinfo);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
145 if ((osinfo.dwMajorVersion == 5 &&
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
146 osinfo.dwMinorVersion == 0 &&
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
147 strcmp(osinfo.szCSDVersion, "Service Pack 3") >= 0) ||
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
148 (osinfo.dwMajorVersion == 5 &&
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
149 osinfo.dwMinorVersion == 1 &&
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
150 strcmp(osinfo.szCSDVersion, "") >= 0)
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
151 ) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
152 DWORD regval = 1;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
153 DWORD reglen = sizeof(DWORD);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
154
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
155 printf("Using Win2k (SP3+) / WinXP (No SP)... Checking SafeDllSearch\n");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
156 read_reg_string(HKEY_LOCAL_MACHINE,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
157 "System\\CurrentControlSet\\Control\\Session Manager",
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
158 "SafeDllSearchMode",
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
159 (LPBYTE) &regval,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
160 &reglen);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
161
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
162 if (regval != 0) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
163 printf("Trying to set SafeDllSearchMode to 0\n");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
164 regval = 0;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
165 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
166 "System\\CurrentControlSet\\Control\\Session Manager",
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
167 0, KEY_SET_VALUE, &hkey
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
168 ) == ERROR_SUCCESS) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
169 if (RegSetValueEx(hkey,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
170 "SafeDllSearchMode", 0,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
171 REG_DWORD, (LPBYTE) &regval,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
172 sizeof(DWORD)
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
173 ) != ERROR_SUCCESS)
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
174 printf("Error writing SafeDllSearchMode. Error: %u\n",
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
175 (UINT) GetLastError());
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
176 RegCloseKey(hkey);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
177 } else
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
178 printf("Error opening Session Manager key for writing. Error: %u\n",
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
179 (UINT) GetLastError());
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
180 } else
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
181 printf("SafeDllSearchMode is set to 0\n");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
182 }/*end else*/
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
183 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
184 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
185
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
186 static void portable_mode_dll_prep(const char *pidgin_dir) {
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
187 /* need to be able to fit MAX_PATH + "PIDGIN_ASPELL_DIR=\\Aspell\\bin" in path2 */
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
188 char path[MAX_PATH + 1];
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
189 char path2[MAX_PATH + 33];
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
190 const char *prev = NULL;
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
191
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
192 /* We assume that GTK+ is installed under \\path\to\Pidgin\..\GTK
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
193 * First we find \\path\to
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
194 */
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
195 if (*pidgin_dir) {
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
196 /* pidgin_dir points to \\path\to\Pidgin */
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
197 const char *tmp = pidgin_dir;
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
198
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
199 while ((tmp = strchr(tmp, '\\'))) {
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
200 prev = tmp;
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
201 tmp++;
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
202 }
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
203 }
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
204
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
205 if (prev) {
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
206 int cnt = (prev - pidgin_dir);
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
207 strncpy(path, pidgin_dir, cnt);
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
208 path[cnt] = '\0';
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
209 } else {
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
210 printf("Unable to determine current executable path. \n"
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
211 "This will prevent the settings dir from being set.\n"
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
212 "Assuming GTK+ is in the PATH.\n");
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
213 return;
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
214 }
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
215
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
216
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
217 /* Set up the settings dir base to be \\path\to
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
218 * The actual settings dir will be \\path\to\.purple */
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
219 snprintf(path2, sizeof(path2), "PURPLEHOME=%s", path);
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
220 printf("Setting settings dir: %s\n", path2);
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
221 putenv(path2);
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
222
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
223 snprintf(path2, sizeof(path2), "PIDGIN_ASPELL_DIR=%s\\Aspell\\bin", path);
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
224 printf("%s\n", path2);
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
225 putenv(path2);
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
226
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
227 /* set the GTK+ path to be \\path\to\GTK\bin */
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
228 strcat(path, "\\GTK\\bin");
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
229
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
230 common_dll_prep(path);
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
231 }
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
232
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
233 static void dll_prep() {
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
234 char path[MAX_PATH + 1];
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
235 HKEY hkey;
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
236 char gtkpath[MAX_PATH + 1];
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
237 DWORD plen;
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
238
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
239 plen = sizeof(gtkpath);
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
240 hkey = HKEY_CURRENT_USER;
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
241 if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "Path",
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
242 (LPBYTE) &gtkpath, &plen)) {
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
243 hkey = HKEY_LOCAL_MACHINE;
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
244 if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "Path",
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
245 (LPBYTE) &gtkpath, &plen)) {
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
246 printf("GTK+ Path Registry Key not found. "
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
247 "Assuming GTK+ is in the PATH.\n");
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
248 return;
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
249 }
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
250 }
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
251
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
252 /* this value is replaced during a successful RegQueryValueEx() */
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
253 plen = sizeof(path);
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
254 /* Determine GTK+ dll path .. */
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
255 if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "DllPath",
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
256 (LPBYTE) &path, &plen)) {
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
257 strcpy(path, gtkpath);
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
258 strcat(path, "\\bin");
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
259 }
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
260
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
261 common_dll_prep(path);
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
262 }
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
263
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
264 static char* winpidgin_lcid_to_posix(LCID lcid) {
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
265 char *posix = NULL;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
266 int lang_id = PRIMARYLANGID(lcid);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
267 int sub_id = SUBLANGID(lcid);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
268
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
269 switch (lang_id) {
18771
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
270 case LANG_AFRIKAANS: posix = "af"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
271 case LANG_ARABIC: posix = "ar"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
272 case LANG_AZERI: posix = "az"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
273 case LANG_BENGALI: posix = "bn"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
274 case LANG_BULGARIAN: posix = "bg"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
275 case LANG_CATALAN: posix = "ca"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
276 case LANG_CZECH: posix = "cs"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
277 case LANG_DANISH: posix = "da"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
278 case LANG_ESTONIAN: posix = "et"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
279 case LANG_PERSIAN: posix = "fa"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
280 case LANG_GERMAN: posix = "de"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
281 case LANG_GREEK: posix = "el"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
282 case LANG_ENGLISH:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
283 switch (sub_id) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
284 case SUBLANG_ENGLISH_UK:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
285 posix = "en_GB"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
286 case SUBLANG_ENGLISH_AUS:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
287 posix = "en_AU"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
288 case SUBLANG_ENGLISH_CAN:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
289 posix = "en_CA"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
290 default:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
291 posix = "en"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
292 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
293 break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
294 case LANG_SPANISH: posix = "es"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
295 case LANG_BASQUE: posix = "eu"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
296 case LANG_FINNISH: posix = "fi"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
297 case LANG_FRENCH: posix = "fr"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
298 case LANG_GALICIAN: posix = "gl"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
299 case LANG_GUJARATI: posix = "gu"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
300 case LANG_HEBREW: posix = "he"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
301 case LANG_HINDI: posix = "hi"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
302 case LANG_HUNGARIAN: posix = "hu"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
303 case LANG_ICELANDIC: break;
18771
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
304 case LANG_INDONESIAN: posix = "id"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
305 case LANG_ITALIAN: posix = "it"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
306 case LANG_JAPANESE: posix = "ja"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
307 case LANG_GEORGIAN: posix = "ka"; break;
18771
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
308 case LANG_KANNADA: posix = "kn"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
309 case LANG_KOREAN: posix = "ko"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
310 case LANG_LITHUANIAN: posix = "lt"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
311 case LANG_MACEDONIAN: posix = "mk"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
312 case LANG_DUTCH: posix = "nl"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
313 case LANG_NEPALI: posix = "ne"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
314 case LANG_NORWEGIAN:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
315 switch (sub_id) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
316 case SUBLANG_NORWEGIAN_BOKMAL:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
317 posix = "nb"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
318 case SUBLANG_NORWEGIAN_NYNORSK:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
319 posix = "nn"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
320 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
321 break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
322 case LANG_PUNJABI: posix = "pa"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
323 case LANG_POLISH: posix = "pl"; break;
18771
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
324 case LANG_PASHTO: posix = "ps"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
325 case LANG_PORTUGUESE:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
326 switch (sub_id) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
327 case SUBLANG_PORTUGUESE_BRAZILIAN:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
328 posix = "pt_BR"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
329 default:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
330 posix = "pt"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
331 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
332 break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
333 case LANG_ROMANIAN: posix = "ro"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
334 case LANG_RUSSIAN: posix = "ru"; break;
18771
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
335 case LANG_SLOVAK: posix = "sk"; break;
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
336 case LANG_SLOVENIAN: posix = "sl"; break;
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
337 case LANG_ALBANIAN: posix = "sq"; break;
19081
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
338 /* LANG_CROATIAN == LANG_SERBIAN == LANG_BOSNIAN */
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
339 case LANG_SERBIAN:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
340 switch (sub_id) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
341 case SUBLANG_SERBIAN_LATIN:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
342 posix = "sr@Latn"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
343 case SUBLANG_SERBIAN_CYRILLIC:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
344 posix = "sr"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
345 case SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
346 case SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
347 posix = "bs"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
348 case SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
349 posix = "hr"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
350 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
351 break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
352 case LANG_SWEDISH: posix = "sv"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
353 case LANG_TAMIL: posix = "ta"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
354 case LANG_TELUGU: posix = "te"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
355 case LANG_THAI: posix = "th"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
356 case LANG_TURKISH: posix = "tr"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
357 case LANG_UKRAINIAN: posix = "uk"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
358 case LANG_VIETNAMESE: posix = "vi"; break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
359 case LANG_XHOSA: posix = "xh"; break;
18771
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
360 case LANG_CHINESE:
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
361 switch (sub_id) {
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
362 case SUBLANG_CHINESE_SIMPLIFIED:
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
363 posix = "zh_CN"; break;
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
364 case SUBLANG_CHINESE_TRADITIONAL:
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
365 posix = "zh_TW"; break;
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
366 default:
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
367 posix = "zh"; break;
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
368 }
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
369 break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
370 case LANG_URDU: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
371 case LANG_BELARUSIAN: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
372 case LANG_LATVIAN: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
373 case LANG_ARMENIAN: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
374 case LANG_FAEROESE: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
375 case LANG_MALAY: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
376 case LANG_KAZAK: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
377 case LANG_KYRGYZ: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
378 case LANG_SWAHILI: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
379 case LANG_UZBEK: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
380 case LANG_TATAR: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
381 case LANG_ORIYA: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
382 case LANG_MALAYALAM: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
383 case LANG_ASSAMESE: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
384 case LANG_MARATHI: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
385 case LANG_SANSKRIT: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
386 case LANG_MONGOLIAN: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
387 case LANG_KONKANI: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
388 case LANG_MANIPURI: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
389 case LANG_SINDHI: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
390 case LANG_SYRIAC: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
391 case LANG_KASHMIRI: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
392 case LANG_DIVEHI: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
393 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
394
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
395 /* Deal with exceptions */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
396 if (posix == NULL) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
397 switch (lcid) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
398 case 0x0455: posix = "my_MM"; break; /* Myanmar (Burmese) */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
399 case 9999: posix = "ku"; break; /* Kurdish (from NSIS) */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
400 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
401 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
402
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
403 return posix;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
404 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
405
16080
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
406 /* Determine and set Pidgin locale as follows (in order of priority):
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
407 - Check PIDGINLANG env var
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
408 - Check NSIS Installer Language reg value
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
409 - Use default user locale
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
410 */
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
411 static const char *winpidgin_get_locale() {
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
412 const char *locale = NULL;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
413 LCID lcid;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
414 char data[10];
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
415 DWORD datalen = 10;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
416
16080
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
417 /* Check if user set PIDGINLANG env var */
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
418 if ((locale = getenv("PIDGINLANG")))
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
419 return locale;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
420
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
421 if (!portable_mode && read_reg_string(HKEY_CURRENT_USER, "SOFTWARE\\pidgin",
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
422 "Installer Language", (LPBYTE) &data, &datalen)) {
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
423 if ((locale = winpidgin_lcid_to_posix(atoi(data))))
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
424 return locale;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
425 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
426
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
427 lcid = GetUserDefaultLCID();
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
428 if ((locale = winpidgin_lcid_to_posix(lcid)))
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
429 return locale;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
430
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
431 return "en";
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
432 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
433
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
434 static void winpidgin_set_locale() {
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
435 const char *locale = NULL;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
436 char envstr[25];
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
437
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
438 locale = winpidgin_get_locale();
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
439
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
440 snprintf(envstr, 25, "LANG=%s", locale);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
441 printf("Setting locale: %s\n", envstr);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
442 putenv(envstr);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
443 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
444
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
445 #define PIDGIN_WM_FOCUS_REQUEST (WM_APP + 13)
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
446 #define PIDGIN_WM_PROTOCOL_HANDLE (WM_APP + 14)
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
447
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
448 static BOOL winpidgin_set_running() {
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
449 HANDLE h;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
450
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
451 if ((h = CreateMutex(NULL, FALSE, "pidgin_is_running"))) {
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
452 if (GetLastError() == ERROR_ALREADY_EXISTS) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
453 HWND msg_win;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
454
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
455 if((msg_win = FindWindow(TEXT("WinpidginMsgWinCls"), NULL)))
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
456 if(SendMessage(msg_win, PIDGIN_WM_FOCUS_REQUEST, (WPARAM) NULL, (LPARAM) NULL))
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
457 return FALSE;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
458
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
459 /* If we get here, the focus request wasn't successful */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
460
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
461 MessageBox(NULL,
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
462 "An instance of Pidgin is already running",
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
463 NULL, MB_OK | MB_TOPMOST);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
464
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
465 return FALSE;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
466 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
467 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
468 return TRUE;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
469 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
470
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
471 #define PROTO_HANDLER_SWITCH "--protocolhandler="
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
472
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
473 static void handle_protocol(char *cmd) {
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
474 char *remote_msg, *tmp1, *tmp2;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
475 int len;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
476 SIZE_T len_written;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
477 HWND msg_win;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
478 DWORD pid;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
479 HANDLE process;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
480
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
481 /* The start of the message */
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
482 tmp1 = cmd + strlen(PROTO_HANDLER_SWITCH);
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
483
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
484 /* The end of the message */
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
485 if ((tmp2 = strchr(tmp1, ' ')))
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
486 len = (tmp2 - tmp1);
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
487 else
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
488 len = strlen(tmp1);
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
489
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
490 if (len == 0) {
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
491 printf("No protocol message specified.\n");
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
492 return;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
493 }
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
494
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
495 if (!(msg_win = FindWindow(TEXT("WinpidginMsgWinCls"), NULL))) {
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
496 printf("Unable to find an instance of Pidgin to handle protocol message.\n");
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
497 return;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
498 }
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
499
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
500 GetWindowThreadProcessId(msg_win, &pid);
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
501 if (!(process = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE, FALSE, pid))) {
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
502 DWORD dw = GetLastError();
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
503 const char *err_msg = get_win32_error_message(dw);
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
504 printf("Unable to open Pidgin process. (%u) %s\n", (UINT) dw, err_msg);
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
505 return;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
506 }
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
507
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
508 printf("Trying to handle protocol message:\n'%*s'\n", len, tmp1);
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
509
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
510 /* MEM_COMMIT initializes the memory to zero,
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
511 * so we don't need to worry that our section of tmp1 isn't nul-terminated */
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
512 if ((remote_msg = (char*) VirtualAllocEx(process, NULL, len + 1, MEM_COMMIT, PAGE_READWRITE))) {
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
513 if (WriteProcessMemory(process, remote_msg, tmp1, len, &len_written)) {
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
514 if (!SendMessage(msg_win, PIDGIN_WM_PROTOCOL_HANDLE, len_written, (LPARAM) remote_msg))
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
515 printf("Unable to send protocol message to Pidgin instance.\n");
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
516 } else {
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
517 DWORD dw = GetLastError();
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
518 const char *err_msg = get_win32_error_message(dw);
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
519 printf("Unable to write to remote memory. (%u) %s\n", (UINT) dw, err_msg);
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
520 }
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
521
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
522 VirtualFreeEx(process, remote_msg, 0, MEM_RELEASE);
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
523 } else {
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
524 DWORD dw = GetLastError();
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
525 const char *err_msg = get_win32_error_message(dw);
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
526 printf("Unable to allocate remote memory. (%u) %s\n", (UINT) dw, err_msg);
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
527 }
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
528
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
529 CloseHandle(process);
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
530 }
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
531
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
532
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
533 int _stdcall
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
534 WinMain (struct HINSTANCE__ *hInstance, struct HINSTANCE__ *hPrevInstance,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
535 char *lpszCmdLine, int nCmdShow) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
536 char errbuf[512];
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
537 char pidgin_dir[MAX_PATH];
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
538 char exe_name[MAX_PATH];
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
539 HMODULE hmod;
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
540 char *tmp;
19081
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
541 int pidgin_argc = __argc;
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
542 char **pidgin_argv = __argv;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
543
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
544 /* If debug or help or version flag used, create console for output */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
545 if (strstr(lpszCmdLine, "-d") || strstr(lpszCmdLine, "-h") || strstr(lpszCmdLine, "-v")) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
546 /* If stdout hasn't been redirected to a file, alloc a console
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
547 * (_istty() doesn't work for stuff using the GUI subsystem) */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
548 if (_fileno(stdout) == -1) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
549 LPFNATTACHCONSOLE MyAttachConsole = NULL;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
550 if ((hmod = GetModuleHandle("kernel32.dll"))) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
551 MyAttachConsole =
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
552 (LPFNATTACHCONSOLE)
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
553 GetProcAddress(hmod, "AttachConsole");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
554 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
555 if ((MyAttachConsole && MyAttachConsole(ATTACH_PARENT_PROCESS))
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
556 || AllocConsole()) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
557 freopen("CONOUT$", "w", stdout);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
558 freopen("CONOUT$", "w", stderr);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
559 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
560 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
561 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
562
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
563 /* If this is a protocol handler invocation, deal with it accordingly */
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
564 if ((tmp = strstr(lpszCmdLine, PROTO_HANDLER_SWITCH)) != NULL) {
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
565 handle_protocol(tmp);
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
566 return 0;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
567 }
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
568
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
569 /* Load exception handler if we have it */
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
570 if (GetModuleFileName(NULL, pidgin_dir, MAX_PATH) != 0) {
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
571 char *prev = NULL;
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
572 tmp = pidgin_dir;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
573
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
574 /* primitive dirname() */
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
575 while ((tmp = strchr(tmp, '\\'))) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
576 prev = tmp;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
577 tmp++;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
578 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
579
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
580 if (prev) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
581 prev[0] = '\0';
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
582
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
583 /* prev++ will now point to the executable file name */
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
584 strcpy(exe_name, prev + 1);
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
585
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
586 strcat(pidgin_dir, "\\exchndl.dll");
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
587 if (LoadLibrary(pidgin_dir))
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
588 printf("Loaded exchndl.dll\n");
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
589
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
590 prev[0] = '\0';
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
591 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
592 } else {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
593 DWORD dw = GetLastError();
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
594 const char *err_msg = get_win32_error_message(dw);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
595 snprintf(errbuf, 512,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
596 "Error getting module filename.\nError: (%u) %s",
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
597 (UINT) dw, err_msg);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
598 printf("%s", errbuf);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
599 MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST);
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
600 pidgin_dir[0] = '\0';
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
601 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
602
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
603 /* Determine if we're running in portable mode */
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
604 if (strstr(lpszCmdLine, "--portable-mode")
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
605 || (exe_name != NULL && strstr(exe_name, "-portable.exe"))) {
19081
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
606 int i = 0, c = 0;
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
607
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
608 printf("Running in PORTABLE mode.\n");
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
609 portable_mode = TRUE;
19081
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
610
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
611 /* Remove the --portable-mode arg from the args passed to pidgin so it doesn't choke */
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
612 pidgin_argv = malloc(sizeof(char*) * pidgin_argc);
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
613 for (; i < __argc; i++) {
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
614 if (strstr(__argv[i], "--portable-mode") == NULL) {
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
615 pidgin_argv[c] = __argv[i];
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
616 c++;
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
617 } else
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
618 pidgin_argc--;
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
619 }
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
620 }
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
621
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
622 if (portable_mode)
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
623 portable_mode_dll_prep(pidgin_dir);
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
624 else if (!getenv("PIDGIN_NO_DLL_CHECK"))
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
625 dll_prep();
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
626
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
627 winpidgin_set_locale();
18769
366db54481aa Make the win32 launcher support "--multiple" as well as %PIDGIN_MULTI_INST%
Daniel Atallah <datallah@pidgin.im>
parents: 17186
diff changeset
628 /* If help, version or multiple flag used, do not check Mutex */
366db54481aa Make the win32 launcher support "--multiple" as well as %PIDGIN_MULTI_INST%
Daniel Atallah <datallah@pidgin.im>
parents: 17186
diff changeset
629 if (!strstr(lpszCmdLine, "-h") && !strstr(lpszCmdLine, "-v") && !strstr(lpszCmdLine, "-m"))
16080
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
630 if (!getenv("PIDGIN_MULTI_INST") && !winpidgin_set_running())
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
631 return 0;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
632
16080
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
633 /* Now we are ready for Pidgin .. */
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
634 if ((hmod = LoadLibrary("pidgin.dll")))
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
635 pidgin_main = (LPFNPIDGINMAIN) GetProcAddress(hmod, "pidgin_main");
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
636
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
637 if (!pidgin_main) {
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
638 DWORD dw = GetLastError();
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
639 BOOL mod_not_found = (dw == ERROR_MOD_NOT_FOUND || dw == ERROR_DLL_NOT_FOUND);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
640 const char *err_msg = get_win32_error_message(dw);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
641
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
642 snprintf(errbuf, 512, "Error loading pidgin.dll.\nError: (%u) %s%s%s",
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
643 (UINT) dw, err_msg,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
644 mod_not_found ? "\n" : "",
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
645 mod_not_found ? "This probably means that GTK+ can't be found." : "");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
646 printf("%s", errbuf);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
647 MessageBox(NULL, errbuf, TEXT("Error"), MB_OK | MB_TOPMOST);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
648
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
649 return 0;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
650 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
651
19081
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
652 return pidgin_main(hInstance, pidgin_argc, pidgin_argv);
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
653 }

mercurial