pidgin/win32/winpidgin.c

Sun, 10 Oct 2021 05:01:54 -0500

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Sun, 10 Oct 2021 05:01:54 -0500
changeset 41086
631e6cba8635
parent 40840
b5f355f90ab0
child 41952
e128168d9ea5
permissions
-rw-r--r--

Fix typos in Pidgin

15450
09e913390266 Restoring win32 stuff that was (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
41086
631e6cba8635 Fix typos in Pidgin
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40840
diff changeset
5 * Description: Entry point for win32 pidgin, and various win32 dependent
15450
09e913390266 Restoring win32 stuff that was (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
39085
9c8e48e76838 win32: Add warning at top of winpidgin.c to warn against direct linking
Mike Ruprecht <cmaiku@gmail.com>
parents: 39081
diff changeset
28 /* This file must remain without any immediate dependencies aka don't link
9c8e48e76838 win32: Add warning at top of winpidgin.c to warn against direct linking
Mike Ruprecht <cmaiku@gmail.com>
parents: 39081
diff changeset
29 * directly to Pidgin, libpidgin, GLib, etc. WinPidgin adds a DLL directory
9c8e48e76838 win32: Add warning at top of winpidgin.c to warn against direct linking
Mike Ruprecht <cmaiku@gmail.com>
parents: 39081
diff changeset
30 * at runtime if needed and dynamically loads libpidgin via LoadLibrary().
9c8e48e76838 win32: Add warning at top of winpidgin.c to warn against direct linking
Mike Ruprecht <cmaiku@gmail.com>
parents: 39081
diff changeset
31 */
9c8e48e76838 win32: Add warning at top of winpidgin.c to warn against direct linking
Mike Ruprecht <cmaiku@gmail.com>
parents: 39081
diff changeset
32
33941
80fcf7f86e4a win32: globally define _WIN32_WINNT macro, tune config, move gtkconv themes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33385
diff changeset
33 #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
34
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
35 #include <windows.h>
35892
02bf3200b9cb cross-win32: make use of WIN32_LEAN_AND_MEAN define
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35859
diff changeset
36 #include <shellapi.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 #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
38 #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
39 #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
40 #include <stdio.h>
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
41 #include <sys/types.h>
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
42 #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
43
33371
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
44 typedef int (__cdecl* LPFNPIDGINMAIN)(HINSTANCE, int, char**);
39078
bbaab5d6a8d5 win32: Simplify complicated DLL preparation
Mike Ruprecht <cmaiku@gmail.com>
parents: 39077
diff changeset
45 typedef BOOL (WINAPI* LPFNSETDLLDIRECTORY)(LPCWSTR);
33371
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
46 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
47 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
48
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
49 /*
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
50 * 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
51 */
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
52 static LPFNPIDGINMAIN pidgin_main = NULL;
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
53
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
54 static const wchar_t *get_win32_error_message(DWORD err) {
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
55 static wchar_t err_msg[512];
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
56
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
57 FormatMessageW(
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
58 FORMAT_MESSAGE_FROM_SYSTEM,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
59 NULL, err,
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
60 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
61 (LPWSTR) &err_msg, sizeof(err_msg) / sizeof(wchar_t), NULL);
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
62
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
63 return err_msg;
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
64 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
65
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
66 #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
67 #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
68
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
69 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
70 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
71
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
72 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
73 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
74 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
75 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
76 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
77
40840
b5f355f90ab0 Port the updates from 2.14.2 and the upcoming 2.14.3 to 3.0.0
Gary Kramlich <grim@reaperworld.com>
parents: 39302
diff changeset
78 wprintf(L"An instance of Pidgin is already running.\n");
20257
e52756e57259 applied changes from d6da6a7a5ad01f170f0fd78424183f73200dc78c
Luke Schierer <lschiere@pidgin.im>
parents: 20221
diff changeset
79
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
80 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
81 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
82 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
83
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
84 /* 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
85
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
86 MessageBoxW(NULL,
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
87 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
88 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
89
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
90 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
91 }
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
92 } else if (err != ERROR_SUCCESS)
40840
b5f355f90ab0 Port the updates from 2.14.2 and the upcoming 2.14.3 to 3.0.0
Gary Kramlich <grim@reaperworld.com>
parents: 39302
diff changeset
93 wprintf(L"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
94 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
95 return 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
96 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
97
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
98 #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
99
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
100 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
101 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
102 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
103 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
104 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
105 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
106 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
107 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
108
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
109 /* 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
110 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
111
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
112 /* 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
113 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
114 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
115 else
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
116 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
117
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
118 if (wlen == 0) {
40840
b5f355f90ab0 Port the updates from 2.14.2 and the upcoming 2.14.3 to 3.0.0
Gary Kramlich <grim@reaperworld.com>
parents: 39302
diff changeset
119 wprintf(L"No protocol message specified.\n");
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
120 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
121 }
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
122
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
123 if (!(msg_win = FindWindowExW(NULL, NULL, L"WinpidginMsgWinCls", NULL))) {
40840
b5f355f90ab0 Port the updates from 2.14.2 and the upcoming 2.14.3 to 3.0.0
Gary Kramlich <grim@reaperworld.com>
parents: 39302
diff changeset
124 wprintf(L"Unable to find an instance of Pidgin to handle protocol message.\n");
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
125 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
126 }
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
127
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
128 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
129 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
130 if (len) {
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
131 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
132 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
133 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
134 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
135
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
136 if (len == 0) {
40840
b5f355f90ab0 Port the updates from 2.14.2 and the upcoming 2.14.3 to 3.0.0
Gary Kramlich <grim@reaperworld.com>
parents: 39302
diff changeset
137 wprintf(L"No protocol message specified.\n");
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
138 return;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
139 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
140
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
141 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
142 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
143 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
144 const wchar_t *err_msg = get_win32_error_message(dw);
39302
64aabebb476b winpidgin: Fix wprintf() style format for wchar_t strings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39087
diff changeset
145 wprintf(L"Unable to open Pidgin process. (%u) %ls\n",
64aabebb476b winpidgin: Fix wprintf() style format for wchar_t strings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39087
diff changeset
146 (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
147 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
148 }
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
149
39302
64aabebb476b winpidgin: Fix wprintf() style format for wchar_t strings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39087
diff changeset
150 wprintf(L"Trying to handle protocol message:\n'%.*ls'\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
151
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
152 /* 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
153 * 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
154 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
155 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
156 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
157 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
158 } 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
159 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
160 const wchar_t *err_msg = get_win32_error_message(dw);
39302
64aabebb476b winpidgin: Fix wprintf() style format for wchar_t strings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39087
diff changeset
161 wprintf(L"Unable to write to remote memory. (%u) %ls\n",
64aabebb476b winpidgin: Fix wprintf() style format for wchar_t strings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39087
diff changeset
162 (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
163 }
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
164
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
165 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
166 } 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
167 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
168 const wchar_t *err_msg = get_win32_error_message(dw);
39302
64aabebb476b winpidgin: Fix wprintf() style format for wchar_t strings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39087
diff changeset
169 wprintf(L"Unable to allocate remote memory. (%u) %ls\n",
64aabebb476b winpidgin: Fix wprintf() style format for wchar_t strings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39087
diff changeset
170 (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
171 }
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
172
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
173 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
174 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
175 }
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
176
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
177
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
178 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
179 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
180 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
181 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
182 wchar_t pidgin_dir[MAX_PATH];
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
183 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
184 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
185 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
186 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
187 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
188 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
189 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
190 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
191 LPWSTR *szArglist;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
192 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
193
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
194 /* 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
195 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
196 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
197 /* 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
198 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
199 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
200 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
201 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
202 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
203 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
204 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
205 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
206 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
207 } else {
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
208 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
209 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
210 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
211 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
212 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
213 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
214 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
215 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
216 }
742223a6306a Patch from Johnson Earls to improve the win32 launcher detection of whether we
Daniel Atallah <datallah@pidgin.im>
parents: 26999
diff changeset
217 }
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
218 }
48d838a2e580 Fix the initial parsing of args in the win32 launcher to be more robust.
Daniel Atallah <datallah@pidgin.im>
parents: 24433
diff changeset
219
33365
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
220 /* 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
221 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
222 LPFNSETPROCESSDEPPOLICY MySetProcessDEPPolicy =
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
223 (LPFNSETPROCESSDEPPOLICY)
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
224 GetProcAddress(hmod, "SetProcessDEPPolicy");
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
225 if (MySetProcessDEPPolicy)
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
226 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
227 }
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
228
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
229 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
230 /* 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
231 * (_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
232 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
233 LPFNATTACHCONSOLE MyAttachConsole = NULL;
33365
3d82cc32b7a2 Use SetProcessDEPPolicy to permanently enable DEP during startup on supported
Daniel Atallah <datallah@pidgin.im>
parents: 31362
diff changeset
234 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
235 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
236 (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
237 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
238 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
239 || 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
240 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
241 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
242 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
243 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
244 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
245
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
246 cmdLine = GetCommandLineW();
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
247
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
248 /* 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
249 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
250 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
251 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
252 }
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
253
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
254 /* 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
255 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
256
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
257 /* primitive dirname() */
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
258 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
259
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
260 if (pidgin_dir_start) {
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
261 HMODULE hmod;
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
262 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
263
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
264 /* 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
265 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
266
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
267 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
268 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
269 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
270 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
271 /* 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
272 char debug_dir[MAX_PATH];
40840
b5f355f90ab0 Port the updates from 2.14.2 and the upcoming 2.14.3 to 3.0.0
Gary Kramlich <grim@reaperworld.com>
parents: 39302
diff changeset
273 wprintf(L"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
274 /* 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
275 * 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
276 * 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
277 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
278 if (MySetLogFile) {
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
279 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
280 strcat(debug_dir, "pidgin.RPT");
40840
b5f355f90ab0 Port the updates from 2.14.2 and the upcoming 2.14.3 to 3.0.0
Gary Kramlich <grim@reaperworld.com>
parents: 39302
diff changeset
281 wprintf(L" Setting exchndl.dll LogFile to %s\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
282 debug_dir);
33371
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
283 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
284 }
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
285 }
33371
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
286 /* 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
287 * 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
288 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
289 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
290 char *pidgin_dir_ansi = NULL;
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
291 /* 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
292 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
293 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
294 -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
295 if (i != 0) {
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
296 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
297 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
298 -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
299 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
300 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
301 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
302 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
303 }
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_ansi != NULL) {
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
305 _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
306 "%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
307 pidgin_dir_ansi, VERSION);
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
308 debug_dir[sizeof(debug_dir) - 1] = '\0';
40840
b5f355f90ab0 Port the updates from 2.14.2 and the upcoming 2.14.3 to 3.0.0
Gary Kramlich <grim@reaperworld.com>
parents: 39302
diff changeset
309 wprintf(L" Setting exchndl.dll DebugInfoDir to %s\n",
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
310 debug_dir);
33371
6d93866a4a3f Explictly set the calling conventions for some dynamic functions on win32.
Daniel Atallah <datallah@pidgin.im>
parents: 33365
diff changeset
311 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
312 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
313 }
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
314 }
e30bf262a1f2 Use an updated exchndl.dll that supports setting the log file path manually and
Daniel Atallah <datallah@pidgin.im>
parents: 29634
diff changeset
315
29634
80dbf6f777c4 Use a private GTK+ Runtime copy on Windows.
Daniel Atallah <datallah@pidgin.im>
parents: 28536
diff changeset
316 }
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
317
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
318 /* 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
319 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
320 }
39078
bbaab5d6a8d5 win32: Simplify complicated DLL preparation
Mike Ruprecht <cmaiku@gmail.com>
parents: 39077
diff changeset
321
39081
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
322 /* Find parent directory to see if it's bin/ */
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
323 pidgin_dir_start = wcsrchr(pidgin_dir, L'\\');
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
324
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
325 /* Add bin/ subdirectory to DLL path if not already in bin/ */
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
326 if (pidgin_dir_start == NULL ||
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
327 wcscmp(pidgin_dir_start + 1, L"bin") != 0) {
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
328 LPFNSETDLLDIRECTORY MySetDllDirectory = NULL;
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
329
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
330 hmod = GetModuleHandleW(L"kernel32.dll");
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
331
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
332 if (hmod != NULL) {
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
333 MySetDllDirectory = (LPFNSETDLLDIRECTORY) GetProcAddress(hmod, "SetDllDirectoryW");
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
334 if (MySetDllDirectory == NULL) {
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
335 DWORD dw = GetLastError();
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
336 const wchar_t *err_msg = get_win32_error_message(dw);
39302
64aabebb476b winpidgin: Fix wprintf() style format for wchar_t strings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39087
diff changeset
337 wprintf(L"Error loading SetDllDirectory(): (%u) %ls\n", dw, err_msg);
39081
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
338 }
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
339 } else {
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
340 printf("Error getting kernel32.dll handle\n");
e84ed81142f8 win32: Allow WinPidgin to choose to add bin/ DLL directory at runtime
Mike Ruprecht <cmaiku@gmail.com>
parents: 39079
diff changeset
341 }
39078
bbaab5d6a8d5 win32: Simplify complicated DLL preparation
Mike Ruprecht <cmaiku@gmail.com>
parents: 39077
diff changeset
342
bbaab5d6a8d5 win32: Simplify complicated DLL preparation
Mike Ruprecht <cmaiku@gmail.com>
parents: 39077
diff changeset
343 if (MySetDllDirectory) {
bbaab5d6a8d5 win32: Simplify complicated DLL preparation
Mike Ruprecht <cmaiku@gmail.com>
parents: 39077
diff changeset
344 wcscat(pidgin_dir, L"\\bin");
bbaab5d6a8d5 win32: Simplify complicated DLL preparation
Mike Ruprecht <cmaiku@gmail.com>
parents: 39077
diff changeset
345 if (MySetDllDirectory(pidgin_dir)) {
39302
64aabebb476b winpidgin: Fix wprintf() style format for wchar_t strings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39087
diff changeset
346 wprintf(L"Added DLL directory to search path: %ls\n",
39078
bbaab5d6a8d5 win32: Simplify complicated DLL preparation
Mike Ruprecht <cmaiku@gmail.com>
parents: 39077
diff changeset
347 pidgin_dir);
bbaab5d6a8d5 win32: Simplify complicated DLL preparation
Mike Ruprecht <cmaiku@gmail.com>
parents: 39077
diff changeset
348 } else {
bbaab5d6a8d5 win32: Simplify complicated DLL preparation
Mike Ruprecht <cmaiku@gmail.com>
parents: 39077
diff changeset
349 DWORD dw = GetLastError();
bbaab5d6a8d5 win32: Simplify complicated DLL preparation
Mike Ruprecht <cmaiku@gmail.com>
parents: 39077
diff changeset
350 const wchar_t *err_msg = get_win32_error_message(dw);
39302
64aabebb476b winpidgin: Fix wprintf() style format for wchar_t strings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39087
diff changeset
351 wprintf(L"Error calling SetDllDirectory(): (%u) %ls\n", dw, err_msg);
39078
bbaab5d6a8d5 win32: Simplify complicated DLL preparation
Mike Ruprecht <cmaiku@gmail.com>
parents: 39077
diff changeset
352 }
bbaab5d6a8d5 win32: Simplify complicated DLL preparation
Mike Ruprecht <cmaiku@gmail.com>
parents: 39077
diff changeset
353 }
bbaab5d6a8d5 win32: Simplify complicated DLL preparation
Mike Ruprecht <cmaiku@gmail.com>
parents: 39077
diff changeset
354 }
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
355 } 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
356 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
357 const wchar_t *err_msg = get_win32_error_message(dw);
39086
a6cf683ddc27 win32: Use actual size of errbuf rather than hardcoding a number
Mike Ruprecht <cmaiku@gmail.com>
parents: 39085
diff changeset
358 _snwprintf(errbuf, sizeof(errbuf) / sizeof(wchar_t),
39302
64aabebb476b winpidgin: Fix wprintf() style format for wchar_t strings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39087
diff changeset
359 L"Error getting module filename.\nError: (%u) %ls",
15450
09e913390266 Restoring win32 stuff that was (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 (UINT) dw, err_msg);
39302
64aabebb476b winpidgin: Fix wprintf() style format for wchar_t strings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39087
diff changeset
361 wprintf(L"%ls\n", errbuf);
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
362 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
363 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
364 }
09e913390266 Restoring win32 stuff that was (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
18769
366db54481aa Make the win32 launcher support "--multiple" as well as %PIDGIN_MULTI_INST%
Daniel Atallah <datallah@pidgin.im>
parents: 17186
diff changeset
366 /* 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
367 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
368 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
369 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
370
16080
5668a44f275c Fix some overzealous s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15931
diff changeset
371 /* Now we are ready for Pidgin .. */
39087
ac9849be4a10 win32: Define libpidgin DLL name in meson to avoid needing to change it
Mike Ruprecht <cmaiku@gmail.com>
parents: 39086
diff changeset
372 if ((hmod = LoadLibraryW(LIBPIDGIN_DLL_NAMEW)))
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
373 pidgin_main = (LPFNPIDGINMAIN) GetProcAddress(hmod, "pidgin_main");
15450
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
374
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15450
diff changeset
375 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
376 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
377 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
378
39086
a6cf683ddc27 win32: Use actual size of errbuf rather than hardcoding a number
Mike Ruprecht <cmaiku@gmail.com>
parents: 39085
diff changeset
379 _snwprintf(errbuf, sizeof(errbuf) / sizeof(wchar_t),
39302
64aabebb476b winpidgin: Fix wprintf() style format for wchar_t strings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39087
diff changeset
380 L"Error loading %ls.\nError: (%u) %ls",
39087
ac9849be4a10 win32: Define libpidgin DLL name in meson to avoid needing to change it
Mike Ruprecht <cmaiku@gmail.com>
parents: 39086
diff changeset
381 LIBPIDGIN_DLL_NAMEW, (UINT) dw, err_msg);
39302
64aabebb476b winpidgin: Fix wprintf() style format for wchar_t strings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39087
diff changeset
382 wprintf(L"%ls\n", errbuf);
29878
623d7875f658 We're not going to support a non-UNICODE pidgin.exe
Daniel Atallah <datallah@pidgin.im>
parents: 29807
diff changeset
383 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
384
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
385 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
386 }
09e913390266 Restoring win32 stuff that was (I assume accidentally) dropped. I took advantage of the opportunity to try the daggy fix stuff.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
387
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
388 /* 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
389 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
390 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
391 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
392 k = 0;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
393 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
394 success = FALSE;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
395 /* 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
396 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
397 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
398 -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
399 if (len != 0) {
33385
562961da7c0d Avoid unnecessary sizeof(char); it must always be 1
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
400 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
401 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
402 -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
403 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
404 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
405 success = TRUE;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
406 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
407 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
408 if (!success)
39302
64aabebb476b winpidgin: Fix wprintf() style format for wchar_t strings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39087
diff changeset
409 wprintf(L"Error converting argument '%ls' to UTF-8\n",
29636
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
410 szArglist[i]);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
411 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
412 if (!success)
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
413 pidgin_argc--;
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
414 }
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
415 LocalFree(szArglist);
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
416
cfd62d35ff49 Fix the win32 launcher to support unicode input. This allows the config
Daniel Atallah <datallah@pidgin.im>
parents: 29635
diff changeset
417
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
418 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
419 }

mercurial