36 |
|
|
37 |
#define rc_ok(rc) ((rc) == ERROR_SUCCESS) |
#define rc_ok(rc) ((rc) == ERROR_SUCCESS) |
38 |
|
|
39 |
|
#define WINPT_REG "Software\\WinPT" |
40 |
|
|
41 |
|
/* GPG file association context. */ |
42 |
|
struct gpg_filetype { |
43 |
|
const char *descr; |
44 |
|
const char *ext; |
45 |
|
int nicon; |
46 |
|
}; |
47 |
|
|
48 |
struct reg_hotkey_s reg_hotkeys[] = { |
struct reg_hotkey_s reg_hotkeys[] = { |
49 |
{"ClipEncrypt", "", 0}, |
{"ClipEncrypt", "", 0}, |
57 |
{NULL, "", 0} |
{NULL, "", 0} |
58 |
}; |
}; |
59 |
|
|
60 |
|
/* Global WinPT registry prefereneces. */ |
61 |
winpt_reg_prefs_s reg_prefs; |
winpt_reg_prefs_s reg_prefs; |
62 |
|
|
|
#define WINPT_REG "Software\\WinPT" |
|
|
|
|
63 |
|
|
64 |
/* Return != 0 if GPG4win is installed. */ |
/* Return != 0 if GPG4win is installed. */ |
65 |
int |
int |
165 |
HKEY reg; |
HKEY reg; |
166 |
char *p = NULL; |
char *p = NULL; |
167 |
char modpath[MAX_PATH+1]; |
char modpath[MAX_PATH+1]; |
168 |
int rc, i, id, n = 0; |
int rc, i, id, n; |
169 |
|
|
170 |
gpg_filetype gpg_filetypes[] = { |
gpg_filetype gpg_filetypes[] = { |
171 |
{_("GPG Detached Signature"), ".sig", 1}, |
{_("GPG Detached Signature"), ".sig", 1}, |
176 |
|
|
177 |
if (created) |
if (created) |
178 |
*created = 0; |
*created = 0; |
179 |
|
if (is_gpgee_installed ()) |
|
p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions"); |
|
|
if ((p && *p == '1') || is_gpgee_installed ()) |
|
180 |
with_ext = 0; |
with_ext = 0; |
|
free_if_alloc (p); |
|
181 |
|
|
|
if (with_ext) { |
|
|
id = msg_box (NULL, _("WinPT can register some GPG file types for you so they can " |
|
|
"be processed with a double click in the explorer.\n" |
|
|
"Do you want to continue?"), _("WinPT"), MB_YESNO|MB_INFO); |
|
|
if (id == IDNO) { |
|
|
set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1"); |
|
|
goto start; |
|
|
} |
|
|
for (i = 0; gpg_filetypes[i].ext; i++) { |
|
|
rc = RegOpenKeyEx (HKEY_CLASSES_ROOT, gpg_filetypes[i].ext, 0, KEY_READ, ®); |
|
|
if (rc_ok (rc)) { |
|
|
RegCloseKey (reg); |
|
|
id = log_box (_("WinPT WARNING"), MB_YESNO|MB_INFO, |
|
|
_("It seems there was already a '%s' file type registered by another application.\n" |
|
|
"Do you want to overwrite it?"), gpg_filetypes[i].ext); |
|
|
if (id == IDNO) |
|
|
continue; |
|
|
} |
|
|
regist_single_filetype (&gpg_filetypes[i]); |
|
|
n++; |
|
|
} |
|
|
} |
|
|
|
|
|
start: |
|
182 |
rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG, 0, KEY_READ, ®); |
rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG, 0, KEY_READ, ®); |
183 |
if (rc_ok (rc)) { |
if (rc_ok (rc)) { |
184 |
RegCloseKey (reg); |
RegCloseKey (reg); |
185 |
rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", 0, KEY_READ, ®); |
rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", 0, KEY_READ, ®); |
186 |
if( !rc_ok (rc)) { |
if (!rc_ok (rc)) { |
187 |
RegCreateKey (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", ®); |
RegCreateKey (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", ®); |
188 |
RegCloseKey (reg); |
RegCloseKey (reg); |
189 |
} |
} |
195 |
set_reg_entry_keyserver ("Default", DEF_HKP_KEYSERVER); |
set_reg_entry_keyserver ("Default", DEF_HKP_KEYSERVER); |
196 |
} |
} |
197 |
free_if_alloc (p); |
free_if_alloc (p); |
|
if (n) |
|
|
set_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1" ); |
|
198 |
return 0; |
return 0; |
199 |
} |
} |
200 |
rc = RegCreateKey (HKEY_CURRENT_USER, WINPT_REG, ®); |
rc = RegCreateKey (HKEY_CURRENT_USER, WINPT_REG, ®); |
203 |
if (created) |
if (created) |
204 |
*created = 1; |
*created = 1; |
205 |
RegCloseKey (reg); |
RegCloseKey (reg); |
206 |
if (n > 0 || is_gpgee_installed ()) |
if (with_ext) { |
207 |
set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1"); |
id = msg_box (NULL, _("WinPT can register some GPG file types for you so they can " |
208 |
|
"be processed with a double click in the explorer.\n" |
209 |
|
"Do you want to continue?"), _("WinPT"), MB_YESNO|MB_INFO); |
210 |
|
if (id == IDYES) { |
211 |
|
for (i = 0; gpg_filetypes[i].ext; i++) { |
212 |
|
rc = RegOpenKeyEx (HKEY_CLASSES_ROOT, gpg_filetypes[i].ext, 0, KEY_READ, ®); |
213 |
|
if (rc_ok (rc)) { |
214 |
|
RegCloseKey (reg); |
215 |
|
id = log_box (_("WinPT WARNING"), MB_YESNO|MB_INFO, |
216 |
|
_("It seems there was already a '%s' file type registered by another application.\n" |
217 |
|
"Do you want to overwrite it?"), gpg_filetypes[i].ext); |
218 |
|
if (id == IDNO) |
219 |
|
continue; |
220 |
|
} |
221 |
|
regist_single_filetype (&gpg_filetypes[i]); |
222 |
|
} |
223 |
|
} |
224 |
|
} |
225 |
if ((n=GetModuleFileName (NULL, modpath, MAX_PATH-1)) > 0) { |
if ((n=GetModuleFileName (NULL, modpath, MAX_PATH-1)) > 0) { |
226 |
while (n-- > 0) { |
while (n-- > 0) { |
227 |
if (modpath[n] == '\\') { |
if (modpath[n] == '\\') { |
420 |
} |
} |
421 |
|
|
422 |
|
|
423 |
char * |
char* |
424 |
get_reg_entry_gpg (const char *key) |
get_reg_entry_gpg (const char *key) |
425 |
{ |
{ |
426 |
return get_reg_entry (HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key); |
char *p; |
427 |
|
p = get_reg_entry (HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key); |
428 |
|
if (!p || strlen (p) == 0) { |
429 |
|
free_if_alloc (p); |
430 |
|
return NULL; |
431 |
|
} |
432 |
|
return p; |
433 |
} |
} |
434 |
|
|
435 |
|
|
479 |
|
|
480 |
|
|
481 |
/* All valid configuration commands. */ |
/* All valid configuration commands. */ |
482 |
static const char * cfg [] = { |
static const char *cfg [] = { |
483 |
NULL, |
NULL, |
484 |
"CacheTime", |
"CacheTime", |
485 |
"WordWrap", |
"WordWrap", |
486 |
"FastMode", |
"FastMode", |
487 |
"Viewer", |
"Viewer", |
488 |
"KeylistMode", |
"WipeMode", |
489 |
"WipeMode", |
"AlwaysTrust", |
490 |
"AlwaysTrust", |
"AutoBackup", |
491 |
"AutoBackup", |
"BackupMode", |
492 |
"BackupMode", |
"DisableHotkeys", |
493 |
"DisableHotkeys", |
"NoCompressMultiMedia", |
494 |
"NoCompressMultiMedia", |
"Expert", |
495 |
"Expert", |
"FMProgressBar", |
496 |
"FMProgressBar", |
}; |
|
}; |
|
497 |
|
|
498 |
|
|
499 |
int |
int |
552 |
case CFG_VIEWER: |
case CFG_VIEWER: |
553 |
sprintf (buf, "%d", opt->use_viewer); |
sprintf (buf, "%d", opt->use_viewer); |
554 |
break; |
break; |
|
case CFG_KEYLISTMODE: |
|
|
sprintf (buf, "%d", opt->keylist_mode); |
|
|
break; |
|
555 |
case CFG_ALWAYSTRUST: |
case CFG_ALWAYSTRUST: |
556 |
sprintf (buf, "%d", opt->always_trust); |
sprintf (buf, "%d", opt->always_trust); |
557 |
break; |
break; |
583 |
if (rc) |
if (rc) |
584 |
goto leave; |
goto leave; |
585 |
} |
} |
|
if (opt->kserv_conf) { |
|
|
rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "KeyserverConfig", |
|
|
opt->kserv_conf); |
|
|
if (rc) |
|
|
goto leave; |
|
|
} |
|
586 |
|
|
587 |
for (i=0; reg_hotkeys[i].reg_entry; i++) { |
for (i=0; reg_hotkeys[i].reg_entry; i++) { |
588 |
strcpy (buf, " "); |
strcpy (buf, " "); |
660 |
case CFG_VIEWER: |
case CFG_VIEWER: |
661 |
opt->use_viewer = atol (val); |
opt->use_viewer = atol (val); |
662 |
break; |
break; |
|
case CFG_KEYLISTMODE: |
|
|
opt->keylist_mode = atol (val); |
|
|
break; |
|
663 |
case CFG_WIPEMODE: |
case CFG_WIPEMODE: |
664 |
opt->wipe_mode = atol (val); |
opt->wipe_mode = atol (val); |
665 |
break; |
break; |
690 |
if (val && val[0] != ' ') |
if (val && val[0] != ' ') |
691 |
opt->backup.path = m_strdup (val); |
opt->backup.path = m_strdup (val); |
692 |
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); |
|
693 |
|
|
694 |
for (i=0; reg_hotkeys[i].reg_entry; i++) { |
for (i=0; reg_hotkeys[i].reg_entry; i++) { |
695 |
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); |