pidgin/win32/winpidgin.c

Wed, 16 Apr 2014 22:40:44 +0200

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Wed, 16 Apr 2014 22:40:44 +0200
changeset 35859
3d157ce203ed
parent 34212
76231c6158ba
child 35892
02bf3200b9cb
permissions
-rw-r--r--

cross-win32: make libpidgin and libfinch shared, disable hacky libpidgin loading code. Pidgin runs now

15450
09e913390266 Restoring win32 stuff that was (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
35859
3d157ce203ed cross-win32: make libpidgin and libfinch shared, disable hacky libpidgin loading code. Pidgin runs now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34212
diff changeset
38 #ifndef IS_WIN32_CROSS_COMPILED
33371
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
39 typedef int (__cdecl* LPFNPIDGINMAIN)(HINSTANCE, int, char**);
35859
3d157ce203ed cross-win32: make libpidgin and libfinch shared, disable hacky libpidgin loading code. Pidgin runs now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34212
diff changeset
40 #endif
33371
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
41 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
42 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
43 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
44
18770
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
45 static BOOL portable_mode = FALSE;
19fd340ce715 Convert portable winpidgin launcher executable to be the same binary as pidgin.exe and determine which behavior to use at runtime. Running "pidgin.exe --portable-mode" or renaming "pidgin.exe" to "pidgin-portable.exe" will cause the portable mode to be used.
Daniel Atallah <datallah@pidgin.im>
parents: 18769
diff changeset
46
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
47 /*
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
48 * PROTOTYPES
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
49 */
35859
3d157ce203ed cross-win32: make libpidgin and libfinch shared, disable hacky libpidgin loading code. Pidgin runs now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34212
diff changeset
50 #ifdef IS_WIN32_CROSS_COMPILED
3d157ce203ed cross-win32: make libpidgin and libfinch shared, disable hacky libpidgin loading code. Pidgin runs now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34212
diff changeset
51 int __cdecl pidgin_main(HINSTANCE hint, int argc, char *argv[]);
3d157ce203ed cross-win32: make libpidgin and libfinch shared, disable hacky libpidgin loading code. Pidgin runs now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34212
diff changeset
52 #else
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
53 static LPFNPIDGINMAIN pidgin_main = NULL;
35859
3d157ce203ed cross-win32: make libpidgin and libfinch shared, disable hacky libpidgin loading code. Pidgin runs now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34212
diff changeset
54 #endif
15450
09e913390266 Restoring win32 stuff that was (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 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
56
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
57 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
58 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
59
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
60 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
61 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
62 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
63 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
64 (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
65
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
66 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
67 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
68
33960
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
69 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
70 HKEY hkey;
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
71 LONG retv;
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
72 DWORD index;
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
73 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
74 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
75
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
76 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
77 return FALSE;
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
78
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
79 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
80 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
81 return FALSE;
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
82
33962
d44a3e57992c Win32: silence perl check
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33960
diff changeset
83 if (val_name[0] == L'\0') {
d44a3e57992c Win32: silence perl check
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33960
diff changeset
84 RegCloseKey(hkey);
d44a3e57992c Win32: silence perl check
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33960
diff changeset
85 return TRUE;
d44a3e57992c Win32: silence perl check
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33960
diff changeset
86 }
d44a3e57992c Win32: silence perl check
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33960
diff changeset
87
33960
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
88 index = 0;
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
89 while (TRUE)
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
90 {
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
91 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
92 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
93 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
94 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
95 break;
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
96 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
97 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
98 exists = TRUE;
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
99 break;
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
100 }
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
101 }
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
102
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
103 RegCloseKey(hkey);
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
104 return exists;
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
105 }
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
106
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
107 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
108 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
109 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
110 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
111
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
112 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
113 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
114 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
115 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
116 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
117 else {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
118 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
119
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
120 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
121 (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
122 : ((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
123 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
124 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
125 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
126 }
09e913390266 Restoring win32 stuff that was (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 else {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
128 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
129
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
130 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
131 (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
132 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
133 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
134 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
135
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
136 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
137 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
138
33960
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
139 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
140 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
141 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
142
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
143 _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
144 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
145 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
146
33960
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
147 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
148 }
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
149
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
150 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
151 HMODULE hmod;
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
152 HKEY hkey;
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
153 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
154 wchar_t tmp_path[MAX_PATH + 1];
34212
76231c6158ba VV: set farstream plugin paths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33962
diff changeset
155 /* 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
156 * MAX_PATH + 1
76231c6158ba VV: set farstream plugin paths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33962
diff changeset
157 */
76231c6158ba VV: set farstream plugin paths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33962
diff changeset
158 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
159
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
160 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
161 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
162 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
163
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
164 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
165 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
166 exit(-1);
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
167 }
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
168
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
169 path = NULL;
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
170 do
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
171 {
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
172 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
173 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
174 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
175 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
176 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
177 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
178 }
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
179 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
180 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
181 break;
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
182 }
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
183 }
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
184 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
185
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
186 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
187 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
188 exit(-1);
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
189 }
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
190 }
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
191
33960
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
192 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
193
33960
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
194 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
195 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
196 wcsrchr(tmp_path, L'\\')[0] = L'\0';
34212
76231c6158ba VV: set farstream plugin paths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33962
diff changeset
197 /* tmp_path now contains \path\to\Pidgin\Gtk */
76231c6158ba VV: set farstream plugin paths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33962
diff changeset
198
76231c6158ba VV: set farstream plugin paths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33962
diff changeset
199 _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
200 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
201 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
202 _wputenv(set_path);
76231c6158ba VV: set farstream plugin paths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33962
diff changeset
203
76231c6158ba VV: set farstream plugin paths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33962
diff changeset
204 _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
205 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
206 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
207 _wputenv(set_path);
76231c6158ba VV: set farstream plugin paths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33962
diff changeset
208
76231c6158ba VV: set farstream plugin paths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33962
diff changeset
209 _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
210 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
211 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
212 _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
213
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
214 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
215 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
216 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
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 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
219 } 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
220 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
221
09e913390266 Restoring win32 stuff that was (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 /* 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
223 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
224 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
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
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
227 /* 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
228 * 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
229 else {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
230 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
231
09e913390266 Restoring win32 stuff that was (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 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
233 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
234 /* 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
235 * 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
236 * 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
237 * 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
238 */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
239 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
240 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
241 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
242 && 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
243 && 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
244 ||
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
245 (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
246 && 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
247 && 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
248 ) {
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
249 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
250 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
251
09e913390266 Restoring win32 stuff that was (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 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
253 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
254 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
255 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
256 (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
257 &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
258
09e913390266 Restoring win32 stuff that was (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 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
260 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
261 regval = 0;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
262 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
263 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
264 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
265 ) == ERROR_SUCCESS) {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
266 if (RegSetValueExW(hkey,
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
267 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
268 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
269 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
270 ) != 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
271 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
272 (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
273 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
274 } 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
275 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
276 (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
277 } 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
278 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
279 }/*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
280 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
281 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
282
33960
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
283 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
284 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
285 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
286
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 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
288 _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
289 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
290 }
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
291
33960
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
292 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
293 }
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
294
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
295 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
296 /* 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
297 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
298 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
299 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
300
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 /* 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
302 * 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
303 */
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
304 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
305 /* 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
306 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
307
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
308 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
309 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
310 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
311 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
312 } 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
313 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
314 "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
315 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
316 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
317 }
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
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
319 /* 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
320 _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
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
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
323 /* 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
324 * 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
325 _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
326 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
327 _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
328
33960
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
329 _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
330 pidgin_dir);
ce450446c56a Win32: strengthen DLL loading; VV: fix farstream plugins loading on win32
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33941
diff changeset
331 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
332 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
333 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
334 else {
29805
c7d28ce85db7 Make the portable mode launcher try the "normal" mode path.
Daniel Atallah <datallah@pidgin.im>
parents: 29637
diff changeset
335 /* 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
336 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
337 common_dll_prep(path);
c7d28ce85db7 Make the portable mode launcher try the "normal" mode path.
Daniel Atallah <datallah@pidgin.im>
parents: 29637
diff changeset
338 }
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
339 }
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
340
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
341 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
342 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
343 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
344 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
345
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
346 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
347 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
348 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
349 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
350 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
351 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
352 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
353 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
354 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
355 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
356 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
357 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
358 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
359 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
360 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
361 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
362 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
363 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
364 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
365 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
366 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
367 default:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
368 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
369 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
370 break;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
371 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
372 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
373 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
374 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
375 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
376 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
377 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
378 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
379 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
380 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
381 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
382 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
383 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
384 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
385 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
386 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
387 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
388 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
389 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
390 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
391 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
392 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
393 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
394 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
395 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
396 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
397 }
09e913390266 Restoring win32 stuff that was (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 break;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
399 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
400 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
401 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
402 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
403 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
404 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
405 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
406 default:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
407 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
408 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
409 break;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
410 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
411 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
412 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
413 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
414 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
415 /* 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
416 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
417 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
418 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
419 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
420 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
421 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
422 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
423 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
424 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
425 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
426 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
427 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
428 break;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
429 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
430 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
431 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
432 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
433 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
434 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
435 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
436 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
437 case LANG_CHINESE:
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
438 switch (sub_id) {
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
439 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
440 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
441 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
442 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
443 default:
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
444 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
445 }
6278b40a207f Add win32 LCID lookup mappings for Afrikaans, Indonesian, Kannada, Pashto.
Daniel Atallah <datallah@pidgin.im>
parents: 18770
diff changeset
446 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
447 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
448 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
449 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
450 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
451 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
452 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
453 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
454 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
455 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
456 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
457 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
458 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
459 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
460 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
461 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
462 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
463 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
464 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
465 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
466 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
467 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
468 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
469 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
470 }
09e913390266 Restoring win32 stuff that was (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 /* 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
473 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
474 switch (lcid) {
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
475 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
476 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
477 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
478 }
09e913390266 Restoring win32 stuff that was (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
09e913390266 Restoring win32 stuff that was (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 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
481 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
482
16080
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
483 /* 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
484 - 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
485 - 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
486 - 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
487 */
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
488 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
489 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
490 LCID lcid;
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
491 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
492 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
493
16080
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
494 /* 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
495 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
496 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
497
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
498 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
499 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
500 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
501 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
502 }
09e913390266 Restoring win32 stuff that was (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 lcid = GetUserDefaultLCID();
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
505 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
506 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
507
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
508 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
509 }
09e913390266 Restoring win32 stuff that was (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
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
511 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
512 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
513 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
514
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
515 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
516
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
517 _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
518 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
519 _wputenv(envstr);
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
520 }
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
521
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
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
523 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
524 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
525 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
526 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
527 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
528 DWORD plen;
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
529
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
530 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
531
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
532 plen = sizeof(perl_path) / sizeof(wchar_t);
33962
d44a3e57992c Win32: silence perl check
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33960
diff changeset
533 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
534 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
535 (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
536 /* 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
537 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
538
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
539 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
540 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
541 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
542
23936
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
543 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
544 } else
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
545 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
546
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
547 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
548
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
549 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
550 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
551 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
552 (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
553 /* 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
554 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
555
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
556 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
557 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
558 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
559
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
560 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
561 } else
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
562 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
563
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
564 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
565 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
566 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
567 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
568 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
569 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
570
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
571 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
572 /* 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
573 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
574 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
575 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
576 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
577 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
578 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
579
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
580 _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
581 path ? path : L"",
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
582 path ? L";" : L"",
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
583 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
584 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
585 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
586 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
587
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
588 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
589
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
590 _wputenv(newpath);
23915
b62601fd6e7d Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents: 22644
diff changeset
591 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
592 }
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
593 }
15450
09e913390266 Restoring win32 stuff that was (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 }
09e913390266 Restoring win32 stuff that was (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
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
596 #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
597 #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
598
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
599 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
600 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
601
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
602 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
603 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
604 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
605 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
606 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
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 printf("An instance of Pidgin is already running.\n");
20257
e52756e57259 applied changes from d6da6a7a5ad01f170f0fd78424183f73200dc78c
Luke Schierer <lschiere@pidgin.im>
parents: 20221
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 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
611 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
612 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
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 /* 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
615
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
616 MessageBoxW(NULL,
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
617 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
618 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
619
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
620 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
621 }
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
622 } else if (err != ERROR_SUCCESS)
22036
50c4b5826c97 Warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 21971
diff changeset
623 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
624 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
625 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
626 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
627
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
628 #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
629
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
630 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
631 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
632 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
633 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
634 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
635 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
636 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
637 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
638
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 /* 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
640 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
641
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
642 /* 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
643 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
644 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
645 else
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
646 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
647
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
648 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
649 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
650 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
651 }
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
652
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
653 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
654 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
655 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
656 }
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
657
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
658 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
659 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
660 if (len) {
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
661 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
662 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
663 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
664 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
665
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
666 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
667 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
668 return;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
669 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
670
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
671 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
672 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
673 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
674 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
675 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
676 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
677 }
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
678
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
679 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
680
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
681 /* 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
682 * 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
683 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
684 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
685 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
686 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
687 } 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
688 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
689 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
690 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
691 }
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 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
694 } 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
695 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
696 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
697 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
698 }
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
699
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
700 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
701 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
702 }
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
703
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
704
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
705 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
706 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
707 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
708 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
709 wchar_t pidgin_dir[MAX_PATH];
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
710 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
711 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
712 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
713 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
714 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
715 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
716 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
717 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
718 LPWSTR *szArglist;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
719 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
720
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
721 /* 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
722 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
723 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
724 /* 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
725 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
726 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
727 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
728 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
729 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
730 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
731 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
732 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
733 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
734 } else {
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
735 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
736 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
737 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
738 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
739 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
740 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
741 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
742 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
743 }
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
744 }
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
745 }
48d838a2e580 Fix the initial parsing of args in the win32 launcher to be more robust.
Daniel Atallah <datallah@pidgin.im>
parents: 24433
diff changeset
746
33365
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
747 /* 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
748 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
749 LPFNSETPROCESSDEPPOLICY MySetProcessDEPPolicy =
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
750 (LPFNSETPROCESSDEPPOLICY)
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
751 GetProcAddress(hmod, "SetProcessDEPPolicy");
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
752 if (MySetProcessDEPPolicy)
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
753 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
754 }
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
755
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
756 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
757 /* 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
758 * (_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
759 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
760 LPFNATTACHCONSOLE MyAttachConsole = NULL;
33365
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
761 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
762 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
763 (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
764 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
765 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
766 || 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
767 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
768 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
769 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
770 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
771 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
772
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
773 cmdLine = GetCommandLineW();
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
774
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
775 /* 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
776 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
777 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
778 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
779 }
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
780
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
781 /* 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
782 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
783
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 /* primitive dirname() */
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
785 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
786
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
787 if (pidgin_dir_start) {
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
788 HMODULE hmod;
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
789 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
790
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
791 /* 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
792 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
793
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
794 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
795 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
796 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
797 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
798 /* 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
799 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
800 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
801 /* 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
802 * 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
803 * 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
804 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
805 if (MySetLogFile) {
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
806 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
807 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
808 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
809 debug_dir);
33371
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
810 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
811 }
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
812 }
33371
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
813 /* 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
814 * 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
815 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
816 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
817 char *pidgin_dir_ansi = NULL;
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
818 /* 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
819 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
820 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
821 -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
822 if (i != 0) {
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
823 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
824 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
825 -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
826 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
827 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
828 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
829 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
830 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
831 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
832 _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
833 "%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
834 pidgin_dir_ansi, VERSION);
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
835 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
836 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
837 debug_dir);
33371
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
838 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
839 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
840 }
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
841 }
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
842
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
843 }
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
844
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
845 /* 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
846 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
847 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
848 } 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
849 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
850 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
851 _snwprintf(errbuf, 512,
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
852 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
853 (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
854 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
855 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
856 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
857 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
858
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
859 /* 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
860 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
861 || (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
862 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
863 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
864 }
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
865
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
866 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
867 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
868 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
869 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
870
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
871 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
872
23936
67df298c2b9b This should have been part of the previous commit related to no longer
Daniel Atallah <datallah@pidgin.im>
parents: 23934
diff changeset
873 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
874
18769
366db54481aa Make the win32 launcher support "--multiple" as well as %PIDGIN_MULTI_INST%
Daniel Atallah <datallah@pidgin.im>
parents: 17186
diff changeset
875 /* 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
876 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
877 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
878 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
879
35859
3d157ce203ed cross-win32: make libpidgin and libfinch shared, disable hacky libpidgin loading code. Pidgin runs now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34212
diff changeset
880 #ifndef IS_WIN32_CROSS_COMPILED
16080
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
881 /* Now we are ready for Pidgin .. */
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
882 wcscat(pidgin_dir, L"\\pidgin.dll");
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
883 if ((hmod = LoadLibraryW(pidgin_dir)))
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
884 pidgin_main = (LPFNPIDGINMAIN) GetProcAddress(hmod, "pidgin_main");
35859
3d157ce203ed cross-win32: make libpidgin and libfinch shared, disable hacky libpidgin loading code. Pidgin runs now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34212
diff changeset
885 #endif
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
886
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
887 /* 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
888 if (pidgin_dir_start)
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
889 pidgin_dir_start[0] = L'\0';
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
890
35859
3d157ce203ed cross-win32: make libpidgin and libfinch shared, disable hacky libpidgin loading code. Pidgin runs now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34212
diff changeset
891 #ifndef IS_WIN32_CROSS_COMPILED
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
892 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
893 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
894 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
895 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
896
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
897 _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
898 (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
899 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
900 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
901 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
902 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
903
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
904 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
905 }
35859
3d157ce203ed cross-win32: make libpidgin and libfinch shared, disable hacky libpidgin loading code. Pidgin runs now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34212
diff changeset
906 #endif
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
907
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
908 /* 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
909 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
910 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
911 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
912 k = 0;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
913 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
914 success = FALSE;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
915 /* 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
916 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
917 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
918 -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
919 if (len != 0) {
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
920 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
921 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
922 -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
923 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
924 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
925 success = TRUE;
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 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
928 if (!success)
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
929 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
930 szArglist[i]);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
931 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
932 if (!success)
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
933 pidgin_argc--;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
934 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
935 LocalFree(szArglist);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
936
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
937
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
938 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
939 }

mercurial