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 |
{ |
{ |
132 |
const char *s; |
const char *s; |
133 |
|
|
134 |
switch (msg) { |
switch (msg) { |
|
case WM_SYSCOMMAND: |
|
|
if (LOWORD (wparam) == SC_CLOSE) |
|
|
EndDialog (dlg, TRUE); |
|
|
return FALSE; |
|
|
|
|
135 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
136 |
SetWindowText (dlg, _("Signature Properties")); |
ks = (gpgme_key_sig_t)lparam; |
137 |
|
if (!ks) |
138 |
|
BUG (0); |
139 |
SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable")); |
SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable")); |
140 |
SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably")); |
SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably")); |
141 |
SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired")); |
SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired")); |
145 |
SetDlgItemText (dlg, IDC_SIGPROPS_KEYINF, _("Issuer key")); |
SetDlgItemText (dlg, IDC_SIGPROPS_KEYINF, _("Issuer key")); |
146 |
SetDlgItemText (dlg, IDC_SIGPROPS_KEYIDINF, _("Issuer key ID")); |
SetDlgItemText (dlg, IDC_SIGPROPS_KEYIDINF, _("Issuer key ID")); |
147 |
SetDlgItemText (dlg, IDC_SIGPROPS_POLICINF, _("Policy URL")); |
SetDlgItemText (dlg, IDC_SIGPROPS_POLICINF, _("Policy URL")); |
148 |
ks = (gpgme_key_sig_t)lparam; |
SetWindowText (dlg, _("Signature Properties")); |
149 |
if (!ks) |
|
|
BUG (0); |
|
150 |
memset (&ctx, 0, sizeof ctx); |
memset (&ctx, 0, sizeof ctx); |
151 |
ctx._class = ks->sig_class; |
ctx._class = ks->sig_class; |
152 |
if (ctx._class == 0) |
if (ctx._class == 0) |
160 |
ctx.alg = "ELG"; |
ctx.alg = "ELG"; |
161 |
ctx.exportable = ks->exportable; |
ctx.exportable = ks->exportable; |
162 |
_snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ, |
_snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ, |
163 |
ctx.exportable? _("Exportable") : _("Non-exportable"), ctx.alg); |
ctx.exportable? _("Exportable") : _("Non-exportable"), |
164 |
|
ctx.alg); |
165 |
SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf); |
SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf); |
166 |
|
|
167 |
_snprintf (tmpbuf, DIM (tmpbuf)-1, "0x%s", ks->keyid+8); |
_snprintf (tmpbuf, DIM (tmpbuf)-1, "0x%s", ks->keyid+8); |
182 |
else { |
else { |
183 |
SYSTEMTIME st; |
SYSTEMTIME st; |
184 |
struct tm *tm; |
struct tm *tm; |
185 |
time_t t = time (NULL); |
time_t now = time (NULL); |
186 |
time_t tmp = ks->expires; |
time_t tmp = ks->expires; |
187 |
|
|
188 |
tm = localtime (&tmp); |
tm = localtime (&tmp); |
189 |
memset (&st, 0, sizeof st); |
memset (&st, 0, sizeof st); |
190 |
st.wYear = tm->tm_year+1900; |
st.wYear = tm->tm_year+1900; |
191 |
st.wMonth = tm->tm_mon; |
st.wMonth = tm->tm_mon+1; |
192 |
st.wDay = tm->tm_mday; |
st.wDay = tm->tm_mday; |
193 |
DateTime_SetSystemtime (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), |
DateTime_SetSystemtime (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), |
194 |
GDT_VALID, &st); |
GDT_VALID, &st); |
195 |
|
|
196 |
tm = localtime (&t); |
if (now > ks->expires) |
|
tm->tm_mon++; |
|
|
tm->tm_year += 1900; |
|
|
if (tm->tm_year > st.wYear) |
|
|
ctx.expired = 1; |
|
|
else if (tm->tm_mon > st.wMonth) |
|
197 |
ctx.expired = 1; |
ctx.expired = 1; |
198 |
if (ctx.expired) |
if (ctx.expired) |
199 |
CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED); |
CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED); |
213 |
|
|
214 |
case WM_COMMAND: |
case WM_COMMAND: |
215 |
if (HIWORD (wparam) == BN_CLICKED) { |
if (HIWORD (wparam) == BN_CLICKED) { |
216 |
|
/* Code to prevent the user changes the check buttons. */ |
217 |
switch (LOWORD (wparam)) { |
switch (LOWORD (wparam)) { |
218 |
case IDC_SIGPROPS_EXP: |
case IDC_SIGPROPS_EXP: |
219 |
CheckDlgButton (dlg, IDC_SIGPROPS_EXP, |
CheckDlgButton (dlg, IDC_SIGPROPS_EXP, |
252 |
} |
} |
253 |
|
|
254 |
|
|
255 |
|
/* Subclass window procedure for the list view. */ |
256 |
static BOOL CALLBACK |
static BOOL CALLBACK |
257 |
subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
258 |
{ |
{ |
287 |
int i, n; |
int i, n; |
288 |
char id[128]; |
char id[128]; |
289 |
|
|
290 |
n = listview_count_items( lv, 0 ); |
n = listview_count_items (lv, 0); |
291 |
for( i = 0; i < n; i++ ) { |
for (i = 0; i < n; i++) { |
292 |
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); |
293 |
if (!strncmp (id, "NOKEY", 5)) |
if (!strncmp (id, "NOKEY", 5)) |
294 |
return 1; |
return 1; |
314 |
for (i = 0; i < n; i++) { |
for (i = 0; i < n; i++) { |
315 |
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); |
316 |
if (!strncmp (id, "NOKEY", 5)) { |
if (!strncmp (id, "NOKEY", 5)) { |
317 |
listview_get_item_text (lv, i, SL_COL_KEYID, |
listview_get_item_text (lv, i, SL_COL_KEYID, |
318 |
keyid, sizeof (keyid) -1); |
keyid, sizeof (keyid) -1); |
319 |
if (!hkp_recv_key (dlg, default_keyserver, |
if (!hkp_recv_key (dlg, default_keyserver, |
320 |
default_keyserver_port, keyid, 0, 0)) { |
default_keyserver_port, keyid, 0, 0)) { |
358 |
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); |
359 |
rc = hkp_recv_key (dlg, default_keyserver, |
rc = hkp_recv_key (dlg, default_keyserver, |
360 |
default_keyserver_port, keyid, 0, 0); |
default_keyserver_port, keyid, 0, 0); |
|
|
|
361 |
if (!rc) |
if (!rc) |
362 |
keycache_update (0, keyid); |
keycache_update (0, keyid); |
363 |
return rc; |
return rc; |
369 |
do_load_keyprops (HWND dlg, listview_ctrl_t lv) |
do_load_keyprops (HWND dlg, listview_ctrl_t lv) |
370 |
{ |
{ |
371 |
winpt_key_s k; |
winpt_key_s k; |
|
gpgme_key_t key; |
|
372 |
char keyid[32] = {0}; |
char keyid[32] = {0}; |
373 |
char status[64] = {0}, creation[64] = {0}; |
char status[64] = {0}, creation[64] = {0}; |
374 |
int n = listview_get_curr_pos (lv); |
int n = listview_get_curr_pos (lv); |
385 |
return; |
return; |
386 |
} |
} |
387 |
|
|
388 |
if ((strlen (keyid) < 3 ||get_pubkey (keyid, &key))) { |
memset (&k, 0, sizeof k); |
389 |
|
if ((strlen (keyid) < 3 || winpt_get_pubkey (keyid, &k))) { |
390 |
if (strlen (creation) > 0) |
if (strlen (creation) > 0) |
391 |
msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO); |
msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO); |
392 |
return; |
return; |
393 |
} |
} |
|
memset (&k, 0, sizeof k); |
|
|
k.keyid = keyid; |
|
394 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg, |
395 |
keyprops_dlg_proc, (LPARAM)&k); |
keyprops_dlg_proc, (LPARAM)&k); |
396 |
} |
} |
445 |
lv = NULL; |
lv = NULL; |
446 |
} |
} |
447 |
return FALSE; |
return FALSE; |
|
|
|
|
case WM_SYSCOMMAND: |
|
|
if (LOWORD (wparam) == SC_CLOSE) |
|
|
EndDialog (dlg, TRUE); |
|
|
return FALSE; |
|
448 |
|
|
449 |
case WM_NOTIFY: |
case WM_NOTIFY: |
450 |
NMHDR *notify; |
NMHDR *notify; |
452 |
notify = (NMHDR *)lparam; |
notify = (NMHDR *)lparam; |
453 |
if (!notify) |
if (!notify) |
454 |
return FALSE; |
return FALSE; |
455 |
if (notify->code == NM_DBLCLK |
if (notify->code == NM_DBLCLK && |
456 |
&& notify->idFrom == IDC_KEYSIG_LIST) |
notify->idFrom == IDC_KEYSIG_LIST) |
457 |
do_load_keyprops (dlg, lv); |
do_load_keyprops (dlg, lv); |
458 |
if (notify->code == NM_RCLICK && |
if (notify->code == NM_RCLICK && |
459 |
notify->idFrom == IDC_KEYSIG_LIST && |
notify->idFrom == IDC_KEYSIG_LIST && |
515 |
} |
} |
516 |
return TRUE; |
return TRUE; |
517 |
|
|
518 |
|
case IDCANCEL: |
519 |
|
EndDialog (dlg, FALSE); |
520 |
|
return TRUE; |
521 |
|
|
522 |
case IDOK: |
case IDOK: |
523 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, TRUE); |
524 |
return TRUE; |
return TRUE; |