Mercurial > pidgin
annotate src/win_gaim.c @ 7484:5b83ed21f070
[gaim-migrate @ 8097]
Good think smocky noticed this. Setting idle time works again.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 12 Nov 2003 05:03:17 +0000 |
parents | 29d69daa1ede |
children | 07156f873116 |
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 * |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
8 * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
9 * |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
10 * 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
|
11 * 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
|
12 * the Free Software Foundation; either version 2 of the License, or |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
13 * (at your option) any later version. |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
14 * |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
15 * 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
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
18 * GNU General Public License for more details. |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
19 * |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
20 * 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
|
21 * along with this program; if not, write to the Free Software |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
22 * 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
|
23 * |
4490 | 24 */ |
25 #include <windows.h> | |
7477
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
26 #include <fcntl.h> |
4490 | 27 #include <stdlib.h> |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
28 #include <string.h> |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
29 #include <stdio.h> |
4490 | 30 |
31 /* | |
32 * PROTOTYPES | |
33 */ | |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
34 static int (*gaim_main)( HINSTANCE, int, char** ) = NULL; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
35 static void (*MySetDllDirectory)(LPCTSTR lpPathName) = NULL; |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
36 |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
37 |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
38 static BOOL read_reg_string(HKEY key, char* sub_key, char* val_name, LPBYTE data, LPDWORD data_len) { |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
39 HKEY hkey; |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
40 BOOL ret = FALSE; |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
41 int retv; |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
42 |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
43 if(ERROR_SUCCESS == RegOpenKeyEx(key, |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
44 sub_key, |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
45 0, KEY_QUERY_VALUE, &hkey)) { |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
46 if(ERROR_SUCCESS == (retv=RegQueryValueEx(hkey, val_name, 0, NULL, data, data_len))) |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
47 ret = TRUE; |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
48 else |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
49 ret = FALSE; |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
50 RegCloseKey(key); |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
51 } |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
52 return ret; |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
53 } |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
54 |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
55 static void run_dll_prep() { |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
56 char gtkpath[MAX_PATH]; |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
57 char path[MAX_PATH]; |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
58 DWORD plen = MAX_PATH; |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
59 int gotreg=FALSE; |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
60 HKEY hkey; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
61 HMODULE hmod; |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
62 |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
63 if(!(gotreg = read_reg_string((hkey=HKEY_LOCAL_MACHINE), "SOFTWARE\\GTK\\2.0", "Path", (LPBYTE)>kpath, &plen))) |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
64 gotreg = read_reg_string((hkey=HKEY_CURRENT_USER), "SOFTWARE\\GTK\\2.0", "Path", (LPBYTE)>kpath, &plen); |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
65 |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
66 if(!gotreg) |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
67 return; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
68 |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
69 /* Determine GTK+ dll path .. */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
70 if(!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "DllPath", (LPBYTE)&path, &plen)) { |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
71 char version[10]; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
72 char inst[10]; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
73 DWORD len = 10; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
74 |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
75 strcpy(path, gtkpath); |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
76 if(read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "Version", (LPBYTE)&version, &len) && |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
77 read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "Installer", (LPBYTE)&inst, &len)) { |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
78 if(strcmp(version, "2.2.2") >= 0 && |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
79 strcmp(inst, "NSIS") == 0) { |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
80 strcat(path, "\\bin"); |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
81 } |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
82 else |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
83 strcat(path, "\\lib"); |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
84 } |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
85 else |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
86 strcat(path, "\\lib"); |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
87 } |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
88 |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
89 if((hmod=LoadLibrary("kernel32.dll"))) { |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
90 MySetDllDirectory = (void*)GetProcAddress(hmod, "SetDllDirectory"); |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
91 } |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
92 |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
93 /* For Windows XP SP1 / Server 2003 we use SetDllDirectory to avoid dll hell */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
94 if(MySetDllDirectory) |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
95 MySetDllDirectory(path); |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
96 /* For the rest, we set the current directory */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
97 else { |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
98 OSVERSIONINFO osinfo; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
99 |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
100 SetCurrentDirectory(path); |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
101 /* For Windows 2000 SP3 and higher: |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
102 * If SafeDllSearchMode is set to 1, Windows system directories are |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
103 * searched for dlls before the current directory. Therefore we set it |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
104 * to 0. |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
105 */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
106 osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
107 GetVersionEx(&osinfo); |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
108 if(osinfo.dwMajorVersion == 5 && |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
109 osinfo.dwMinorVersion == 0 && |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
110 strcmp(osinfo.szCSDVersion, "Service Pack 3") >= 0) { |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
111 if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
112 "System\\CurrentControlSet\\Control\\Session Manager", |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
113 0, KEY_SET_VALUE, &hkey)) { |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
114 DWORD regval = 0; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
115 RegSetValueEx(hkey, |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
116 "SafeDllSearchMode", |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
117 0, |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
118 REG_DWORD, |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
119 (LPBYTE) ®val, |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
120 sizeof(regval)); |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
121 RegCloseKey(hkey); |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
122 } |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
123 } |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
124 } |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
125 } |
4490 | 126 |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
127 static char* wgaim_lcid_to_posix(LCID lcid) { |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
128 switch(lcid) { |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
129 case 1026: return "bg"; /* bulgarian */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
130 case 1027: return "ca"; /* catalan */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
131 case 1050: return "hr"; /* croation */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
132 case 1029: return "cs"; /* czech */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
133 case 1030: return "da"; /* danaish */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
134 case 1043: return "nl"; /* dutch - netherlands */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
135 case 1033: return "en"; /* english - us */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
136 case 1035: return "fi"; /* finish */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
137 case 1036: return "fr"; /* french - france */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
138 case 1031: return "de"; /* german - germany */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
139 case 1032: return "el"; /* greek */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
140 case 1037: return "he"; /* hebrew */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
141 case 1038: return "hu"; /* hungarian */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
142 case 1040: return "it"; /* italian - italy */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
143 case 1041: return "ja"; /* japanese */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
144 case 1042: return "ko"; /* korean */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
145 case 1063: return "lt"; /* lithuanian */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
146 case 1071: return "mk"; /* macedonian */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
147 case 1045: return "pl"; /* polish */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
148 case 2070: return "pt"; /* portuguese - portugal */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
149 case 1046: return "pt_BR"; /* portuguese - brazil */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
150 case 1048: return "ro"; /* romanian - romania */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
151 case 1049: return "ru"; /* russian - russia */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
152 case 2074: return "sr@Latn"; /* serbian - latin */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
153 case 3098: return "sr"; /* serbian - cyrillic */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
154 case 2052: return "zh_CN"; /* chinese - china (simple) */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
155 case 1051: return "sk"; /* slovak */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
156 case 1060: return "sl"; /* slovenian */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
157 case 1034: return "es"; /* spanish */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
158 case 1053: return "sv"; /* swedish */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
159 case 1054: return "th"; /* thai */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
160 case 1028: return "zh_TW"; /* chinese - taiwan (traditional) */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
161 case 1055: return "tr"; /* turkish */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
162 case 1058: return "uk"; /* ukrainian */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
163 default: |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
164 return NULL; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
165 } |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
166 } |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
167 |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
168 /* Determine and set Gaim locale as follows (in order of priority): |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
169 - Check LANG env var |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
170 - Check NSIS Installer Language reg value |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
171 - Use default user locale |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
172 */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
173 static void wgaim_set_locale() { |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
174 HKEY hkey; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
175 char* locale=NULL; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
176 char envstr[25]; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
177 LCID lcid; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
178 |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
179 /* Check if user set LANG env var */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
180 if((locale = (char*)getenv("LANG"))) { |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
181 goto finish; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
182 } |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
183 |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
184 /* Check reg key set at install time */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
185 if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
186 "SOFTWARE\\gaim", |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
187 0, KEY_QUERY_VALUE, &hkey)) { |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
188 BYTE data[10]; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
189 DWORD ds = 10; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
190 if(ERROR_SUCCESS == RegQueryValueEx(hkey, "Installer Language", 0, NULL, (LPBYTE)&data, &ds)) { |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
191 if((locale = wgaim_lcid_to_posix(atoi(data)))) |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
192 goto finish; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
193 } |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
194 } |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
195 |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
196 lcid = GetUserDefaultLCID(); |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
197 if((locale = wgaim_lcid_to_posix(lcid))) |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
198 goto finish; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
199 |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
200 finish: |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
201 if(!locale) |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
202 locale = "en"; |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
203 |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
204 sprintf(envstr, "LANG=%s", locale); |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
205 putenv(envstr); |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
206 } |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
207 |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
208 |
4490 | 209 #ifdef __GNUC__ |
210 # ifndef _stdcall | |
211 # define _stdcall __attribute__((stdcall)) | |
212 # endif | |
213 #endif | |
214 | |
215 int _stdcall | |
216 WinMain (struct HINSTANCE__ *hInstance, | |
217 struct HINSTANCE__ *hPrevInstance, | |
218 char *lpszCmdLine, | |
219 int nCmdShow) | |
220 { | |
7477
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
221 char errbuf[512]; |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
222 char gaimdir[MAX_PATH]; |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
223 HMODULE hmod; |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
224 |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
225 /* If GAIM_NO_DLL_CHECK is set, don't run the dll check */ |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
226 if(!getenv("GAIM_NO_DLL_CHECK")) |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
227 run_dll_prep(); |
6816
5aeba37b303c
[gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4490
diff
changeset
|
228 |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
229 /* Load exception handler if we have it */ |
7477
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
230 if(GetModuleFileName(NULL, gaimdir, MAX_PATH) != 0) { |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
231 char *tmp = gaimdir; |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
232 char *prev = NULL; |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
233 |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
234 while((tmp=strchr(tmp, '\\'))) { |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
235 prev = tmp; |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
236 tmp+=1; |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
237 } |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
238 if(prev) { |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
239 prev[0] = '\0'; |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
240 strcat(gaimdir, "\\exchndl.dll"); |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
241 LoadLibrary(gaimdir); |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
242 } |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
243 } |
7477
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
244 else { |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
245 snprintf(errbuf, 512, "Error getting module filename. Error: %u", (UINT)GetLastError()); |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
246 MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST); |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
247 } |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
248 |
7350
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
249 /* Set Gaim locale */ |
e28728795a45
[gaim-migrate @ 7941]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
250 wgaim_set_locale(); |
6816
5aeba37b303c
[gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4490
diff
changeset
|
251 |
7477
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
252 /* Set global file mode to binary so that we don't do any dos file translations */ |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
253 _fmode = _O_BINARY; |
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
254 |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
255 /* Now we are ready for Gaim .. */ |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
256 if((hmod=LoadLibrary("gaim.dll"))) { |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
257 gaim_main = (void*)GetProcAddress(hmod, "gaim_main"); |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
258 } |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
259 |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
260 if(!gaim_main) { |
7477
29d69daa1ede
[gaim-migrate @ 8090]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7363
diff
changeset
|
261 snprintf(errbuf, 512, "Error loading gaim.dll. Error: %u", (UINT)GetLastError()); |
7356
be11a6f2fe00
[gaim-migrate @ 7949]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
262 MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST); |
6890
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
263 return 0; |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
264 } |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
265 else |
4eee806af511
[gaim-migrate @ 7436]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
266 return gaim_main (hInstance, __argc, __argv); |
4490 | 267 } |
268 |