1 |
/* wptMainProc.cpp - Main window procedure |
2 |
* Copyright (C) 2000-2005 Timo Schulz |
3 |
* |
4 |
* This file is part of WinPT. |
5 |
* |
6 |
* 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 |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* WinPT is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with WinPT; if not, write to the Free Software Foundation, |
18 |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
*/ |
20 |
|
21 |
#include <windows.h> |
22 |
#include <commctrl.h> |
23 |
#include <io.h> |
24 |
|
25 |
#include "../resource.h" |
26 |
#include "wptTypes.h" |
27 |
#include "wptGPG.h" |
28 |
#include "wptW32API.h" |
29 |
#include "wptVersion.h" |
30 |
#include "wptCommonCtl.h" |
31 |
#include "wptContext.h" /* for passphrase_s */ |
32 |
#include "wptDlgs.h" |
33 |
#include "wptErrors.h" |
34 |
#include "wptNLS.h" |
35 |
#include "wptHotkey.h" |
36 |
#include "wptRegistry.h" |
37 |
#include "wptKeyserver.h" |
38 |
#include "wptAgent.h" |
39 |
#include "wptKeyManager.h" |
40 |
#include "wptCard.h" |
41 |
#include "wptCryptdisk.h" |
42 |
|
43 |
extern HWND activ_hwnd; |
44 |
static int cmd = 0; |
45 |
static int wipe_contents = 0; |
46 |
|
47 |
|
48 |
BOOL CALLBACK |
49 |
elgamal_warn_dlg_proc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam ) |
50 |
{ |
51 |
gpgme_keycache_t pc; |
52 |
gpgme_key_t key; |
53 |
|
54 |
switch( msg ) { |
55 |
case WM_INITDIALOG: |
56 |
pc = keycache_get_ctx( 1 ); |
57 |
while( !gpgme_keycache_next_key( pc, 0, &key ) ) { |
58 |
if( gpgme_key_get_ulong_attr( key, GPGME_ATTR_ALGO, NULL, 0 ) |
59 |
== GPGME_PK_ELG_ES ) { |
60 |
char tmp[128+64+1]; |
61 |
_snprintf( tmp, sizeof (tmp)-1, "(0x%s) %s", |
62 |
gpgme_key_get_string_attr( key, GPGME_ATTR_KEYID, NULL, 0 )+8, |
63 |
gpgme_key_get_string_attr( key, GPGME_ATTR_USERID, NULL, 0 ) ); |
64 |
SendDlgItemMessage( dlg, IDC_ELGWARN_LIST, LB_ADDSTRING, |
65 |
0, (LPARAM)(const char *) tmp ); |
66 |
} |
67 |
} |
68 |
gpgme_keycache_rewind( pc ); |
69 |
center_window( dlg ); |
70 |
SetForegroundWindow( dlg ); |
71 |
break; |
72 |
|
73 |
case WM_COMMAND: |
74 |
switch( LOWORD( wparam ) ) { |
75 |
case IDOK: |
76 |
EndDialog( dlg, TRUE ); |
77 |
break; |
78 |
} |
79 |
break; |
80 |
} |
81 |
return FALSE; |
82 |
} /* elgamal_warn_dlg_proc */ |
83 |
|
84 |
|
85 |
static void |
86 |
cleanup_tmp_files (void) |
87 |
{ |
88 |
struct _finddata_t dat; |
89 |
char tmp[384]; |
90 |
long hd; |
91 |
|
92 |
if (GetTempPath (sizeof (tmp)-1, tmp) == FALSE || |
93 |
SetCurrentDirectory (tmp) == FALSE) { |
94 |
winpt_errmsg ("GetTempPath", 0); |
95 |
return; |
96 |
} |
97 |
hd = _findfirst ("gpgmeOUT*", &dat); |
98 |
if (hd == -1) |
99 |
return; |
100 |
do { |
101 |
secure_unlink (dat.name, WIPE_MODE_SIMPLE); |
102 |
} while (_findnext (hd, &dat) == 0); |
103 |
_findclose (hd); |
104 |
} |
105 |
|
106 |
|
107 |
static BOOL CALLBACK |
108 |
confirm_delclipboard_dlg (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
109 |
{ |
110 |
switch (msg) { |
111 |
case WM_INITDIALOG: |
112 |
center_window (dlg); |
113 |
SetForegroundWindow (dlg); |
114 |
break; |
115 |
|
116 |
case WM_COMMAND: |
117 |
switch (LOWORD (wparam)) { |
118 |
case IDYES: |
119 |
wipe_contents = 1; |
120 |
if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN)) |
121 |
set_reg_winpt_flag ("WipeClipboard", 1); |
122 |
EndDialog (dlg, TRUE); |
123 |
break; |
124 |
|
125 |
case IDNO: |
126 |
wipe_contents = 0; |
127 |
if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN)) |
128 |
set_reg_winpt_flag ("WipeClipboard", 0); |
129 |
EndDialog (dlg, FALSE); |
130 |
break; |
131 |
} |
132 |
break; |
133 |
} |
134 |
return FALSE; |
135 |
} /* confirm_delclipboard_dlg */ |
136 |
|
137 |
|
138 |
static int |
139 |
currwnd_gpg_dlg (HWND hwnd, UINT id, int *ret_set) |
140 |
{ |
141 |
gpgme_error_t err; |
142 |
gpgme_pgptype_t type; |
143 |
int rc = 0; |
144 |
|
145 |
if( ret_set ) |
146 |
*ret_set = 1; |
147 |
switch( id ) { |
148 |
case ID_WINPT_CURRWND_SYMENC: |
149 |
gpgme_encrypt_symmetric (); |
150 |
break; |
151 |
|
152 |
case ID_WINPT_CURRWND_ENCRYPT: |
153 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd, |
154 |
clip_encrypt_dlg_proc, NULL, |
155 |
_("Encryption"), IDS_WINPT_ENCRYPT ); |
156 |
break; |
157 |
|
158 |
case ID_WINPT_CURRWND_SIGNENCRYPT: |
159 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd, |
160 |
clip_signenc_dlg_proc, NULL, |
161 |
_("Sign & Encrypt"), IDS_WINPT_SIGNENC ); |
162 |
break; |
163 |
|
164 |
case ID_WINPT_CURRWND_SIGN: |
165 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd, |
166 |
clip_sign_dlg_proc, NULL, |
167 |
_("Signing"), IDS_WINPT_SIGN ); |
168 |
break; |
169 |
|
170 |
case ID_WINPT_CURRWND_DECRYPT_VERIFY: |
171 |
err = gpgme_clip_get_pgptype( &type ); |
172 |
if( err ) { |
173 |
msg_box( hwnd, gpgme_strerror( err ), _("Clipboard"), MB_ERR ); |
174 |
break; |
175 |
} |
176 |
if( (type & GPGME_PGP_MESSAGE) && !(type & GPGME_PGP_CLEARSIG) ) { |
177 |
/* It makes only sense to insert the data in the window if it's |
178 |
really a ciphertext. Verfied data doesn't need this. */ |
179 |
rc = clip_decrypt_dlg( hwnd ); |
180 |
if( !rc && reg_prefs.use_viewer ) { |
181 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT, |
182 |
GetDesktopWindow(), clip_edit_dlg_proc, NULL, |
183 |
_("Clipboard Editor"), IDS_WINPT_CLIPEDIT ); |
184 |
if( ret_set ) |
185 |
*ret_set = 0; |
186 |
} |
187 |
} |
188 |
else if ((type & GPGME_PGP_PUBKEY) && !(type & GPGME_PGP_CLEARSIG)) |
189 |
km_clip_import (GetDesktopWindow ()); |
190 |
else { |
191 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
192 |
clip_verify_dlg_proc, NULL, |
193 |
_("Verify"), IDS_WINPT_VERIFY ); |
194 |
rc = 1; |
195 |
} |
196 |
break; |
197 |
} |
198 |
|
199 |
return rc; |
200 |
} /* currwnd_gpg_dlg */ |
201 |
|
202 |
|
203 |
static void |
204 |
clip_gpg_dlg( HWND hwnd, UINT id ) |
205 |
{ |
206 |
gpgme_error_t ec; |
207 |
gpgme_pgptype_t type; |
208 |
size_t size = 0; |
209 |
int rc; |
210 |
|
211 |
if( (id == ID_WINPT_SIGN || id == ID_WINPT_SIGNENCRYPT) |
212 |
&& gnupg_access_keyring (0) ) { |
213 |
msg_box( hwnd, _("Could not access secret keyring."), _("Sign"), MB_ERR ); |
214 |
return; |
215 |
} |
216 |
|
217 |
switch( id ) { |
218 |
case ID_WINPT_SYMENC: |
219 |
gpgme_encrypt_symmetric(); |
220 |
break; |
221 |
|
222 |
case ID_WINPT_ENCRYPT: |
223 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd, |
224 |
clip_encrypt_dlg_proc, NULL, |
225 |
_("Encryption"), IDS_WINPT_ENCRYPT ); |
226 |
break; |
227 |
|
228 |
case ID_WINPT_SIGN: |
229 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd, |
230 |
clip_sign_dlg_proc, NULL, |
231 |
_("Signing"), IDS_WINPT_SIGN ); |
232 |
break; |
233 |
|
234 |
case ID_WINPT_SIGNENCRYPT: |
235 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd, |
236 |
clip_signenc_dlg_proc, NULL, |
237 |
_("Sign & Encrypt"), IDS_WINPT_SIGNENC ); |
238 |
break; |
239 |
|
240 |
case ID_WINPT_DECRYPT_VERIFY: |
241 |
ec = gpgme_clip_get_pgptype( &type ); |
242 |
if( ec ) { |
243 |
msg_box( hwnd, gpgme_strerror( ec ), _("Clipboard"), MB_ERR ); |
244 |
break; |
245 |
} |
246 |
if( (type & GPGME_PGP_MESSAGE) && !(type & GPGME_PGP_CLEARSIG) ) { |
247 |
rc = clip_decrypt_dlg (hwnd); |
248 |
if (!rc && reg_prefs.use_viewer) { |
249 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT, |
250 |
GetDesktopWindow(), clip_edit_dlg_proc, NULL, |
251 |
_("Clipboard Editor"), IDS_WINPT_CLIPEDIT ); |
252 |
} |
253 |
} |
254 |
else if( (type & GPGME_PGP_SIG) && !(type & GPGME_PGP_CLEARSIG) ) { |
255 |
text_input_s input; |
256 |
gpgme_data_t sig; |
257 |
|
258 |
memset( &input, 0, sizeof (input) ); |
259 |
ec = gpgme_data_new_from_clipboard (&sig); |
260 |
if( ec ) { |
261 |
msg_box( hwnd, gpgme_strerror( ec ),_("Verify"), MB_ERR ); |
262 |
return; |
263 |
} |
264 |
input.type = 0; |
265 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_TEXT, hwnd, |
266 |
text_input_dlg_proc, (LPARAM)&input, |
267 |
_("Text Input"), IDS_WINPT_TEXT ); |
268 |
|
269 |
gpgme_data_release_and_set_clipboard( sig ); |
270 |
if( input.length ) { |
271 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
272 |
clip_verify_dlg_proc, (LPARAM)&input, |
273 |
_("Verify"), IDS_WINPT_VERIFY ); |
274 |
input.length = 0; |
275 |
free_if_alloc( input.data ); |
276 |
} |
277 |
} |
278 |
else if (type & GPGME_PGP_CLEARSIG) { |
279 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
280 |
clip_verify_dlg_proc, NULL, |
281 |
_("Verify"), IDS_WINPT_VERIFY ); |
282 |
} |
283 |
else if ((type & GPGME_PGP_PUBKEY) || (type & GPGME_PGP_SECKEY)) |
284 |
km_clip_import (GetDesktopWindow ()); |
285 |
else |
286 |
msg_box (hwnd, _("Unknown OpenPGP type."), _("Clipboard"), MB_ERR); |
287 |
} |
288 |
} /* clip_gpg_dlg */ |
289 |
|
290 |
|
291 |
gpgme_card_t |
292 |
smartcard_init (void) |
293 |
{ |
294 |
/* |
295 |
pcsc_loadlib (scard_support); |
296 |
rc = show_card_status (); |
297 |
if( rc ) |
298 |
break; |
299 |
*/ |
300 |
return gpg_load_scard (); |
301 |
} /* smartcard_init */ |
302 |
|
303 |
|
304 |
LRESULT CALLBACK |
305 |
winpt_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) |
306 |
{ |
307 |
static NOTIFYICONDATA NID; |
308 |
static int use_hotkey = 0; |
309 |
reminder_ctx_s ctx; |
310 |
LPARAM param; |
311 |
curr_wnd_ctx currwnd = {0}; |
312 |
size_t size = 0; |
313 |
int rc, set_wc = 0, has_data = 0; |
314 |
INITCOMMONCONTROLSEX cce; |
315 |
gpgme_error_t ec; |
316 |
gpgme_card_t card; |
317 |
|
318 |
switch( msg ) { |
319 |
case WM_CREATE: |
320 |
NID.cbSize = sizeof (NID); |
321 |
NID.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
322 |
NID.uCallbackMessage = WM_USER; |
323 |
NID.hWnd = hwnd; |
324 |
NID.hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_WINPT)); |
325 |
strcpy (NID.szTip, "Windows Privacy Tray v"PGM_VERSION); |
326 |
Shell_NotifyIcon (NIM_ADD, &NID); |
327 |
DestroyIcon (NID.hIcon); |
328 |
rc = wsock_init (); |
329 |
if (rc) |
330 |
msg_box (NULL, winpt_strerror (rc), "Winsock2 DLL", MB_ERR); |
331 |
if (!reg_prefs.no_hotkeys) { |
332 |
rc = hotkeys_register (hwnd); |
333 |
if (rc) |
334 |
msg_box (hwnd, hotkeys_strerror (), winpt_strerror (rc), MB_ERR); |
335 |
} |
336 |
rc = PTD_initialize (); |
337 |
if (!rc) |
338 |
msg_box (hwnd, _("Could not set current window mode hooks."), _("WinPT Error"), MB_OK); |
339 |
mapi_init (); |
340 |
/* init common controls: date control. */ |
341 |
cce.dwSize = sizeof (INITCOMMONCONTROLSEX); |
342 |
cce.dwICC = ICC_DATE_CLASSES; |
343 |
InitCommonControlsEx (&cce); |
344 |
LoadLibrary ("RichEd32.Dll"); |
345 |
break; |
346 |
|
347 |
case WM_DESTROY: |
348 |
case WM_CLOSE: |
349 |
cryptdisk_cleanup (); |
350 |
mapi_deinit (); |
351 |
wsock_end (); |
352 |
keycache_release (); |
353 |
gnupg_backup_keyrings (); |
354 |
free_reg_prefs (); |
355 |
free_gnupg_table (); |
356 |
hotkeys_unregister (hwnd); |
357 |
release_file_lock (&mo_file); |
358 |
PTD_delete (); |
359 |
agent_flush_cache (); |
360 |
if (!gpgme_clip_istext_avail (&has_data) && has_data) { |
361 |
int chk = get_reg_winpt_flag ("WipeClipboard"); |
362 |
if (chk == -1) |
363 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CONFDELCLIP, |
364 |
GetDesktopWindow (), confirm_delclipboard_dlg, |
365 |
NULL); |
366 |
if (wipe_contents || chk) |
367 |
set_clip_text (NULL, " ", 1); |
368 |
wipe_contents = 0; |
369 |
} |
370 |
gpgme_lib_cleanup (); |
371 |
cleanup_tmp_files (); |
372 |
Shell_NotifyIcon (NIM_DELETE, &NID); |
373 |
PostQuitMessage (0); |
374 |
ExitProcess (0); |
375 |
return 0; |
376 |
|
377 |
case WM_USER: |
378 |
switch (lparam) { |
379 |
case WM_RBUTTONUP: |
380 |
HMENU hm, popup; |
381 |
POINT p; |
382 |
|
383 |
gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1; |
384 |
|
385 |
SetForegroundWindow (hwnd); |
386 |
GetCursorPos (&p); |
387 |
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT)); |
388 |
popup = GetSubMenu (hm, 0); |
389 |
#ifndef LANG_DE |
390 |
set_menu_text( popup, ID_WINPT_FILE, _("File Manager") ); |
391 |
set_menu_text( popup, ID_WINPT_KEY, _("Key Manager") ); |
392 |
set_menu_text( popup, ID_WINPT_CARD, _("Card Manager") ); |
393 |
if (!scard_support) |
394 |
set_menu_state (popup, ID_WINPT_CARD, MF_DISABLED|MF_GRAYED); |
395 |
if (!cryptdisk_available ()) { |
396 |
set_menu_state (popup, ID_WINPT_CDISKNEW, MF_DISABLED|MF_GRAYED); |
397 |
set_menu_state (popup, ID_WINPT_CDISKMOUNT, MF_DISABLED|MF_GRAYED); |
398 |
set_menu_state (popup, ID_WINPT_CDISKUNMOUNT, MF_DISABLED|MF_GRAYED); |
399 |
} |
400 |
|
401 |
set_menu_text( popup, ID_WINPT_EDIT, _("Edit Clipboard") ); |
402 |
set_menu_text( popup, ID_WINPT_ABOUT, _("About...") ); |
403 |
set_menu_text( popup, ID_WINPT_QUIT, _("Exit") ); |
404 |
set_menu_text( popup, ID_WINPT_SYMENC, _("Symmetric") ); |
405 |
#if 0 |
406 |
set_menu_text( popup, ID_WINPT_ENCRYPT, _("Encrypt") ); |
407 |
set_menu_text( popup, ID_WINPT_SIGNENCRYPT, _("Sign && Encrypt") ); |
408 |
set_menu_text( popup, ID_WINPT_DECRYPT, _("Decrypt/Verify") ); |
409 |
set_menu_text( popup, ID_WINPT_VERIFY, _("Verify") ); |
410 |
set_menu_text( popup, ID_WINPT_CURRWND_ENCRYPT, _("Encrypt") ); |
411 |
set_menu_text( popup, ID_WINPT_CURRWND_SIGNENCRYPT, _("Sign && Encrypt") ); |
412 |
set_menu_text( popup, ID_WINPT_CURRWND_DECRYPT_VERIFY, _("Decrypt/Verify") ); |
413 |
set_menu_text( popup, ID_WINPT_CURRWND_SIGN, _("Sign") ); |
414 |
#endif |
415 |
#endif |
416 |
TrackPopupMenu( popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL ); |
417 |
PostMessage( hwnd, WM_USER, 0, 0 ); |
418 |
DestroyMenu( popup ); |
419 |
DestroyMenu( hm ); |
420 |
break; |
421 |
|
422 |
case WM_LBUTTONDBLCLK: |
423 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_KEY, 0 ); |
424 |
break; |
425 |
} |
426 |
break; |
427 |
|
428 |
case WM_HOTKEY: |
429 |
cmd = 0; |
430 |
switch( wparam ) { |
431 |
case WPT_CLIP_ENCRYPT_ID: |
432 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_ENCRYPT, 0 ); |
433 |
break; |
434 |
|
435 |
case WPT_CLIP_DECRYPT_VERIFY_ID: |
436 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_DECRYPT_VERIFY, 0 ); |
437 |
break; |
438 |
|
439 |
case WPT_CLIP_SIGN_ID: |
440 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_SIGN, 0 ); |
441 |
break; |
442 |
|
443 |
case WPT_CLIP_SIGN_ENCRYPT_ID: |
444 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_SIGNENCRYPT, 0 ); |
445 |
break; |
446 |
|
447 |
case WPT_CURRWND_ENCRYPT_ID: |
448 |
use_hotkey = 1; |
449 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_ENCRYPT, 0 ); |
450 |
break; |
451 |
|
452 |
case WPT_CURRWND_SIGN_ID: |
453 |
use_hotkey = 1; |
454 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_SIGN, 0 ); |
455 |
break; |
456 |
|
457 |
case WPT_CURRWND_SIGN_ENCRYPT_ID: |
458 |
use_hotkey = 1; |
459 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_SIGNENCRYPT, 0 ); |
460 |
break; |
461 |
|
462 |
case WPT_CURRWND_DECRYPT_VERIFY_ID: |
463 |
use_hotkey = 1; |
464 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_DECRYPT_VERIFY, 0 ); |
465 |
break; |
466 |
|
467 |
case WPT_AGENT_FORGET_ID: |
468 |
rc = msg_box( hwnd, _("Remove all passphrases from cache?"), |
469 |
_("WinPT"), MB_YESNO|MB_ICONQUESTION ); |
470 |
if( rc == IDYES ) |
471 |
agent_flush_cache(); |
472 |
break; |
473 |
} |
474 |
break; |
475 |
|
476 |
case WM_COMMAND: |
477 |
if( gnupg_access_keyring( 1 ) ) { |
478 |
if( log_box( "WinPT", MB_ERR|MB_YESNO, |
479 |
_("Could not access public keyring, exit WinPT?") ) == IDYES ) |
480 |
SendMessage( hwnd, WM_DESTROY, 0, 0 ); |
481 |
break; |
482 |
} |
483 |
switch( wparam ) { |
484 |
/** Clipboard operations **/ |
485 |
case ID_WINPT_SYMENC: |
486 |
case ID_WINPT_ENCRYPT: |
487 |
case ID_WINPT_SIGN: |
488 |
case ID_WINPT_SIGNENCRYPT: |
489 |
case ID_WINPT_DECRYPT_VERIFY: |
490 |
ec = gpgme_clip_istext_avail( &has_data ); |
491 |
if( ec ) { |
492 |
msg_box( hwnd, gpgme_strerror( ec ),_("Clipboard"), MB_ERR ); |
493 |
break; |
494 |
} |
495 |
if( !has_data ) { |
496 |
msg_box( hwnd, gpgme_strerror( GPGME_Clip_Empty ),_("Clipboard"), MB_ERR ); |
497 |
break; |
498 |
} |
499 |
ctx.msecs = 500; |
500 |
window_reminder( &ctx ); |
501 |
clip_gpg_dlg( hwnd, (int)wparam ); |
502 |
break; |
503 |
|
504 |
/** Current window operations **/ |
505 |
case ID_WINPT_CURRWND_SYMENC: |
506 |
case ID_WINPT_CURRWND_ENCRYPT: |
507 |
case ID_WINPT_CURRWND_SIGNENCRYPT: |
508 |
case ID_WINPT_CURRWND_DECRYPT_VERIFY: |
509 |
case ID_WINPT_CURRWND_SIGN: |
510 |
rc = get_window_contents( hwnd, &currwnd, &use_hotkey ); |
511 |
if( rc ) { |
512 |
log_box( _("WinPT Error"), MB_ERR, |
513 |
_("Make sure that the window contains text.\n" |
514 |
"%s."), |
515 |
winpt_strerror( WPTERR_CURR_WND ) ); |
516 |
break; |
517 |
} |
518 |
ctx.msecs = 500; |
519 |
window_reminder( &ctx ); |
520 |
rc = currwnd_gpg_dlg( hwnd, (UINT)wparam, &set_wc ); |
521 |
if( !rc && set_wc ) |
522 |
set_window_contents( hwnd, &currwnd ); |
523 |
break; |
524 |
|
525 |
/** File handling **/ |
526 |
case ID_WINPT_FILE: |
527 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_FILE, |
528 |
GetDesktopWindow(), file_manager_dlg_proc, NULL, |
529 |
_("File Manager (use drag & drop to add files)"), IDS_WINPT_FILE ); |
530 |
break; |
531 |
|
532 |
/** Misc **/ |
533 |
case ID_WINPT_KEY: |
534 |
param = NULL; |
535 |
if( cmd ) |
536 |
param = (LPARAM)cmd; |
537 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYMISC, |
538 |
GetDesktopWindow(), keymanager_dlg_proc, param, |
539 |
_("Key Manager"), IDS_WINPT_KEYMISC ); |
540 |
cmd = 0; |
541 |
break; |
542 |
|
543 |
case ID_WINPT_CARD: |
544 |
card = smartcard_init (); |
545 |
if( card ) { |
546 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CARD_EDIT, |
547 |
GetDesktopWindow(), card_edit_dlg_proc, |
548 |
(LPARAM)card, |
549 |
_("Card Edit"), IDS_WINPT_CARD_EDIT ); |
550 |
gpgme_card_release( card ); card = NULL; |
551 |
} |
552 |
break; |
553 |
|
554 |
case ID_WINPT_EDIT: |
555 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT, |
556 |
GetDesktopWindow(), clip_edit_dlg_proc, NULL, |
557 |
_("Clipboard Editor"), IDS_WINPT_CLIPEDIT ); |
558 |
break; |
559 |
|
560 |
case ID_WINPT_ABOUT: |
561 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ABOUT, GetDesktopWindow(), |
562 |
about_winpt_dlg_proc, NULL, |
563 |
_("About WinPT"), IDS_WINPT_ABOUT ); |
564 |
break; |
565 |
|
566 |
case ID_WINPT_PREFS: |
567 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_PREFS, GetDesktopWindow(), |
568 |
prefs_dlg_proc, NULL, |
569 |
_("WinPT Preferences"), IDS_WINPT_PREFS ); |
570 |
break; |
571 |
|
572 |
case ID_WINPT_GPGPREFS: |
573 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS, GetDesktopWindow(), |
574 |
gpgprefs_dlg_proc, NULL, |
575 |
_("GnuPG Preferences"), IDS_WINPT_GPGPREFS ); |
576 |
break; |
577 |
|
578 |
case ID_WINPT_CDISKNEW: |
579 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_NEW, |
580 |
GetDesktopWindow (), cryptdisk_new_dlg_proc, NULL); |
581 |
break; |
582 |
|
583 |
case ID_WINPT_CDISKMOUNT: |
584 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_MOUNT, |
585 |
GetDesktopWindow (), cryptdisk_mount_dlg_proc, NULL); |
586 |
break; |
587 |
|
588 |
case ID_WINPT_CDISKUNMOUNT: |
589 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_UMOUNT, |
590 |
GetDesktopWindow (), cryptdisk_umount_dlg_proc, NULL); |
591 |
break; |
592 |
|
593 |
case ID_WINPT_CDISKUMOUNTALL: |
594 |
cryptdisk_unmount (0, 0); |
595 |
break; |
596 |
|
597 |
case ID_WINPT_QUIT: |
598 |
SendMessage (hwnd, WM_DESTROY, 0, 0); |
599 |
break; |
600 |
} |
601 |
break; |
602 |
} |
603 |
|
604 |
return DefWindowProc (hwnd, msg, wparam, lparam); |
605 |
} /* winpt_main_proc */ |