pidgin/win32/winpidgin.c

Tue, 11 Jun 2013 10:15:23 +0200

author
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
date
Tue, 11 Jun 2013 10:15:23 +0200
changeset 34212
76231c6158ba
parent 33962
d44a3e57992c
child 35859
3d157ce203ed
permissions
-rw-r--r--

VV: set farstream plugin paths

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

mercurial