pidgin/win32/winpidgin.c

Mon, 15 Mar 2010 22:00:43 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Mon, 15 Mar 2010 22:00:43 +0000
changeset 29879
49a411ec1162
parent 29878
623d7875f658
child 30739
72613eff8b0e
permissions
-rw-r--r--

We're not going to support aspell dictionaries on Windows anymore.

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
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
41 typedef int (CALLBACK* LPFNPIDGINMAIN)(HINSTANCE, int, char**);
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
42 typedef void (CALLBACK* LPFNSETDLLDIRECTORY)(LPCWSTR);
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
43 typedef BOOL (CALLBACK* LPFNATTACHCONSOLE)(DWORD);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
44
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
45 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
46
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
47 /*
09e913390266 Restoring win32 stuff that was (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 * 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
49 */
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
50 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
51 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
52
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
53 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
54 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
55
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
56 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
57 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
58 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
59 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
60 (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
61
09e913390266 Restoring win32 stuff that was (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 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
63 }
09e913390266 Restoring win32 stuff that was (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
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
65 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
66 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
67 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
68 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
69
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
70 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
71 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
72 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
73 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
74 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
75 else {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
76 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
77
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
78 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
79 (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
80 : ((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
81 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
82 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
83 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
84 }
09e913390266 Restoring win32 stuff that was (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 else {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
86 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
87
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
88 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
89 (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
90 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
91 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
92 }
09e913390266 Restoring win32 stuff that was (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 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
95 }
09e913390266 Restoring win32 stuff that was (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
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
97 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
98 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
99 HKEY hkey;
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
100 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
101 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
102
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
103 _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
104 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
105 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
106
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
107 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
108 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
109 "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
110 return FALSE;
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
111 }
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
112
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
113
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
114 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
115
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
116 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
117 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
118 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
119 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
120 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
121 } 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
122 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
123
09e913390266 Restoring win32 stuff that was (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 /* 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
125 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
126 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
127 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
128 }
09e913390266 Restoring win32 stuff that was (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 /* 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
131 * 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
132 else {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
133 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
134
09e913390266 Restoring win32 stuff that was (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 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
136 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
137 /* 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
138 * 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
139 * 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
140 * 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
141 */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
142 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
143 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
144 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
145 && 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
146 && 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
147 ||
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
148 (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
149 && 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
150 && 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
151 ) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
152 DWORD regval = 1;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
153 DWORD reglen = sizeof(DWORD);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
154
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
155 printf("Using Win2k (SP3+) / WinXP (No SP)... Checking SafeDllSearch\n");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
156 read_reg_string(HKEY_LOCAL_MACHINE,
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
157 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
158 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
159 (LPBYTE) &regval,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
160 &reglen);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
161
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
162 if (regval != 0) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
163 printf("Trying to set SafeDllSearchMode to 0\n");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
164 regval = 0;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
165 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
166 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
167 0, KEY_SET_VALUE, &hkey
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
168 ) == ERROR_SUCCESS) {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
169 if (RegSetValueExW(hkey,
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
170 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
171 REG_DWORD, (LPBYTE) &regval,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
172 sizeof(DWORD)
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
173 ) != ERROR_SUCCESS)
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
174 printf("Error writing SafeDllSearchMode. Error: %u\n",
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
175 (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
176 RegCloseKey(hkey);
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
177 } else
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
178 printf("Error opening Session Manager key for writing. Error: %u\n",
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
179 (UINT) GetLastError());
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
180 } else
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
181 printf("SafeDllSearchMode is set to 0\n");
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
182 }/*end else*/
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
183 }
29805
c7d28ce85db7 Make the portable mode launcher try the "normal" mode path.
Daniel Atallah <datallah@pidgin.im>
parents: 29637
diff changeset
184
c7d28ce85db7 Make the portable mode launcher try the "normal" mode path.
Daniel Atallah <datallah@pidgin.im>
parents: 29637
diff changeset
185 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
186 }
09e913390266 Restoring win32 stuff that was (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
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
188 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
189 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
190 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
191
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 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
193 _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
194 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
195 }
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 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
198 }
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
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
200 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
201 /* 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
202 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
203 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
204 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
205
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 /* 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
207 * 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
208 */
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
209 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
210 /* 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
211 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
212
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 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
214 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
215 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
216 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
217 } 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
218 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
219 "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
220 "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
221 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
222 }
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
223
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
224 /* 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
225 _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
226 _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
227
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 /* 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
229 * 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
230 _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
231 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
232 _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
233
29805
c7d28ce85db7 Make the portable mode launcher try the "normal" mode path.
Daniel Atallah <datallah@pidgin.im>
parents: 29637
diff changeset
234 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
235 /* 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
236 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
237 common_dll_prep(path);
c7d28ce85db7 Make the portable mode launcher try the "normal" mode path.
Daniel Atallah <datallah@pidgin.im>
parents: 29637
diff changeset
238 }
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
239 }
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
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
241 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
242 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
243 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
244 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
245
09e913390266 Restoring win32 stuff that was (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 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
247 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
248 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
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256 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
257 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
258 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
259 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
260 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
261 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
262 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
263 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
264 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
265 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
266 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
267 default:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
268 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
269 }
09e913390266 Restoring win32 stuff that was (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 break;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
271 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
272 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
273 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
274 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
275 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
276 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
277 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
278 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
279 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
280 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
281 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
282 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
283 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
284 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
285 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
286 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
287 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
288 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
289 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
290 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
291 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
292 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
293 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
294 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
295 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
296 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
297 }
09e913390266 Restoring win32 stuff that was (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 break;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
299 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
300 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
301 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
302 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
303 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
304 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
305 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
306 default:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
307 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
308 }
09e913390266 Restoring win32 stuff that was (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 break;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
310 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
311 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
312 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
313 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
314 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
315 /* 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
316 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
317 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
318 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
319 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
320 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
321 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
322 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
323 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
324 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
325 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
326 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
327 }
09e913390266 Restoring win32 stuff that was (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 break;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
329 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
330 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
331 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
332 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
333 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
334 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
335 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
336 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
337 case LANG_CHINESE:
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
338 switch (sub_id) {
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
339 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
340 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
341 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
342 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
343 default:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
344 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
345 }
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
346 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
347 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
348 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
349 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
350 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
351 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
352 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
353 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
354 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
355 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
356 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
357 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
358 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
359 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
360 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
361 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
362 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
363 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
364 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
365 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
366 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
367 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
368 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
369 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
370 }
09e913390266 Restoring win32 stuff that was (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 /* 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
373 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
374 switch (lcid) {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
375 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
376 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
377 }
09e913390266 Restoring win32 stuff that was (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 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
381 }
09e913390266 Restoring win32 stuff that was (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
16080
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
383 /* 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
384 - 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
385 - 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
386 - 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
387 */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
388 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
389 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
390 LCID lcid;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
391 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
392 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
393
16080
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
394 /* 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
395 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
396 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
397
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
398 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
399 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
400 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
401 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
402 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
403
09e913390266 Restoring win32 stuff that was (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 lcid = GetUserDefaultLCID();
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
405 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
406 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
407
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
408 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
409 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
410
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
411 static 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
412 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
413 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
414
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
415 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
416
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
417 _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
418 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
419 _wputenv(envstr);
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
420 }
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
421
23936
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
422
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
423 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
424 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
425 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
426 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
427 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
428 DWORD plen;
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
429
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
430 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
431
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
432 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
433 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
434 (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
435 /* 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
436 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
437
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
438 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
439 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
440 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
441
23936
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
442 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
443 } else
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
444 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
445
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
446 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
447
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
448 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
449 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
450 (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
451 /* 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
452 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
453
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
454 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
455 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
456 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
457
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
458 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
459 } else
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
460 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
461
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
462 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
463 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
464 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
465 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
466 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
467 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
468
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
469 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
470 /* 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
471 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
472 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
473 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
474 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
475 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
476 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
477
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
478 _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
479 path ? path : L"",
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
480 path ? L";" : L"",
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
481 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
482 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
483 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
484 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
485
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
486 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
487
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
488 _wputenv(newpath);
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
489 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
490 }
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
491 }
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
492 }
09e913390266 Restoring win32 stuff that was (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
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
494 #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
495 #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
496
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
497 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
498 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
499
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
500 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
501 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
502 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
503 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
504 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
505
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
506 printf("An instance of Pidgin is already running.\n");
20257
e52756e57259 applied changes from d6da6a7a5ad01f170f0fd78424183f73200dc78c
Luke Schierer <lschiere@pidgin.im>
parents: 20221
diff changeset
507
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
508 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
509 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
510 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
511
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
512 /* 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
513
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
514 MessageBoxW(NULL,
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
515 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
516 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
517
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
518 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
519 }
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 } else if (err != ERROR_SUCCESS)
22036
50c4b5826c97 Warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 21971
diff changeset
521 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
522 }
09e913390266 Restoring win32 stuff that was (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 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
524 }
09e913390266 Restoring win32 stuff that was (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
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
526 #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
527
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
528 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
529 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
530 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
531 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
532 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
533 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
534 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
535 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
536
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 /* 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
538 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
539
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 /* 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
541 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
542 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
543 else
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
544 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
545
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
546 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
547 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
548 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
549 }
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
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
551 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
552 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
553 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
554 }
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
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
556 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
557 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
558 if (len) {
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
559 utf8msg = malloc(len * sizeof(char));
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
560 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
561 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
562 }
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 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
565 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
566 return;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
567 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
568
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
569 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
570 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
571 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
572 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
573 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
574 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
575 }
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
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
577 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
578
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
579 /* 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
580 * 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
581 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
582 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
583 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
584 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
585 } 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
586 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
587 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
588 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
589 }
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 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
592 } 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
593 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
594 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
595 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
596 }
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 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
599 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
600 }
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
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
602
09e913390266 Restoring win32 stuff that was (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 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
604 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
605 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
606 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
607 wchar_t pidgin_dir[MAX_PATH];
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
608 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
609 HMODULE hmod;
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 *tmp;
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
611 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
612 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
613 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
614 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
615 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
616 LPWSTR *szArglist;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
617 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
618
09e913390266 Restoring win32 stuff that was (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 /* 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
620 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
621 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
622 /* 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
623 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
624 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
625 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
626 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
627 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
628 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
629 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
630 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
631 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
632 } else {
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
633 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
634 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
635 else if (strchr(__argv[i], 'h'))
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
636 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
637 else if (strchr(__argv[i], 'v'))
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
638 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
639 else if (strchr(__argv[i], 'm'))
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
640 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
641 }
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
642 }
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
643 }
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 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
646 /* 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
647 * (_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
648 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
649 LPFNATTACHCONSOLE MyAttachConsole = NULL;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
650 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
651 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
652 (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
653 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
654 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
655 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
656 || 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
657 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
658 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
659 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
660 }
09e913390266 Restoring win32 stuff that was (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 }
09e913390266 Restoring win32 stuff that was (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
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
663 cmdLine = GetCommandLineW();
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
664
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
665 /* 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
666 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
667 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
668 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
669 }
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
670
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
671 /* 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
672 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
673
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
674 /* primitive dirname() */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
675 tmp = 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
676
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
677 if (tmp) {
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
678 HMODULE hmod;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
679 tmp[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
680
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
681 /* tmp++ will now point to the executable file name */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
682 wcscpy(exe_name, tmp + 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
683
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
684 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
685 if ((hmod = LoadLibraryW(pidgin_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
686 FARPROC proc;
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
687 /* 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
688 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
689 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
690 /* 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
691 * 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
692 * again when it initializes) */
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
693 proc = GetProcAddress(hmod, "SetLogFile");
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
694 if (proc) {
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
695 if (GetTempPathA(sizeof(debug_dir) * sizeof(char), 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
696 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
697 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
698 debug_dir);
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
699 (proc)(debug_dir);
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 }
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 }
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 proc = GetProcAddress(hmod, "SetDebugInfoDir");
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
703 if (proc) {
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
704 char *pidgin_dir_ansi = NULL;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
705 tmp[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
706 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
707 -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
708 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
709 pidgin_dir_ansi = malloc(i * sizeof(char));
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
710 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
711 -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
712 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
713 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
714 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
715 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
716 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
717 if (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
718 _snprintf(debug_dir, sizeof(debug_dir) / sizeof(char),
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
719 "%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
720 pidgin_dir_ansi, VERSION);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
721 debug_dir[sizeof(debug_dir) / sizeof(char) - 1] = '\0';
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
722 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
723 debug_dir);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
724 (proc)(debug_dir);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
725 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
726 }
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
727 }
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
728
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
729 }
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
730
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
731 tmp[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
732 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
733 } 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
734 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
735 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
736 _snwprintf(errbuf, 512,
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
737 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
738 (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
739 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
740 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
741 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
742 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
743
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
744 /* 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
745 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
746 || (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
747 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
748 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
749 }
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
750
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
751 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
752 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
753 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
754 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
755
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
756 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
757
23936
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
758 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
759
18769
366db54481aa Make the win32 launcher support "--multiple" as well as %PIDGIN_MULTI_INST%
Daniel Atallah <datallah@pidgin.im>
parents: 17186
diff changeset
760 /* 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
761 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
762 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
763 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
764
16080
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
765 /* Now we are ready for Pidgin .. */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
766 if ((hmod = LoadLibraryW(L"pidgin.dll")))
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
767 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
768
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
769 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
770 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
771 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
772 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
773
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
774 _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
775 (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
776 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
777 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
778 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
779 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
780
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
781 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
782 }
09e913390266 Restoring win32 stuff that was (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
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
784 /* 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
785 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
786 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
787 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
788 k = 0;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
789 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
790 success = FALSE;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
791 /* 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
792 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
793 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
794 -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
795 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
796 char *arg = malloc(len * sizeof(char));
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
797 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
798 -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
799 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
800 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
801 success = TRUE;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
802 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
803 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
804 if (!success)
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
805 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
806 szArglist[i]);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
807 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
808 if (!success)
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
809 pidgin_argc--;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
810 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
811 LocalFree(szArglist);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
812
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
813
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
814 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
815 }

mercurial