1 |
/* wptMainProc.cpp - Main window procedure |
2 |
* Copyright (C) 2000-2009, 2011 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 |
|
17 |
#ifdef HAVE_CONFIG_H |
18 |
#include <config.h> |
19 |
#endif |
20 |
|
21 |
/* Only define the constant if needed. */ |
22 |
#ifndef _WIN32_IE |
23 |
#define _WIN32_IE 0x0700 |
24 |
#endif |
25 |
|
26 |
#include <windows.h> |
27 |
#include <commctrl.h> |
28 |
#include <io.h> |
29 |
|
30 |
#include "resource.h" |
31 |
#include "wptTypes.h" |
32 |
#include "wptGPG.h" |
33 |
#include "wptW32API.h" |
34 |
#include "wptVersion.h" |
35 |
#include "wptCommonCtl.h" |
36 |
#include "wptContext.h" /* for passphrase_s */ |
37 |
#include "wptDlgs.h" |
38 |
#include "wptErrors.h" |
39 |
#include "wptNLS.h" |
40 |
#include "wptHotkey.h" |
41 |
#include "wptRegistry.h" |
42 |
#include "wptKeyserver.h" |
43 |
#include "wptAgent.h" |
44 |
#include "wptUTF8.h" |
45 |
#include "wptKeylist.h" |
46 |
#include "wptKeyManager.h" |
47 |
#include "wptCard.h" |
48 |
#include "wptCardEdit.h" |
49 |
|
50 |
|
51 |
/* KLUDGE: for no-hooking */ |
52 |
extern int disable_hook; |
53 |
|
54 |
|
55 |
int update_keycache (HWND hwnd); |
56 |
|
57 |
/* Command for the Key Manager dialog. (0=no command) */ |
58 |
static int cmd = 0; |
59 |
|
60 |
/* 1 indicates that the clipboard will be emptied o exit. */ |
61 |
static int wipe_contents = 0; |
62 |
|
63 |
|
64 |
/* Dialog box procedure to display all insecure all ElGamal keys. */ |
65 |
BOOL CALLBACK |
66 |
elgamal_warn_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
67 |
{ |
68 |
gpg_keycache_t pc; |
69 |
gpgme_key_t key; |
70 |
char *uid; |
71 |
char tmp[128+64+1]; |
72 |
|
73 |
switch (msg) { |
74 |
case WM_INITDIALOG: |
75 |
pc = keycache_get_ctx (1); |
76 |
while (!gpg_keycache_next_key (pc, 0, &key)) { |
77 |
if (key->subkeys->pubkey_algo == GPGME_PK_ELG) { |
78 |
uid = utf8_to_native (key->uids->uid); |
79 |
_snprintf (tmp, DIM (tmp)-1, "(0x%s) %s", |
80 |
key->subkeys->keyid+8, uid); |
81 |
SendDlgItemMessage (dlg, IDC_ELGWARN_LIST, LB_ADDSTRING, |
82 |
0, (LPARAM)(const char *)tmp); |
83 |
free_if_alloc (uid); |
84 |
} |
85 |
} |
86 |
gpg_keycache_rewind (pc); |
87 |
center_window (dlg, NULL); |
88 |
SetForegroundWindow (dlg); |
89 |
break; |
90 |
|
91 |
case WM_COMMAND: |
92 |
switch (LOWORD (wparam)) { |
93 |
case IDOK: |
94 |
EndDialog (dlg, TRUE); |
95 |
break; |
96 |
} |
97 |
break; |
98 |
} |
99 |
return FALSE; |
100 |
} |
101 |
|
102 |
|
103 |
/* Dialog box procedure to confirm to delete the clipboard contents. */ |
104 |
static BOOL CALLBACK |
105 |
confirm_delclipboard_dlg (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
106 |
{ |
107 |
switch (msg) { |
108 |
case WM_INITDIALOG: |
109 |
SetWindowText (dlg, _("Delete Clipboard Contents")); |
110 |
SetDlgItemText (dlg, IDC_CONFDELCLIP_BRAIN, |
111 |
_("&Remember the answer")); |
112 |
SetDlgItemText (dlg, IDC_CONFDELCLIP_INFO, |
113 |
_("Do you want to delete the contents from the clipboard?")); |
114 |
SetDlgItemText (dlg, IDYES, _("&Yes")); |
115 |
SetDlgItemText (dlg, IDNO, _("&No")); |
116 |
center_window (dlg, NULL); |
117 |
SetForegroundWindow (dlg); |
118 |
break; |
119 |
|
120 |
case WM_COMMAND: |
121 |
switch (LOWORD (wparam)) { |
122 |
case IDYES: |
123 |
wipe_contents = 1; |
124 |
if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN)) |
125 |
set_reg_winpt_flag ("WipeClipboard", 1); |
126 |
EndDialog (dlg, 1); |
127 |
break; |
128 |
|
129 |
case IDNO: |
130 |
wipe_contents = 0; |
131 |
if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN)) |
132 |
set_reg_winpt_flag ("WipeClipboard", 0); |
133 |
EndDialog (dlg, 0); |
134 |
break; |
135 |
} |
136 |
break; |
137 |
} |
138 |
return FALSE; |
139 |
} |
140 |
|
141 |
|
142 |
/* Handle the various command requests for the clipboard |
143 |
and the current window. */ |
144 |
static void |
145 |
clip_gpg_dlg (HWND hwnd, UINT id, int *r_upd_window) |
146 |
{ |
147 |
gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR); |
148 |
int type; |
149 |
int disable_viewer = 0; |
150 |
|
151 |
if (r_upd_window) { |
152 |
*r_upd_window = 1; |
153 |
/* for the current window mode it makes no sense to |
154 |
use the clipboard viewer for decryption because the |
155 |
text will be pasted directly into the window. */ |
156 |
disable_viewer = 1; |
157 |
} |
158 |
if ((id == ID_WINPT_SIGN || id == ID_WINPT_SIGNENCRYPT) && gnupg_access_keyring (0)) { |
159 |
msg_box (hwnd, _("Could not access secret keyring."), _("Sign"), MB_ERR); |
160 |
return; |
161 |
} |
162 |
|
163 |
switch (id) { |
164 |
case ID_WINPT_SYMENC: |
165 |
case ID_WINPT_CURRWND_SYMENC: |
166 |
err = gpg_clip_sym_encrypt (); |
167 |
if (err && r_upd_window) |
168 |
*r_upd_window = 0; |
169 |
break; |
170 |
|
171 |
case ID_WINPT_ENCRYPT: |
172 |
case ID_WINPT_CURRWND_ENCRYPT: |
173 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd, |
174 |
clip_encrypt_dlg_proc, 0, _("Encryption"), IDS_WINPT_ENCRYPT); |
175 |
break; |
176 |
|
177 |
case ID_WINPT_SIGN: |
178 |
case ID_WINPT_CURRWND_SIGN: |
179 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd, |
180 |
clip_sign_dlg_proc, 0, _("Signing"), IDS_WINPT_SIGN); |
181 |
break; |
182 |
|
183 |
case ID_WINPT_SIGNENCRYPT: |
184 |
case ID_WINPT_CURRWND_SIGNENCRYPT: |
185 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd, |
186 |
clip_signenc_dlg_proc, 0, _("Sign & Encrypt"), IDS_WINPT_SIGNENC); |
187 |
break; |
188 |
|
189 |
case ID_WINPT_DECRYPT_VERIFY: |
190 |
case ID_WINPT_CURRWND_DECRYPT_VERIFY: |
191 |
err = gpg_clip_get_pgptype (&type); |
192 |
if (err) { |
193 |
msg_box (hwnd, gpgme_strerror (err), _("Clipboard"), MB_ERR); |
194 |
if (r_upd_window) |
195 |
*r_upd_window = 0; |
196 |
break; |
197 |
} |
198 |
if ((type & PGP_MESSAGE) && !(type & PGP_CLEARSIG)) |
199 |
err = clip_decrypt_dlg (hwnd, disable_viewer? 0 : reg_prefs.use_viewer); |
200 |
else if ((type & PGP_SIG) && !(type & PGP_CLEARSIG)) { |
201 |
text_input_s input; |
202 |
gpgme_data_t sig; |
203 |
|
204 |
memset (&input, 0, sizeof (input)); |
205 |
err = gpg_data_new_from_clipboard (&sig, 0); |
206 |
if (err) { |
207 |
msg_box (hwnd, gpgme_strerror (err),_("Verify"), MB_ERR); |
208 |
if (r_upd_window) |
209 |
*r_upd_window = 0; |
210 |
return; |
211 |
} |
212 |
input.type = 0; |
213 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_TEXT, hwnd, |
214 |
text_input_dlg_proc, (LPARAM)&input, |
215 |
_("Text Input"), IDS_WINPT_TEXT); |
216 |
|
217 |
/* The dialog might have changed the clipboard, so we restore |
218 |
the original state (again). */ |
219 |
gpg_data_release_to_clipboard (sig, 0); |
220 |
if (input.length > 0) { |
221 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
222 |
clip_verify_dlg_proc, (LPARAM)&input, |
223 |
_("Verify"), IDS_WINPT_VERIFY); |
224 |
input.length = 0; |
225 |
free_if_alloc (input.data); |
226 |
} |
227 |
if (r_upd_window) |
228 |
*r_upd_window = 0; |
229 |
} |
230 |
else if (type & PGP_CLEARSIG) { |
231 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
232 |
clip_verify_dlg_proc, 0, |
233 |
_("Verify"), IDS_WINPT_VERIFY); |
234 |
if (r_upd_window) |
235 |
*r_upd_window = 0; |
236 |
} |
237 |
else if ((type & PGP_PUBKEY) || (type & PGP_SECKEY)) { |
238 |
km_clip_import (GetDesktopWindow (), NULL, NULL); |
239 |
if (r_upd_window) |
240 |
*r_upd_window = 0; |
241 |
} |
242 |
else { |
243 |
msg_box (hwnd, _("Unknown OpenPGP type."), _("Clipboard"), MB_ERR); |
244 |
if (r_upd_window) |
245 |
*r_upd_window = 0; |
246 |
} |
247 |
} |
248 |
} |
249 |
|
250 |
|
251 |
/* Load the Card Manager with the current card. */ |
252 |
static void |
253 |
load_card_manager (void) |
254 |
{ |
255 |
gpg_card_t card; |
256 |
|
257 |
card = gpg_card_load (); |
258 |
if (!card) |
259 |
return; |
260 |
|
261 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_CARD_EDIT, |
262 |
GetDesktopWindow (), card_edit_dlg_proc, |
263 |
(LPARAM)card, |
264 |
_("Card Edit"), IDS_WINPT_CARD_EDIT); |
265 |
gpg_card_release (card); |
266 |
} |
267 |
|
268 |
|
269 |
/* Add the winpt symbol to the task bar. */ |
270 |
static void |
271 |
add_taskbar_icon (HWND hwnd, NOTIFYICONDATA *nid) |
272 |
{ |
273 |
nid->cbSize = sizeof (NOTIFYICONDATA); |
274 |
nid->uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
275 |
nid->uCallbackMessage = WM_USER; |
276 |
nid->hWnd = hwnd; |
277 |
nid->hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_WINPT)); |
278 |
strcpy (nid->szTip, "Windows Privacy Tray v"PGM_VERSION); |
279 |
Shell_NotifyIcon (NIM_ADD, nid); |
280 |
DestroyIcon (nid->hIcon); |
281 |
} |
282 |
|
283 |
|
284 |
/* Initialize all needed common controls. */ |
285 |
static void |
286 |
init_common_controls (void) |
287 |
{ |
288 |
INITCOMMONCONTROLSEX cce; |
289 |
|
290 |
/* date control, toolbar, trackbar, ... */ |
291 |
cce.dwSize = sizeof (INITCOMMONCONTROLSEX); |
292 |
cce.dwICC = ICC_DATE_CLASSES|ICC_BAR_CLASSES; |
293 |
InitCommonControlsEx (&cce); |
294 |
} |
295 |
|
296 |
|
297 |
/* Wipe the clipboard if the user requested it. */ |
298 |
static void |
299 |
wipe_clipboard (int manual_shutdown) |
300 |
{ |
301 |
int has_data = 0; |
302 |
|
303 |
if (!gpg_clip_istext_avail (&has_data) && has_data) { |
304 |
int chk = get_reg_winpt_flag ("WipeClipboard"); |
305 |
if (chk == -1 && manual_shutdown) |
306 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CONFDELCLIP, |
307 |
GetDesktopWindow (), confirm_delclipboard_dlg, 0); |
308 |
if (wipe_contents || chk) |
309 |
set_clip_text (NULL, " ", 1); |
310 |
wipe_contents = 0; |
311 |
} |
312 |
} |
313 |
|
314 |
|
315 |
|
316 |
/* Main message loop for the tray window. */ |
317 |
LRESULT CALLBACK |
318 |
winpt_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) |
319 |
{ |
320 |
static NOTIFYICONDATA NID; |
321 |
static int use_hotkey = 0; |
322 |
static int manual_shutdown = 0; |
323 |
HWND wnd, cw_main, cw_focus; |
324 |
gpgme_error_t err; |
325 |
const char *s; |
326 |
int rc, set_wc = 0; |
327 |
int has_data = 0; |
328 |
|
329 |
switch (msg) { |
330 |
case WM_CREATE: |
331 |
add_taskbar_icon (hwnd, &NID); |
332 |
rc = wsock_init (); |
333 |
if (rc) |
334 |
msg_box (NULL, winpt_strerror (rc), "Winsock2 DLL", MB_ERR); |
335 |
if (!reg_prefs.no_hotkeys) { |
336 |
rc = hotkeys_register (hwnd); |
337 |
if (rc) |
338 |
msg_box (hwnd, hotkeys_strerror (), winpt_strerror (rc), MB_ERR); |
339 |
} |
340 |
if (!disable_hook) { |
341 |
rc = PTD_initialize (); |
342 |
if (!rc) |
343 |
msg_box (hwnd, _("Could not set current window mode hooks."), _("WinPT Error"), MB_OK); |
344 |
} |
345 |
mapi_init (); |
346 |
init_common_controls (); |
347 |
LoadLibrary ("RichEd32.Dll"); |
348 |
manual_shutdown = 0; |
349 |
break; |
350 |
|
351 |
case WM_ENDSESSION: |
352 |
case WM_DESTROY: |
353 |
case WM_CLOSE: |
354 |
case WM_QUIT: |
355 |
mapi_deinit (); |
356 |
wsock_end (); |
357 |
keycache_release (1); |
358 |
/* FIXME: There seems to be a problem with the backup at the |
359 |
* end on EFS file systems. I currently have no access to |
360 |
* any EFS partition so I need to do some general investigations |
361 |
* to find out what the problem is. |
362 |
*/ |
363 |
gnupg_backup_keyrings (reg_prefs.auto_backup, |
364 |
reg_prefs.backup.mode, |
365 |
reg_prefs.backup.include_secr); |
366 |
free_reg_prefs (); |
367 |
free_gnupg_table (); |
368 |
wipe_clipboard (manual_shutdown); |
369 |
gettext_free_current_domain (); |
370 |
hotkeys_unregister (hwnd); |
371 |
PTD_delete_hook (); |
372 |
agent_flush_cache (); |
373 |
debug_end (); |
374 |
Shell_NotifyIcon (NIM_DELETE, &NID); |
375 |
PostQuitMessage (0); |
376 |
ExitProcess (0); |
377 |
break; |
378 |
|
379 |
case WM_USER: |
380 |
switch (lparam) { |
381 |
case WM_RBUTTONUP: |
382 |
case WM_LBUTTONUP: |
383 |
HMENU hm, popup; |
384 |
POINT p; |
385 |
|
386 |
if (!wait_for_progress_cb (0)) |
387 |
break; |
388 |
gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1; |
389 |
SetForegroundWindow (hwnd); |
390 |
GetCursorPos (&p); |
391 |
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT)); |
392 |
popup = GetSubMenu (hm, 0); |
393 |
|
394 |
if (!scard_support) |
395 |
set_menu_state (popup, ID_WINPT_CARD, MF_DISABLED|MF_GRAYED); |
396 |
set_menu_text (popup, ID_WINPT_FILE, _("File Manager...")); |
397 |
set_menu_text (popup, ID_WINPT_KEY, _("Key Manager...")); |
398 |
set_menu_text (popup, ID_WINPT_CARD, _("Card Manager...")); |
399 |
set_menu_text (popup, ID_WINPT_EDIT, _("Edit...")); |
400 |
set_menu_text (popup, ID_WINPT_ABOUT, _("About...")); |
401 |
set_menu_text (popup, ID_WINPT_QUIT, _("Exit")); |
402 |
set_menu_text (popup, ID_WINPT_SYMENC, _("Symmetric")); |
403 |
set_menu_text (popup, ID_WINPT_ENCRYPT, _("Encrypt")); |
404 |
set_menu_text (popup, ID_WINPT_SIGN, _("Sign")); |
405 |
set_menu_text (popup, ID_WINPT_SIGNENCRYPT, _("Sign && Encrypt")); |
406 |
set_menu_text (popup, ID_WINPT_DECRYPT, _("Decrypt/Verify")); |
407 |
set_menu_text (popup, ID_WINPT_VERIFY, _("Verify")); |
408 |
set_menu_text (popup, ID_WINPT_CURRWND_ENCRYPT, _("Encrypt")); |
409 |
set_menu_text (popup, ID_WINPT_CURRWND_SIGNENCRYPT, _("Sign && Encrypt")); |
410 |
set_menu_text (popup, ID_WINPT_CURRWND_DECRYPT_VERIFY, _("Decrypt/Verify")); |
411 |
set_menu_text (popup, ID_WINPT_CURRWND_SIGN, _("Sign")); |
412 |
set_menu_text (popup, ID_WINPT_CURRWND_SYMENC, _("Symmetric")); |
413 |
if (!secret_key_available ()) { |
414 |
set_menu_state (popup, ID_WINPT_SIGN, MF_DISABLED|MF_GRAYED); |
415 |
set_menu_state (popup, ID_WINPT_CURRWND_SIGN, MF_DISABLED|MF_GRAYED); |
416 |
set_menu_state (popup, ID_WINPT_SIGNENCRYPT, MF_DISABLED|MF_GRAYED); |
417 |
set_menu_state (popup, ID_WINPT_CURRWND_SIGNENCRYPT, MF_DISABLED|MF_GRAYED); |
418 |
} |
419 |
/* FIXME: we have to change popup texts */ |
420 |
set_menu_text_bypos (popup, 3, _("Clipboard")); |
421 |
set_menu_text_bypos (popup, 4, _("Current Window")); |
422 |
set_menu_text_bypos (popup, 6, _("Preferences")); |
423 |
|
424 |
if (gettext_domain_needs_refresh()) |
425 |
gettext_set_user_domain(); |
426 |
TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL); |
427 |
PostMessage (hwnd, WM_USER, 0, 0); |
428 |
DestroyMenu (popup); |
429 |
DestroyMenu (hm); |
430 |
break; |
431 |
} |
432 |
break; |
433 |
|
434 |
case WM_HOTKEY: |
435 |
cmd = 0; |
436 |
switch (wparam) { |
437 |
case WPT_CLIP_ENCRYPT_ID: |
438 |
SendMessage (hwnd, WM_COMMAND, ID_WINPT_ENCRYPT, 0); |
439 |
break; |
440 |
|
441 |
case WPT_CLIP_DECRYPT_VERIFY_ID: |
442 |
SendMessage (hwnd, WM_COMMAND, ID_WINPT_DECRYPT_VERIFY, 0); |
443 |
break; |
444 |
|
445 |
case WPT_CLIP_SIGN_ID: |
446 |
SendMessage (hwnd, WM_COMMAND, ID_WINPT_SIGN, 0); |
447 |
break; |
448 |
|
449 |
case WPT_CLIP_SIGN_ENCRYPT_ID: |
450 |
SendMessage (hwnd, WM_COMMAND, ID_WINPT_SIGNENCRYPT, 0); |
451 |
break; |
452 |
|
453 |
case WPT_CURRWND_ENCRYPT_ID: |
454 |
use_hotkey = 1; |
455 |
SendMessage (hwnd, WM_COMMAND, ID_WINPT_CURRWND_ENCRYPT, 0); |
456 |
break; |
457 |
|
458 |
case WPT_CURRWND_SIGN_ID: |
459 |
use_hotkey = 1; |
460 |
SendMessage (hwnd, WM_COMMAND, ID_WINPT_CURRWND_SIGN, 0); |
461 |
break; |
462 |
|
463 |
case WPT_CURRWND_SIGN_ENCRYPT_ID: |
464 |
use_hotkey = 1; |
465 |
SendMessage (hwnd, WM_COMMAND, ID_WINPT_CURRWND_SIGNENCRYPT, 0 ); |
466 |
break; |
467 |
|
468 |
case WPT_CURRWND_DECRYPT_VERIFY_ID: |
469 |
use_hotkey = 1; |
470 |
SendMessage (hwnd, WM_COMMAND, ID_WINPT_CURRWND_DECRYPT_VERIFY, 0); |
471 |
break; |
472 |
|
473 |
case WPT_AGENT_FORGET_ID: |
474 |
rc = msg_box (hwnd, _("Remove all passphrases from cache?"), |
475 |
_("WinPT"), MB_YESNO|MB_ICONQUESTION); |
476 |
if (rc == IDYES) |
477 |
agent_flush_cache (); |
478 |
break; |
479 |
} |
480 |
break; |
481 |
|
482 |
case WM_COMMAND: |
483 |
if (gnupg_access_keyring (1)) { |
484 |
if (log_box( "WinPT", MB_ERR|MB_YESNO, |
485 |
_("Could not access public keyring, exit WinPT?") ) == IDYES) |
486 |
SendMessage (hwnd, WM_DESTROY, 0, 0); |
487 |
break; |
488 |
} |
489 |
switch (wparam) { |
490 |
/** Clipboard operations **/ |
491 |
case ID_WINPT_SYMENC: |
492 |
case ID_WINPT_ENCRYPT: |
493 |
case ID_WINPT_SIGN: |
494 |
case ID_WINPT_SIGNENCRYPT: |
495 |
case ID_WINPT_DECRYPT_VERIFY: |
496 |
err = gpg_clip_istext_avail (&has_data); |
497 |
if (err) { |
498 |
msg_box (hwnd, gpgme_strerror (err),_("Clipboard"), MB_ERR); |
499 |
break; |
500 |
} |
501 |
if (!has_data) { |
502 |
msg_box (hwnd, winpt_strerror (WPTERR_CLIP_EMPTY), |
503 |
_("Clipboard"), MB_ERR); |
504 |
break; |
505 |
} |
506 |
clip_gpg_dlg (hwnd, (int)wparam, NULL); |
507 |
break; |
508 |
|
509 |
/** Current window operations **/ |
510 |
case ID_WINPT_CURRWND_SYMENC: |
511 |
case ID_WINPT_CURRWND_ENCRYPT: |
512 |
case ID_WINPT_CURRWND_SIGNENCRYPT: |
513 |
case ID_WINPT_CURRWND_DECRYPT_VERIFY: |
514 |
case ID_WINPT_CURRWND_SIGN: |
515 |
rc = copy_window_content (hwnd, &cw_main, &cw_focus, use_hotkey); |
516 |
if (rc) { |
517 |
log_box (_("WinPT Error"), MB_ERR, |
518 |
_("Make sure that the window contains text.\n" |
519 |
"%s."), |
520 |
winpt_strerror (WPTERR_CURR_WND)); |
521 |
break; |
522 |
} |
523 |
clip_gpg_dlg (hwnd, (int)wparam, &set_wc); |
524 |
if (set_wc == 1) |
525 |
paste_window_content (hwnd, cw_main, cw_focus); |
526 |
use_hotkey = 0; |
527 |
break; |
528 |
|
529 |
/** File handling **/ |
530 |
case ID_WINPT_FILE: |
531 |
s = _("File Manager (use drag & drop to add files)"); |
532 |
wnd = FindWindow (NULL, s); |
533 |
if (wnd && IsIconic (wnd)) |
534 |
ShowWindow (wnd, SW_RESTORE); |
535 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_FILE, |
536 |
GetDesktopWindow (), file_manager_dlg_proc, 0, |
537 |
s, IDS_WINPT_FILE); |
538 |
break; |
539 |
|
540 |
/** Misc **/ |
541 |
case ID_WINPT_KEY: |
542 |
wnd = FindWindow (NULL, _("Key Manager")); |
543 |
if (wnd && IsIconic (wnd)) |
544 |
ShowWindow (wnd, SW_RESTORE); |
545 |
if (wnd) |
546 |
SetForegroundWindow (wnd); |
547 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYMISC, |
548 |
GetDesktopWindow(), keymanager_dlg_proc, |
549 |
cmd != 0? (LPARAM)cmd : 0, |
550 |
_("Key Manager"), IDS_WINPT_KEYMISC); |
551 |
cmd = 0; |
552 |
break; |
553 |
|
554 |
case ID_WINPT_CARD: |
555 |
load_card_manager (); |
556 |
break; |
557 |
|
558 |
case ID_WINPT_EDIT: |
559 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT, |
560 |
GetDesktopWindow(), clip_edit_dlg_proc, 0, |
561 |
_("Clipboard Editor"), IDS_WINPT_CLIPEDIT ); |
562 |
break; |
563 |
|
564 |
case ID_WINPT_ABOUT: |
565 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ABOUT, GetDesktopWindow(), |
566 |
about_winpt_dlg_proc, 0, |
567 |
_("About WinPT"), IDS_WINPT_ABOUT ); |
568 |
break; |
569 |
|
570 |
case ID_WINPT_PREFS: |
571 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_PREFS, GetDesktopWindow(), |
572 |
prefs_dlg_proc, 0, |
573 |
_("WinPT Preferences"), IDS_WINPT_PREFS ); |
574 |
break; |
575 |
|
576 |
case ID_WINPT_GPGPREFS: |
577 |
rc = dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS, |
578 |
GetDesktopWindow(), gpgprefs_dlg_proc, 0, |
579 |
_("GnuPG Preferences"), IDS_WINPT_GPGPREFS); |
580 |
if (rc == TRUE) |
581 |
update_keycache (GetDesktopWindow ()); |
582 |
break; |
583 |
|
584 |
case ID_WINPT_QUIT: |
585 |
manual_shutdown = 1; |
586 |
SendMessage (hwnd, WM_DESTROY, 0, 0); |
587 |
break; |
588 |
} |
589 |
break; |
590 |
} |
591 |
|
592 |
return DefWindowProc (hwnd, msg, wparam, lparam); |
593 |
} |