1 |
/* wptKeyPropsDlg.cpp - WinPT key properties dialog |
/* wptKeyPropsDlg.cpp - WinPT key properties dialog |
2 |
* Copyright (C) 2000, 2001, 2002, 2003, 2005 Timo Schulz |
* Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
51 |
|
|
52 |
/* Convert a trust integer into a string representation. */ |
/* Convert a trust integer into a string representation. */ |
53 |
static const char* |
static const char* |
54 |
ownertrust_to_string (int val) |
ownertrust_to_string (int val, bool is_keypair) |
55 |
{ |
{ |
56 |
const char *inf; |
const char *inf; |
57 |
int id = val; |
int id = val; |
62 |
case 3: inf = _("I trust marginally"); break; |
case 3: inf = _("I trust marginally"); break; |
63 |
case 4: inf = _("I trust fully"); break; |
case 4: inf = _("I trust fully"); break; |
64 |
case 5: |
case 5: |
65 |
case 6: inf = _("I trust ultimately"); break; |
case 6: |
66 |
|
if (is_keypair) |
67 |
|
inf = _("I trust ultimately (implicit)"); |
68 |
|
else |
69 |
|
inf = _("I trust ultimately"); break; |
70 |
default:inf = _("Unknown"); break; |
default:inf = _("Unknown"); break; |
71 |
} |
} |
72 |
|
|
258 |
|
|
259 |
SetDlgItemText (dlg, IDC_KEYPROPS_INFO, info); |
SetDlgItemText (dlg, IDC_KEYPROPS_INFO, info); |
260 |
SetDlgItemText (dlg, IDC_KEYPROPS_FPR, get_key_fpr (key)); |
SetDlgItemText (dlg, IDC_KEYPROPS_FPR, get_key_fpr (key)); |
261 |
inf = ownertrust_to_string (key->owner_trust); |
inf = ownertrust_to_string (key->owner_trust, k->key_pair); |
262 |
SetDlgItemText (dlg, IDC_KEYPROPS_OT, inf); |
SetDlgItemText (dlg, IDC_KEYPROPS_OT, inf); |
263 |
|
|
264 |
*r_key = key; |
*r_key = key; |
274 |
gpgme_validity_t valid; |
gpgme_validity_t valid; |
275 |
refresh_cache_s rcs = {0}; |
refresh_cache_s rcs = {0}; |
276 |
const char *inf; |
const char *inf; |
277 |
|
int cancel = 0; |
278 |
int rc; |
int rc; |
279 |
|
|
280 |
/* XXX: static variable (k) prevent that the dialog can |
/* XXX: static variable (k) prevent that the dialog can |
287 |
SetWindowText (dlg, _("Key Properties")); |
SetWindowText (dlg, _("Key Properties")); |
288 |
SetDlgItemText (dlg, IDC_KEYPROPS_OT_CHANGE, _("&Change")); |
SetDlgItemText (dlg, IDC_KEYPROPS_OT_CHANGE, _("&Change")); |
289 |
SetDlgItemText (dlg, IDC_KEYPROPS_REVOKERS, _("&Revokers")); |
SetDlgItemText (dlg, IDC_KEYPROPS_REVOKERS, _("&Revokers")); |
290 |
SetDlgItemText (dlg, IDC_KEYPROPS_CHANGE_PWD, _("Change &Passwd")); |
SetDlgItemText (dlg, IDC_KEYPROPS_CHANGE_PWD, _("Change &Password")); |
291 |
SetDlgItemText (dlg, IDC_KEYPROPS_OTINF, _("Ownertrust")); |
SetDlgItemText (dlg, IDC_KEYPROPS_OTINF, _("Ownertrust")); |
292 |
|
|
293 |
display_key_info (dlg, k, &key); |
display_key_info (dlg, k, &key); |
300 |
EnableWindow (GetDlgItem (dlg, IDC_KEYPROPS_CHANGE_PWD), TRUE); |
EnableWindow (GetDlgItem (dlg, IDC_KEYPROPS_CHANGE_PWD), TRUE); |
301 |
if (check_for_desig_rev (key)) |
if (check_for_desig_rev (key)) |
302 |
EnableWindow (GetDlgItem (dlg, IDC_KEYPROPS_REVOKERS), TRUE); |
EnableWindow (GetDlgItem (dlg, IDC_KEYPROPS_REVOKERS), TRUE); |
303 |
|
if (key->revoked || key->expired) |
304 |
|
EnableWindow (GetDlgItem (dlg, IDC_KEYPROPS_OT_CHANGE), FALSE); |
305 |
center_window (dlg, NULL); |
center_window (dlg, NULL); |
306 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
307 |
return TRUE; |
return TRUE; |
333 |
_("WinPT Warning"), MB_ERR); |
_("WinPT Warning"), MB_ERR); |
334 |
return TRUE; |
return TRUE; |
335 |
} |
} |
336 |
if( !k->key_pair && key->uids->validity < 3 ) { |
if (!k->key_pair && key->uids->validity < 3) { |
337 |
rc = msg_box( dlg, _("This is a non-valid key.\n" |
rc = msg_box (dlg, _("This is a non-valid key.\n" |
338 |
"Modifying the ownertrust has no effect on such keys.\n\n" |
"Modifying the ownertrust has no effect on such keys.\n\n" |
339 |
"Do you really want to continue?"), |
"Do you really want to continue?"), |
340 |
_("WinPT Warning"), MB_ICONWARNING|MB_YESNO ); |
_("WinPT Warning"), MB_ICONWARNING|MB_YESNO); |
341 |
if (rc == IDNO) |
if (rc == IDNO) |
342 |
return TRUE; |
return TRUE; |
343 |
} |
} |
350 |
break; |
break; |
351 |
} |
} |
352 |
|
|
353 |
inf = ownertrust_to_string (k->callback.new_val); |
inf = ownertrust_to_string (k->callback.new_val, k->key_pair); |
354 |
SetDlgItemText (dlg, IDC_KEYPROPS_OT, inf); |
SetDlgItemText (dlg, IDC_KEYPROPS_OT, inf); |
355 |
msg_box (dlg, _("Ownertrust successfully changed."), |
msg_box (dlg, _("Ownertrust successfully changed."), |
356 |
_("GnuPG Status"), MB_OK); |
_("GnuPG Status"), MB_OK); |
357 |
|
|
358 |
/* XXX: modified ownertrust values can effect the entire |
keycache_update (0, key->subkeys->keyid); |
|
WoT so we reload the cache. But this is very slow. */ |
|
|
memset (&rcs, 0, sizeof (rcs)); |
|
|
rcs.kr_reload = 1; rcs.kr_update = 1; /* reload only keylist */ |
|
|
DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, dlg, |
|
|
keycache_dlg_proc, (LPARAM)&rcs); |
|
359 |
return TRUE; |
return TRUE; |
360 |
|
|
361 |
case IDC_KEYPROPS_CHANGE_PWD: |
case IDC_KEYPROPS_CHANGE_PWD: |