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 |
* |
* |
6 |
* WinPT is free software; you can redistribute it and/or modify |
* WinPT is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
* (at your option) any later version. |
10 |
* |
* |
11 |
* WinPT is distributed in the hope that it will be useful, |
* WinPT is distributed in the hope that it will be useful, |
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. |
15 |
* |
* |
16 |
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
17 |
* along with WinPT; if not, write to the Free Software Foundation, |
* along with WinPT; if not, write to the Free Software Foundation, |
18 |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
*/ |
*/ |
20 |
|
#ifdef HAVE_CONFIG_H |
21 |
#include <windows.h> |
#include <config.h> |
22 |
|
#endif |
23 |
#include "../resource.h" |
|
24 |
#include "wptErrors.h" |
#include <windows.h> |
25 |
#include "wptGPG.h" |
|
26 |
#include "wptCommonCtl.h" |
#include "resource.h" |
27 |
#include "wptContext.h" /* for passphrase_s */ |
#include "wptErrors.h" |
28 |
#include "wptNLS.h" |
#include "wptGPG.h" |
29 |
#include "wptDlgs.h" |
#include "wptCommonCtl.h" |
30 |
#include "wptTypes.h" |
#include "wptContext.h" /* for passphrase_s */ |
31 |
#include "wptKeylist.h" |
#include "wptNLS.h" |
32 |
#include "wptW32API.h" |
#include "wptDlgs.h" |
33 |
#include "wptVersion.h" |
#include "wptTypes.h" |
34 |
#include "wptKeyEdit.h" |
#include "wptKeylist.h" |
35 |
|
#include "wptW32API.h" |
36 |
int keyedit_ownertrust_get_val (void); |
#include "wptVersion.h" |
37 |
|
#include "wptKeyEdit.h" |
38 |
|
|
39 |
static void |
|
40 |
do_change_ownertrust (winpt_key_t k, const char *s) |
/* Check that the key is not expired or revoked. */ |
41 |
{ |
static int |
42 |
char ot[64]; |
do_check_key (gpgme_key_t key) |
43 |
|
{ |
44 |
if( strstr( s, "ultimate" ) ) { |
int okay = 0; |
45 |
listview_get_item_text (k->callback.ctl, k->callback.idx, 5, ot, DIM (ot)-1); |
okay = key->expired; |
46 |
strcpy (ot, "Ultimate"); |
if (!okay) |
47 |
listview_add_sub_item (k->callback.ctl, k->callback.idx, 5, ot); |
okay = key->revoked; |
48 |
/* fixme: If we switch back from Ultimate to a lower level */ |
return okay; |
49 |
} |
} |
50 |
} /* do_change_ownertrust */ |
|
51 |
|
|
52 |
|
/* Convert a trust integer into a string representation. */ |
53 |
static int |
static const char* |
54 |
do_check_key (gpgme_key_t key) |
ownertrust_to_string (int val, bool is_keypair) |
55 |
{ |
{ |
56 |
int okay = 0; |
const char *inf; |
57 |
okay = gpgme_key_get_ulong_attr (key, GPGME_ATTR_KEY_EXPIRED, NULL, 0); |
int id = val; |
58 |
if (!okay) |
|
59 |
okay = gpgme_key_get_ulong_attr (key, GPGME_ATTR_KEY_REVOKED, NULL, 0); |
switch (id) { |
60 |
return okay; |
case 1: inf = _("Don't know"); break; |
61 |
} /* do_check_key */ |
case 2: inf = _("I do NOT trust"); break; |
62 |
|
case 3: inf = _("I trust marginally"); break; |
63 |
|
case 4: inf = _("I trust fully"); break; |
64 |
static const char* |
case 5: |
65 |
ownertrust_to_string (gpgme_editkey_t ctx, int val) |
case 6: |
66 |
{ |
if (is_keypair) |
67 |
const char * inf; |
inf = _("I trust ultimately (implicit)"); |
68 |
int id; |
else |
69 |
|
inf = _("I trust ultimately"); break; |
70 |
if (ctx) |
default:inf = _("Unknown"); break; |
71 |
id = keyedit_ownertrust_get_val (); |
} |
72 |
else if (!ctx && val) |
|
73 |
id = val; |
return inf; |
74 |
switch (id) { |
} |
75 |
case 1: inf = _("Don't know"); break; |
|
76 |
case 2: inf = _("I do NOT trust"); break; |
|
77 |
case 3: inf = _("I trust marginally"); break; |
/* Generate a unique temp name for the photo which |
78 |
case 4: inf = _("I trust fully"); break; |
depends on the dialog handle and return it. */ |
79 |
case 5: |
static const char* |
80 |
case 6: inf = _("I trust ultimately"); break; |
get_photo_tmpname (HWND dlg) |
81 |
default:inf = _("Unknown"); break; |
{ |
82 |
} |
static char buf[64]; |
83 |
|
|
84 |
return inf; |
_snprintf (buf, sizeof (buf)-1, "winpt_photo_%08lX.tmp", (DWORD)dlg); |
85 |
} /* ownertrust_to_string */ |
return buf; |
86 |
|
} |
87 |
|
|
88 |
#define PHOTO_TMPNAME "winpt_temp_photo.jpg" |
|
89 |
|
static void |
90 |
static int |
draw_nophoto_img (HWND dlg) |
91 |
keyprops_show_photo (HWND dlg, gpgme_key_t key) |
{ |
92 |
{ |
/*.. |
93 |
RECT r; |
n = DrawText (hdc, "No Photo-ID", -1, &r, DT_LEFT); |
94 |
POINT p; |
..*/ |
95 |
HWND h; |
} |
96 |
const BYTE *img; |
|
97 |
DWORD imglen = 0; |
|
98 |
int pos=0; |
/* Load the photo from the key @key */ |
99 |
|
static int |
100 |
img = (const byte *)gpgme_key_get_string_attr (key, GPGME_ATTR_PHOTO, |
keyprops_load_photo (HWND dlg, gpgme_key_t key, gpgme_validity_t *r_valid) |
101 |
(void **)&imglen, 0); |
{ |
102 |
if (!img || !imglen) |
winpt_key_s k; |
103 |
return -1; |
FILE *f; |
104 |
FILE *f = fopen (PHOTO_TMPNAME, "wb"); |
const BYTE *img; |
105 |
if (f) { |
DWORD imglen = 0; |
106 |
for (pos = 0; img[pos] != 0x10; pos++) |
int pos=0; |
107 |
; |
|
108 |
pos += 16; |
winpt_get_pubkey (key->subkeys->keyid, &k); |
109 |
fwrite (img + pos, 1, imglen - pos, f); |
img = k.ext->attrib.d; |
110 |
fwrite (img, 1, imglen, f); |
imglen = k.ext->attrib.len; |
111 |
fclose (f); |
if (!k.ext->attrib.validity) |
112 |
} |
get_uat_validity (key->subkeys->keyid, &k.ext->attrib.validity); |
113 |
|
*r_valid = k.ext->attrib.validity; |
114 |
h = GetDlgItem (dlg, IDC_KEYPROPS_IMG); |
|
115 |
GetWindowRect (h, &r); |
if (!img || !imglen) { |
116 |
p.x = r.left + 5; |
draw_nophoto_img (dlg); |
117 |
p.y = r.top - 2; |
return -1; |
118 |
memset (&p, 0, sizeof (p)); |
} |
119 |
PTD_jpg_show (h, &p, PHOTO_TMPNAME); |
|
120 |
unlink (PHOTO_TMPNAME); |
f = fopen (get_photo_tmpname (dlg), "wb"); |
121 |
|
if (f) { |
122 |
return 0; |
//for (pos = 0; img[pos] != 0x10; pos++) |
123 |
} |
// ; |
124 |
|
pos += 16; |
125 |
|
fwrite (img + pos, 1, imglen - pos, f); |
126 |
static const char* |
fclose (f); |
127 |
get_validity (gpgme_key_t key) |
} |
128 |
{ |
return 0; |
129 |
int val; |
} |
130 |
val = gpgme_key_get_ulong_attr (key, GPGME_ATTR_KEY_EXPIRED, NULL, 0); |
|
131 |
if (val) |
|
132 |
return "Expired"; |
/* Display the photo in the image control in the dialog @dlg. */ |
133 |
val = gpgme_key_get_ulong_attr( key, GPGME_ATTR_KEY_REVOKED, NULL, 0 ); |
static int |
134 |
if (val) |
keyprops_show_photo (HWND dlg) |
135 |
return "Revoked"; |
{ |
136 |
val = gpgme_key_get_ulong_attr (key, GPGME_ATTR_VALIDITY, NULL, 0); |
RECT r; |
137 |
return gpgme_key_expand_attr (GPGME_ATTR_VALIDITY, val); |
POINT p; |
138 |
} |
HWND h; |
139 |
|
|
140 |
|
h = GetDlgItem (dlg, IDC_KEYPROPS_IMG); |
141 |
BOOL CALLBACK |
GetWindowRect (h, &r); |
142 |
keyprops_dlg_proc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam ) |
p.x = r.left + 5; |
143 |
{ |
p.y = r.top - 2; |
144 |
static winpt_key_t k; |
memset (&p, 0, sizeof (p)); |
145 |
static gpgme_key_t key, sk; |
PTD_jpg_show (h, &p, get_photo_tmpname (dlg)); |
146 |
static int photo_done = 0; |
|
147 |
gpgme_editkey_t ek; |
return 0; |
148 |
gpgme_ctx_t ctx; |
} |
149 |
gpgme_error_t ec; |
|
150 |
refresh_cache_s rcs = {0}; |
|
151 |
const char *inf; |
/* Return string representation of the key validity. @key. */ |
152 |
const char * sym_prefs; |
static const char* |
153 |
char info[2048], dummy_symprefs[] = {0x01, 0x00}; |
get_validity (gpgme_key_t key) |
154 |
u32 created, expires; |
{ |
155 |
int ot, cancel = 0; |
int val; |
156 |
int rc; |
val = key->expired; |
157 |
|
if (val) |
158 |
switch (msg) { |
return _("Expired"); |
159 |
case WM_INITDIALOG: |
val = key->revoked; |
160 |
if (!lparam) |
if (val) |
161 |
dlg_fatal_error( dlg, "Could not get dialog param!" ); |
return _("Revoked"); |
162 |
k = (winpt_key_t)lparam; |
val = key->disabled; |
163 |
#ifndef LANG_DE |
if (val) |
164 |
SetWindowText( dlg, _("Key Properties") ); |
return _("Disabled"); |
165 |
SetDlgItemText (dlg, IDC_KEYPROPS_OT_CHANGE, _("&Change")); |
return get_key_trust2 (NULL, key->uids->validity, 0, 0); |
166 |
SetDlgItemText (dlg, IDC_KEYPROPS_REVOKERS, _("&Revokers")); |
} |
167 |
SetDlgItemText (dlg, IDC_KEYPROPS_CHANGE_PWD, _("Change &Passwd")); |
|
168 |
#endif |
|
169 |
|
/* Return the preferred sym. algorithm from @key as a string. */ |
170 |
photo_done = 0; |
static const char* |
171 |
get_seckey (k->keyid, &sk); |
get_pref_cipher (winpt_key_t k) |
172 |
if (sk) |
{ |
173 |
k->is_protected = gpgme_key_get_ulong_attr( sk, GPGME_ATTR_IS_PROTECTED, NULL, 0 ); |
if (k->is_v3) |
174 |
if (get_pubkey (k->keyid, &key)) |
return "IDEA"; |
175 |
BUG (0); |
if (!k->ext->sym_prefs) |
176 |
created = gpgme_key_get_ulong_attr( key, GPGME_ATTR_CREATED, NULL, 0 ); |
return "3DES"; |
177 |
expires = gpgme_key_get_ulong_attr( key, GPGME_ATTR_EXPIRES, NULL, 0 ); |
switch (*k->ext->sym_prefs) { |
178 |
sym_prefs = gpgme_key_get_string_attr( key, GPGME_ATTR_KEY_SYMPREFS, NULL, 0 ); |
case 1: return "IDEA"; |
179 |
if (!sym_prefs) |
case 2: return "3DES"; |
180 |
sym_prefs = dummy_symprefs; |
case 3: return "CAST5"; |
181 |
_snprintf (info, sizeof info -1, |
case 4: return "Blowfish"; |
182 |
"Type: %s\r\n" |
case 7: |
183 |
"Key ID: %s\r\n" |
case 8: |
184 |
"Algorithm: %s\r\n" |
case 9: return "AES"; |
185 |
"Size: %s\r\n" |
case 10:return "Twofish"; |
186 |
"Created: %s\r\n" |
} |
187 |
"Expires: %s\r\n" |
return "Unknown"; |
188 |
"Validity: %s\r\n" |
} |
189 |
"Cipher: %s\r\n", |
|
190 |
get_key_type( key ), |
|
191 |
k->keyid, |
/* Return true if the key has designated revokers. */ |
192 |
get_key_algo( key, 0 ), |
static bool |
193 |
get_key_size( key, 0 ), |
check_for_desig_rev (gpgme_key_t key) |
194 |
get_key_created( created ), |
{ |
195 |
get_key_expire_date( expires ), |
winpt_key_s k; |
196 |
get_validity (key), |
memset (&k, 0, sizeof (k)); |
197 |
gpgme_key_expand_attr( GPGME_ATTR_KEY_SYMPREFS, *sym_prefs ) ); |
if (!winpt_get_pubkey (key->subkeys->keyid, &k)) |
198 |
SetDlgItemText( dlg, IDC_KEYPROPS_INFO, info ); |
return k.ext->gloflags.has_desig_rev? true : false; |
199 |
SetDlgItemText( dlg, IDC_KEYPROPS_FPR, get_key_fpr( key ) ); |
return false; |
200 |
ot = gpgme_key_get_ulong_attr( key, GPGME_ATTR_OTRUST, NULL, 0 ); |
} |
201 |
inf = ownertrust_to_string( NULL, ot ); |
|
202 |
SetDlgItemText( dlg, IDC_KEYPROPS_OT, inf ); |
|
203 |
if( k->key_pair ) |
/* Print information (name) of the smart card. */ |
204 |
EnableWindow( GetDlgItem( dlg, IDC_KEYPROPS_CHANGE_PWD ), TRUE ); |
static const char* |
205 |
if( gpgme_key_count_items( key, GPGME_ATTR_REVKEY_FPR ) ) |
get_card_type (winpt_key_t k) |
206 |
EnableWindow( GetDlgItem( dlg, IDC_KEYPROPS_REVOKERS ), TRUE ); |
{ |
207 |
center_window (dlg); |
static char buf[64]; |
208 |
SetForegroundWindow (dlg); |
|
209 |
return TRUE; |
if (!k->ext->card_type) |
210 |
|
return ""; |
211 |
case WM_PAINT: |
_snprintf (buf, sizeof (buf)-1, _("Card-Type: %s\r\n"), k->ext->card_type); |
212 |
if (photo_done == 0) { |
return buf; |
213 |
photo_done = 1; |
} |
214 |
keyprops_show_photo (dlg, key); |
|
215 |
} |
|
216 |
break; |
/* Display the key information for key @k. |
217 |
|
Return value: gpgme key on success. */ |
218 |
case WM_SYSCOMMAND: |
static void |
219 |
if( LOWORD( wparam ) == SC_CLOSE ) |
display_key_info (HWND dlg, winpt_key_t k, gpgme_key_t *r_key) |
220 |
EndDialog( dlg, TRUE ); |
{ |
221 |
return FALSE; |
struct winpt_key_s k2; |
222 |
|
gpgme_key_t sk, key; |
223 |
case WM_COMMAND: |
char info[512]; |
224 |
switch( LOWORD( wparam ) ) { |
const char *inf; |
225 |
case IDOK: |
u32 created, expires; |
226 |
EndDialog( dlg, TRUE ); |
|
227 |
return TRUE; |
memset (&k2, 0, sizeof (k2)); |
228 |
|
if (k->key_pair) |
229 |
case IDC_KEYPROPS_OT_CHANGE: |
winpt_get_seckey (k->keyid, &k2); |
230 |
if( do_check_key( key ) ) { |
else |
231 |
msg_box( dlg, _("The status of this key is 'revoked' or 'expired'.\n" |
winpt_get_pubkey (k->keyid, &k2); |
232 |
"You cannot change the ownertrust of such keys."), |
sk = k2.ctx; |
233 |
_("WinPT Warning"), MB_ERR ); |
if (sk) |
234 |
return FALSE; |
k->is_protected = k2.is_protected; |
235 |
} |
if (get_pubkey (k->keyid, &key)) |
236 |
if( !k->key_pair && gpgme_key_get_ulong_attr( key, GPGME_ATTR_VALIDITY, NULL, 0 ) < 3 ) { |
BUG (0); |
237 |
rc = msg_box( dlg, _("This is a non-valid key.\n" |
created = key->subkeys->timestamp; |
238 |
"Modifying the ownertrust has no effect on such keys.\n" |
expires = key->subkeys->expires; |
239 |
"Do you really want to continue?"), |
_snprintf (info, DIM (info)-1, |
240 |
_("WinPT Warning"), MB_ICONWARNING|MB_YESNO ); |
_("Type: %s\r\n" |
241 |
if (rc == IDNO) |
"Key ID: %s\r\n" |
242 |
return FALSE; |
"Algorithm: %s\r\n" |
243 |
} |
"Size: %s bits\r\n" |
244 |
GetDlgItemText( dlg, IDC_KEYPROPS_OT, info, sizeof info -1 ); |
"Created: %s\r\n" |
245 |
gpgme_editkey_new( &ek ); |
"Expires: %s\r\n" |
246 |
gpgme_editkey_is_secret( ek, k->key_pair ); |
"Validity: %s\r\n" |
247 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYEDIT_OWNERTRUST, |
"Cipher: %s\r\n" |
248 |
dlg, (DLGPROC)keyedit_ownertrust_dlg_proc, |
"%s\r\n"), |
249 |
(LPARAM)ek, _("Change Ownertrust"), |
get_key_type (key), |
250 |
IDS_WINPT_KEYEDIT_OWNERTRUST ); |
k->keyid, |
251 |
if (!gpgme_editkey_is_valid (ek)) |
get_key_algo (key, 0), |
252 |
return FALSE; |
get_key_size (key, 0), |
253 |
ec = gpgme_new (&ctx); |
get_key_created (created), |
254 |
if (ec) |
get_key_expire_date (expires), |
255 |
BUG (0); |
get_validity (key), |
256 |
gpgme_set_edit_ctx( ctx, ek, GPGME_EDITKEY_TRUST ); |
get_pref_cipher (&k2), |
257 |
ec = gpgme_op_editkey( ctx, k->keyid ); |
get_card_type (&k2)); |
258 |
gpgme_editkey_release( ek ); |
|
259 |
gpgme_release( ctx ); |
SetDlgItemText (dlg, IDC_KEYPROPS_INFO, info); |
260 |
if( ec ) { |
SetDlgItemText (dlg, IDC_KEYPROPS_FPR, get_key_fpr (key)); |
261 |
msg_box( dlg, gpgme_strerror( ec ), _("Ownertrust"), MB_ERR ); |
inf = ownertrust_to_string (key->owner_trust, k->key_pair); |
262 |
return FALSE; |
SetDlgItemText (dlg, IDC_KEYPROPS_OT, inf); |
263 |
} |
|
264 |
inf = ownertrust_to_string (ek, 0); |
*r_key = key; |
265 |
k->callback.new_val = keyedit_ownertrust_get_val (); |
} |
266 |
do_change_ownertrust (k, inf); |
|
267 |
SetDlgItemText (dlg, IDC_KEYPROPS_OT, inf); |
|
268 |
msg_box (dlg, _("Ownertrust successfully changed."), _("GnuPG Status"), MB_OK); |
/* Dialog box procedure to show the key properties. */ |
269 |
|
BOOL CALLBACK |
270 |
/* reload only the keylist */ |
keyprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
271 |
rcs.kr_reload = 1; rcs.kr_update = 1; |
{ |
272 |
rcs.tr_update = 0; |
static winpt_key_t k; |
273 |
DialogBoxParam( glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, dlg, |
static gpgme_key_t key; |
274 |
keycache_dlg_proc, (LPARAM)&rcs ); |
gpgme_validity_t valid; |
275 |
get_seckey (k->keyid, &sk); |
refresh_cache_s rcs = {0}; |
276 |
if (get_pubkey (k->keyid, &key)) |
const char *inf; |
277 |
BUG (0); |
int cancel = 0; |
278 |
return TRUE; |
int rc; |
279 |
|
|
280 |
case IDC_KEYPROPS_CHANGE_PWD: |
/* XXX: static variable (k) prevent that the dialog can |
281 |
keyedit_change_passwd (k, dlg); |
be opened twice. */ |
282 |
return TRUE; |
switch (msg) { |
283 |
|
case WM_INITDIALOG: |
284 |
case IDC_KEYPROPS_REVOKERS: |
if (!lparam) |
285 |
dialog_box_param( glob_hinst, (LPCTSTR)IDD_WINPT_KEYREVOKERS, dlg, |
dlg_fatal_error (dlg, "Could not get dialog param!"); |
286 |
key_revokers_dlg_proc, (LPARAM)key, _("Key Revokers"), |
k = (winpt_key_t)lparam; |
287 |
IDS_WINPT_KEY_REVOKERS ); |
SetWindowText (dlg, _("Key Properties")); |
288 |
break; |
SetDlgItemText (dlg, IDC_KEYPROPS_OT_CHANGE, _("&Change")); |
289 |
} |
SetDlgItemText (dlg, IDC_KEYPROPS_REVOKERS, _("&Revokers")); |
290 |
} |
SetDlgItemText (dlg, IDC_KEYPROPS_CHANGE_PWD, _("Change &Password")); |
291 |
|
SetDlgItemText (dlg, IDC_KEYPROPS_OTINF, _("Ownertrust")); |
292 |
return FALSE; |
|
293 |
} /* keyprops_dlg_proc */ |
display_key_info (dlg, k, &key); |
294 |
|
if (!keyprops_load_photo (dlg, key, &valid)) { |
295 |
|
k->has_photo = 1; |
296 |
|
if (valid < GPGME_VALIDITY_MARGINAL) |
297 |
|
SetDlgItemText (dlg, IDC_KEYPROPS_IMGINF, _("Photo-ID not validated.")); |
298 |
|
} |
299 |
|
if (k->key_pair) |
300 |
|
EnableWindow (GetDlgItem (dlg, IDC_KEYPROPS_CHANGE_PWD), TRUE); |
301 |
|
if (check_for_desig_rev (key)) |
302 |
|
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); |
306 |
|
SetForegroundWindow (dlg); |
307 |
|
return TRUE; |
308 |
|
|
309 |
|
case WM_DESTROY: |
310 |
|
remove (get_photo_tmpname (dlg)); |
311 |
|
break; |
312 |
|
|
313 |
|
case WM_PAINT: |
314 |
|
if (k->has_photo) |
315 |
|
keyprops_show_photo (dlg); |
316 |
|
break; |
317 |
|
|
318 |
|
case WM_SYSCOMMAND: |
319 |
|
if (LOWORD (wparam) == SC_CLOSE) |
320 |
|
EndDialog (dlg, TRUE); |
321 |
|
return FALSE; |
322 |
|
|
323 |
|
case WM_COMMAND: |
324 |
|
switch (LOWORD (wparam)) { |
325 |
|
case IDOK: |
326 |
|
EndDialog (dlg, TRUE); |
327 |
|
return TRUE; |
328 |
|
|
329 |
|
case IDC_KEYPROPS_OT_CHANGE: |
330 |
|
if (do_check_key (key)) { |
331 |
|
msg_box (dlg, _("The status of this key is 'revoked' or 'expired'.\n" |
332 |
|
"You cannot change the ownertrust of such keys."), |
333 |
|
_("WinPT Warning"), MB_ERR); |
334 |
|
return TRUE; |
335 |
|
} |
336 |
|
if (!k->key_pair && key->uids->validity < 3) { |
337 |
|
rc = msg_box (dlg, _("This is a non-valid key.\n" |
338 |
|
"Modifying the ownertrust has no effect on such keys.\n\n" |
339 |
|
"Do you really want to continue?"), |
340 |
|
_("WinPT Warning"), MB_ICONWARNING|MB_YESNO); |
341 |
|
if (rc == IDNO) |
342 |
|
return TRUE; |
343 |
|
} |
344 |
|
rc = dialog_box_param (glob_hinst, |
345 |
|
(LPCSTR)IDD_WINPT_KEYEDIT_OWNERTRUST, |
346 |
|
dlg, keyedit_ownertrust_dlg_proc, |
347 |
|
(LPARAM)k, _("Change Ownertrust"), |
348 |
|
IDS_WINPT_KEYEDIT_OWNERTRUST); |
349 |
|
if (rc == FALSE) /* Cancel */ |
350 |
|
return TRUE; |
351 |
|
|
352 |
|
inf = ownertrust_to_string (k->callback.new_val, k->key_pair); |
353 |
|
SetDlgItemText (dlg, IDC_KEYPROPS_OT, inf); |
354 |
|
msg_box (dlg, _("Ownertrust successfully changed."), |
355 |
|
_("GnuPG Status"), MB_OK); |
356 |
|
k->update = 1; |
357 |
|
return TRUE; |
358 |
|
|
359 |
|
case IDC_KEYPROPS_CHANGE_PWD: |
360 |
|
keyedit_change_passwd (k, dlg); |
361 |
|
return TRUE; |
362 |
|
|
363 |
|
case IDC_KEYPROPS_REVOKERS: |
364 |
|
k->update = dialog_box_param ( |
365 |
|
glob_hinst, (LPCTSTR)IDD_WINPT_KEYREVOKERS, dlg, |
366 |
|
key_revokers_dlg_proc, (LPARAM)key, |
367 |
|
_("Key Revokers"), IDS_WINPT_KEY_REVOKERS); |
368 |
|
break; |
369 |
|
} |
370 |
|
} |
371 |
|
|
372 |
|
return FALSE; |
373 |
|
} |