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

Annotation of /trunk/Src/wptMainProc.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 226 - (hide annotations)
Mon Jun 12 13:40:21 2006 UTC (18 years, 8 months ago) by twoaday
File size: 19776 byte(s)
Prepare new release.


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     if( (type & PGP_MESSAGE) && !(type & PGP_CLEARSIG) ) {
168     /* 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     err = clip_decrypt_dlg (hwnd);
171     if (!err && reg_prefs.use_viewer) {
172     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,
173 twoaday 68 GetDesktopWindow(), clip_edit_dlg_proc, 0,
174 werner 36 _("Clipboard Editor"), IDS_WINPT_CLIPEDIT);
175     if (ret_set)
176     *ret_set = 0;
177     }
178     }
179     else if ((type & PGP_PUBKEY) && !(type & PGP_CLEARSIG))
180 twoaday 165 km_clip_import (GetDesktopWindow (), NULL, NULL);
181 werner 36 else {
182     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,
183 twoaday 68 clip_verify_dlg_proc, 0,
184 werner 36 _("Verify"), IDS_WINPT_VERIFY );
185 twoaday 150 err = gpg_error (GPG_ERR_EOF); /* make sure window is not updated. */
186 werner 36 }
187     break;
188     }
189    
190     return err;
191     }
192    
193    
194     static void
195     clip_gpg_dlg (HWND hwnd, UINT id)
196     {
197     gpgme_error_t err;
198     int type;
199    
200 twoaday 129 if ((id == ID_WINPT_SIGN || id == ID_WINPT_SIGNENCRYPT)
201     && gnupg_access_keyring (0)) {
202     msg_box (hwnd, _("Could not access secret keyring."), _("Sign"), MB_ERR);
203 werner 36 return;
204     }
205    
206     switch( id ) {
207     case ID_WINPT_SYMENC:
208 twoaday 226 gpg_clip_sym_encrypt ();
209 werner 36 break;
210    
211     case ID_WINPT_ENCRYPT:
212     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd,
213 twoaday 68 clip_encrypt_dlg_proc, 0,
214 werner 36 _("Encryption"), IDS_WINPT_ENCRYPT );
215     break;
216    
217     case ID_WINPT_SIGN:
218     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd,
219 twoaday 68 clip_sign_dlg_proc, 0,
220 werner 36 _("Signing"), IDS_WINPT_SIGN );
221     break;
222    
223     case ID_WINPT_SIGNENCRYPT:
224     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd,
225 twoaday 68 clip_signenc_dlg_proc, 0,
226 werner 36 _("Sign & Encrypt"), IDS_WINPT_SIGNENC );
227     break;
228    
229     case ID_WINPT_DECRYPT_VERIFY:
230     err = gpg_clip_get_pgptype (&type);
231     if (err) {
232     msg_box( hwnd, gpgme_strerror( err ), _("Clipboard"), MB_ERR );
233     break;
234     }
235     if( (type & PGP_MESSAGE) && !(type & PGP_CLEARSIG) ) {
236     err = clip_decrypt_dlg (hwnd);
237     if (!err && reg_prefs.use_viewer) {
238     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,
239 twoaday 68 GetDesktopWindow(), clip_edit_dlg_proc, 0,
240 werner 36 _("Clipboard Editor"), IDS_WINPT_CLIPEDIT );
241     }
242     }
243     else if( (type & PGP_SIG) && !(type & PGP_CLEARSIG) ) {
244     text_input_s input;
245     gpgme_data_t sig;
246    
247 twoaday 225 memset (&input, 0, sizeof (input));
248 werner 36 err = gpg_data_new_from_clipboard (&sig, 0);
249 twoaday 225 if (err) {
250     msg_box (hwnd, gpgme_strerror( err ),_("Verify"), MB_ERR);
251 werner 36 return;
252     }
253     input.type = 0;
254 twoaday 225 dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_TEXT, hwnd,
255     text_input_dlg_proc, (LPARAM)&input,
256     _("Text Input"), IDS_WINPT_TEXT);
257    
258     /* the dialog might have changed the clipboard, so we restore
259     the original state (again). */
260     gpg_data_release_and_set_clipboard (sig, 0);
261     if (input.length > 0) {
262     dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,
263     clip_verify_dlg_proc, (LPARAM)&input,
264     _("Verify"), IDS_WINPT_VERIFY);
265 werner 36 input.length = 0;
266 twoaday 225 free_if_alloc (input.data);
267 werner 36 }
268     }
269     else if (type & PGP_CLEARSIG) {
270     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,
271 twoaday 68 clip_verify_dlg_proc, 0,
272 werner 36 _("Verify"), IDS_WINPT_VERIFY );
273     }
274     else if ((type & PGP_PUBKEY) || (type & PGP_SECKEY))
275 twoaday 165 km_clip_import (GetDesktopWindow (), NULL, NULL);
276 werner 36 else
277     msg_box (hwnd, _("Unknown OpenPGP type."), _("Clipboard"), MB_ERR);
278     }
279 twoaday 72 }
280 werner 36
281    
282     /* Load the Card Manager with the current card. */
283     static void
284 twoaday 121 load_card_manager (void)
285 werner 36 {
286     gpg_card_t card;
287    
288     card = gpg_card_load ();
289 twoaday 193 if (!card)
290     return;
291    
292     dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_CARD_EDIT,
293     GetDesktopWindow (), card_edit_dlg_proc,
294     (LPARAM)card,
295     _("Card Edit"), IDS_WINPT_CARD_EDIT);
296     gpg_card_release (card);
297 werner 36 }
298    
299    
300     /* Add the winpt symbol to the task bar. */
301     static void
302     add_taskbar_icon (HWND hwnd, NOTIFYICONDATA *nid)
303     {
304     nid->cbSize = sizeof (NOTIFYICONDATA);
305     nid->uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
306     nid->uCallbackMessage = WM_USER;
307     nid->hWnd = hwnd;
308     nid->hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_WINPT));
309     strcpy (nid->szTip, "Windows Privacy Tray v"PGM_VERSION);
310     Shell_NotifyIcon (NIM_ADD, nid);
311     DestroyIcon (nid->hIcon);
312     }
313    
314    
315 twoaday 193 static void
316     init_common_controls (void)
317     {
318     INITCOMMONCONTROLSEX cce;
319    
320     /* date control, toolbar, trackbar, ... */
321     cce.dwSize = sizeof (INITCOMMONCONTROLSEX);
322     cce.dwICC = ICC_DATE_CLASSES|ICC_BAR_CLASSES;
323     InitCommonControlsEx (&cce);
324     }
325    
326    
327 werner 36 /* Main message loop for the tray window. */
328     LRESULT CALLBACK
329     winpt_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
330     {
331     static NOTIFYICONDATA NID;
332 twoaday 174 static DWORD cookie;
333 twoaday 139 static int use_hotkey = 0;
334 twoaday 193 static int manual_shutdown = 0;
335 twoaday 139 HWND wnd;
336     gpgme_error_t err;
337     curr_wnd_ctx currwnd = {0};
338     const char *s;
339 werner 36 int rc, set_wc = 0, has_data = 0;
340    
341     switch (msg) {
342     case WM_CREATE:
343     add_taskbar_icon (hwnd, &NID);
344     rc = wsock_init ();
345     if (rc)
346     msg_box (NULL, winpt_strerror (rc), "Winsock2 DLL", MB_ERR);
347     if (!reg_prefs.no_hotkeys) {
348     rc = hotkeys_register (hwnd);
349     if (rc)
350     msg_box (hwnd, hotkeys_strerror (), winpt_strerror (rc), MB_ERR);
351     }
352     rc = PTD_initialize ();
353     if (!rc)
354     msg_box (hwnd, _("Could not set current window mode hooks."),
355     _("WinPT Error"), MB_OK);
356     mapi_init ();
357 twoaday 193 init_common_controls ();
358 twoaday 174 html_help_init (&cookie);
359 werner 36 LoadLibrary ("RichEd32.Dll");
360 twoaday 193 manual_shutdown = 0;
361 werner 36 break;
362    
363     case WM_ENDSESSION:
364     case WM_DESTROY:
365     case WM_CLOSE:
366     case WM_QUIT:
367     mapi_deinit ();
368     wsock_end ();
369     keycache_release (1);
370 twoaday 222 gnupg_backup_keyrings (reg_prefs.auto_backup,
371     reg_prefs.backup.mode,
372     reg_prefs.backup.include_secr);
373 werner 36 free_reg_prefs ();
374     free_gnupg_table ();
375     hotkeys_unregister (hwnd);
376     PTD_delete ();
377     agent_flush_cache ();
378 twoaday 174 html_help_deinit (cookie);
379 werner 36 if (!gpg_clip_istext_avail (&has_data) && has_data) {
380     int chk = get_reg_winpt_flag ("WipeClipboard");
381 twoaday 193 if (chk == -1 && manual_shutdown)
382 werner 36 DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CONFDELCLIP,
383     GetDesktopWindow (), confirm_delclipboard_dlg,
384 twoaday 68 0);
385 werner 36 if (wipe_contents || chk)
386     set_clip_text (NULL, " ", 1);
387     wipe_contents = 0;
388     }
389     debug_end ();
390     Shell_NotifyIcon (NIM_DELETE, &NID);
391     PostQuitMessage (0);
392     ExitProcess (0);
393 twoaday 72 break;
394 werner 36
395     case WM_USER:
396     switch (lparam) {
397     case WM_RBUTTONUP:
398     HMENU hm, popup;
399     POINT p;
400    
401     gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1;
402    
403     SetForegroundWindow (hwnd);
404     GetCursorPos (&p);
405     hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT));
406     popup = GetSubMenu (hm, 0);
407 twoaday 72
408 twoaday 193 set_menu_text (popup, ID_WINPT_FILE, _("File Manager"));
409     set_menu_text (popup, ID_WINPT_KEY, _("Key Manager"));
410     set_menu_text (popup, ID_WINPT_CARD, _("Card Manager"));
411 werner 36 if (!scard_support)
412     set_menu_state (popup, ID_WINPT_CARD, MF_DISABLED|MF_GRAYED);
413     set_menu_text (popup, ID_WINPT_EDIT, _("Edit Clipboard"));
414     set_menu_text (popup, ID_WINPT_ABOUT, _("About..."));
415     set_menu_text (popup, ID_WINPT_QUIT, _("Exit"));
416     set_menu_text (popup, ID_WINPT_SYMENC, _("Symmetric"));
417     set_menu_text (popup, ID_WINPT_ENCRYPT, _("Encrypt"));
418 twoaday 72 set_menu_text (popup, ID_WINPT_SIGN, _("Sign"));
419 werner 36 set_menu_text (popup, ID_WINPT_SIGNENCRYPT, _("Sign && Encrypt"));
420     set_menu_text (popup, ID_WINPT_DECRYPT, _("Decrypt/Verify"));
421     set_menu_text (popup, ID_WINPT_VERIFY, _("Verify"));
422     set_menu_text (popup, ID_WINPT_CURRWND_ENCRYPT, _("Encrypt"));
423     set_menu_text (popup, ID_WINPT_CURRWND_SIGNENCRYPT, _("Sign && Encrypt"));
424     set_menu_text (popup, ID_WINPT_CURRWND_DECRYPT_VERIFY, _("Decrypt/Verify"));
425     set_menu_text (popup, ID_WINPT_CURRWND_SIGN, _("Sign"));
426 twoaday 72 if (!secret_key_available ()) {
427     set_menu_state (popup, ID_WINPT_SIGN, MF_DISABLED|MF_GRAYED);
428     set_menu_state (popup, ID_WINPT_CURRWND_SIGN, MF_DISABLED|MF_GRAYED);
429     set_menu_state (popup, ID_WINPT_SIGNENCRYPT, MF_DISABLED|MF_GRAYED);
430     set_menu_state (popup, ID_WINPT_CURRWND_SIGNENCRYPT, MF_DISABLED|MF_GRAYED);
431     }
432 werner 36 /* change popup texts */
433     set_menu_text_bypos (popup, 6, _("Clipboard"));
434     set_menu_text_bypos (popup, 7, _("Current Window"));
435     set_menu_text_bypos (popup, 9, _("Preferences"));
436    
437 twoaday 72 TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL);
438     PostMessage (hwnd, WM_USER, 0, 0);
439     DestroyMenu (popup);
440     DestroyMenu (hm);
441 werner 36 break;
442    
443     case WM_LBUTTONDBLCLK:
444 twoaday 78 gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1;
445     SendMessage (hwnd, WM_COMMAND, ID_WINPT_KEY, 0);
446 werner 36 break;
447     }
448     break;
449    
450     case WM_HOTKEY:
451     cmd = 0;
452     switch( wparam ) {
453     case WPT_CLIP_ENCRYPT_ID:
454     SendMessage( hwnd, WM_COMMAND, ID_WINPT_ENCRYPT, 0 );
455     break;
456    
457     case WPT_CLIP_DECRYPT_VERIFY_ID:
458     SendMessage( hwnd, WM_COMMAND, ID_WINPT_DECRYPT_VERIFY, 0 );
459     break;
460    
461     case WPT_CLIP_SIGN_ID:
462     SendMessage( hwnd, WM_COMMAND, ID_WINPT_SIGN, 0 );
463     break;
464    
465     case WPT_CLIP_SIGN_ENCRYPT_ID:
466     SendMessage( hwnd, WM_COMMAND, ID_WINPT_SIGNENCRYPT, 0 );
467     break;
468    
469     case WPT_CURRWND_ENCRYPT_ID:
470     use_hotkey = 1;
471     SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_ENCRYPT, 0 );
472     break;
473    
474     case WPT_CURRWND_SIGN_ID:
475     use_hotkey = 1;
476     SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_SIGN, 0 );
477     break;
478    
479     case WPT_CURRWND_SIGN_ENCRYPT_ID:
480     use_hotkey = 1;
481     SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_SIGNENCRYPT, 0 );
482     break;
483    
484     case WPT_CURRWND_DECRYPT_VERIFY_ID:
485     use_hotkey = 1;
486     SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_DECRYPT_VERIFY, 0 );
487     break;
488    
489     case WPT_AGENT_FORGET_ID:
490     rc = msg_box( hwnd, _("Remove all passphrases from cache?"),
491     _("WinPT"), MB_YESNO|MB_ICONQUESTION );
492     if( rc == IDYES )
493     agent_flush_cache();
494     break;
495     }
496     break;
497    
498     case WM_COMMAND:
499     if( gnupg_access_keyring( 1 ) ) {
500     if( log_box( "WinPT", MB_ERR|MB_YESNO,
501     _("Could not access public keyring, exit WinPT?") ) == IDYES )
502     SendMessage( hwnd, WM_DESTROY, 0, 0 );
503     break;
504     }
505     switch( wparam ) {
506     /** Clipboard operations **/
507     case ID_WINPT_SYMENC:
508     case ID_WINPT_ENCRYPT:
509     case ID_WINPT_SIGN:
510     case ID_WINPT_SIGNENCRYPT:
511     case ID_WINPT_DECRYPT_VERIFY:
512 twoaday 193 err = gpg_clip_istext_avail (&has_data);
513     if (err) {
514     msg_box (hwnd, gpgme_strerror (err),_("Clipboard"), MB_ERR);
515 werner 36 break;
516     }
517 twoaday 193 if (!has_data) {
518     msg_box (hwnd, winpt_strerror (WPTERR_CLIP_EMPTY),
519     _("Clipboard"), MB_ERR);
520 werner 36 break;
521     }
522 twoaday 129 clip_gpg_dlg (hwnd, (int)wparam);
523 werner 36 break;
524 twoaday 193
525 werner 36 /** Current window operations **/
526     case ID_WINPT_CURRWND_SYMENC:
527     case ID_WINPT_CURRWND_ENCRYPT:
528     case ID_WINPT_CURRWND_SIGNENCRYPT:
529     case ID_WINPT_CURRWND_DECRYPT_VERIFY:
530     case ID_WINPT_CURRWND_SIGN:
531     rc = get_window_contents( hwnd, &currwnd, &use_hotkey );
532     if( rc ) {
533     log_box( _("WinPT Error"), MB_ERR,
534     _("Make sure that the window contains text.\n"
535     "%s."),
536     winpt_strerror( WPTERR_CURR_WND ) );
537     break;
538     }
539 twoaday 129 rc = currwnd_gpg_dlg (hwnd, (UINT)wparam, &set_wc);
540     if (!rc && set_wc)
541     set_window_contents (hwnd, &currwnd);
542 werner 36 break;
543    
544     /** File handling **/
545     case ID_WINPT_FILE:
546 twoaday 139 s = _("File Manager (use drag & drop to add files)");
547     wnd = FindWindow (NULL, s);
548     if (wnd && IsIconic (wnd))
549     ShowWindow (wnd, SW_RESTORE);
550     dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_FILE,
551     GetDesktopWindow (), file_manager_dlg_proc, 0,
552     s, IDS_WINPT_FILE);
553 werner 36 break;
554    
555     /** Misc **/
556     case ID_WINPT_KEY:
557 twoaday 139 wnd = FindWindow (NULL, _("Key Manager"));
558     if (wnd && IsIconic (wnd))
559     ShowWindow (wnd, SW_RESTORE);
560 twoaday 180 if (wnd)
561     SetForegroundWindow (wnd);
562 twoaday 139 dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYMISC,
563 twoaday 193 GetDesktopWindow(), keymanager_dlg_proc,
564     cmd != 0? (LPARAM)cmd : 0,
565 twoaday 139 _("Key Manager"), IDS_WINPT_KEYMISC);
566 werner 36 cmd = 0;
567     break;
568    
569     case ID_WINPT_CARD:
570 twoaday 121 load_card_manager ();
571 werner 36 break;
572    
573     case ID_WINPT_EDIT:
574     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,
575 twoaday 68 GetDesktopWindow(), clip_edit_dlg_proc, 0,
576 werner 36 _("Clipboard Editor"), IDS_WINPT_CLIPEDIT );
577     break;
578    
579     case ID_WINPT_ABOUT:
580     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ABOUT, GetDesktopWindow(),
581 twoaday 68 about_winpt_dlg_proc, 0,
582 werner 36 _("About WinPT"), IDS_WINPT_ABOUT );
583     break;
584    
585     case ID_WINPT_PREFS:
586     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_PREFS, GetDesktopWindow(),
587 twoaday 68 prefs_dlg_proc, 0,
588 werner 36 _("WinPT Preferences"), IDS_WINPT_PREFS );
589     break;
590    
591     case ID_WINPT_GPGPREFS:
592 twoaday 190 rc = dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS,
593     GetDesktopWindow(), gpgprefs_dlg_proc, 0,
594 werner 36 _("GnuPG Preferences"), IDS_WINPT_GPGPREFS);
595 twoaday 190 if (rc == TRUE)
596     update_keycache (GetDesktopWindow ());
597 werner 36 break;
598    
599     case ID_WINPT_QUIT:
600 twoaday 193 manual_shutdown = 1;
601 werner 36 SendMessage (hwnd, WM_DESTROY, 0, 0);
602     break;
603     }
604     break;
605     }
606    
607     return DefWindowProc (hwnd, msg, wparam, lparam);
608     }

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26