1 |
/* wptKeyEditDlgs.cpp - GPG key edit dialogs |
/* wptKeyEditDlgs.cpp - GPG key edit dialogs |
2 |
* Copyright (C) 2002-2007 Timo Schulz |
* Copyright (C) 2002-2009 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
37 |
#include "wptKeyManager.h" |
#include "wptKeyManager.h" |
38 |
#include "wptRegistry.h" |
#include "wptRegistry.h" |
39 |
#include "wptKeyEdit.h" |
#include "wptKeyEdit.h" |
40 |
|
#include "wptKeyserver.h" |
41 |
#include "StringBuffer.h" |
#include "StringBuffer.h" |
42 |
|
|
43 |
|
|
79 |
{"DELKEY", 1, CMD_DELKEY}, |
{"DELKEY", 1, CMD_DELKEY}, |
80 |
{"EXPIRE", 1, CMD_EXPIRE}, |
{"EXPIRE", 1, CMD_EXPIRE}, |
81 |
{"SHOWPREF", 0, CMD_SHOWPREF}, |
{"SHOWPREF", 0, CMD_SHOWPREF}, |
|
/*{"SETPREF", 1, CMD_SETPREF},*/ |
|
82 |
{"PASSWD", 1, CMD_PASSWD}, |
{"PASSWD", 1, CMD_PASSWD}, |
83 |
{"PRIMARY", 1, CMD_PRIMARY}, |
{"PRIMARY", 1, CMD_PRIMARY}, |
84 |
{"TRUST", 0, CMD_TRUST}, |
{"TRUST", 0, CMD_TRUST}, |
308 |
return false; |
return false; |
309 |
n = fread (buf, 1, DIM (buf), fp); |
n = fread (buf, 1, DIM (buf), fp); |
310 |
fclose (fp); |
fclose (fp); |
311 |
if (n < DIM (buf)) |
if (n < (int)DIM (buf)) |
312 |
return false; |
return false; |
313 |
return buf[6] == 'J' && buf[7] == 'F' && |
return buf[6] == 'J' && buf[7] == 'F' && |
314 |
buf[8] == 'I' && buf[9] == 'F'; |
buf[8] == 'I' && buf[9] == 'F'; |
337 |
SetWindowText (dlg, _("Add Photo ID")); |
SetWindowText (dlg, _("Add Photo ID")); |
338 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
339 |
break; |
break; |
340 |
|
|
341 |
|
case WM_DESTROY: |
342 |
|
balloon_msg_disable (); |
343 |
|
break; |
344 |
|
|
345 |
case WM_COMMAND: |
case WM_COMMAND: |
346 |
switch( LOWORD (wparam)) { |
switch( LOWORD (wparam)) { |
347 |
case IDC_ADDPHOTO_SELFILE: |
case IDC_ADDPHOTO_SELFILE: |
349 |
"JPEG Files (*.jpg, *.jpeg)\0*.jpg;*.jpeg\0\0", |
"JPEG Files (*.jpg, *.jpeg)\0*.jpg;*.jpeg\0\0", |
350 |
NULL); |
NULL); |
351 |
if (s && !is_jpg_file (s)) { |
if (s && !is_jpg_file (s)) { |
352 |
log_box (_("Add Photo"), MB_ERR, |
log_box (_("Add Photo ID"), MB_ERR, |
353 |
_("'%s' is not a valid JPEG file."), s); |
_("'%s' is not a valid JPEG file."), s); |
354 |
return FALSE; |
return FALSE; |
355 |
} |
} |
359 |
|
|
360 |
case IDOK: |
case IDOK: |
361 |
if (!GetDlgItemText (dlg, IDC_ADDPHOTO_FILE, file, sizeof (file)-1)){ |
if (!GetDlgItemText (dlg, IDC_ADDPHOTO_FILE, file, sizeof (file)-1)){ |
362 |
msg_box (dlg, _("Please enter a file name."), |
show_balloon_msg (GetDlgItem (dlg, IDC_ADDPHOTO_FILE), |
363 |
_("Add Photo"), MB_ERR); |
_("Please enter a file name."), IDI_ERROR); |
364 |
return FALSE; |
return FALSE; |
365 |
} |
} |
366 |
if (get_file_size (file) == 0 || get_file_size (file) > 6144) { |
if (get_file_size (file) == 0 || get_file_size (file) > 6144) { |
367 |
id = msg_box (dlg, _("The JPEG is really large.\n" |
id = msg_box (dlg, _("The JPEG is really large.\n" |
368 |
"Are you sure you want to use it?"), |
"Are you sure you want to use it?"), |
369 |
_("Add Photo"), MB_YESNO|MB_INFO); |
_("Add Photo ID"), MB_YESNO|MB_INFO); |
370 |
if (id == IDNO) |
if (id == IDNO) |
371 |
return TRUE; |
return TRUE; |
372 |
} |
} |
382 |
err = ke.addPhotoid (file); |
err = ke.addPhotoid (file); |
383 |
} |
} |
384 |
if (err) { |
if (err) { |
385 |
msg_box (dlg, gpgme_strerror (err), _("Add Photo"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Add Photo ID"), MB_ERR); |
386 |
return FALSE; |
return FALSE; |
387 |
} |
} |
388 |
else { |
else { |
419 |
do_init_keylist (dlg, cb->keyid); |
do_init_keylist (dlg, cb->keyid); |
420 |
SetDlgItemText (dlg, IDC_ADDREV_INF, |
SetDlgItemText (dlg, IDC_ADDREV_INF, |
421 |
_("Appointing a key as designated revoker cannot be undone.")); |
_("Appointing a key as designated revoker cannot be undone.")); |
422 |
SetDlgItemText (dlg, IDC_ADDREV_KEYINF, _("Public key")); |
SetDlgItemText (dlg, IDC_ADDREV_KEYINF, _("Public key:")); |
423 |
SetDlgItemText (dlg, IDC_ADDREV_PWDINF, _("Passphrase")); |
SetDlgItemText (dlg, IDC_ADDREV_PWDINF, _("Passphrase")); |
424 |
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
425 |
SetWindowText (dlg, _("Add Revoker")); |
SetWindowText (dlg, _("Add Revoker")); |
427 |
center_window (dlg, cb->parent); |
center_window (dlg, cb->parent); |
428 |
break; |
break; |
429 |
|
|
430 |
|
case WM_DESTROY: |
431 |
|
balloon_msg_disable (); |
432 |
|
break; |
433 |
|
|
434 |
case WM_COMMAND: |
case WM_COMMAND: |
435 |
switch (LOWORD (wparam)) { |
switch (LOWORD (wparam)) { |
436 |
case IDOK: |
case IDOK: |
437 |
if (!GetDlgItemText_utf8 (dlg, IDC_ADDREV_KEYLIST, &uid)) { |
if (!GetDlgItemText_utf8 (dlg, IDC_ADDREV_KEYLIST, &uid)) { |
438 |
msg_box (dlg, _("Please select a user ID."), _("Add Revoker"), MB_ERR); |
show_balloon_msg (GetDlgItem (dlg, IDC_ADDREV_KEYLIST), |
439 |
|
_("Please select a user ID."), IDI_ERROR); |
440 |
return FALSE; |
return FALSE; |
441 |
} |
} |
442 |
|
|
491 |
ctx = (keyedit_cb_t)lparam; |
ctx = (keyedit_cb_t)lparam; |
492 |
if (!ctx) |
if (!ctx) |
493 |
dlg_fatal_error(dlg, "Could not get dialog param!"); |
dlg_fatal_error(dlg, "Could not get dialog param!"); |
494 |
SetWindowText (dlg, _("Add new User ID")); |
SetWindowText (dlg, _("Add user ID")); |
495 |
SetDlgItemText (dlg, IDC_ADDUID_INFNAME, _("&Name")); |
SetDlgItemText (dlg, IDC_ADDUID_INFNAME, _("&Name:")); |
496 |
SetDlgItemText (dlg, IDC_ADDUID_INFEMAIL, _("&Email")); |
SetDlgItemText (dlg, IDC_ADDUID_INFEMAIL, _("&Email:")); |
497 |
SetDlgItemText (dlg, IDC_ADDUID_INFCOMMENT, _("&Comment")); |
SetDlgItemText (dlg, IDC_ADDUID_INFCOMMENT, _("&Comment:")); |
498 |
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
499 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
500 |
center_window (dlg, ctx->parent); |
center_window (dlg, ctx->parent); |
501 |
return FALSE; |
return FALSE; |
502 |
|
|
503 |
|
case WM_DESTROY: |
504 |
|
balloon_msg_disable (); |
505 |
|
break; |
506 |
|
|
507 |
case WM_COMMAND: |
case WM_COMMAND: |
508 |
switch ( LOWORD( wparam ) ) { |
switch ( LOWORD( wparam ) ) { |
509 |
case IDOK: |
case IDOK: |
510 |
keygen = (keygen_cb_t)ctx->opaque; |
keygen = (keygen_cb_t)ctx->opaque; |
511 |
rc = GetDlgItemText_utf8 (dlg, IDC_ADDUID_NAME, &utf8_name); |
rc = GetDlgItemText_utf8 (dlg, IDC_ADDUID_NAME, &utf8_name); |
512 |
if (!rc || rc < 5) { |
if (!rc || rc < 5) { |
513 |
msg_box (dlg, _("Please enter a name (min. 5 chars.)"), |
show_balloon_msg (GetDlgItem (dlg, IDC_ADDUID_NAME), |
514 |
_("UserID"), MB_ERR); |
_("Please enter a name (min. 5 chars.)"), |
515 |
|
IDI_ERROR); |
516 |
free_if_alloc (utf8_name); |
free_if_alloc (utf8_name); |
517 |
return FALSE; |
return FALSE; |
518 |
} |
} |
519 |
if (strchr (utf8_name, '@')) { |
if (strchr (utf8_name, '@')) { |
520 |
msg_box (dlg, _("Please enter the email address in the email field and not in the name field"), |
show_balloon_msg (GetDlgItem (dlg, IDC_ADDUID_NAME), |
521 |
_("UserID"), MB_INFO); |
_("Please enter the email address in the email field and not in the name field"), |
522 |
|
IDI_WARNING); |
523 |
free_if_alloc (utf8_name); |
free_if_alloc (utf8_name); |
524 |
return FALSE; |
return FALSE; |
525 |
} |
} |
526 |
|
|
527 |
if( !GetDlgItemText (dlg, IDC_ADDUID_EMAIL, email, sizeof (email) -1)) { |
if( !GetDlgItemText (dlg, IDC_ADDUID_EMAIL, email, DIM (email) -1)) { |
528 |
msg_box (dlg, _("Please enter an email address."), _("UserID"), MB_ERR); |
show_balloon_msg (GetDlgItem (dlg, IDC_ADDUID_EMAIL), |
529 |
|
_("Please enter an email address."),IDI_ERROR); |
530 |
free_if_alloc (utf8_name); |
free_if_alloc (utf8_name); |
531 |
return FALSE; |
return FALSE; |
532 |
} |
} |
533 |
if (check_email_address (email)) { |
if (check_email_address (email)) { |
534 |
msg_box (dlg, _("Invalid email address."), _("UserID"), MB_ERR); |
show_balloon_msg (GetDlgItem (dlg, IDC_ADDUID_EMAIL), |
535 |
|
_("Invalid email address."), IDI_ERROR); |
536 |
free_if_alloc (utf8_name); |
free_if_alloc (utf8_name); |
537 |
return FALSE; |
return FALSE; |
538 |
} |
} |
539 |
|
|
540 |
rc = GetDlgItemText_utf8 (dlg, IDC_ADDUID_COMMENT, &utf8_comment); |
rc = GetDlgItemText_utf8 (dlg, IDC_ADDUID_COMMENT, &utf8_comment); |
|
|
|
541 |
{ |
{ |
542 |
GpgKeyEdit ke; |
GpgKeyEdit ke; |
543 |
|
|
572 |
} |
} |
573 |
|
|
574 |
|
|
575 |
/* Initalize a combo box with default key sizes (1024-4096). */ |
/* Initalize a combo box with default key sizes. */ |
576 |
static void |
static void |
577 |
init_keysize_box (HWND dlg, int ctlid) |
init_keysize_box (HWND dlg, int ctlid) |
578 |
{ |
{ |
579 |
/* Array with standard key-length in bits. */ |
/* Array with standard key-length in bits. */ |
580 |
const char *sizelist[] = { |
const char *sizelist[] = { |
581 |
"1024", "1536", |
"2048", "3072", "4096", NULL |
|
"2048", "3072", |
|
|
"4096", NULL |
|
582 |
}; |
}; |
|
int i; |
|
583 |
|
|
584 |
for (i=0; sizelist[i] != NULL; i++) |
for (int i=0; sizelist[i] != NULL; i++) |
585 |
SendDlgItemMessage (dlg, ctlid, CB_ADDSTRING, 0, |
SendDlgItemMessage (dlg, ctlid, CB_ADDSTRING, 0, |
586 |
(LPARAM)(char*)sizelist[i]); |
(LPARAM)(char*)sizelist[i]); |
587 |
SendDlgItemMessage (dlg, ctlid, CB_SETCURSEL, (WPARAM)2, 0); |
SendDlgItemMessage (dlg, ctlid, CB_SETCURSEL, (WPARAM)0, 0); |
588 |
} |
} |
589 |
|
|
590 |
|
|
610 |
|
|
611 |
memset (&tm, 0, sizeof (tm)); |
memset (&tm, 0, sizeof (tm)); |
612 |
tm.tm_year = st->wYear-1900; |
tm.tm_year = st->wYear-1900; |
613 |
tm.tm_mday = st->wDay+1; |
tm.tm_mday = st->wDay; |
614 |
tm.tm_mon = st->wMonth-1; |
tm.tm_mon = st->wMonth-1; |
615 |
return mktime (&tm); |
return mktime (&tm); |
616 |
} |
} |
632 |
ctx = (keyedit_cb_t)lparam; |
ctx = (keyedit_cb_t)lparam; |
633 |
if (!ctx) |
if (!ctx) |
634 |
BUG (NULL); |
BUG (NULL); |
635 |
SetWindowText (dlg, _("Add new Subkey")); |
SetWindowText (dlg, _("Add Subkey")); |
636 |
SetDlgItemText (dlg, IDC_ADDSUBKEY_INFALGO, _("Key type")); |
SetDlgItemText (dlg, IDC_ADDSUBKEY_INFALGO, _("Key type:")); |
637 |
SetDlgItemText (dlg, IDC_ADDSUBKEY_INFSIZE, _("Size in bits")); |
SetDlgItemText (dlg, IDC_ADDSUBKEY_INFSIZE, _("Size in bits:")); |
638 |
SetDlgItemText (dlg, IDC_ADDSUBKEY_INFVALID, _("Key expiration")); |
SetDlgItemText (dlg, IDC_ADDSUBKEY_INFVALID, _("Key expiration:")); |
639 |
SetDlgItemText (dlg, IDC_ADDSUBKEY_EXPIRE, _("&Never")); |
SetDlgItemText (dlg, IDC_ADDSUBKEY_EXPIRE, _("&Never")); |
640 |
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
641 |
|
|
642 |
hwnd = GetDlgItem (dlg, IDC_ADDSUBKEY_ALGO); |
hwnd = GetDlgItem (dlg, IDC_ADDSUBKEY_ALGO); |
643 |
listbox_add_string (hwnd, "DSA (sign only)"); |
listbox_add_string (hwnd, _("DSA (sign only)")); |
644 |
listbox_add_string (hwnd, "ElGamal (encrypt only)"); |
listbox_add_string (hwnd, _("ElGamal (encrypt only)")); |
645 |
listbox_add_string (hwnd, "RSA (sign only)"); |
listbox_add_string (hwnd, _("RSA (sign only)")); |
646 |
listbox_add_string (hwnd, "RSA (encrypt only)"); |
listbox_add_string (hwnd, _("RSA (encrypt only)")); |
647 |
CheckDlgButton (dlg, IDC_ADDSUBKEY_EXPIRE, BST_CHECKED); |
CheckDlgButton (dlg, IDC_ADDSUBKEY_EXPIRE, BST_CHECKED); |
648 |
EnableWindow (GetDlgItem (dlg, IDC_ADDSUBKEY_EXPDATE), FALSE); |
EnableWindow (GetDlgItem (dlg, IDC_ADDSUBKEY_EXPDATE), FALSE); |
649 |
|
EnableWindow (GetDlgItem (dlg, IDC_ADDSUBKEY_SIZE), FALSE); |
650 |
init_keysize_box (dlg, IDC_ADDSUBKEY_SIZE); |
init_keysize_box (dlg, IDC_ADDSUBKEY_SIZE); |
651 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
652 |
center_window (dlg, ctx->parent); |
center_window (dlg, ctx->parent); |
653 |
return FALSE; |
return FALSE; |
654 |
|
|
655 |
|
case WM_DESTROY: |
656 |
|
balloon_msg_disable (); |
657 |
|
break; |
658 |
|
|
659 |
case WM_COMMAND: |
case WM_COMMAND: |
660 |
if (HIWORD (wparam) == BN_CLICKED && |
if (HIWORD (wparam) == BN_CLICKED && |
661 |
LOWORD (wparam) == IDC_ADDSUBKEY_EXPIRE) { |
LOWORD (wparam) == IDC_ADDSUBKEY_EXPIRE) { |
666 |
} |
} |
667 |
if (HIWORD (wparam) == LBN_SELCHANGE && |
if (HIWORD (wparam) == LBN_SELCHANGE && |
668 |
LOWORD (wparam) == IDC_ADDSUBKEY_ALGO) { |
LOWORD (wparam) == IDC_ADDSUBKEY_ALGO) { |
669 |
/* If the selected algorithm is DSA, automatically set the |
/* If DSA is selected, we disable the selection box since it |
670 |
size to 1024, otherwise use the default keysize. */ |
is hardocded to 2048-bit. */ |
671 |
index = SendMessage ((HWND)lparam, LB_GETCURSEL, 0, 0); |
index = SendMessage ((HWND)lparam, LB_GETCURSEL, 0, 0); |
672 |
SendDlgItemMessage (dlg, IDC_ADDSUBKEY_SIZE, CB_SETCURSEL, |
EnableWindow (GetDlgItem (dlg, IDC_ADDSUBKEY_SIZE), |
673 |
index==0? 0 : 2, 0); |
index != 0? TRUE : FALSE); |
674 |
} |
} |
675 |
|
|
676 |
switch (LOWORD (wparam)) { |
switch (LOWORD (wparam)) { |
677 |
case IDOK: |
case IDOK: |
678 |
keygen = (keygen_cb_t)ctx->opaque; |
keygen = (keygen_cb_t)ctx->opaque; |
679 |
assert (keygen); |
if (!keygen) |
680 |
|
BUG (NULL); |
681 |
hwnd = GetDlgItem (dlg, IDC_ADDSUBKEY_ALGO); |
hwnd = GetDlgItem (dlg, IDC_ADDSUBKEY_ALGO); |
682 |
|
int map[4]; |
683 |
|
/* this is for GPG 1.4.9 */ |
684 |
|
map[0] = 2; |
685 |
|
map[1] = 4; |
686 |
|
map[2] = 5; |
687 |
|
map[3] = 6; |
688 |
|
/* >1.4.10 changed the menu IDs. */ |
689 |
|
if (gpgver[0] == 1 && gpgver[1] >= 4 && gpgver[2] > 9) { |
690 |
|
map[0] = 3; |
691 |
|
map[1] = 5; |
692 |
|
map[2] = 4; |
693 |
|
map[3] = 6; |
694 |
|
} |
695 |
|
|
696 |
/* Map combo box numbers to GPG answers. */ |
/* Map combo box numbers to GPG answers. */ |
697 |
switch (listbox_get_cursel (hwnd)) { |
switch (listbox_get_cursel (hwnd)) { |
698 |
case 0: index = 2; break; |
case 0: |
699 |
case 1: index = 4; break; |
case 1: |
700 |
case 2: index = 5; break; |
case 2: |
701 |
case 3: index = 6; break; |
case 3: |
702 |
|
break; |
703 |
default: |
default: |
704 |
msg_box (dlg, _("Please select one entry."), |
show_balloon_msg (GetDlgItem (dlg, IDC_ADDSUBKEY_ALGO), |
705 |
_("Add Subkey"), MB_ERR); |
_("Please select one entry."), IDI_ERROR); |
706 |
return FALSE; |
return FALSE; |
707 |
} |
} |
708 |
|
index = map[listbox_get_cursel (hwnd)]; |
709 |
size = get_keysize_from_box (dlg, IDC_ADDSUBKEY_SIZE); |
size = get_keysize_from_box (dlg, IDC_ADDSUBKEY_SIZE); |
710 |
if (index == 2 && size != 1024) { |
if (index == 2) /* DSA */ |
711 |
msg_box (dlg,_("DSS uses a fixed keysize of 1024. Size changed."), |
size = 2048; |
|
_("Add Subkey"), MB_INFO); |
|
|
size = 1024; |
|
|
} |
|
712 |
|
|
713 |
hwnd = GetDlgItem (dlg, IDC_ADDSUBKEY_EXPDATE); |
hwnd = GetDlgItem (dlg, IDC_ADDSUBKEY_EXPDATE); |
714 |
DateTime_GetSystemtime (hwnd, &st); |
DateTime_GetSystemtime (hwnd, &st); |
856 |
cb.opaque = &keygen; |
cb.opaque = &keygen; |
857 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYEDIT_ADDSUBKEY, |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYEDIT_ADDSUBKEY, |
858 |
dlg, keyedit_addsubkey_dlg_proc, |
dlg, keyedit_addsubkey_dlg_proc, |
859 |
(LPARAM)&cb, _("Add new Subkey"), |
(LPARAM)&cb, _("Add Subkey"), |
860 |
IDS_WINPT_KEYEDIT_ADDSUBKEY); |
IDS_WINPT_KEYEDIT_ADDSUBKEY); |
861 |
if (lv != NULL && cb.finished) |
if (lv != NULL && cb.finished) |
862 |
do_add_new_subkey (lv, &keygen, 0); |
do_add_new_subkey (lv, &keygen, 0); |
879 |
char *pass = NULL; |
char *pass = NULL; |
880 |
|
|
881 |
url = (struct URL_ctx_s *)get_keyserver_URL_dlg (dlg); |
url = (struct URL_ctx_s *)get_keyserver_URL_dlg (dlg); |
882 |
if (url->cancel == 1) { |
if (url == NULL || url->cancel == 1) { |
883 |
delete url; |
delete url; |
884 |
return FALSE; |
return FALSE; |
885 |
} |
} |
902 |
else |
else |
903 |
msg_box (dlg, gpgme_strerror (err), _("Key Edit"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Key Edit"), MB_ERR); |
904 |
|
|
905 |
|
keyserver_set_default (url->url, 0); |
906 |
sfree_if_alloc (pass); |
sfree_if_alloc (pass); |
907 |
delete url; |
delete url; |
908 |
return err == 0? 0 : WPTERR_GENERAL; |
return err == 0? 0 : WPTERR_GENERAL; |
920 |
|
|
921 |
if (!k->key_pair) { |
if (!k->key_pair) { |
922 |
msg_box (dlg, _("There is no secret key available!"), |
msg_box (dlg, _("There is no secret key available!"), |
923 |
_("Add Photo"), MB_ERR); |
_("Add Photo ID"), MB_ERR); |
924 |
return FALSE; |
return FALSE; |
925 |
} |
} |
926 |
|
|
1077 |
if (err) |
if (err) |
1078 |
msg_box (dlg, gpgme_strerror (err), _("Change Password"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Change Password"), MB_ERR); |
1079 |
else |
else |
1080 |
msg_box (dlg, _("Passphrase successfully changed."), _("GnuPG status"), MB_OK); |
msg_box (dlg, _("Passphrase successfully changed."), _("GnuPG Status"), MB_OK); |
1081 |
sfree_if_alloc (old_pass); |
sfree_if_alloc (old_pass); |
1082 |
sfree_if_alloc (new_pass); |
sfree_if_alloc (new_pass); |
1083 |
|
|
1098 |
{2, 66, (char *)_("Creation")}, |
{2, 66, (char *)_("Creation")}, |
1099 |
{3, 66, (char *)_("Expires")}, |
{3, 66, (char *)_("Expires")}, |
1100 |
{4, 64, (char *)_("Status")}, |
{4, 64, (char *)_("Status")}, |
1101 |
{5, 16, "C"/*ertify*/}, |
{5, 16, (char *) "C"/*ertify*/}, |
1102 |
{6, 16, "S"/*ign*/}, |
{6, 16, (char *) "S"/*ign*/}, |
1103 |
{7, 16, "E"/*ncrypt*/}, |
{7, 16, (char *) "E"/*ncrypt*/}, |
1104 |
{8, 16, "A"/*uth*/}, |
{8, 16, (char *) "A"/*uth*/}, |
1105 |
{0, 0, 0} |
{0, 0, 0} |
1106 |
}; |
}; |
1107 |
listview_ctrl_t lv; |
listview_ctrl_t lv; |
1267 |
|
|
1268 |
help = |
help = |
1269 |
_( |
_( |
1270 |
"ADDUID add a user ID\r\n" |
"ADDUID\t\t\tadd a user ID\r\n" |
1271 |
"ADDPHOTO add a photo ID\r\n" |
"ADDPHOTO\t\t\tadd a photo ID\r\n" |
1272 |
"DELUID delete a user ID\r\n" |
"DELUID\t\t\tdelete a user ID\r\n" |
1273 |
"ADDKEY add a secondary key\r\n" |
"ADDKEY\t\t\tadd a secondary key\r\n" |
1274 |
"DELKEY delete a secondary key\r\n" |
"DELKEY\t\t\tdelete a secondary key\r\n" |
1275 |
"ADDREVOKER add a revocation key\r\n" |
"ADDREVOKER\t\t\tadd a revocation key\r\n" |
1276 |
"EXPIRE change the expire date\r\n" |
"EXPIRE\t\t\tchange the expire date\r\n" |
1277 |
"SHOWPREF list preferences (verbose)\r\n" |
"SHOWPREF\t\t\tlist preferences (verbose)\r\n" |
1278 |
/*"SETPREF update specific algorithm preferences\r\n"*/ |
"PASSWD\t\t\tchange the passphrase\r\n" |
1279 |
"PASSWD change the passphrase\r\n" |
"PRIMARY\t\t\tflag user ID as primary\r\n" |
1280 |
"PRIMARY flag user ID as primary\r\n" |
"TRUST\t\t\tchange the ownertrust\r\n" |
1281 |
"TRUST change the ownertrust\r\n" |
"REVUID\t\t\trevoke a user ID\r\n" |
1282 |
"REVUID revoke a user ID\r\n" |
"REVKEY\t\t\trevoke a secondary key\r\n" |
1283 |
"REVKEY revoke a secondary key\r\n" |
"DISABLE\t\t\tdisable a key\r\n" |
1284 |
"DISABLE disable a key\r\n" |
"ENABLE\t\t\tenable a key\r\n" |
1285 |
"ENABLE enable a key\r\n" |
"SIGN\t\t\tsign a user-id (exportable)\r\n" |
1286 |
"SIGN sign a user-id (exportable)\r\n" |
"LSIGN\t\t\tsign a user-id (non-exportable)\r\n" |
1287 |
"LSIGN sign a user-id (non-exportable)\r\n" |
"CLEAN\t\t\tremove unusable signatures from key\r\n" |
1288 |
"CLEAN remove unusable signatures from key\r\n" |
"MINIMIZE\t\t\tremove all signatures from key\r\n" |
|
"MINIMIZE remove all signatures from key\r\n" |
|
1289 |
); |
); |
1290 |
msg_box (dlg, help, _("Key Edit Help"), MB_OK); |
msg_box (dlg, help, _("Key Edit Help"), MB_OK); |
1291 |
} |
} |
1317 |
return FALSE; |
return FALSE; |
1318 |
|
|
1319 |
if (listview_count_items (lv, 0) == 1) { |
if (listview_count_items (lv, 0) == 1) { |
1320 |
msg_box (dlg, _("Primary key can not be deleted!"), _("Key Edit"), MB_ERR); |
show_balloon_msg (lv->ctrl, _("Primary key can not be deleted!"), |
1321 |
|
IDI_ERROR); |
1322 |
return FALSE; |
return FALSE; |
1323 |
} |
} |
1324 |
pos = listview_get_curr_pos (lv); |
pos = listview_get_curr_pos (lv); |
1325 |
if (pos == -1) { |
if (pos == -1) { |
1326 |
msg_box (dlg, _("Please select a key."), _("Key Edit"), MB_ERR); |
show_balloon_msg (lv->ctrl, _("Please select a key."), IDI_ERROR); |
1327 |
return FALSE; |
return FALSE; |
1328 |
} |
} |
1329 |
if (pos == 0) { |
if (pos == 0) { |
1330 |
msg_box (dlg, _("Primary key can not be deleted!"), _("Key Edit"), MB_ERR); |
show_balloon_msg (lv->ctrl, _("Primary key can not be deleted!"), |
1331 |
|
IDI_ERROR); |
1332 |
return FALSE; |
return FALSE; |
1333 |
} |
} |
1334 |
|
|
1345 |
warn = ""; /* just get rid of the warning. */ |
warn = ""; /* just get rid of the warning. */ |
1346 |
|
|
1347 |
id = log_box (_("Key Edit"), MB_YESNO|MB_ICONWARNING, |
id = log_box (_("Key Edit"), MB_YESNO|MB_ICONWARNING, |
1348 |
_("\"Subkey %s.\"\n\n%s\n\n" |
_("\"Subkey %s, ID 0x%s.\"\n\n%s\n\n" |
1349 |
"Do you really want to delete this subkey?"), |
"Do you really want to DELETE this subkey?"), |
1350 |
tmp, warn); |
tmp, subk->keyid+8, warn); |
1351 |
if (id == IDNO) |
if (id == IDNO) |
1352 |
return FALSE; |
return FALSE; |
1353 |
|
|
1358 |
else { |
else { |
1359 |
listview_del_item (lv, pos); |
listview_del_item (lv, pos); |
1360 |
k->update = 1; |
k->update = 1; |
1361 |
status_box (dlg, _("Subkey successfully deleted."), _("GnuPG status")); |
status_box (dlg, _("Subkey successfully deleted."), _("GnuPG Status")); |
1362 |
} |
} |
1363 |
return err? FALSE : TRUE; |
return err? FALSE : TRUE; |
1364 |
} |
} |
1430 |
listview_add_sub_item (lv, pos, SUBK_COL_EXPIRES, buf); |
listview_add_sub_item (lv, pos, SUBK_COL_EXPIRES, buf); |
1431 |
k->update = 1; |
k->update = 1; |
1432 |
msg_box (dlg, _("Subkey expire date successfully set."), |
msg_box (dlg, _("Subkey expire date successfully set."), |
1433 |
_("GnuPG status"), MB_OK); |
_("GnuPG Status"), MB_OK); |
1434 |
} |
} |
1435 |
sfree_if_alloc (pass); |
sfree_if_alloc (pass); |
1436 |
return TRUE; |
return TRUE; |
1566 |
|
|
1567 |
|
|
1568 |
static int |
static int |
|
do_editkey_setpref (winpt_key_t k, HWND dlg, listview_ctrl_t lv) |
|
|
{ |
|
|
gpgme_error_t err; |
|
|
GpgKeyEdit ke; |
|
|
gpg_uid_info_t uidinf = NULL; |
|
|
char buf[256], *pass = NULL, *prefs = NULL; |
|
|
int pos, id, cancel=0, flags=0; |
|
|
|
|
|
pos = listview_get_curr_pos (lv); |
|
|
if (pos == -1) { |
|
|
msg_box (dlg, _("Please select a user ID."), _("Key Edit"), MB_ERR); |
|
|
return FALSE; |
|
|
} |
|
|
listview_get_item_text (lv, pos, 2, buf, DIM (buf)-1); |
|
|
id = do_find_userid (k->keyid, buf, NULL, &uidinf); |
|
|
if (id == -1) |
|
|
BUG (NULL); |
|
|
if (k->is_protected) { |
|
|
pass = request_key_passphrase (k->ctx, _("Key Edit"), &cancel); |
|
|
gpg_uid_info_release (uidinf); |
|
|
if (cancel) |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
get_userid_preflist (uidinf->prefs, &prefs, &flags); |
|
|
gpg_uid_info_release (uidinf); |
|
|
if (!prefs) { |
|
|
sfree_if_alloc (pass); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
ke.setKeyID (k->keyid); |
|
|
if (k->is_protected) |
|
|
ke.setPassphrase (pass); |
|
|
else |
|
|
ke.setNoPassphrase (true); |
|
|
err = ke.setUseridPreferences (id, prefs); |
|
|
if (err) |
|
|
msg_box (dlg, gpgme_strerror (err), _("Set user ID preferences"), MB_ERR); |
|
|
else { |
|
|
k->update = 1; |
|
|
status_box (dlg, _("User ID preferences successfully updated"), _("GnuPG Status")); |
|
|
} |
|
|
|
|
|
sfree_if_alloc (pass); |
|
|
free_if_alloc (prefs); |
|
|
return err? FALSE: TRUE; |
|
|
} |
|
|
|
|
|
|
|
|
static int |
|
1569 |
do_editkey_primary (winpt_key_t k, HWND dlg, listview_ctrl_t lv) |
do_editkey_primary (winpt_key_t k, HWND dlg, listview_ctrl_t lv) |
1570 |
{ |
{ |
1571 |
gpgme_error_t err; |
gpgme_error_t err; |
1695 |
} |
} |
1696 |
} |
} |
1697 |
gpg_uid_info_release (inf); |
gpg_uid_info_release (inf); |
1698 |
if (pos == -1) { |
if (pos == -1) { |
1699 |
msg_box (dlg, _("No preferences available."), _("Key Edit"), MB_ERR); |
msg_box (dlg, _("No preferences available."), _("Key Edit"), MB_ERR); |
1700 |
EndDialog (dlg, FALSE); |
EndDialog (dlg, FALSE); |
1701 |
break; |
break; |
1782 |
_snprintf (inf, DIM (inf)-1, _("user ID \"%s\".\n\n" |
_snprintf (inf, DIM (inf)-1, _("user ID \"%s\".\n\n" |
1783 |
"All signatures on this user ID will be also deleted." |
"All signatures on this user ID will be also deleted." |
1784 |
"\n\n" |
"\n\n" |
1785 |
"Do you really want to delete this user ID?"), |
"Do you really want to DELETE this user ID?"), |
1786 |
name); |
name); |
1787 |
if (msg_box (dlg, inf, _("Key Edit"), MB_YESNO|MB_ICONWARNING) == IDNO) |
if (msg_box (dlg, inf, _("Key Edit"), MB_YESNO|MB_ICONWARNING) == IDNO) |
1788 |
return FALSE; |
return FALSE; |
1874 |
do_editkey_enable_disable (winpt_key_t k, HWND dlg, |
do_editkey_enable_disable (winpt_key_t k, HWND dlg, |
1875 |
listview_ctrl_t lv, int enable) |
listview_ctrl_t lv, int enable) |
1876 |
{ |
{ |
1877 |
km_enable_disable_key (lv, dlg, 0, enable); |
gpgme_error_t err; |
1878 |
k->update = 1; |
gpgme_key_t key; |
1879 |
|
GpgKeyEdit ke; |
1880 |
|
|
1881 |
|
// FIXME: We had to duplicate the code here since the key manager |
1882 |
|
// code uses the listview to get the pointer to the key! |
1883 |
|
key = k->ctx; |
1884 |
|
ke.setKeyID (key->subkeys->keyid); |
1885 |
|
|
1886 |
|
err = enable? ke.enable () : ke.disable (); |
1887 |
|
if (!err) { |
1888 |
|
show_msg (dlg, 1500, _("Key status changed.")); |
1889 |
|
k->update = 1; |
1890 |
|
} |
1891 |
|
else |
1892 |
|
msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR); |
1893 |
} |
} |
1894 |
|
|
1895 |
|
|
2082 |
TOOLINFO ti; |
TOOLINFO ti; |
2083 |
HWND tt; |
HWND tt; |
2084 |
|
|
2085 |
tt = CreateWindow (TOOLTIPS_CLASS, (LPSTR) NULL, TTS_ALWAYSTIP, |
tt = CreateWindow (TOOLTIPS_CLASS, (LPSTR) NULL, TTS_ALWAYSTIP|TTS_BALLOON , |
2086 |
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, |
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, |
2087 |
CW_USEDEFAULT, |
CW_USEDEFAULT, |
2088 |
NULL, (HMENU) NULL, glob_hinst, NULL); |
NULL, (HMENU) NULL, glob_hinst, NULL); |
2100 |
} |
} |
2101 |
|
|
2102 |
|
|
2103 |
|
#define TTM_POPUP (WM_USER+34) |
2104 |
|
|
2105 |
/* Dialog box procedure for the edit key dialog. */ |
/* Dialog box procedure for the edit key dialog. */ |
2106 |
BOOL CALLBACK |
BOOL CALLBACK |
2107 |
keyedit_main_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
keyedit_main_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
2108 |
{ |
{ |
2109 |
static winpt_key_t k; |
static winpt_key_t k; |
2110 |
static listview_ctrl_t lvsub = NULL, lvuid = NULL; |
static listview_ctrl_t lvsub = NULL; |
2111 |
static HWND tt; |
static listview_ctrl_t lvuid = NULL; |
2112 |
|
static HWND tt = NULL; |
2113 |
int cmd; |
int cmd; |
2114 |
HWND item; |
HWND item; |
2115 |
|
|
2135 |
} |
} |
2136 |
} |
} |
2137 |
tt = create_header_tooltip (dlg); |
tt = create_header_tooltip (dlg); |
2138 |
|
|
2139 |
item = GetDlgItem (dlg, IDC_KEYEDIT_UIDLIST); |
item = GetDlgItem (dlg, IDC_KEYEDIT_UIDLIST); |
2140 |
keyedit_uid_proc.opaque = (void*)k; |
keyedit_uid_proc.opaque = (void*)k; |
2141 |
keyedit_uid_proc.dlg = dlg; |
keyedit_uid_proc.dlg = dlg; |
2149 |
BUG (NULL); |
BUG (NULL); |
2150 |
} |
} |
2151 |
} |
} |
2152 |
if (k->ctx->revoked) { |
if (k->ctx->revoked || k->ctx->expired) { |
2153 |
EnableWindow (GetDlgItem (dlg, IDC_KEYEDIT_CMD), FALSE); |
EnableWindow (GetDlgItem (dlg, IDC_KEYEDIT_CMD), FALSE); |
2154 |
EnableWindow (GetDlgItem (dlg, IDOK), FALSE); |
EnableWindow (GetDlgItem (dlg, IDOK), FALSE); |
2155 |
} |
} |
2160 |
SetDlgItemText (dlg, IDOK, _("&OK")); |
SetDlgItemText (dlg, IDOK, _("&OK")); |
2161 |
if (!check_desig_rev (k)) |
if (!check_desig_rev (k)) |
2162 |
ShowWindow (GetDlgItem (dlg, IDC_KEYEDIT_REVOKE), SW_HIDE); |
ShowWindow (GetDlgItem (dlg, IDC_KEYEDIT_REVOKE), SW_HIDE); |
2163 |
SetWindowText (dlg, _("Key Edit")); |
if (k->is_v3) |
2164 |
|
SetWindowText (dlg, _("Key Edit (PGP 2.6.x mode)")); |
2165 |
|
else |
2166 |
|
SetWindowText (dlg, _("Key Edit")); |
2167 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
2168 |
center_window (dlg, NULL); |
center_window (dlg, NULL); |
2169 |
return TRUE; |
return TRUE; |
2177 |
listview_release (lvuid); |
listview_release (lvuid); |
2178 |
lvuid = NULL; |
lvuid = NULL; |
2179 |
} |
} |
2180 |
|
if (tt != NULL) |
2181 |
|
DestroyWindow (tt); |
2182 |
|
|
2183 |
|
balloon_msg_disable (); |
2184 |
break; |
break; |
2185 |
|
|
2186 |
case WM_NOTIFY: |
case WM_NOTIFY: |
2191 |
if (notify->code == NM_DBLCLK) |
if (notify->code == NM_DBLCLK) |
2192 |
do_editkey_showpref (k, dlg, lvuid); |
do_editkey_showpref (k, dlg, lvuid); |
2193 |
else if (notify->code == NM_RCLICK && k->key_pair) { |
else if (notify->code == NM_RCLICK && k->key_pair) { |
2194 |
|
if (listview_count_items (lvuid, 0) == 1) |
2195 |
|
break; |
2196 |
HMENU hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYEDIT)); |
HMENU hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYEDIT)); |
2197 |
HMENU popup = GetSubMenu (hm, 0); |
HMENU popup = GetSubMenu (hm, 0); |
2198 |
POINT p; |
POINT p; |
2199 |
|
|
2200 |
|
set_menu_text (popup, ID_KEYEDIT_UID_PRIM, _("Flag user ID as &primary")); |
2201 |
|
set_menu_text (popup, ID_KEYEDIT_UID_DEL, _("&Delete user ID")); |
2202 |
|
set_menu_text (popup, ID_KEYEDIT_UID_REV, _("&Revoke user ID")); |
2203 |
GetCursorPos (&p); |
GetCursorPos (&p); |
2204 |
TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL); |
TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL); |
2205 |
DestroyMenu (hm); |
DestroyMenu (hm); |
2212 |
case IDOK: |
case IDOK: |
2213 |
cmd = lookup_cmd (dlg); |
cmd = lookup_cmd (dlg); |
2214 |
if (cmd == LB_ERR) { |
if (cmd == LB_ERR) { |
2215 |
msg_box( dlg, _("Please select a command."), _("Key Edit"), MB_INFO ); |
msg_box (dlg, _("Please select a command."), _("Key Edit"), MB_INFO); |
2216 |
return FALSE; |
return FALSE; |
2217 |
} |
} |
2218 |
if (k->is_v3 && is_cmd_openpgp (cmd)) { |
if (k->is_v3 && is_cmd_openpgp (cmd)) { |
2232 |
case CMD_ADDPHOTO: keyedit_add_photo( k, dlg ); break; |
case CMD_ADDPHOTO: keyedit_add_photo( k, dlg ); break; |
2233 |
case CMD_REVUID: do_editkey_revuid( k, dlg, lvuid ); break; |
case CMD_REVUID: do_editkey_revuid( k, dlg, lvuid ); break; |
2234 |
case CMD_DELUID: do_editkey_deluid( k, dlg, lvuid ); break; |
case CMD_DELUID: do_editkey_deluid( k, dlg, lvuid ); break; |
2235 |
case CMD_PASSWD: keyedit_change_passwd( k, dlg ); break; |
case CMD_PASSWD: keyedit_change_passwd (k, dlg); break; |
2236 |
case CMD_PRIMARY: do_editkey_primary( k, dlg, lvuid ); break; |
case CMD_PRIMARY: do_editkey_primary (k, dlg, lvuid); break; |
2237 |
case CMD_ENABLE: do_editkey_enable_disable (k, dlg, lvsub, 1); break; |
case CMD_ENABLE: do_editkey_enable_disable (k, dlg, lvsub, 1); break; |
2238 |
case CMD_DISABLE: do_editkey_enable_disable (k, dlg, lvsub, 0); break; |
case CMD_DISABLE: do_editkey_enable_disable (k, dlg, lvsub, 0); break; |
2239 |
case CMD_CHECK: do_editkey_check (k, dlg); break; |
case CMD_CHECK: do_editkey_check (k, dlg); break; |