1 |
/* wptKeyEditDlgs.cpp - GPG key edit dialogs |
/* wptKeyEditDlgs.cpp - GPG key edit dialogs |
2 |
* Copyright (C) 2002-2006 Timo Schulz |
* Copyright (C) 2002-2007 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
* GNU General Public License for more details. |
|
* |
|
|
* You should have received a copy of the GNU General Public License |
|
|
* along with WinPT; if not, write to the Free Software Foundation, |
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
15 |
*/ |
*/ |
16 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
17 |
#include <config.h> |
#include <config.h> |
134 |
struct keygen_cb_s { |
struct keygen_cb_s { |
135 |
int bits; |
int bits; |
136 |
int algo; |
int algo; |
137 |
DWORD expire; |
DWORD expire; /* date of expiration or '0' for infinite valid. */ |
138 |
char *fpr; |
char *fpr; |
139 |
char *name; |
char *name; |
140 |
char *comment; |
char *comment; |
262 |
do_find_userid (const char *keyid, const char *email, |
do_find_userid (const char *keyid, const char *email, |
263 |
const char *name, gpg_uid_info_t *r_inf) |
const char *name, gpg_uid_info_t *r_inf) |
264 |
{ |
{ |
265 |
GpgKeyEdit *ke; |
GpgKeyEdit ke; |
266 |
gpgme_error_t err; |
gpgme_error_t err; |
267 |
gpg_uid_info_t inf, ui; |
gpg_uid_info_t inf, ui; |
268 |
int pos = -1; |
int pos = -1; |
269 |
|
|
270 |
ke = create_GpgKeyEdit (keyid); |
ke.setKeyID (keyid); |
271 |
err = ke->getUseridInfo (&inf); |
err = ke.getUseridInfo (&inf); |
|
delete ke; |
|
272 |
if (err) { |
if (err) { |
273 |
log_box (_("user ID"), MB_ERR, |
log_box (_("user ID"), MB_ERR, |
274 |
_("Could not get key information for: \"%s\":\n%s"), |
_("Could not get key information for: \"%s\":\n%s"), |
332 |
keyedit_addphoto_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
keyedit_addphoto_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
333 |
{ |
{ |
334 |
static keyedit_cb_t cb; |
static keyedit_cb_t cb; |
|
GpgKeyEdit *ke; |
|
335 |
gpgme_error_t err; |
gpgme_error_t err; |
336 |
const char *s; |
const char *s; |
337 |
char file[128]; |
char file[128]; |
378 |
if (id == IDNO) |
if (id == IDNO) |
379 |
return TRUE; |
return TRUE; |
380 |
} |
} |
381 |
ke = create_GpgKeyEdit (cb->keyid); |
|
382 |
if (cb->pass) |
{ |
383 |
ke->setPassphrase (cb->pass); |
GpgKeyEdit ke; |
384 |
else |
|
385 |
ke->setNoPassphrase (true); |
ke.setKeyID (cb->keyid); |
386 |
err = ke->addPhotoid (file); |
if (cb->pass) |
387 |
delete ke; |
ke.setPassphrase (cb->pass); |
388 |
|
else |
389 |
|
ke.setNoPassphrase (true); |
390 |
|
err = ke.addPhotoid (file); |
391 |
|
} |
392 |
if (err) { |
if (err) { |
393 |
msg_box (dlg, gpgme_strerror (err), _("Add Photo"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Add Photo"), MB_ERR); |
394 |
return FALSE; |
return FALSE; |
417 |
{ |
{ |
418 |
static keyedit_cb_t cb; |
static keyedit_cb_t cb; |
419 |
gpgme_error_t err; |
gpgme_error_t err; |
|
GpgKeyEdit *ke; |
|
420 |
char *uid=NULL; |
char *uid=NULL; |
421 |
|
|
422 |
switch (msg) { |
switch (msg) { |
443 |
return FALSE; |
return FALSE; |
444 |
} |
} |
445 |
|
|
446 |
ke = create_GpgKeyEdit (cb->keyid); |
{ |
447 |
if (cb->pass) |
GpgKeyEdit ke; |
448 |
ke->setPassphrase (cb->pass); |
|
449 |
else |
ke.setKeyID (cb->keyid); |
450 |
ke->setNoPassphrase (true); |
if (cb->pass) |
451 |
err = ke->addDesignatedRevoker (uid); |
ke.setPassphrase (cb->pass); |
452 |
delete ke; |
else |
453 |
|
ke.setNoPassphrase (true); |
454 |
|
err = ke.addDesignatedRevoker (uid); |
455 |
|
} |
456 |
|
|
457 |
safe_free (uid); |
safe_free (uid); |
458 |
if (err) { |
if (err) { |
459 |
msg_box (dlg, gpgme_strerror (err), _("Add Revoker"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Add Revoker"), MB_ERR); |
484 |
static keyedit_cb_t ctx; |
static keyedit_cb_t ctx; |
485 |
keygen_cb_t keygen; |
keygen_cb_t keygen; |
486 |
gpgme_error_t err; |
gpgme_error_t err; |
|
GpgKeyEdit *ke; |
|
487 |
char *utf8_name = NULL; |
char *utf8_name = NULL; |
488 |
char *utf8_comment = NULL; |
char *utf8_comment = NULL; |
489 |
char email[128]; |
char email[128]; |
534 |
|
|
535 |
rc = GetDlgItemText_utf8 (dlg, IDC_ADDUID_COMMENT, &utf8_comment); |
rc = GetDlgItemText_utf8 (dlg, IDC_ADDUID_COMMENT, &utf8_comment); |
536 |
|
|
537 |
ke = create_GpgKeyEdit (ctx->keyid); |
{ |
538 |
if (ctx->is_protected) |
GpgKeyEdit ke; |
539 |
ke->setPassphrase (ctx->pass); |
|
540 |
else |
ke.setKeyID (ctx->keyid); |
541 |
ke->setNoPassphrase (true); |
if (ctx->is_protected) |
542 |
err = ke->addUserid (utf8_name, utf8_comment, email); |
ke.setPassphrase (ctx->pass); |
543 |
|
else |
544 |
|
ke.setNoPassphrase (true); |
545 |
|
err = ke.addUserid (utf8_name, utf8_comment, email); |
546 |
|
} |
547 |
if (err) |
if (err) |
548 |
msg_box (dlg, gpgme_strerror (err), _("UserID"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("UserID"), MB_ERR); |
549 |
else { |
else { |
554 |
keygen->comment = utf8_comment; |
keygen->comment = utf8_comment; |
555 |
keygen->email = m_strdup (email); |
keygen->email = m_strdup (email); |
556 |
} |
} |
|
delete ke; |
|
557 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, TRUE); |
558 |
return TRUE; |
return TRUE; |
559 |
|
|
620 |
{ |
{ |
621 |
static keyedit_cb_t ctx; |
static keyedit_cb_t ctx; |
622 |
keygen_cb_t keygen; |
keygen_cb_t keygen; |
|
GpgKeyEdit *ke; |
|
623 |
gpgme_error_t err; |
gpgme_error_t err; |
624 |
SYSTEMTIME st; |
SYSTEMTIME st; |
625 |
HWND hwnd; |
HWND hwnd; |
704 |
if (valid > 0) |
if (valid > 0) |
705 |
keygen->expire = time (NULL) + valid*24*60*60; |
keygen->expire = time (NULL) + valid*24*60*60; |
706 |
|
|
707 |
ke = create_GpgKeyEdit (ctx->keyid); |
{ |
708 |
ke->setCallback (keygen_cb, NULL); |
GpgKeyEdit ke; |
709 |
if (ctx->is_protected) |
|
710 |
ke->setPassphrase (ctx->pass); |
ke.setKeyID (ctx->keyid); |
711 |
else |
ke.setCallback (keygen_cb, NULL); |
712 |
ke->setNoPassphrase (true); |
if (ctx->is_protected) |
713 |
keygen_cb_dlg_create (); |
ke.setPassphrase (ctx->pass); |
714 |
|
else |
715 |
err = ke->addSubkey ((gpgme_pubkey_algo_t)index, size, valid); |
ke.setNoPassphrase (true); |
716 |
|
keygen_cb_dlg_create (); |
717 |
|
err = ke.addSubkey ((gpgme_pubkey_algo_t)index, size, valid); |
718 |
|
} |
719 |
keygen->fpr = get_subkey_keyid (ctx->keyid); |
keygen->fpr = get_subkey_keyid (ctx->keyid); |
720 |
keygen_cb_dlg_destroy (1); |
keygen_cb_dlg_destroy (1); |
721 |
if (err) |
if (err) |
725 |
_("GnuPG Status"), MB_OK); |
_("GnuPG Status"), MB_OK); |
726 |
ctx->finished = 1; |
ctx->finished = 1; |
727 |
} |
} |
|
delete ke; |
|
728 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, TRUE); |
729 |
return TRUE; |
return TRUE; |
730 |
|
|
852 |
BOOL |
BOOL |
853 |
keyedit_set_pref_keyserver (winpt_key_t k, HWND dlg) |
keyedit_set_pref_keyserver (winpt_key_t k, HWND dlg) |
854 |
{ |
{ |
855 |
GpgKeyEdit *ke; |
GpgKeyEdit ke; |
856 |
gpgme_error_t err; |
gpgme_error_t err; |
857 |
struct URL_ctx_s *url; |
struct URL_ctx_s *url; |
858 |
char *pass = NULL; |
char *pass = NULL; |
869 |
return FALSE; |
return FALSE; |
870 |
} |
} |
871 |
|
|
872 |
ke = create_GpgKeyEdit (k->keyid); |
ke.setKeyID (k->keyid); |
873 |
if (k->is_protected) |
if (k->is_protected) |
874 |
ke->setPassphrase (pass); |
ke.setPassphrase (pass); |
875 |
else |
else |
876 |
ke->setNoPassphrase (true); |
ke.setNoPassphrase (true); |
877 |
err = ke->setPreferredKeyserver (-1, url->url); |
err = ke.setPreferredKeyserver (-1, url->url); |
878 |
if (!err) |
if (!err) |
879 |
msg_box (dlg, _("Preferred keyserver successfully set."), |
msg_box (dlg, _("Preferred keyserver successfully set."), |
880 |
_("Key Edit"), MB_OK); |
_("Key Edit"), MB_OK); |
882 |
msg_box (dlg, gpgme_strerror (err), _("Key Edit"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Key Edit"), MB_ERR); |
883 |
|
|
884 |
sfree_if_alloc (pass); |
sfree_if_alloc (pass); |
|
delete ke; |
|
885 |
delete url; |
delete url; |
886 |
return err == 0? 0 : WPTERR_GENERAL; |
return err == 0? 0 : WPTERR_GENERAL; |
887 |
} |
} |
1005 |
keyedit_change_passwd (winpt_key_t k, HWND dlg) |
keyedit_change_passwd (winpt_key_t k, HWND dlg) |
1006 |
{ |
{ |
1007 |
gpgme_error_t err; |
gpgme_error_t err; |
1008 |
GpgKeyEdit *ke; |
GpgKeyEdit ke; |
1009 |
char *old_pass = NULL; |
char *old_pass = NULL; |
1010 |
char *new_pass = NULL; |
char *new_pass = NULL; |
1011 |
int cancel = 0; |
int cancel = 0; |
1047 |
} |
} |
1048 |
} |
} |
1049 |
|
|
1050 |
ke = create_GpgKeyEdit (k->keyid); |
ke.setKeyID (k->keyid); |
1051 |
ke->setPassphrase (k->is_protected? old_pass : NULL); |
ke.setPassphrase (k->is_protected? old_pass : NULL); |
1052 |
if (!k->is_protected) |
if (!k->is_protected) |
1053 |
ke->setNoPassphrase (true); |
ke.setNoPassphrase (true); |
1054 |
err = ke->changePassphrase (new_pass, 1); |
err = ke.changePassphrase (new_pass, 1); |
1055 |
if (err) |
if (err) |
1056 |
msg_box (dlg, gpgme_strerror (err), _("Change Password"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Change Password"), MB_ERR); |
1057 |
else |
else |
1058 |
msg_box (dlg, _("Passphrase successfully changed."), _("GnuPG status"), MB_OK); |
msg_box (dlg, _("Passphrase successfully changed."), _("GnuPG status"), MB_OK); |
1059 |
sfree_if_alloc (old_pass); |
sfree_if_alloc (old_pass); |
1060 |
sfree_if_alloc (new_pass); |
sfree_if_alloc (new_pass); |
1061 |
delete ke; |
|
1062 |
return TRUE; |
return TRUE; |
1063 |
} |
} |
1064 |
|
|
1287 |
{ |
{ |
1288 |
gpgme_error_t err; |
gpgme_error_t err; |
1289 |
gpgme_subkey_t subk; |
gpgme_subkey_t subk; |
1290 |
GpgKeyEdit *ke; |
GpgKeyEdit ke; |
1291 |
int pos, id; |
int pos, id; |
1292 |
const char *warn; |
const char *warn; |
1293 |
char tmp[64]; |
char tmp[64]; |
1328 |
if (id == IDNO) |
if (id == IDNO) |
1329 |
return FALSE; |
return FALSE; |
1330 |
|
|
1331 |
ke = create_GpgKeyEdit (k->keyid); |
ke.setKeyID (k->keyid); |
1332 |
err = ke->delKey (pos); |
err = ke.delKey (pos); |
1333 |
if (err) |
if (err) |
1334 |
msg_box (dlg, gpgme_strerror (err), _("Delete Subkey"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Delete Subkey"), MB_ERR); |
1335 |
else { |
else { |
1337 |
k->update = 1; |
k->update = 1; |
1338 |
status_box (dlg, _("Subkey successfully deleted."), _("GnuPG status")); |
status_box (dlg, _("Subkey successfully deleted."), _("GnuPG status")); |
1339 |
} |
} |
|
delete ke; |
|
1340 |
return err? FALSE : TRUE; |
return err? FALSE : TRUE; |
1341 |
} |
} |
1342 |
|
|
1347 |
do_editkey_expire (winpt_key_t k, HWND dlg, listview_ctrl_t lv) |
do_editkey_expire (winpt_key_t k, HWND dlg, listview_ctrl_t lv) |
1348 |
{ |
{ |
1349 |
gpgme_error_t err; |
gpgme_error_t err; |
1350 |
GpgKeyEdit *ke; |
GpgKeyEdit ke; |
1351 |
date_s udd = {0}; |
date_s udd = {0}; |
1352 |
char buf[256], * pass = NULL; |
char buf[256], * pass = NULL; |
1353 |
time_t exp; |
time_t exp; |
1393 |
return FALSE; |
return FALSE; |
1394 |
} |
} |
1395 |
exp = w32_mktime (&udd.st); |
exp = w32_mktime (&udd.st); |
1396 |
ke = create_GpgKeyEdit (k->keyid); |
|
1397 |
|
ke.setKeyID (k->keyid); |
1398 |
if (k->is_protected) |
if (k->is_protected) |
1399 |
ke->setPassphrase (pass); |
ke.setPassphrase (pass); |
1400 |
else |
else |
1401 |
ke->setNoPassphrase (true); |
ke.setNoPassphrase (true); |
1402 |
err = ke->setKeyExpireDate (pos, exp, false); |
err = ke.setKeyExpireDate (pos, exp, false); |
1403 |
if (err) |
if (err) |
1404 |
msg_box (dlg, gpgme_strerror (err), _("Expire Subkey"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Expire Subkey"), MB_ERR); |
1405 |
else { |
else { |
1410 |
_("GnuPG status"), MB_OK); |
_("GnuPG status"), MB_OK); |
1411 |
} |
} |
1412 |
sfree_if_alloc (pass); |
sfree_if_alloc (pass); |
|
delete ke; |
|
1413 |
return TRUE; |
return TRUE; |
1414 |
} |
} |
1415 |
|
|
1421 |
do_editkey_revoke (winpt_key_t k, HWND dlg, listview_ctrl_t lv) |
do_editkey_revoke (winpt_key_t k, HWND dlg, listview_ctrl_t lv) |
1422 |
{ |
{ |
1423 |
gpgme_error_t err; |
gpgme_error_t err; |
1424 |
GpgKeyEdit *ke; |
GpgKeyEdit ke; |
1425 |
char buf[256]; |
char buf[256]; |
1426 |
char *pass = NULL; |
char *pass = NULL; |
1427 |
int j, cancel = 0; |
int j, cancel = 0; |
1455 |
return FALSE; |
return FALSE; |
1456 |
} |
} |
1457 |
|
|
1458 |
ke = create_GpgKeyEdit (k->keyid); |
ke.setKeyID (k->keyid); |
1459 |
if (k->is_protected) |
if (k->is_protected) |
1460 |
ke->setPassphrase (pass); |
ke.setPassphrase (pass); |
1461 |
else |
else |
1462 |
ke->setNoPassphrase (true); |
ke.setNoPassphrase (true); |
1463 |
err = ke->revokeSubkey (j, 0, NULL); |
err = ke.revokeSubkey (j, 0, NULL); |
1464 |
if (err) |
if (err) |
1465 |
msg_box( dlg, gpgme_strerror (err), _("Revoke Subkey"), MB_ERR); |
msg_box( dlg, gpgme_strerror (err), _("Revoke Subkey"), MB_ERR); |
1466 |
else { |
else { |
1469 |
msg_box( dlg, _("Subkey successfully revoked."), _("GnuPG Status"), MB_OK ); |
msg_box( dlg, _("Subkey successfully revoked."), _("GnuPG Status"), MB_OK ); |
1470 |
} |
} |
1471 |
sfree_if_alloc (pass); |
sfree_if_alloc (pass); |
|
delete ke; |
|
1472 |
return TRUE; |
return TRUE; |
1473 |
} |
} |
1474 |
|
|
1479 |
do_editkey_revuid (winpt_key_t k, HWND dlg, listview_ctrl_t lv) |
do_editkey_revuid (winpt_key_t k, HWND dlg, listview_ctrl_t lv) |
1480 |
{ |
{ |
1481 |
gpgme_error_t err; |
gpgme_error_t err; |
1482 |
GpgKeyEdit *ke; |
GpgKeyEdit ke; |
1483 |
char buf[128], email[128]; |
char buf[128], email[128]; |
1484 |
char inf[512]; |
char inf[512]; |
1485 |
char *pass = NULL; |
char *pass = NULL; |
1524 |
if (id == -1) |
if (id == -1) |
1525 |
BUG (NULL); |
BUG (NULL); |
1526 |
|
|
1527 |
ke = create_GpgKeyEdit (k->keyid); |
ke.setKeyID (k->keyid); |
1528 |
if (k->is_protected) |
if (k->is_protected) |
1529 |
ke->setPassphrase (pass); |
ke.setPassphrase (pass); |
1530 |
else |
else |
1531 |
ke->setNoPassphrase (true); |
ke.setNoPassphrase (true); |
1532 |
err = ke->revokeUserid (id); |
err = ke.revokeUserid (id); |
1533 |
if (err) |
if (err) |
1534 |
msg_box (dlg, gpgme_strerror (err), _("Revoke User ID"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Revoke User ID"), MB_ERR); |
1535 |
else { |
else { |
1538 |
status_box (dlg, _("User ID successfully revoked"), _("GnuPG Status")); |
status_box (dlg, _("User ID successfully revoked"), _("GnuPG Status")); |
1539 |
} |
} |
1540 |
sfree_if_alloc (pass); |
sfree_if_alloc (pass); |
|
delete ke; |
|
1541 |
return err? FALSE : TRUE; |
return err? FALSE : TRUE; |
1542 |
} |
} |
1543 |
|
|
1546 |
do_editkey_setpref (winpt_key_t k, HWND dlg, listview_ctrl_t lv) |
do_editkey_setpref (winpt_key_t k, HWND dlg, listview_ctrl_t lv) |
1547 |
{ |
{ |
1548 |
gpgme_error_t err; |
gpgme_error_t err; |
1549 |
GpgKeyEdit *ke; |
GpgKeyEdit ke; |
1550 |
gpg_uid_info_t uidinf = NULL; |
gpg_uid_info_t uidinf = NULL; |
1551 |
char buf[256], *pass = NULL, *prefs = NULL; |
char buf[256], *pass = NULL, *prefs = NULL; |
1552 |
int pos, id, cancel=0, flags=0; |
int pos, id, cancel=0, flags=0; |
1574 |
return FALSE; |
return FALSE; |
1575 |
} |
} |
1576 |
|
|
1577 |
ke = create_GpgKeyEdit (k->keyid); |
ke.setKeyID (k->keyid); |
1578 |
if (k->is_protected) |
if (k->is_protected) |
1579 |
ke->setPassphrase (pass); |
ke.setPassphrase (pass); |
1580 |
else |
else |
1581 |
ke->setNoPassphrase (true); |
ke.setNoPassphrase (true); |
1582 |
err = ke->setUseridPreferences (id, prefs); |
err = ke.setUseridPreferences (id, prefs); |
1583 |
if (err) |
if (err) |
1584 |
msg_box (dlg, gpgme_strerror (err), _("Set user ID preferences"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Set user ID preferences"), MB_ERR); |
1585 |
else { |
else { |
1589 |
|
|
1590 |
sfree_if_alloc (pass); |
sfree_if_alloc (pass); |
1591 |
free_if_alloc (prefs); |
free_if_alloc (prefs); |
|
delete ke; |
|
1592 |
return err? FALSE: TRUE; |
return err? FALSE: TRUE; |
1593 |
} |
} |
1594 |
|
|
1597 |
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) |
1598 |
{ |
{ |
1599 |
gpgme_error_t err; |
gpgme_error_t err; |
1600 |
GpgKeyEdit *ke; |
GpgKeyEdit ke; |
1601 |
int j, id, cancel=0; |
int j, id, cancel=0; |
1602 |
char valid[32]; |
char valid[32]; |
1603 |
char buf[256], *pass = NULL; |
char buf[256], *pass = NULL; |
1621 |
return FALSE; |
return FALSE; |
1622 |
} |
} |
1623 |
|
|
1624 |
ke = create_GpgKeyEdit (k->keyid); |
ke.setKeyID (k->keyid); |
1625 |
if (k->is_protected) |
if (k->is_protected) |
1626 |
ke->setPassphrase (pass); |
ke.setPassphrase (pass); |
1627 |
else |
else |
1628 |
ke->setNoPassphrase (true); |
ke.setNoPassphrase (true); |
1629 |
err = ke->setPrimaryUserid (id); |
err = ke.setPrimaryUserid (id); |
1630 |
if (err) |
if (err) |
1631 |
msg_box (dlg, gpgme_strerror (err), _("Primary"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Primary"), MB_ERR); |
1632 |
else { |
else { |
1635 |
} |
} |
1636 |
|
|
1637 |
sfree_if_alloc (pass); |
sfree_if_alloc (pass); |
|
delete ke; |
|
1638 |
return err? FALSE : TRUE; |
return err? FALSE : TRUE; |
1639 |
} |
} |
1640 |
|
|
1787 |
do_editkey_deluid (winpt_key_t k, HWND dlg, listview_ctrl_t lv) |
do_editkey_deluid (winpt_key_t k, HWND dlg, listview_ctrl_t lv) |
1788 |
{ |
{ |
1789 |
gpgme_error_t err; |
gpgme_error_t err; |
1790 |
GpgKeyEdit *ke; |
GpgKeyEdit ke; |
1791 |
char email[128], name[128]; |
char email[128], name[128]; |
1792 |
char inf[384]; |
char inf[384]; |
1793 |
int pos, id = 0; |
int pos, id = 0; |
1821 |
if (id == -1) |
if (id == -1) |
1822 |
BUG (NULL); |
BUG (NULL); |
1823 |
|
|
1824 |
ke = create_GpgKeyEdit (k->keyid); |
ke.setKeyID (k->keyid); |
1825 |
err = ke->delUserid (id); |
err = ke.delUserid (id); |
1826 |
if (err) |
if (err) |
1827 |
msg_box (dlg, gpgme_strerror (err), _("Delete User ID"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Delete User ID"), MB_ERR); |
1828 |
else { |
else { |
1830 |
k->update = 1; |
k->update = 1; |
1831 |
status_box (dlg, _("User ID successfully deleted"), _("GnuPG Status")); |
status_box (dlg, _("User ID successfully deleted"), _("GnuPG Status")); |
1832 |
} |
} |
|
delete ke; |
|
1833 |
return err? FALSE : TRUE; |
return err? FALSE : TRUE; |
1834 |
} |
} |
1835 |
|
|
1911 |
do_editkey_minimize (winpt_key_t k, HWND dlg) |
do_editkey_minimize (winpt_key_t k, HWND dlg) |
1912 |
{ |
{ |
1913 |
gpgme_error_t err; |
gpgme_error_t err; |
1914 |
GpgKeyEdit *ke; |
GpgKeyEdit ke; |
1915 |
|
|
1916 |
ke = create_GpgKeyEdit (k->keyid); |
ke.setKeyID (k->keyid); |
1917 |
err = ke->minimizeKey (); |
err = ke.minimizeKey (); |
1918 |
if (err) |
if (err) |
1919 |
msg_box (dlg, gpgme_strerror (err), _("Key Edit"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Key Edit"), MB_ERR); |
1920 |
else { |
else { |
1921 |
msg_box (dlg, _("Finished to compact key."), _("Key Edit"), MB_OK); |
msg_box (dlg, _("Finished to compact key."), _("Key Edit"), MB_OK); |
1922 |
k->update = 1; |
k->update = 1; |
1923 |
} |
} |
|
delete ke; |
|
1924 |
} |
} |
1925 |
|
|
1926 |
|
|
1928 |
do_editkey_clean (winpt_key_t k, HWND dlg) |
do_editkey_clean (winpt_key_t k, HWND dlg) |
1929 |
{ |
{ |
1930 |
gpgme_error_t err; |
gpgme_error_t err; |
1931 |
GpgKeyEdit *ke; |
GpgKeyEdit ke; |
1932 |
|
|
1933 |
ke = create_GpgKeyEdit (k->keyid); |
ke.setKeyID (k->keyid); |
1934 |
err = ke->cleanKey (); |
err = ke.cleanKey (); |
1935 |
if (err) |
if (err) |
1936 |
msg_box (dlg, gpgme_strerror (err), _("Key Edit"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Key Edit"), MB_ERR); |
1937 |
else { |
else { |
1938 |
msg_box (dlg, _("Finished to compact key."), _("Key Edit"), MB_OK); |
msg_box (dlg, _("Finished to compact key."), _("Key Edit"), MB_OK); |
1939 |
k->update = 1; |
k->update = 1; |
1940 |
} |
} |
|
delete ke; |
|
1941 |
} |
} |
1942 |
|
|
1943 |
|
|
1960 |
{ |
{ |
1961 |
gpgme_error_t err; |
gpgme_error_t err; |
1962 |
winpt_key_s signer; |
winpt_key_s signer; |
1963 |
GpgKeyEdit *ke; |
GpgKeyEdit ke; |
1964 |
char *pass = NULL; |
char *pass = NULL; |
1965 |
char *defkey; |
char *defkey; |
1966 |
char email[64], name[128], valid[32]; |
char email[64], name[128], valid[32]; |
1997 |
if (cancel) |
if (cancel) |
1998 |
return FALSE; |
return FALSE; |
1999 |
} |
} |
2000 |
ke = create_GpgKeyEdit (k->keyid); |
ke.setKeyID (k->keyid); |
2001 |
if (signer.is_protected) |
if (signer.is_protected) |
2002 |
ke->setPassphrase (pass); |
ke.setPassphrase (pass); |
2003 |
else |
else |
2004 |
ke->setNoPassphrase (true); |
ke.setNoPassphrase (true); |
2005 |
ke->setLocalUser (signer.ctx); |
ke.setLocalUser (signer.ctx); |
2006 |
err = ke->signUserid (uid_index, |
err = ke.signUserid (uid_index, |
2007 |
mode == CMD_SIGN? GPG_EDITKEY_SIGN : GPG_EDITKEY_LSIGN, |
mode == CMD_SIGN? GPG_EDITKEY_SIGN : GPG_EDITKEY_LSIGN, |
2008 |
0, NULL); |
0, NULL); |
2009 |
if (!err) { |
if (!err) { |
2012 |
} |
} |
2013 |
else |
else |
2014 |
msg_box (dlg, gpgme_strerror (err), _("Key Edit"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Key Edit"), MB_ERR); |
2015 |
delete ke; |
|
2016 |
sfree_if_alloc (pass); |
sfree_if_alloc (pass); |
2017 |
return !err? TRUE : FALSE; |
return !err? TRUE : FALSE; |
2018 |
} |
} |