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