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