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

Annotation of /trunk/Src/wptMainProc.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 320 - (hide annotations)
Fri Aug 3 13:54:55 2007 UTC (17 years, 6 months ago) by twoaday
File size: 19117 byte(s)


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

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26