Mercurial > pidgin.yaz
annotate src/win32/win32dep.c @ 14103:eec0c7fd8529
[gaim-migrate @ 16734]
gaim_proxy_connect()ion attemps can now be canceled. So there
is no longer a need to do that GAIM_CONNECTION_IS_VALID()
crap at the top of gaim_proxy_connect() callback functions.
All of the callers of gaim_proxy_connect() still need to be
updated, though.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 13 Aug 2006 08:38:02 +0000 |
parents | abb12528b1b7 |
children |
rev | line source |
---|---|
3630 | 1 /* |
5913
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
2 * gaim |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
3 * |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
4 * File: win32dep.c |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
5 * Date: June, 2002 |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
6 * Description: Windows dependant code for Gaim |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
7 * |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
8 * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> |
3630 | 9 * |
5913
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
10 * This program is free software; you can redistribute it and/or modify |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
13 * (at your option) any later version. |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
14 * |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
15 * This program is distributed in the hope that it will be useful, |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
18 * GNU General Public License for more details. |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
19 * |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
20 * You should have received a copy of the GNU General Public License |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
21 * along with this program; if not, write to the Free Software |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
23 * |
3630 | 24 */ |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
25 #define _WIN32_IE 0x500 |
3630 | 26 #include <windows.h> |
6425
26b739bc9f1a
[gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6423
diff
changeset
|
27 #include <io.h> |
3630 | 28 #include <stdlib.h> |
29 #include <stdio.h> | |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
30 #include <winuser.h> |
5913
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
31 |
3630 | 32 #include <glib.h> |
11323
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
33 #include <glib/gstdio.h> |
4097
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
34 |
3630 | 35 #include "gaim.h" |
5913
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
36 #include "debug.h" |
6929
906567be99b2
[gaim-migrate @ 7476]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
37 #include "notify.h" |
5913
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
38 |
3630 | 39 #include "resource.h" |
4535
de9f45c815df
[gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4411
diff
changeset
|
40 #include "idletrack.h" |
5008
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
41 #include "zlib.h" |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
42 #include "untar.h" |
3630 | 43 |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
44 #include <libintl.h> |
5913
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
45 |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
46 #include "win32dep.h" |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
47 |
3630 | 48 /* |
49 * DEFINES & MACROS | |
50 */ | |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
51 #define _(x) gettext(x) |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
52 |
3630 | 53 /* |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
54 * DATA STRUCTS |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
55 */ |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
56 |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
57 /* For shfolder.dll */ |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
58 typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHA)(HWND, int, HANDLE, DWORD, LPSTR); |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
59 typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHW)(HWND, int, HANDLE, DWORD, LPWSTR); |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
60 |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
61 /* |
3630 | 62 * LOCALS |
63 */ | |
11323
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
64 static char *app_data_dir, *install_dir, *lib_dir, *locale_dir; |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
65 |
3630 | 66 /* |
67 * GLOBALS | |
68 */ | |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
69 HINSTANCE gaimexe_hInstance = 0; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
70 HINSTANCE gaimdll_hInstance = 0; |
3630 | 71 |
72 /* | |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
73 * PROTOS |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
74 */ |
6848
060aa79a733e
[gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
75 |
4097
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
76 FARPROC wgaim_find_and_loadproc(char*, char*); |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
77 char* wgaim_data_dir(void); |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
78 |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
79 /* |
3630 | 80 * STATIC CODE |
81 */ | |
82 | |
7526
77727178a1df
[gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7523
diff
changeset
|
83 static void wgaim_debug_print(GaimDebugLevel level, const char *category, const char *format, va_list args) { |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
84 char *str = NULL; |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
85 if (args != NULL) { |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
86 str = g_strdup_vprintf(format, args); |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
87 } else { |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
88 str = g_strdup(format); |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
89 } |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
90 printf("%s%s%s", category ? category : "", category ? ": " : "", str); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
91 g_free(str); |
7526
77727178a1df
[gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7523
diff
changeset
|
92 } |
77727178a1df
[gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7523
diff
changeset
|
93 |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
94 static GaimDebugUiOps ops = { |
7526
77727178a1df
[gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7523
diff
changeset
|
95 wgaim_debug_print |
77727178a1df
[gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7523
diff
changeset
|
96 }; |
77727178a1df
[gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7523
diff
changeset
|
97 |
4097
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
98 /* |
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
99 * PUBLIC CODE |
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
100 */ |
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
101 |
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
102 HINSTANCE wgaim_hinstance(void) { |
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
103 return gaimexe_hInstance; |
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
104 } |
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
105 |
4406
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
106 /* Escape windows dir separators. This is needed when paths are saved, |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
107 and on being read back have their '\' chars used as an escape char. |
4555
75f75ef235e4
[gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4535
diff
changeset
|
108 Returns an allocated string which needs to be freed. |
4406
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
109 */ |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
110 char* wgaim_escape_dirsep(char* filename) { |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
111 int sepcount = 0; |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
112 char* ret = NULL; |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
113 int cnt = 0; |
4406
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
114 |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
115 ret = filename; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
116 while(*ret) { |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
117 if(*ret == '\\') |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
118 sepcount++; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
119 ret++; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
120 } |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
121 ret = g_malloc0(strlen(filename) + sepcount + 1); |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
122 while(*filename) { |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
123 ret[cnt] = *filename; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
124 if(*filename == '\\') |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
125 ret[++cnt] = '\\'; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
126 filename++; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
127 cnt++; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
128 } |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
129 ret[cnt] = '\0'; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
130 return ret; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
131 } |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
132 |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
133 /* Determine whether the specified dll contains the specified procedure. |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
134 If so, load it (if not already loaded). */ |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
135 FARPROC wgaim_find_and_loadproc(char* dllname, char* procedure) { |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
136 HMODULE hmod; |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
137 BOOL did_load = FALSE; |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
138 FARPROC proc = 0; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
139 |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
140 if(!(hmod = GetModuleHandle(dllname))) { |
13614
e186876efaf3
[gaim-migrate @ 16000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13321
diff
changeset
|
141 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "%s not already loaded; loading it...\n", dllname); |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
142 if(!(hmod = LoadLibrary(dllname))) { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
143 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Could not load: %s\n", dllname); |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
144 return NULL; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
145 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
146 else |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
147 did_load = TRUE; |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
148 } |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
149 |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
150 if((proc = GetProcAddress(hmod, procedure))) { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
151 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "This version of %s contains %s\n", |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
152 dllname, procedure); |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
153 return proc; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
154 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
155 else { |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
156 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Function %s not found in dll %s\n", |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
157 procedure, dllname); |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
158 if(did_load) { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
159 /* unload dll */ |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
160 FreeLibrary(hmod); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
161 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
162 return NULL; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
163 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
164 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
165 |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
166 /* Determine Gaim Paths during Runtime */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
167 |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
168 /* Get paths to special Windows folders. */ |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
169 char *wgaim_get_special_folder(int folder_type) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
170 static LPFNSHGETFOLDERPATHA MySHGetFolderPathA = NULL; |
13779
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
171 static LPFNSHGETFOLDERPATHW MySHGetFolderPathW = NULL; |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
172 char *retval = NULL; |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
173 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
174 if (!MySHGetFolderPathW) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
175 MySHGetFolderPathW = (LPFNSHGETFOLDERPATHW) |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
176 wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathW"); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
177 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
178 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
179 if (MySHGetFolderPathW) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
180 wchar_t utf_16_dir[MAX_PATH + 1]; |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
181 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
182 if (SUCCEEDED(MySHGetFolderPathW(NULL, folder_type, NULL, |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
183 SHGFP_TYPE_CURRENT, utf_16_dir))) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
184 retval = g_utf16_to_utf8(utf_16_dir, -1, NULL, NULL, NULL); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
185 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
186 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
187 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
188 if (!retval) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
189 if (!MySHGetFolderPathA) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
190 MySHGetFolderPathA = (LPFNSHGETFOLDERPATHA) |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
191 wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathA"); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
192 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
193 if (MySHGetFolderPathA) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
194 char locale_dir[MAX_PATH + 1]; |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
195 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
196 if (SUCCEEDED(MySHGetFolderPathA(NULL, folder_type, NULL, |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
197 SHGFP_TYPE_CURRENT, locale_dir))) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
198 retval = g_locale_to_utf8(locale_dir, -1, NULL, NULL, NULL); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
199 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
200 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
201 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
202 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
203 return retval; |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
204 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
205 |
3630 | 206 char* wgaim_install_dir(void) { |
11323
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
207 static gboolean initialized = FALSE; |
3630 | 208 |
11323
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
209 if (!initialized) { |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
210 char *tmp = NULL; |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
211 if (G_WIN32_HAVE_WIDECHAR_API()) { |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
212 wchar_t winstall_dir[MAXPATHLEN]; |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
213 if (GetModuleFileNameW(NULL, winstall_dir, |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
214 MAXPATHLEN) > 0) { |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
215 tmp = g_utf16_to_utf8(winstall_dir, -1, |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
216 NULL, NULL, NULL); |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
217 } |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
218 } else { |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
219 gchar cpinstall_dir[MAXPATHLEN]; |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
220 if (GetModuleFileNameA(NULL, cpinstall_dir, |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
221 MAXPATHLEN) > 0) { |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
222 tmp = g_locale_to_utf8(cpinstall_dir, |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
223 -1, NULL, NULL, NULL); |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
224 } |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
225 } |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
226 |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
227 if (tmp == NULL) { |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
228 tmp = g_win32_error_message(GetLastError()); |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
229 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
230 "GetModuleFileName error: %s\n", tmp); |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
231 g_free(tmp); |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
232 return NULL; |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
233 } else { |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
234 install_dir = g_path_get_dirname(tmp); |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
235 g_free(tmp); |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
236 initialized = TRUE; |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
237 } |
3630 | 238 } |
239 | |
11323
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
240 return install_dir; |
3630 | 241 } |
242 | |
243 char* wgaim_lib_dir(void) { | |
11323
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
244 static gboolean initialized = FALSE; |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
245 |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
246 if (!initialized) { |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
247 char *inst_dir = wgaim_install_dir(); |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
248 if (inst_dir != NULL) { |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
249 lib_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "plugins", inst_dir); |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
250 initialized = TRUE; |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
251 } else { |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
252 return NULL; |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
253 } |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
254 } |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
255 |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
256 return lib_dir; |
3630 | 257 } |
258 | |
259 char* wgaim_locale_dir(void) { | |
11323
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
260 static gboolean initialized = FALSE; |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
261 |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
262 if (!initialized) { |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
263 char *inst_dir = wgaim_install_dir(); |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
264 if (inst_dir != NULL) { |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
265 locale_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "locale", inst_dir); |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
266 initialized = TRUE; |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
267 } else { |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
268 return NULL; |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
269 } |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
270 } |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
271 |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
272 return locale_dir; |
3630 | 273 } |
274 | |
6848
060aa79a733e
[gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
275 char* wgaim_data_dir(void) { |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
276 return app_data_dir; |
6848
060aa79a733e
[gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
277 } |
060aa79a733e
[gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
278 |
3973
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
279 /* Miscellaneous */ |
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
280 |
6437
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
281 gboolean wgaim_read_reg_string(HKEY key, char* sub_key, char* val_name, LPBYTE data, LPDWORD data_len) { |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
282 HKEY hkey; |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
283 gboolean ret = FALSE; |
6437
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
284 |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
285 if(ERROR_SUCCESS == RegOpenKeyEx(key, sub_key, 0, KEY_QUERY_VALUE, |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
286 &hkey)) { |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
287 if(ERROR_SUCCESS == RegQueryValueEx(hkey, val_name, 0, NULL, |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
288 data, data_len)) |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
289 ret = TRUE; |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
290 RegCloseKey(key); |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
291 } |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
292 return ret; |
6437
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
293 } |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
294 |
5008
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
295 int wgaim_gz_decompress(const char* in, const char* out) { |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
296 gzFile fin; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
297 FILE *fout; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
298 char buf[1024]; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
299 int ret; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
300 |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
301 if((fin = gzopen(in, "rb"))) { |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
302 if(!(fout = g_fopen(out, "wb"))) { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
303 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "Error opening file: %s\n", out); |
5008
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
304 gzclose(fin); |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
305 return 0; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
306 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
307 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
308 else { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
309 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "gzopen failed to open: %s\n", in); |
5008
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
310 return 0; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
311 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
312 |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
313 while((ret = gzread(fin, buf, 1024))) { |
5008
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
314 if(fwrite(buf, 1, ret, fout) < ret) { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
315 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "Error writing %d bytes to file\n", ret); |
5008
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
316 gzclose(fin); |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
317 fclose(fout); |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
318 return 0; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
319 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
320 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
321 fclose(fout); |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
322 gzclose(fin); |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
323 |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
324 if(ret < 0) { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
325 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "gzread failed while reading: %s\n", in); |
5008
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
326 return 0; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
327 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
328 |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
329 return 1; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
330 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
331 |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
332 int wgaim_gz_untar(const char* filename, const char* destdir) { |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
333 char tmpfile[_MAX_PATH]; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
334 char template[]="wgaimXXXXXX"; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
335 |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
336 sprintf(tmpfile, "%s%s%s", g_get_tmp_dir(), G_DIR_SEPARATOR_S, _mktemp(template)); |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
337 if(wgaim_gz_decompress(filename, tmpfile)) { |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
338 int ret; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
339 if(untar(tmpfile, destdir, UNTAR_FORCE | UNTAR_QUIET)) |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
340 ret = 1; |
5008
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
341 else { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
342 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_untar", "Failure untaring %s\n", tmpfile); |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
343 ret = 0; |
5008
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
344 } |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
345 g_unlink(tmpfile); |
5008
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
346 return ret; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
347 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
348 else { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
349 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_untar", "Failed to gz decompress %s\n", filename); |
5008
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
350 return 0; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
351 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
352 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
353 |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
354 void wgaim_notify_uri(const char *uri) { |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
355 |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
356 /* We'll allow whatever URI schemes are supported by the |
13779
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
357 * default http browser. |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
358 */ |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
359 |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
360 if (G_WIN32_HAVE_WIDECHAR_API()) { |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
361 SHELLEXECUTEINFOW wsinfo; |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
362 wchar_t *w_uri; |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
363 |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
364 w_uri = g_utf8_to_utf16(uri, -1, NULL, NULL, NULL); |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
365 |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
366 memset(&wsinfo, 0, sizeof(wsinfo)); |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
367 wsinfo.cbSize = sizeof(wsinfo); |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
368 wsinfo.fMask = SEE_MASK_CLASSNAME; |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
369 wsinfo.lpVerb = L"open"; |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
370 wsinfo.lpFile = w_uri; |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
371 wsinfo.nShow = SW_SHOWNORMAL; |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
372 wsinfo.lpClass = L"http"; |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
373 |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
374 gaim_debug(GAIM_DEBUG_INFO, "wgaim_notify_uri", "The wide uri is %s\n", uri); |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
375 if(!ShellExecuteExW(&wsinfo)) |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
376 gaim_debug_error("wgaim", "Error opening URI: %s error: %d\n", |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
377 uri, (int) wsinfo.hInstApp); |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
378 |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
379 g_free(w_uri); |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
380 } else { |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
381 SHELLEXECUTEINFOA sinfo; |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
382 gchar *locale_uri; |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
383 |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
384 locale_uri = g_locale_from_utf8(uri, -1, NULL, NULL, NULL); |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
385 |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
386 memset(&sinfo, 0, sizeof(sinfo)); |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
387 sinfo.cbSize = sizeof(sinfo); |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
388 sinfo.fMask = SEE_MASK_CLASSNAME; |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
389 sinfo.lpVerb = "open"; |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
390 sinfo.lpFile = locale_uri; |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
391 sinfo.nShow = SW_SHOWNORMAL; |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
392 sinfo.lpClass = "http"; |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
393 |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
394 if(!ShellExecuteExA(&sinfo)) |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
395 gaim_debug_error("wgaim", "Error opening URI: %s error: %d\n", |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
396 uri, (int) sinfo.hInstApp); |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
397 |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
398 g_free(locale_uri); |
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
399 } |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
400 } |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
401 |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
402 void wgaim_init(HINSTANCE hint) { |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
403 WORD wVersionRequested; |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
404 WSADATA wsaData; |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
405 const char *perlenv; |
11323
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
406 char *newenv; |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
407 |
11323
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
408 gaim_debug_set_ui_ops(&ops); |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
409 gaim_debug_info("wgaim", "wgaim_init start\n"); |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
410 |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
411 gaim_debug_info("wgaim", "Glib:%u.%u.%u\n", |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
412 glib_major_version, glib_minor_version, glib_micro_version); |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
413 |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
414 gaimexe_hInstance = hint; |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
415 |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
416 /* Winsock init */ |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
417 wVersionRequested = MAKEWORD(2, 2); |
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
418 WSAStartup(wVersionRequested, &wsaData); |
6848
060aa79a733e
[gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
419 |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
420 /* Confirm that the winsock DLL supports 2.2 */ |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
421 /* Note that if the DLL supports versions greater than |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
422 2.2 in addition to 2.2, it will still return 2.2 in |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
423 wVersion since that is the version we requested. */ |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
424 if(LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) { |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
425 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Could not find a usable WinSock DLL. Oh well.\n"); |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
426 WSACleanup(); |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
427 } |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
428 |
11323
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
429 /* Set Environmental Variables */ |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
430 /* Tell perl where to find Gaim's perl modules */ |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
431 perlenv = g_getenv("PERL5LIB"); |
13779
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
432 newenv = g_strdup_printf("PERL5LIB=%s%s%s" G_DIR_SEPARATOR_S "perlmod;", |
11323
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
433 perlenv ? perlenv : "", |
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
434 perlenv ? ";" : "", |
13779
42edc3d4941d
[gaim-migrate @ 16191]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13614
diff
changeset
|
435 wgaim_install_dir()); |
11323
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
436 if (putenv(newenv) < 0) |
6816
5aeba37b303c
[gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6437
diff
changeset
|
437 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "putenv failed\n"); |
11323
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
438 g_free(newenv); |
6848
060aa79a733e
[gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
439 |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
440 /* Set app data dir, used by gaim_home_dir */ |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
441 newenv = (char*) g_getenv("GAIMHOME"); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
442 if (newenv) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
443 app_data_dir = g_strdup(newenv); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
444 } else { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
445 app_data_dir = wgaim_get_special_folder(CSIDL_APPDATA); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
446 if (!app_data_dir) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
447 app_data_dir = g_strdup("C:"); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
448 } |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
449 } |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
450 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
451 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Gaim settings dir: %s\n", app_data_dir); |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
452 |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
453 /* IdleTracker Initialization */ |
4535
de9f45c815df
[gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4411
diff
changeset
|
454 if(!wgaim_set_idlehooks()) |
13321
c61c0a4ba6de
[gaim-migrate @ 15690]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12572
diff
changeset
|
455 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Failed to initialize idle tracker\n"); |
4861
6cb8b0686e46
[gaim-migrate @ 5188]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4728
diff
changeset
|
456 |
11323
caec745e390e
[gaim-migrate @ 13528]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11256
diff
changeset
|
457 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_init end\n"); |
3630 | 458 } |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
459 |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
460 /* Windows Cleanup */ |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
461 |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
462 void wgaim_cleanup(void) { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
463 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_cleanup\n"); |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
464 |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
465 /* winsock cleanup */ |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
466 WSACleanup(); |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
467 |
4535
de9f45c815df
[gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4411
diff
changeset
|
468 /* Idle tracker cleanup */ |
de9f45c815df
[gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4411
diff
changeset
|
469 wgaim_remove_idlehooks(); |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
470 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
471 g_free(app_data_dir); |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
472 } |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
473 |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
474 /* DLL initializer */ |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
475 BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
476 gaimdll_hInstance = hinstDLL; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
477 return TRUE; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
478 } |