annotate src/win_gaim.c @ 13646:e8e5931e7e8d

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