18 |
* along with WinPT; if not, write to the Free Software Foundation, |
* along with WinPT; if not, write to the Free Software Foundation, |
19 |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 |
*/ |
*/ |
21 |
|
|
22 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
23 |
#include <config.h> |
#include <config.h> |
24 |
#endif |
#endif |
25 |
|
|
26 |
#include <windows.h> |
#include <windows.h> |
|
#include <windows.h> |
|
27 |
#include <commctrl.h> |
#include <commctrl.h> |
28 |
#include <stdio.h> |
#include <stdio.h> |
29 |
|
|
30 |
#include "gpgme.h" |
#include "gpgme.h" |
31 |
#include "../resource.h" |
#include "resource.h" |
32 |
#include "wptTypes.h" |
#include "wptTypes.h" |
33 |
#include "wptW32API.h" |
#include "wptW32API.h" |
34 |
#include "wptVersion.h" |
#include "wptVersion.h" |
46 |
#include "wptHTTP.h" |
#include "wptHTTP.h" |
47 |
#include "wptKeyEdit.h" |
#include "wptKeyEdit.h" |
48 |
#include "wptImport.h" |
#include "wptImport.h" |
49 |
|
#include "wptCrypto.h" |
50 |
|
#include "wptUTF8.h" |
51 |
|
|
52 |
|
|
53 |
|
/* Macros to change the cursor */ |
54 |
|
#define op_begin() SetCursor (LoadCursor (NULL, IDC_WAIT)) |
55 |
|
#define op_end() SetCursor (LoadCursor (NULL, IDC_ARROW)) |
56 |
|
|
57 |
|
|
58 |
/* Return a user friendly key representation in @buf of |
/* Return a user friendly key representation in @buf of |
61 |
key_get_clip_info (const char *keyid, char *buf, size_t buflen) |
key_get_clip_info (const char *keyid, char *buf, size_t buflen) |
62 |
{ |
{ |
63 |
gpgme_key_t pk; |
gpgme_key_t pk; |
64 |
|
char *uid; |
65 |
|
|
66 |
if (get_pubkey (keyid, &pk)) |
if (get_pubkey (keyid, &pk)) |
67 |
BUG (NULL); |
BUG (NULL); |
68 |
|
uid = utf8_to_wincp2 (pk->uids->uid); |
69 |
_snprintf (buf, buflen-1, |
_snprintf (buf, buflen-1, |
70 |
"pub %04d%s/%s %s %s\r\n" |
"pub %04d%s/%s %s %s\r\n" |
71 |
" Primary key fingerprint: %s\r\n", |
" Primary key fingerprint: %s\r\n", |
72 |
pk->subkeys->length, |
pk->subkeys->length, |
73 |
get_key_pubalgo (pk->subkeys->pubkey_algo), |
get_key_pubalgo2 (pk->subkeys->pubkey_algo), |
74 |
pk->subkeys->keyid+8, |
pk->subkeys->keyid+8, |
75 |
get_key_created (pk->subkeys->timestamp), |
get_key_created (pk->subkeys->timestamp), |
76 |
pk->uids->uid, |
uid, |
77 |
get_key_fpr (pk)); |
get_key_fpr (pk)); |
78 |
|
safe_free (uid); |
79 |
|
} |
80 |
|
|
81 |
|
|
82 |
|
/* Return a general description of the key @key. */ |
83 |
|
static char* |
84 |
|
key_get_info (gpgme_key_t pk, int is_sec) |
85 |
|
{ |
86 |
|
const char *fmt = "%s %04d%s/0x%s %s\n \"%s\""; |
87 |
|
char *p, *uid; |
88 |
|
int n; |
89 |
|
|
90 |
|
n = strlen (fmt) + 8 + 2 + 16 + 12 + strlen (pk->uids->uid) + 32; |
91 |
|
p = new char[n+1]; |
92 |
|
if (!p) |
93 |
|
BUG (NULL); |
94 |
|
uid = utf8_to_wincp2 (pk->uids->uid); |
95 |
|
_snprintf (p, n, fmt, is_sec? "sec" : "pub", |
96 |
|
pk->subkeys->length, |
97 |
|
get_key_pubalgo2 (pk->subkeys->pubkey_algo), |
98 |
|
pk->subkeys->keyid+8, get_key_created (pk->subkeys->timestamp), |
99 |
|
uid); |
100 |
|
safe_free (uid); |
101 |
|
return p; |
102 |
} |
} |
103 |
|
|
104 |
|
|
128 |
int |
int |
129 |
km_check_for_seckey (listview_ctrl_t lv, int pos, int *utrust) |
km_check_for_seckey (listview_ctrl_t lv, int pos, int *utrust) |
130 |
{ |
{ |
131 |
char t[32], t2[64]; |
gpgme_key_t key; |
132 |
|
winpt_key_s sk; |
133 |
int type = 0; |
int type = 0; |
134 |
|
|
135 |
|
key = (gpgme_key_t)listview_get_item2 (lv, pos); |
136 |
|
if (!key) |
137 |
|
BUG (NULL); |
138 |
if (utrust) |
if (utrust) |
139 |
*utrust = 0; |
*utrust = 0; |
140 |
listview_get_item_text (lv, pos, 5, t, DIM (t)-1); |
memset (&sk, 0, sizeof (sk)); |
141 |
listview_get_item_text (lv, pos, 2, t2, DIM (t2)-1); |
if (!winpt_get_seckey (key->subkeys->keyid+8, &sk)) |
|
if (!strcmp (t2, "pub/sec")) |
|
142 |
type = 1; |
type = 1; |
143 |
else if (!strcmp (t2, "pub/crd")) |
if (sk.ext && sk.ext->gloflags.divert_to_card) |
144 |
type = 2; |
type = 2; |
145 |
if ((strstr (t, "Expired") || strstr (t, "Revoked")) && utrust) |
if (utrust && (key->expired || key->revoked)) |
146 |
*utrust = -1; |
*utrust = -1; |
147 |
else if (stristr (t, "Ultimate") && utrust) |
else if (utrust && key->owner_trust == GPGME_VALIDITY_ULTIMATE) |
148 |
*utrust = 1; |
*utrust = 1; |
149 |
return type; |
return type; |
150 |
} |
} |
165 |
} |
} |
166 |
|
|
167 |
|
|
168 |
|
/* Check if the key has a good status. |
169 |
|
Return value: 0 on success. */ |
170 |
int |
int |
171 |
km_check_key_status (listview_ctrl_t lv, int pos) |
km_check_key_status (listview_ctrl_t lv, int pos) |
172 |
{ |
{ |
184 |
} |
} |
185 |
|
|
186 |
return 0; |
return 0; |
187 |
} /* km_check_key_status */ |
} |
188 |
|
|
189 |
|
|
190 |
|
/* Return all key flags ORed. */ |
191 |
int |
int |
192 |
km_get_key_status (listview_ctrl_t lv, int pos) |
km_get_key_status (listview_ctrl_t lv, int pos) |
193 |
{ |
{ |
207 |
if (key->disabled) |
if (key->disabled) |
208 |
flags |= KM_FLAG_DISABLED; |
flags |= KM_FLAG_DISABLED; |
209 |
return flags; |
return flags; |
210 |
} /* km_get_key_status */ |
} |
211 |
|
|
212 |
|
|
213 |
/* Interface to enable or disable a key (@enable = 1 then enable). |
/* Interface to enable or disable a key (@enable = 1 then enable). |
215 |
int |
int |
216 |
km_enable_disable_key (listview_ctrl_t lv, HWND dlg, int pos, int enable) |
km_enable_disable_key (listview_ctrl_t lv, HWND dlg, int pos, int enable) |
217 |
{ |
{ |
|
GpgKeyEdit *ke; |
|
218 |
gpgme_error_t err; |
gpgme_error_t err; |
219 |
char keyid[32]; |
gpgme_key_t key; |
220 |
|
GpgKeyEdit *ke; |
|
listview_get_item_text (lv, pos, 1, keyid, DIM (keyid)-1); |
|
221 |
|
|
222 |
ke = new GpgKeyEdit (keyid); |
key = (gpgme_key_t)listview_get_item2 (lv, pos); |
223 |
|
if (!key) |
224 |
|
BUG (NULL); |
225 |
|
ke = new GpgKeyEdit (key->subkeys->keyid); |
226 |
if (!ke) |
if (!ke) |
227 |
BUG (NULL); |
BUG (NULL); |
228 |
|
|
229 |
err = enable? ke->enable () : ke->disable (); |
err = enable? ke->enable () : ke->disable (); |
230 |
if (!err) { |
if (!err) |
231 |
show_msg (dlg, 1500, _("Key status changed.")); |
show_msg (dlg, 1500, _("Key status changed.")); |
|
keycache_set_reload (1); /* XXX: set update flag */ |
|
|
} |
|
232 |
else |
else |
233 |
msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR); |
234 |
delete ke; |
delete ke; |
308 |
|
|
309 |
rset = keylist_enum_recipients (lv, KEYLIST_LIST, &n); |
rset = keylist_enum_recipients (lv, KEYLIST_LIST, &n); |
310 |
if (!n) { |
if (!n) { |
311 |
msg_box (dlg, _("No key was selected for export."), _("Key Manager"), MB_ERR); |
msg_box (dlg, _("No key was selected for export."), |
312 |
rc = WPTERR_GENERAL; |
_("Key Manager"), MB_ERR); |
313 |
|
rc = WPTERR_GENERAL; |
314 |
goto leave; |
goto leave; |
315 |
} |
} |
316 |
|
|
330 |
leave: |
leave: |
331 |
free (rset); |
free (rset); |
332 |
return rc; |
return rc; |
333 |
} /* km_clip_export */ |
} |
334 |
|
|
335 |
|
|
336 |
/* Export the selected secret key from @lv into @fname. |
/* Export the selected secret key from @lv into @fname. |
367 |
} |
} |
368 |
|
|
369 |
|
|
370 |
|
/* Export the selected recipients from @lv into the file @fname. */ |
371 |
int |
int |
372 |
km_file_export (HWND dlg, listview_ctrl_t lv, const char * fname) |
km_file_export (HWND dlg, listview_ctrl_t lv, const char *fname) |
373 |
{ |
{ |
374 |
gpgme_key_t *rset; |
gpgme_key_t *rset; |
375 |
gpgme_data_t keydata; |
gpgme_data_t keydata; |
396 |
/*gpgme_set_comment (ctx, "Generated by WinPT "PGM_VERSION);*/ |
/*gpgme_set_comment (ctx, "Generated by WinPT "PGM_VERSION);*/ |
397 |
patt = gpg_keylist_to_pattern (rset, n); |
patt = gpg_keylist_to_pattern (rset, n); |
398 |
|
|
399 |
err = gpgme_op_export( ctx, patt, 0, keydata); |
err = gpgme_op_export (ctx, patt, 0, keydata); |
400 |
if( err ) { |
if( err ) { |
401 |
msg_box( dlg, gpgme_strerror( err ), _("Key Manager"), MB_ERR ); |
msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR); |
402 |
goto leave; |
goto leave; |
403 |
} |
} |
404 |
|
|
405 |
log_box( _("Key Manager"), MB_OK, |
log_box (_("Key Manager"), MB_OK, |
406 |
_("Key(s) successfully saved in '%s'."), fname ); |
_("Key(s) successfully saved in '%s'."), fname); |
407 |
|
|
408 |
leave: |
leave: |
409 |
err = gpg_data_release_and_set_file( keydata, fname ); |
err = gpg_data_release_and_set_file (keydata, fname); |
410 |
if (err) |
if (err) |
411 |
log_box (_("Key Manager"), MB_OK, |
log_box (_("Key Manager"), MB_OK, |
412 |
_("Could not save data to '%s'."), fname); |
_("Could not save data to '%s'."), fname); |
413 |
gpgme_release (ctx); |
gpgme_release (ctx); |
414 |
free (patt); |
free (patt); |
415 |
return (int)err; |
return (int)err; |
416 |
} /* km_file_export */ |
} |
417 |
|
|
418 |
|
|
419 |
|
/* Read a dash escaped key from the clipboard |
420 |
|
unescape it and write it back. */ |
421 |
static int |
static int |
422 |
extract_dash_escaped_key (void) |
extract_dash_escaped_key (void) |
423 |
{ |
{ |
426 |
|
|
427 |
err = gpg_data_new_from_clipboard (&inp, 0); |
err = gpg_data_new_from_clipboard (&inp, 0); |
428 |
if (err) { |
if (err) { |
429 |
msg_box (NULL, gpgme_strerror( err ), _("Key Manager"), MB_ERR); |
msg_box (NULL, gpgme_strerror (err), _("Key Manager"), MB_ERR); |
430 |
return -1; |
return -1; |
431 |
} |
} |
432 |
gpg_data_extract_plaintext (inp, &plain); |
gpg_data_extract_plaintext (inp, &plain); |
434 |
gpgme_data_release (inp); |
gpgme_data_release (inp); |
435 |
|
|
436 |
return 0; |
return 0; |
437 |
} /* extract_dash_escaped_key */ |
} |
438 |
|
|
439 |
|
|
440 |
/* Import keys from the clipboard. */ |
/* Import keys from the clipboard. */ |
447 |
int has_data = 0; |
int has_data = 0; |
448 |
|
|
449 |
if (!gpg_clip_istext_avail (&has_data) && !has_data) { |
if (!gpg_clip_istext_avail (&has_data) && !has_data) { |
450 |
msg_box( dlg, winpt_strerror (WPTERR_CLIP_ISEMPTY), _("Key Manager"), MB_ERR); |
msg_box (dlg, winpt_strerror (WPTERR_CLIP_ISEMPTY), |
451 |
|
_("Key Manager"), MB_ERR); |
452 |
return WPTERR_CLIP_ISEMPTY; |
return WPTERR_CLIP_ISEMPTY; |
453 |
} |
} |
454 |
err = gpg_clip_is_secured (&pgptype, &has_data); |
err = gpg_clip_is_secured (&pgptype, &has_data); |
455 |
if (err) |
if (err) |
456 |
msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR); |
457 |
if (!has_data) { |
if (!has_data) { |
458 |
msg_box (dlg, _("No valid OpenPGP data found."), _("Key Manager"), MB_ERR); |
msg_box (dlg, _("No valid OpenPGP data found."), |
459 |
|
_("Key Manager"), MB_ERR); |
460 |
return WPTERR_GENERAL; |
return WPTERR_GENERAL; |
461 |
} |
} |
462 |
if (!(pgptype & PGP_PUBKEY) && !(pgptype & PGP_SECKEY)) { |
if (!(pgptype & PGP_PUBKEY) && !(pgptype & PGP_SECKEY)) { |
463 |
msg_box (dlg, _("No valid OpenPGP keys found."), _("Key Manager"), MB_ERR); |
msg_box (dlg, _("No valid OpenPGP keys found."), |
464 |
|
_("Key Manager"), MB_ERR); |
465 |
return WPTERR_GENERAL; |
return WPTERR_GENERAL; |
466 |
} |
} |
467 |
if (pgptype & PGP_DASH_ESCAPED) { |
if (pgptype & PGP_DASH_ESCAPED) { |
476 |
} |
} |
477 |
|
|
478 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_IMPORT, dlg, |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_IMPORT, dlg, |
479 |
clip_import_dlg_proc, NULL, |
clip_import_dlg_proc, 0, |
480 |
_("Key Import"), IDS_WINPT_IMPORT); |
_("Key Import"), IDS_WINPT_IMPORT); |
481 |
|
|
482 |
return 0; |
return 0; |
506 |
fp = fopen (p, "wb"); |
fp = fopen (p, "wb"); |
507 |
if (!fp) { |
if (!fp) { |
508 |
free_if_alloc (p); |
free_if_alloc (p); |
509 |
log_box (_("Key Import HTTP"), MB_ERR, "%s: %s", p, winpt_strerror (WPTERR_FILE_CREAT)); |
log_box (_("Key Import HTTP"), MB_ERR, "%s: %s", p, |
510 |
|
winpt_strerror (WPTERR_FILE_CREAT)); |
511 |
return WPTERR_FILE_CREAT; |
return WPTERR_FILE_CREAT; |
512 |
} |
} |
513 |
|
|
524 |
rc = WPTERR_GENERAL; |
rc = WPTERR_GENERAL; |
525 |
} |
} |
526 |
km_file_import (dlg, p); |
km_file_import (dlg, p); |
527 |
unlink (p); |
remove (p); |
528 |
free_if_alloc (p); |
free_if_alloc (p); |
529 |
return rc; |
return rc; |
530 |
} |
} |
562 |
goto leave; |
goto leave; |
563 |
} |
} |
564 |
|
|
565 |
SetCursor (LoadCursor (NULL, IDC_WAIT)); |
op_begin (); |
566 |
err = gpgme_op_import (ctx, keydata); |
err = gpgme_op_import (ctx, keydata); |
567 |
SetCursor (LoadCursor (NULL, IDC_ARROW)); |
op_end (); |
568 |
if (err) { |
if (err) { |
569 |
msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR); |
570 |
goto leave; |
goto leave; |
576 |
if (res->secret_imported == 0 && fm_stat.import.has_seckey == 1) |
if (res->secret_imported == 0 && fm_stat.import.has_seckey == 1) |
577 |
res->secret_imported = 1; |
res->secret_imported = 1; |
578 |
|
|
579 |
|
/* XXX: if we import a key pair but the secret key comes first, |
580 |
|
no_{valid}_user_id is 1 even so the public key, which comes |
581 |
|
later is valid and self-signed. */ |
582 |
print_import_status (res); |
print_import_status (res); |
583 |
if (res->no_user_id > 0) { |
if (res->no_user_id > 0) { |
584 |
msg_box (dlg, _("Key without a self signature was dectected!\n" |
msg_box (dlg, _("Key without a self signature was dectected!\n" |
613 |
{ |
{ |
614 |
gpgme_error_t err; |
gpgme_error_t err; |
615 |
gpgme_ctx_t ctx; |
gpgme_ctx_t ctx; |
616 |
gpgme_key_t *rset, k; |
gpgme_key_t *rset; |
617 |
char keyid[32], uid[256], date[64], keylen[64]; |
gpgme_key_t key; |
618 |
|
char keyid[32]; |
619 |
|
char *p; |
620 |
int with_seckey=0, seckey_type=0, confirm=0; |
int with_seckey=0, seckey_type=0, confirm=0; |
621 |
int i, rc, n, k_pos=0; |
int i, rc, n, k_pos=0; |
622 |
|
|
623 |
if (listview_get_curr_pos (lv) == -1) { |
if (listview_get_curr_pos (lv) == -1) { |
624 |
msg_box (dlg, _("Please select a key."), _("Key Manager"), MB_ERR); |
msg_box (dlg, _("Please select a key."), _("Key Manager"), MB_ERR); |
625 |
return WPTERR_GENERAL; |
return -1; |
626 |
} |
} |
627 |
|
|
628 |
if (listview_count_items (lv, 1) > 8) { |
if (listview_count_items (lv, 1) > 8) { |
640 |
rset = (gpgme_key_t *)calloc (n+1, sizeof (gpgme_key_t)); |
rset = (gpgme_key_t *)calloc (n+1, sizeof (gpgme_key_t)); |
641 |
if (!rset) |
if (!rset) |
642 |
BUG (NULL); |
BUG (NULL); |
643 |
for( i = 0; i < n; i++ ) { |
for (i = 0; i < n; i++) { |
644 |
if( listview_get_item_state( lv, i ) ) { |
if (listview_get_item_state(lv, i)) { |
645 |
listview_get_item_text( lv, i, 0, uid, sizeof uid - 1 ); |
key = (gpgme_key_t)listview_get_item2 (lv, i); |
646 |
listview_get_item_text( lv, i, 1, keyid, sizeof keyid - 1 ); |
if (!key) |
647 |
listview_get_item_text( lv, i, 3, keylen, sizeof keylen - 1 ); |
BUG (NULL); |
|
listview_get_item_text( lv, i, 7, date, sizeof date - 1 ); |
|
648 |
seckey_type = km_check_for_seckey (lv, i, NULL); |
seckey_type = km_check_for_seckey (lv, i, NULL); |
649 |
if (confirm && !seckey_type) { |
if (confirm && !seckey_type) { |
650 |
|
p = key_get_info (key, 0); |
651 |
rc = log_box( _("Key Manager"), MB_YESNO|MB_ICONWARNING, |
rc = log_box( _("Key Manager"), MB_YESNO|MB_ICONWARNING, |
652 |
_("Do you really want to delete this key?\n\n" |
_("Do you really want to delete this key?\n\n" |
653 |
"pub %s %s %s\n" |
"%s"), p); |
654 |
" \"%s\""), keylen, keyid, date, uid ); |
if (rc == IDYES) |
655 |
if (rc == IDYES) { |
rset[k_pos++] = key; |
|
get_pubkey (keyid, &k); |
|
|
rset[k_pos++] = k; |
|
|
} |
|
656 |
with_seckey = 0; |
with_seckey = 0; |
657 |
|
free_if_alloc (p); |
658 |
} |
} |
659 |
else if (confirm) { |
else if (confirm) { |
660 |
rc = log_box( _("Key Manager"), MB_YESNO|MB_ICONWARNING, |
p = key_get_info (key, 1); |
661 |
|
rc = log_box (_("Key Manager"), MB_YESNO|MB_ICONWARNING, |
662 |
_("Do you really want to delete this KEY PAIR?\n\n" |
_("Do you really want to delete this KEY PAIR?\n\n" |
663 |
"Please remember that you are not able to decrypt\n" |
"Please remember that you are not able to decrypt\n" |
664 |
"messages you stored with this key any longer.\n" |
"messages you stored with this key any longer.\n" |
665 |
"\n" |
"\n" |
666 |
"pub/sec %s %s %s\n" |
"%s"), p); |
|
" \"%s\""), keylen, keyid, date, uid ); |
|
667 |
if( rc == IDYES ) { |
if( rc == IDYES ) { |
668 |
if (seckey_type == 2) |
if (seckey_type == 2) |
669 |
msg_box( dlg, _("The actual secret key is stored on a smartcard.\n" |
msg_box (dlg, _("The actual secret key is stored on a smartcard.\n" |
670 |
"Only the public key and the secret key \n" |
"Only the public key and the secret key \n" |
671 |
"placeholder will be deleted.\n"), _("Key Manager"), MB_OK ); |
"placeholder will be deleted.\n"), |
672 |
get_pubkey (keyid, &k); |
_("Key Manager"), MB_OK); |
673 |
rset[k_pos++] = k; |
rset[k_pos++] = key; |
674 |
} |
} |
675 |
with_seckey = 1; |
with_seckey = 1; |
676 |
|
free_if_alloc (p); |
677 |
} |
} |
678 |
else { |
else { |
679 |
with_seckey = 1; |
with_seckey = 1; |
680 |
get_pubkey (keyid, &k); |
get_pubkey (keyid, &key); |
681 |
rset[k_pos++] = k; |
rset[k_pos++] = key; |
682 |
} |
} |
683 |
} |
} |
684 |
} |
} |
691 |
err = gpgme_new (&ctx); |
err = gpgme_new (&ctx); |
692 |
if (err) |
if (err) |
693 |
BUG (NULL); |
BUG (NULL); |
694 |
n=k_pos; |
n = k_pos; |
695 |
|
op_begin (); |
696 |
for (i=0; i < k_pos; i++) { |
for (i=0; i < k_pos; i++) { |
697 |
err = gpgme_op_delete (ctx, rset[i], with_seckey); |
err = gpgme_op_delete (ctx, rset[i], with_seckey); |
698 |
if (err) |
if (err) |
700 |
else |
else |
701 |
n--; |
n--; |
702 |
} |
} |
703 |
|
op_end (); |
704 |
if (n == 0) |
if (n == 0) |
705 |
show_msg (dlg, 1500, _("GnuPG Status: Finished")); |
show_msg (dlg, 1500, _("GnuPG Status: Finished")); |
706 |
gpgme_release (ctx); |
gpgme_release (ctx); |
707 |
listview_del_items (lv); |
listview_del_items (lv); |
708 |
delete_keys_from_cache (rset, k_pos); |
delete_keys_from_cache (rset, k_pos); |
712 |
} |
} |
713 |
|
|
714 |
|
|
715 |
|
/* Send the select key in @lv to the keyserver @host:@port. */ |
716 |
int |
int |
717 |
km_send_to_keyserver (listview_ctrl_t lv, HWND dlg, const char * host, u16 port) |
km_send_to_keyserver (listview_ctrl_t lv, HWND dlg, const char *host, u16 port) |
718 |
{ |
{ |
719 |
char keyid[32]; |
gpgme_key_t key; |
|
const char *t; |
|
720 |
int id; |
int id; |
721 |
|
|
722 |
id = listview_get_curr_pos( lv ); |
id = listview_get_curr_pos (lv); |
723 |
if( id == -1 ) { |
if (id == -1) { |
724 |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
725 |
return WPTERR_GENERAL; |
return WPTERR_GENERAL; |
726 |
} |
} |
727 |
|
|
728 |
listview_get_item_text( lv, id, 1, keyid, sizeof keyid - 1 ); |
key = (gpgme_key_t)listview_get_item2 (lv, id); |
729 |
|
if (!key) |
730 |
|
BUG (NULL); |
731 |
id = log_box (_("Key Manager"), MB_YESNO, |
id = log_box (_("Key Manager"), MB_YESNO, |
732 |
_("Do you really want to send '%s' to keyserver %s?"), |
_("Do you really want to send '%s' to keyserver %s?"), |
733 |
keyid, host); |
key->subkeys->keyid+8, host); |
734 |
if (id == IDYES) { |
if (id == IDYES) |
735 |
t = keyid; |
hkp_send_key (dlg, host, port, key->subkeys->keyid+8); |
|
if (!strncmp (keyid, "0x", 2)) |
|
|
t += 2; |
|
|
hkp_send_key (dlg, host, port, t); |
|
|
} |
|
736 |
|
|
737 |
return 0; |
return 0; |
738 |
} /* km_send_to_keyserver */ |
} |
739 |
|
|
740 |
|
|
741 |
|
/* Send the selected key in @lv via MAPI to a mail recipient. */ |
742 |
int |
int |
743 |
km_send_to_mail_recipient( listview_ctrl_t lv, HWND dlg ) |
km_send_to_mail_recipient (listview_ctrl_t lv, HWND dlg) |
744 |
{ |
{ |
|
#if 0 /*FIXME*/ |
|
745 |
gpgme_key_t key; |
gpgme_key_t key; |
746 |
gpgme_ctx_t ctx=NULL; |
gpgme_ctx_t ctx=NULL; |
747 |
gpgme_recipients_t rset=NULL; |
gpgme_data_t out; |
748 |
gpgme_error_t rc; |
gpgme_error_t rc; |
749 |
const char * s; |
char tmp[128]; |
750 |
char keyid[32], tmp[192+256], * p =NULL; |
char *fname; |
751 |
|
char *name; |
752 |
int pos; |
int pos; |
753 |
|
|
754 |
if( listview_count_items( lv, 1 ) > 1 ) { |
if (listview_count_items (lv, 1) > 1) { |
755 |
msg_box( dlg, _("Please only select one key."), _("Key Manager"), MB_INFO|MB_OK ); |
msg_box (dlg, _("Please only select one key."), |
756 |
|
_("Key Manager"), MB_INFO|MB_OK); |
757 |
return WPTERR_GENERAL; |
return WPTERR_GENERAL; |
758 |
} |
} |
759 |
pos = listview_get_curr_pos( lv ); |
pos = listview_get_curr_pos (lv); |
760 |
if( pos == -1 ) { |
if (pos == -1) { |
761 |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
msg_box (dlg, _("Please select a key."), _("Key Manager"), MB_ERR); |
762 |
return WPTERR_GENERAL; |
return WPTERR_GENERAL; |
763 |
} |
} |
764 |
listview_get_item_text( lv, pos, 1, keyid, sizeof keyid-1 ); |
key = (gpgme_key_t)listview_get_item2 (lv, pos); |
765 |
if( get_pubkey( keyid, &key ) ) |
if (!key) |
766 |
BUG( NULL ); |
BUG (NULL); |
|
s = key->uids->name; |
|
|
GetTempPath (sizeof tmp-1, tmp); |
|
|
strncat (tmp, s, sizeof tmp-200); |
|
|
strncat (tmp, ".asc", sizeof tmp-200); |
|
|
p = fm_quote_file (tmp); |
|
767 |
|
|
768 |
rc = gpgme_recipients_new (&rset); |
GetTempPath (sizeof (tmp)-1, tmp); |
769 |
if (!rc) |
if (tmp[strlen (tmp)-1] == '\\') |
770 |
rc = gpgme_recipients_add_name (rset, keyid); |
tmp[strlen (tmp)-1] = 0; |
771 |
if (!rc) |
name = utf8_to_wincp2 (key->uids->name); |
772 |
rc = gpgme_new (&ctx); |
fname = make_filename (tmp, name, "asc"); |
773 |
if (!rc) { |
for (pos=0; pos < (int)strlen (fname); pos++) { |
774 |
gpgme_set_armor (ctx, 1); |
if (fname[pos] == ' ') |
775 |
rc = gpgme_op_file_export (ctx, rset, p); |
fname[pos] = '_'; |
776 |
} |
} |
777 |
|
|
778 |
|
rc = gpgme_new (&ctx); |
779 |
|
if (rc) |
780 |
|
BUG (NULL); |
781 |
|
rc = gpgme_data_new (&out); |
782 |
|
if (rc) |
783 |
|
BUG (NULL); |
784 |
|
|
785 |
|
gpgme_set_armor (ctx, 1); |
786 |
|
rc = gpgme_op_export (ctx, key->subkeys->keyid, 0, out); |
787 |
if (rc) |
if (rc) |
788 |
msg_box (dlg, gpgme_strerror (rc), _("Key Manager"), MB_ERR); |
msg_box (dlg, gpgme_strerror (rc), _("Key Manager"), MB_ERR); |
789 |
else |
else |
790 |
mapi_send_pubkey (keyid, tmp); |
mapi_send_pubkey (key->subkeys->keyid+8, fname); |
791 |
|
|
792 |
free_if_alloc (p); |
gpg_data_release_and_set_file (out, fname); |
|
gpgme_recipients_release (rset); |
|
793 |
gpgme_release (ctx); |
gpgme_release (ctx); |
794 |
|
safe_free (name); |
795 |
|
free_if_alloc (fname); |
796 |
return rc; |
return rc; |
|
#endif |
|
|
return 0; |
|
797 |
} |
} |
798 |
|
|
799 |
|
|
800 |
static void |
static void |
801 |
km_refresh_one_key (listview_ctrl_t lv, HWND dlg, int pos) |
km_refresh_one_key (listview_ctrl_t lv, HWND dlg, int pos) |
802 |
{ |
{ |
803 |
|
gpgme_key_t key; |
804 |
int idx; |
int idx; |
|
char keyid[32]; |
|
|
const char *t; |
|
805 |
|
|
806 |
if (pos != 0) |
if (pos != 0) |
807 |
idx = pos; |
idx = pos; |
808 |
else |
else |
809 |
idx = listview_get_curr_pos (lv); |
idx = listview_get_curr_pos (lv); |
810 |
if (idx != -1) |
if (idx != -1) { |
811 |
{ |
key = (gpgme_key_t)listview_get_item2 (lv, idx); |
812 |
listview_get_item_text (lv, idx, 1, keyid, sizeof keyid - 1); |
hkp_recv_key (dlg, default_keyserver, default_keyserver_port, |
813 |
t = keyid; |
key->subkeys->keyid+8, 0, KM_KS_REFRESH); |
|
if (!strncmp (keyid, "0x", 2)) |
|
|
t += 2; |
|
|
hkp_recv_key (dlg, default_keyserver, default_keyserver_port, t, 0, KM_KS_REFRESH); |
|
814 |
} |
} |
815 |
} |
} |
816 |
|
|
817 |
|
|
818 |
|
/* Refresh all keys from the default keyserver. */ |
819 |
void |
void |
820 |
km_refresh_from_keyserver (listview_ctrl_t lv, HWND dlg) |
km_refresh_from_keyserver (listview_ctrl_t lv, HWND dlg) |
821 |
{ |
{ |
822 |
int idx, id, i; |
int idx, id, i; |
823 |
|
|
824 |
if (kserver_check_inet_connection ()) |
if (kserver_check_inet_connection ()) { |
|
{ |
|
825 |
msg_box (dlg, _("Could not connect to keyserver, abort procedure."), |
msg_box (dlg, _("Could not connect to keyserver, abort procedure."), |
826 |
_("Key Manager"), MB_ERR); |
_("Key Manager"), MB_ERR); |
827 |
return; |
return; |
828 |
} |
} |
829 |
idx = listview_count_items (lv, 0); |
idx = listview_count_items (lv, 0); |
830 |
if (listview_count_items (lv, 1) == idx) { |
if (listview_count_items (lv, 1) == idx) { |
831 |
id = msg_box (dlg, _("Do you really want to refresh all keys in the keyring?"), _("Key Manager"), MB_YESNO); |
id = msg_box (dlg, _("Do you really want to refresh all keys in the keyring?"), |
832 |
|
_("Key Manager"), MB_YESNO); |
833 |
if (id == IDNO) |
if (id == IDNO) |
834 |
return; |
return; |
835 |
for (i = 0; i < idx; i++) |
for (i = 0; i < idx; i++) |
843 |
km_refresh_one_key (lv, dlg, i); |
km_refresh_one_key (lv, dlg, i); |
844 |
} |
} |
845 |
} |
} |
846 |
} /* km_refresh_from_keyserver */ |
} |
847 |
|
|
848 |
|
|
849 |
void |
void |
851 |
{ |
{ |
852 |
char buf[256]; |
char buf[256]; |
853 |
|
|
854 |
key_get_clip_info (uid, buf, 255); |
key_get_clip_info (uid, buf, sizeof (buf)-1); |
855 |
set_clip_text (NULL, buf, strlen (buf)); |
set_clip_text (NULL, buf, strlen (buf)); |
856 |
} /* km_set_clip_info */ |
} |
857 |
|
|
858 |
|
|
859 |
|
|
863 |
km_key_is_v3 (listview_ctrl_t lv, int pos) |
km_key_is_v3 (listview_ctrl_t lv, int pos) |
864 |
{ |
{ |
865 |
gpgme_key_t pk; |
gpgme_key_t pk; |
|
char keyid[32]; |
|
866 |
|
|
867 |
listview_get_item_text (lv, pos, 1, keyid, sizeof keyid-1); |
pk = (gpgme_key_t)listview_get_item2 (lv, pos); |
868 |
if (get_pubkey (keyid, &pk)) |
if (!pk) |
869 |
BUG (NULL); |
BUG (NULL); |
870 |
if (strlen (pk->subkeys->fpr) == 32 && |
if (strlen (pk->subkeys->fpr) == 32 && |
871 |
pk->subkeys->pubkey_algo == GPGME_PK_RSA) |
pk->subkeys->pubkey_algo == GPGME_PK_RSA) |
874 |
} |
} |
875 |
|
|
876 |
|
|
|
/* Update the default key entry in the status bar for dialog @dlg. */ |
|
|
void |
|
|
km_update_default_key_str (HWND dlg) |
|
|
{ |
|
|
char *keyid, defkeyinf[512]; |
|
|
const char *fmt; |
|
|
|
|
|
/* XXX: also show the name? */ |
|
|
keyid = get_gnupg_default_key (); |
|
|
if (!keyid) |
|
|
BUG (0); |
|
|
if( (keyid[0] >= 'A' && keyid[0] <= 'Z') || (keyid[0] >= 'a' && keyid[0] <= 'z') |
|
|
|| (keyid[0] == '0' && keyid[1] == 'x') ) |
|
|
fmt = _("Default Key: %s"); |
|
|
else |
|
|
fmt = _("Default Key: 0x%s"); |
|
|
_snprintf (defkeyinf, sizeof defkeyinf - 1, fmt, keyid); |
|
|
SendMessage (dlg, SB_SETTEXT, 0, (LPARAM)defkeyinf); |
|
|
free_if_alloc (keyid); |
|
|
} |
|
|
|
|
|
|
|
|
/* Count all keys and show from @lv results in the status bar @sb. */ |
|
|
void |
|
|
km_complete_status_bar (HWND sb, listview_ctrl_t lv) |
|
|
{ |
|
|
char txt_sec[128], txt_pub[128]; |
|
|
int nkeys = 0, nsec = 0, i; |
|
|
|
|
|
nkeys = listview_count_items (lv, 0); |
|
|
for (i = 0; i < nkeys; i++) { |
|
|
if (km_check_for_seckey (lv, i, NULL)) |
|
|
nsec++; |
|
|
} |
|
|
_snprintf (txt_sec, sizeof (txt_sec)-1, _("%d secret keys"), nsec); |
|
|
_snprintf (txt_pub, sizeof (txt_pub)-1, _("%d keys"), nkeys); |
|
|
SendMessage (sb, SB_SETTEXT, 1, (LPARAM)txt_sec); |
|
|
SendMessage (sb, SB_SETTEXT, 2, (LPARAM)txt_pub); |
|
|
} |
|
|
|
|
|
|
|
877 |
/* Set trust of selected key in @lv (at @pos) to ultimate. */ |
/* Set trust of selected key in @lv (at @pos) to ultimate. */ |
878 |
int |
int |
879 |
km_set_implicit_trust (HWND dlg, listview_ctrl_t lv, int pos) |
km_set_implicit_trust (HWND dlg, listview_ctrl_t lv, int pos) |
880 |
{ |
{ |
881 |
|
gpgme_error_t err; |
882 |
|
gpgme_key_t key; |
883 |
GpgKeyEdit *ke; |
GpgKeyEdit *ke; |
|
gpgme_error_t err; |
|
|
char keyid[32]; |
|
|
|
|
|
listview_get_item_text (lv, pos, 1, keyid, 31); |
|
884 |
|
|
885 |
ke = new GpgKeyEdit (keyid); |
key = (gpgme_key_t)listview_get_item2 (lv, pos); |
886 |
|
if (!key) |
887 |
|
BUG (NULL); |
888 |
|
ke = new GpgKeyEdit (key->subkeys->keyid); |
889 |
if (!ke) |
if (!ke) |
890 |
BUG (0); |
BUG (0); |
891 |
|
|
928 |
} |
} |
929 |
|
|
930 |
|
|
931 |
|
/* Return a user-friendly name for a key derrived from |
932 |
void |
name. If @is_secret is 1, a secret key name will be generated. */ |
933 |
km_dump_key (gpgme_key_t key) |
char* |
934 |
{ |
km_gen_export_filename (const char *keyid, int is_secret) |
|
#if _DEBUG |
|
|
log_box ("DEBUG", MB_OK, |
|
|
"%d %d %s %d\n%s", key->subkeys->length, |
|
|
key->subkeys->pubkey_algo, |
|
|
key->subkeys->keyid, |
|
|
key->subkeys->timestamp, |
|
|
key->uids->uid); |
|
|
#endif |
|
|
} |
|
|
|
|
|
#if 0 |
|
|
gpg_optfile_t |
|
|
km_groupdb_open (void) |
|
|
{ |
|
|
gpg_optfile_t opt; |
|
|
char * optfile; |
|
|
int err = 0; |
|
|
|
|
|
optfile = get_gnupg_cfgfile(); |
|
|
if( !optfile ) |
|
|
BUG( NULL ); |
|
|
if( parse_gpg_options( optfile, &opt ) ) |
|
|
err = 1; |
|
|
free_if_alloc( optfile ); |
|
|
return err? NULL : opt; |
|
|
} /* km_groupdb_open */ |
|
|
|
|
|
|
|
|
int |
|
|
km_groupdb_expand_recipients( const char *name, gpgme_recipients_t rset ) |
|
|
{ |
|
|
gpg_keycache_t kc; |
|
|
gpgme_key_t pk; |
|
|
gpg_optfile_t opt; |
|
|
gpg_group_t grp; |
|
|
gpg_member_t mbr; |
|
|
int no_trust = 0, n; |
|
|
|
|
|
kc = keycache_get_ctx( 1 ); |
|
|
if( !kc ) |
|
|
BUG( NULL ); |
|
|
|
|
|
opt = km_groupdb_open( ); |
|
|
if( !opt ) |
|
|
return WPTERR_FILE_OPEN; |
|
|
|
|
|
grp = find_group( opt, name ); |
|
|
if( !grp ) |
|
|
return WPTERR_GENERAL; |
|
|
|
|
|
/* we are paranoid and check that all group members exist in the |
|
|
key cache. there is no need that it is really the real key, but |
|
|
an entry should be available. the rest is up to GPG. */ |
|
|
for( mbr = grp->list; mbr; mbr = mbr->next ) { |
|
|
if( gpgme_keycache_find_key( kc, mbr->name, 0, &pk ) ) |
|
|
BUG( NULL ); |
|
|
n = count_userids (pk); |
|
|
while( n-- ) { |
|
|
gpgme_user_id_t u = get_nth_userid (pk, n); |
|
|
const char * s = u->uid; |
|
|
if( s && stristr( s, mbr->name ) |
|
|
&& u->validity < 3 ) |
|
|
no_trust++; |
|
|
} |
|
|
} |
|
|
|
|
|
gpgme_recipients_add_name( rset, name ); |
|
|
release_gpg_options( opt ); |
|
|
|
|
|
return no_trust; |
|
|
} /* km_groupdb_expand_recipients */ |
|
|
|
|
|
|
|
|
static HTREEITEM |
|
|
km_tv_insert_item( HWND tree, HTREEITEM parent, const char *text ) |
|
|
{ |
|
|
TVINSERTSTRUCT tvis; |
|
|
HTREEITEM node; |
|
|
|
|
|
memset( &tvis, 0, sizeof tvis ); |
|
|
tvis.hParent = parent; |
|
|
tvis.hInsertAfter = TVI_LAST; |
|
|
tvis.item.mask = TVIF_TEXT; |
|
|
tvis.item.pszText = (char *)text; |
|
|
node = TreeView_InsertItem( tree, &tvis ); |
|
|
return node; |
|
|
} /* km_tv_insert_item */ |
|
|
|
|
|
|
|
|
int |
|
|
km_groups_new( km_group_t *r_gc, HWND ctrl ) |
|
|
{ |
|
|
km_group_t gc; |
|
|
|
|
|
gc = new km_group_s; |
|
|
if (!gc) |
|
|
BUG (NULL); |
|
|
gc->tree = ctrl; |
|
|
gc->gh = km_groupdb_open (); |
|
|
*r_gc = gc; |
|
|
return 0; |
|
|
} /* km_groups_new */ |
|
|
|
|
|
|
|
|
void |
|
|
km_groups_sync( km_group_t gc ) |
|
|
{ |
|
|
char * optfile; |
|
|
|
|
|
optfile = get_gnupg_cfgfile (); |
|
|
if( !optfile ) |
|
|
BUG( NULL ); |
|
|
commit_gpg_options( optfile, gc->gh ); |
|
|
free_if_alloc( optfile ); |
|
|
gc->need_sync = 0; |
|
|
} /* km_groups_sync */ |
|
|
|
|
|
|
|
|
void |
|
|
km_groups_release (km_group_t gc) |
|
|
{ |
|
|
if( gc ) { |
|
|
/* xxx: this reset the default key (sync=1) */ |
|
|
gc->need_sync=0; |
|
|
if (gc->need_sync) |
|
|
km_groups_sync (gc); |
|
|
if (gc->gh) |
|
|
release_gpg_options( gc->gh ); |
|
|
gc->gh = NULL; |
|
|
gc->tree = NULL; |
|
|
delete gc; |
|
|
} |
|
|
} /* km_groups_release */ |
|
|
|
|
|
|
|
|
int |
|
|
km_groups_load( km_group_t gc ) |
|
|
{ |
|
|
HTREEITEM n; |
|
|
gpg_group_t grp, g; |
|
|
gpg_member_t mbr; |
|
|
u32 gid = 0; |
|
|
|
|
|
if( !gc->gh ) |
|
|
return 0; |
|
|
grp = gc->gh->grp; |
|
|
if( !grp ) |
|
|
return 0; /* no groups */ |
|
|
|
|
|
for( g = grp; g; g = g->next ) { |
|
|
n = km_tv_insert_item( gc->tree, NULL, g->name ); |
|
|
for( mbr = g->list; mbr; mbr = mbr->next ) { |
|
|
if( mbr->used && mbr->name ) |
|
|
km_tv_insert_item( gc->tree, n, mbr->name ); |
|
|
} |
|
|
} |
|
|
DragAcceptFiles( gc->tree, TRUE ); |
|
|
gc->need_sync = 0; |
|
|
return 0; |
|
|
} /* km_groups_load */ |
|
|
|
|
|
|
|
|
int |
|
|
km_groups_add( km_group_t gc, listview_ctrl_t lv, int km_index ) |
|
|
{ |
|
|
TVITEM tvi; |
|
|
char uid[128], valid[64], text[128]; |
|
|
int i_valid; |
|
|
|
|
|
memset( &tvi, 0, sizeof tvi ); |
|
|
tvi.hItem = TreeView_GetSelection( gc->tree ); |
|
|
tvi.pszText = text; |
|
|
tvi.cchTextMax = sizeof text -1; |
|
|
tvi.mask = TVIF_TEXT; |
|
|
TreeView_GetItem( gc->tree, &tvi ); |
|
|
|
|
|
|
|
|
listview_get_item_text( lv, km_index, 0, uid, sizeof uid -1 ); |
|
|
listview_get_item_text( lv, km_index, 5, valid, sizeof valid -1 ); |
|
|
|
|
|
if( strstr( valid, "Ultimate" ) ) |
|
|
i_valid = 5; |
|
|
else if( !strstr( valid, "Full" ) ) |
|
|
i_valid = 4; |
|
|
else if( !strstr( valid, "Marginal" ) ) |
|
|
i_valid = 3; |
|
|
else |
|
|
i_valid = 0; |
|
|
|
|
|
/* we can't add the full name. one way would be to use the first |
|
|
text until a space appears. |
|
|
group_add_entry(&gc->gh, gid, i_valid, uid); |
|
|
treeview_add_item(gc->tree, tvi.hItem, uid); |
|
|
*/ |
|
|
gc->need_sync = 1; |
|
|
|
|
|
return 0; |
|
|
} /* km_groups_add */ |
|
|
|
|
|
|
|
|
static int |
|
|
km_groups_del_main( km_group_t gc ) |
|
|
{ |
|
|
TVITEM tvi; |
|
|
char text[128]; |
|
|
int id; |
|
|
|
|
|
memset( &tvi, 0, sizeof tvi ); |
|
|
tvi.hItem = TreeView_GetSelection( gc->tree ); |
|
|
tvi.pszText = text; |
|
|
tvi.cchTextMax = sizeof text -1; |
|
|
tvi.mask = TVIF_TEXT; |
|
|
TreeView_GetItem( gc->tree, &tvi ); |
|
|
|
|
|
id = log_box( _("Key Manager"), MB_INFO_ASK, |
|
|
_("Do you really want to delete this group?\n\n%s"), text); |
|
|
if( id == IDNO ) |
|
|
return 0; |
|
|
delete_group( gc->gh, text ); |
|
|
TreeView_DeleteItem( gc->tree, &tvi ); |
|
|
gc->need_sync = 1; |
|
|
|
|
|
return 0; |
|
|
} /* km_groups_del */ |
|
|
|
|
|
|
|
|
static int |
|
|
km_groups_del_entry( km_group_t gc ) |
|
935 |
{ |
{ |
936 |
TVITEM tvi; |
gpgme_key_t key; |
937 |
HTREEITEM root; |
char *p, *uid; |
|
int id; |
|
|
char text[128], info[256]; |
|
|
gpg_group_t grp = NULL; |
|
|
|
|
|
memset( &tvi, 0, sizeof tvi ); |
|
|
tvi.hItem = TreeView_GetSelection( gc->tree ); |
|
|
tvi.pszText = text; |
|
|
tvi.cchTextMax = sizeof text-1; |
|
|
tvi.mask = TVIF_TEXT; |
|
|
TreeView_GetItem( gc->tree, &tvi ); |
|
|
|
|
|
_snprintf( info, sizeof info -1, |
|
|
_("Do you really want to delete this entry?\n\n%s"), text ); |
|
|
|
|
|
id = msg_box( gc->tree, info, _("Key Manager"), MB_INFO_ASK ); |
|
|
if( id == IDNO ) |
|
|
return 0; |
|
938 |
|
|
939 |
root = TreeView_GetParent( gc->tree, tvi.hItem ); |
if (get_pubkey (keyid, &key)) |
940 |
if( root ) { |
return m_strdup (keyid); |
941 |
|
uid = utf8_to_wincp2 (key->uids->name); |
942 |
|
if (!uid) |
943 |
|
return m_strdup (keyid); |
944 |
|
p = new char[strlen (uid) + 8 + 16]; |
945 |
|
if (!p) |
946 |
|
BUG (0); |
947 |
|
sprintf (p, "%s%s.asc", uid, is_secret? "_sec" : ""); |
948 |
|
for (size_t i=0; i < strlen (p); i++) { |
949 |
|
if (p[i] == ' ' || p[i] == ':' || p[i] == '?' || p[i] == '|') |
950 |
|
p[i] = '_'; |
951 |
} |
} |
952 |
|
safe_free (uid); |
953 |
delete_member( gc->gh, /*fixme*/NULL, text ); |
return p; |
954 |
TreeView_DeleteItem( gc->tree, &tvi ); |
} |
|
gc->need_sync = 1; |
|
|
return 0; |
|
|
} /* km_groups_del_entry */ |
|
|
|
|
|
|
|
|
int |
|
|
km_groups_del( km_group_t gc ) |
|
|
{ |
|
|
if ( TreeView_GetParent( gc->tree, TreeView_GetSelection( gc->tree ) ) ) |
|
|
return km_groups_del_entry( gc ); |
|
|
else |
|
|
return km_groups_del_main( gc ); |
|
|
} /* km_groups_del */ |
|
|
#endif |
|