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