pidgin/win32/winpidgin.c

Mon, 10 Sep 2012 23:15:35 -0400

author
Daniel Atallah <datallah@pidgin.im>
date
Mon, 10 Sep 2012 23:15:35 -0400
branch
release-2.x.y
changeset 33385
562961da7c0d
parent 33371
6d93866a4a3f
child 33941
80fcf7f86e4a
child 36301
2b4af2e09a67
permissions
-rw-r--r--

Avoid unnecessary sizeof(char); it must always be 1

* If it wasn't always 1, there would be a bug in this (line ~705)
* WideCharToMultiByte returns the size in bytes, not chars, so this was also wrong in that respect.

15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
1 /*
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
2 * winpidgin.c
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
3 *
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
4 * Date: June, 2002
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
5 * Description: Entry point for win32 pidgin, and various win32 dependant
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
6 * routines.
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
7 *
15931
716b5fac1895 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
8 * Pidgin is the legal property of its developers, whose names are too numerous
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
10 * source distribution.
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
11 *
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
15 * (at your option) any later version.
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
16 *
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
20 * GNU General Public License for more details.
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
21 *
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19081
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
25 *
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
26 */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
27
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
28 /* This is for ATTACH_PARENT_PROCESS */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
29 #ifndef _WIN32_WINNT
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
30 #define _WIN32_WINNT 0x501
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
31 #endif
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
32 #include <windows.h>
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
33 #include <fcntl.h>
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
34 #include <stdlib.h>
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
35 #include <string.h>
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
36 #include <stdio.h>
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
37 #include <sys/types.h>
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
38 #include <sys/stat.h>
29635
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
39 #include "config.h"
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
40
33371
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
41 typedef int (__cdecl* LPFNPIDGINMAIN)(HINSTANCE, int, char**);
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
42 typedef void (WINAPI* LPFNSETDLLDIRECTORY)(LPCWSTR);
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
43 typedef BOOL (WINAPI* LPFNATTACHCONSOLE)(DWORD);
33365
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
44 typedef BOOL (WINAPI* LPFNSETPROCESSDEPPOLICY)(DWORD);
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
45
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
46 static BOOL portable_mode = FALSE;
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
47
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
48 /*
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
49 * PROTOTYPES
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
50 */
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
51 static LPFNPIDGINMAIN pidgin_main = NULL;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
52 static LPFNSETDLLDIRECTORY MySetDllDirectory = NULL;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
53
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
54 static const wchar_t *get_win32_error_message(DWORD err) {
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
55 static wchar_t err_msg[512];
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
56
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
57 FormatMessageW(
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
58 FORMAT_MESSAGE_FROM_SYSTEM,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
59 NULL, err,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
60 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
61 (LPWSTR) &err_msg, sizeof(err_msg) / sizeof(wchar_t), NULL);
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
62
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
63 return err_msg;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
64 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
65
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
66 static BOOL read_reg_string(HKEY key, wchar_t *sub_key, wchar_t *val_name, LPBYTE data, LPDWORD data_len) {
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
67 HKEY hkey;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
68 BOOL ret = FALSE;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
69 LONG retv;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
70
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
71 if (ERROR_SUCCESS == (retv = RegOpenKeyExW(key, sub_key, 0,
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
72 KEY_QUERY_VALUE, &hkey))) {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
73 if (ERROR_SUCCESS == (retv = RegQueryValueExW(hkey, val_name,
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
74 NULL, NULL, data, data_len)))
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
75 ret = TRUE;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
76 else {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
77 const wchar_t *err_msg = get_win32_error_message(retv);
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
78
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
79 wprintf(L"Could not read reg key '%s' subkey '%s' value: '%s'.\nMessage: (%ld) %s\n",
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
80 (key == HKEY_LOCAL_MACHINE) ? L"HKLM"
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
81 : ((key == HKEY_CURRENT_USER) ? L"HKCU" : L"???"),
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
82 sub_key, val_name, retv, err_msg);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
83 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
84 RegCloseKey(hkey);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
85 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
86 else {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
87 wchar_t szBuf[80];
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
88
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
89 FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, NULL, retv, 0,
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
90 (LPWSTR) &szBuf, sizeof(szBuf) / sizeof(wchar_t), NULL);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
91 wprintf(L"Could not open reg subkey: %s\nError: (%ld) %s\n",
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
92 sub_key, retv, szBuf);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
93 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
94
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
95 return ret;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
96 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
97
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
98 static BOOL common_dll_prep(const wchar_t *path) {
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
99 HMODULE hmod;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
100 HKEY hkey;
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
101 struct _stat stat_buf;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
102 wchar_t test_path[MAX_PATH + 1];
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
103
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
104 _snwprintf(test_path, sizeof(test_path) / sizeof(wchar_t),
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
105 L"%s\\libgtk-win32-2.0-0.dll", path);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
106 test_path[sizeof(test_path) / sizeof(wchar_t) - 1] = L'\0';
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
107
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
108 if (_wstat(test_path, &stat_buf) != 0) {
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
109 printf("Unable to determine GTK+ path. \n"
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
110 "Assuming GTK+ is in the PATH.\n");
29805
c7d28ce85db7 Make the portable mode launcher try the "normal" mode path.
Daniel Atallah <datallah@pidgin.im>
parents: 29637
diff changeset
111 return FALSE;
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
112 }
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
113
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
114
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
115 wprintf(L"GTK+ path found: %s\n", path);
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
116
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
117 if ((hmod = GetModuleHandleW(L"kernel32.dll"))) {
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
118 MySetDllDirectory = (LPFNSETDLLDIRECTORY) GetProcAddress(
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
119 hmod, "SetDllDirectoryW");
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
120 if (!MySetDllDirectory)
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
121 printf("SetDllDirectory not supported\n");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
122 } else
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
123 printf("Error getting kernel32.dll module handle\n");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
124
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
125 /* For Windows XP SP1+ / Server 2003 we use SetDllDirectory to avoid dll hell */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
126 if (MySetDllDirectory) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
127 printf("Using SetDllDirectory\n");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
128 MySetDllDirectory(path);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
129 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
130
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
131 /* For the rest, we set the current directory and make sure
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
132 * SafeDllSearch is set to 0 where needed. */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
133 else {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
134 OSVERSIONINFOW osinfo;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
135
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
136 printf("Setting current directory to GTK+ dll directory\n");
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
137 SetCurrentDirectoryW(path);
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
138 /* For Windows 2000 (SP3+) / WinXP (No SP):
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
139 * If SafeDllSearchMode is set to 1, Windows system directories are
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
140 * searched for dlls before the current directory. Therefore we set it
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
141 * to 0.
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
142 */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
143 osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
144 GetVersionExW(&osinfo);
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
145 if ((osinfo.dwMajorVersion == 5
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
146 && osinfo.dwMinorVersion == 0
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
147 && wcscmp(osinfo.szCSDVersion, L"Service Pack 3") >= 0)
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
148 ||
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
149 (osinfo.dwMajorVersion == 5
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
150 && osinfo.dwMinorVersion == 1
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
151 && wcscmp(osinfo.szCSDVersion, L"") >= 0)
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
152 ) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
153 DWORD regval = 1;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
154 DWORD reglen = sizeof(DWORD);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
155
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
156 printf("Using Win2k (SP3+) / WinXP (No SP)... Checking SafeDllSearch\n");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
157 read_reg_string(HKEY_LOCAL_MACHINE,
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
158 L"System\\CurrentControlSet\\Control\\Session Manager",
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
159 L"SafeDllSearchMode",
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
160 (LPBYTE) &regval,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
161 &reglen);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
162
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
163 if (regval != 0) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
164 printf("Trying to set SafeDllSearchMode to 0\n");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
165 regval = 0;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
166 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
167 L"System\\CurrentControlSet\\Control\\Session Manager",
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
168 0, KEY_SET_VALUE, &hkey
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
169 ) == ERROR_SUCCESS) {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
170 if (RegSetValueExW(hkey,
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
171 L"SafeDllSearchMode", 0,
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
172 REG_DWORD, (LPBYTE) &regval,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
173 sizeof(DWORD)
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
174 ) != ERROR_SUCCESS)
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
175 printf("Error writing SafeDllSearchMode. Error: %u\n",
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
176 (UINT) GetLastError());
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
177 RegCloseKey(hkey);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
178 } else
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
179 printf("Error opening Session Manager key for writing. Error: %u\n",
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
180 (UINT) GetLastError());
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
181 } else
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
182 printf("SafeDllSearchMode is set to 0\n");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
183 }/*end else*/
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
184 }
29805
c7d28ce85db7 Make the portable mode launcher try the "normal" mode path.
Daniel Atallah <datallah@pidgin.im>
parents: 29637
diff changeset
185
c7d28ce85db7 Make the portable mode launcher try the "normal" mode path.
Daniel Atallah <datallah@pidgin.im>
parents: 29637
diff changeset
186 return TRUE;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
187 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
188
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
189 static BOOL dll_prep(const wchar_t *pidgin_dir) {
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
190 wchar_t path[MAX_PATH + 1];
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
191 path[0] = L'\0';
29807
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 29805
diff changeset
192
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 29805
diff changeset
193 if (*pidgin_dir) {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
194 _snwprintf(path, sizeof(path) / sizeof(wchar_t), L"%s\\Gtk\\bin", pidgin_dir);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
195 path[sizeof(path) / sizeof(wchar_t) - 1] = L'\0';
29807
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 29805
diff changeset
196 }
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 29805
diff changeset
197
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 29805
diff changeset
198 return common_dll_prep(path);
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 29805
diff changeset
199 }
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 29805
diff changeset
200
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
201 static void portable_mode_dll_prep(const wchar_t *pidgin_dir) {
29879
49a411ec1162 We're not going to support aspell dictionaries on Windows anymore.
Daniel Atallah <datallah@pidgin.im>
parents: 29878
diff changeset
202 /* need to be able to fit MAX_PATH + "PURPLEHOME=" in path2 */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
203 wchar_t path[MAX_PATH + 1];
29879
49a411ec1162 We're not going to support aspell dictionaries on Windows anymore.
Daniel Atallah <datallah@pidgin.im>
parents: 29878
diff changeset
204 wchar_t path2[MAX_PATH + 12];
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
205 const wchar_t *prev = NULL;
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
206
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
207 /* We assume that GTK+ is installed under \\path\to\Pidgin\..\GTK
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
208 * First we find \\path\to
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
209 */
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
210 if (*pidgin_dir)
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
211 /* pidgin_dir points to \\path\to\Pidgin */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
212 prev = wcsrchr(pidgin_dir, L'\\');
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
213
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
214 if (prev) {
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
215 int cnt = (prev - pidgin_dir);
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
216 wcsncpy(path, pidgin_dir, cnt);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
217 path[cnt] = L'\0';
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
218 } else {
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
219 printf("Unable to determine current executable path. \n"
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
220 "This will prevent the settings dir from being set.\n"
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
221 "Assuming GTK+ is in the PATH.\n");
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
222 return;
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
223 }
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
224
24433
a5213aeff14c Set %HOME% when running in portable mode so that GTK+'s files get stored in the
Daniel Atallah <datallah@pidgin.im>
parents: 23936
diff changeset
225 /* Set $HOME so that the GTK+ settings get stored in the right place */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
226 _snwprintf(path2, sizeof(path2) / sizeof(wchar_t), L"HOME=%s", path);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
227 _wputenv(path2);
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
228
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
229 /* Set up the settings dir base to be \\path\to
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
230 * The actual settings dir will be \\path\to\.purple */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
231 _snwprintf(path2, sizeof(path2) / sizeof(wchar_t), L"PURPLEHOME=%s", path);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
232 wprintf(L"Setting settings dir: %s\n", path2);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
233 _wputenv(path2);
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
234
29805
c7d28ce85db7 Make the portable mode launcher try the "normal" mode path.
Daniel Atallah <datallah@pidgin.im>
parents: 29637
diff changeset
235 if (!dll_prep(pidgin_dir)) {
c7d28ce85db7 Make the portable mode launcher try the "normal" mode path.
Daniel Atallah <datallah@pidgin.im>
parents: 29637
diff changeset
236 /* set the GTK+ path to be \\path\to\GTK\bin */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
237 wcscat(path, L"\\GTK\\bin");
29805
c7d28ce85db7 Make the portable mode launcher try the "normal" mode path.
Daniel Atallah <datallah@pidgin.im>
parents: 29637
diff changeset
238 common_dll_prep(path);
c7d28ce85db7 Make the portable mode launcher try the "normal" mode path.
Daniel Atallah <datallah@pidgin.im>
parents: 29637
diff changeset
239 }
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
240 }
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
241
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
242 static wchar_t* winpidgin_lcid_to_posix(LCID lcid) {
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
243 wchar_t *posix = NULL;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
244 int lang_id = PRIMARYLANGID(lcid);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
245 int sub_id = SUBLANGID(lcid);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
246
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
247 switch (lang_id) {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
248 case LANG_AFRIKAANS: posix = L"af"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
249 case LANG_ARABIC: posix = L"ar"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
250 case LANG_AZERI: posix = L"az"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
251 case LANG_BENGALI: posix = L"bn"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
252 case LANG_BULGARIAN: posix = L"bg"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
253 case LANG_CATALAN: posix = L"ca"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
254 case LANG_CZECH: posix = L"cs"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
255 case LANG_DANISH: posix = L"da"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
256 case LANG_ESTONIAN: posix = L"et"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
257 case LANG_PERSIAN: posix = L"fa"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
258 case LANG_GERMAN: posix = L"de"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
259 case LANG_GREEK: posix = L"el"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
260 case LANG_ENGLISH:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
261 switch (sub_id) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
262 case SUBLANG_ENGLISH_UK:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
263 posix = L"en_GB"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
264 case SUBLANG_ENGLISH_AUS:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
265 posix = L"en_AU"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
266 case SUBLANG_ENGLISH_CAN:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
267 posix = L"en_CA"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
268 default:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
269 posix = L"en"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
270 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
271 break;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
272 case LANG_SPANISH: posix = L"es"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
273 case LANG_BASQUE: posix = L"eu"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
274 case LANG_FINNISH: posix = L"fi"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
275 case LANG_FRENCH: posix = L"fr"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
276 case LANG_GALICIAN: posix = L"gl"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
277 case LANG_GUJARATI: posix = L"gu"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
278 case LANG_HEBREW: posix = L"he"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
279 case LANG_HINDI: posix = L"hi"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
280 case LANG_HUNGARIAN: posix = L"hu"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
281 case LANG_ICELANDIC: break;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
282 case LANG_INDONESIAN: posix = L"id"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
283 case LANG_ITALIAN: posix = L"it"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
284 case LANG_JAPANESE: posix = L"ja"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
285 case LANG_GEORGIAN: posix = L"ka"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
286 case LANG_KANNADA: posix = L"kn"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
287 case LANG_KOREAN: posix = L"ko"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
288 case LANG_LITHUANIAN: posix = L"lt"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
289 case LANG_MACEDONIAN: posix = L"mk"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
290 case LANG_DUTCH: posix = L"nl"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
291 case LANG_NEPALI: posix = L"ne"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
292 case LANG_NORWEGIAN:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
293 switch (sub_id) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
294 case SUBLANG_NORWEGIAN_BOKMAL:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
295 posix = L"nb"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
296 case SUBLANG_NORWEGIAN_NYNORSK:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
297 posix = L"nn"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
298 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
299 break;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
300 case LANG_PUNJABI: posix = L"pa"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
301 case LANG_POLISH: posix = L"pl"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
302 case LANG_PASHTO: posix = L"ps"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
303 case LANG_PORTUGUESE:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
304 switch (sub_id) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
305 case SUBLANG_PORTUGUESE_BRAZILIAN:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
306 posix = L"pt_BR"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
307 default:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
308 posix = L"pt"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
309 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
310 break;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
311 case LANG_ROMANIAN: posix = L"ro"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
312 case LANG_RUSSIAN: posix = L"ru"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
313 case LANG_SLOVAK: posix = L"sk"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
314 case LANG_SLOVENIAN: posix = L"sl"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
315 case LANG_ALBANIAN: posix = L"sq"; break;
19081
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
316 /* LANG_CROATIAN == LANG_SERBIAN == LANG_BOSNIAN */
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
317 case LANG_SERBIAN:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
318 switch (sub_id) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
319 case SUBLANG_SERBIAN_LATIN:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
320 posix = L"sr@Latn"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
321 case SUBLANG_SERBIAN_CYRILLIC:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
322 posix = L"sr"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
323 case SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC:
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
324 case SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
325 posix = L"bs"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
326 case SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
327 posix = L"hr"; break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
328 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
329 break;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
330 case LANG_SWEDISH: posix = L"sv"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
331 case LANG_TAMIL: posix = L"ta"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
332 case LANG_TELUGU: posix = L"te"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
333 case LANG_THAI: posix = L"th"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
334 case LANG_TURKISH: posix = L"tr"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
335 case LANG_UKRAINIAN: posix = L"uk"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
336 case LANG_VIETNAMESE: posix = L"vi"; break;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
337 case LANG_XHOSA: posix = L"xh"; break;
18771
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
338 case LANG_CHINESE:
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
339 switch (sub_id) {
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
340 case SUBLANG_CHINESE_SIMPLIFIED:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
341 posix = L"zh_CN"; break;
18771
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
342 case SUBLANG_CHINESE_TRADITIONAL:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
343 posix = L"zh_TW"; break;
18771
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
344 default:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
345 posix = L"zh"; break;
18771
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
346 }
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
347 break;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
348 case LANG_URDU: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
349 case LANG_BELARUSIAN: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
350 case LANG_LATVIAN: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
351 case LANG_ARMENIAN: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
352 case LANG_FAEROESE: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
353 case LANG_MALAY: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
354 case LANG_KAZAK: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
355 case LANG_KYRGYZ: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
356 case LANG_SWAHILI: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
357 case LANG_UZBEK: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
358 case LANG_TATAR: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
359 case LANG_ORIYA: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
360 case LANG_MALAYALAM: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
361 case LANG_ASSAMESE: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
362 case LANG_MARATHI: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
363 case LANG_SANSKRIT: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
364 case LANG_MONGOLIAN: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
365 case LANG_KONKANI: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
366 case LANG_MANIPURI: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
367 case LANG_SINDHI: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
368 case LANG_SYRIAC: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
369 case LANG_KASHMIRI: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
370 case LANG_DIVEHI: break;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
371 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
372
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
373 /* Deal with exceptions */
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
374 if (posix == NULL) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
375 switch (lcid) {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
376 case 0x0455: posix = L"my_MM"; break; /* Myanmar (Burmese) */
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
377 case 9999: posix = L"ku"; break; /* Kurdish (from NSIS) */
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
378 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
379 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
380
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
381 return posix;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
382 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
383
16080
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
384 /* Determine and set Pidgin locale as follows (in order of priority):
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
385 - Check PIDGINLANG env var
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
386 - Check NSIS Installer Language reg value
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
387 - Use default user locale
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
388 */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
389 static const wchar_t *winpidgin_get_locale() {
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
390 const wchar_t *locale = NULL;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
391 LCID lcid;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
392 wchar_t data[10];
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
393 DWORD datalen = sizeof(data) / sizeof(wchar_t);
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
394
16080
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
395 /* Check if user set PIDGINLANG env var */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
396 if ((locale = _wgetenv(L"PIDGINLANG")))
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
397 return locale;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
398
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
399 if (!portable_mode && read_reg_string(HKEY_CURRENT_USER, L"SOFTWARE\\pidgin",
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
400 L"Installer Language", (LPBYTE) &data, &datalen)) {
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
401 if ((locale = winpidgin_lcid_to_posix(_wtoi(data))))
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
402 return locale;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
403 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
404
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
405 lcid = GetUserDefaultLCID();
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
406 if ((locale = winpidgin_lcid_to_posix(lcid)))
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
407 return locale;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
408
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
409 return L"en";
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
410 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
411
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
412 static void winpidgin_set_locale() {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
413 const wchar_t *locale;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
414 wchar_t envstr[25];
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
415
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
416 locale = winpidgin_get_locale();
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
417
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
418 _snwprintf(envstr, sizeof(envstr) / sizeof(wchar_t), L"LANG=%s", locale);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
419 wprintf(L"Setting locale: %s\n", envstr);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
420 _wputenv(envstr);
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
421 }
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
422
23936
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
423
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
424 static void winpidgin_add_stuff_to_path() {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
425 wchar_t perl_path[MAX_PATH + 1];
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
426 wchar_t *ppath = NULL;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
427 wchar_t mit_kerberos_path[MAX_PATH + 1];
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
428 wchar_t *mpath = NULL;
23936
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
429 DWORD plen;
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
430
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
431 printf("%s", "Looking for Perl... ");
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
432
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
433 plen = sizeof(perl_path) / sizeof(wchar_t);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
434 if (read_reg_string(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Perl", L"",
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
435 (LPBYTE) &perl_path, &plen)) {
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
436 /* We *could* check for perl510.dll, but it seems unnecessary. */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
437 wprintf(L"found in '%s'.\n", perl_path);
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
438
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
439 if (perl_path[wcslen(perl_path) - 1] != L'\\')
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
440 wcscat(perl_path, L"\\");
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
441 wcscat(perl_path, L"bin");
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
442
23936
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
443 ppath = perl_path;
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
444 } else
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
445 printf("%s", "not found.\n");
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
446
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
447 printf("%s", "Looking for MIT Kerberos... ");
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
448
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
449 plen = sizeof(mit_kerberos_path) / sizeof(wchar_t);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
450 if (read_reg_string(HKEY_LOCAL_MACHINE, L"SOFTWARE\\MIT\\Kerberos", L"InstallDir",
23936
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
451 (LPBYTE) &mit_kerberos_path, &plen)) {
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
452 /* We *could* check for gssapi32.dll */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
453 wprintf(L"found in '%s'.\n", mit_kerberos_path);
23936
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
454
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
455 if (mit_kerberos_path[wcslen(mit_kerberos_path) - 1] != L'\\')
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
456 wcscat(mit_kerberos_path, L"\\");
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
457 wcscat(mit_kerberos_path, L"bin");
23936
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
458
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
459 mpath = mit_kerberos_path;
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
460 } else
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
461 printf("%s", "not found.\n");
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
462
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
463 if (ppath != NULL || mpath != NULL) {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
464 const wchar_t *path = _wgetenv(L"PATH");
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
465 BOOL add_ppath = ppath != NULL && (path == NULL || !wcsstr(path, ppath));
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
466 BOOL add_mpath = mpath != NULL && (path == NULL || !wcsstr(path, mpath));
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
467 wchar_t *newpath;
23936
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
468 int newlen;
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
469
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
470 if (add_ppath || add_mpath) {
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
471 /* Enough to add "PATH=" + path + ";" + ppath + ";" + mpath + \0 */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
472 newlen = 6 + (path ? wcslen(path) + 1 : 0);
23936
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
473 if (add_ppath)
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
474 newlen += wcslen(ppath) + 1;
23936
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
475 if (add_mpath)
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
476 newlen += wcslen(mpath) + 1;
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
477 newpath = malloc(newlen * sizeof(wchar_t));
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
478
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
479 _snwprintf(newpath, newlen, L"PATH=%s%s%s%s%s%s",
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
480 path ? path : L"",
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
481 path ? L";" : L"",
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
482 add_ppath ? ppath : L"",
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
483 add_ppath ? L";" : L"",
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
484 add_mpath ? mpath : L"",
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
485 add_mpath ? L";" : L"");
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
486
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
487 wprintf(L"New PATH: %s\n", newpath);
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
488
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
489 _wputenv(newpath);
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
490 free(newpath);
23936
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
491 }
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
492 }
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
493 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
494
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
495 #define PIDGIN_WM_FOCUS_REQUEST (WM_APP + 13)
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
496 #define PIDGIN_WM_PROTOCOL_HANDLE (WM_APP + 14)
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
497
21971
e00e0d55d129 Allow the user to Retry if Pidgin is running when they start the installer. Fixes #4355
Daniel Atallah <datallah@pidgin.im>
parents: 21613
diff changeset
498 static BOOL winpidgin_set_running(BOOL fail_if_running) {
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
499 HANDLE h;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
500
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
501 if ((h = CreateMutexW(NULL, FALSE, L"pidgin_is_running"))) {
21971
e00e0d55d129 Allow the user to Retry if Pidgin is running when they start the installer. Fixes #4355
Daniel Atallah <datallah@pidgin.im>
parents: 21613
diff changeset
502 DWORD err = GetLastError();
22114
272116fabba9 This is how the error handling for the win32 single instance mutex is supposed to work.
Daniel Atallah <datallah@pidgin.im>
parents: 22036
diff changeset
503 if (err == ERROR_ALREADY_EXISTS) {
272116fabba9 This is how the error handling for the win32 single instance mutex is supposed to work.
Daniel Atallah <datallah@pidgin.im>
parents: 22036
diff changeset
504 if (fail_if_running) {
272116fabba9 This is how the error handling for the win32 single instance mutex is supposed to work.
Daniel Atallah <datallah@pidgin.im>
parents: 22036
diff changeset
505 HWND msg_win;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
506
22114
272116fabba9 This is how the error handling for the win32 single instance mutex is supposed to work.
Daniel Atallah <datallah@pidgin.im>
parents: 22036
diff changeset
507 printf("An instance of Pidgin is already running.\n");
20257
e52756e57259 applied changes from d6da6a7a5ad01f170f0fd78424183f73200dc78c
Luke Schierer <lschiere@pidgin.im>
parents: 20221
diff changeset
508
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
509 if((msg_win = FindWindowExW(NULL, NULL, L"WinpidginMsgWinCls", NULL)))
22114
272116fabba9 This is how the error handling for the win32 single instance mutex is supposed to work.
Daniel Atallah <datallah@pidgin.im>
parents: 22036
diff changeset
510 if(SendMessage(msg_win, PIDGIN_WM_FOCUS_REQUEST, (WPARAM) NULL, (LPARAM) NULL))
272116fabba9 This is how the error handling for the win32 single instance mutex is supposed to work.
Daniel Atallah <datallah@pidgin.im>
parents: 22036
diff changeset
511 return FALSE;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
512
22114
272116fabba9 This is how the error handling for the win32 single instance mutex is supposed to work.
Daniel Atallah <datallah@pidgin.im>
parents: 22036
diff changeset
513 /* If we get here, the focus request wasn't successful */
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
514
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
515 MessageBoxW(NULL,
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
516 L"An instance of Pidgin is already running",
22114
272116fabba9 This is how the error handling for the win32 single instance mutex is supposed to work.
Daniel Atallah <datallah@pidgin.im>
parents: 22036
diff changeset
517 NULL, MB_OK | MB_TOPMOST);
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
518
22114
272116fabba9 This is how the error handling for the win32 single instance mutex is supposed to work.
Daniel Atallah <datallah@pidgin.im>
parents: 22036
diff changeset
519 return FALSE;
272116fabba9 This is how the error handling for the win32 single instance mutex is supposed to work.
Daniel Atallah <datallah@pidgin.im>
parents: 22036
diff changeset
520 }
272116fabba9 This is how the error handling for the win32 single instance mutex is supposed to work.
Daniel Atallah <datallah@pidgin.im>
parents: 22036
diff changeset
521 } else if (err != ERROR_SUCCESS)
22036
50c4b5826c97 Warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 21971
diff changeset
522 printf("Error (%u) accessing \"pidgin_is_running\" mutex.\n", (UINT) err);
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
523 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
524 return TRUE;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
525 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
526
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
527 #define PROTO_HANDLER_SWITCH L"--protocolhandler="
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
528
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
529 static void handle_protocol(wchar_t *cmd) {
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
530 char *remote_msg, *utf8msg;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
531 wchar_t *tmp1, *tmp2;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
532 int len, wlen;
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
533 SIZE_T len_written;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
534 HWND msg_win;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
535 DWORD pid;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
536 HANDLE process;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
537
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
538 /* The start of the message */
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
539 tmp1 = cmd + wcslen(PROTO_HANDLER_SWITCH);
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
540
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
541 /* The end of the message */
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
542 if ((tmp2 = wcschr(tmp1, L' ')))
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
543 wlen = (tmp2 - tmp1);
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
544 else
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
545 wlen = wcslen(tmp1);
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
546
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
547 if (wlen == 0) {
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
548 printf("No protocol message specified.\n");
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
549 return;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
550 }
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
551
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
552 if (!(msg_win = FindWindowExW(NULL, NULL, L"WinpidginMsgWinCls", NULL))) {
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
553 printf("Unable to find an instance of Pidgin to handle protocol message.\n");
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
554 return;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
555 }
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
556
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
557 len = WideCharToMultiByte(CP_UTF8, 0, tmp1,
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
558 wlen, NULL, 0, NULL, NULL);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
559 if (len) {
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
560 utf8msg = malloc(len);
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
561 len = WideCharToMultiByte(CP_UTF8, 0, tmp1,
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
562 wlen, utf8msg, len, NULL, NULL);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
563 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
564
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
565 if (len == 0) {
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
566 printf("No protocol message specified.\n");
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
567 return;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
568 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
569
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
570 GetWindowThreadProcessId(msg_win, &pid);
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
571 if (!(process = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE, FALSE, pid))) {
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
572 DWORD dw = GetLastError();
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
573 const wchar_t *err_msg = get_win32_error_message(dw);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
574 wprintf(L"Unable to open Pidgin process. (%u) %s\n", (UINT) dw, err_msg);
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
575 return;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
576 }
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
577
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
578 wprintf(L"Trying to handle protocol message:\n'%.*s'\n", wlen, tmp1);
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
579
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
580 /* MEM_COMMIT initializes the memory to zero
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
581 * so we don't need to worry that our section of utf8msg isn't nul-terminated */
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
582 if ((remote_msg = (char*) VirtualAllocEx(process, NULL, len + 1, MEM_COMMIT, PAGE_READWRITE))) {
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
583 if (WriteProcessMemory(process, remote_msg, utf8msg, len, &len_written)) {
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
584 if (!SendMessageA(msg_win, PIDGIN_WM_PROTOCOL_HANDLE, len_written, (LPARAM) remote_msg))
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
585 printf("Unable to send protocol message to Pidgin instance.\n");
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
586 } else {
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
587 DWORD dw = GetLastError();
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
588 const wchar_t *err_msg = get_win32_error_message(dw);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
589 wprintf(L"Unable to write to remote memory. (%u) %s\n", (UINT) dw, err_msg);
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
590 }
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
591
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
592 VirtualFreeEx(process, remote_msg, 0, MEM_RELEASE);
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
593 } else {
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
594 DWORD dw = GetLastError();
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
595 const wchar_t *err_msg = get_win32_error_message(dw);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
596 wprintf(L"Unable to allocate remote memory. (%u) %s\n", (UINT) dw, err_msg);
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
597 }
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
598
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
599 CloseHandle(process);
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
600 free(utf8msg);
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
601 }
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
602
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
603
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
604 int _stdcall
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
605 WinMain (struct HINSTANCE__ *hInstance, struct HINSTANCE__ *hPrevInstance,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
606 char *lpszCmdLine, int nCmdShow) {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
607 wchar_t errbuf[512];
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
608 wchar_t pidgin_dir[MAX_PATH];
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
609 wchar_t *pidgin_dir_start = NULL;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
610 wchar_t exe_name[MAX_PATH];
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
611 HMODULE hmod;
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
612 wchar_t *wtmp;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
613 int pidgin_argc;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
614 char **pidgin_argv; /* This is in utf-8 */
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
615 int i, j, k;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
616 BOOL debug = FALSE, help = FALSE, version = FALSE, multiple = FALSE, success;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
617 LPWSTR *szArglist;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
618 LPWSTR cmdLine;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
619
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
620 /* If debug or help or version flag used, create console for output */
24795
48d838a2e580 Fix the initial parsing of args in the win32 launcher to be more robust.
Daniel Atallah <datallah@pidgin.im>
parents: 24433
diff changeset
621 for (i = 1; i < __argc; i++) {
28536
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
622 if (strlen(__argv[i]) > 1 && __argv[i][0] == '-') {
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
623 /* check if we're looking at -- or - option */
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
624 if (__argv[i][1] == '-') {
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
625 if (strstr(__argv[i], "--debug") == __argv[i])
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
626 debug = TRUE;
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
627 else if (strstr(__argv[i], "--help") == __argv[i])
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
628 help = TRUE;
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
629 else if (strstr(__argv[i], "--version") == __argv[i])
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
630 version = TRUE;
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
631 else if (strstr(__argv[i], "--multiple") == __argv[i])
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
632 multiple = TRUE;
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
633 } else {
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
634 if (strchr(__argv[i], 'd'))
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
635 debug = TRUE;
31362
e5bfe4ed7307 Allowed pidgin on windows to properly handle combined arguments (i.e. "-dm" as opposed to "-d -m")
Nader Morshed <morshed.nader@gmail.com>
parents: 30739
diff changeset
636 if (strchr(__argv[i], 'h'))
28536
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
637 help = TRUE;
31362
e5bfe4ed7307 Allowed pidgin on windows to properly handle combined arguments (i.e. "-dm" as opposed to "-d -m")
Nader Morshed <morshed.nader@gmail.com>
parents: 30739
diff changeset
638 if (strchr(__argv[i], 'v'))
28536
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
639 version = TRUE;
31362
e5bfe4ed7307 Allowed pidgin on windows to properly handle combined arguments (i.e. "-dm" as opposed to "-d -m")
Nader Morshed <morshed.nader@gmail.com>
parents: 30739
diff changeset
640 if (strchr(__argv[i], 'm'))
28536
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
641 multiple = TRUE;
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
642 }
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
643 }
24795
48d838a2e580 Fix the initial parsing of args in the win32 launcher to be more robust.
Daniel Atallah <datallah@pidgin.im>
parents: 24433
diff changeset
644 }
48d838a2e580 Fix the initial parsing of args in the win32 launcher to be more robust.
Daniel Atallah <datallah@pidgin.im>
parents: 24433
diff changeset
645
33365
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
646 /* Permanently enable DEP if the OS supports it */
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
647 if ((hmod = GetModuleHandleW(L"kernel32.dll"))) {
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
648 LPFNSETPROCESSDEPPOLICY MySetProcessDEPPolicy =
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
649 (LPFNSETPROCESSDEPPOLICY)
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
650 GetProcAddress(hmod, "SetProcessDEPPolicy");
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
651 if (MySetProcessDEPPolicy)
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
652 MySetProcessDEPPolicy(1); //PROCESS_DEP_ENABLE
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
653 }
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
654
24795
48d838a2e580 Fix the initial parsing of args in the win32 launcher to be more robust.
Daniel Atallah <datallah@pidgin.im>
parents: 24433
diff changeset
655 if (debug || help || version) {
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
656 /* If stdout hasn't been redirected to a file, alloc a console
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
657 * (_istty() doesn't work for stuff using the GUI subsystem) */
20221
28e31ee832cd applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
658 if (_fileno(stdout) == -1 || _fileno(stdout) == -2) {
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
659 LPFNATTACHCONSOLE MyAttachConsole = NULL;
33365
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
660 if (hmod)
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
661 MyAttachConsole =
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
662 (LPFNATTACHCONSOLE)
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
663 GetProcAddress(hmod, "AttachConsole");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
664 if ((MyAttachConsole && MyAttachConsole(ATTACH_PARENT_PROCESS))
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
665 || AllocConsole()) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
666 freopen("CONOUT$", "w", stdout);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
667 freopen("CONOUT$", "w", stderr);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
668 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
669 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
670 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
671
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
672 cmdLine = GetCommandLineW();
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
673
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
674 /* If this is a protocol handler invocation, deal with it accordingly */
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
675 if ((wtmp = wcsstr(cmdLine, PROTO_HANDLER_SWITCH)) != NULL) {
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
676 handle_protocol(wtmp);
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
677 return 0;
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
678 }
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
679
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
680 /* Load exception handler if we have it */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
681 if (GetModuleFileNameW(NULL, pidgin_dir, MAX_PATH) != 0) {
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
682
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
683 /* primitive dirname() */
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
684 pidgin_dir_start = wcsrchr(pidgin_dir, L'\\');
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
685
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
686 if (pidgin_dir_start) {
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
687 HMODULE hmod;
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
688 pidgin_dir_start[0] = L'\0';
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
689
29635
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
690 /* tmp++ will now point to the executable file name */
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
691 wcscpy(exe_name, pidgin_dir_start + 1);
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
692
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
693 wcscat(pidgin_dir, L"\\exchndl.dll");
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
694 if ((hmod = LoadLibraryW(pidgin_dir))) {
33371
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
695 typedef void (__cdecl* LPFNSETLOGFILE)(const LPCSTR);
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
696 LPFNSETLOGFILE MySetLogFile;
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
697 /* exchndl.dll is built without UNICODE */
29635
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
698 char debug_dir[MAX_PATH];
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
699 printf("Loaded exchndl.dll\n");
29635
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
700 /* Temporarily override exchndl.dll's logfile
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
701 * to something sane (Pidgin will override it
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
702 * again when it initializes) */
33371
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
703 MySetLogFile = (LPFNSETLOGFILE) GetProcAddress(hmod, "SetLogFile");
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
704 if (MySetLogFile) {
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
705 if (GetTempPathA(sizeof(debug_dir), debug_dir) != 0) {
29635
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
706 strcat(debug_dir, "pidgin.RPT");
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
707 printf(" Setting exchndl.dll LogFile to %s\n",
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
708 debug_dir);
33371
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
709 MySetLogFile(debug_dir);
29635
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
710 }
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
711 }
33371
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
712 /* The function signature for SetDebugInfoDir is the same as SetLogFile,
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
713 * so we can reuse the variable */
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
714 MySetLogFile = (LPFNSETLOGFILE) GetProcAddress(hmod, "SetDebugInfoDir");
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
715 if (MySetLogFile) {
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
716 char *pidgin_dir_ansi = NULL;
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
717 /* Restore pidgin_dir to point to where the executable is */
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
718 pidgin_dir_start[0] = L'\0';
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
719 i = WideCharToMultiByte(CP_ACP, 0, pidgin_dir,
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
720 -1, NULL, 0, NULL, NULL);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
721 if (i != 0) {
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
722 pidgin_dir_ansi = malloc(i);
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
723 i = WideCharToMultiByte(CP_ACP, 0, pidgin_dir,
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
724 -1, pidgin_dir_ansi, i, NULL, NULL);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
725 if (i == 0) {
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
726 free(pidgin_dir_ansi);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
727 pidgin_dir_ansi = NULL;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
728 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
729 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
730 if (pidgin_dir_ansi != NULL) {
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
731 _snprintf(debug_dir, sizeof(debug_dir),
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
732 "%s\\pidgin-%s-dbgsym",
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
733 pidgin_dir_ansi, VERSION);
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
734 debug_dir[sizeof(debug_dir) - 1] = '\0';
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
735 printf(" Setting exchndl.dll DebugInfoDir to %s\n",
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
736 debug_dir);
33371
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
737 MySetLogFile(debug_dir);
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
738 free(pidgin_dir_ansi);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
739 }
29635
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
740 }
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
741
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
742 }
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
743
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
744 /* Restore pidgin_dir to point to where the executable is */
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
745 pidgin_dir_start[0] = L'\0';
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
746 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
747 } else {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
748 DWORD dw = GetLastError();
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
749 const wchar_t *err_msg = get_win32_error_message(dw);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
750 _snwprintf(errbuf, 512,
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
751 L"Error getting module filename.\nError: (%u) %s",
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
752 (UINT) dw, err_msg);
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
753 wprintf(L"%s\n", errbuf);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
754 MessageBoxW(NULL, errbuf, NULL, MB_OK | MB_TOPMOST);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
755 pidgin_dir[0] = L'\0';
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
756 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
757
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
758 /* Determine if we're running in portable mode */
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
759 if (wcsstr(cmdLine, L"--portable-mode")
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
760 || (exe_name != NULL && wcsstr(exe_name, L"-portable.exe"))) {
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
761 printf("Running in PORTABLE mode.\n");
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
762 portable_mode = TRUE;
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
763 }
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
764
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
765 if (portable_mode)
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
766 portable_mode_dll_prep(pidgin_dir);
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
767 else if (!getenv("PIDGIN_NO_DLL_CHECK"))
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
768 dll_prep(pidgin_dir);
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
769
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
770 winpidgin_set_locale();
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
771
23936
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
772 winpidgin_add_stuff_to_path();
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
773
18769
366db54481aa Make the win32 launcher support "--multiple" as well as %PIDGIN_MULTI_INST%
Daniel Atallah <datallah@pidgin.im>
parents: 17186
diff changeset
774 /* If help, version or multiple flag used, do not check Mutex */
24795
48d838a2e580 Fix the initial parsing of args in the win32 launcher to be more robust.
Daniel Atallah <datallah@pidgin.im>
parents: 24433
diff changeset
775 if (!help && !version)
48d838a2e580 Fix the initial parsing of args in the win32 launcher to be more robust.
Daniel Atallah <datallah@pidgin.im>
parents: 24433
diff changeset
776 if (!winpidgin_set_running(getenv("PIDGIN_MULTI_INST") == NULL && !multiple))
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
777 return 0;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
778
16080
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
779 /* Now we are ready for Pidgin .. */
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
780 wcscat(pidgin_dir, L"\\pidgin.dll");
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
781 if ((hmod = LoadLibraryW(pidgin_dir)))
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
782 pidgin_main = (LPFNPIDGINMAIN) GetProcAddress(hmod, "pidgin_main");
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
783
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
784 /* Restore pidgin_dir to point to where the executable is */
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
785 if (pidgin_dir_start)
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
786 pidgin_dir_start[0] = L'\0';
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
787
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
788 if (!pidgin_main) {
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
789 DWORD dw = GetLastError();
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
790 BOOL mod_not_found = (dw == ERROR_MOD_NOT_FOUND || dw == ERROR_DLL_NOT_FOUND);
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
791 const wchar_t *err_msg = get_win32_error_message(dw);
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
792
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
793 _snwprintf(errbuf, 512, L"Error loading pidgin.dll.\nError: (%u) %s%s%s",
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
794 (UINT) dw, err_msg,
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
795 mod_not_found ? L"\n" : L"",
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
796 mod_not_found ? L"This probably means that GTK+ can't be found." : L"");
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
797 wprintf(L"%s\n", errbuf);
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
798 MessageBoxW(NULL, errbuf, L"Error", MB_OK | MB_TOPMOST);
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
799
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
800 return 0;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
801 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
802
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
803 /* Convert argv to utf-8*/
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
804 szArglist = CommandLineToArgvW(cmdLine, &j);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
805 pidgin_argc = j;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
806 pidgin_argv = malloc(pidgin_argc* sizeof(char*));
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
807 k = 0;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
808 for (i = 0; i < j; i++) {
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
809 success = FALSE;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
810 /* Remove the --portable-mode arg from the args passed to pidgin so it doesn't choke */
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
811 if (wcsstr(szArglist[i], L"--portable-mode") == NULL) {
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
812 int len = WideCharToMultiByte(CP_UTF8, 0, szArglist[i],
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
813 -1, NULL, 0, NULL, NULL);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
814 if (len != 0) {
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
815 char *arg = malloc(len);
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
816 len = WideCharToMultiByte(CP_UTF8, 0, szArglist[i],
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
817 -1, arg, len, NULL, NULL);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
818 if (len != 0) {
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
819 pidgin_argv[k++] = arg;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
820 success = TRUE;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
821 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
822 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
823 if (!success)
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
824 wprintf(L"Error converting argument '%s' to UTF-8\n",
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
825 szArglist[i]);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
826 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
827 if (!success)
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
828 pidgin_argc--;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
829 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
830 LocalFree(szArglist);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
831
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
832
19081
744d42ac088d Fix "pidgin.exe --portable-mode" not to pass the flag to pidgin's init, so getopt doesn't choke on it. Fixes #2392.
Daniel Atallah <datallah@pidgin.im>
parents: 18771
diff changeset
833 return pidgin_main(hInstance, pidgin_argc, pidgin_argv);
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
834 }

mercurial