36 |
|
|
37 |
#define rc_ok(rc) ((rc) == ERROR_SUCCESS) |
#define rc_ok(rc) ((rc) == ERROR_SUCCESS) |
38 |
|
|
|
static gpg_filetype gpg_filetypes[] = { |
|
|
{"GPG Detached Signature", ".sig", 1}, |
|
|
{"GPG Encrypted Data", ".gpg", 2}, |
|
|
{"GPG Armored Data", ".asc", 2}, |
|
|
{0} |
|
|
}; |
|
39 |
|
|
40 |
|
|
41 |
struct reg_hotkey_s reg_hotkeys[] = { |
struct reg_hotkey_s reg_hotkeys[] = { |
55 |
#define WINPT_REG "Software\\WinPT" |
#define WINPT_REG "Software\\WinPT" |
56 |
|
|
57 |
|
|
58 |
|
/* Return != 0 if GPG4win is installed. */ |
59 |
|
int |
60 |
|
is_gpg4win_installed (void) |
61 |
|
{ |
62 |
|
char *p; |
63 |
|
|
64 |
|
p = get_reg_entry_gpg4win (NULL); |
65 |
|
if (!p) |
66 |
|
return 0; |
67 |
|
if (dir_exist_check (p)) { |
68 |
|
free_if_alloc (p); |
69 |
|
return 0; |
70 |
|
} |
71 |
|
free_if_alloc (p); |
72 |
|
return -1; |
73 |
|
} |
74 |
|
|
75 |
|
|
76 |
/* Return != 0 if GPGee is installed. */ |
/* Return != 0 if GPGee is installed. */ |
77 |
int |
int |
78 |
is_gpgee_installed (void) |
is_gpgee_installed (void) |
105 |
static int |
static int |
106 |
regist_single_filetype (gpg_filetype *gfile) |
regist_single_filetype (gpg_filetype *gfile) |
107 |
{ |
{ |
108 |
char icon[256], prog[256]; |
char icon[256]; |
109 |
|
char prog[256]; |
110 |
|
|
111 |
memset (&icon, 0, sizeof (icon)); |
memset (&icon, 0, sizeof (icon)); |
112 |
GetModuleFileName (glob_hinst, prog, sizeof (prog)-1); |
GetModuleFileName (glob_hinst, prog, sizeof (prog)-1); |
145 |
} |
} |
146 |
|
|
147 |
return 0; |
return 0; |
148 |
} /* regist_inst_gpg */ |
} |
149 |
|
|
150 |
|
|
151 |
/* Install WinPT into the W32 registry, if the entry already |
/* Install WinPT into the W32 registry, if the entry already |
155 |
Return value: 0 on success. */ |
Return value: 0 on success. */ |
156 |
int |
int |
157 |
regist_inst_winpt (int with_ext, int *created) |
regist_inst_winpt (int with_ext, int *created) |
158 |
{ |
{ |
159 |
HKEY reg; |
HKEY reg; |
160 |
char *p = NULL; |
char *p = NULL; |
161 |
char modpath[MAX_PATH+1]; |
char modpath[MAX_PATH+1]; |
162 |
int rc, i, id, n = 0; |
int rc, i, id, n = 0; |
163 |
|
|
164 |
|
gpg_filetype gpg_filetypes[] = { |
165 |
|
{_("GPG Detached Signature"), ".sig", 1}, |
166 |
|
{_("GPG Encrypted Data"), ".gpg", 2}, |
167 |
|
{_("GPG Armored Data"), ".asc", 2}, |
168 |
|
{0} |
169 |
|
}; |
170 |
|
|
171 |
if (created) |
if (created) |
172 |
*created = 0; |
*created = 0; |
173 |
|
|
217 |
} |
} |
218 |
free_if_alloc (p); |
free_if_alloc (p); |
219 |
if (n) |
if (n) |
220 |
set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1"); |
set_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1" ); |
221 |
return 0; |
return 0; |
222 |
} |
} |
223 |
rc = RegCreateKey (HKEY_CURRENT_USER, WINPT_REG, ®); |
rc = RegCreateKey (HKEY_CURRENT_USER, WINPT_REG, ®); |
226 |
if (created) |
if (created) |
227 |
*created = 1; |
*created = 1; |
228 |
RegCloseKey (reg); |
RegCloseKey (reg); |
229 |
if (n) |
if (n > 0 || is_gpgee_installed ()) |
230 |
set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1"); |
set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1"); |
231 |
if ((n=GetModuleFileName (NULL, modpath, MAX_PATH-1)) > 0) { |
if ((n=GetModuleFileName (NULL, modpath, MAX_PATH-1)) > 0) { |
232 |
while (n-- > 0) { |
while (n-- > 0) { |
244 |
/* Create a new filetype in the W32 registry. |
/* Create a new filetype in the W32 registry. |
245 |
We should really care of errors! Otherwise we can damage the registry! */ |
We should really care of errors! Otherwise we can damage the registry! */ |
246 |
int |
int |
247 |
create_file_type( const char *exefile, const char *ext, const char *extname, char *iconfile ) |
create_file_type (const char *exefile, const char *ext, |
248 |
|
const char *extname, char *iconfile) |
249 |
{ |
{ |
250 |
int rc; |
int rc; |
251 |
HKEY reg = NULL; |
HKEY reg = NULL; |
311 |
return NULL; |
return NULL; |
312 |
len += 1; |
len += 1; |
313 |
p = new char[len+1]; |
p = new char[len+1]; |
314 |
if( !p ) |
if (!p) |
315 |
return NULL; |
return NULL; |
316 |
len = ExpandEnvironmentStrings (path, p, len); |
len = ExpandEnvironmentStrings (path, p, len); |
317 |
if (!len) { |
if (!len) { |
319 |
return NULL; |
return NULL; |
320 |
} |
} |
321 |
return p; |
return p; |
322 |
} /* expand_path */ |
} |
323 |
|
|
324 |
|
|
325 |
/* Retrieve a registry entry with the directory given in @dir |
/* Retrieve a registry entry with the directory given in @dir |
332 |
char text[384] = {0}; |
char text[384] = {0}; |
333 |
DWORD nbytes, type; |
DWORD nbytes, type; |
334 |
HKEY reg_key = NULL; |
HKEY reg_key = NULL; |
335 |
char *p = NULL; |
char * p = NULL; |
336 |
|
|
337 |
rc = RegOpenKeyEx (root_key, dir, 0, KEY_QUERY_VALUE, ®_key); |
rc = RegOpenKeyEx (root_key, dir, 0, KEY_QUERY_VALUE, ®_key); |
338 |
if( !rc_ok( rc ) ) |
if( !rc_ok( rc ) ) |
418 |
} |
} |
419 |
|
|
420 |
|
|
|
|
|
|
|
|
421 |
int |
int |
422 |
set_reg_entry_mo (const char * value) |
set_reg_entry_mo (const char * value) |
423 |
{ |
{ |
512 |
int |
int |
513 |
get_reg_winpt_single (int id) |
get_reg_winpt_single (int id) |
514 |
{ |
{ |
515 |
char *buf = NULL; |
char * buf = NULL; |
516 |
int val = 0; |
int val = 0; |
517 |
|
|
518 |
buf = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[id]); |
buf = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[id]); |
587 |
if (rc) |
if (rc) |
588 |
goto leave; |
goto leave; |
589 |
} |
} |
|
if (opt->kserv_conf) { |
|
|
rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "KeyserverConfig", |
|
|
opt->kserv_conf); |
|
|
if (rc) |
|
|
goto leave; |
|
|
} |
|
590 |
|
|
591 |
for (i=0; reg_hotkeys[i].reg_entry; i++) { |
for (i=0; reg_hotkeys[i].reg_entry; i++) { |
592 |
strcpy (buf, " "); |
strcpy (buf, " "); |
697 |
if (val && val[0] != ' ') |
if (val && val[0] != ' ') |
698 |
opt->backup.path = m_strdup (val); |
opt->backup.path = m_strdup (val); |
699 |
free_if_alloc (val); |
free_if_alloc (val); |
|
|
|
|
val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "KeyserverConfig"); |
|
|
if (val && val[0] != ' ') |
|
|
opt->kserv_conf = m_strdup (val); |
|
|
free_if_alloc (val); |
|
700 |
|
|
701 |
for (i=0; reg_hotkeys[i].reg_entry; i++) { |
for (i=0; reg_hotkeys[i].reg_entry; i++) { |
702 |
val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, reg_hotkeys[i].reg_entry); |
val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, reg_hotkeys[i].reg_entry); |