39 |
#include "wptVersion.h" |
#include "wptVersion.h" |
40 |
#include "wptKeyEdit.h" |
#include "wptKeyEdit.h" |
41 |
#include "wptKeylist.h" |
#include "wptKeylist.h" |
42 |
|
#include "wptUTF8.h" |
43 |
|
|
44 |
|
|
45 |
|
enum revoke_col_t { |
46 |
|
REV_COL_NAME = 0, |
47 |
|
REV_COL_KEYID = 1, |
48 |
|
REV_COL_ALGO = 2 |
49 |
|
}; |
50 |
|
|
51 |
/* Initialize the listview given in @ctrl and return it in @r_lv. */ |
/* Initialize the listview given in @ctrl and return it in @r_lv. */ |
52 |
static int |
static int |
53 |
revokelist_build (listview_ctrl_t *r_lv, HWND ctrl) |
revokelist_build (listview_ctrl_t *r_lv, HWND ctrl) |
54 |
{ |
{ |
55 |
listview_ctrl_t lv; |
listview_ctrl_t lv; |
56 |
struct listview_column_s rlist[] = { |
struct listview_column_s rlist[] = { |
57 |
{ 0, 55, (char *)_("Algorithm") }, |
{0, 160, (char *)_("Name") }, |
58 |
{ 1, 80, (char *)_("Key ID") }, |
{1, 80, (char *)_("Key ID")}, |
59 |
{ 2, 160, (char *)_("Name") }, |
{2, 55, (char *)_("Algorithm")}, |
60 |
{0} |
{0} |
61 |
}; |
}; |
62 |
int i, rc; |
int i, rc; |
82 |
revokelist_init (HWND ctrl, gpgme_key_t key, gpg_keycache_t ctx) |
revokelist_init (HWND ctrl, gpgme_key_t key, gpg_keycache_t ctx) |
83 |
{ |
{ |
84 |
gpgme_error_t err; |
gpgme_error_t err; |
85 |
gpgme_key_t revkey; |
gpgme_key_t revkey; |
86 |
GpgKeyEdit *ke; |
GpgKeyEdit *ke; |
87 |
gpg_desig_rev_t rev=NULL, r; |
gpg_desig_rev_t rev=NULL, r; |
88 |
listview_ctrl_t lv; |
listview_ctrl_t lv; |
89 |
const char *id; |
const char *alg; |
90 |
|
char *uid = NULL; |
91 |
|
|
92 |
ke = new GpgKeyEdit (key); |
ke = new GpgKeyEdit (key); |
93 |
if (!ke) |
if (!ke) |
95 |
err = ke->getDesignatedRevoker (&rev); |
err = ke->getDesignatedRevoker (&rev); |
96 |
if (err) { |
if (err) { |
97 |
delete ke; |
delete ke; |
98 |
msg_box (NULL, gpgme_strerror (err), _("Designated Key Revokers"), MB_ERR); |
msg_box (NULL, gpgme_strerror (err), |
99 |
|
_("Designated Key Revokers"), MB_ERR); |
100 |
return NULL; |
return NULL; |
101 |
} |
} |
102 |
|
|
104 |
BUG (0); |
BUG (0); |
105 |
for (r = rev; r; r = r->next) { |
for (r = rev; r; r = r->next) { |
106 |
if (get_pubkey (r->fpr+32, &revkey)) |
if (get_pubkey (r->fpr+32, &revkey)) |
107 |
id = _("user ID not found"); |
uid = strdup (_("user ID not found")); |
108 |
else |
else |
109 |
id = revkey->uids->name; |
uid = utf8_to_wincp2 (revkey->uids->name); |
110 |
listview_add_item (lv, ""); |
listview_add_item (lv, ""); |
111 |
listview_add_sub_item (lv, 0, 0, get_key_pubalgo (r->pubkey_algo)); |
alg = get_key_pubalgo (r->pubkey_algo); |
112 |
listview_add_sub_item (lv, 0, 1, r->fpr+32); |
listview_add_sub_item (lv, 0, REV_COL_ALGO, alg); |
113 |
listview_add_sub_item (lv, 0, 2, id); |
listview_add_sub_item (lv, 0, REV_COL_KEYID, r->fpr+32); |
114 |
|
listview_add_sub_item (lv, 0, REV_COL_NAME, uid); |
115 |
|
safe_free (uid); |
116 |
} |
} |
117 |
|
|
118 |
delete ke; |
delete ke; |
119 |
gpg_desig_rev_release (rev); |
gpg_desig_rev_release (rev); |
120 |
return lv; |
return lv; |
152 |
if (notify && notify->code == NM_DBLCLK && |
if (notify && notify->code == NM_DBLCLK && |
153 |
notify->idFrom == IDC_KEYREVOKERS_LIST) { |
notify->idFrom == IDC_KEYREVOKERS_LIST) { |
154 |
int idx = listview_get_curr_pos (lv); |
int idx = listview_get_curr_pos (lv); |
155 |
listview_get_item_text (lv, idx, 1, keyid, DIM (keyid)-1); |
listview_get_item_text (lv, idx, REV_COL_KEYID, keyid, DIM (keyid)-1); |
156 |
listview_get_item_text (lv, idx, 2, buf, DIM (buf)-1); |
listview_get_item_text (lv, idx, REV_COL_NAME, buf, sizeof (buf)-1); |
157 |
if (!strcmp( buf, _("user ID not found"))) { |
if (!strcmp (buf, _("user ID not found"))) { |
158 |
int id = log_box (_("Designated Key Revokers"), MB_YESNO|MB_INFO, |
int id = log_box (_("Designated Key Revokers"), MB_YESNO|MB_INFO, |
159 |
_("Do you want to retrieve 0x%s via the default keyserver?"), keyid); |
_("Do you want to retrieve 0x%s via the default keyserver?"), keyid); |
160 |
if (id == IDNO) |
if (id == IDNO) |
161 |
break; |
break; |
162 |
rc = hkp_recv_key (dlg, default_keyserver, |
rc = hkp_recv_key (dlg, default_keyserver, |
163 |
default_keyserver_port, buf, 0, 0); |
default_keyserver_port, keyid, 0, 0); |
164 |
if( !rc ) { |
if (!rc) { |
165 |
keycache_reload (dlg); |
keycache_reload (dlg); |
166 |
if (get_pubkey (keyid, &key)) |
if (get_pubkey (keyid, &key)) |
167 |
BUG (NULL); |
BUG (NULL); |
168 |
if (key->uids && key->uids->name) |
if (key->uids && key->uids->name) { |
169 |
listview_add_sub_item (lv, idx, 2, key->uids->name); |
char *uid = utf8_to_wincp2 (key->uids->name); |
170 |
|
listview_add_sub_item (lv, idx, REV_COL_NAME, uid); |
171 |
|
free (uid); |
172 |
|
} |
173 |
} |
} |
174 |
} |
} |
175 |
else { |
else { |