35 |
#include "wptTypes.h" |
#include "wptTypes.h" |
36 |
#include "wptVersion.h" |
#include "wptVersion.h" |
37 |
#include "wptErrors.h" |
#include "wptErrors.h" |
38 |
|
#include "wptKeyEdit.h" |
39 |
|
|
40 |
static subclass_s siglist_proc; |
static subclass_s siglist_proc; |
41 |
|
|
54 |
} |
} |
55 |
|
|
56 |
|
|
57 |
|
/* Delete the selected signature from list view @lv. The |
58 |
|
key is given in @key. */ |
59 |
static int |
static int |
60 |
do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key) |
do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key) |
61 |
{ |
{ |
62 |
int pos, npos, id; |
int pos, npos, id; |
63 |
int signo=0, uidno=0; |
int signo=0, uidno=0; |
64 |
gpgme_ctx_t ctx; |
GpgKeyEdit *ke; |
65 |
gpgme_editkey_t ek; |
gpgme_error_t err; |
|
gpgme_error_t rc; |
|
66 |
|
|
67 |
npos = pos = listview_get_curr_pos (lv); |
npos = pos = listview_get_curr_pos (lv); |
68 |
if (!is_sig (lv, -1)) |
if (!is_sig (lv, -1)) |
80 |
uidno++; |
uidno++; |
81 |
|
|
82 |
/* XXX: do not allow to delete the self signature */ |
/* XXX: do not allow to delete the self signature */ |
83 |
id = log_box(_("Key Manager"), MB_YESNO, |
id = log_box (_("Key Manager"), MB_YESNO, |
84 |
_("Are you really sure you want to delete this signature from\n" |
_("Are you really sure you want to delete this signature from\n" |
85 |
" \"%s\""), key->uid); |
" \"%s\""), key->uid); |
86 |
if (id == IDNO) |
if (id == IDNO) |
87 |
return 0; |
return 0; |
88 |
rc = gpgme_new (&ctx); |
|
89 |
if (rc) |
ke = new GpgKeyEdit (key->keyid); |
90 |
BUG (0); |
if (!ke) |
91 |
rc = gpgme_editkey_new (&ek); |
BUG (NULL); |
92 |
if (rc) |
err = ke->delUseridSignature (uidno, signo); |
93 |
BUG (0); |
if (err) |
94 |
gpgme_editkey_delsig_set (ek, uidno, signo); |
msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR); |
|
gpgme_set_edit_ctx (ctx, ek, GPGME_EDITKEY_DELSIG); |
|
|
rc = gpgme_op_editkey (ctx, key->keyid); |
|
|
if (rc) |
|
|
msg_box (dlg, gpgme_strerror (rc), _("Key Manager"), MB_ERR); |
|
95 |
else |
else |
96 |
listview_del_item (lv, pos); |
listview_del_item (lv, pos); |
97 |
gpgme_release (ctx); |
delete ke; |
|
gpgme_editkey_release (ek); |
|
98 |
key->update = 1; /*update*/ |
key->update = 1; /*update*/ |
99 |
return 0; |
return err? -1 : 0; |
100 |
} |
} |
101 |
|
|
102 |
|
|
103 |
|
/* Dialog box procedure to display the signature properties. */ |
104 |
static BOOL CALLBACK |
static BOOL CALLBACK |
105 |
sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
106 |
{ |
{ |
115 |
const char * alg; |
const char * alg; |
116 |
int _class; |
int _class; |
117 |
} ctx; |
} ctx; |
118 |
const char * fmt_templ = "%s %s signature"; |
const char *fmt_templ = _("%s %s signature"); |
119 |
|
|
120 |
switch (msg) { |
switch (msg) { |
121 |
case WM_SYSCOMMAND: |
case WM_SYSCOMMAND: |
144 |
ctx.alg = "RSA"; |
ctx.alg = "RSA"; |
145 |
else |
else |
146 |
ctx.alg = "ELG"; |
ctx.alg = "ELG"; |
147 |
_snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ, |
_snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ, |
148 |
ctx.exportable? "Exportable" : "Non-exportable", ctx.alg); |
ctx.exportable? _("Exportable") : _("Non-exportable"), ctx.alg); |
149 |
SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf); |
SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf); |
150 |
listview_get_item_text (lv, n, 4, tmpbuf, DIM (tmpbuf)-1); |
listview_get_item_text (lv, n, 4, tmpbuf, DIM (tmpbuf)-1); |
151 |
SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf); |
SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf); |
186 |
SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably")); |
SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably")); |
187 |
SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked")); |
SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked")); |
188 |
SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired")); |
SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired")); |
189 |
|
SetWindowText (dlg, _("Signature Properties")); |
190 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
191 |
center_window (dlg); |
center_window (dlg, NULL); |
192 |
return TRUE; |
return TRUE; |
193 |
|
|
194 |
case WM_COMMAND: |
case WM_COMMAND: |
227 |
} |
} |
228 |
|
|
229 |
|
|
230 |
|
/* Return 1 if the list view @lv contains non-available keys. */ |
231 |
static int |
static int |
232 |
check_for_missing_keys (listview_ctrl_t lv) |
check_for_missing_keys (listview_ctrl_t lv) |
233 |
{ |
{ |
242 |
} |
} |
243 |
|
|
244 |
return 0; |
return 0; |
245 |
} /* check_for_missing_keys */ |
} |
246 |
|
|
247 |
|
|
248 |
|
/* Receive all missing keys marked in the list @lv. */ |
249 |
static int |
static int |
250 |
recv_missing_keys (HWND dlg, listview_ctrl_t lv) |
recv_missing_keys (HWND dlg, listview_ctrl_t lv) |
251 |
{ |
{ |
264 |
} |
} |
265 |
|
|
266 |
return rc; |
return rc; |
267 |
} /* recv_missing_keys */ |
} |
268 |
|
|
269 |
|
|
270 |
|
/* Create a mini popup with available choices. */ |
271 |
static void |
static void |
272 |
do_create_popup (HWND dlg) |
do_create_popup (HWND dlg) |
273 |
{ |
{ |
278 |
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX)); |
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX)); |
279 |
sm = GetSubMenu (hm, 0); |
sm = GetSubMenu (hm, 0); |
280 |
|
|
281 |
|
set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties")); |
282 |
|
set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties")); |
283 |
|
|
284 |
TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL); |
TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL); |
285 |
|
|
286 |
DestroyMenu (hm); |
DestroyMenu (hm); |
288 |
} |
} |
289 |
|
|
290 |
|
|
291 |
|
/* Load the key property dialog with the selected key from @lv. */ |
292 |
static void |
static void |
293 |
do_load_keyprops (HWND dlg, listview_ctrl_t lv) |
do_load_keyprops (HWND dlg, listview_ctrl_t lv) |
294 |
{ |
{ |
318 |
keyprops_dlg_proc, (LPARAM)&k); |
keyprops_dlg_proc, (LPARAM)&k); |
319 |
} |
} |
320 |
|
|
321 |
|
|
322 |
|
/* Dialog box procedure to list signatures. */ |
323 |
BOOL CALLBACK |
BOOL CALLBACK |
324 |
keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
325 |
{ |
{ |
352 |
siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC); |
siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC); |
353 |
if (siglist_proc.old) { |
if (siglist_proc.old) { |
354 |
if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current)) { |
if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current)) { |
355 |
msg_box (dlg, _("Could not set keylist window procedure."), _("Key Manager"), MB_ERR); |
msg_box (dlg, _("Could not set keylist window procedure."), |
356 |
|
_("Key Manager"), MB_ERR); |
357 |
BUG (0); |
BUG (0); |
358 |
} |
} |
359 |
} |
} |
360 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
361 |
center_window (dlg); |
center_window (dlg, NULL); |
362 |
return TRUE; |
return TRUE; |
363 |
|
|
364 |
case WM_DESTROY: |
case WM_DESTROY: |
412 |
keycache_set_reload (1); |
keycache_set_reload (1); |
413 |
return TRUE; |
return TRUE; |
414 |
} |
} |
415 |
return FALSE; |
return TRUE; |
416 |
} |
} |
417 |
listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1); |
listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1); |
418 |
if (strcmp (inf, "NOKEY")) |
if (strcmp (inf, "NOKEY")) |
438 |
break; |
break; |
439 |
} |
} |
440 |
return FALSE; |
return FALSE; |
441 |
} /* keysig_dlg_proc */ |
} |