45 |
int gpg_read_only = 0; |
int gpg_read_only = 0; |
46 |
char gpgver[3]; |
char gpgver[3]; |
47 |
|
|
|
/* Internal IPC */ |
|
|
int start_keymanager = 0; |
|
|
|
|
48 |
static void |
static void |
49 |
update_keycache (HWND hwnd) |
update_keycache (HWND hwnd) |
50 |
{ |
{ |
102 |
/* check if the default key from the gpg.conf file is available in the |
/* check if the default key from the gpg.conf file is available in the |
103 |
keyring. if not, bail out because encryption won't work properly then. */ |
keyring. if not, bail out because encryption won't work properly then. */ |
104 |
static int |
static int |
105 |
check_default_key (gpgme_keycache_t kc) |
check_default_key (gpg_keycache_t kc) |
106 |
{ |
{ |
107 |
gpgme_key_t key; |
gpgme_key_t key; |
108 |
gpgme_error_t err = GPG_ERR_NO_ERROR; |
gpgme_error_t err = GPG_ERR_NO_ERROR; |
110 |
|
|
111 |
defkey = get_gnupg_default_key (); |
defkey = get_gnupg_default_key (); |
112 |
if (defkey) |
if (defkey) |
113 |
err = gpgme_keycache_find_key (kc, defkey, 0, &key); |
err = gpg_keycache_find_key (kc, defkey, 0, &key); |
114 |
free_if_alloc (defkey); |
free_if_alloc (defkey); |
115 |
return err? -1 : 0; |
return err? -1 : 0; |
116 |
} /* check_default_key */ |
} /* check_default_key */ |
151 |
static int |
static int |
152 |
check_crypto_engine (void) |
check_crypto_engine (void) |
153 |
{ |
{ |
154 |
int ma=1, mi=4, pa=0; /* GPG 1.4.0 */ |
int ma=1, mi=4, pa=1; /* GPG 1.4.1 */ |
155 |
int rc; |
int rc; |
156 |
|
|
157 |
rc = check_gnupg_engine (&ma, &mi, &pa); |
rc = check_gnupg_engine (&ma, &mi, &pa); |
214 |
|
|
215 |
char* get_subkey_fingerprint (gpgme_ctx_t ctx, const char *keyid); |
char* get_subkey_fingerprint (gpgme_ctx_t ctx, const char *keyid); |
216 |
|
|
217 |
|
|
218 |
int WINAPI |
int WINAPI |
|
#ifndef WINPT_IPC |
|
219 |
WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd) |
WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd) |
|
#else |
|
|
win_main (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd) |
|
|
#endif |
|
220 |
{ |
{ |
221 |
WNDCLASS wc = {0, winpt_main_proc, 0, 0, hinst, 0, 0, 0, 0, PGM_NAME}; |
WNDCLASS wc = {0, winpt_main_proc, 0, 0, hinst, 0, 0, 0, 0, PGM_NAME}; |
222 |
HACCEL accel_tab; |
HACCEL accel_tab; |
286 |
_("GPG home directory is not set correctly.\n" |
_("GPG home directory is not set correctly.\n" |
287 |
"Please check the GPG registry settings:\n%s."), |
"Please check the GPG registry settings:\n%s."), |
288 |
winpt_strerror (rc)); |
winpt_strerror (rc)); |
289 |
const char * s = get_filename_dlg (GetActiveWindow (), FILE_OPEN, |
const char * s = get_fileopen_dlg (GetActiveWindow (), |
290 |
_("Select GPG Public Keyring"), |
_("Select GPG Public Keyring"), |
291 |
_("GPG Keyrings (*.gpg)\0*.gpg\0\0"), |
_("GPG Keyrings (*.gpg)\0*.gpg\0\0"), |
292 |
NULL); |
NULL); |
375 |
} |
} |
376 |
|
|
377 |
load_keyserver_conf (cmdline? 1 : 0); |
load_keyserver_conf (cmdline? 1 : 0); |
|
if (start_keymanager) { |
|
|
dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYMISC, |
|
|
GetDesktopWindow(), keymanager_dlg_proc, NULL, |
|
|
_("Key Manager"), IDS_WINPT_KEYMISC); |
|
|
keycache_release (); |
|
|
free_gnupg_table (); |
|
|
return 0; |
|
|
} |
|
378 |
|
|
379 |
if (cmdline && (stristr (cmdline, "--keymanager") |
if (cmdline && (stristr (cmdline, "--keymanager") |
380 |
|| stristr (cmdline, "--cardmanager"))) { |
|| stristr (cmdline, "--cardmanager"))) { |
384 |
GetDesktopWindow(), keymanager_dlg_proc, NULL, |
GetDesktopWindow(), keymanager_dlg_proc, NULL, |
385 |
_("Key Manager"), IDS_WINPT_KEYMISC); |
_("Key Manager"), IDS_WINPT_KEYMISC); |
386 |
else { |
else { |
387 |
gpg_card_t crd = smartcard_init (); |
gpg_card_t crd = gpg_card_load (); |
388 |
if (crd) |
if (crd) |
389 |
dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_CARD_EDIT, |
dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_CARD_EDIT, |
390 |
GetDesktopWindow(), card_edit_dlg_proc, |
GetDesktopWindow(), card_edit_dlg_proc, |
392 |
IDS_WINPT_CARD_EDIT); |
IDS_WINPT_CARD_EDIT); |
393 |
gpg_card_release (crd); |
gpg_card_release (crd); |
394 |
} |
} |
395 |
keycache_release (); |
keycache_release (0); |
396 |
free_gnupg_table (); |
free_gnupg_table (); |
397 |
return 0; |
return 0; |
398 |
} |
} |
492 |
check_crypto_engine (); |
check_crypto_engine (); |
493 |
} |
} |
494 |
else { |
else { |
495 |
gpgme_keycache_t c; |
gpg_keycache_t c; |
496 |
update_keycache (hwnd); |
update_keycache (hwnd); |
497 |
c = keycache_get_ctx (1); |
c = keycache_get_ctx (1); |
498 |
if (!c || !gpgme_keycache_count (c)) { |
if (!c || !gpg_keycache_get_size (c)) { |
499 |
gnupg_display_error (); |
gnupg_display_error (); |
500 |
msg_box (hwnd, _("The keycache was not initialized or is empty.\n" |
msg_box (hwnd, _("The keycache was not initialized or is empty.\n" |
501 |
"Please check your GPG config (keyrings, pathes...)"), |
"Please check your GPG config (keyrings, pathes...)"), |