annotate pidgin/win32/winpidgin.c @ 23667:bd789c20f577

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