39 |
#include "wptKeyManager.h" |
#include "wptKeyManager.h" |
40 |
#include "wptCard.h" |
#include "wptCard.h" |
41 |
#include "wptCryptdisk.h" |
#include "wptCryptdisk.h" |
42 |
|
#include "wptCardEdit.h" |
43 |
|
|
44 |
extern HWND activ_hwnd; |
extern HWND activ_hwnd; |
45 |
static int cmd = 0; |
static int cmd = 0; |
56 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
57 |
pc = keycache_get_ctx( 1 ); |
pc = keycache_get_ctx( 1 ); |
58 |
while( !gpgme_keycache_next_key( pc, 0, &key ) ) { |
while( !gpgme_keycache_next_key( pc, 0, &key ) ) { |
59 |
if( gpgme_key_get_ulong_attr( key, GPGME_ATTR_ALGO, NULL, 0 ) |
if( key->subkeys->pubkey_algo == GPGME_PK_ELG ) { |
|
== GPGME_PK_ELG_ES ) { |
|
60 |
char tmp[128+64+1]; |
char tmp[128+64+1]; |
61 |
_snprintf( tmp, sizeof (tmp)-1, "(0x%s) %s", |
_snprintf( tmp, sizeof (tmp)-1, "(0x%s) %s", |
62 |
gpgme_key_get_string_attr( key, GPGME_ATTR_KEYID, NULL, 0 )+8, |
key->subkeys->keyid+8, key->uids->uid); |
|
gpgme_key_get_string_attr( key, GPGME_ATTR_USERID, NULL, 0 ) ); |
|
63 |
SendDlgItemMessage( dlg, IDC_ELGWARN_LIST, LB_ADDSTRING, |
SendDlgItemMessage( dlg, IDC_ELGWARN_LIST, LB_ADDSTRING, |
64 |
0, (LPARAM)(const char *) tmp ); |
0, (LPARAM)(const char *) tmp ); |
65 |
} |
} |
66 |
} |
} |
67 |
gpgme_keycache_rewind( pc ); |
gpgme_keycache_rewind( pc ); |
68 |
center_window( dlg ); |
center_window( dlg, NULL ); |
69 |
SetForegroundWindow( dlg ); |
SetForegroundWindow( dlg ); |
70 |
break; |
break; |
71 |
|
|
108 |
{ |
{ |
109 |
switch (msg) { |
switch (msg) { |
110 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
111 |
center_window (dlg); |
center_window (dlg, NULL); |
112 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
113 |
break; |
break; |
114 |
|
|
134 |
} /* confirm_delclipboard_dlg */ |
} /* confirm_delclipboard_dlg */ |
135 |
|
|
136 |
|
|
137 |
static int |
static gpgme_error_t |
138 |
currwnd_gpg_dlg (HWND hwnd, UINT id, int *ret_set) |
currwnd_gpg_dlg (HWND hwnd, UINT id, int *ret_set) |
139 |
{ |
{ |
140 |
gpgme_error_t err; |
gpgme_error_t err; |
141 |
gpgme_pgptype_t type; |
gpgme_pgptype_t type; |
|
int rc = 0; |
|
142 |
|
|
143 |
if( ret_set ) |
if( ret_set ) |
144 |
*ret_set = 1; |
*ret_set = 1; |
171 |
msg_box( hwnd, gpgme_strerror( err ), _("Clipboard"), MB_ERR ); |
msg_box( hwnd, gpgme_strerror( err ), _("Clipboard"), MB_ERR ); |
172 |
break; |
break; |
173 |
} |
} |
174 |
if( (type & GPGME_PGP_MESSAGE) && !(type & GPGME_PGP_CLEARSIG) ) { |
if( (type & PGP_MESSAGE) && !(type & PGP_CLEARSIG) ) { |
175 |
/* It makes only sense to insert the data in the window if it's |
/* It makes only sense to insert the data in the window if it's |
176 |
really a ciphertext. Verfied data doesn't need this. */ |
really a ciphertext. Verfied data doesn't need this. */ |
177 |
rc = clip_decrypt_dlg( hwnd ); |
err = clip_decrypt_dlg (hwnd); |
178 |
if( !rc && reg_prefs.use_viewer ) { |
if (!err && reg_prefs.use_viewer) { |
179 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT, |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT, |
180 |
GetDesktopWindow(), clip_edit_dlg_proc, NULL, |
GetDesktopWindow(), clip_edit_dlg_proc, NULL, |
181 |
_("Clipboard Editor"), IDS_WINPT_CLIPEDIT ); |
_("Clipboard Editor"), IDS_WINPT_CLIPEDIT); |
182 |
if( ret_set ) |
if (ret_set) |
183 |
*ret_set = 0; |
*ret_set = 0; |
184 |
} |
} |
185 |
} |
} |
186 |
else if ((type & GPGME_PGP_PUBKEY) && !(type & GPGME_PGP_CLEARSIG)) |
else if ((type & PGP_PUBKEY) && !(type & PGP_CLEARSIG)) |
187 |
km_clip_import (GetDesktopWindow ()); |
km_clip_import (GetDesktopWindow ()); |
188 |
else { |
else { |
189 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
190 |
clip_verify_dlg_proc, NULL, |
clip_verify_dlg_proc, NULL, |
191 |
_("Verify"), IDS_WINPT_VERIFY ); |
_("Verify"), IDS_WINPT_VERIFY ); |
192 |
rc = 1; |
err = gpg_error (GPG_ERR_EOF); /* make sure window is ot updated. */ |
193 |
} |
} |
194 |
break; |
break; |
195 |
} |
} |
196 |
|
|
197 |
return rc; |
return err; |
198 |
} /* currwnd_gpg_dlg */ |
} /* currwnd_gpg_dlg */ |
199 |
|
|
200 |
|
|
201 |
static void |
static void |
202 |
clip_gpg_dlg( HWND hwnd, UINT id ) |
clip_gpg_dlg( HWND hwnd, UINT id ) |
203 |
{ |
{ |
204 |
gpgme_error_t ec; |
gpgme_error_t err; |
205 |
gpgme_pgptype_t type; |
gpgme_pgptype_t type; |
206 |
size_t size = 0; |
size_t size = 0; |
|
int rc; |
|
207 |
|
|
208 |
if( (id == ID_WINPT_SIGN || id == ID_WINPT_SIGNENCRYPT) |
if( (id == ID_WINPT_SIGN || id == ID_WINPT_SIGNENCRYPT) |
209 |
&& gnupg_access_keyring (0) ) { |
&& gnupg_access_keyring (0) ) { |
235 |
break; |
break; |
236 |
|
|
237 |
case ID_WINPT_DECRYPT_VERIFY: |
case ID_WINPT_DECRYPT_VERIFY: |
238 |
ec = gpgme_clip_get_pgptype( &type ); |
err = gpgme_clip_get_pgptype( &type ); |
239 |
if( ec ) { |
if( err ) { |
240 |
msg_box( hwnd, gpgme_strerror( ec ), _("Clipboard"), MB_ERR ); |
msg_box( hwnd, gpgme_strerror( err ), _("Clipboard"), MB_ERR ); |
241 |
break; |
break; |
242 |
} |
} |
243 |
if( (type & GPGME_PGP_MESSAGE) && !(type & GPGME_PGP_CLEARSIG) ) { |
if( (type & PGP_MESSAGE) && !(type & PGP_CLEARSIG) ) { |
244 |
rc = clip_decrypt_dlg (hwnd); |
err = clip_decrypt_dlg (hwnd); |
245 |
if (!rc && reg_prefs.use_viewer) { |
if (!err && reg_prefs.use_viewer) { |
246 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT, |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT, |
247 |
GetDesktopWindow(), clip_edit_dlg_proc, NULL, |
GetDesktopWindow(), clip_edit_dlg_proc, NULL, |
248 |
_("Clipboard Editor"), IDS_WINPT_CLIPEDIT ); |
_("Clipboard Editor"), IDS_WINPT_CLIPEDIT ); |
249 |
} |
} |
250 |
} |
} |
251 |
else if( (type & GPGME_PGP_SIG) && !(type & GPGME_PGP_CLEARSIG) ) { |
else if( (type & PGP_SIG) && !(type & PGP_CLEARSIG) ) { |
252 |
text_input_s input; |
text_input_s input; |
253 |
gpgme_data_t sig; |
gpgme_data_t sig; |
254 |
|
|
255 |
memset( &input, 0, sizeof (input) ); |
memset( &input, 0, sizeof (input) ); |
256 |
ec = gpgme_data_new_from_clipboard (&sig); |
err = gpg_data_new_from_clipboard (&sig, 0); |
257 |
if( ec ) { |
if( err ) { |
258 |
msg_box( hwnd, gpgme_strerror( ec ),_("Verify"), MB_ERR ); |
msg_box( hwnd, gpgme_strerror( err ),_("Verify"), MB_ERR ); |
259 |
return; |
return; |
260 |
} |
} |
261 |
input.type = 0; |
input.type = 0; |
263 |
text_input_dlg_proc, (LPARAM)&input, |
text_input_dlg_proc, (LPARAM)&input, |
264 |
_("Text Input"), IDS_WINPT_TEXT ); |
_("Text Input"), IDS_WINPT_TEXT ); |
265 |
|
|
266 |
gpgme_data_release_and_set_clipboard( sig ); |
gpg_data_release_and_set_clipboard( sig, 0 ); |
267 |
if( input.length ) { |
if( input.length ) { |
268 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
269 |
clip_verify_dlg_proc, (LPARAM)&input, |
clip_verify_dlg_proc, (LPARAM)&input, |
272 |
free_if_alloc( input.data ); |
free_if_alloc( input.data ); |
273 |
} |
} |
274 |
} |
} |
275 |
else if (type & GPGME_PGP_CLEARSIG) { |
else if (type & PGP_CLEARSIG) { |
276 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
277 |
clip_verify_dlg_proc, NULL, |
clip_verify_dlg_proc, NULL, |
278 |
_("Verify"), IDS_WINPT_VERIFY ); |
_("Verify"), IDS_WINPT_VERIFY ); |
279 |
} |
} |
280 |
else if ((type & GPGME_PGP_PUBKEY) || (type & GPGME_PGP_SECKEY)) |
else if ((type & PGP_PUBKEY) || (type & PGP_SECKEY)) |
281 |
km_clip_import (GetDesktopWindow ()); |
km_clip_import (GetDesktopWindow ()); |
282 |
else |
else |
283 |
msg_box (hwnd, _("Unknown OpenPGP type."), _("Clipboard"), MB_ERR); |
msg_box (hwnd, _("Unknown OpenPGP type."), _("Clipboard"), MB_ERR); |
285 |
} /* clip_gpg_dlg */ |
} /* clip_gpg_dlg */ |
286 |
|
|
287 |
|
|
288 |
gpgme_card_t |
gpg_card_t |
289 |
smartcard_init (void) |
smartcard_init (void) |
290 |
{ |
{ |
291 |
/* |
/* |
309 |
size_t size = 0; |
size_t size = 0; |
310 |
int rc, set_wc = 0, has_data = 0; |
int rc, set_wc = 0, has_data = 0; |
311 |
INITCOMMONCONTROLSEX cce; |
INITCOMMONCONTROLSEX cce; |
312 |
gpgme_error_t ec; |
gpgme_error_t err; |
313 |
gpgme_card_t card; |
gpg_card_t card; |
314 |
|
|
315 |
switch( msg ) { |
switch( msg ) { |
316 |
case WM_CREATE: |
case WM_CREATE: |
366 |
set_clip_text (NULL, " ", 1); |
set_clip_text (NULL, " ", 1); |
367 |
wipe_contents = 0; |
wipe_contents = 0; |
368 |
} |
} |
|
gpgme_lib_cleanup (); |
|
369 |
cleanup_tmp_files (); |
cleanup_tmp_files (); |
370 |
Shell_NotifyIcon (NIM_DELETE, &NID); |
Shell_NotifyIcon (NIM_DELETE, &NID); |
371 |
PostQuitMessage (0); |
PostQuitMessage (0); |
485 |
case ID_WINPT_SIGN: |
case ID_WINPT_SIGN: |
486 |
case ID_WINPT_SIGNENCRYPT: |
case ID_WINPT_SIGNENCRYPT: |
487 |
case ID_WINPT_DECRYPT_VERIFY: |
case ID_WINPT_DECRYPT_VERIFY: |
488 |
ec = gpgme_clip_istext_avail( &has_data ); |
err = gpgme_clip_istext_avail( &has_data ); |
489 |
if( ec ) { |
if( err ) { |
490 |
msg_box( hwnd, gpgme_strerror( ec ),_("Clipboard"), MB_ERR ); |
msg_box( hwnd, gpgme_strerror( err ),_("Clipboard"), MB_ERR ); |
491 |
break; |
break; |
492 |
} |
} |
493 |
if( !has_data ) { |
if( !has_data ) { |
494 |
msg_box( hwnd, gpgme_strerror( GPGME_Clip_Empty ),_("Clipboard"), MB_ERR ); |
msg_box( hwnd, winpt_strerror (WPTERR_CLIP_EMPTY),_("Clipboard"), MB_ERR ); |
495 |
break; |
break; |
496 |
} |
} |
497 |
ctx.msecs = 500; |
ctx.msecs = 500; |
545 |
GetDesktopWindow(), card_edit_dlg_proc, |
GetDesktopWindow(), card_edit_dlg_proc, |
546 |
(LPARAM)card, |
(LPARAM)card, |
547 |
_("Card Edit"), IDS_WINPT_CARD_EDIT ); |
_("Card Edit"), IDS_WINPT_CARD_EDIT ); |
548 |
gpgme_card_release( card ); card = NULL; |
gpg_card_release( card ); card = NULL; |
549 |
} |
} |
550 |
break; |
break; |
551 |
|
|