Mercurial > pidgin.yaz
annotate libpurple/win32/win32dep.c @ 32295:dc120ca9f523
propagate from branch 'im.pidgin.pidgin' (head bfb757dfe6b2549ab37a9b19f78f5f1f2f9df0cd)
to branch 'im.pidgin.pidgin.next.major' (head fc195a83f896d038c367b1e92cc1bebd7e8246ab)
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 21 Mar 2011 05:45:22 +0000 |
parents | 35d8acf675e9 |
children |
rev | line source |
---|---|
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
15823 | 2 * purple |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4 * File: win32dep.c |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 * Date: June, 2002 |
15823 | 6 * Description: Windows dependant code for Purple |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * along with this program; if not, write to the Free Software |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18448
diff
changeset
|
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 */ |
29905
10ea601e6502
Update _WIN32_IE definition slightly to make building with mingw-64 more pleasant
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29618
diff
changeset
|
25 #define _WIN32_IE 0x501 |
22709
1cd99421c696
Include winsock2.h before windows.h is included to avoid winsock.h being
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22529
diff
changeset
|
26 #include "internal.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include <winuser.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include "notify.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 * LOCALS |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 static char *app_data_dir = NULL, *install_dir = NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 *lib_dir = NULL, *locale_dir = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 |
30898
31c2dd632ffa
Make wpurple_install_dir() (DATADIR) relative to the libpurple dll instead of the executable file that launched the process
Daniel Atallah <daniel.atallah@gmail.com>
parents:
30897
diff
changeset
|
38 static HINSTANCE libpurpledll_hInstance = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 * PUBLIC CODE |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 /* Escape windows dir separators. This is needed when paths are saved, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 and on being read back have their '\' chars used as an escape char. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 Returns an allocated string which needs to be freed. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 */ |
15823 | 48 char *wpurple_escape_dirsep(const char *filename) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 int sepcount = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 const char *tmp = filename; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 char *ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 int cnt = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 g_return_val_if_fail(filename != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 while(*tmp) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 if(*tmp == '\\') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 sepcount++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 tmp++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 ret = g_malloc0(strlen(filename) + sepcount + 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 while(*filename) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 ret[cnt] = *filename; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 if(*filename == '\\') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 ret[++cnt] = '\\'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 filename++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 cnt++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 ret[cnt] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 /* Determine whether the specified dll contains the specified procedure. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 If so, load it (if not already loaded). */ |
15823 | 75 FARPROC wpurple_find_and_loadproc(const char *dllname, const char *procedure) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 HMODULE hmod; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
77 BOOL did_load = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 FARPROC proc = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
79 |
30897
7be961ff3fa2
Make wpurple_find_and_loadproc() work for non-ASCII full paths
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29905
diff
changeset
|
80 wchar_t *wc_dllname = g_utf8_to_utf16(dllname, -1, NULL, NULL, NULL); |
7be961ff3fa2
Make wpurple_find_and_loadproc() work for non-ASCII full paths
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29905
diff
changeset
|
81 |
7be961ff3fa2
Make wpurple_find_and_loadproc() work for non-ASCII full paths
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29905
diff
changeset
|
82 if(!(hmod = GetModuleHandleW(wc_dllname))) { |
15823 | 83 purple_debug_warning("wpurple", "%s not already loaded; loading it...\n", dllname); |
30897
7be961ff3fa2
Make wpurple_find_and_loadproc() work for non-ASCII full paths
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29905
diff
changeset
|
84 if(!(hmod = LoadLibraryW(wc_dllname))) { |
30899
35d8acf675e9
Display the reason LoadLibrary didn't succeed in the debug log
Daniel Atallah <daniel.atallah@gmail.com>
parents:
30898
diff
changeset
|
85 purple_debug_error("wpurple", "Could not load: %s (%s)\n", dllname, |
35d8acf675e9
Display the reason LoadLibrary didn't succeed in the debug log
Daniel Atallah <daniel.atallah@gmail.com>
parents:
30898
diff
changeset
|
86 g_win32_error_message(GetLastError())); |
30897
7be961ff3fa2
Make wpurple_find_and_loadproc() work for non-ASCII full paths
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29905
diff
changeset
|
87 g_free(wc_dllname); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
89 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 did_load = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 |
30897
7be961ff3fa2
Make wpurple_find_and_loadproc() work for non-ASCII full paths
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29905
diff
changeset
|
94 g_free(wc_dllname); |
7be961ff3fa2
Make wpurple_find_and_loadproc() work for non-ASCII full paths
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29905
diff
changeset
|
95 wc_dllname = NULL; |
7be961ff3fa2
Make wpurple_find_and_loadproc() work for non-ASCII full paths
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29905
diff
changeset
|
96 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 if((proc = GetProcAddress(hmod, procedure))) { |
15823 | 98 purple_debug_info("wpurple", "This version of %s contains %s\n", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 dllname, procedure); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 return proc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
101 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 else { |
15823 | 103 purple_debug_warning("wpurple", "Function %s not found in dll %s\n", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 procedure, dllname); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 if(did_load) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 /* unload dll */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 FreeLibrary(hmod); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
110 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 |
15823 | 113 /* Determine Purple Paths during Runtime */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 /* Get paths to special Windows folders. */ |
22529
d93577159f2a
printf format warning fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21030
diff
changeset
|
116 gchar *wpurple_get_special_folder(int folder_type) { |
d93577159f2a
printf format warning fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21030
diff
changeset
|
117 gchar *retval = NULL; |
29618
3be6a18e0bcb
No need to access SHGetFolderPath() indirectly any more with required versions of Windows.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29493
diff
changeset
|
118 wchar_t utf_16_dir[MAX_PATH + 1]; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 |
29618
3be6a18e0bcb
No need to access SHGetFolderPath() indirectly any more with required versions of Windows.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29493
diff
changeset
|
120 if (SUCCEEDED(SHGetFolderPathW(NULL, folder_type, NULL, |
3be6a18e0bcb
No need to access SHGetFolderPath() indirectly any more with required versions of Windows.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29493
diff
changeset
|
121 SHGFP_TYPE_CURRENT, utf_16_dir))) { |
3be6a18e0bcb
No need to access SHGetFolderPath() indirectly any more with required versions of Windows.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29493
diff
changeset
|
122 retval = g_utf16_to_utf8(utf_16_dir, -1, NULL, NULL, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 return retval; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 |
15823 | 128 const char *wpurple_install_dir(void) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 static gboolean initialized = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 if (!initialized) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 char *tmp = NULL; |
29493
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
133 wchar_t winstall_dir[MAXPATHLEN]; |
30898
31c2dd632ffa
Make wpurple_install_dir() (DATADIR) relative to the libpurple dll instead of the executable file that launched the process
Daniel Atallah <daniel.atallah@gmail.com>
parents:
30897
diff
changeset
|
134 if (GetModuleFileNameW(libpurpledll_hInstance, winstall_dir, |
29493
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
135 MAXPATHLEN) > 0) { |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
136 tmp = g_utf16_to_utf8(winstall_dir, -1, |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
137 NULL, NULL, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 if (tmp == NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 tmp = g_win32_error_message(GetLastError()); |
15823 | 142 purple_debug_error("wpurple", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
143 "GetModuleFileName error: %s\n", tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
144 g_free(tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 install_dir = g_path_get_dirname(tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
148 g_free(tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
149 initialized = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 return install_dir; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 |
15823 | 156 const char *wpurple_lib_dir(void) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 static gboolean initialized = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
158 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
159 if (!initialized) { |
15823 | 160 const char *inst_dir = wpurple_install_dir(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 if (inst_dir != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 lib_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "plugins", inst_dir); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
163 initialized = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 return lib_dir; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 |
15823 | 172 const char *wpurple_locale_dir(void) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 static gboolean initialized = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 if (!initialized) { |
15823 | 176 const char *inst_dir = wpurple_install_dir(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
177 if (inst_dir != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 locale_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "locale", inst_dir); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 initialized = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
184 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
185 return locale_dir; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 |
15823 | 188 const char *wpurple_data_dir(void) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
189 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 if (!app_data_dir) { |
15823 | 191 /* Set app data dir, used by purple_home_dir */ |
192 const char *newenv = g_getenv("PURPLEHOME"); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 if (newenv) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 app_data_dir = g_strdup(newenv); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 else { |
15823 | 196 app_data_dir = wpurple_get_special_folder(CSIDL_APPDATA); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 if (!app_data_dir) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 app_data_dir = g_strdup("C:"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 } |
15823 | 200 purple_debug_info("wpurple", "Purple settings dir: %s\n", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 app_data_dir); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
203 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
204 return app_data_dir; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
207 /* Miscellaneous */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
208 |
15823 | 209 gboolean wpurple_write_reg_string(HKEY rootkey, const char *subkey, const char *valname, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 const char *value) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 HKEY reg_key; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 gboolean success = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 |
29493
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
214 wchar_t *wc_subkey = g_utf8_to_utf16(subkey, -1, NULL, |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
215 NULL, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 |
29493
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
217 if(RegOpenKeyExW(rootkey, wc_subkey, 0, |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
218 KEY_SET_VALUE, ®_key) == ERROR_SUCCESS) { |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
219 wchar_t *wc_valname = NULL; |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
220 |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
221 if (valname) |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
222 wc_valname = g_utf8_to_utf16(valname, -1, |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
223 NULL, NULL, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
224 |
29493
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
225 if(value) { |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
226 wchar_t *wc_value = g_utf8_to_utf16(value, -1, |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
227 NULL, NULL, NULL); |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
228 int len = (wcslen(wc_value) * sizeof(wchar_t)) + 1; |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
229 if(RegSetValueExW(reg_key, wc_valname, 0, REG_SZ, |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
230 (LPBYTE)wc_value, len |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
231 ) == ERROR_SUCCESS) |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
232 success = TRUE; |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
233 g_free(wc_value); |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
234 } else |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
235 if(RegDeleteValueW(reg_key, wc_valname) == ERROR_SUCCESS) |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
236 success = TRUE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 |
29493
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
238 g_free(wc_valname); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 } |
29493
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
240 g_free(wc_subkey); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 if(reg_key != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
243 RegCloseKey(reg_key); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 return success; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
246 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 static HKEY _reg_open_key(HKEY rootkey, const char *subkey, REGSAM access) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
249 HKEY reg_key = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 LONG rv; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 |
29493
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
252 wchar_t *wc_subkey = g_utf8_to_utf16(subkey, -1, NULL, |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
253 NULL, NULL); |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
254 rv = RegOpenKeyExW(rootkey, wc_subkey, 0, access, ®_key); |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
255 |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
256 g_free(wc_subkey); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
258 if (rv != ERROR_SUCCESS) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
259 char *errmsg = g_win32_error_message(rv); |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
26605
diff
changeset
|
260 purple_debug_error("wpurple", "Could not open reg key '%s' subkey '%s'.\nMessage: (%ld) %s\n", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 ((rootkey == HKEY_LOCAL_MACHINE) ? "HKLM" : |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 (rootkey == HKEY_CURRENT_USER) ? "HKCU" : |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
263 (rootkey == HKEY_CLASSES_ROOT) ? "HKCR" : "???"), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 subkey, rv, errmsg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 g_free(errmsg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 return reg_key; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 static gboolean _reg_read(HKEY reg_key, const char *valname, LPDWORD type, LPBYTE data, LPDWORD data_len) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
272 LONG rv; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
273 |
29493
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
274 wchar_t *wc_valname = NULL; |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
275 if (valname) |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
276 wc_valname = g_utf8_to_utf16(valname, -1, NULL, NULL, NULL); |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
277 rv = RegQueryValueExW(reg_key, wc_valname, 0, type, data, data_len); |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
278 g_free(wc_valname); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
279 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 if (rv != ERROR_SUCCESS) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 char *errmsg = g_win32_error_message(rv); |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
26605
diff
changeset
|
282 purple_debug_error("wpurple", "Could not read from reg key value '%s'.\nMessage: (%ld) %s\n", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 valname, rv, errmsg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 g_free(errmsg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
287 return (rv == ERROR_SUCCESS); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
288 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
289 |
15823 | 290 gboolean wpurple_read_reg_dword(HKEY rootkey, const char *subkey, const char *valname, LPDWORD result) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
291 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
292 DWORD type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
293 DWORD nbytes; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
294 HKEY reg_key = _reg_open_key(rootkey, subkey, KEY_QUERY_VALUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 gboolean success = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
297 if(reg_key) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
298 if(_reg_read(reg_key, valname, &type, (LPBYTE)result, &nbytes)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
299 success = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
300 RegCloseKey(reg_key); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
301 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
302 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
303 return success; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
304 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 |
15823 | 306 char *wpurple_read_reg_string(HKEY rootkey, const char *subkey, const char *valname) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
307 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
308 DWORD type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
309 DWORD nbytes; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
310 HKEY reg_key = _reg_open_key(rootkey, subkey, KEY_QUERY_VALUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
311 char *result = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
312 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
313 if(reg_key) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
314 if(_reg_read(reg_key, valname, &type, NULL, &nbytes) && type == REG_SZ) { |
29493
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
315 LPBYTE data = (LPBYTE) g_new(wchar_t, ((nbytes + 1) / sizeof(wchar_t)) + 1); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
316 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
317 if(_reg_read(reg_key, valname, &type, data, &nbytes)) { |
29493
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
318 wchar_t *wc_temp = (wchar_t*) data; |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
319 wc_temp[nbytes / sizeof(wchar_t)] = '\0'; |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
320 result = g_utf16_to_utf8(wc_temp, -1, |
224f9674a57e
Remove some win9x specific code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
27489
diff
changeset
|
321 NULL, NULL, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
322 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
323 g_free(data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
324 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
325 RegCloseKey(reg_key); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
326 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
327 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
328 return result; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
329 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 |
15823 | 331 void wpurple_init(void) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
332 WORD wVersionRequested; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
333 WSADATA wsaData; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
334 |
23900
54eb782d4721
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22709
diff
changeset
|
335 if (!g_thread_supported()) |
54eb782d4721
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22709
diff
changeset
|
336 g_thread_init(NULL); |
54eb782d4721
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22709
diff
changeset
|
337 |
15823 | 338 purple_debug_info("wpurple", "wpurple_init start\n"); |
21030
3cc856ca2338
Add a --with-extraversion option to ./configure so packagers can fine tune
Stu Tomlinson <stu@nosnilmot.com>
parents:
20685
diff
changeset
|
339 purple_debug_info("wpurple", "libpurple version: " DISPLAY_VERSION "\n"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
340 |
15823 | 341 purple_debug_info("wpurple", "Glib:%u.%u.%u\n", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
342 glib_major_version, glib_minor_version, glib_micro_version); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
344 /* Winsock init */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
345 wVersionRequested = MAKEWORD(2, 2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 WSAStartup(wVersionRequested, &wsaData); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
348 /* Confirm that the winsock DLL supports 2.2 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
349 /* Note that if the DLL supports versions greater than |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 2.2 in addition to 2.2, it will still return 2.2 in |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
351 wVersion since that is the version we requested. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
352 if(LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) { |
15823 | 353 purple_debug_error("wpurple", "Could not find a usable WinSock DLL. Oh well.\n"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 WSACleanup(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
355 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
356 |
15823 | 357 purple_debug_info("wpurple", "wpurple_init end\n"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
358 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
359 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
360 /* Windows Cleanup */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 |
15823 | 362 void wpurple_cleanup(void) { |
363 purple_debug_info("wpurple", "wpurple_cleanup\n"); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
364 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
365 /* winsock cleanup */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
366 WSACleanup(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
367 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
368 g_free(app_data_dir); |
26605
6a3943412f2d
Clean up libpurple memory allocations on win32 libpurple uninit.
Nick Hebner <hebnern@gmail.com>
parents:
23900
diff
changeset
|
369 g_free(install_dir); |
6a3943412f2d
Clean up libpurple memory allocations on win32 libpurple uninit.
Nick Hebner <hebnern@gmail.com>
parents:
23900
diff
changeset
|
370 g_free(lib_dir); |
6a3943412f2d
Clean up libpurple memory allocations on win32 libpurple uninit.
Nick Hebner <hebnern@gmail.com>
parents:
23900
diff
changeset
|
371 g_free(locale_dir); |
6a3943412f2d
Clean up libpurple memory allocations on win32 libpurple uninit.
Nick Hebner <hebnern@gmail.com>
parents:
23900
diff
changeset
|
372 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
373 app_data_dir = NULL; |
26605
6a3943412f2d
Clean up libpurple memory allocations on win32 libpurple uninit.
Nick Hebner <hebnern@gmail.com>
parents:
23900
diff
changeset
|
374 install_dir = NULL; |
6a3943412f2d
Clean up libpurple memory allocations on win32 libpurple uninit.
Nick Hebner <hebnern@gmail.com>
parents:
23900
diff
changeset
|
375 lib_dir = NULL; |
6a3943412f2d
Clean up libpurple memory allocations on win32 libpurple uninit.
Nick Hebner <hebnern@gmail.com>
parents:
23900
diff
changeset
|
376 locale_dir = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
377 |
15823 | 378 libpurpledll_hInstance = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
379 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 |
20503
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
18448
diff
changeset
|
381 long |
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
18448
diff
changeset
|
382 wpurple_get_tz_offset() { |
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
18448
diff
changeset
|
383 TIME_ZONE_INFORMATION tzi; |
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
18448
diff
changeset
|
384 DWORD ret; |
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
18448
diff
changeset
|
385 long off = -1; |
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
18448
diff
changeset
|
386 |
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
18448
diff
changeset
|
387 if ((ret = GetTimeZoneInformation(&tzi)) != TIME_ZONE_ID_INVALID) |
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
18448
diff
changeset
|
388 { |
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
18448
diff
changeset
|
389 off = -(tzi.Bias * 60); |
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
18448
diff
changeset
|
390 if (ret == TIME_ZONE_ID_DAYLIGHT) |
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
18448
diff
changeset
|
391 off -= tzi.DaylightBias * 60; |
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
18448
diff
changeset
|
392 } |
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
18448
diff
changeset
|
393 |
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
18448
diff
changeset
|
394 return off; |
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
18448
diff
changeset
|
395 } |
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
18448
diff
changeset
|
396 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
397 /* DLL initializer */ |
15728
8e08e961813c
I forgot to add the new mingw makefiles.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15374
diff
changeset
|
398 /* suppress gcc "no previous prototype" warning */ |
8e08e961813c
I forgot to add the new mingw makefiles.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15374
diff
changeset
|
399 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
400 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { |
15823 | 401 libpurpledll_hInstance = hinstDLL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
403 } |