Mercurial > pidgin
annotate src/win_gaim.c @ 11716:382696a92103
[gaim-migrate @ 14007]
I rearranged a few things, added Chip's last name, and added Casey
Harkins for rewriting the docklet stuff.
Feel free to clean up any of this.
Also, we need to get things ready to release a beta soon
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 22 Oct 2005 19:38:42 +0000 |
parents | dd5a40c6699f |
children | 8d5ebd7d4ec3 |
rev | line source |
---|---|
4490 | 1 /* |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
2 * win_gaim.c |
4490 | 3 * |
4 * Date: June, 2002 | |
5 * Description: Entry point for win32 gaim, and various win32 dependant | |
6 * routines. | |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
7 * |
8046 | 8 * Gaim is the legal property of its developers, whose names are too numerous |
9 * to list here. Please refer to the COPYRIGHT file distributed with this | |
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 | 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 | 32 #include <windows.h> |
7477
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
33 #include <fcntl.h> |
4490 | 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 | 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 | 44 /* |
45 * PROTOTYPES | |
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); |
71945305a87e
[gaim-migrate @ 13825]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11555
diff
changeset
|
128 |
71945305a87e
[gaim-migrate @ 13825]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11555
diff
changeset
|
129 /* set the GTK+ path to be \\path\to\GTK\bin */ |
71945305a87e
[gaim-migrate @ 13825]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11555
diff
changeset
|
130 strcat(path, "\\GTK\\bin"); |
71945305a87e
[gaim-migrate @ 13825]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11555
diff
changeset
|
131 } else |
71945305a87e
[gaim-migrate @ 13825]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11555
diff
changeset
|
132 return; |
71945305a87e
[gaim-migrate @ 13825]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11555
diff
changeset
|
133 #else /* PORTABLE */ |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
134 char gtkpath[MAX_PATH + 1]; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
135 DWORD plen; |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
136 |
10688
7818a5e9e3a2
[gaim-migrate @ 12237]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10521
diff
changeset
|
137 plen = sizeof(gtkpath); |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
138 hkey = HKEY_CURRENT_USER; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
139 if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "Path", |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
140 (LPBYTE) >kpath, &plen)) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
141 hkey = HKEY_LOCAL_MACHINE; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
142 if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "Path", |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
143 (LPBYTE) >kpath, &plen)) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
144 printf("GTK+ Path Registry Key not found. " |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
145 "Assuming GTK+ is in the PATH.\n"); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
146 return; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
147 } |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
148 } |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
149 |
10688
7818a5e9e3a2
[gaim-migrate @ 12237]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10521
diff
changeset
|
150 /* this value is replaced during a successful RegQueryValueEx() */ |
7818a5e9e3a2
[gaim-migrate @ 12237]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10521
diff
changeset
|
151 plen = sizeof(path); |
7818a5e9e3a2
[gaim-migrate @ 12237]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10521
diff
changeset
|
152 /* Determine GTK+ dll path .. */ |
7818a5e9e3a2
[gaim-migrate @ 12237]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10521
diff
changeset
|
153 if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "DllPath", |
7818a5e9e3a2
[gaim-migrate @ 12237]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10521
diff
changeset
|
154 (LPBYTE) &path, &plen)) { |
7818a5e9e3a2
[gaim-migrate @ 12237]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10521
diff
changeset
|
155 strcpy(path, gtkpath); |
7818a5e9e3a2
[gaim-migrate @ 12237]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10521
diff
changeset
|
156 strcat(path, "\\bin"); |
7818a5e9e3a2
[gaim-migrate @ 12237]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10521
diff
changeset
|
157 } |
11561
71945305a87e
[gaim-migrate @ 13825]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11555
diff
changeset
|
158 #endif |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
159 printf("GTK+ path found: %s\n", path); |
7522
07156f873116
[gaim-migrate @ 8135]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7477
diff
changeset
|
160 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
161 if ((hmod = GetModuleHandle("kernel32.dll"))) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
162 MySetDllDirectory = (LPFNSETDLLDIRECTORY) GetProcAddress( |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
163 hmod, "SetDllDirectoryA"); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
164 if (!MySetDllDirectory) |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
165 printf("SetDllDirectory not supported\n"); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
166 } else |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
167 printf("Error getting kernel32.dll module handle\n"); |
7522
07156f873116
[gaim-migrate @ 8135]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7477
diff
changeset
|
168 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
169 /* 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
|
170 if (MySetDllDirectory) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
171 printf("Using SetDllDirectory\n"); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
172 MySetDllDirectory(path); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
173 } |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
174 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
175 /* 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
|
176 * SafeDllSearch is set to 0 where needed. */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
177 else { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
178 OSVERSIONINFO osinfo; |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
179 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
180 printf("Setting current directory to GTK+ dll directory\n"); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
181 SetCurrentDirectory(path); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
182 /* For Windows 2000 (SP3+) / WinXP (No SP): |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
183 * If SafeDllSearchMode is set to 1, Windows system directories are |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
184 * 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
|
185 * to 0. |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
186 */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
187 osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
188 GetVersionEx(&osinfo); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
189 if ((osinfo.dwMajorVersion == 5 && |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
190 osinfo.dwMinorVersion == 0 && |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
191 strcmp(osinfo.szCSDVersion, "Service Pack 3") >= 0) || |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
192 (osinfo.dwMajorVersion == 5 && |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
193 osinfo.dwMinorVersion == 1 && |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
194 strcmp(osinfo.szCSDVersion, "") >= 0) |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
195 ) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
196 DWORD regval = 1; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
197 DWORD reglen = sizeof(DWORD); |
7522
07156f873116
[gaim-migrate @ 8135]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7477
diff
changeset
|
198 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
199 printf("Using Win2k (SP3+) / WinXP (No SP).. Checking SafeDllSearch\n"); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
200 read_reg_string(HKEY_LOCAL_MACHINE, |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
201 "System\\CurrentControlSet\\Control\\Session Manager", |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
202 "SafeDllSearchMode", |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
203 (LPBYTE) ®val, |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
204 ®len); |
7522
07156f873116
[gaim-migrate @ 8135]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7477
diff
changeset
|
205 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
206 if (regval != 0) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
207 printf("Trying to set SafeDllSearchMode to 0\n"); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
208 regval = 0; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
209 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
210 "System\\CurrentControlSet\\Control\\Session Manager", |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
211 0, KEY_SET_VALUE, &hkey |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
212 ) == ERROR_SUCCESS) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
213 if (RegSetValueEx(hkey, |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
214 "SafeDllSearchMode", 0, |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
215 REG_DWORD, (LPBYTE) ®val, |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
216 sizeof(DWORD) |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
217 ) != ERROR_SUCCESS) |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
218 printf("Error writing SafeDllSearchMode. Error: %u\n", |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
219 (UINT) GetLastError()); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
220 RegCloseKey(hkey); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
221 } else |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
222 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
|
223 (UINT) GetLastError()); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
224 } else |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
225 printf("SafeDllSearchMode is set to 0\n"); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
226 }/*end else*/ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
227 } |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
228 } |
4490 | 229 |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
230 static char* wgaim_lcid_to_posix(LCID lcid) { |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
231 switch(lcid) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
232 case 1026: return "bg"; /* bulgarian */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
233 case 2125: return "my_MM"; /* burmese (Myanmar) */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
234 case 1027: return "ca"; /* catalan */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
235 case 1050: return "hr"; /* croatian */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
236 case 1029: return "cs"; /* czech */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
237 case 1030: return "da"; /* danish */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
238 case 1043: return "nl"; /* dutch - netherlands */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
239 case 1033: return "en"; /* english - us */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
240 case 3081: return "en_AU"; /* english - australia */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
241 case 4105: return "en_CA"; /* english - canada */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
242 case 2057: return "en_GB"; /* english - great britain */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
243 case 1035: return "fi"; /* finnish */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
244 case 1036: return "fr"; /* french - france */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
245 case 1031: return "de"; /* german - germany */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
246 case 1032: return "el"; /* greek */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
247 case 1037: return "he"; /* hebrew */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
248 case 1081: return "hi"; /* hindi */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
249 case 1038: return "hu"; /* hungarian */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
250 case 1040: return "it"; /* italian - italy */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
251 case 1041: return "ja"; /* japanese */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
252 case 1042: return "ko"; /* korean */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
253 case 1063: return "lt"; /* lithuanian */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
254 case 1071: return "mk"; /* macedonian */ |
11571
dd5a40c6699f
[gaim-migrate @ 13839]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11570
diff
changeset
|
255 case 1044: return "nb"; /* norwegian (Bokmal)*/ |
dd5a40c6699f
[gaim-migrate @ 13839]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11570
diff
changeset
|
256 case 2068: return "nn"; /* norwegian (Nynorsk)*/ |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
257 case 1045: return "pl"; /* polish */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
258 case 2070: return "pt"; /* portuguese - portugal */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
259 case 1046: return "pt_BR"; /* portuguese - brazil */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
260 case 1048: return "ro"; /* romanian - romania */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
261 case 1049: return "ru"; /* russian - russia */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
262 case 2074: return "sr@Latn"; /* serbian - latin */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
263 case 3098: return "sr"; /* serbian - cyrillic */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
264 case 2052: return "zh_CN"; /* chinese - china (simple) */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
265 case 1051: return "sk"; /* slovak */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
266 case 1060: return "sl"; /* slovenian */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
267 case 1034: return "es"; /* spanish */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
268 case 1052: return "sq"; /* albanian */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
269 case 1053: return "sv"; /* swedish */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
270 case 1054: return "th"; /* thai */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
271 case 1028: return "zh_TW"; /* chinese - taiwan (traditional) */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
272 case 1055: return "tr"; /* turkish */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
273 case 1058: return "uk"; /* ukrainian */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
274 case 1066: return "vi"; /* vietnamese */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
275 default: return NULL; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
276 } |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
277 } |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
278 |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
279 /* 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
|
280 - Check GAIMLANG env var |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
281 - Check NSIS Installer Language reg value |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
282 - Use default user locale |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
283 */ |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
284 static const char *wgaim_get_locale() { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
285 const char *locale = NULL; |
11561
71945305a87e
[gaim-migrate @ 13825]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11555
diff
changeset
|
286 LCID lcid; |
71945305a87e
[gaim-migrate @ 13825]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11555
diff
changeset
|
287 #ifndef PORTABLE |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
288 char data[10]; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
289 DWORD datalen = 10; |
11561
71945305a87e
[gaim-migrate @ 13825]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11555
diff
changeset
|
290 #endif |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
291 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
292 /* Check if user set GAIMLANG env var */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
293 if ((locale = getenv("GAIMLANG"))) |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
294 return locale; |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
295 |
11561
71945305a87e
[gaim-migrate @ 13825]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11555
diff
changeset
|
296 #ifndef PORTABLE |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
297 if (read_reg_string(HKEY_CURRENT_USER, "SOFTWARE\\gaim", |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
298 "Installer Language", (LPBYTE) &data, &datalen)) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
299 if ((locale = wgaim_lcid_to_posix(atoi(data)))) |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
300 return locale; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
301 } |
11561
71945305a87e
[gaim-migrate @ 13825]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11555
diff
changeset
|
302 #endif |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
303 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
304 lcid = GetUserDefaultLCID(); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
305 if ((locale = wgaim_lcid_to_posix(lcid))) |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
306 return locale; |
10330 | 307 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
308 return "en"; |
10330 | 309 } |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
310 |
10330 | 311 static void wgaim_set_locale() { |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
312 const char *locale = NULL; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
313 char envstr[25]; |
10330 | 314 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
315 locale = wgaim_get_locale(); |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
316 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
317 snprintf(envstr, 25, "LANG=%s", locale); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
318 printf("Setting locale: %s\n", envstr); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
319 putenv(envstr); |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
320 } |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
321 |
10212
08251403c871
[gaim-migrate @ 11336]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10210
diff
changeset
|
322 static BOOL wgaim_set_running() { |
08251403c871
[gaim-migrate @ 11336]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10210
diff
changeset
|
323 HANDLE h; |
08251403c871
[gaim-migrate @ 11336]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10210
diff
changeset
|
324 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
325 if ((h = CreateMutex(NULL, FALSE, "gaim_is_running"))) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
326 if (GetLastError() == ERROR_ALREADY_EXISTS) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
327 MessageBox(NULL, |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
328 "An instance of Gaim is already running", |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
329 NULL, MB_OK | MB_TOPMOST); |
10212
08251403c871
[gaim-migrate @ 11336]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10210
diff
changeset
|
330 return FALSE; |
08251403c871
[gaim-migrate @ 11336]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10210
diff
changeset
|
331 } |
08251403c871
[gaim-migrate @ 11336]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10210
diff
changeset
|
332 } |
08251403c871
[gaim-migrate @ 11336]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10210
diff
changeset
|
333 return TRUE; |
08251403c871
[gaim-migrate @ 11336]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10210
diff
changeset
|
334 } |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
335 |
11193
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
336 static void wgaim_set_proxy() { |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
337 DWORD regval = 1; |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
338 DWORD reglen = sizeof(DWORD); |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
339 |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
340 /* If the proxy server environment variables are already set, |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
341 * we shouldn't override them */ |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
342 if (getenv("HTTP_PROXY") || getenv("http_proxy") || getenv("HTTPPROXY")) |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
343 return; |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
344 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
345 if (read_reg_string(HKEY_CURRENT_USER, WIN32_PROXY_REGKEY, |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
346 "ProxyEnable", |
11193
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
347 (LPBYTE) ®val, ®len) && (regval & 1)) { |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
348 char proxy_server[2048]; |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
349 char *c = NULL; |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
350 reglen = sizeof(proxy_server); |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
351 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
352 if (!read_reg_string(HKEY_CURRENT_USER, WIN32_PROXY_REGKEY, |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
353 "ProxyServer", (LPBYTE) &proxy_server, ®len)) |
11193
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
354 return; |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
355 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
356 if ((reglen > strlen("http=")) |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
357 && (c = strstr(proxy_server, "http="))) { |
11193
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
358 char *d; |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
359 c += strlen("http="); |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
360 d = strchr(c, ';'); |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
361 if (d) { |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
362 *d = '\0'; |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
363 } |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
364 /* c now points the proxy server (and port) */ |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
365 } |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
366 |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
367 if (c) { |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
368 const char envstr_prefix[] = "HTTP_PROXY=http://"; |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
369 char envstr[sizeof(envstr_prefix) + strlen(c) + 1]; |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
370 snprintf(envstr, sizeof(envstr), "%s%s", |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
371 envstr_prefix, c); |
11193
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
372 printf("Setting HTTP Proxy: %s\n", envstr); |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
373 putenv(envstr); |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
374 } |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
375 } |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
376 |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
377 } |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
378 |
4490 | 379 #ifdef __GNUC__ |
380 # ifndef _stdcall | |
381 # define _stdcall __attribute__((stdcall)) | |
382 # endif | |
383 #endif | |
384 | |
385 int _stdcall | |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
386 WinMain (struct HINSTANCE__ *hInstance, struct HINSTANCE__ *hPrevInstance, |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
387 char *lpszCmdLine, int nCmdShow) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
388 char errbuf[512]; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
389 char gaimdir[MAX_PATH]; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
390 HMODULE hmod; |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
391 |
11469
d83e1fe99d69
[gaim-migrate @ 13709]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11441
diff
changeset
|
392 /* 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
|
393 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
|
394 LPFNATTACHCONSOLE MyAttachConsole = NULL; |
52d6b10025ca
[gaim-migrate @ 13014]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10898
diff
changeset
|
395 if ((hmod = GetModuleHandle("kernel32.dll"))) { |
52d6b10025ca
[gaim-migrate @ 13014]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10898
diff
changeset
|
396 MyAttachConsole = |
52d6b10025ca
[gaim-migrate @ 13014]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10898
diff
changeset
|
397 (LPFNATTACHCONSOLE) |
52d6b10025ca
[gaim-migrate @ 13014]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10898
diff
changeset
|
398 GetProcAddress(hmod, "AttachConsole"); |
52d6b10025ca
[gaim-migrate @ 13014]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10898
diff
changeset
|
399 } |
52d6b10025ca
[gaim-migrate @ 13014]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10898
diff
changeset
|
400 if ((MyAttachConsole && MyAttachConsole(ATTACH_PARENT_PROCESS)) |
52d6b10025ca
[gaim-migrate @ 13014]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10898
diff
changeset
|
401 || AllocConsole()) |
52d6b10025ca
[gaim-migrate @ 13014]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10898
diff
changeset
|
402 freopen("CONOUT$", "w", stdout); |
52d6b10025ca
[gaim-migrate @ 13014]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10898
diff
changeset
|
403 } |
7802
f1d2907db5be
[gaim-migrate @ 8448]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7522
diff
changeset
|
404 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
405 /* Load exception handler if we have it */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
406 if (GetModuleFileName(NULL, gaimdir, MAX_PATH) != 0) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
407 char *tmp = gaimdir; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
408 char *prev = NULL; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
409 |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
410 while ((tmp = strchr(tmp, '\\'))) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
411 prev = tmp; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
412 tmp++; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
413 } |
7477
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
414 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
415 if (prev) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
416 prev[0] = '\0'; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
417 strcat(gaimdir, "\\exchndl.dll"); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
418 if (LoadLibrary(gaimdir)) |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
419 printf("Loaded exchndl.dll\n"); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
420 } |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
421 } else { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
422 snprintf(errbuf, 512, |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
423 "Error getting module filename. Error: %u", |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
424 (UINT) GetLastError()); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
425 MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
426 } |
7477
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
427 |
11561
71945305a87e
[gaim-migrate @ 13825]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11555
diff
changeset
|
428 #ifndef PORTABLE |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
429 if (!getenv("GAIM_NO_DLL_CHECK")) |
11561
71945305a87e
[gaim-migrate @ 13825]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11555
diff
changeset
|
430 #endif |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
431 dll_prep(); |
6816
5aeba37b303c
[gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4490
diff
changeset
|
432 |
11193
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
433 wgaim_set_locale(); |
11469
d83e1fe99d69
[gaim-migrate @ 13709]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11441
diff
changeset
|
434 /* 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
|
435 if (!strstr(lpszCmdLine, "-h") && !strstr(lpszCmdLine, "-v")) |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
436 if (!getenv("GAIM_MULTI_INST") && !wgaim_set_running()) |
11469
d83e1fe99d69
[gaim-migrate @ 13709]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11441
diff
changeset
|
437 return 0; |
11193
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
438 |
e865bdbbf91d
[gaim-migrate @ 13316]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11060
diff
changeset
|
439 wgaim_set_proxy(); |
7477
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
440 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
441 /* Now we are ready for Gaim .. */ |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
442 if ((hmod = LoadLibrary("gaim.dll"))) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
443 gaim_main = (LPFNGAIMMAIN) GetProcAddress(hmod, "gaim_main"); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
444 } |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
445 |
11555
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
446 if (!gaim_main) { |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
447 snprintf(errbuf, 512, "Error loading gaim.dll. Error: %u", |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
448 (UINT) GetLastError()); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
449 MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST); |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
450 return 0; |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
451 } |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
452 |
4da9e0d4e8d2
[gaim-migrate @ 13815]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11469
diff
changeset
|
453 return gaim_main (hInstance, __argc, __argv); |
4490 | 454 } |