43 |
static subclass_s siglist_proc; |
static subclass_s siglist_proc; |
44 |
|
|
45 |
|
|
46 |
|
/* Return -1 if the selected item is a signature. */ |
47 |
static int |
static int |
48 |
is_sig (listview_ctrl_t lv, int pos) |
is_sig (listview_ctrl_t lv, int pos) |
49 |
{ |
{ |
113 |
} |
} |
114 |
|
|
115 |
|
|
116 |
|
/* Initialize a datepicker control with the time given in @t. */ |
117 |
|
static void |
118 |
|
init_datepicker_from_time (HWND picker, time_t t) |
119 |
|
{ |
120 |
|
SYSTEMTIME st; |
121 |
|
struct tm *tm; |
122 |
|
|
123 |
|
tm = localtime (&t); |
124 |
|
memset (&st, 0, sizeof st); |
125 |
|
st.wYear = tm->tm_year+1900; |
126 |
|
st.wMonth = tm->tm_mon+1; |
127 |
|
st.wDay = tm->tm_mday; |
128 |
|
DateTime_SetSystemtime (picker, GDT_VALID, &st); |
129 |
|
} |
130 |
|
|
131 |
|
|
132 |
/* Dialog box procedure to display the signature properties. */ |
/* Dialog box procedure to display the signature properties. */ |
133 |
BOOL CALLBACK |
BOOL CALLBACK |
134 |
sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
135 |
{ |
{ |
136 |
static gpgme_key_sig_t ks; |
gpgme_key_sig_t ks; |
137 |
gpgme_key_t issuer; |
winpt_key_s issuer; |
138 |
char tmpbuf[256]; |
char tmpbuf[256]; |
139 |
struct { |
static struct { |
140 |
unsigned int exportable:1; |
unsigned int exportable:1; |
141 |
unsigned int expired:1; |
unsigned int expired:1; |
142 |
unsigned int nrev:1; |
unsigned int nrev:1; |
145 |
int _class; |
int _class; |
146 |
} ctx; |
} ctx; |
147 |
const char *fmt_templ = _("%s %s signature"); |
const char *fmt_templ = _("%s %s signature"); |
148 |
|
const char *s; |
149 |
|
|
150 |
switch (msg) { |
switch (msg) { |
|
case WM_SYSCOMMAND: |
|
|
if (LOWORD (wparam) == SC_CLOSE) |
|
|
EndDialog (dlg, TRUE); |
|
|
return FALSE; |
|
|
|
|
151 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
152 |
SetWindowText (dlg, _("Signature Properties")); |
ks = (gpgme_key_sig_t)lparam; |
153 |
|
if (!ks) |
154 |
|
BUG (0); |
155 |
SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable")); |
SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable")); |
156 |
SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably")); |
SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably")); |
157 |
SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired")); |
SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired")); |
158 |
SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked")); |
SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked")); |
159 |
SetDlgItemText (dlg, IDC_SIGPROPS_CLASSINF, _("Class")); |
SetDlgItemText (dlg, IDC_SIGPROPS_CLASSINF, _("Class")); |
160 |
SetDlgItemText (dlg, IDC_SIGPROPS_EXPSTR, _("Expire date")); |
SetDlgItemText (dlg, IDC_SIGPROPS_EXPSTR, _("Expire date")); |
161 |
|
SetDlgItemText (dlg, IDC_SIGPROPS_CREATSTR, _("Creation date")); |
162 |
SetDlgItemText (dlg, IDC_SIGPROPS_KEYINF, _("Issuer key")); |
SetDlgItemText (dlg, IDC_SIGPROPS_KEYINF, _("Issuer key")); |
163 |
SetDlgItemText (dlg, IDC_SIGPROPS_KEYIDINF, _("Issuer key ID")); |
SetDlgItemText (dlg, IDC_SIGPROPS_KEYIDINF, _("Issuer key ID")); |
164 |
ks = (gpgme_key_sig_t)lparam; |
SetDlgItemText (dlg, IDC_SIGPROPS_POLICINF, _("Policy URL")); |
165 |
if (!ks) |
SetWindowText (dlg, _("Signature Properties")); |
166 |
BUG (0); |
|
167 |
memset (&ctx, 0, sizeof ctx); |
memset (&ctx, 0, sizeof ctx); |
168 |
ctx._class = ks->sig_class; |
ctx._class = ks->sig_class; |
169 |
if (ctx._class == 0) |
if (ctx._class == 0) |
177 |
ctx.alg = "ELG"; |
ctx.alg = "ELG"; |
178 |
ctx.exportable = ks->exportable; |
ctx.exportable = ks->exportable; |
179 |
_snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ, |
_snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ, |
180 |
ctx.exportable? _("Exportable") : _("Non-exportable"), ctx.alg); |
ctx.exportable? _("Exportable") : _("Non-exportable"), |
181 |
|
ctx.alg); |
182 |
SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf); |
SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf); |
183 |
|
|
184 |
SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, ks->keyid+8); |
_snprintf (tmpbuf, DIM (tmpbuf)-1, "0x%s", ks->keyid+8); |
185 |
|
SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf); |
186 |
SetDlgItemInt (dlg, IDC_SIGPROPS_CLASS, ctx._class, FALSE); |
SetDlgItemInt (dlg, IDC_SIGPROPS_CLASS, ctx._class, FALSE); |
187 |
if (ctx.exportable) |
if (ctx.exportable) |
188 |
CheckDlgButton (dlg, IDC_SIGPROPS_EXP, BST_CHECKED); |
CheckDlgButton (dlg, IDC_SIGPROPS_EXP, BST_CHECKED); |
189 |
if (!get_pubkey (ks->keyid+8, &issuer)) { |
memset (&issuer, 0, sizeof (issuer)); |
190 |
char *uid = utf8_to_native (issuer->uids->uid); |
if (!winpt_get_pubkey (ks->keyid+8, &issuer)) |
191 |
SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, uid); |
s = issuer.ext->uids->uid; |
|
safe_free (uid); |
|
|
} |
|
192 |
else |
else |
193 |
SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, _(" user ID not found")); |
s = _(" user ID not found"); |
194 |
|
SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, s); |
195 |
|
|
196 |
|
init_datepicker_from_time (GetDlgItem (dlg, IDC_SIGPROPS_CREATDATE), |
197 |
|
ks->timestamp); |
198 |
if (ks->expires == 0) { |
if (ks->expires == 0) { |
199 |
ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE); |
ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE); |
200 |
ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE); |
ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE); |
201 |
} |
} |
202 |
else { |
else { |
203 |
SYSTEMTIME st; |
init_datepicker_from_time (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), |
204 |
struct tm *tm; |
ks->expires); |
205 |
time_t t = time (NULL); |
if (time (NULL) > ks->expires) |
|
time_t tmp = ks->expires; |
|
|
|
|
|
tm = localtime (&tmp); |
|
|
memset (&st, 0, sizeof st); |
|
|
st.wYear = tm->tm_year+1900; |
|
|
st.wMonth = tm->tm_mon; |
|
|
st.wDay = tm->tm_mday; |
|
|
DateTime_SetSystemtime (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), |
|
|
GDT_VALID, &st); |
|
|
|
|
|
tm = localtime (&t); |
|
|
tm->tm_mon++; |
|
|
tm->tm_year += 1900; |
|
|
if (tm->tm_year > st.wYear) |
|
|
ctx.expired = 1; |
|
|
else if (tm->tm_mon > st.wMonth) |
|
206 |
ctx.expired = 1; |
ctx.expired = 1; |
207 |
if (ctx.expired) |
if (ctx.expired) |
208 |
CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED); |
CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED); |
209 |
} |
} |
210 |
|
if (ks->notations && !ks->notations->name && ks->notations->value) |
211 |
|
SetDlgItemText (dlg, IDC_SIGPROPS_POLIC, ks->notations->value); |
212 |
|
|
213 |
SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable")); |
SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable")); |
214 |
SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably")); |
SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably")); |
215 |
SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked")); |
SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked")); |
220 |
return TRUE; |
return TRUE; |
221 |
|
|
222 |
case WM_COMMAND: |
case WM_COMMAND: |
223 |
|
if (HIWORD (wparam) == BN_CLICKED) { |
224 |
|
/* Code to prevent the user changes the check buttons. */ |
225 |
|
switch (LOWORD (wparam)) { |
226 |
|
case IDC_SIGPROPS_EXP: |
227 |
|
CheckDlgButton (dlg, IDC_SIGPROPS_EXP, |
228 |
|
ctx.exportable? BST_CHECKED : BST_UNCHECKED); |
229 |
|
return TRUE; |
230 |
|
|
231 |
|
case IDC_SIGPROPS_EXPIRED: |
232 |
|
CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, |
233 |
|
ctx.expired? BST_CHECKED : BST_UNCHECKED); |
234 |
|
return TRUE; |
235 |
|
|
236 |
|
case IDC_SIGPROPS_REV: |
237 |
|
CheckDlgButton (dlg, IDC_SIGPROPS_REV, |
238 |
|
ctx.rev? BST_CHECKED : BST_UNCHECKED); |
239 |
|
return TRUE; |
240 |
|
|
241 |
|
case IDC_SIGPROPS_NREV: |
242 |
|
CheckDlgButton (dlg, IDC_SIGPROPS_NREV, |
243 |
|
ctx.nrev? BST_CHECKED : BST_UNCHECKED); |
244 |
|
return TRUE; |
245 |
|
} |
246 |
|
} |
247 |
|
|
248 |
switch (LOWORD (wparam)) { |
switch (LOWORD (wparam)) { |
249 |
case IDOK: |
case IDOK: |
250 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, TRUE); |
260 |
} |
} |
261 |
|
|
262 |
|
|
263 |
|
/* Subclass window procedure for the list view. */ |
264 |
static BOOL CALLBACK |
static BOOL CALLBACK |
265 |
subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
266 |
{ |
{ |
295 |
int i, n; |
int i, n; |
296 |
char id[128]; |
char id[128]; |
297 |
|
|
298 |
n = listview_count_items( lv, 0 ); |
n = listview_count_items (lv, 0); |
299 |
for( i = 0; i < n; i++ ) { |
for (i = 0; i < n; i++) { |
300 |
listview_get_item_text (lv, i, SL_COL_VALID, id, sizeof (id) - 1); |
listview_get_item_text (lv, i, SL_COL_VALID, id, sizeof (id) - 1); |
301 |
if (!strncmp (id, "NOKEY", 5)) |
if (!strncmp (id, "NOKEY", 5)) |
302 |
return 1; |
return 1; |
322 |
for (i = 0; i < n; i++) { |
for (i = 0; i < n; i++) { |
323 |
listview_get_item_text (lv, i, SL_COL_VALID, id, sizeof (id) - 1); |
listview_get_item_text (lv, i, SL_COL_VALID, id, sizeof (id) - 1); |
324 |
if (!strncmp (id, "NOKEY", 5)) { |
if (!strncmp (id, "NOKEY", 5)) { |
325 |
listview_get_item_text (lv, i, SL_COL_KEYID, |
listview_get_item_text (lv, i, SL_COL_KEYID, |
326 |
keyid, sizeof (keyid) -1); |
keyid, sizeof (keyid) -1); |
327 |
if (!hkp_recv_key (dlg, default_keyserver, |
if (!hkp_recv_key (dlg, default_keyserver, |
328 |
default_keyserver_port, keyid, 0, 0)) { |
default_keyserver_port, keyid, 0, 0)) { |
366 |
listview_get_item_text (lv, idx, SL_COL_KEYID, keyid, DIM (keyid)-1); |
listview_get_item_text (lv, idx, SL_COL_KEYID, keyid, DIM (keyid)-1); |
367 |
rc = hkp_recv_key (dlg, default_keyserver, |
rc = hkp_recv_key (dlg, default_keyserver, |
368 |
default_keyserver_port, keyid, 0, 0); |
default_keyserver_port, keyid, 0, 0); |
|
|
|
369 |
if (!rc) |
if (!rc) |
370 |
keycache_update (0, keyid); |
keycache_update (0, keyid); |
371 |
return rc; |
return rc; |
377 |
do_load_keyprops (HWND dlg, listview_ctrl_t lv) |
do_load_keyprops (HWND dlg, listview_ctrl_t lv) |
378 |
{ |
{ |
379 |
winpt_key_s k; |
winpt_key_s k; |
|
gpgme_key_t key; |
|
380 |
char keyid[32] = {0}; |
char keyid[32] = {0}; |
381 |
char status[64] = {0}, creation[64] = {0}; |
char status[64] = {0}, creation[64] = {0}; |
382 |
int n = listview_get_curr_pos (lv); |
int n = listview_get_curr_pos (lv); |
393 |
return; |
return; |
394 |
} |
} |
395 |
|
|
396 |
if ((strlen (keyid) < 3 ||get_pubkey (keyid, &key))) { |
memset (&k, 0, sizeof k); |
397 |
|
if ((strlen (keyid) < 3 || winpt_get_pubkey (keyid, &k))) { |
398 |
if (strlen (creation) > 0) |
if (strlen (creation) > 0) |
399 |
msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO); |
msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO); |
400 |
return; |
return; |
401 |
} |
} |
|
memset (&k, 0, sizeof k); |
|
|
k.keyid = keyid; |
|
402 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg, |
403 |
keyprops_dlg_proc, (LPARAM)&k); |
keyprops_dlg_proc, (LPARAM)&k); |
404 |
} |
} |
412 |
static struct winpt_key_s *k; |
static struct winpt_key_s *k; |
413 |
gpgme_key_sig_t ks; |
gpgme_key_sig_t ks; |
414 |
HWND sl; |
HWND sl; |
415 |
char inf[384], *utf8_uid; |
char inf[384]; |
416 |
int idx = 0; |
int idx = 0; |
417 |
|
|
418 |
switch (msg) { |
switch (msg) { |
420 |
k = (winpt_key_t) lparam; |
k = (winpt_key_t) lparam; |
421 |
if (!k) |
if (!k) |
422 |
BUG (0); |
BUG (0); |
423 |
if (k->uid) { |
if (k->uid) |
424 |
utf8_uid = utf8_to_native (k->uid); |
_snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid); |
|
_snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), utf8_uid); |
|
|
safe_free (utf8_uid); |
|
|
} |
|
425 |
SetWindowText (dlg, inf); |
SetWindowText (dlg, inf); |
426 |
SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key")); |
SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key")); |
427 |
SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties")); |
SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties")); |
453 |
lv = NULL; |
lv = NULL; |
454 |
} |
} |
455 |
return FALSE; |
return FALSE; |
|
|
|
|
case WM_SYSCOMMAND: |
|
|
if (LOWORD (wparam) == SC_CLOSE) |
|
|
EndDialog (dlg, TRUE); |
|
|
return FALSE; |
|
456 |
|
|
457 |
case WM_NOTIFY: |
case WM_NOTIFY: |
458 |
NMHDR *notify; |
NMHDR *notify; |
460 |
notify = (NMHDR *)lparam; |
notify = (NMHDR *)lparam; |
461 |
if (!notify) |
if (!notify) |
462 |
return FALSE; |
return FALSE; |
463 |
if (notify->code == NM_DBLCLK |
if (notify->code == NM_DBLCLK && |
464 |
&& notify->idFrom == IDC_KEYSIG_LIST) |
notify->idFrom == IDC_KEYSIG_LIST) |
465 |
do_load_keyprops (dlg, lv); |
do_load_keyprops (dlg, lv); |
466 |
if (notify->code == NM_RCLICK && |
if (notify->code == NM_RCLICK && |
467 |
notify->idFrom == IDC_KEYSIG_LIST && |
notify->idFrom == IDC_KEYSIG_LIST && |
497 |
switch (LOWORD (wparam)) { |
switch (LOWORD (wparam)) { |
498 |
case ID_SIGCTX_KEYPROPS: |
case ID_SIGCTX_KEYPROPS: |
499 |
do_load_keyprops (dlg, lv); |
do_load_keyprops (dlg, lv); |
500 |
break; |
return TRUE; |
501 |
|
|
502 |
case ID_SIGCTX_PROPS: |
case ID_SIGCTX_PROPS: |
503 |
if (is_sig (lv, -1)) { |
if (is_sig (lv, -1)) { |
505 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg, |
506 |
sigprops_dlg_proc, (LPARAM)ks); |
sigprops_dlg_proc, (LPARAM)ks); |
507 |
} |
} |
508 |
break; |
return TRUE; |
509 |
|
|
510 |
case IDC_KEYSIG_RECVKEY: |
case IDC_KEYSIG_RECVKEY: |
511 |
idx = listview_get_curr_pos (lv); |
idx = listview_get_curr_pos (lv); |
523 |
} |
} |
524 |
return TRUE; |
return TRUE; |
525 |
|
|
526 |
|
case IDCANCEL: |
527 |
|
EndDialog (dlg, FALSE); |
528 |
|
return TRUE; |
529 |
|
|
530 |
case IDOK: |
case IDOK: |
531 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, TRUE); |
532 |
return TRUE; |
return TRUE; |