Mercurial > pidgin
annotate gtk/win32/win_gaim.c @ 14263:d7b40a686355
[gaim-migrate @ 16945]
Don't call gethostbyname in a thread because it's not thread-safe.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 21 Aug 2006 05:49:20 +0000 |
parents | 14933d9055a0 |
children | 79adfd5ac0b9 |
rev | line source |
---|---|
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
1 /* |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
2 * win_gaim.c |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
3 * |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
4 * Date: June, 2002 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
5 * Description: Entry point for win32 gaim, and various win32 dependant |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
6 * routines. |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
7 * |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
8 * Gaim is the legal property of its developers, whose names are too numerous |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
9 * to list here. Please refer to the COPYRIGHT file distributed with this |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
10 * source distribution. |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
11 * |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
12 * This program is free software; you can redistribute it and/or modify |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
13 * it under the terms of the GNU General Public License as published by |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
14 * the Free Software Foundation; either version 2 of the License, or |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
15 * (at your option) any later version. |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
16 * |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
17 * This program is distributed in the hope that it will be useful, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
20 * GNU General Public License for more details. |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
21 * |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
22 * You should have received a copy of the GNU General Public License |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
23 * along with this program; if not, write to the Free Software |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
25 * |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
26 */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
27 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
28 /* This is for ATTACH_PARENT_PROCESS */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
29 #ifndef _WIN32_WINNT |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
30 #define _WIN32_WINNT 0x501 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
31 #endif |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
32 #include <windows.h> |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
33 #include <fcntl.h> |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
34 #include <stdlib.h> |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
35 #include <string.h> |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
36 #include <stdio.h> |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
37 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
38 #define WIN32_PROXY_REGKEY "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings" |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
39 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
40 typedef int (CALLBACK* LPFNGAIMMAIN)(HINSTANCE, int, char**); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
41 typedef void (CALLBACK* LPFNSETDLLDIRECTORY)(LPCTSTR); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
42 typedef BOOL (CALLBACK* LPFNATTACHCONSOLE)(DWORD); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
43 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
44 /* |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
45 * PROTOTYPES |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
46 */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
47 static LPFNGAIMMAIN gaim_main = NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
48 static LPFNSETDLLDIRECTORY MySetDllDirectory = NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
49 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
50 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
51 static BOOL read_reg_string(HKEY key, char* sub_key, char* val_name, LPBYTE data, LPDWORD data_len) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
52 HKEY hkey; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
53 BOOL ret = FALSE; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
54 LONG retv; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
55 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
56 if (ERROR_SUCCESS == (retv = RegOpenKeyEx(key, sub_key, 0, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
57 KEY_QUERY_VALUE, &hkey))) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
58 if (ERROR_SUCCESS == (retv = RegQueryValueEx(hkey, val_name, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
59 NULL, NULL, data, data_len))) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
60 ret = TRUE; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
61 else { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
62 TCHAR szBuf[80]; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
63 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
64 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
65 NULL, retv, 0, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
66 (LPTSTR) &szBuf, sizeof(szBuf), NULL); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
67 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
68 printf("Could not read reg key '%s' subkey '%s' value: '%s'\nError: (%ld) %s\n", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
69 ((key == HKEY_LOCAL_MACHINE) ? "HKLM" : |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
70 (key == HKEY_CURRENT_USER) ? "HKCU" : |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
71 "???"), |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
72 sub_key, val_name, retv, szBuf); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
73 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
74 RegCloseKey(hkey); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
75 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
76 else { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
77 TCHAR szBuf[80]; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
78 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
79 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, retv, 0, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
80 (LPTSTR) &szBuf, sizeof(szBuf), NULL); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
81 printf("Could not open reg subkey: %s\nError: (%ld) %s\n", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
82 sub_key, retv, szBuf); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
83 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
84 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
85 return ret; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
86 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
87 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
88 static void dll_prep() { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
89 char path[MAX_PATH + 1]; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
90 HMODULE hmod; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
91 HKEY hkey; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
92 #ifdef PORTABLE |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
93 /* We assume that GTK+ is installed under \\path\to\Gaim\..\GTK |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
94 * First we find \\path\to |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
95 */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
96 if (GetModuleFileName(NULL, path, MAX_PATH) != 0) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
97 char *tmp = path; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
98 char *prev = NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
99 char *prev2 = NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
100 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
101 while ((tmp = strchr(tmp, '\\'))) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
102 prev2 = prev; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
103 prev = tmp; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
104 tmp++; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
105 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
106 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
107 if (prev2) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
108 prev2[0] = '\0'; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
109 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
110 } else { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
111 printf("Unable to determine current executable path. \n" |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
112 "This will prevent the settings dir from being set.\n" |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
113 "Assuming GTK+ is in the PATH.\n"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
114 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
115 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
116 if (path) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
117 /* Set up the settings dir base to be \\path\to |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
118 * The actual settings dir will be \\path\to\.gaim */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
119 char settingsdir[strlen(path) + strlen("GAIMHOME=") + 1]; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
120 char aspelldir[strlen(path) + strlen("GAIM_ASPELL_DIR=\\Aspell\\bin") + 1]; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
121 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
122 snprintf(settingsdir, sizeof(settingsdir), "GAIMHOME=%s", path); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
123 printf("Setting settings dir: %s\n", settingsdir); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
124 putenv(settingsdir); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
125 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
126 snprintf(aspelldir, sizeof(aspelldir), "GAIM_ASPELL_DIR=%s\\Aspell\\bin", path); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
127 printf(aspelldir); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
128 putenv(aspelldir); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
129 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
130 /* set the GTK+ path to be \\path\to\GTK\bin */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
131 strcat(path, "\\GTK\\bin"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
132 } else |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
133 return; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
134 #else /* PORTABLE */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
135 char gtkpath[MAX_PATH + 1]; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
136 DWORD plen; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
137 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
138 plen = sizeof(gtkpath); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
139 hkey = HKEY_CURRENT_USER; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
140 if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "Path", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
141 (LPBYTE) >kpath, &plen)) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
142 hkey = HKEY_LOCAL_MACHINE; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
143 if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "Path", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
144 (LPBYTE) >kpath, &plen)) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
145 printf("GTK+ Path Registry Key not found. " |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
146 "Assuming GTK+ is in the PATH.\n"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
147 return; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
148 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
149 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
150 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
151 /* this value is replaced during a successful RegQueryValueEx() */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
152 plen = sizeof(path); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
153 /* Determine GTK+ dll path .. */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
154 if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "DllPath", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
155 (LPBYTE) &path, &plen)) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
156 strcpy(path, gtkpath); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
157 strcat(path, "\\bin"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
158 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
159 #endif |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
160 printf("GTK+ path found: %s\n", path); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
161 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
162 if ((hmod = GetModuleHandle("kernel32.dll"))) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
163 MySetDllDirectory = (LPFNSETDLLDIRECTORY) GetProcAddress( |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
164 hmod, "SetDllDirectoryA"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
165 if (!MySetDllDirectory) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
166 printf("SetDllDirectory not supported\n"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
167 } else |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
168 printf("Error getting kernel32.dll module handle\n"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
169 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
170 /* For Windows XP SP1+ / Server 2003 we use SetDllDirectory to avoid dll hell */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
171 if (MySetDllDirectory) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
172 printf("Using SetDllDirectory\n"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
173 MySetDllDirectory(path); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
174 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
175 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
176 /* For the rest, we set the current directory and make sure |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
177 * SafeDllSearch is set to 0 where needed. */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
178 else { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
179 OSVERSIONINFO osinfo; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
180 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
181 printf("Setting current directory to GTK+ dll directory\n"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
182 SetCurrentDirectory(path); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
183 /* For Windows 2000 (SP3+) / WinXP (No SP): |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
184 * If SafeDllSearchMode is set to 1, Windows system directories are |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
185 * searched for dlls before the current directory. Therefore we set it |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
186 * to 0. |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
187 */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
188 osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
189 GetVersionEx(&osinfo); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
190 if ((osinfo.dwMajorVersion == 5 && |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
191 osinfo.dwMinorVersion == 0 && |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
192 strcmp(osinfo.szCSDVersion, "Service Pack 3") >= 0) || |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
193 (osinfo.dwMajorVersion == 5 && |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
194 osinfo.dwMinorVersion == 1 && |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
195 strcmp(osinfo.szCSDVersion, "") >= 0) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
196 ) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
197 DWORD regval = 1; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
198 DWORD reglen = sizeof(DWORD); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
199 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
200 printf("Using Win2k (SP3+) / WinXP (No SP)... Checking SafeDllSearch\n"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
201 read_reg_string(HKEY_LOCAL_MACHINE, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
202 "System\\CurrentControlSet\\Control\\Session Manager", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
203 "SafeDllSearchMode", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
204 (LPBYTE) ®val, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
205 ®len); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
206 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
207 if (regval != 0) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
208 printf("Trying to set SafeDllSearchMode to 0\n"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
209 regval = 0; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
210 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
211 "System\\CurrentControlSet\\Control\\Session Manager", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
212 0, KEY_SET_VALUE, &hkey |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
213 ) == ERROR_SUCCESS) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
214 if (RegSetValueEx(hkey, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
215 "SafeDllSearchMode", 0, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
216 REG_DWORD, (LPBYTE) ®val, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
217 sizeof(DWORD) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
218 ) != ERROR_SUCCESS) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
219 printf("Error writing SafeDllSearchMode. Error: %u\n", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
220 (UINT) GetLastError()); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
221 RegCloseKey(hkey); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
222 } else |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
223 printf("Error opening Session Manager key for writing. Error: %u\n", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
224 (UINT) GetLastError()); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
225 } else |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
226 printf("SafeDllSearchMode is set to 0\n"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
227 }/*end else*/ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
228 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
229 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
230 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
231 static char* wgaim_lcid_to_posix(LCID lcid) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
232 char *posix = NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
233 int lang_id = PRIMARYLANGID(lcid); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
234 int sub_id = SUBLANGID(lcid); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
235 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
236 switch (lang_id) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
237 case LANG_ARABIC: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
238 case LANG_BULGARIAN: posix = "bg"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
239 case LANG_CATALAN: posix = "ca"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
240 case LANG_CHINESE: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
241 switch (sub_id) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
242 case SUBLANG_CHINESE_SIMPLIFIED: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
243 posix = "zh_CN"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
244 case SUBLANG_CHINESE_TRADITIONAL: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
245 posix = "zh_TW"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
246 default: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
247 posix = "zh"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
248 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
249 break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
250 case LANG_CZECH: posix = "cs"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
251 case LANG_DANISH: posix = "da"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
252 case LANG_GERMAN: posix = "de"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
253 case LANG_GREEK: posix = "el"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
254 case LANG_ENGLISH: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
255 switch (sub_id) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
256 case SUBLANG_ENGLISH_UK: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
257 posix = "en_GB"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
258 case SUBLANG_ENGLISH_AUS: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
259 posix = "en_AU"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
260 case SUBLANG_ENGLISH_CAN: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
261 posix = "en_CA"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
262 default: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
263 posix = "en"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
264 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
265 break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
266 case LANG_SPANISH: posix = "es"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
267 case LANG_FINNISH: posix = "fi"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
268 case LANG_FRENCH: posix = "fr"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
269 case LANG_HEBREW: posix = "he"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
270 case LANG_HUNGARIAN: posix = "hu"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
271 case LANG_ICELANDIC: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
272 case LANG_ITALIAN: posix = "it"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
273 case LANG_JAPANESE: posix = "ja"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
274 case LANG_KOREAN: posix = "ko"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
275 case LANG_DUTCH: posix = "nl"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
276 case LANG_NORWEGIAN: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
277 switch (sub_id) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
278 case SUBLANG_NORWEGIAN_BOKMAL: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
279 posix = "nb"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
280 case SUBLANG_NORWEGIAN_NYNORSK: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
281 posix = "nn"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
282 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
283 break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
284 case LANG_POLISH: posix = "pl"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
285 case LANG_PORTUGUESE: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
286 switch (sub_id) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
287 case SUBLANG_PORTUGUESE_BRAZILIAN: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
288 posix = "pt_BR"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
289 default: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
290 posix = "pt"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
291 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
292 break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
293 case LANG_ROMANIAN: posix = "ro"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
294 case LANG_RUSSIAN: posix = "ru"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
295 /* LANG_CROATIAN == LANG_SERBIAN for some reason |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
296 * We'll need to do something here if we ever get a croatian translation */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
297 /* case LANG_CROATIAN: posix = "hr"; break;*/ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
298 case LANG_SERBIAN: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
299 switch (sub_id) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
300 case SUBLANG_SERBIAN_LATIN: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
301 posix = "sr@Latn"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
302 case SUBLANG_SERBIAN_CYRILLIC: |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
303 posix = "sr"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
304 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
305 break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
306 case LANG_SLOVAK: posix = "sk"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
307 case LANG_ALBANIAN: posix = "sq"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
308 case LANG_SWEDISH: posix = "sv"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
309 case LANG_THAI: posix = "th"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
310 case LANG_TURKISH: posix = "tr"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
311 case LANG_URDU: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
312 case LANG_INDONESIAN: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
313 case LANG_UKRAINIAN: posix = "uk"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
314 case LANG_BELARUSIAN: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
315 case LANG_SLOVENIAN: posix = "sl"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
316 case LANG_ESTONIAN: posix = "et"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
317 case LANG_LATVIAN: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
318 case LANG_LITHUANIAN: posix = "lt"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
319 case LANG_FARSI: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
320 case LANG_VIETNAMESE: posix = "vi"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
321 case LANG_ARMENIAN: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
322 case LANG_AZERI: posix = "az"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
323 case LANG_BASQUE: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
324 case LANG_MACEDONIAN: posix = "mk"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
325 case LANG_AFRIKAANS: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
326 case LANG_GEORGIAN: posix = "ka"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
327 case LANG_FAEROESE: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
328 case LANG_HINDI: posix = "hi"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
329 case LANG_MALAY: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
330 case LANG_KAZAK: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
331 case LANG_KYRGYZ: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
332 case LANG_SWAHILI: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
333 case LANG_UZBEK: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
334 case LANG_TATAR: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
335 case LANG_BENGALI: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
336 case LANG_PUNJABI: posix = "pa"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
337 case LANG_GUJARATI: posix = "gu"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
338 case LANG_ORIYA: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
339 case LANG_TAMIL: posix = "ta"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
340 case LANG_TELUGU: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
341 case LANG_KANNADA: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
342 case LANG_MALAYALAM: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
343 case LANG_ASSAMESE: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
344 case LANG_MARATHI: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
345 case LANG_SANSKRIT: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
346 case LANG_MONGOLIAN: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
347 case LANG_GALICIAN: posix = "gl"; break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
348 case LANG_KONKANI: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
349 case LANG_MANIPURI: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
350 case LANG_SINDHI: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
351 case LANG_SYRIAC: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
352 case LANG_KASHMIRI: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
353 case LANG_NEPALI: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
354 case LANG_DIVEHI: break; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
355 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
356 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
357 /* Deal with exceptions */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
358 if (posix == NULL) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
359 switch (lcid) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
360 case 2125: posix = "my_MM"; break; /* Myanmar (Burmese) */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
361 case 1076: posix = "xh"; break; /* Xhosa */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
362 case 9999: posix = "ku"; break; /* Kurdish (from NSIS) */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
363 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
364 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
365 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
366 return posix; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
367 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
368 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
369 /* Determine and set Gaim locale as follows (in order of priority): |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
370 - Check GAIMLANG env var |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
371 - Check NSIS Installer Language reg value |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
372 - Use default user locale |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
373 */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
374 static const char *wgaim_get_locale() { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
375 const char *locale = NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
376 LCID lcid; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
377 #ifndef PORTABLE |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
378 char data[10]; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
379 DWORD datalen = 10; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
380 #endif |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
381 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
382 /* Check if user set GAIMLANG env var */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
383 if ((locale = getenv("GAIMLANG"))) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
384 return locale; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
385 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
386 #ifndef PORTABLE |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
387 if (read_reg_string(HKEY_CURRENT_USER, "SOFTWARE\\gaim", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
388 "Installer Language", (LPBYTE) &data, &datalen)) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
389 if ((locale = wgaim_lcid_to_posix(atoi(data)))) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
390 return locale; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
391 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
392 #endif |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
393 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
394 lcid = GetUserDefaultLCID(); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
395 if ((locale = wgaim_lcid_to_posix(lcid))) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
396 return locale; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
397 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
398 return "en"; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
399 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
400 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
401 static void wgaim_set_locale() { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
402 const char *locale = NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
403 char envstr[25]; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
404 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
405 locale = wgaim_get_locale(); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
406 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
407 snprintf(envstr, 25, "LANG=%s", locale); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
408 printf("Setting locale: %s\n", envstr); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
409 putenv(envstr); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
410 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
411 |
14257
14933d9055a0
[gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
412 #define WM_FOCUS_REQUEST (WM_APP + 13) |
14933d9055a0
[gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
413 |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
414 static BOOL wgaim_set_running() { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
415 HANDLE h; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
416 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
417 if ((h = CreateMutex(NULL, FALSE, "gaim_is_running"))) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
418 if (GetLastError() == ERROR_ALREADY_EXISTS) { |
14257
14933d9055a0
[gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
419 HWND msg_win; |
14933d9055a0
[gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
420 |
14933d9055a0
[gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
421 if((msg_win = FindWindow(TEXT("WingaimMsgWinCls"), NULL))) |
14933d9055a0
[gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
422 if(SendMessage(msg_win, WM_FOCUS_REQUEST, (WPARAM) NULL, (LPARAM) NULL)) |
14933d9055a0
[gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
423 return FALSE; |
14933d9055a0
[gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
424 |
14933d9055a0
[gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
425 /* If we get here, the focus request wasn't successful */ |
14933d9055a0
[gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
426 |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
427 MessageBox(NULL, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
428 "An instance of Gaim is already running", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
429 NULL, MB_OK | MB_TOPMOST); |
14257
14933d9055a0
[gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
430 |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
431 return FALSE; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
432 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
433 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
434 return TRUE; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
435 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
436 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
437 static void wgaim_set_proxy() { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
438 DWORD regval = 1; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
439 DWORD reglen = sizeof(DWORD); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
440 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
441 /* If the proxy server environment variables are already set, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
442 * we shouldn't override them */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
443 if (getenv("HTTP_PROXY") || getenv("http_proxy") || getenv("HTTPPROXY")) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
444 return; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
445 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
446 if (read_reg_string(HKEY_CURRENT_USER, WIN32_PROXY_REGKEY, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
447 "ProxyEnable", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
448 (LPBYTE) ®val, ®len) && (regval & 1)) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
449 char proxy_server[2048]; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
450 char *c = NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
451 reglen = sizeof(proxy_server); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
452 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
453 if (!read_reg_string(HKEY_CURRENT_USER, WIN32_PROXY_REGKEY, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
454 "ProxyServer", (LPBYTE) &proxy_server, ®len)) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
455 return; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
456 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
457 if ((reglen > strlen("http=")) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
458 && (c = strstr(proxy_server, "http="))) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
459 char *d; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
460 c += strlen("http="); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
461 d = strchr(c, ';'); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
462 if (d) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
463 *d = '\0'; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
464 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
465 /* c now points the proxy server (and port) */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
466 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
467 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
468 if (c) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
469 const char envstr_prefix[] = "HTTP_PROXY=http://"; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
470 char envstr[sizeof(envstr_prefix) + strlen(c) + 1]; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
471 snprintf(envstr, sizeof(envstr), "%s%s", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
472 envstr_prefix, c); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
473 printf("Setting HTTP Proxy: %s\n", envstr); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
474 putenv(envstr); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
475 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
476 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
477 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
478 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
479 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
480 #ifdef __GNUC__ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
481 # ifndef _stdcall |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
482 # define _stdcall __attribute__((stdcall)) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
483 # endif |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
484 #endif |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
485 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
486 int _stdcall |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
487 WinMain (struct HINSTANCE__ *hInstance, struct HINSTANCE__ *hPrevInstance, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
488 char *lpszCmdLine, int nCmdShow) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
489 char errbuf[512]; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
490 char gaimdir[MAX_PATH]; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
491 HMODULE hmod; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
492 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
493 /* If debug or help or version flag used, create console for output */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
494 if (strstr(lpszCmdLine, "-d") || strstr(lpszCmdLine, "-h") || strstr(lpszCmdLine, "-v")) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
495 LPFNATTACHCONSOLE MyAttachConsole = NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
496 if ((hmod = GetModuleHandle("kernel32.dll"))) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
497 MyAttachConsole = |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
498 (LPFNATTACHCONSOLE) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
499 GetProcAddress(hmod, "AttachConsole"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
500 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
501 if ((MyAttachConsole && MyAttachConsole(ATTACH_PARENT_PROCESS)) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
502 || AllocConsole()) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
503 freopen("CONOUT$", "w", stdout); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
504 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
505 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
506 /* Load exception handler if we have it */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
507 if (GetModuleFileName(NULL, gaimdir, MAX_PATH) != 0) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
508 char *tmp = gaimdir; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
509 char *prev = NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
510 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
511 while ((tmp = strchr(tmp, '\\'))) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
512 prev = tmp; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
513 tmp++; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
514 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
515 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
516 if (prev) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
517 prev[0] = '\0'; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
518 strcat(gaimdir, "\\exchndl.dll"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
519 if (LoadLibrary(gaimdir)) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
520 printf("Loaded exchndl.dll\n"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
521 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
522 } else { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
523 snprintf(errbuf, 512, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
524 "Error getting module filename. Error: %u", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
525 (UINT) GetLastError()); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
526 MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
527 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
528 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
529 #ifndef PORTABLE |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
530 if (!getenv("GAIM_NO_DLL_CHECK")) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
531 #endif |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
532 dll_prep(); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
533 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
534 wgaim_set_locale(); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
535 /* If help or version flag used, do not check Mutex */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
536 if (!strstr(lpszCmdLine, "-h") && !strstr(lpszCmdLine, "-v")) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
537 if (!getenv("GAIM_MULTI_INST") && !wgaim_set_running()) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
538 return 0; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
539 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
540 wgaim_set_proxy(); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
541 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
542 /* Now we are ready for Gaim .. */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
543 if ((hmod = LoadLibrary("gtkgaim.dll"))) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
544 gaim_main = (LPFNGAIMMAIN) GetProcAddress(hmod, "gaim_main"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
545 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
546 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
547 if (!gaim_main) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
548 snprintf(errbuf, 512, "Error loading gaim.dll. Error: %u", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
549 (UINT) GetLastError()); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
550 MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
551 return 0; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
552 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
553 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
554 return gaim_main (hInstance, __argc, __argv); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
555 } |