Mercurial > pidgin
annotate libgaim/win32/win32dep.c @ 14965:650dee386bf6
[gaim-migrate @ 17744]
Stuff we ship should not include gaim.h--we should include individual
header files. Eventually 3rd party plugins should just need to
include only gaim.h, but not yet
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 13 Nov 2006 06:47:19 +0000 |
parents | 95246f6b6414 |
children | 721465a37d4e |
rev | line source |
---|---|
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
1 /* |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
2 * gaim |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
3 * |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
4 * File: win32dep.c |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
5 * Date: June, 2002 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
6 * Description: Windows dependant code for Gaim |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
7 * |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
8 * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
9 * |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
10 * This program is free software; you can redistribute it and/or modify |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
13 * (at your option) any later version. |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
14 * |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
15 * This program is distributed in the hope that it will be useful, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
18 * GNU General Public License for more details. |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
19 * |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
20 * You should have received a copy of the GNU General Public License |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
21 * along with this program; if not, write to the Free Software |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
23 * |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
24 */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
25 #define _WIN32_IE 0x500 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
26 #include <windows.h> |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
27 #include <io.h> |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
28 #include <stdlib.h> |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
29 #include <stdio.h> |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
30 #include <winuser.h> |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
31 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
32 #include <glib.h> |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
33 #include <glib/gstdio.h> |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
34 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
35 #include "debug.h" |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
36 #include "notify.h" |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
37 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
38 #include <libintl.h> |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
39 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
40 #include "win32dep.h" |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
41 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
42 /* |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
43 * DEFINES & MACROS |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
44 */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
45 #define _(x) gettext(x) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
46 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
47 /* For shfolder.dll */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
48 typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHA)(HWND, int, HANDLE, DWORD, LPSTR); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
49 typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHW)(HWND, int, HANDLE, DWORD, LPWSTR); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
50 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
51 /* |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
52 * LOCALS |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
53 */ |
14269
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
54 static char *app_data_dir = NULL, *install_dir = NULL, |
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
55 *lib_dir = NULL, *locale_dir = NULL; |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
56 |
14269
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
57 static HINSTANCE libgaimdll_hInstance = 0; |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
58 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
59 /* |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
60 * PUBLIC CODE |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
61 */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
62 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
63 /* Escape windows dir separators. This is needed when paths are saved, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
64 and on being read back have their '\' chars used as an escape char. |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
65 Returns an allocated string which needs to be freed. |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
66 */ |
14272
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
67 char *wgaim_escape_dirsep(const char *filename) { |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
68 int sepcount = 0; |
14272
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
69 const char *tmp = filename; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
70 char *ret; |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
71 int cnt = 0; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
72 |
14272
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
73 g_return_val_if_fail(filename != NULL, NULL); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
74 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
75 while(*tmp) { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
76 if(*tmp == '\\') |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
77 sepcount++; |
14272
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
78 tmp++; |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
79 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
80 ret = g_malloc0(strlen(filename) + sepcount + 1); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
81 while(*filename) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
82 ret[cnt] = *filename; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
83 if(*filename == '\\') |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
84 ret[++cnt] = '\\'; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
85 filename++; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
86 cnt++; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
87 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
88 ret[cnt] = '\0'; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
89 return ret; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
90 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
91 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
92 /* Determine whether the specified dll contains the specified procedure. |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
93 If so, load it (if not already loaded). */ |
14272
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
94 FARPROC wgaim_find_and_loadproc(const char *dllname, const char *procedure) { |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
95 HMODULE hmod; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
96 BOOL did_load = FALSE; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
97 FARPROC proc = 0; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
98 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
99 if(!(hmod = GetModuleHandle(dllname))) { |
14748
95246f6b6414
[gaim-migrate @ 17505]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14722
diff
changeset
|
100 gaim_debug_warning("wgaim", "%s not already loaded; loading it...\n", dllname); |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
101 if(!(hmod = LoadLibrary(dllname))) { |
14748
95246f6b6414
[gaim-migrate @ 17505]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14722
diff
changeset
|
102 gaim_debug_error("wgaim", "Could not load: %s\n", dllname); |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
103 return NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
104 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
105 else |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
106 did_load = TRUE; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
107 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
108 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
109 if((proc = GetProcAddress(hmod, procedure))) { |
14748
95246f6b6414
[gaim-migrate @ 17505]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14722
diff
changeset
|
110 gaim_debug_info("wgaim", "This version of %s contains %s\n", |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
111 dllname, procedure); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
112 return proc; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
113 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
114 else { |
14748
95246f6b6414
[gaim-migrate @ 17505]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14722
diff
changeset
|
115 gaim_debug_warning("wgaim", "Function %s not found in dll %s\n", |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
116 procedure, dllname); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
117 if(did_load) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
118 /* unload dll */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
119 FreeLibrary(hmod); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
120 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
121 return NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
122 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
123 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
124 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
125 /* Determine Gaim Paths during Runtime */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
126 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
127 /* Get paths to special Windows folders. */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
128 char *wgaim_get_special_folder(int folder_type) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
129 static LPFNSHGETFOLDERPATHA MySHGetFolderPathA = NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
130 static LPFNSHGETFOLDERPATHW MySHGetFolderPathW = NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
131 char *retval = NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
132 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
133 if (!MySHGetFolderPathW) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
134 MySHGetFolderPathW = (LPFNSHGETFOLDERPATHW) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
135 wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathW"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
136 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
137 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
138 if (MySHGetFolderPathW) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
139 wchar_t utf_16_dir[MAX_PATH + 1]; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
140 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
141 if (SUCCEEDED(MySHGetFolderPathW(NULL, folder_type, NULL, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
142 SHGFP_TYPE_CURRENT, utf_16_dir))) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
143 retval = g_utf16_to_utf8(utf_16_dir, -1, NULL, NULL, NULL); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
144 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
145 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
146 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
147 if (!retval) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
148 if (!MySHGetFolderPathA) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
149 MySHGetFolderPathA = (LPFNSHGETFOLDERPATHA) |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
150 wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathA"); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
151 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
152 if (MySHGetFolderPathA) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
153 char locale_dir[MAX_PATH + 1]; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
154 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
155 if (SUCCEEDED(MySHGetFolderPathA(NULL, folder_type, NULL, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
156 SHGFP_TYPE_CURRENT, locale_dir))) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
157 retval = g_locale_to_utf8(locale_dir, -1, NULL, NULL, NULL); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
158 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
159 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
160 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
161 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
162 return retval; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
163 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
164 |
14272
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
165 const char *wgaim_install_dir(void) { |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
166 static gboolean initialized = FALSE; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
167 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
168 if (!initialized) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
169 char *tmp = NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
170 if (G_WIN32_HAVE_WIDECHAR_API()) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
171 wchar_t winstall_dir[MAXPATHLEN]; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
172 if (GetModuleFileNameW(NULL, winstall_dir, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
173 MAXPATHLEN) > 0) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
174 tmp = g_utf16_to_utf8(winstall_dir, -1, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
175 NULL, NULL, NULL); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
176 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
177 } else { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
178 gchar cpinstall_dir[MAXPATHLEN]; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
179 if (GetModuleFileNameA(NULL, cpinstall_dir, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
180 MAXPATHLEN) > 0) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
181 tmp = g_locale_to_utf8(cpinstall_dir, |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
182 -1, NULL, NULL, NULL); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
183 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
184 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
185 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
186 if (tmp == NULL) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
187 tmp = g_win32_error_message(GetLastError()); |
14748
95246f6b6414
[gaim-migrate @ 17505]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14722
diff
changeset
|
188 gaim_debug_error("wgaim", |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
189 "GetModuleFileName error: %s\n", tmp); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
190 g_free(tmp); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
191 return NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
192 } else { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
193 install_dir = g_path_get_dirname(tmp); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
194 g_free(tmp); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
195 initialized = TRUE; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
196 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
197 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
198 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
199 return install_dir; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
200 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
201 |
14272
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
202 const char *wgaim_lib_dir(void) { |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
203 static gboolean initialized = FALSE; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
204 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
205 if (!initialized) { |
14272
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
206 const char *inst_dir = wgaim_install_dir(); |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
207 if (inst_dir != NULL) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
208 lib_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "plugins", inst_dir); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
209 initialized = TRUE; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
210 } else { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
211 return NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
212 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
213 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
214 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
215 return lib_dir; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
216 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
217 |
14272
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
218 const char *wgaim_locale_dir(void) { |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
219 static gboolean initialized = FALSE; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
220 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
221 if (!initialized) { |
14272
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
222 const char *inst_dir = wgaim_install_dir(); |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
223 if (inst_dir != NULL) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
224 locale_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "locale", inst_dir); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
225 initialized = TRUE; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
226 } else { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
227 return NULL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
228 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
229 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
230 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
231 return locale_dir; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
232 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
233 |
14272
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
234 const char *wgaim_data_dir(void) { |
14269
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
235 |
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
236 if (!app_data_dir) { |
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
237 /* Set app data dir, used by gaim_home_dir */ |
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
238 const char *newenv = g_getenv("GAIMHOME"); |
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
239 if (newenv) |
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
240 app_data_dir = g_strdup(newenv); |
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
241 else { |
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
242 app_data_dir = wgaim_get_special_folder(CSIDL_APPDATA); |
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
243 if (!app_data_dir) |
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
244 app_data_dir = g_strdup("C:"); |
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
245 } |
14748
95246f6b6414
[gaim-migrate @ 17505]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14722
diff
changeset
|
246 gaim_debug_info("wgaim", "Gaim settings dir: %s\n", |
14269
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
247 app_data_dir); |
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
248 } |
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
249 |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
250 return app_data_dir; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
251 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
252 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
253 /* Miscellaneous */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
254 |
14272
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
255 gboolean wgaim_write_reg_string(HKEY rootkey, const char *subkey, const char *valname, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
256 const char *value) { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
257 HKEY reg_key; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
258 gboolean success = FALSE; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
259 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
260 if(G_WIN32_HAVE_WIDECHAR_API()) { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
261 wchar_t *wc_subkey = g_utf8_to_utf16(subkey, -1, NULL, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
262 NULL, NULL); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
263 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
264 if(RegOpenKeyExW(rootkey, wc_subkey, 0, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
265 KEY_SET_VALUE, ®_key) == ERROR_SUCCESS) { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
266 wchar_t *wc_valname = NULL; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
267 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
268 if (valname) |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
269 wc_valname = g_utf8_to_utf16(valname, -1, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
270 NULL, NULL, NULL); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
271 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
272 if(value) { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
273 wchar_t *wc_value = g_utf8_to_utf16(value, -1, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
274 NULL, NULL, NULL); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
275 int len = (wcslen(wc_value) * sizeof(wchar_t)) + 1; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
276 if(RegSetValueExW(reg_key, wc_valname, 0, REG_SZ, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
277 (LPBYTE)wc_value, len |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
278 ) == ERROR_SUCCESS) |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
279 success = TRUE; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
280 g_free(wc_value); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
281 } else |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
282 if(RegDeleteValueW(reg_key, wc_valname) == ERROR_SUCCESS) |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
283 success = TRUE; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
284 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
285 g_free(wc_valname); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
286 } |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
287 g_free(wc_subkey); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
288 } else { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
289 char *cp_subkey = g_locale_from_utf8(subkey, -1, NULL, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
290 NULL, NULL); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
291 if(RegOpenKeyExA(rootkey, cp_subkey, 0, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
292 KEY_SET_VALUE, ®_key) == ERROR_SUCCESS) { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
293 char *cp_valname = NULL; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
294 if(valname) |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
295 cp_valname = g_locale_from_utf8(valname, -1, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
296 NULL, NULL, NULL); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
297 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
298 if (value) { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
299 char *cp_value = g_locale_from_utf8(value, -1, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
300 NULL, NULL, NULL); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
301 int len = strlen(cp_value) + 1; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
302 if(RegSetValueExA(reg_key, cp_valname, 0, REG_SZ, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
303 cp_value, len |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
304 ) == ERROR_SUCCESS) |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
305 success = TRUE; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
306 g_free(cp_value); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
307 } else |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
308 if(RegDeleteValueA(reg_key, cp_valname) == ERROR_SUCCESS) |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
309 success = TRUE; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
310 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
311 g_free(cp_valname); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
312 } |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
313 g_free(cp_subkey); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
314 } |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
315 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
316 if(reg_key != NULL) |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
317 RegCloseKey(reg_key); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
318 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
319 return success; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
320 } |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
321 |
14272
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
322 char *wgaim_read_reg_string(HKEY rootkey, const char *subkey, const char *valname) { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
323 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
324 DWORD type; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
325 DWORD nbytes; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
326 HKEY reg_key; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
327 char *result = NULL; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
328 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
329 if(G_WIN32_HAVE_WIDECHAR_API()) { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
330 wchar_t *wc_subkey = g_utf8_to_utf16(subkey, -1, NULL, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
331 NULL, NULL); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
332 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
333 if(RegOpenKeyExW(rootkey, wc_subkey, 0, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
334 KEY_QUERY_VALUE, ®_key) == ERROR_SUCCESS) { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
335 wchar_t *wc_valname = NULL; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
336 if (valname) |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
337 wc_valname = g_utf8_to_utf16(valname, -1, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
338 NULL, NULL, NULL); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
339 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
340 if(RegQueryValueExW(reg_key, wc_valname, 0, &type, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
341 NULL, &nbytes) == ERROR_SUCCESS |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
342 && type == REG_SZ) { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
343 wchar_t *wc_temp = |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
344 g_new(wchar_t, ((nbytes + 1) / sizeof(wchar_t)) + 1); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
345 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
346 if(RegQueryValueExW(reg_key, wc_valname, 0, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
347 &type, (LPBYTE) wc_temp, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
348 &nbytes) == ERROR_SUCCESS) { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
349 wc_temp[nbytes / sizeof(wchar_t)] = '\0'; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
350 result = g_utf16_to_utf8(wc_temp, -1, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
351 NULL, NULL, NULL); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
352 } |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
353 g_free(wc_temp); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
354 } |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
355 g_free(wc_valname); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
356 } |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
357 g_free(wc_subkey); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
358 } else { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
359 char *cp_subkey = g_locale_from_utf8(subkey, -1, NULL, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
360 NULL, NULL); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
361 if(RegOpenKeyExA(rootkey, cp_subkey, 0, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
362 KEY_QUERY_VALUE, ®_key) == ERROR_SUCCESS) { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
363 char *cp_valname = NULL; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
364 if(valname) |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
365 cp_valname = g_locale_from_utf8(valname, -1, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
366 NULL, NULL, NULL); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
367 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
368 if(RegQueryValueExA(reg_key, cp_valname, 0, &type, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
369 NULL, &nbytes) == ERROR_SUCCESS |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
370 && type == REG_SZ) { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
371 char *cp_temp = g_malloc(nbytes + 1); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
372 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
373 if(RegQueryValueExA(reg_key, cp_valname, 0, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
374 &type, cp_temp, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
375 &nbytes) == ERROR_SUCCESS) { |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
376 cp_temp[nbytes] = '\0'; |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
377 result = g_locale_to_utf8(cp_temp, -1, |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
378 NULL, NULL, NULL); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
379 } |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
380 g_free (cp_temp); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
381 } |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
382 g_free(cp_valname); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
383 } |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
384 g_free(cp_subkey); |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
385 } |
14272
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
386 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
387 if(reg_key != NULL) |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
388 RegCloseKey(reg_key); |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
389 |
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
390 return result; |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
391 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
392 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
393 void wgaim_init(void) { |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
394 WORD wVersionRequested; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
395 WSADATA wsaData; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
396 const char *perlenv; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
397 char *newenv; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
398 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
399 gaim_debug_info("wgaim", "wgaim_init start\n"); |
14748
95246f6b6414
[gaim-migrate @ 17505]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14722
diff
changeset
|
400 gaim_debug_info("wgaim", "libgaim version: " VERSION "\n"); |
95246f6b6414
[gaim-migrate @ 17505]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14722
diff
changeset
|
401 |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
402 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
403 gaim_debug_info("wgaim", "Glib:%u.%u.%u\n", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
404 glib_major_version, glib_minor_version, glib_micro_version); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
405 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
406 /* Winsock init */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
407 wVersionRequested = MAKEWORD(2, 2); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
408 WSAStartup(wVersionRequested, &wsaData); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
409 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
410 /* Confirm that the winsock DLL supports 2.2 */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
411 /* Note that if the DLL supports versions greater than |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
412 2.2 in addition to 2.2, it will still return 2.2 in |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
413 wVersion since that is the version we requested. */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
414 if(LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) { |
14748
95246f6b6414
[gaim-migrate @ 17505]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14722
diff
changeset
|
415 gaim_debug_error("wgaim", "Could not find a usable WinSock DLL. Oh well.\n"); |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
416 WSACleanup(); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
417 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
418 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
419 /* Set Environmental Variables */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
420 /* Tell perl where to find Gaim's perl modules */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
421 perlenv = g_getenv("PERL5LIB"); |
14272
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
422 newenv = g_strdup_printf("%s%s%s" G_DIR_SEPARATOR_S "perlmod;", |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
423 perlenv ? perlenv : "", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
424 perlenv ? ";" : "", |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
425 wgaim_install_dir()); |
14272
7635195195c0
[gaim-migrate @ 16957]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14269
diff
changeset
|
426 if (!g_setenv("PERL5LIB", newenv, TRUE)) |
14748
95246f6b6414
[gaim-migrate @ 17505]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14722
diff
changeset
|
427 gaim_debug_warning("wgaim", "putenv failed for PERL5LIB\n"); |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
428 g_free(newenv); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
429 |
14722
51685370de57
[gaim-migrate @ 17476]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14272
diff
changeset
|
430 if (!g_thread_supported()) |
51685370de57
[gaim-migrate @ 17476]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14272
diff
changeset
|
431 g_thread_init(NULL); |
51685370de57
[gaim-migrate @ 17476]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14272
diff
changeset
|
432 |
14748
95246f6b6414
[gaim-migrate @ 17505]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14722
diff
changeset
|
433 gaim_debug_info("wgaim", "wgaim_init end\n"); |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
434 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
435 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
436 /* Windows Cleanup */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
437 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
438 void wgaim_cleanup(void) { |
14748
95246f6b6414
[gaim-migrate @ 17505]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14722
diff
changeset
|
439 gaim_debug_info("wgaim", "wgaim_cleanup\n"); |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
440 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
441 /* winsock cleanup */ |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
442 WSACleanup(); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
443 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
444 g_free(app_data_dir); |
14269
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
445 app_data_dir = NULL; |
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
446 |
d1cb45dec12f
[gaim-migrate @ 16951]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14224
diff
changeset
|
447 libgaimdll_hInstance = NULL; |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
448 } |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
449 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
450 /* DLL initializer */ |
14748
95246f6b6414
[gaim-migrate @ 17505]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14722
diff
changeset
|
451 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
452 libgaimdll_hInstance = hinstDLL; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
453 return TRUE; |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
454 } |