1 |
/* wptRegistry.cpp - W32 Registry access |
/* wptRegistry.cpp - Windows Registry access |
2 |
* Copyright (C) 2000-2005 Timo Schulz |
* Copyright (C) 2000-2006 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
6 |
* WinPT is free software; you can redistribute it and/or |
* WinPT is free software; you can redistribute it and/or |
7 |
* modify it under the terms of the GNU General Public License |
* modify it under the terms of the GNU General Public License |
8 |
* as published by the Free Software Foundation; either version 2 |
* as published by the Free Software Foundation; either version 2 |
9 |
* of the License, or (at your option) any later version. |
* of the License, or (at your option) any later version. |
10 |
* |
* |
11 |
* WinPT is distributed in the hope that it will be useful, |
* WinPT is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
* General Public License for more details. |
* General Public License for more details. |
15 |
* |
*/ |
16 |
* You should have received a copy of the GNU General Public License |
#ifdef HAVE_CONFIG_H |
17 |
* along with WinPT; if not, write to the Free Software Foundation, |
#include <config.h> |
18 |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
#endif |
19 |
*/ |
|
20 |
|
#include <windows.h> |
21 |
#include <windows.h> |
#include <stdio.h> |
22 |
#include <stdio.h> |
|
23 |
|
#include "wptErrors.h" |
24 |
#include "wptErrors.h" |
#include "wptW32API.h" |
25 |
#include "wptW32API.h" |
#include "wptGPG.h" |
26 |
#include "wptGPG.h" |
#include "wptRegistry.h" |
27 |
#include "wptRegistry.h" |
#include "wptKeyserver.h" |
28 |
#include "wptKeyserver.h" |
#include "wptTypes.h" |
29 |
#include "wptTypes.h" |
#include "wptNLS.h" |
30 |
#include "wptNLS.h" |
#include "wptVersion.h" |
31 |
#include "wptVersion.h" |
#include "wptHotkey.h" |
32 |
|
|
33 |
#define rc_ok(rc) ((rc) == ERROR_SUCCESS) |
#define rc_ok(rc) ((rc) == ERROR_SUCCESS) |
34 |
|
|
35 |
struct reg_hotkey_s reg_hotkeys[] = { |
/* WinPT registry path. */ |
36 |
{"ClipEncrypt", NULL, 0}, |
#define WINPT_REG "Software\\WinPT" |
37 |
{"ClipDecrypt", NULL, 0}, |
|
38 |
{"ClipSign", NULL, 0}, |
/* GPG registry path. */ |
39 |
{"ClipSignEnc", NULL, 0}, |
#define GPG_REG "Software\\GNU\\GnuPG" |
40 |
{"CwsEncrypt", NULL, 0}, |
|
41 |
{"CwsDecrypt", NULL, 0}, |
#define GPG_MO_REG "Control Panel\\MingW32\\NLS" |
42 |
{"CwsSign", NULL, 0}, |
|
43 |
{"CwsSignEnc", NULL, 0}, |
/* GPG file association context. */ |
44 |
{0} |
struct gpg_filetype_s { |
45 |
}; |
const char *descr; /* description. */ |
46 |
|
const char *ext; /* extension. */ |
47 |
winpt_reg_prefs_s reg_prefs; |
int nicon; /* number of the image icon. */ |
48 |
|
}; |
49 |
#define WINPT_REG "Software\\WinPT" |
typedef struct gpg_filetype_s *gpg_filetype_t; |
50 |
|
|
51 |
|
/* Global WinPT registry prefereneces. */ |
52 |
void |
struct winpt_prefs_s reg_prefs; |
53 |
free_reg_prefs (void) |
|
54 |
{ |
/* All valid configuration commands. */ |
55 |
free_if_alloc (reg_prefs.backup.path); |
const char *cfg [] = { |
56 |
free_if_alloc (reg_prefs.kserv_conf); |
NULL, |
57 |
memset (®_prefs, 0, sizeof reg_prefs); |
"CacheTime", |
58 |
} /* free_reg_prefs */ |
"WordWrap", |
59 |
|
"DefaultExt", |
60 |
|
"Viewer", |
61 |
/* |
"AlwaysTrust", |
62 |
* Register the given WinPT filetype. |
"AutoBackup", |
63 |
*/ |
"BackupMode", |
64 |
static int |
"DisableHotkeys", |
65 |
regist_single_filetype (gpg_filetype *gfile) |
"NoCompressMultiMedia", |
66 |
{ |
"Expert", |
67 |
char icon[256], prog[256]; |
"FMProgressBar", |
68 |
|
"BackupSecring" |
69 |
memset (&icon, 0, sizeof (icon)); |
}; |
70 |
GetModuleFileName (glob_hinst, prog, sizeof (prog)-1); |
|
71 |
_snprintf (icon, sizeof (icon) -1, "%s,%d", prog, gfile->nicon); |
/* Return != 0 if GPG4win is installed. */ |
72 |
return create_file_type (prog, gfile->ext, gfile->descr, icon); |
int |
73 |
} /* regist_single_filetype */ |
is_gpg4win_installed (void) |
74 |
|
{ |
75 |
|
char *p; |
76 |
/* |
|
77 |
* Install the GPG related into the W32 resgistry, if the entry already |
p = get_reg_entry_gpg4win (NULL); |
78 |
* exists< the function returns immediately. |
if (!p) |
79 |
*/ |
return 0; |
80 |
int |
if (dir_exist_check (p)) { |
81 |
regist_inst_gnupg( int create_mokey ) |
free_if_alloc (p); |
82 |
{ |
return 0; |
83 |
int rc; |
} |
84 |
HKEY reg; |
free_if_alloc (p); |
85 |
|
return -1; |
86 |
rc = RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", 0, KEY_READ, ® ); |
} |
87 |
if( rc_ok( rc ) ) { |
|
88 |
RegCloseKey( reg ); |
|
89 |
return 0; |
/* Return != 0 if GPGee is installed. */ |
90 |
} |
static int |
91 |
rc = RegCreateKey( HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", ® ); |
is_gpgee_installed (void) |
92 |
if( !rc_ok( rc ) ) |
{ |
93 |
return WPTERR_REGISTRY; |
HKEY hk; |
94 |
RegCloseKey( reg ); |
LONG ec; |
95 |
if( create_mokey ) { |
|
96 |
rc = RegOpenKeyEx( HKEY_CURRENT_USER, "Control Panel\\MingW32\\NLS", 0, KEY_READ, ® ); |
ec = RegOpenKeyEx (HKEY_CURRENT_USER, "Software\\GPGee", 0, KEY_READ, &hk); |
97 |
if( rc_ok( rc ) ) { |
if (ec == ERROR_SUCCESS) { |
98 |
RegCloseKey( reg ); |
RegCloseKey (hk); |
99 |
return 0; |
return -1; |
100 |
} |
} |
101 |
rc = RegCreateKey( HKEY_CURRENT_USER, "Control Panel\\MingW32\\NLS", ® ); |
|
102 |
if( !rc_ok( rc ) ) |
return 0; |
103 |
return WPTERR_REGISTRY; |
} |
104 |
RegCloseKey( reg ); |
|
105 |
} |
|
106 |
|
/* Free all members in the registry preference struct. */ |
107 |
return 0; |
void |
108 |
} /* regist_inst_gpg */ |
free_reg_prefs (void) |
109 |
|
{ |
110 |
|
free_if_alloc (reg_prefs.backup.path); |
111 |
/* |
free_if_alloc (reg_prefs.kserv_conf); |
112 |
* Install WinPT into the W32 registry, if the entry already |
free_if_alloc (reg_prefs.homedir); |
113 |
* exists the function returns immediately. |
memset (®_prefs, 0, sizeof (reg_prefs)); |
114 |
*/ |
} |
115 |
int |
|
116 |
regist_inst_winpt( int with_ext, int * created ) |
|
117 |
{ |
|
118 |
HKEY reg; |
/* Install the GPG related into the W32 resgistry, if the entry already |
119 |
char * p = NULL; |
exists the function returns immediately. */ |
120 |
int rc, i, id, n = 0; |
int |
121 |
|
regist_inst_gnupg (int create_mokey) |
122 |
if( created ) |
{ |
123 |
*created = 0; |
int rc; |
124 |
|
HKEY reg; |
125 |
p = get_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions" ); |
|
126 |
if( p && *p == '1' ) |
rc = RegOpenKeyEx (HKEY_CURRENT_USER, GPG_REG, 0, KEY_READ, ®); |
127 |
with_ext = 0; |
if (rc == ERROR_SUCCESS) { |
128 |
free_if_alloc( p ); |
RegCloseKey (reg); |
129 |
|
return 0; |
130 |
if( with_ext ) { |
} |
131 |
id = msg_box( NULL, _("WinPT can register some GPG file types for you so they can " |
rc = RegCreateKey (HKEY_CURRENT_USER, GPG_REG, ®); |
132 |
"be processed with a double click in the explorer.\n" |
if (rc != ERROR_SUCCESS) |
133 |
"Do you want to continue?"), _("WinPT"), MB_YESNO|MB_INFO ); |
return WPTERR_REGISTRY; |
134 |
if( id == IDNO ) { |
RegCloseKey (reg); |
135 |
set_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1" ); |
|
136 |
goto start; |
if (!create_mokey) |
137 |
} |
return 0; |
138 |
for( i = 0; gpg_filetypes[i].ext; i++ ) { |
|
139 |
rc = RegOpenKeyEx( HKEY_CLASSES_ROOT, gpg_filetypes[i].ext, 0, KEY_READ, ® ); |
rc = RegOpenKeyEx (HKEY_CURRENT_USER, GPG_MO_REG, 0, KEY_READ, ®); |
140 |
if( rc_ok( rc ) ) { |
if (rc == ERROR_SUCCESS) { |
141 |
RegCloseKey( reg ); |
RegCloseKey (reg); |
142 |
id = log_box( _("WinPT WARNING"), MB_YESNO|MB_INFO, |
return 0; |
143 |
_("It seems there was already a '%s' file type registered by another application.\n" |
} |
144 |
"Do you want to overwrite it?"), gpg_filetypes[i].ext ); |
rc = RegCreateKey (HKEY_CURRENT_USER, GPG_MO_REG, ®); |
145 |
if( id == IDNO ) |
if (rc != ERROR_SUCCESS) |
146 |
continue; |
return WPTERR_REGISTRY; |
147 |
} |
|
148 |
regist_single_filetype( &gpg_filetypes[i] ); |
RegCloseKey (reg); |
149 |
n++; |
return 0; |
150 |
} |
} |
151 |
} |
|
152 |
|
|
153 |
start: |
/* Create a new filetype in the W32 registry. |
154 |
rc = RegOpenKeyEx( HKEY_CURRENT_USER, WINPT_REG, 0, KEY_READ, ® ); |
We should really care of errors! Otherwise we can damage the registry! */ |
155 |
if( rc_ok( rc ) ) { |
static int |
156 |
RegCloseKey( reg ); |
create_file_type (const char *exefile, const char *ext, |
157 |
rc = RegOpenKeyEx( HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", 0, KEY_READ, ® ); |
const char *extname, char *iconfile) |
158 |
if( !rc_ok( rc ) ) { |
{ |
159 |
RegCreateKey( HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", ® ); |
HKEY reg = NULL; |
160 |
RegCloseKey( reg ); |
char deficon[MAX_PATH+1]; |
161 |
} |
char defexec[MAX_PATH+1]; |
162 |
p = get_reg_entry_keyserver ("Default"); |
char p_exefile[MAX_PATH+1]; |
163 |
if (!p) { |
int rc; |
164 |
char buf[16]; |
|
165 |
sprintf (buf, "%d", HKP_PORT); |
rc = RegCreateKey (HKEY_CLASSES_ROOT, ext, ®); |
166 |
set_reg_entry_keyserver ("Default_Port", buf); |
if( rc_ok( rc ) ) |
167 |
set_reg_entry_keyserver ("Default", DEF_HKP_KEYSERVER); |
rc = RegSetValueEx( reg, NULL, 0, REG_SZ, (BYTE *)extname, strlen( extname ) ); |
168 |
} |
if( rc_ok( rc ) ) |
169 |
free_if_alloc( p ); |
rc = RegCloseKey( reg ); |
170 |
if( n ) |
if( rc_ok( rc ) ) |
171 |
set_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1" ); |
rc = RegCreateKey( HKEY_CLASSES_ROOT, extname, ® ); |
172 |
return 0; |
if( rc_ok( rc ) ) |
173 |
} |
rc = RegSetValueEx( reg, NULL, 0, REG_SZ, (BYTE *) extname, strlen( extname ) ); |
174 |
rc = RegCreateKey( HKEY_CURRENT_USER, WINPT_REG, ® ); |
if( rc_ok( rc ) ) |
175 |
if( !rc_ok( rc ) ) |
rc = RegCloseKey( reg ); |
176 |
return WPTERR_REGISTRY; |
if( !rc_ok( rc ) ) { |
177 |
if( created ) |
rc = WPTERR_REGISTRY; |
178 |
*created = 1; |
goto leave; |
179 |
RegCloseKey( reg ); |
} |
180 |
if( n ) |
|
181 |
set_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1" ); |
memset( &deficon, 0, sizeof deficon ); |
182 |
return 0; |
_snprintf( deficon, DIM (deficon) - 1, "%s\\DefaultIcon", extname ); |
183 |
} /* regist_inst_winpt */ |
memset( &defexec, 0, sizeof defexec ); |
184 |
|
_snprintf( defexec, DIM (defexec) - 1, "%s\\shell\\open\\command", extname ); |
185 |
|
memset( &p_exefile, 0, sizeof p_exefile ); |
186 |
/* |
_snprintf( p_exefile, DIM (p_exefile) - 1, "%s %%1", exefile ); |
187 |
* Create a new filetype in the W32 registry. |
|
188 |
* We should really care of errors! Otherwise we can damage the registry! |
rc = RegCreateKey( HKEY_CLASSES_ROOT, deficon, ® ); |
189 |
*/ |
if( rc_ok( rc ) ) |
190 |
int |
rc = RegSetValueEx(reg, NULL, 0, REG_SZ, (BYTE *)iconfile, strlen( iconfile ) ); |
191 |
create_file_type( const char *exefile, const char *ext, const char *extname, char *iconfile ) |
if( rc_ok( rc ) ) |
192 |
{ |
rc = RegCloseKey( reg ); |
193 |
int rc; |
if( rc_ok( rc ) ) |
194 |
HKEY reg = NULL; |
rc = RegCreateKey( HKEY_CLASSES_ROOT, defexec, ® ); |
195 |
char deficon[256], defexec[256], p_exefile[256]; |
if( rc_ok( rc ) ) |
196 |
|
rc = RegSetValueEx( reg, NULL, 0, REG_SZ, (BYTE *)p_exefile, strlen( exefile ) ); |
197 |
|
if( rc_ok( rc ) ) |
198 |
rc = RegCreateKey( HKEY_CLASSES_ROOT, ext, ® ); |
rc = RegCloseKey( reg ); |
199 |
if( rc_ok( rc ) ) |
if( !rc_ok( rc ) ) { |
200 |
rc = RegSetValueEx( reg, NULL, 0, REG_SZ, (byte *)extname, strlen( extname ) ); |
rc = WPTERR_REGISTRY; |
201 |
if( rc_ok( rc ) ) |
goto leave; |
202 |
rc = RegCloseKey( reg ); |
} |
203 |
if( rc_ok( rc ) ) |
|
204 |
rc = RegCreateKey( HKEY_CLASSES_ROOT, extname, ® ); |
leave: |
205 |
if( rc_ok( rc ) ) |
if (reg) |
206 |
rc = RegSetValueEx( reg, NULL, 0, REG_SZ, (byte *) extname, strlen( extname ) ); |
RegCloseKey (reg); |
207 |
if( rc_ok( rc ) ) |
return rc; |
208 |
rc = RegCloseKey( reg ); |
} |
209 |
if( !rc_ok( rc ) ) { |
|
210 |
rc = WPTERR_REGISTRY; |
|
211 |
goto leave; |
/* Register the given WinPT filetype. */ |
212 |
} |
static int |
213 |
|
regist_single_filetype (gpg_filetype_t gfile) |
214 |
memset( &deficon, 0, sizeof deficon ); |
{ |
215 |
_snprintf( deficon, sizeof deficon - 1, "%s\\DefaultIcon", extname ); |
char icon[MAX_PATH+1] = {0}; |
216 |
memset( &defexec, 0, sizeof defexec ); |
char prog[MAX_PATH+1] = {0}; |
217 |
_snprintf( defexec, sizeof defexec - 1, "%s\\shell\\open\\command", extname ); |
|
218 |
memset( &p_exefile, 0, sizeof p_exefile ); |
if (!GetModuleFileName (glob_hinst, prog, DIM (prog)-1)) |
219 |
_snprintf( p_exefile, sizeof p_exefile - 1, "%s %%1", exefile ); |
return WPTERR_REGISTRY; |
220 |
|
_snprintf (icon, DIM (icon) -1, "%s,%d", prog, gfile->nicon); |
221 |
rc = RegCreateKey( HKEY_CLASSES_ROOT, deficon, ® ); |
return create_file_type (prog, gfile->ext, gfile->descr, icon); |
222 |
if( rc_ok( rc ) ) |
} |
223 |
rc = RegSetValueEx(reg, NULL, 0, REG_SZ, (byte *)iconfile, strlen( iconfile ) ); |
|
224 |
if( rc_ok( rc ) ) |
/* Install WinPT into the W32 registry, if the entry already |
225 |
rc = RegCloseKey( reg ); |
exists the function returns immediately. @with_ext can be |
226 |
if( rc_ok( rc ) ) |
used to register some file types (if 1). @created contains |
227 |
rc = RegCreateKey( HKEY_CLASSES_ROOT, defexec, ® ); |
1 if the registry key was created. |
228 |
if( rc_ok( rc ) ) |
Return value: 0 on success. */ |
229 |
rc = RegSetValueEx( reg, NULL, 0, REG_SZ, (byte *)p_exefile, strlen( exefile ) ); |
int |
230 |
if( rc_ok( rc ) ) |
regist_inst_winpt (int with_ext, int *created) |
231 |
rc = RegCloseKey( reg ); |
{ |
232 |
if( !rc_ok( rc ) ) { |
struct gpg_filetype_s gpg_filetypes[] = { |
233 |
rc = WPTERR_REGISTRY; |
{_("GPG Detached Signature"), ".sig", 1}, |
234 |
goto leave; |
{_("GPG Encrypted Data"), ".gpg", 2}, |
235 |
} |
{_("GPG Armored Data"), ".asc", 2}, |
236 |
|
{0} |
237 |
leave: |
}; |
238 |
if( reg ) |
HKEY reg; |
239 |
RegCloseKey( reg ); |
char *p = NULL; |
240 |
return rc; |
char modpath[MAX_PATH+1]; |
241 |
} /* create_file_type */ |
int rc, i, id, n; |
242 |
|
|
243 |
|
if (created) |
244 |
static char * |
*created = 0; |
245 |
expand_path( const char *path ) |
|
246 |
{ |
/* If GPGee is already installed deactivate file extension registering |
247 |
DWORD len; |
because it is very likely this would overwrite the GPGee settings. */ |
248 |
char *p; |
if (is_gpgee_installed ()) |
249 |
|
with_ext = 0; |
250 |
len = ExpandEnvironmentStrings( path, NULL, 0 ); |
|
251 |
if( !len ) |
rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG, 0, KEY_READ, ®); |
252 |
return NULL; |
if (rc == ERROR_SUCCESS) { |
253 |
len += 1; |
RegCloseKey (reg); |
254 |
p = new char[len]; |
rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", 0, KEY_READ, ®); |
255 |
if( !p ) |
if (rc != ERROR_SUCCESS) { |
256 |
return NULL; |
rc = RegCreateKey (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", ®); |
257 |
len = ExpandEnvironmentStrings( path, p, len ); |
if (rc == ERROR_SUCCESS) |
258 |
if( !len ) { |
RegCloseKey (reg); |
259 |
free_if_alloc( p ); |
} |
260 |
return NULL; |
else |
261 |
} |
RegCloseKey (reg); |
262 |
return p; |
p = get_reg_entry_keyserver ("Default"); |
263 |
} /* expand_path */ |
if (!p) { |
264 |
|
char buf[16]; |
265 |
|
|
266 |
char * |
_snprintf (buf, DIM (buf)-1, "%d", HKP_PORT); |
267 |
get_reg_entry( HKEY root_key, const char * dir, const char * key ) |
set_reg_entry_keyserver ("Default_Port", buf); |
268 |
{ |
set_reg_entry_keyserver ("Default", DEF_HKP_KEYSERVER); |
269 |
int rc; |
} |
270 |
char text[384] = {0}; |
free_if_alloc (p); |
271 |
DWORD nbytes, type, n1 = 0; |
return 0; |
272 |
HKEY reg_key = NULL; |
} |
273 |
char * p = NULL, * tmp = NULL; |
rc = RegCreateKey (HKEY_CURRENT_USER, WINPT_REG, ®); |
274 |
|
if (rc != ERROR_SUCCESS) |
275 |
rc = RegOpenKeyEx( root_key, dir, 0, KEY_QUERY_VALUE, ®_key ); |
return WPTERR_REGISTRY; |
276 |
if( !rc_ok( rc ) ) |
if (created) |
277 |
goto leave; |
*created = 1; |
278 |
nbytes = sizeof text - 1; |
RegCloseKey (reg); |
279 |
type = REG_SZ; |
/* FIXME: check this part */ |
280 |
|
if (with_ext) { |
281 |
rc = RegQueryValueEx (reg_key, key, 0, &type, (BYTE *)&text, &nbytes); |
id = msg_box (NULL, _("WinPT can register some GPG file types for you so they can " |
282 |
if (!rc_ok (rc) || !nbytes) |
"be processed with a double click in the explorer.\n" |
283 |
goto leave; |
"Do you want to continue?"), _("WinPT"), MB_YESNO|MB_INFO); |
284 |
|
if (id == IDYES) { |
285 |
if (type == REG_EXPAND_SZ && strchr (text, '%')) |
for (i = 0; gpg_filetypes[i].ext; i++) { |
286 |
p = expand_path (text); |
rc = RegOpenKeyEx (HKEY_CLASSES_ROOT, gpg_filetypes[i].ext, 0, KEY_READ, ®); |
287 |
else { |
if (rc == ERROR_SUCCESS) { |
288 |
p = new char[nbytes + 1]; |
RegCloseKey (reg); |
289 |
if (!p) |
id = log_box (_("WinPT WARNING"), MB_YESNO|MB_INFO, |
290 |
BUG (0); |
_("It seems there was already a '%s' file type registered by another application.\n" |
291 |
memcpy (p, text, nbytes); |
"Do you want to overwrite it?"), gpg_filetypes[i].ext); |
292 |
p[nbytes] = '\0'; |
if (id == IDNO) |
293 |
} |
continue; |
294 |
|
} |
295 |
leave: |
regist_single_filetype (&gpg_filetypes[i]); |
296 |
if (reg_key) |
} |
297 |
RegCloseKey (reg_key); |
} |
298 |
return p; |
} |
299 |
} /* get_reg_entry */ |
/* Store the install directory for later use. */ |
300 |
|
n = GetModuleFileName (NULL, modpath, MAX_PATH-1); |
301 |
|
if (n > 0) { |
302 |
int |
while (n-- > 0) { |
303 |
set_reg_entry( HKEY root_key, const char * dir, const char * key, |
if (modpath[n] == '\\') { |
304 |
const char * value ) |
modpath[n] = 0; |
305 |
{ |
break; |
306 |
int rc = 0; |
} |
307 |
HKEY reg_key; |
} |
308 |
|
log_debug("storing install directory '%s'", modpath); |
309 |
rc = RegOpenKeyEx( root_key, dir, 0, KEY_WRITE, ®_key ); |
set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Install Directory", modpath); |
310 |
if( !rc_ok( rc ) ) |
} |
311 |
return WPTERR_REGISTRY; |
return 0; |
312 |
rc = RegSetValueEx( reg_key, key, 0, REG_SZ, (BYTE *)value, strlen( value ) ); |
} |
313 |
if( !rc_ok( rc ) ) |
|
314 |
rc = WPTERR_REGISTRY; |
|
315 |
RegCloseKey( reg_key ); |
/* Expand a string with %foo% entries so that %foo% will |
316 |
return rc; |
be replaced with its actual value. */ |
317 |
} /* set_reg_entry */ |
static char* |
318 |
|
expand_path (const char *path) |
319 |
|
{ |
320 |
int |
DWORD len; |
321 |
set_reg_key( HKEY root_key, const char * dir, const char * key, |
char *p; |
322 |
const char * value ) |
|
323 |
{ |
len = ExpandEnvironmentStrings (path, NULL, 0); |
324 |
int rc = 0; |
if (!len) |
325 |
HKEY reg_key; |
return NULL; |
326 |
|
len += 1; |
327 |
rc = RegOpenKeyEx( root_key, dir, 0, KEY_WRITE, ®_key ); |
p = new char[len+1]; |
328 |
if( !rc_ok( rc ) ) |
if (!p) |
329 |
return WPTERR_REGISTRY; |
return NULL; |
330 |
|
len = ExpandEnvironmentStrings (path, p, len); |
331 |
rc = RegSetValueEx( reg_key, key, 0, REG_SZ, (BYTE *)value, strlen( value ) ); |
if (!len) { |
332 |
if( !rc_ok( rc ) ) { |
free_if_alloc (p); |
333 |
if ( RegCreateKey( root_key, key, ®_key ) != ERROR_SUCCESS ) { |
return NULL; |
334 |
rc = WPTERR_REGISTRY; |
} |
335 |
goto leave; |
return p; |
336 |
} |
} |
337 |
rc = RegSetValueEx( reg_key, key, 0, REG_SZ, (BYTE *)value, strlen( value ) ); |
|
338 |
if ( !rc_ok( rc ) ) |
|
339 |
rc = WPTERR_REGISTRY; |
/* Retrieve a registry entry with the directory given in @dir |
340 |
} |
and the key given in @key. |
341 |
|
Return value is the value or NULL otherwise. */ |
342 |
leave: |
char* |
343 |
RegCloseKey( reg_key ); |
get_reg_entry (HKEY root_key, const char *dir, const char *key) |
344 |
return rc; |
{ |
345 |
} /* set_reg_key */ |
HKEY reg_key = NULL; |
346 |
|
char *p = NULL, *pp; |
347 |
|
DWORD type = REG_SZ, nbytes = 0; |
348 |
int |
int rc; |
349 |
set_reg_entry_gpg( const char * key, const char * value ) |
|
350 |
{ |
rc = RegOpenKeyEx (root_key, dir, 0, KEY_QUERY_VALUE, ®_key); |
351 |
return set_reg_entry( HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key, value ); |
if (rc != ERROR_SUCCESS) |
352 |
} /* set_reg_entry_gpg */ |
goto leave; |
353 |
|
rc = RegQueryValueEx (reg_key, key, NULL, &type, NULL, &nbytes); |
354 |
|
if (rc != ERROR_SUCCESS) |
355 |
int |
goto leave; |
356 |
set_reg_entry_mo( const char * value ) |
if (!nbytes) |
357 |
{ |
goto leave; /* empty */ |
358 |
return set_reg_entry( HKEY_CURRENT_USER, "Control Panel\\Mingw32\\NLS", "MODir", value ); |
p = new char[nbytes+1]; |
359 |
} /* set_reg_entry_mo */ |
if (!p) |
360 |
|
BUG (0); |
361 |
|
rc = RegQueryValueEx (reg_key, key, NULL, &type, (BYTE*)p, &nbytes); |
362 |
char * |
if (rc != ERROR_SUCCESS) |
363 |
get_reg_entry_gpg( const char *key ) |
goto leave; |
364 |
{ |
if (type == REG_EXPAND_SZ && strchr (p, '%')) { |
365 |
return get_reg_entry( HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key ); |
pp = p; |
366 |
} /* get_reg_entry_gpg */ |
p = expand_path (pp); |
367 |
|
free_if_alloc (pp); |
368 |
|
} |
369 |
char * |
|
370 |
get_reg_entry_mo( void ) |
leave: |
371 |
{ |
if (reg_key != NULL) |
372 |
return get_reg_entry( HKEY_CURRENT_USER, "Control Panel\\Mingw32\\NLS", "MODir" ); |
RegCloseKey (reg_key); |
373 |
} /* get_reg_entry_mo */ |
return p; |
374 |
|
} |
375 |
|
|
376 |
static const char * cfg [] = { |
|
377 |
NULL, |
/* XXX: use REG_EXPAND_SZ to support multi user environments. |
378 |
"CacheTime", |
keep this type and do not overwrite it with REG_SZ. */ |
379 |
"WordWrap", |
|
380 |
"FastMode", |
/* Set a registry entry. */ |
381 |
"Viewer", |
int |
382 |
"KeylistMode", |
set_reg_entry (HKEY root_key, const char *dir, const char *key, |
383 |
"WipeMode", |
const char *value) |
384 |
"AlwaysTrust", |
{ |
385 |
"AutoBackup", |
HKEY reg_key; |
386 |
"BackupMode", |
int rc; |
387 |
"DisableHotkeys", |
|
388 |
"NoCompressMultiMedia", |
rc = RegOpenKeyEx (root_key, dir, 0, KEY_WRITE, ®_key); |
389 |
"Expert", |
if (rc != ERROR_SUCCESS) |
390 |
}; |
return WPTERR_REGISTRY; |
391 |
|
rc = RegSetValueEx (reg_key, key, 0, REG_SZ, (BYTE *)value, strlen (value)); |
392 |
|
if (rc != ERROR_SUCCESS) |
393 |
int |
rc = WPTERR_REGISTRY; |
394 |
set_reg_winpt_single (int id, int val) |
RegCloseKey (reg_key); |
395 |
{ |
return rc; |
396 |
char buf[64]; |
} |
397 |
int rc; |
|
398 |
|
|
399 |
sprintf (buf, "%d", val); |
int |
400 |
rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[id], buf); |
set_reg_key (HKEY root_key, const char *dir, const char *key, |
401 |
return rc; |
const char *value) |
402 |
} |
{ |
403 |
|
HKEY reg_key; |
404 |
|
int rc; |
405 |
int |
|
406 |
get_reg_winpt_single (int id) |
rc = RegOpenKeyEx (root_key, dir, 0, KEY_WRITE, ®_key); |
407 |
{ |
if (rc != ERROR_SUCCESS) |
408 |
char * buf = NULL; |
return WPTERR_REGISTRY; |
409 |
int val = 0; |
|
410 |
|
rc = RegSetValueEx (reg_key, key, 0, REG_SZ, (BYTE *)value, strlen (value)); |
411 |
buf = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[id]); |
if (rc != ERROR_SUCCESS) { |
412 |
if (buf && *buf != ' ') |
if (RegCreateKey (root_key, key, ®_key) != ERROR_SUCCESS) { |
413 |
val = 1; |
rc = WPTERR_REGISTRY; |
414 |
else if (!buf) |
goto leave; |
415 |
val = -1; |
} |
416 |
free_if_alloc (buf); |
rc = RegSetValueEx (reg_key, key, 0, REG_SZ, (BYTE *)value, strlen (value)); |
417 |
return val; |
if (rc != ERROR_SUCCESS) |
418 |
} |
rc = WPTERR_REGISTRY; |
419 |
|
} |
420 |
|
|
421 |
int |
leave: |
422 |
set_reg_winpt_prefs (winpt_reg_prefs_s * opt) |
RegCloseKey (reg_key); |
423 |
{ |
return rc; |
424 |
char buf[128]; |
} |
425 |
int rc = 0, i; |
|
426 |
|
|
427 |
for (i=1; i < DIM (cfg); i++) { |
int |
428 |
switch (i) { |
set_reg_entry_gpg (const char *key, const char *value) |
429 |
case CFG_CACHETIME: |
{ |
430 |
sprintf (buf, "%d", opt->cache_time); |
return set_reg_entry (HKEY_CURRENT_USER, GPG_REG, key, value); |
431 |
break; |
} |
432 |
case CFG_WORDWRAP: |
|
433 |
sprintf (buf, "%d", opt->word_wrap); |
|
434 |
break; |
|
435 |
case CFG_WIPEMODE: |
char* |
436 |
sprintf (buf, "%d", opt->wipe_mode); |
get_reg_entry_gpg (const char *key) |
437 |
break; |
{ |
438 |
case CFG_FASTMODE: |
char *p; |
439 |
sprintf (buf, "%d", opt->use_tmpfiles); |
|
440 |
break; |
p = get_reg_entry (HKEY_CURRENT_USER, GPG_REG, key); |
441 |
case CFG_NOZIP_MMEDIA: |
if (!p || strlen (p) == 0) { |
442 |
sprintf (buf, "%d", opt->no_zip_mmedia); |
free_if_alloc (p); |
443 |
break; |
return NULL; |
444 |
case CFG_VIEWER: |
} |
445 |
sprintf (buf, "%d", opt->use_viewer); |
return p; |
446 |
break; |
} |
447 |
case CFG_KEYLISTMODE: |
|
448 |
sprintf (buf, "%d", opt->keylist_mode); |
|
449 |
break; |
/* Return if possible the GPG4Win installation directory concatenated |
450 |
case CFG_ALWAYSTRUST: |
with the string in @path if given. */ |
451 |
sprintf (buf, "%d", opt->always_trust); |
char* |
452 |
break; |
get_reg_entry_gpg4win (const char *path) |
453 |
case CFG_AUTOBACKUP: |
{ |
454 |
sprintf (buf, "%d", opt->auto_backup); |
const char *fmt; |
455 |
break; |
char *p, *pp; |
456 |
case CFG_AUTOBAKMODE: |
|
457 |
sprintf (buf, "%d", opt->backup.mode); |
p = get_reg_entry (HKEY_LOCAL_MACHINE, GPG_REG, "Install Directory"); |
458 |
break; |
if (!p) |
459 |
case CFG_DISHOTKEYS: |
return NULL; |
460 |
sprintf (buf, "%d", opt->no_hotkeys); |
if (!path) |
461 |
break; |
return p; |
462 |
case CFG_EXPERT: |
fmt = "%s\\%s"; |
463 |
sprintf (buf, "%d", opt->expert); |
pp = new char[strlen (p) + strlen (path) + strlen (fmt) + 1]; |
464 |
break; |
if (!pp) |
465 |
} |
BUG (NULL); |
466 |
rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[i], buf); |
sprintf (pp, fmt, p, path); |
467 |
if (rc) |
free_if_alloc (p); |
468 |
goto leave; |
return pp; |
469 |
} |
} |
470 |
|
|
471 |
if (opt->backup.path) { |
|
472 |
rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "BackupPath", |
char* |
473 |
opt->backup.path); |
get_reg_entry_mo (void) |
474 |
if (rc) |
{ |
475 |
goto leave; |
char *p, *pp; |
476 |
} |
const char *fmt; |
477 |
if (opt->kserv_conf) { |
const char *lang; |
478 |
rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "KeyserverConfig", |
|
479 |
opt->kserv_conf); |
p = get_reg_entry (HKEY_CURRENT_USER, GPG_MO_REG, "MODir"); |
480 |
if (rc) |
if (p) |
481 |
goto leave; |
return p; |
482 |
} |
|
483 |
|
lang = gettext_get_langid (); |
484 |
for (i=0; reg_hotkeys[i].reg_entry; i++) { |
if (!lang) |
485 |
strcpy (buf, " "); |
return NULL; |
486 |
if (reg_hotkeys[i].enabled) |
fmt = "share\\locale\\%s\\LC_MESSAGES"; |
487 |
strcpy (buf, reg_hotkeys[i].key); |
pp = new char[strlen (fmt) + strlen (lang) + 4 + 1]; |
488 |
rc = set_reg_key (HKEY_CURRENT_USER, WINPT_REG, |
if (!pp) |
489 |
reg_hotkeys[i].reg_entry, buf); |
BUG (NULL); |
490 |
if (rc) |
sprintf (pp, fmt, lang); |
491 |
break; |
p = get_reg_entry_gpg4win (pp); |
492 |
} |
free_if_alloc (pp); |
493 |
|
return p; |
494 |
leave: |
} |
495 |
if (rc) { |
|
496 |
msg_box (NULL, _("Could not write to Registry."), _("Preferences"), MB_ERR); |
|
497 |
return rc; |
int |
498 |
} |
set_reg_winpt_single (int id, int val) |
499 |
return 0; |
{ |
500 |
} /* set_reg_winpt_prefs */ |
char buf[64]; |
501 |
|
int rc; |
502 |
|
|
503 |
int |
_snprintf (buf, DIM (buf)-1, "%d", val); |
504 |
set_reg_winpt_flag (const char * name, int val) |
rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[id], buf); |
505 |
{ |
return rc; |
506 |
return set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, name, val? "1" : "0"); |
} |
507 |
} /* set_reg_winpt_flag */ |
|
508 |
|
|
509 |
|
int |
510 |
int |
get_reg_winpt_single (int id) |
511 |
get_reg_winpt_flag (const char * name) |
{ |
512 |
{ |
char *buf; |
513 |
char * buf; |
int val = 0; |
514 |
int flag = 0; |
|
515 |
|
buf = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[id]); |
516 |
buf = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, name); |
if (buf && *buf != ' ') |
517 |
if (buf && buf[0] == '1') |
val = 1; |
518 |
flag = 1; |
else if (!buf) |
519 |
else if (!buf || buf && buf[0] != '0') |
val = -1; |
520 |
flag = -1; |
free_if_alloc (buf); |
521 |
free_if_alloc (buf); |
return val; |
522 |
return flag; |
} |
523 |
} /* get_reg_winpt_flag */ |
|
524 |
|
|
525 |
|
/* Saves the winpt preferences in the registry. */ |
526 |
int |
int |
527 |
get_reg_winpt_prefs (winpt_reg_prefs_s * opt) |
set_reg_winpt_prefs (winpt_prefs_t opt) |
528 |
{ |
{ |
529 |
char * val = NULL; |
char buf[128]; |
530 |
int i; |
size_t i; |
531 |
|
int rc = 0; |
532 |
for (i=1; i < DIM (cfg); i++) { |
|
533 |
val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[i]); |
for (i=1; i < DIM (cfg); i++) { |
534 |
if (!val || *val == ' ') { |
switch (i) { |
535 |
free_if_alloc (val); |
case CFG_CACHETIME: |
536 |
continue; |
sprintf (buf, "%d", opt->cache_time); |
537 |
} |
break; |
538 |
switch (i) { |
|
539 |
case CFG_CACHETIME: |
case CFG_WORDWRAP: |
540 |
opt->cache_time = atol (val); |
sprintf (buf, "%d", opt->word_wrap); |
541 |
/* We do NOT support passphrase caching for more than an hour. |
break; |
542 |
* Perhaps we should allow it, but for now we silently drop this. |
|
543 |
*/ |
case CFG_FILEEXT: |
544 |
if (opt->cache_time > 3600) |
sprintf (buf, "%d", opt->default_ext); |
545 |
opt->cache_time = 3600; |
break; |
546 |
break; |
|
547 |
case CFG_WORDWRAP: |
case CFG_NOZIP_MMEDIA: |
548 |
opt->word_wrap = atol (val); |
sprintf (buf, "%d", opt->no_zip_mmedia); |
549 |
break; |
break; |
550 |
case CFG_FASTMODE: |
|
551 |
opt->use_tmpfiles = atol (val); |
case CFG_VIEWER: |
552 |
break; |
sprintf (buf, "%d", opt->use_viewer); |
553 |
case CFG_NOZIP_MMEDIA: |
break; |
554 |
opt->no_zip_mmedia = atol (val); |
|
555 |
break; |
case CFG_ALWAYSTRUST: |
556 |
case CFG_VIEWER: |
sprintf (buf, "%d", opt->always_trust); |
557 |
opt->use_viewer = atol (val); |
break; |
558 |
break; |
|
559 |
case CFG_KEYLISTMODE: |
case CFG_AUTOBACKUP: |
560 |
opt->keylist_mode = atol (val); |
sprintf (buf, "%d", opt->auto_backup); |
561 |
break; |
break; |
562 |
case CFG_WIPEMODE: |
|
563 |
opt->wipe_mode = atol (val); |
case CFG_AUTOBAKMODE: |
564 |
break; |
sprintf (buf, "%d", opt->backup.mode); |
565 |
case CFG_DISHOTKEYS: |
break; |
566 |
opt->no_hotkeys = atol (val); |
|
567 |
break; |
case CFG_DISHOTKEYS: |
568 |
case CFG_ALWAYSTRUST: |
sprintf (buf, "%d", opt->no_hotkeys); |
569 |
opt->always_trust = atol (val); |
break; |
570 |
break; |
|
571 |
case CFG_AUTOBACKUP: |
case CFG_EXPERT: |
572 |
opt->auto_backup = atol (val); |
sprintf (buf, "%d", opt->expert); |
573 |
break; |
break; |
574 |
case CFG_AUTOBAKMODE: |
|
575 |
opt->backup.mode = atol (val); |
case CFG_FM_PROGRESS: |
576 |
break; |
sprintf (buf, "%d", opt->fm.progress); |
577 |
case CFG_EXPERT: |
break; |
578 |
opt->expert = atol (val); |
|
579 |
break; |
case CFG_BACKUP_INC_SKR: |
580 |
} |
sprintf (buf, "%d", opt->backup.include_secr); |
581 |
free_if_alloc (val); |
break; |
582 |
} |
} |
583 |
|
rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[i], buf); |
584 |
val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "BackupPath"); |
if (rc) |
585 |
if (val && val[0] != ' ') |
goto leave; |
586 |
opt->backup.path = m_strdup (val); |
} |
587 |
free_if_alloc (val); |
|
588 |
|
if (opt->backup.path) { |
589 |
val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "KeyserverConfig"); |
rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "BackupPath", |
590 |
if (val && val[0] != ' ') |
opt->backup.path); |
591 |
opt->kserv_conf = m_strdup (val); |
if (rc) |
592 |
free_if_alloc (val); |
goto leave; |
593 |
|
} |
594 |
for (i=0; reg_hotkeys[i].reg_entry; i++) { |
|
595 |
val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, reg_hotkeys[i].reg_entry); |
for (i=0; wpt_hotkeys[i].name != NULL; i++) { |
596 |
if (val && val[0] != ' ') { |
if (wpt_hotkeys[i].enabled == 1) { |
597 |
reg_hotkeys[i].key[0] = *val; |
buf[0] = wpt_hotkeys[i].key; |
598 |
reg_hotkeys[i].enabled = 1; |
buf[1] = 0; |
599 |
} |
} |
600 |
else |
else |
601 |
reg_hotkeys[i].enabled = 0; |
strcpy (buf, " "); |
602 |
free_if_alloc (val); |
rc = set_reg_key (HKEY_CURRENT_USER, WINPT_REG, |
603 |
} |
wpt_hotkeys[i].name, buf); |
604 |
return 0; |
if (rc) |
605 |
} /* get_reg_winpt_prefs */ |
break; |
606 |
|
} |
607 |
|
|
608 |
char * |
leave: |
609 |
get_reg_entry_keyserver (const char *name) |
if (rc) { |
610 |
{ |
msg_box (NULL, _("Could not write to Registry."), _("Preferences"), MB_ERR); |
611 |
char * p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", name); |
return rc; |
612 |
if (p && !strcmp (p, "")) { |
} |
613 |
free_if_alloc (p); |
return 0; |
614 |
return NULL; |
} |
615 |
} |
|
616 |
return p; |
|
617 |
} /* get_reg_entry_keyserver */ |
int |
618 |
|
set_reg_winpt_flag (const char *name, int val) |
619 |
|
{ |
620 |
void |
return set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, name, val? "1" : "0"); |
621 |
get_reg_proxy_prefs (char ** host, int * port, char ** user, char ** pass) |
} |
622 |
{ |
|
623 |
if (host) |
|
624 |
*host = get_reg_entry_keyserver ("Host"); |
int |
625 |
if (user) |
get_reg_winpt_flag (const char *name) |
626 |
*user = get_reg_entry_keyserver ("User"); |
{ |
627 |
if (pass) |
char *buf; |
628 |
*pass = get_reg_entry_keyserver ("Pass"); |
int flag = 0; |
629 |
if (port) { |
|
630 |
char * p = get_reg_entry_keyserver ("Port"); |
buf = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, name); |
631 |
if (p) { |
if (buf && buf[0] == '1') |
632 |
*port = atol (p); |
flag = 1; |
633 |
free_if_alloc (p); |
else if (!buf || (buf && buf[0] != '0')) |
634 |
} |
flag = -1; |
635 |
} |
free_if_alloc (buf); |
636 |
} /* get_reg_proxy_prefs */ |
return flag; |
637 |
|
} |
638 |
|
|
639 |
int |
|
640 |
set_reg_entry_keyserver( const char * name, const char * val ) |
/* Retrieve the winpt preferences from the registry. */ |
641 |
{ |
int |
642 |
return set_reg_entry( HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", name, val ); |
get_reg_winpt_prefs (winpt_prefs_t opt) |
643 |
} /* set_reg_entry_keyserver */ |
{ |
644 |
|
char *val = NULL; |
645 |
|
size_t i; |
646 |
int |
|
647 |
set_reg_proxy_prefs( const char * host, int port, const char * user, const char * pass ) |
for (i=1; i < DIM (cfg); i++) { |
648 |
{ |
val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[i]); |
649 |
int rc; |
if (!val || *val == ' ') { |
650 |
|
free_if_alloc (val); |
651 |
rc = set_reg_entry_keyserver( "Host", host? host : "" ); |
continue; |
652 |
if( !rc ) { |
} |
653 |
char buf[32]; |
switch (i) { |
654 |
sprintf( buf, "%d", port ); |
case CFG_CACHETIME: |
655 |
rc = set_reg_entry_keyserver( "Port", buf ); |
opt->cache_time = atoi (val); |
656 |
} |
break; |
657 |
if( !rc ) |
case CFG_WORDWRAP: |
658 |
rc = set_reg_entry_keyserver( "User", user? user : "" ); |
opt->word_wrap = atoi (val); |
659 |
if( !rc ) |
break; |
660 |
rc = set_reg_entry_keyserver( "Pass", pass? pass : "" ); |
case CFG_FILEEXT: |
661 |
return rc; |
opt->default_ext = atoi (val); |
662 |
} /* set_reg_proxy_prefs */ |
break; |
663 |
|
case CFG_NOZIP_MMEDIA: |
664 |
|
opt->no_zip_mmedia = atoi (val); |
665 |
|
break; |
666 |
|
case CFG_VIEWER: |
667 |
|
opt->use_viewer = atoi (val); |
668 |
|
break; |
669 |
|
case CFG_DISHOTKEYS: |
670 |
|
opt->no_hotkeys = atoi (val); |
671 |
|
break; |
672 |
|
case CFG_ALWAYSTRUST: |
673 |
|
opt->always_trust = atoi (val); |
674 |
|
break; |
675 |
|
case CFG_AUTOBACKUP: |
676 |
|
opt->auto_backup = atoi (val); |
677 |
|
break; |
678 |
|
case CFG_AUTOBAKMODE: |
679 |
|
opt->backup.mode = atoi (val); |
680 |
|
break; |
681 |
|
case CFG_EXPERT: |
682 |
|
opt->expert = atoi (val); |
683 |
|
break; |
684 |
|
case CFG_FM_PROGRESS: |
685 |
|
opt->fm.progress = atoi (val); |
686 |
|
break; |
687 |
|
|
688 |
|
case CFG_BACKUP_INC_SKR: |
689 |
|
opt->backup.include_secr = atoi (val); |
690 |
|
break; |
691 |
|
} |
692 |
|
free_if_alloc (val); |
693 |
|
} |
694 |
|
|
695 |
|
val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "BackupPath"); |
696 |
|
if (val && val[0] != ' ') |
697 |
|
opt->backup.path = m_strdup (val); |
698 |
|
free_if_alloc (val); |
699 |
|
|
700 |
|
for (i=0; wpt_hotkeys[i].name; i++) { |
701 |
|
wpt_hotkeys[i].enabled = 0; |
702 |
|
val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, wpt_hotkeys[i].name); |
703 |
|
if (val && val[0] != ' ') { |
704 |
|
wpt_hotkeys[i].key = *val; |
705 |
|
wpt_hotkeys[i].enabled = 1; |
706 |
|
} |
707 |
|
free_if_alloc (val); |
708 |
|
} |
709 |
|
return 0; |
710 |
|
} |
711 |
|
|
712 |
|
|
713 |
|
char* |
714 |
|
get_reg_entry_keyserver (const char *name) |
715 |
|
{ |
716 |
|
char *p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", name); |
717 |
|
if (p && (!strcmp (p, "") || strlen (p) == 0)) { |
718 |
|
free_if_alloc (p); |
719 |
|
return NULL; |
720 |
|
} |
721 |
|
return p; |
722 |
|
} |
723 |
|
|
724 |
|
|
725 |
|
int |
726 |
|
set_reg_entry_keyserver (const char *name, const char *val) |
727 |
|
{ |
728 |
|
return set_reg_entry (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", name, val); |
729 |
|
} |
730 |
|
|