116 |
if (!path) |
if (!path) |
117 |
return NULL; |
return NULL; |
118 |
p = get_reg_entry_gpg ("OptFile"); |
p = get_reg_entry_gpg ("OptFile"); |
119 |
if (p && !strcmp (p, "")) { |
if (p) { |
120 |
nlen = strlen (path) + 64; |
nlen = strlen (p) + 4; |
|
optfile = new char[nlen + 1]; |
|
|
if (!optfile) |
|
|
BUG (0); |
|
|
_snprintf (optfile, nlen, "%s\\"GPG_CONF, path); |
|
|
} |
|
|
else if (p) { |
|
|
nlen = strlen( p ) + 4; |
|
121 |
optfile = new char[nlen + 1]; |
optfile = new char[nlen + 1]; |
122 |
if (!optfile) |
if (!optfile) |
123 |
BUG (NULL); |
BUG (NULL); |
243 |
o = find_option (opt, "ask-cert-level"); |
o = find_option (opt, "ask-cert-level"); |
244 |
if (o) |
if (o) |
245 |
reg_prefs.gpg.ask_cert_level = 1; |
reg_prefs.gpg.ask_cert_level = 1; |
246 |
|
o = find_option (opt, "ask-cert-expire"); |
247 |
|
if (o) |
248 |
|
reg_prefs.gpg.ask_cert_expire = 1; |
249 |
release_gpg_options (opt); |
release_gpg_options (opt); |
250 |
free_if_alloc (conf); |
free_if_alloc (conf); |
251 |
return 0; |
return 0; |
360 |
int rc = 1; |
int rc = 1; |
361 |
|
|
362 |
/* Convert the needed GPG version to the integer format. */ |
/* Convert the needed GPG version to the integer format. */ |
363 |
rc = parse_version_nr (need_gpg_ver, |
if (parse_version_nr (need_gpg_ver, |
364 |
&need_major, &need_minor, &need_patch); |
&need_major, &need_minor, &need_patch)) |
365 |
if (rc) |
return 1; |
|
return rc; |
|
366 |
|
|
367 |
gpgme_new (&ctx); |
gpgme_new (&ctx); |
368 |
inf = gpgme_ctx_get_engine_info (ctx); |
inf = gpgme_ctx_get_engine_info (ctx); |
377 |
if (strstr (eng, "IDEA")) |
if (strstr (eng, "IDEA")) |
378 |
idea_available = 1; |
idea_available = 1; |
379 |
free (eng); |
free (eng); |
380 |
rc = parse_version_nr (inf->version, &major, &minor, &patch); |
if (parse_version_nr (inf->version, &major, &minor, &patch)) { |
|
if (rc) { |
|
381 |
gpgme_release (ctx); |
gpgme_release (ctx); |
382 |
return rc; |
return 1; |
383 |
} |
} |
384 |
|
|
385 |
if (major > need_major) |
if (major > need_major) |
557 |
} /* get_gnupg_config */ |
} /* get_gnupg_config */ |
558 |
|
|
559 |
|
|
560 |
|
/* Set the default key in the gpg.conf. |
561 |
|
If @key is NULL, the entry will be deleted. */ |
562 |
int |
int |
563 |
set_gnupg_default_key (const char * key) |
set_gnupg_default_key (const char *key) |
564 |
{ |
{ |
565 |
gpg_optfile_t opt; |
gpg_optfile_t opt; |
566 |
gpg_option_t e; |
gpg_option_t e; |
569 |
|
|
570 |
optfile = get_gnupg_cfgfile (); |
optfile = get_gnupg_cfgfile (); |
571 |
if (!optfile) |
if (!optfile) |
572 |
return -1; |
return WPTERR_FILE_OPEN; |
573 |
rc = parse_gpg_options (optfile, &opt); |
rc = parse_gpg_options (optfile, &opt); |
574 |
if( rc ) { |
if (rc) { |
575 |
free_if_alloc (optfile); |
free_if_alloc (optfile); |
576 |
return -1; |
return WPTERR_GENERAL; |
577 |
} |
} |
578 |
e = find_option (opt, "default-key"); |
e = find_option (opt, "default-key"); |
579 |
if (e) { |
if (e && !key) |
580 |
|
e->used = 0; |
581 |
|
else if (e) { |
582 |
free_if_alloc (e->val); |
free_if_alloc (e->val); |
583 |
e->val = m_strdup (key); |
e->val = m_strdup (key); |
584 |
e->used = 1; |
e->used = 1; |
591 |
release_gpg_options (opt); |
release_gpg_options (opt); |
592 |
|
|
593 |
return rc; |
return rc; |
594 |
} /* set_gnupg_default_key */ |
} |
595 |
|
|
596 |
|
|
597 |
/* |
/* |
914 |
hwnd = GetDesktopWindow (); |
hwnd = GetDesktopWindow (); |
915 |
|
|
916 |
pring = get_fileopen_dlg (hwnd, _("Please choose your public keyring"), |
pring = get_fileopen_dlg (hwnd, _("Please choose your public keyring"), |
917 |
_("GPG Keyrings (*.gpg)\0*.gpg\0\0"),NULL); |
"GPG Keyrings (*.gpg)\0*.gpg\0\0",NULL); |
918 |
if (!pring) { |
if (!pring) { |
919 |
msg_box (hwnd, _("No keyring was chosen. Exit."), _("WinPT Error"), MB_ERR); |
msg_box (hwnd, _("No keyring was chosen. Exit."), _("WinPT Error"), MB_ERR); |
920 |
free_if_alloc (path); |
free_if_alloc (path); |
934 |
free_if_alloc (file); |
free_if_alloc (file); |
935 |
|
|
936 |
sring = get_fileopen_dlg (hwnd, _("Please choose your secret keyring"), |
sring = get_fileopen_dlg (hwnd, _("Please choose your secret keyring"), |
937 |
_("GPG Keyrings (*.gpg)\0*.gpg\0\0"), NULL); |
"GPG Keyrings (*.gpg)\0*.gpg\0\0", NULL); |
938 |
if (!sring) { |
if (!sring) { |
939 |
msg_box( NULL, _("No keyring was chosen. Exit."), _("WinPT Error"), MB_ERR ); |
msg_box( NULL, _("No keyring was chosen. Exit."), _("WinPT Error"), MB_ERR ); |
940 |
return WPTERR_GENERAL; |
return WPTERR_GENERAL; |
1111 |
void |
void |
1112 |
gnupg_display_error (void) |
gnupg_display_error (void) |
1113 |
{ |
{ |
1114 |
char tmpath[512], * errstr; |
char tmpath[512], *errstr; |
1115 |
size_t size = 0; |
size_t size = 0; |
1116 |
FILE * fp; |
FILE *fp; |
1117 |
|
|
1118 |
GetTempPath (sizeof tmpath - 32, (tmpath)); |
get_temp_name (tmpath, sizeof (tmpath), "gpg_stderr"); |
|
strcat (tmpath, "gpg_stderr"); |
|
1119 |
size = get_file_size (tmpath); |
size = get_file_size (tmpath); |
1120 |
if (file_exist_check (tmpath) || size <= 0) |
if (file_exist_check (tmpath) || size <= 0) |
1121 |
return; |
return; |