213 |
|
|
214 |
|
|
215 |
/* Try to find the GPG edit key index which belongs to the user ID |
/* Try to find the GPG edit key index which belongs to the user ID |
216 |
given by @name. If @r_inf != NULL, the info context will be returned. |
given by the email address @email, @name is used as a fallback. |
217 |
|
If @r_inf != NULL, the info context will be returned. |
218 |
Return value: index of the user ID or -1 on error. */ |
Return value: index of the user ID or -1 on error. */ |
219 |
static int |
static int |
220 |
do_find_userid (const char *keyid, const char *name, gpg_uid_info_t *r_inf) |
do_find_userid (const char *keyid, const char *email, |
221 |
|
const char *name, gpg_uid_info_t *r_inf) |
222 |
{ |
{ |
223 |
GpgKeyEdit *ke; |
GpgKeyEdit *ke; |
224 |
gpgme_error_t err; |
gpgme_error_t err; |
238 |
} |
} |
239 |
|
|
240 |
for (ui = inf; ui; ui = ui->next) { |
for (ui = inf; ui; ui = ui->next) { |
241 |
if (!strcmp (ui->email, name)) { |
if (name && email && ui->email && ui->name) { |
242 |
|
if (!strcmp (ui->email, email) && |
243 |
|
!strncmp (ui->name, name, strlen (name))) { |
244 |
|
pos = ui->index; |
245 |
|
break; |
246 |
|
} |
247 |
|
continue; |
248 |
|
} |
249 |
|
if (ui->email) { |
250 |
|
if (!strcmp (ui->email, email)) { |
251 |
|
pos = ui->index; |
252 |
|
break; |
253 |
|
} |
254 |
|
/* The email address is more unique, use the name just |
255 |
|
as the fallbck when no email address is available. */ |
256 |
|
continue; |
257 |
|
} |
258 |
|
if (ui->name && name && !strcmp (ui->name, name)) { |
259 |
pos = ui->index; |
pos = ui->index; |
260 |
break; |
break; |
261 |
} |
} |
1113 |
if (attr) { |
if (attr) { |
1114 |
char *uid = utf8_to_wincp (attr, strlen (attr)); |
char *uid = utf8_to_wincp (attr, strlen (attr)); |
1115 |
if (uid) { |
if (uid) { |
1116 |
listview_add_sub_item( lv, j, 1, uid ); |
listview_add_sub_item (lv, j, 1, uid); |
1117 |
free( uid ); |
free (uid); |
1118 |
} |
} |
1119 |
} |
} |
1120 |
else |
else |
1121 |
listview_add_sub_item( lv, j, 1, _("Invalid user ID") ); |
listview_add_sub_item (lv, j, 1, _("Invalid user ID")); |
1122 |
attr = u->email; |
attr = u->email; |
1123 |
if (attr) |
if (attr) |
1124 |
listview_add_sub_item (lv, j, 2, attr); |
listview_add_sub_item (lv, j, 2, attr); |
1410 |
{ |
{ |
1411 |
gpgme_error_t err; |
gpgme_error_t err; |
1412 |
GpgKeyEdit *ke; |
GpgKeyEdit *ke; |
1413 |
char buf[256], t[512]; |
char buf[128], email[128]; |
1414 |
char *pass=NULL; |
char inf[512]; |
1415 |
|
char *pass = NULL; |
1416 |
int cancel = 0, id = 0, j; |
int cancel = 0, id = 0, j; |
1417 |
|
|
1418 |
if (!k->key_pair) { |
if (!k->key_pair) { |
1419 |
msg_box( dlg, _("There is no secret key available!"), _("Revoke user ID"), MB_ERR ); |
msg_box (dlg, _("There is no secret key available!"), |
1420 |
|
_("Revoke user ID"), MB_ERR); |
1421 |
return FALSE; |
return FALSE; |
1422 |
} |
} |
1423 |
|
|
1424 |
if( listview_count_items( lv, 0 ) == 1 ) { |
if (listview_count_items (lv, 0) == 1) { |
1425 |
msg_box( dlg, _("Key has only one user ID."), _("Key Edit"), MB_ERR ); |
msg_box (dlg, _("Key has only one user ID."), _("Key Edit"), MB_ERR); |
1426 |
return FALSE; |
return FALSE; |
1427 |
} |
} |
1428 |
|
|
1431 |
return FALSE; |
return FALSE; |
1432 |
} |
} |
1433 |
|
|
1434 |
listview_get_item_text( lv, j, 0, buf, sizeof buf - 1 ); |
listview_get_item_text( lv, j, UID_COL_VALID, buf, sizeof buf - 1); |
1435 |
if( strstr( buf, _("Revoked") ) ) { |
if (strstr (buf, _("Revoked"))) { |
1436 |
msg_box( dlg, _("This user ID has been already revoked."), _("Key Edit"), MB_INFO ); |
msg_box (dlg, _("This user ID has been already revoked."), |
1437 |
|
_("Key Edit"), MB_INFO); |
1438 |
return FALSE; |
return FALSE; |
1439 |
} |
} |
1440 |
|
|
1441 |
listview_get_item_text (lv, j, 1, buf, sizeof buf -1); |
listview_get_item_text (lv, j, UID_COL_NAME, buf, sizeof buf -1); |
1442 |
_snprintf( t, sizeof t -1, _("user ID \"%s\".\n\n" |
_snprintf (inf, sizeof (inf) -1, _("user ID \"%s\".\n\n" |
1443 |
"Do you really want to revoke this user ID?"), buf ); |
"Do you really want to revoke this user ID?"), buf); |
1444 |
if( msg_box( dlg, t, _("Key Edit"), MB_WARN_ASK) == IDNO ) |
if (msg_box (dlg, inf, _("Key Edit"), MB_WARN_ASK) == IDNO) |
1445 |
return FALSE; |
return FALSE; |
1446 |
if( k->is_protected ) { |
if (k->is_protected) { |
1447 |
pass = request_passphrase (_("Key Edit"), 1, &cancel); |
pass = request_passphrase (_("Key Edit"), 1, &cancel); |
1448 |
if (cancel) |
if (cancel) |
1449 |
return FALSE; |
return FALSE; |
1450 |
} |
} |
1451 |
listview_get_item_text (lv, j, 2, buf, sizeof (buf)-1); |
listview_get_item_text (lv, j, UID_COL_EMAIL, email, sizeof (email)-1); |
1452 |
id = do_find_userid (k->keyid, buf, NULL); |
listview_get_item_text (lv, j, UID_COL_NAME, buf, sizeof (buf)-1); |
1453 |
|
id = do_find_userid (k->keyid, email, buf, NULL); |
1454 |
if (id == -1) |
if (id == -1) |
1455 |
BUG (NULL); |
BUG (NULL); |
1456 |
|
|
1461 |
ke->setPassphrase (pass); |
ke->setPassphrase (pass); |
1462 |
err = ke->revokeUserid (id); |
err = ke->revokeUserid (id); |
1463 |
if (err) |
if (err) |
1464 |
msg_box (dlg, gpgme_strerror (err), _("Revoke Signature"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Revoke User ID"), MB_ERR); |
1465 |
else { |
else { |
1466 |
listview_add_sub_item (lv, j, 0, _("Revoked")); |
listview_add_sub_item (lv, j, 0, _("Revoked")); |
1467 |
k->update = 1; |
k->update = 1; |
1486 |
return FALSE; |
return FALSE; |
1487 |
} |
} |
1488 |
listview_get_item_text (lv, j, 2, buf, sizeof buf-1); |
listview_get_item_text (lv, j, 2, buf, sizeof buf-1); |
1489 |
id = do_find_userid (k->keyid, buf, NULL); |
id = do_find_userid (k->keyid, buf, NULL, NULL); |
1490 |
if (id == -1) |
if (id == -1) |
1491 |
BUG (dlg); |
BUG (dlg); |
1492 |
if (k->is_protected) { |
if (k->is_protected) { |
1528 |
return FALSE; |
return FALSE; |
1529 |
} |
} |
1530 |
listview_get_item_text (lv, j, 2, buf, sizeof buf-1); |
listview_get_item_text (lv, j, 2, buf, sizeof buf-1); |
1531 |
id = do_find_userid (k->keyid, buf, NULL); |
id = do_find_userid (k->keyid, buf, NULL, NULL); |
1532 |
if (id == -1) |
if (id == -1) |
1533 |
BUG (dlg); |
BUG (dlg); |
1534 |
if (k->is_protected) { |
if (k->is_protected) { |
1619 |
pos = listview_get_curr_pos (cb->lv); |
pos = listview_get_curr_pos (cb->lv); |
1620 |
listview_get_item_text (cb->lv, pos, 2, buf, DIM (buf)-1); |
listview_get_item_text (cb->lv, pos, 2, buf, DIM (buf)-1); |
1621 |
SetDlgItemText (dlg, IDC_SHOWPREF_INFO, buf); |
SetDlgItemText (dlg, IDC_SHOWPREF_INFO, buf); |
1622 |
pos = do_find_userid (((winpt_key_t)cb->opaque)->keyid, buf, &inf); |
pos = do_find_userid (((winpt_key_t)cb->opaque)->keyid, |
1623 |
|
buf, NULL, &inf); |
1624 |
if (inf) { |
if (inf) { |
1625 |
const char *prefs = inf->prefs; |
const char *prefs = inf->prefs; |
1626 |
if (prefs && *prefs) { |
if (prefs && *prefs) { |
1682 |
{ |
{ |
1683 |
gpgme_error_t err; |
gpgme_error_t err; |
1684 |
GpgKeyEdit *ke; |
GpgKeyEdit *ke; |
1685 |
char buf[256], t[512]; |
char email[128], name[128]; |
1686 |
|
char inf[384]; |
1687 |
int j, id = 0; |
int j, id = 0; |
1688 |
|
|
1689 |
if (!k->key_pair) |
if (!k->key_pair) |
1690 |
return FALSE; /* XXX: see do_editkey_delsubkey */ |
return FALSE; /* XXX: see do_editkey_delsubkey */ |
1691 |
|
|
1692 |
if( listview_count_items( lv, 0 ) == 1 ) { |
if (listview_count_items (lv, 0) == 1) { |
1693 |
msg_box( dlg, _("Primary user ID can not be deleted!"), _("Key Edit"), MB_ERR ); |
msg_box (dlg, _("Primary user ID can not be deleted!"), |
1694 |
|
_("Key Edit"), MB_ERR); |
1695 |
return FALSE; |
return FALSE; |
1696 |
} |
} |
1697 |
if( (j = listview_get_curr_pos( lv )) == -1 ) { |
if ((j = listview_get_curr_pos (lv)) == -1) { |
1698 |
msg_box( dlg, _("Please select a user ID."), _("Key Edit"), MB_ERR ); |
msg_box (dlg, _("Please select a user ID."), _("Key Edit"), MB_ERR); |
1699 |
return FALSE; |
return FALSE; |
1700 |
} |
} |
1701 |
|
|
1702 |
/* XXX: add a hint that also all signatures will be deleted? */ |
/* XXX: add a hint that also all signatures will be deleted? */ |
1703 |
listview_get_item_text( lv, j, 1, buf, DIM(buf) -1 ); |
listview_get_item_text (lv, j, UID_COL_NAME, name, DIM(name) -1); |
1704 |
_snprintf( t, DIM (t)-1, _("user ID \"%s\".\n\n" |
_snprintf (inf, DIM (inf)-1, _("user ID \"%s\".\n\n" |
1705 |
"Do you really want to delete this user ID?"), |
"Do you really want to delete this user ID?"), |
1706 |
buf); |
name); |
1707 |
if( msg_box( dlg, t, _("Key Edit"), MB_YESNO|MB_ICONWARNING ) == IDNO ) |
if (msg_box (dlg, inf, _("Key Edit"), MB_YESNO|MB_ICONWARNING) == IDNO) |
1708 |
return FALSE; |
return FALSE; |
1709 |
|
|
1710 |
listview_get_item_text (lv, j, 2, buf, DIM (buf)-1); |
listview_get_item_text (lv, j, UID_COL_EMAIL, email, DIM (email)-1); |
1711 |
id = do_find_userid (k->keyid, buf, NULL); |
listview_get_item_text (lv, j, UID_COL_NAME, name, DIM (name)-1); |
1712 |
|
id = do_find_userid (k->keyid, email, name, NULL); |
1713 |
if (id == -1) |
if (id == -1) |
1714 |
BUG (dlg); |
BUG (dlg); |
1715 |
|
|
1718 |
BUG (NULL); |
BUG (NULL); |
1719 |
|
|
1720 |
err = ke->delUserid (id); |
err = ke->delUserid (id); |
1721 |
if( err ) |
if (err) |
1722 |
msg_box( dlg, gpgme_strerror (err), _("Delete user ID"), MB_ERR ); |
msg_box (dlg, gpgme_strerror (err), _("Delete user ID"), MB_ERR); |
1723 |
else { |
else { |
1724 |
listview_del_item( lv, j ); |
listview_del_item (lv, j); |
1725 |
k->update = 1; |
k->update = 1; |
1726 |
status_box( dlg, _("User ID successfully deleted"), _("GnuPG Status") ); |
status_box (dlg, _("User ID successfully deleted"), _("GnuPG Status")); |
1727 |
} |
} |
1728 |
delete ke; |
delete ke; |
1729 |
return err? FALSE : TRUE; |
return err? FALSE : TRUE; |