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

Annotation of /trunk/Src/wptMainProc.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 420 - (hide annotations)
Sat Mar 3 20:01:04 2012 UTC (12 years, 11 months ago) by twoaday
File size: 18655 byte(s)


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

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26