1 |
/* wptKeysigDlg.cpp - Key signature listing |
/* wptKeysigDlg.cpp - Key signature listing |
2 |
* Copyright (C) 2001-2006 Timo Schulz |
* Copyright (C) 2001-2006, 2008 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
* GNU General Public License for more details. |
|
* |
|
|
* You should have received a copy of the GNU General Public License |
|
|
* along with WinPT; if not, write to the Free Software Foundation, |
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
15 |
*/ |
*/ |
16 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
17 |
#include <config.h> |
#include <config.h> |
62 |
do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key) |
do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key) |
63 |
{ |
{ |
64 |
gpgme_error_t err; |
gpgme_error_t err; |
65 |
GpgKeyEdit *ke; |
GpgKeyEdit ke; |
66 |
char keyid[32]; |
char keyid[32]; |
67 |
int pos, npos, id, is_selfsig=0; |
int pos, npos, id, is_selfsig=0; |
68 |
int signo=0, uidno=0; |
int signo=0, uidno=0; |
94 |
if (id == IDNO) |
if (id == IDNO) |
95 |
return 0; |
return 0; |
96 |
|
|
97 |
ke = new GpgKeyEdit (key->keyid); |
ke.setKeyID (key->keyid); |
98 |
if (!ke) |
err = ke.delUseridSignature (uidno, signo); |
|
BUG (NULL); |
|
|
err = ke->delUseridSignature (uidno, signo); |
|
99 |
if (err) |
if (err) |
100 |
msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR); |
101 |
else |
else |
102 |
listview_del_item (lv, pos); |
listview_del_item (lv, pos); |
|
delete ke; |
|
103 |
if (!err) |
if (!err) |
104 |
key->update = 1; |
key->update = 1; |
105 |
return err? -1 : 0; |
return err? -1 : 0; |
106 |
} |
} |
107 |
|
|
108 |
|
|
109 |
|
/* Initialize a datepicker control with the time given in @t. */ |
110 |
|
static void |
111 |
|
init_datepicker_from_time (HWND picker, time_t t) |
112 |
|
{ |
113 |
|
SYSTEMTIME st; |
114 |
|
struct tm *tm; |
115 |
|
|
116 |
|
tm = localtime (&t); |
117 |
|
memset (&st, 0, sizeof st); |
118 |
|
st.wYear = tm->tm_year+1900; |
119 |
|
st.wMonth = tm->tm_mon+1; |
120 |
|
st.wDay = tm->tm_mday; |
121 |
|
DateTime_SetSystemtime (picker, GDT_VALID, &st); |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
/* Dialog box procedure to display the signature properties. */ |
/* Dialog box procedure to display the signature properties. */ |
126 |
BOOL CALLBACK |
BOOL CALLBACK |
127 |
sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
151 |
SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked")); |
SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked")); |
152 |
SetDlgItemText (dlg, IDC_SIGPROPS_CLASSINF, _("Class")); |
SetDlgItemText (dlg, IDC_SIGPROPS_CLASSINF, _("Class")); |
153 |
SetDlgItemText (dlg, IDC_SIGPROPS_EXPSTR, _("Expire date")); |
SetDlgItemText (dlg, IDC_SIGPROPS_EXPSTR, _("Expire date")); |
154 |
|
SetDlgItemText (dlg, IDC_SIGPROPS_CREATSTR, _("Creation date")); |
155 |
SetDlgItemText (dlg, IDC_SIGPROPS_KEYINF, _("Issuer key")); |
SetDlgItemText (dlg, IDC_SIGPROPS_KEYINF, _("Issuer key")); |
156 |
SetDlgItemText (dlg, IDC_SIGPROPS_KEYIDINF, _("Issuer key ID")); |
SetDlgItemText (dlg, IDC_SIGPROPS_KEYIDINF, _("Issuer key ID")); |
157 |
SetDlgItemText (dlg, IDC_SIGPROPS_POLICINF, _("Policy URL")); |
SetDlgItemText (dlg, IDC_SIGPROPS_POLICINF, _("Policy URL")); |
158 |
|
SetDlgItemText (dlg, IDC_SIGPROPS_FRAME, _("Signature Info")); |
159 |
SetWindowText (dlg, _("Signature Properties")); |
SetWindowText (dlg, _("Signature Properties")); |
160 |
|
|
161 |
memset (&ctx, 0, sizeof ctx); |
memset (&ctx, 0, sizeof ctx); |
186 |
else |
else |
187 |
s = _(" user ID not found"); |
s = _(" user ID not found"); |
188 |
SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, s); |
SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, s); |
189 |
|
|
190 |
|
init_datepicker_from_time (GetDlgItem (dlg, IDC_SIGPROPS_CREATDATE), |
191 |
|
ks->timestamp); |
192 |
if (ks->expires == 0) { |
if (ks->expires == 0) { |
193 |
ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE); |
ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE); |
194 |
ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE); |
ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE); |
195 |
} |
} |
196 |
else { |
else { |
197 |
SYSTEMTIME st; |
init_datepicker_from_time (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), |
198 |
struct tm *tm; |
ks->expires); |
199 |
time_t now = 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+1; |
|
|
st.wDay = tm->tm_mday; |
|
|
DateTime_SetSystemtime (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), |
|
|
GDT_VALID, &st); |
|
|
|
|
|
if (now > ks->expires) |
|
200 |
ctx.expired = 1; |
ctx.expired = 1; |
201 |
if (ctx.expired) |
if (ctx.expired) |
202 |
CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED); |
CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED); |
203 |
} |
} |
|
/* XXX (gpgme): \r at the end of the notation value. */ |
|
204 |
if (ks->notations && !ks->notations->name && ks->notations->value) |
if (ks->notations && !ks->notations->name && ks->notations->value) |
205 |
SetDlgItemText (dlg, IDC_SIGPROPS_POLIC, ks->notations->value); |
SetDlgItemText (dlg, IDC_SIGPROPS_POLIC, ks->notations->value); |
206 |
|
|
286 |
static int |
static int |
287 |
check_for_missing_keys (listview_ctrl_t lv) |
check_for_missing_keys (listview_ctrl_t lv) |
288 |
{ |
{ |
289 |
int i, n; |
int n; |
290 |
char id[128]; |
char id[128]; |
291 |
|
const char *txt = _("NOKEY"); |
292 |
|
|
293 |
n = listview_count_items (lv, 0); |
n = listview_count_items (lv, 0); |
294 |
for (i = 0; i < n; i++) { |
for (int i = 0; i < n; i++) { |
295 |
listview_get_item_text (lv, i, SL_COL_VALID, id, sizeof (id) - 1); |
listview_get_item_text (lv, i, SL_COL_VALID, id, DIM (id) - 1); |
296 |
if (!strncmp (id, "NOKEY", 5)) |
if (!strncmp (id, txt, strlen (txt))) |
297 |
return 1; |
return 1; |
298 |
} |
} |
299 |
|
|
305 |
static int |
static int |
306 |
recv_missing_keys (HWND dlg, listview_ctrl_t lv) |
recv_missing_keys (HWND dlg, listview_ctrl_t lv) |
307 |
{ |
{ |
308 |
|
const char *txt = _("NOKEY"); |
309 |
char id[128], keyid[18+1]; |
char id[128], keyid[18+1]; |
310 |
int i, n, cnt=0; |
int n, cnt=0; |
311 |
|
|
312 |
i = msg_box (dlg, _("Really receive all missing keys?"), |
if (msg_box (dlg, _("Really receive all missing keys?"), |
313 |
_("Key Manager"), MB_YESNO|MB_INFO); |
_("Key Manager"), MB_YESNO|MB_INFO) == IDNO) |
|
if (i == IDNO) |
|
314 |
return 0; |
return 0; |
315 |
|
|
316 |
n = listview_count_items (lv, 0); |
n = listview_count_items (lv, 0); |
317 |
for (i = 0; i < n; i++) { |
for (int i = 0; i < n; i++) { |
318 |
listview_get_item_text (lv, i, SL_COL_VALID, id, sizeof (id) - 1); |
listview_get_item_text (lv, i, SL_COL_VALID, id, DIM (id) - 1); |
319 |
if (!strncmp (id, "NOKEY", 5)) { |
if (!strncmp (id, txt, strlen (txt))) { |
320 |
listview_get_item_text (lv, i, SL_COL_KEYID, |
listview_get_item_text (lv, i, SL_COL_KEYID, |
321 |
keyid, sizeof (keyid) -1); |
keyid, DIM (keyid) -1); |
322 |
if (!hkp_recv_key (dlg, default_keyserver, |
if (!hkp_recv_key (dlg, default_keyserver, |
323 |
default_keyserver_port, keyid, 0, 0)) { |
default_keyserver_port, keyid, 0, 0)) { |
324 |
keycache_update (0, keyid); |
keycache_update (0, keyid); |
370 |
/* Load the key property dialog with the selected key from @lv. */ |
/* Load the key property dialog with the selected key from @lv. */ |
371 |
static void |
static void |
372 |
do_load_keyprops (HWND dlg, listview_ctrl_t lv) |
do_load_keyprops (HWND dlg, listview_ctrl_t lv) |
373 |
{ |
{ |
374 |
winpt_key_s k; |
winpt_key_s k; |
375 |
char keyid[32] = {0}; |
char keyid[32] = {0}; |
376 |
char status[64] = {0}, creation[64] = {0}; |
char status[64] = {0}, creation[64] = {0}; |
379 |
listview_get_item_text (lv, n, SL_COL_VALID, status, DIM (status)-1); |
listview_get_item_text (lv, n, SL_COL_VALID, status, DIM (status)-1); |
380 |
listview_get_item_text (lv, n, SL_COL_CREATE, creation, DIM (creation)-1); |
listview_get_item_text (lv, n, SL_COL_CREATE, creation, DIM (creation)-1); |
381 |
listview_get_item_text (lv, n, SL_COL_KEYID, keyid, DIM (keyid)-1); |
listview_get_item_text (lv, n, SL_COL_KEYID, keyid, DIM (keyid)-1); |
382 |
if (!strcmp (status, "NOKEY")) { |
if (!strcmp (status, _("NOKEY"))) { |
383 |
int id = msg_box (dlg, _("Key not found in keyring, do you want to fetch it from the keyserver?"), |
int id = msg_box (dlg, _("Key not found in keyring, do you want to fetch it from the keyserver?"), |
384 |
_("Key Manager"), MB_QUEST_ASK); |
_("Key Manager"), MB_QUEST_ASK); |
385 |
if (id == IDNO) |
if (id == IDNO) |
467 |
idx = listview_get_curr_pos (lv); |
idx = listview_get_curr_pos (lv); |
468 |
listview_get_item_text (lv, idx, SL_COL_VALID, inf, DIM (inf)-1); |
listview_get_item_text (lv, idx, SL_COL_VALID, inf, DIM (inf)-1); |
469 |
EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY), |
EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY), |
470 |
strcmp (inf, "NOKEY") == 0? TRUE: FALSE); |
strcmp (inf, _("NOKEY")) == 0? TRUE: FALSE); |
471 |
EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_SIGPROPS), |
EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_SIGPROPS), |
472 |
is_sig (lv, -1)? TRUE : FALSE); |
is_sig (lv, -1)? TRUE : FALSE); |
473 |
} |
} |
492 |
switch (LOWORD (wparam)) { |
switch (LOWORD (wparam)) { |
493 |
case ID_SIGCTX_KEYPROPS: |
case ID_SIGCTX_KEYPROPS: |
494 |
do_load_keyprops (dlg, lv); |
do_load_keyprops (dlg, lv); |
495 |
break; |
return TRUE; |
496 |
|
|
497 |
case ID_SIGCTX_PROPS: |
case ID_SIGCTX_PROPS: |
498 |
if (is_sig (lv, -1)) { |
if (is_sig (lv, -1)) { |
500 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg, |
501 |
sigprops_dlg_proc, (LPARAM)ks); |
sigprops_dlg_proc, (LPARAM)ks); |
502 |
} |
} |
503 |
break; |
return TRUE; |
504 |
|
|
505 |
case IDC_KEYSIG_RECVKEY: |
case IDC_KEYSIG_RECVKEY: |
506 |
idx = listview_get_curr_pos (lv); |
idx = listview_get_curr_pos (lv); |
512 |
|
|
513 |
case IDC_KEYSIG_SIGPROPS: |
case IDC_KEYSIG_SIGPROPS: |
514 |
if (is_sig (lv, -1)) { |
if (is_sig (lv, -1)) { |
515 |
ks = ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv)); |
ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv)); |
516 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg, |
517 |
sigprops_dlg_proc, (LPARAM)ks); |
sigprops_dlg_proc, (LPARAM)ks); |
518 |
} |
} |