/[winpt]/trunk/Src/wptMainProc.cpp
ViewVC logotype

Annotation of /trunk/Src/wptMainProc.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 415 - (hide annotations)
Sat Feb 11 16:51:01 2012 UTC (13 years ago) by twoaday
File size: 18722 byte(s)
2012-02-11  Timo Schulz  <twoaday@gmx.net>

        * WinPT.cpp (WinMain): Switch to disable hooking.
        * wptMainProc.cpp (winpt_main_proc): Handle it here.
	

1 werner 36 /* wptMainProc.cpp - Main window procedure
2 twoaday 338 * Copyright (C) 2000-2009, 2011 Timo Schulz
3 werner 36 *
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 twoaday 320 /* Only define the constant if needed. */
22     #ifndef _WIN32_IE
23 twoaday 338 #define _WIN32_IE 0x0700
24 twoaday 320 #endif
25 twoaday 262
26 werner 36 #include <windows.h>
27     #include <commctrl.h>
28     #include <io.h>
29    
30 werner 47 #include "resource.h"
31 werner 36 #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 twoaday 248 #include "wptUTF8.h"
45 twoaday 328 #include "wptKeylist.h"
46 werner 36 #include "wptKeyManager.h"
47     #include "wptCard.h"
48     #include "wptCardEdit.h"
49    
50 twoaday 190
51 twoaday 415 /* KLUDGE: for no-hooking */
52     extern int disable_hook;
53    
54    
55 twoaday 255 int update_keycache (HWND hwnd);
56 twoaday 190
57 twoaday 248 /* Command for the Key Manager dialog. (0=no command) */
58 werner 36 static int cmd = 0;
59 twoaday 248
60     /* 1 indicates that the clipboard will be emptied o exit. */
61 werner 36 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 twoaday 248 char *uid;
71 werner 36 char tmp[128+64+1];
72    
73 twoaday 72 switch (msg) {
74 werner 36 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 twoaday 248 uid = utf8_to_native (key->uids->uid);
79 twoaday 328 _snprintf (tmp, DIM (tmp)-1, "(0x%s) %s",
80 twoaday 248 key->subkeys->keyid+8, uid);
81 werner 36 SendDlgItemMessage (dlg, IDC_ELGWARN_LIST, LB_ADDSTRING,
82 twoaday 248 0, (LPARAM)(const char *)tmp);
83     free_if_alloc (uid);
84 werner 36 }
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 twoaday 32 }
101 werner 36
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 twoaday 226 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 twoaday 105 SetDlgItemText (dlg, IDYES, _("&Yes"));
115 twoaday 121 SetDlgItemText (dlg, IDNO, _("&No"));
116 werner 36 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 twoaday 248 EndDialog (dlg, 1);
127 werner 36 break;
128    
129     case IDNO:
130     wipe_contents = 0;
131     if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN))
132     set_reg_winpt_flag ("WipeClipboard", 0);
133 twoaday 248 EndDialog (dlg, 0);
134 werner 36 break;
135     }
136     break;
137     }
138     return FALSE;
139     }
140    
141    
142 twoaday 255 /* 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 werner 36 {
147 twoaday 68 gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);
148 werner 36 int type;
149 twoaday 255 int disable_viewer = 0;
150 werner 36
151 twoaday 255 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 werner 36 }
158 twoaday 338 if ((id == ID_WINPT_SIGN || id == ID_WINPT_SIGNENCRYPT) && gnupg_access_keyring (0)) {
159 twoaday 129 msg_box (hwnd, _("Could not access secret keyring."), _("Sign"), MB_ERR);
160 werner 36 return;
161     }
162    
163 twoaday 255 switch (id) {
164 werner 36 case ID_WINPT_SYMENC:
165 twoaday 255 case ID_WINPT_CURRWND_SYMENC:
166     err = gpg_clip_sym_encrypt ();
167     if (err && r_upd_window)
168     *r_upd_window = 0;
169 werner 36 break;
170    
171     case ID_WINPT_ENCRYPT:
172 twoaday 255 case ID_WINPT_CURRWND_ENCRYPT:
173     dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd,
174 twoaday 338 clip_encrypt_dlg_proc, 0, _("Encryption"), IDS_WINPT_ENCRYPT);
175 werner 36 break;
176    
177     case ID_WINPT_SIGN:
178 twoaday 255 case ID_WINPT_CURRWND_SIGN:
179     dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd,
180 twoaday 338 clip_sign_dlg_proc, 0, _("Signing"), IDS_WINPT_SIGN);
181 werner 36 break;
182    
183     case ID_WINPT_SIGNENCRYPT:
184 twoaday 255 case ID_WINPT_CURRWND_SIGNENCRYPT:
185     dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd,
186 twoaday 338 clip_signenc_dlg_proc, 0, _("Sign & Encrypt"), IDS_WINPT_SIGNENC);
187 werner 36 break;
188    
189     case ID_WINPT_DECRYPT_VERIFY:
190 twoaday 255 case ID_WINPT_CURRWND_DECRYPT_VERIFY:
191 werner 36 err = gpg_clip_get_pgptype (&type);
192     if (err) {
193 twoaday 255 msg_box (hwnd, gpgme_strerror (err), _("Clipboard"), MB_ERR);
194     if (r_upd_window)
195     *r_upd_window = 0;
196 werner 36 break;
197     }
198 twoaday 255 if ((type & PGP_MESSAGE) && !(type & PGP_CLEARSIG))
199 twoaday 338 err = clip_decrypt_dlg (hwnd, disable_viewer? 0 : reg_prefs.use_viewer);
200 twoaday 229 else if ((type & PGP_SIG) && !(type & PGP_CLEARSIG)) {
201 werner 36 text_input_s input;
202     gpgme_data_t sig;
203    
204 twoaday 225 memset (&input, 0, sizeof (input));
205 werner 36 err = gpg_data_new_from_clipboard (&sig, 0);
206 twoaday 225 if (err) {
207 twoaday 255 msg_box (hwnd, gpgme_strerror (err),_("Verify"), MB_ERR);
208     if (r_upd_window)
209     *r_upd_window = 0;
210 werner 36 return;
211     }
212     input.type = 0;
213 twoaday 225 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 twoaday 338 /* The dialog might have changed the clipboard, so we restore
218 twoaday 225 the original state (again). */
219 twoaday 328 gpg_data_release_to_clipboard (sig, 0);
220 twoaday 225 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 werner 36 input.length = 0;
225 twoaday 225 free_if_alloc (input.data);
226 werner 36 }
227 twoaday 255 if (r_upd_window)
228     *r_upd_window = 0;
229 werner 36 }
230     else if (type & PGP_CLEARSIG) {
231 twoaday 255 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 werner 36 }
237 twoaday 255 else if ((type & PGP_PUBKEY) || (type & PGP_SECKEY)) {
238 twoaday 165 km_clip_import (GetDesktopWindow (), NULL, NULL);
239 twoaday 255 if (r_upd_window)
240     *r_upd_window = 0;
241     }
242     else {
243 werner 36 msg_box (hwnd, _("Unknown OpenPGP type."), _("Clipboard"), MB_ERR);
244 twoaday 255 if (r_upd_window)
245     *r_upd_window = 0;
246     }
247 werner 36 }
248 twoaday 72 }
249 werner 36
250    
251     /* Load the Card Manager with the current card. */
252     static void
253 twoaday 121 load_card_manager (void)
254 werner 36 {
255     gpg_card_t card;
256    
257     card = gpg_card_load ();
258 twoaday 193 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 werner 36 }
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 twoaday 229 /* Initialize all needed common controls. */
285 twoaday 193 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 twoaday 248 /* 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 twoaday 270
316 werner 36 /* 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 twoaday 139 static int use_hotkey = 0;
322 twoaday 193 static int manual_shutdown = 0;
323 twoaday 328 HWND wnd, cw_main, cw_focus;
324 twoaday 139 gpgme_error_t err;
325     const char *s;
326 twoaday 248 int rc, set_wc = 0;
327     int has_data = 0;
328 werner 36
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 twoaday 415 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 werner 36 mapi_init ();
346 twoaday 193 init_common_controls ();
347 werner 36 LoadLibrary ("RichEd32.Dll");
348 twoaday 193 manual_shutdown = 0;
349 werner 36 break;
350    
351     case WM_ENDSESSION:
352     case WM_DESTROY:
353     case WM_CLOSE:
354     case WM_QUIT:
355     mapi_deinit ();
356 twoaday 328 wsock_end ();
357 werner 36 keycache_release (1);
358 twoaday 319 /* 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 twoaday 222 gnupg_backup_keyrings (reg_prefs.auto_backup,
364 twoaday 248 reg_prefs.backup.mode,
365     reg_prefs.backup.include_secr);
366 twoaday 270 free_reg_prefs ();
367 werner 36 free_gnupg_table ();
368 twoaday 328 wipe_clipboard (manual_shutdown);
369 twoaday 278 gettext_free_current_domain ();
370 werner 36 hotkeys_unregister (hwnd);
371 twoaday 338 PTD_delete_hook ();
372 werner 36 agent_flush_cache ();
373     debug_end ();
374     Shell_NotifyIcon (NIM_DELETE, &NID);
375     PostQuitMessage (0);
376     ExitProcess (0);
377 twoaday 72 break;
378 werner 36
379     case WM_USER:
380     switch (lparam) {
381     case WM_RBUTTONUP:
382 twoaday 320 case WM_LBUTTONUP:
383 werner 36 HMENU hm, popup;
384     POINT p;
385    
386 twoaday 244 if (!wait_for_progress_cb (0))
387     break;
388 twoaday 248 gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1;
389 werner 36 SetForegroundWindow (hwnd);
390     GetCursorPos (&p);
391     hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT));
392     popup = GetSubMenu (hm, 0);
393 twoaday 72
394 twoaday 248 if (!scard_support)
395     set_menu_state (popup, ID_WINPT_CARD, MF_DISABLED|MF_GRAYED);
396 twoaday 328 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 werner 36 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 twoaday 72 set_menu_text (popup, ID_WINPT_SIGN, _("Sign"));
405 werner 36 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 twoaday 234 set_menu_text (popup, ID_WINPT_CURRWND_SYMENC, _("Symmetric"));
413 twoaday 72 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 twoaday 338 /* FIXME: we have to change popup texts */
420 twoaday 328 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 twoaday 72 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 werner 36 break;
431     }
432     break;
433    
434     case WM_HOTKEY:
435     cmd = 0;
436 twoaday 229 switch (wparam) {
437 werner 36 case WPT_CLIP_ENCRYPT_ID:
438 twoaday 338 SendMessage (hwnd, WM_COMMAND, ID_WINPT_ENCRYPT, 0);
439 werner 36 break;
440    
441     case WPT_CLIP_DECRYPT_VERIFY_ID:
442 twoaday 338 SendMessage (hwnd, WM_COMMAND, ID_WINPT_DECRYPT_VERIFY, 0);
443 werner 36 break;
444    
445     case WPT_CLIP_SIGN_ID:
446 twoaday 338 SendMessage (hwnd, WM_COMMAND, ID_WINPT_SIGN, 0);
447 werner 36 break;
448    
449     case WPT_CLIP_SIGN_ENCRYPT_ID:
450 twoaday 338 SendMessage (hwnd, WM_COMMAND, ID_WINPT_SIGNENCRYPT, 0);
451 werner 36 break;
452    
453     case WPT_CURRWND_ENCRYPT_ID:
454     use_hotkey = 1;
455 twoaday 338 SendMessage (hwnd, WM_COMMAND, ID_WINPT_CURRWND_ENCRYPT, 0);
456 werner 36 break;
457    
458     case WPT_CURRWND_SIGN_ID:
459     use_hotkey = 1;
460 twoaday 338 SendMessage (hwnd, WM_COMMAND, ID_WINPT_CURRWND_SIGN, 0);
461 werner 36 break;
462    
463     case WPT_CURRWND_SIGN_ENCRYPT_ID:
464     use_hotkey = 1;
465 twoaday 338 SendMessage (hwnd, WM_COMMAND, ID_WINPT_CURRWND_SIGNENCRYPT, 0 );
466 werner 36 break;
467    
468     case WPT_CURRWND_DECRYPT_VERIFY_ID:
469     use_hotkey = 1;
470 twoaday 338 SendMessage (hwnd, WM_COMMAND, ID_WINPT_CURRWND_DECRYPT_VERIFY, 0);
471 werner 36 break;
472    
473     case WPT_AGENT_FORGET_ID:
474 twoaday 248 rc = msg_box (hwnd, _("Remove all passphrases from cache?"),
475     _("WinPT"), MB_YESNO|MB_ICONQUESTION);
476     if (rc == IDYES)
477     agent_flush_cache ();
478 werner 36 break;
479 twoaday 338 }
480 werner 36 break;
481    
482     case WM_COMMAND:
483 twoaday 248 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 werner 36 break;
488     }
489 twoaday 248 switch (wparam) {
490 werner 36 /** 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 twoaday 193 err = gpg_clip_istext_avail (&has_data);
497     if (err) {
498     msg_box (hwnd, gpgme_strerror (err),_("Clipboard"), MB_ERR);
499 werner 36 break;
500     }
501 twoaday 193 if (!has_data) {
502     msg_box (hwnd, winpt_strerror (WPTERR_CLIP_EMPTY),
503     _("Clipboard"), MB_ERR);
504 werner 36 break;
505     }
506 twoaday 255 clip_gpg_dlg (hwnd, (int)wparam, NULL);
507 werner 36 break;
508 twoaday 193
509 werner 36 /** 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 twoaday 328 rc = copy_window_content (hwnd, &cw_main, &cw_focus, use_hotkey);
516 twoaday 248 if (rc) {
517     log_box (_("WinPT Error"), MB_ERR,
518 werner 36 _("Make sure that the window contains text.\n"
519     "%s."),
520 twoaday 328 winpt_strerror (WPTERR_CURR_WND));
521 werner 36 break;
522     }
523 twoaday 255 clip_gpg_dlg (hwnd, (int)wparam, &set_wc);
524     if (set_wc == 1)
525 twoaday 328 paste_window_content (hwnd, cw_main, cw_focus);
526     use_hotkey = 0;
527 werner 36 break;
528    
529     /** File handling **/
530     case ID_WINPT_FILE:
531 twoaday 139 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 werner 36 break;
539    
540     /** Misc **/
541     case ID_WINPT_KEY:
542 twoaday 139 wnd = FindWindow (NULL, _("Key Manager"));
543     if (wnd && IsIconic (wnd))
544     ShowWindow (wnd, SW_RESTORE);
545 twoaday 180 if (wnd)
546     SetForegroundWindow (wnd);
547 twoaday 139 dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYMISC,
548 twoaday 193 GetDesktopWindow(), keymanager_dlg_proc,
549     cmd != 0? (LPARAM)cmd : 0,
550 twoaday 139 _("Key Manager"), IDS_WINPT_KEYMISC);
551 werner 36 cmd = 0;
552     break;
553    
554     case ID_WINPT_CARD:
555 twoaday 121 load_card_manager ();
556 werner 36 break;
557    
558     case ID_WINPT_EDIT:
559     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,
560 twoaday 68 GetDesktopWindow(), clip_edit_dlg_proc, 0,
561 werner 36 _("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 twoaday 68 about_winpt_dlg_proc, 0,
567 werner 36 _("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 twoaday 68 prefs_dlg_proc, 0,
573 werner 36 _("WinPT Preferences"), IDS_WINPT_PREFS );
574     break;
575    
576     case ID_WINPT_GPGPREFS:
577 twoaday 190 rc = dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS,
578     GetDesktopWindow(), gpgprefs_dlg_proc, 0,
579 werner 36 _("GnuPG Preferences"), IDS_WINPT_GPGPREFS);
580 twoaday 190 if (rc == TRUE)
581     update_keycache (GetDesktopWindow ());
582 werner 36 break;
583    
584     case ID_WINPT_QUIT:
585 twoaday 193 manual_shutdown = 1;
586 werner 36 SendMessage (hwnd, WM_DESTROY, 0, 0);
587     break;
588     }
589     break;
590     }
591    
592     return DefWindowProc (hwnd, msg, wparam, lparam);
593     }

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26