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