33 |
#include "wptTypes.h" |
#include "wptTypes.h" |
34 |
#include "wptNLS.h" |
#include "wptNLS.h" |
35 |
#include "wptVersion.h" |
#include "wptVersion.h" |
36 |
|
#include "wptHotkey.h" |
37 |
|
|
38 |
#define rc_ok(rc) ((rc) == ERROR_SUCCESS) |
#define rc_ok(rc) ((rc) == ERROR_SUCCESS) |
39 |
|
|
46 |
int nicon; |
int nicon; |
47 |
}; |
}; |
48 |
|
|
|
struct reg_hotkey_s reg_hotkeys[] = { |
|
|
{"ClipEncrypt", "", 0}, |
|
|
{"ClipDecrypt", "", 0}, |
|
|
{"ClipSign", "", 0}, |
|
|
{"ClipSignEnc", "", 0}, |
|
|
{"CwsEncrypt", "", 0}, |
|
|
{"CwsDecrypt", "", 0}, |
|
|
{"CwsSign", "", 0}, |
|
|
{"CwsSignEnc", "", 0}, |
|
|
{NULL, "", 0} |
|
|
}; |
|
|
|
|
49 |
/* Global WinPT registry prefereneces. */ |
/* Global WinPT registry prefereneces. */ |
50 |
winpt_reg_prefs_s reg_prefs; |
winpt_reg_prefs_s reg_prefs; |
51 |
|
|
573 |
goto leave; |
goto leave; |
574 |
} |
} |
575 |
|
|
576 |
for (i=0; reg_hotkeys[i].reg_entry; i++) { |
for (i=0; wpt_hotkeys[i].name; i++) { |
577 |
strcpy (buf, " "); |
if (wpt_hotkeys[i].enabled) { |
578 |
if (reg_hotkeys[i].enabled) |
buf[0] = wpt_hotkeys[i].key; |
579 |
strcpy (buf, reg_hotkeys[i].key); |
buf[1] = 0; |
580 |
|
} |
581 |
|
else |
582 |
|
strcpy (buf, " "); |
583 |
rc = set_reg_key (HKEY_CURRENT_USER, WINPT_REG, |
rc = set_reg_key (HKEY_CURRENT_USER, WINPT_REG, |
584 |
reg_hotkeys[i].reg_entry, buf); |
wpt_hotkeys[i].name, buf); |
585 |
if (rc) |
if (rc) |
586 |
break; |
break; |
587 |
} |
} |
634 |
switch (i) { |
switch (i) { |
635 |
case CFG_CACHETIME: |
case CFG_CACHETIME: |
636 |
opt->cache_time = atol (val); |
opt->cache_time = atol (val); |
|
/* We do NOT support passphrase caching for more than an hour. |
|
|
* Perhaps we should allow it, but for now we silently drop this. |
|
|
*/ |
|
|
if (opt->cache_time > 3600) |
|
|
opt->cache_time = 3600; |
|
637 |
break; |
break; |
638 |
case CFG_WORDWRAP: |
case CFG_WORDWRAP: |
639 |
opt->word_wrap = atol (val); |
opt->word_wrap = atol (val); |
665 |
case CFG_EXPERT: |
case CFG_EXPERT: |
666 |
opt->expert = atol (val); |
opt->expert = atol (val); |
667 |
break; |
break; |
|
|
|
668 |
case CFG_FM_PROGRESS: |
case CFG_FM_PROGRESS: |
669 |
opt->fm.progress = atol (val); |
opt->fm.progress = atol (val); |
670 |
break; |
break; |
677 |
opt->backup.path = m_strdup (val); |
opt->backup.path = m_strdup (val); |
678 |
free_if_alloc (val); |
free_if_alloc (val); |
679 |
|
|
680 |
for (i=0; reg_hotkeys[i].reg_entry; i++) { |
for (i=0; wpt_hotkeys[i].name; i++) { |
681 |
val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, reg_hotkeys[i].reg_entry); |
wpt_hotkeys[i].enabled = 0; |
682 |
|
val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, wpt_hotkeys[i].name); |
683 |
if (val && val[0] != ' ') { |
if (val && val[0] != ' ') { |
684 |
reg_hotkeys[i].key[0] = *val; |
wpt_hotkeys[i].key = *val; |
685 |
reg_hotkeys[i].enabled = 1; |
wpt_hotkeys[i].enabled = 1; |
686 |
} |
} |
|
else |
|
|
reg_hotkeys[i].enabled = 0; |
|
687 |
free_if_alloc (val); |
free_if_alloc (val); |
688 |
} |
} |
689 |
return 0; |
return 0; |
690 |
} /* get_reg_winpt_prefs */ |
} |
691 |
|
|
692 |
|
|
693 |
char* |
char* |
702 |
} |
} |
703 |
|
|
704 |
|
|
705 |
|
int |
706 |
|
set_reg_entry_keyserver (const char * name, const char * val) |
707 |
|
{ |
708 |
|
return set_reg_entry( HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", name, val ); |
709 |
|
} |
710 |
|
|
711 |
|
static int |
712 |
|
get_reg_entry_keyserver_int (const char *key) |
713 |
|
{ |
714 |
|
char *p; |
715 |
|
int val; |
716 |
|
|
717 |
|
p = get_reg_entry_keyserver (key); |
718 |
|
if (p && *p) |
719 |
|
val = atoi (p); |
720 |
|
free_if_alloc (p); |
721 |
|
return val; |
722 |
|
} |
723 |
|
|
724 |
|
|
725 |
void |
void |
726 |
get_reg_proxy_prefs (char ** host, int * port, char ** user, char ** pass) |
get_reg_proxy_prefs (keyserver_proxy_t prox) |
727 |
{ |
{ |
728 |
if (host) |
if (!prox) |
729 |
*host = get_reg_entry_keyserver ("Host"); |
return; |
730 |
if (user) |
|
731 |
*user = get_reg_entry_keyserver ("User"); |
free_if_alloc (prox->host); |
732 |
if (pass) |
prox->host = get_reg_entry_keyserver ("Host"); |
733 |
*pass = get_reg_entry_keyserver ("Pass"); |
free_if_alloc (prox->user); |
734 |
if (port) { |
prox->user = get_reg_entry_keyserver ("User"); |
735 |
char * p = get_reg_entry_keyserver ("Port"); |
free_if_alloc (prox->pass); |
736 |
if (p) { |
prox->pass = get_reg_entry_keyserver ("Pass"); |
737 |
*port = atol (p); |
prox->port = get_reg_entry_keyserver_int ("Port"); |
738 |
free_if_alloc (p); |
} |
|
} |
|
|
} |
|
|
} /* get_reg_proxy_prefs */ |
|
739 |
|
|
740 |
|
|
741 |
int |
static int |
742 |
set_reg_entry_keyserver( const char * name, const char * val ) |
set_reg_entry_keyserver_int (const char *key, int val) |
743 |
{ |
{ |
744 |
return set_reg_entry( HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", name, val ); |
char buf[32]; |
745 |
} /* set_reg_entry_keyserver */ |
|
746 |
|
sprintf (buf, "%d", val); |
747 |
|
return set_reg_entry_keyserver (key, buf); |
748 |
|
} |
749 |
|
|
750 |
|
|
751 |
int |
int |
752 |
set_reg_proxy_prefs( const char * host, int port, const char * user, const char * pass ) |
set_reg_proxy_prefs (keyserver_proxy_t prox) |
753 |
{ |
{ |
754 |
int rc; |
int rc; |
755 |
|
|
756 |
rc = set_reg_entry_keyserver( "Host", host? host : "" ); |
rc = set_reg_entry_keyserver_int ("Proto", prox->proto); |
757 |
if( !rc ) { |
if (!rc) |
758 |
char buf[32]; |
rc = set_reg_entry_keyserver ("Host", prox->host? prox->host : ""); |
759 |
sprintf( buf, "%d", port ); |
if (!rc) |
760 |
rc = set_reg_entry_keyserver( "Port", buf ); |
rc = set_reg_entry_keyserver_int ("Port", prox->port); |
761 |
} |
if (!rc) |
762 |
if( !rc ) |
rc = set_reg_entry_keyserver ("User", prox->user? prox->user : ""); |
763 |
rc = set_reg_entry_keyserver( "User", user? user : "" ); |
if (!rc) |
764 |
if( !rc ) |
rc = set_reg_entry_keyserver ("Pass", prox->pass? prox->pass : ""); |
|
rc = set_reg_entry_keyserver( "Pass", pass? pass : "" ); |
|
765 |
return rc; |
return rc; |
766 |
} /* set_reg_proxy_prefs */ |
} |