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) |
148 |
const char *s; |
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 |
SetDlgItemText (dlg, IDC_SIGPROPS_POLICINF, _("Policy URL")); |
SetDlgItemText (dlg, IDC_SIGPROPS_POLICINF, _("Policy URL")); |
165 |
ks = (gpgme_key_sig_t)lparam; |
SetWindowText (dlg, _("Signature Properties")); |
166 |
if (!ks) |
|
|
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 |
_snprintf (tmpbuf, DIM (tmpbuf)-1, "0x%s", ks->keyid+8); |
_snprintf (tmpbuf, DIM (tmpbuf)-1, "0x%s", ks->keyid+8); |
192 |
else |
else |
193 |
s = _(" user ID not found"); |
s = _(" user ID not found"); |
194 |
SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, s); |
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); |
222 |
|
|
223 |
case WM_COMMAND: |
case WM_COMMAND: |
224 |
if (HIWORD (wparam) == BN_CLICKED) { |
if (HIWORD (wparam) == BN_CLICKED) { |
225 |
|
/* Code to prevent the user changes the check buttons. */ |
226 |
switch (LOWORD (wparam)) { |
switch (LOWORD (wparam)) { |
227 |
case IDC_SIGPROPS_EXP: |
case IDC_SIGPROPS_EXP: |
228 |
CheckDlgButton (dlg, IDC_SIGPROPS_EXP, |
CheckDlgButton (dlg, IDC_SIGPROPS_EXP, |
261 |
} |
} |
262 |
|
|
263 |
|
|
264 |
|
/* Subclass window procedure for the list view. */ |
265 |
static BOOL CALLBACK |
static BOOL CALLBACK |
266 |
subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
267 |
{ |
{ |
296 |
int i, n; |
int i, n; |
297 |
char id[128]; |
char id[128]; |
298 |
|
|
299 |
n = listview_count_items( lv, 0 ); |
n = listview_count_items (lv, 0); |
300 |
for( i = 0; i < n; i++ ) { |
for (i = 0; i < n; i++) { |
301 |
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); |
302 |
if (!strncmp (id, "NOKEY", 5)) |
if (!strncmp (id, "NOKEY", 5)) |
303 |
return 1; |
return 1; |
323 |
for (i = 0; i < n; i++) { |
for (i = 0; i < n; i++) { |
324 |
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); |
325 |
if (!strncmp (id, "NOKEY", 5)) { |
if (!strncmp (id, "NOKEY", 5)) { |
326 |
listview_get_item_text (lv, i, SL_COL_KEYID, |
listview_get_item_text (lv, i, SL_COL_KEYID, |
327 |
keyid, sizeof (keyid) -1); |
keyid, sizeof (keyid) -1); |
328 |
if (!hkp_recv_key (dlg, default_keyserver, |
if (!hkp_recv_key (dlg, default_keyserver, |
329 |
default_keyserver_port, keyid, 0, 0)) { |
default_keyserver_port, keyid, 0, 0)) { |
367 |
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); |
368 |
rc = hkp_recv_key (dlg, default_keyserver, |
rc = hkp_recv_key (dlg, default_keyserver, |
369 |
default_keyserver_port, keyid, 0, 0); |
default_keyserver_port, keyid, 0, 0); |
|
|
|
370 |
if (!rc) |
if (!rc) |
371 |
keycache_update (0, keyid); |
keycache_update (0, keyid); |
372 |
return rc; |
return rc; |
378 |
do_load_keyprops (HWND dlg, listview_ctrl_t lv) |
do_load_keyprops (HWND dlg, listview_ctrl_t lv) |
379 |
{ |
{ |
380 |
winpt_key_s k; |
winpt_key_s k; |
|
gpgme_key_t key; |
|
381 |
char keyid[32] = {0}; |
char keyid[32] = {0}; |
382 |
char status[64] = {0}, creation[64] = {0}; |
char status[64] = {0}, creation[64] = {0}; |
383 |
int n = listview_get_curr_pos (lv); |
int n = listview_get_curr_pos (lv); |
394 |
return; |
return; |
395 |
} |
} |
396 |
|
|
397 |
if ((strlen (keyid) < 3 ||get_pubkey (keyid, &key))) { |
memset (&k, 0, sizeof k); |
398 |
|
if ((strlen (keyid) < 3 || winpt_get_pubkey (keyid, &k))) { |
399 |
if (strlen (creation) > 0) |
if (strlen (creation) > 0) |
400 |
msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO); |
msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO); |
401 |
return; |
return; |
402 |
} |
} |
|
memset (&k, 0, sizeof k); |
|
|
k.keyid = keyid; |
|
403 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg, |
404 |
keyprops_dlg_proc, (LPARAM)&k); |
keyprops_dlg_proc, (LPARAM)&k); |
405 |
} |
} |
454 |
lv = NULL; |
lv = NULL; |
455 |
} |
} |
456 |
return FALSE; |
return FALSE; |
|
|
|
|
case WM_SYSCOMMAND: |
|
|
if (LOWORD (wparam) == SC_CLOSE) |
|
|
EndDialog (dlg, TRUE); |
|
|
return FALSE; |
|
457 |
|
|
458 |
case WM_NOTIFY: |
case WM_NOTIFY: |
459 |
NMHDR *notify; |
NMHDR *notify; |
461 |
notify = (NMHDR *)lparam; |
notify = (NMHDR *)lparam; |
462 |
if (!notify) |
if (!notify) |
463 |
return FALSE; |
return FALSE; |
464 |
if (notify->code == NM_DBLCLK |
if (notify->code == NM_DBLCLK && |
465 |
&& notify->idFrom == IDC_KEYSIG_LIST) |
notify->idFrom == IDC_KEYSIG_LIST) |
466 |
do_load_keyprops (dlg, lv); |
do_load_keyprops (dlg, lv); |
467 |
if (notify->code == NM_RCLICK && |
if (notify->code == NM_RCLICK && |
468 |
notify->idFrom == IDC_KEYSIG_LIST && |
notify->idFrom == IDC_KEYSIG_LIST && |
524 |
} |
} |
525 |
return TRUE; |
return TRUE; |
526 |
|
|
527 |
|
case IDCANCEL: |
528 |
|
EndDialog (dlg, FALSE); |
529 |
|
return TRUE; |
530 |
|
|
531 |
case IDOK: |
case IDOK: |
532 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, TRUE); |
533 |
return TRUE; |
return TRUE; |