1 |
werner |
36 |
/* wptKeysigDlg.cpp - Key signature listing |
2 |
twoaday |
139 |
* Copyright (C) 2001-2006 Timo Schulz |
3 |
werner |
36 |
* |
4 |
|
|
* This file is part of WinPT. |
5 |
|
|
* |
6 |
|
|
* WinPT is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* WinPT is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with WinPT; if not, write to the Free Software Foundation, |
18 |
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
|
|
*/ |
20 |
werner |
42 |
#ifdef HAVE_CONFIG_H |
21 |
|
|
#include <config.h> |
22 |
|
|
#endif |
23 |
|
|
|
24 |
werner |
36 |
#include <windows.h> |
25 |
|
|
#include <commctrl.h> |
26 |
|
|
#include <time.h> |
27 |
|
|
|
28 |
werner |
47 |
#include "resource.h" |
29 |
werner |
36 |
#include "wptGPG.h" |
30 |
|
|
#include "wptCommonCtl.h" |
31 |
|
|
#include "wptContext.h" /* for passphrase_s */ |
32 |
|
|
#include "wptDlgs.h" |
33 |
|
|
#include "wptW32API.h" |
34 |
|
|
#include "wptNLS.h" |
35 |
werner |
47 |
#include "wptKeylist.h" |
36 |
werner |
36 |
#include "wptKeyserver.h" |
37 |
|
|
#include "wptUTF8.h" |
38 |
|
|
#include "wptTypes.h" |
39 |
|
|
#include "wptVersion.h" |
40 |
|
|
#include "wptErrors.h" |
41 |
|
|
#include "wptKeyEdit.h" |
42 |
|
|
|
43 |
|
|
static subclass_s siglist_proc; |
44 |
|
|
|
45 |
|
|
|
46 |
twoaday |
225 |
/* Return -1 if the selected item is a signature. */ |
47 |
werner |
36 |
static int |
48 |
|
|
is_sig (listview_ctrl_t lv, int pos) |
49 |
|
|
{ |
50 |
twoaday |
128 |
char tmpbuf[200]; |
51 |
werner |
36 |
|
52 |
|
|
if (pos == -1) |
53 |
|
|
pos = listview_get_curr_pos (lv); |
54 |
|
|
if (pos == -1) |
55 |
|
|
return 0; |
56 |
twoaday |
139 |
listview_get_item_text (lv, pos, SL_COL_UID, tmpbuf, sizeof (tmpbuf)-1); |
57 |
werner |
36 |
if (*tmpbuf == ' ') |
58 |
|
|
return -1; |
59 |
|
|
return 0; |
60 |
twoaday |
32 |
} |
61 |
werner |
36 |
|
62 |
|
|
|
63 |
|
|
/* Delete the selected signature from list view @lv. The |
64 |
|
|
key is given in @key. */ |
65 |
|
|
static int |
66 |
|
|
do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key) |
67 |
|
|
{ |
68 |
twoaday |
150 |
gpgme_error_t err; |
69 |
|
|
GpgKeyEdit *ke; |
70 |
|
|
char keyid[32]; |
71 |
|
|
int pos, npos, id, is_selfsig=0; |
72 |
werner |
36 |
int signo=0, uidno=0; |
73 |
|
|
|
74 |
|
|
npos = pos = listview_get_curr_pos (lv); |
75 |
|
|
if (!is_sig (lv, -1)) |
76 |
|
|
return -1; |
77 |
twoaday |
150 |
listview_get_item_text (lv, pos, SL_COL_KEYID, keyid, sizeof (keyid)-1); |
78 |
|
|
if (!strncmp (key->keyid, keyid+2, 8)) |
79 |
|
|
is_selfsig = 1; |
80 |
|
|
|
81 |
werner |
36 |
while (pos > 0 && is_sig (lv, pos)) { |
82 |
|
|
signo++; |
83 |
|
|
pos--; |
84 |
|
|
} |
85 |
|
|
pos = npos; |
86 |
|
|
while (npos > 0) { |
87 |
|
|
if (!is_sig (lv, npos)) |
88 |
|
|
uidno++; |
89 |
|
|
npos--; |
90 |
|
|
} |
91 |
|
|
uidno++; |
92 |
|
|
|
93 |
|
|
/* XXX: do not allow to delete the self signature */ |
94 |
twoaday |
150 |
id = log_box (_("Key Manager"), is_selfsig? MB_WARN_ASK : MB_QUEST_ASK, |
95 |
|
|
_("Are you really sure you want to delete this %s from\n\n" |
96 |
|
|
" \"%s\""), is_selfsig? _("self signature") : _("signature"), |
97 |
|
|
key->uid); |
98 |
werner |
36 |
if (id == IDNO) |
99 |
|
|
return 0; |
100 |
|
|
|
101 |
|
|
ke = new GpgKeyEdit (key->keyid); |
102 |
|
|
if (!ke) |
103 |
|
|
BUG (NULL); |
104 |
|
|
err = ke->delUseridSignature (uidno, signo); |
105 |
|
|
if (err) |
106 |
|
|
msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR); |
107 |
|
|
else |
108 |
|
|
listview_del_item (lv, pos); |
109 |
|
|
delete ke; |
110 |
twoaday |
150 |
if (!err) |
111 |
|
|
key->update = 1; |
112 |
werner |
36 |
return err? -1 : 0; |
113 |
|
|
} |
114 |
|
|
|
115 |
|
|
|
116 |
|
|
/* Dialog box procedure to display the signature properties. */ |
117 |
twoaday |
176 |
BOOL CALLBACK |
118 |
werner |
36 |
sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
119 |
|
|
{ |
120 |
twoaday |
207 |
gpgme_key_sig_t ks; |
121 |
twoaday |
208 |
winpt_key_s issuer; |
122 |
werner |
36 |
char tmpbuf[256]; |
123 |
twoaday |
208 |
static struct { |
124 |
werner |
36 |
unsigned int exportable:1; |
125 |
|
|
unsigned int expired:1; |
126 |
|
|
unsigned int nrev:1; |
127 |
|
|
unsigned int rev:1; |
128 |
twoaday |
176 |
const char *alg; |
129 |
werner |
36 |
int _class; |
130 |
|
|
} ctx; |
131 |
|
|
const char *fmt_templ = _("%s %s signature"); |
132 |
twoaday |
208 |
const char *s; |
133 |
werner |
36 |
|
134 |
|
|
switch (msg) { |
135 |
|
|
case WM_INITDIALOG: |
136 |
twoaday |
225 |
ks = (gpgme_key_sig_t)lparam; |
137 |
|
|
if (!ks) |
138 |
|
|
BUG (0); |
139 |
twoaday |
88 |
SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable")); |
140 |
|
|
SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably")); |
141 |
|
|
SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired")); |
142 |
|
|
SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked")); |
143 |
|
|
SetDlgItemText (dlg, IDC_SIGPROPS_CLASSINF, _("Class")); |
144 |
|
|
SetDlgItemText (dlg, IDC_SIGPROPS_EXPSTR, _("Expire date")); |
145 |
|
|
SetDlgItemText (dlg, IDC_SIGPROPS_KEYINF, _("Issuer key")); |
146 |
|
|
SetDlgItemText (dlg, IDC_SIGPROPS_KEYIDINF, _("Issuer key ID")); |
147 |
twoaday |
207 |
SetDlgItemText (dlg, IDC_SIGPROPS_POLICINF, _("Policy URL")); |
148 |
twoaday |
225 |
SetWindowText (dlg, _("Signature Properties")); |
149 |
|
|
|
150 |
werner |
36 |
memset (&ctx, 0, sizeof ctx); |
151 |
twoaday |
176 |
ctx._class = ks->sig_class; |
152 |
werner |
36 |
if (ctx._class == 0) |
153 |
twoaday |
176 |
ctx._class = 16; |
154 |
|
|
ctx._class -= 6; |
155 |
|
|
if (ks->pubkey_algo == GPGME_PK_DSA) |
156 |
werner |
36 |
ctx.alg = "DSA"; |
157 |
twoaday |
176 |
else if (ks->pubkey_algo == GPGME_PK_RSA) |
158 |
werner |
36 |
ctx.alg = "RSA"; |
159 |
|
|
else |
160 |
|
|
ctx.alg = "ELG"; |
161 |
twoaday |
176 |
ctx.exportable = ks->exportable; |
162 |
werner |
36 |
_snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ, |
163 |
twoaday |
225 |
ctx.exportable? _("Exportable") : _("Non-exportable"), |
164 |
|
|
ctx.alg); |
165 |
werner |
36 |
SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf); |
166 |
twoaday |
176 |
|
167 |
twoaday |
208 |
_snprintf (tmpbuf, DIM (tmpbuf)-1, "0x%s", ks->keyid+8); |
168 |
|
|
SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf); |
169 |
werner |
36 |
SetDlgItemInt (dlg, IDC_SIGPROPS_CLASS, ctx._class, FALSE); |
170 |
|
|
if (ctx.exportable) |
171 |
|
|
CheckDlgButton (dlg, IDC_SIGPROPS_EXP, BST_CHECKED); |
172 |
twoaday |
208 |
memset (&issuer, 0, sizeof (issuer)); |
173 |
|
|
if (!winpt_get_pubkey (ks->keyid+8, &issuer)) |
174 |
|
|
s = issuer.ext->uids->uid; |
175 |
twoaday |
176 |
else |
176 |
twoaday |
208 |
s = _(" user ID not found"); |
177 |
twoaday |
205 |
SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, s); |
178 |
twoaday |
176 |
if (ks->expires == 0) { |
179 |
werner |
36 |
ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE); |
180 |
|
|
ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE); |
181 |
|
|
} |
182 |
|
|
else { |
183 |
|
|
SYSTEMTIME st; |
184 |
twoaday |
176 |
struct tm *tm; |
185 |
twoaday |
225 |
time_t now = time (NULL); |
186 |
twoaday |
176 |
time_t tmp = ks->expires; |
187 |
werner |
36 |
|
188 |
twoaday |
176 |
tm = localtime (&tmp); |
189 |
werner |
36 |
memset (&st, 0, sizeof st); |
190 |
twoaday |
176 |
st.wYear = tm->tm_year+1900; |
191 |
twoaday |
213 |
st.wMonth = tm->tm_mon+1; |
192 |
twoaday |
176 |
st.wDay = tm->tm_mday; |
193 |
werner |
36 |
DateTime_SetSystemtime (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), |
194 |
|
|
GDT_VALID, &st); |
195 |
|
|
|
196 |
twoaday |
225 |
if (now > ks->expires) |
197 |
werner |
36 |
ctx.expired = 1; |
198 |
|
|
if (ctx.expired) |
199 |
|
|
CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED); |
200 |
|
|
} |
201 |
twoaday |
208 |
/* XXX (gpgme): \r at the end of the notation value. */ |
202 |
twoaday |
207 |
if (ks->notations && !ks->notations->name && ks->notations->value) |
203 |
|
|
SetDlgItemText (dlg, IDC_SIGPROPS_POLIC, ks->notations->value); |
204 |
|
|
|
205 |
werner |
36 |
SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable")); |
206 |
|
|
SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably")); |
207 |
|
|
SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked")); |
208 |
|
|
SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired")); |
209 |
|
|
SetWindowText (dlg, _("Signature Properties")); |
210 |
|
|
SetForegroundWindow (dlg); |
211 |
|
|
center_window (dlg, NULL); |
212 |
|
|
return TRUE; |
213 |
|
|
|
214 |
|
|
case WM_COMMAND: |
215 |
twoaday |
208 |
if (HIWORD (wparam) == BN_CLICKED) { |
216 |
twoaday |
225 |
/* Code to prevent the user changes the check buttons. */ |
217 |
twoaday |
208 |
switch (LOWORD (wparam)) { |
218 |
|
|
case IDC_SIGPROPS_EXP: |
219 |
|
|
CheckDlgButton (dlg, IDC_SIGPROPS_EXP, |
220 |
|
|
ctx.exportable? BST_CHECKED : BST_UNCHECKED); |
221 |
|
|
return TRUE; |
222 |
|
|
|
223 |
|
|
case IDC_SIGPROPS_EXPIRED: |
224 |
|
|
CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, |
225 |
|
|
ctx.expired? BST_CHECKED : BST_UNCHECKED); |
226 |
|
|
return TRUE; |
227 |
|
|
|
228 |
|
|
case IDC_SIGPROPS_REV: |
229 |
|
|
CheckDlgButton (dlg, IDC_SIGPROPS_REV, |
230 |
|
|
ctx.rev? BST_CHECKED : BST_UNCHECKED); |
231 |
|
|
return TRUE; |
232 |
|
|
|
233 |
|
|
case IDC_SIGPROPS_NREV: |
234 |
|
|
CheckDlgButton (dlg, IDC_SIGPROPS_NREV, |
235 |
|
|
ctx.nrev? BST_CHECKED : BST_UNCHECKED); |
236 |
|
|
return TRUE; |
237 |
|
|
} |
238 |
|
|
} |
239 |
|
|
|
240 |
werner |
36 |
switch (LOWORD (wparam)) { |
241 |
|
|
case IDOK: |
242 |
|
|
EndDialog (dlg, TRUE); |
243 |
|
|
break; |
244 |
twoaday |
176 |
|
245 |
|
|
case IDCANCEL: |
246 |
|
|
EndDialog (dlg, FALSE); |
247 |
|
|
break; |
248 |
werner |
36 |
} |
249 |
|
|
} |
250 |
|
|
|
251 |
|
|
return FALSE; |
252 |
|
|
} |
253 |
|
|
|
254 |
|
|
|
255 |
twoaday |
225 |
/* Subclass window procedure for the list view. */ |
256 |
werner |
36 |
static BOOL CALLBACK |
257 |
|
|
subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
258 |
|
|
{ |
259 |
|
|
listview_ctrl_t lv; |
260 |
|
|
winpt_key_t key; |
261 |
twoaday |
176 |
gpgme_key_sig_t ks; |
262 |
werner |
36 |
|
263 |
|
|
switch (msg) { |
264 |
|
|
case WM_KEYUP: |
265 |
|
|
int virt_key = (int)wparam; |
266 |
|
|
key = (winpt_key_t)siglist_proc.opaque; |
267 |
|
|
lv = key->callback.ctl; |
268 |
|
|
if (virt_key == VK_SPACE) { |
269 |
twoaday |
176 |
if (is_sig (lv, -1)) { |
270 |
|
|
ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv)); |
271 |
werner |
36 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg, |
272 |
twoaday |
176 |
sigprops_dlg_proc, (LPARAM)ks); |
273 |
|
|
} |
274 |
werner |
36 |
} |
275 |
|
|
else if (virt_key == VK_DELETE) |
276 |
|
|
do_delsig (dlg, lv, key); |
277 |
|
|
break; |
278 |
|
|
} |
279 |
|
|
return CallWindowProc (siglist_proc.old, dlg, msg, wparam, lparam); |
280 |
|
|
} |
281 |
|
|
|
282 |
|
|
|
283 |
|
|
/* Return 1 if the list view @lv contains non-available keys. */ |
284 |
|
|
static int |
285 |
|
|
check_for_missing_keys (listview_ctrl_t lv) |
286 |
|
|
{ |
287 |
|
|
int i, n; |
288 |
|
|
char id[128]; |
289 |
|
|
|
290 |
twoaday |
225 |
n = listview_count_items (lv, 0); |
291 |
|
|
for (i = 0; i < n; i++) { |
292 |
twoaday |
139 |
listview_get_item_text (lv, i, SL_COL_VALID, id, sizeof (id) - 1); |
293 |
|
|
if (!strncmp (id, "NOKEY", 5)) |
294 |
werner |
36 |
return 1; |
295 |
|
|
} |
296 |
|
|
|
297 |
|
|
return 0; |
298 |
|
|
} |
299 |
|
|
|
300 |
|
|
|
301 |
|
|
/* Receive all missing keys marked in the list @lv. */ |
302 |
twoaday |
150 |
static int |
303 |
werner |
36 |
recv_missing_keys (HWND dlg, listview_ctrl_t lv) |
304 |
|
|
{ |
305 |
twoaday |
150 |
char id[128], keyid[18+1]; |
306 |
twoaday |
139 |
int i, n, cnt=0; |
307 |
|
|
|
308 |
|
|
i = msg_box (dlg, _("Really receive all missing keys?"), |
309 |
|
|
_("Key Manager"), MB_YESNO|MB_INFO); |
310 |
|
|
if (i == IDNO) |
311 |
twoaday |
150 |
return 0; |
312 |
werner |
36 |
|
313 |
|
|
n = listview_count_items (lv, 0); |
314 |
twoaday |
139 |
for (i = 0; i < n; i++) { |
315 |
|
|
listview_get_item_text (lv, i, SL_COL_VALID, id, sizeof (id) - 1); |
316 |
|
|
if (!strncmp (id, "NOKEY", 5)) { |
317 |
twoaday |
225 |
listview_get_item_text (lv, i, SL_COL_KEYID, |
318 |
twoaday |
139 |
keyid, sizeof (keyid) -1); |
319 |
|
|
if (!hkp_recv_key (dlg, default_keyserver, |
320 |
twoaday |
150 |
default_keyserver_port, keyid, 0, 0)) { |
321 |
|
|
keycache_update (0, keyid); |
322 |
twoaday |
139 |
cnt++; |
323 |
twoaday |
150 |
} |
324 |
twoaday |
139 |
else |
325 |
werner |
36 |
break; |
326 |
|
|
} |
327 |
|
|
} |
328 |
twoaday |
150 |
return cnt; |
329 |
werner |
36 |
} |
330 |
|
|
|
331 |
|
|
|
332 |
|
|
/* Create a mini popup with available choices. */ |
333 |
|
|
static void |
334 |
|
|
do_create_popup (HWND dlg) |
335 |
|
|
{ |
336 |
|
|
HMENU hm, sm; |
337 |
|
|
POINT p; |
338 |
|
|
|
339 |
|
|
GetCursorPos (&p); |
340 |
|
|
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX)); |
341 |
|
|
sm = GetSubMenu (hm, 0); |
342 |
|
|
set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties")); |
343 |
|
|
set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties")); |
344 |
|
|
TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL); |
345 |
|
|
DestroyMenu (hm); |
346 |
|
|
DestroyMenu (sm); |
347 |
|
|
} |
348 |
|
|
|
349 |
|
|
|
350 |
twoaday |
139 |
/* Fetch a single key and extract the keyid from the listview |
351 |
|
|
entry at the pos @idx. */ |
352 |
|
|
static int |
353 |
|
|
recv_single_key (HWND dlg, listview_ctrl_t lv, int idx) |
354 |
|
|
{ |
355 |
|
|
char keyid[32]; |
356 |
|
|
int rc; |
357 |
|
|
|
358 |
|
|
listview_get_item_text (lv, idx, SL_COL_KEYID, keyid, DIM (keyid)-1); |
359 |
|
|
rc = hkp_recv_key (dlg, default_keyserver, |
360 |
|
|
default_keyserver_port, keyid, 0, 0); |
361 |
|
|
if (!rc) |
362 |
|
|
keycache_update (0, keyid); |
363 |
|
|
return rc; |
364 |
|
|
} |
365 |
|
|
|
366 |
|
|
|
367 |
werner |
36 |
/* Load the key property dialog with the selected key from @lv. */ |
368 |
|
|
static void |
369 |
|
|
do_load_keyprops (HWND dlg, listview_ctrl_t lv) |
370 |
|
|
{ |
371 |
|
|
winpt_key_s k; |
372 |
|
|
char keyid[32] = {0}; |
373 |
|
|
char status[64] = {0}, creation[64] = {0}; |
374 |
|
|
int n = listview_get_curr_pos (lv); |
375 |
|
|
|
376 |
twoaday |
139 |
listview_get_item_text (lv, n, SL_COL_VALID, status, DIM (status)-1); |
377 |
|
|
listview_get_item_text (lv, n, SL_COL_CREATE, creation, DIM (creation)-1); |
378 |
|
|
listview_get_item_text (lv, n, SL_COL_KEYID, keyid, DIM (keyid)-1); |
379 |
werner |
36 |
if (!strcmp (status, "NOKEY")) { |
380 |
twoaday |
139 |
int id = msg_box (dlg, _("Key not found in keyring, do you want to fetch it from the keyserver?"), |
381 |
twoaday |
150 |
_("Key Manager"), MB_QUEST_ASK); |
382 |
twoaday |
139 |
if (id == IDNO) |
383 |
|
|
return; |
384 |
|
|
if (recv_single_key (dlg, lv, n)) |
385 |
|
|
return; |
386 |
werner |
36 |
} |
387 |
|
|
|
388 |
twoaday |
212 |
memset (&k, 0, sizeof k); |
389 |
|
|
if ((strlen (keyid) < 3 || winpt_get_pubkey (keyid, &k))) { |
390 |
werner |
36 |
if (strlen (creation) > 0) |
391 |
|
|
msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO); |
392 |
|
|
return; |
393 |
|
|
} |
394 |
|
|
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg, |
395 |
|
|
keyprops_dlg_proc, (LPARAM)&k); |
396 |
|
|
} |
397 |
|
|
|
398 |
|
|
|
399 |
|
|
/* Dialog box procedure to list signatures. */ |
400 |
|
|
BOOL CALLBACK |
401 |
|
|
keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
402 |
|
|
{ |
403 |
|
|
static listview_ctrl_t lv = NULL; |
404 |
|
|
static struct winpt_key_s *k; |
405 |
twoaday |
176 |
gpgme_key_sig_t ks; |
406 |
|
|
HWND sl; |
407 |
twoaday |
204 |
char inf[384]; |
408 |
twoaday |
176 |
int idx = 0; |
409 |
werner |
36 |
|
410 |
twoaday |
139 |
switch (msg) { |
411 |
werner |
36 |
case WM_INITDIALOG: |
412 |
|
|
k = (winpt_key_t) lparam; |
413 |
|
|
if (!k) |
414 |
|
|
BUG (0); |
415 |
twoaday |
208 |
if (k->uid) |
416 |
|
|
_snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid); |
417 |
twoaday |
205 |
SetWindowText (dlg, inf); |
418 |
werner |
36 |
SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key")); |
419 |
|
|
SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties")); |
420 |
twoaday |
128 |
|
421 |
werner |
36 |
lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid); |
422 |
|
|
if (!check_for_missing_keys (lv)) |
423 |
twoaday |
41 |
EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY), FALSE); |
424 |
twoaday |
129 |
EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_SIGPROPS), FALSE); |
425 |
werner |
36 |
k->callback.ctl = lv; |
426 |
|
|
sl = GetDlgItem (dlg, IDC_KEYSIG_LIST); |
427 |
|
|
siglist_proc.dlg = dlg; |
428 |
|
|
siglist_proc.opaque = k; |
429 |
|
|
siglist_proc.current = (WNDPROC)subclass_dlg_proc; |
430 |
|
|
siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC); |
431 |
|
|
if (siglist_proc.old) { |
432 |
|
|
if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current)) { |
433 |
twoaday |
141 |
msg_box (dlg, "Could not set keylist window procedure.", |
434 |
werner |
36 |
_("Key Manager"), MB_ERR); |
435 |
|
|
BUG (0); |
436 |
|
|
} |
437 |
|
|
} |
438 |
|
|
SetForegroundWindow (dlg); |
439 |
|
|
center_window (dlg, NULL); |
440 |
|
|
return TRUE; |
441 |
|
|
|
442 |
|
|
case WM_DESTROY: |
443 |
twoaday |
139 |
if (lv) { |
444 |
|
|
siglist_delete (lv); |
445 |
werner |
36 |
lv = NULL; |
446 |
|
|
} |
447 |
|
|
return FALSE; |
448 |
|
|
|
449 |
|
|
case WM_NOTIFY: |
450 |
twoaday |
41 |
NMHDR *notify; |
451 |
werner |
36 |
|
452 |
|
|
notify = (NMHDR *)lparam; |
453 |
twoaday |
139 |
if (!notify) |
454 |
|
|
return FALSE; |
455 |
twoaday |
225 |
if (notify->code == NM_DBLCLK && |
456 |
|
|
notify->idFrom == IDC_KEYSIG_LIST) |
457 |
werner |
36 |
do_load_keyprops (dlg, lv); |
458 |
twoaday |
139 |
if (notify->code == NM_RCLICK && |
459 |
twoaday |
128 |
notify->idFrom == IDC_KEYSIG_LIST && |
460 |
|
|
is_sig (lv, -1)) |
461 |
werner |
36 |
do_create_popup (dlg); |
462 |
twoaday |
139 |
if (notify->code == LVN_ITEMCHANGED && |
463 |
twoaday |
41 |
((LPNMLISTVIEW)lparam)->uNewState) { |
464 |
|
|
idx = listview_get_curr_pos (lv); |
465 |
twoaday |
139 |
listview_get_item_text (lv, idx, SL_COL_VALID, inf, DIM (inf)-1); |
466 |
twoaday |
41 |
EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY), |
467 |
|
|
strcmp (inf, "NOKEY") == 0? TRUE: FALSE); |
468 |
twoaday |
128 |
EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_SIGPROPS), |
469 |
|
|
is_sig (lv, -1)? TRUE : FALSE); |
470 |
twoaday |
41 |
} |
471 |
twoaday |
139 |
if (notify->code == LVN_COLUMNCLICK) { |
472 |
|
|
NMLISTVIEW *nft = (LPNMLISTVIEW) lparam; |
473 |
|
|
int sortby = 0; |
474 |
|
|
switch (nft->iSubItem) { |
475 |
|
|
//case 0: sortby = KEY_SORT_USERID; break; |
476 |
|
|
case 1: sortby = KEY_SORT_VALIDITY; break; |
477 |
|
|
case 2: sortby = SIG_SORT_CLASS; break; |
478 |
|
|
case 3: sortby = KEY_SORT_CREATED; break; |
479 |
|
|
case 4: sortby = KEY_SORT_KEYID; break; |
480 |
|
|
case 5: sortby = SIG_SORT_EXPIRE; break; |
481 |
|
|
case 6: sortby = KEY_SORT_ALGO; break; |
482 |
|
|
default: return TRUE; |
483 |
|
|
} |
484 |
|
|
siglist_sort (lv, sortby); |
485 |
|
|
} |
486 |
werner |
36 |
break; |
487 |
|
|
|
488 |
|
|
case WM_COMMAND: |
489 |
twoaday |
139 |
switch (LOWORD (wparam)) { |
490 |
werner |
36 |
case ID_SIGCTX_KEYPROPS: |
491 |
|
|
do_load_keyprops (dlg, lv); |
492 |
|
|
break; |
493 |
|
|
|
494 |
|
|
case ID_SIGCTX_PROPS: |
495 |
twoaday |
176 |
if (is_sig (lv, -1)) { |
496 |
|
|
ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv)); |
497 |
werner |
36 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg, |
498 |
twoaday |
176 |
sigprops_dlg_proc, (LPARAM)ks); |
499 |
|
|
} |
500 |
werner |
36 |
break; |
501 |
|
|
|
502 |
|
|
case IDC_KEYSIG_RECVKEY: |
503 |
|
|
idx = listview_get_curr_pos (lv); |
504 |
twoaday |
139 |
if (idx == -1) |
505 |
|
|
recv_missing_keys (dlg, lv); |
506 |
|
|
else |
507 |
|
|
recv_single_key (dlg, lv, idx); |
508 |
werner |
36 |
return TRUE; |
509 |
|
|
|
510 |
|
|
case IDC_KEYSIG_SIGPROPS: |
511 |
twoaday |
176 |
if (is_sig (lv, -1)) { |
512 |
|
|
ks = ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv)); |
513 |
werner |
36 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg, |
514 |
twoaday |
176 |
sigprops_dlg_proc, (LPARAM)ks); |
515 |
|
|
} |
516 |
werner |
36 |
return TRUE; |
517 |
|
|
|
518 |
twoaday |
212 |
case IDCANCEL: |
519 |
|
|
EndDialog (dlg, FALSE); |
520 |
|
|
return TRUE; |
521 |
|
|
|
522 |
werner |
36 |
case IDOK: |
523 |
|
|
EndDialog (dlg, TRUE); |
524 |
|
|
return TRUE; |
525 |
|
|
} |
526 |
|
|
break; |
527 |
|
|
} |
528 |
|
|
return FALSE; |
529 |
|
|
} |