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

Annotation of /trunk/Src/wptMainProc.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26