annotate pidgin/win32/winpidgin.c @ 32005:135868ec0aa9

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