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

Annotation of /trunk/Src/wptMainProc.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 190 - (hide annotations)
Mon Mar 27 10:05:14 2006 UTC (18 years, 11 months ago) by twoaday
File size: 20513 byte(s)
2006-03-26  Timo Schulz  <ts@g10code.de>
 
        * wptSigTreeDlg.cpp (sigtree_load): Always use UTF8.
        * wptMainProc.cpp (winpt_main_proc): Reload key cache
        when the GPG settings were changed.
        * wptKeygenDlg.cpp (keygen_wizard_dlg_proc,
        keygen_dlg_proc): Improved check for the email address.
        * wptKeyEditDlgs.cpp (keyedit_adduid_dlg_proc): Likewise.
        * wptKeyserverDlg.cpp (keyserver_dlg_proc): Modified design.
         


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 95 SetDlgItemText (dlg, IDC_CONFDELCLIP_BRAIN, _("&Remember the answer"));
99     SetDlgItemText (dlg, IDC_CONFDELCLIP_INFO, _("Do you want to delete the contents from the clipboard?"));
100 twoaday 105 SetDlgItemText (dlg, IDYES, _("&Yes"));
101 twoaday 121 SetDlgItemText (dlg, IDNO, _("&No"));
102 werner 36 center_window (dlg, NULL);
103     SetForegroundWindow (dlg);
104     break;
105    
106     case WM_COMMAND:
107     switch (LOWORD (wparam)) {
108     case IDYES:
109     wipe_contents = 1;
110     if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN))
111     set_reg_winpt_flag ("WipeClipboard", 1);
112     EndDialog (dlg, TRUE);
113     break;
114    
115     case IDNO:
116     wipe_contents = 0;
117     if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN))
118     set_reg_winpt_flag ("WipeClipboard", 0);
119     EndDialog (dlg, FALSE);
120     break;
121     }
122     break;
123     }
124     return FALSE;
125     }
126    
127    
128     static gpgme_error_t
129     currwnd_gpg_dlg (HWND hwnd, UINT id, int *ret_set)
130     {
131 twoaday 68 gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);
132 werner 36 int type;
133    
134     if (ret_set)
135     *ret_set = 1;
136     switch (id) {
137     case ID_WINPT_CURRWND_SYMENC:
138     gpg_encrypt_symmetric ();
139     break;
140    
141     case ID_WINPT_CURRWND_ENCRYPT:
142     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd,
143 twoaday 68 clip_encrypt_dlg_proc, 0,
144 werner 36 _("Encryption"), IDS_WINPT_ENCRYPT );
145     break;
146    
147     case ID_WINPT_CURRWND_SIGNENCRYPT:
148     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd,
149 twoaday 68 clip_signenc_dlg_proc, 0,
150 werner 36 _("Sign & Encrypt"), IDS_WINPT_SIGNENC );
151     break;
152    
153     case ID_WINPT_CURRWND_SIGN:
154     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd,
155 twoaday 68 clip_sign_dlg_proc, 0,
156 werner 36 _("Signing"), IDS_WINPT_SIGN );
157     break;
158    
159     case ID_WINPT_CURRWND_DECRYPT_VERIFY:
160     err = gpg_clip_get_pgptype (&type);
161     if (err) {
162     msg_box (hwnd, gpgme_strerror (err), _("Clipboard"), MB_ERR);
163     break;
164     }
165     if( (type & PGP_MESSAGE) && !(type & PGP_CLEARSIG) ) {
166     /* It makes only sense to insert the data in the window if it's
167     really a ciphertext. Verfied data doesn't need this. */
168     err = clip_decrypt_dlg (hwnd);
169     if (!err && reg_prefs.use_viewer) {
170     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,
171 twoaday 68 GetDesktopWindow(), clip_edit_dlg_proc, 0,
172 werner 36 _("Clipboard Editor"), IDS_WINPT_CLIPEDIT);
173     if (ret_set)
174     *ret_set = 0;
175     }
176     }
177     else if ((type & PGP_PUBKEY) && !(type & PGP_CLEARSIG))
178 twoaday 165 km_clip_import (GetDesktopWindow (), NULL, NULL);
179 werner 36 else {
180     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,
181 twoaday 68 clip_verify_dlg_proc, 0,
182 werner 36 _("Verify"), IDS_WINPT_VERIFY );
183 twoaday 150 err = gpg_error (GPG_ERR_EOF); /* make sure window is not updated. */
184 werner 36 }
185     break;
186     }
187    
188     return err;
189     }
190    
191    
192     static void
193     clip_gpg_dlg (HWND hwnd, UINT id)
194     {
195     gpgme_error_t err;
196     int type;
197    
198 twoaday 129 if ((id == ID_WINPT_SIGN || id == ID_WINPT_SIGNENCRYPT)
199     && gnupg_access_keyring (0)) {
200     msg_box (hwnd, _("Could not access secret keyring."), _("Sign"), MB_ERR);
201 werner 36 return;
202     }
203    
204     switch( id ) {
205     case ID_WINPT_SYMENC:
206 twoaday 129 gpg_encrypt_symmetric ();
207 werner 36 break;
208    
209     case ID_WINPT_ENCRYPT:
210     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd,
211 twoaday 68 clip_encrypt_dlg_proc, 0,
212 werner 36 _("Encryption"), IDS_WINPT_ENCRYPT );
213     break;
214    
215     case ID_WINPT_SIGN:
216     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd,
217 twoaday 68 clip_sign_dlg_proc, 0,
218 werner 36 _("Signing"), IDS_WINPT_SIGN );
219     break;
220    
221     case ID_WINPT_SIGNENCRYPT:
222     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd,
223 twoaday 68 clip_signenc_dlg_proc, 0,
224 werner 36 _("Sign & Encrypt"), IDS_WINPT_SIGNENC );
225     break;
226    
227     case ID_WINPT_DECRYPT_VERIFY:
228     err = gpg_clip_get_pgptype (&type);
229     if (err) {
230     msg_box( hwnd, gpgme_strerror( err ), _("Clipboard"), MB_ERR );
231     break;
232     }
233     if( (type & PGP_MESSAGE) && !(type & PGP_CLEARSIG) ) {
234     err = clip_decrypt_dlg (hwnd);
235     if (!err && reg_prefs.use_viewer) {
236     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,
237 twoaday 68 GetDesktopWindow(), clip_edit_dlg_proc, 0,
238 werner 36 _("Clipboard Editor"), IDS_WINPT_CLIPEDIT );
239     }
240     }
241     else if( (type & PGP_SIG) && !(type & PGP_CLEARSIG) ) {
242     text_input_s input;
243     gpgme_data_t sig;
244    
245     memset( &input, 0, sizeof (input) );
246     err = gpg_data_new_from_clipboard (&sig, 0);
247     if( err ) {
248     msg_box( hwnd, gpgme_strerror( err ),_("Verify"), MB_ERR );
249     return;
250     }
251     input.type = 0;
252     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_TEXT, hwnd,
253     text_input_dlg_proc, (LPARAM)&input,
254     _("Text Input"), IDS_WINPT_TEXT );
255    
256     gpg_data_release_and_set_clipboard( sig, 0 );
257     if( input.length ) {
258     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,
259     clip_verify_dlg_proc, (LPARAM)&input,
260     _("Verify"), IDS_WINPT_VERIFY );
261     input.length = 0;
262     free_if_alloc( input.data );
263     }
264     }
265     else if (type & PGP_CLEARSIG) {
266     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,
267 twoaday 68 clip_verify_dlg_proc, 0,
268 werner 36 _("Verify"), IDS_WINPT_VERIFY );
269     }
270     else if ((type & PGP_PUBKEY) || (type & PGP_SECKEY))
271 twoaday 165 km_clip_import (GetDesktopWindow (), NULL, NULL);
272 werner 36 else
273     msg_box (hwnd, _("Unknown OpenPGP type."), _("Clipboard"), MB_ERR);
274     }
275 twoaday 72 }
276 werner 36
277    
278 twoaday 72 static bool
279     secret_key_available (void)
280     {
281     gpg_keycache_t sec = keycache_get_ctx (0);
282     if (!sec || gpg_keycache_get_size (sec) == 0)
283     return false;
284     return true;
285     }
286    
287    
288 werner 36 /* Load the Card Manager with the current card. */
289     static void
290 twoaday 121 load_card_manager (void)
291 werner 36 {
292     gpg_card_t card;
293    
294     card = gpg_card_load ();
295     if (card) {
296     dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_CARD_EDIT,
297     GetDesktopWindow (), card_edit_dlg_proc,
298     (LPARAM)card,
299     _("Card Edit"), IDS_WINPT_CARD_EDIT);
300 twoaday 121 gpg_card_release (card);
301 werner 36 }
302     }
303    
304    
305     /* Add the winpt symbol to the task bar. */
306     static void
307     add_taskbar_icon (HWND hwnd, NOTIFYICONDATA *nid)
308     {
309     nid->cbSize = sizeof (NOTIFYICONDATA);
310     nid->uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
311     nid->uCallbackMessage = WM_USER;
312     nid->hWnd = hwnd;
313     nid->hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_WINPT));
314     strcpy (nid->szTip, "Windows Privacy Tray v"PGM_VERSION);
315     Shell_NotifyIcon (NIM_ADD, nid);
316     DestroyIcon (nid->hIcon);
317     }
318    
319    
320     /* 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     INITCOMMONCONTROLSEX cce;
328 werner 36 LPARAM param;
329 twoaday 139 HWND wnd;
330     gpgme_error_t err;
331     curr_wnd_ctx currwnd = {0};
332     const char *s;
333 werner 36 int rc, set_wc = 0, has_data = 0;
334    
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     /* init common controls: date control. */
352     cce.dwSize = sizeof (INITCOMMONCONTROLSEX);
353     cce.dwICC = ICC_DATE_CLASSES;
354     InitCommonControlsEx (&cce);
355 twoaday 174 html_help_init (&cookie);
356 werner 36 LoadLibrary ("RichEd32.Dll");
357     break;
358    
359     case WM_ENDSESSION:
360     case WM_DESTROY:
361     case WM_CLOSE:
362     case WM_QUIT:
363 twoaday 185 /*cryptdisk_cleanup ();*/
364 werner 36 mapi_deinit ();
365     wsock_end ();
366     keycache_release (1);
367     gnupg_backup_keyrings ();
368     free_reg_prefs ();
369     free_gnupg_table ();
370     hotkeys_unregister (hwnd);
371     PTD_delete ();
372     agent_flush_cache ();
373 twoaday 174 html_help_deinit (cookie);
374 werner 36 if (!gpg_clip_istext_avail (&has_data) && has_data) {
375     int chk = get_reg_winpt_flag ("WipeClipboard");
376 twoaday 78 if (chk == -1 && msg != WM_ENDSESSION)
377 werner 36 DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CONFDELCLIP,
378     GetDesktopWindow (), confirm_delclipboard_dlg,
379 twoaday 68 0);
380 werner 36 if (wipe_contents || chk)
381     set_clip_text (NULL, " ", 1);
382     wipe_contents = 0;
383     }
384     debug_end ();
385     Shell_NotifyIcon (NIM_DELETE, &NID);
386     PostQuitMessage (0);
387     ExitProcess (0);
388 twoaday 72 break;
389 werner 36
390     case WM_USER:
391     switch (lparam) {
392     case WM_RBUTTONUP:
393     HMENU hm, popup;
394     POINT p;
395    
396     gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1;
397    
398     SetForegroundWindow (hwnd);
399     GetCursorPos (&p);
400     hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT));
401     popup = GetSubMenu (hm, 0);
402 twoaday 72
403 werner 36 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     if (!scard_support)
407     set_menu_state (popup, ID_WINPT_CARD, MF_DISABLED|MF_GRAYED);
408 twoaday 185 /*
409 werner 36 if (!cryptdisk_available ()) {
410     set_menu_state (popup, ID_WINPT_CDISKNEW, MF_DISABLED|MF_GRAYED);
411     set_menu_state (popup, ID_WINPT_CDISKMOUNT, MF_DISABLED|MF_GRAYED);
412     set_menu_state (popup, ID_WINPT_CDISKUNMOUNT, MF_DISABLED|MF_GRAYED);
413     }
414 twoaday 185 */
415 werner 36
416     set_menu_text (popup, ID_WINPT_EDIT, _("Edit Clipboard"));
417     set_menu_text (popup, ID_WINPT_ABOUT, _("About..."));
418     set_menu_text (popup, ID_WINPT_QUIT, _("Exit"));
419     set_menu_text (popup, ID_WINPT_SYMENC, _("Symmetric"));
420     set_menu_text (popup, ID_WINPT_ENCRYPT, _("Encrypt"));
421 twoaday 72 set_menu_text (popup, ID_WINPT_SIGN, _("Sign"));
422 werner 36 set_menu_text (popup, ID_WINPT_SIGNENCRYPT, _("Sign && Encrypt"));
423     set_menu_text (popup, ID_WINPT_DECRYPT, _("Decrypt/Verify"));
424     set_menu_text (popup, ID_WINPT_VERIFY, _("Verify"));
425     set_menu_text (popup, ID_WINPT_CURRWND_ENCRYPT, _("Encrypt"));
426     set_menu_text (popup, ID_WINPT_CURRWND_SIGNENCRYPT, _("Sign && Encrypt"));
427     set_menu_text (popup, ID_WINPT_CURRWND_DECRYPT_VERIFY, _("Decrypt/Verify"));
428     set_menu_text (popup, ID_WINPT_CURRWND_SIGN, _("Sign"));
429 twoaday 72 if (!secret_key_available ()) {
430     set_menu_state (popup, ID_WINPT_SIGN, MF_DISABLED|MF_GRAYED);
431     set_menu_state (popup, ID_WINPT_CURRWND_SIGN, MF_DISABLED|MF_GRAYED);
432     set_menu_state (popup, ID_WINPT_SIGNENCRYPT, MF_DISABLED|MF_GRAYED);
433     set_menu_state (popup, ID_WINPT_CURRWND_SIGNENCRYPT, MF_DISABLED|MF_GRAYED);
434     }
435 werner 36 /* change popup texts */
436     set_menu_text_bypos (popup, 6, _("Clipboard"));
437     set_menu_text_bypos (popup, 7, _("Current Window"));
438     set_menu_text_bypos (popup, 9, _("Preferences"));
439    
440 twoaday 72 TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL);
441     PostMessage (hwnd, WM_USER, 0, 0);
442     DestroyMenu (popup);
443     DestroyMenu (hm);
444 werner 36 break;
445    
446     case WM_LBUTTONDBLCLK:
447 twoaday 78 gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1;
448     SendMessage (hwnd, WM_COMMAND, ID_WINPT_KEY, 0);
449 werner 36 break;
450     }
451     break;
452    
453     case WM_HOTKEY:
454     cmd = 0;
455     switch( wparam ) {
456     case WPT_CLIP_ENCRYPT_ID:
457     SendMessage( hwnd, WM_COMMAND, ID_WINPT_ENCRYPT, 0 );
458     break;
459    
460     case WPT_CLIP_DECRYPT_VERIFY_ID:
461     SendMessage( hwnd, WM_COMMAND, ID_WINPT_DECRYPT_VERIFY, 0 );
462     break;
463    
464     case WPT_CLIP_SIGN_ID:
465     SendMessage( hwnd, WM_COMMAND, ID_WINPT_SIGN, 0 );
466     break;
467    
468     case WPT_CLIP_SIGN_ENCRYPT_ID:
469     SendMessage( hwnd, WM_COMMAND, ID_WINPT_SIGNENCRYPT, 0 );
470     break;
471    
472     case WPT_CURRWND_ENCRYPT_ID:
473     use_hotkey = 1;
474     SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_ENCRYPT, 0 );
475     break;
476    
477     case WPT_CURRWND_SIGN_ID:
478     use_hotkey = 1;
479     SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_SIGN, 0 );
480     break;
481    
482     case WPT_CURRWND_SIGN_ENCRYPT_ID:
483     use_hotkey = 1;
484     SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_SIGNENCRYPT, 0 );
485     break;
486    
487     case WPT_CURRWND_DECRYPT_VERIFY_ID:
488     use_hotkey = 1;
489     SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_DECRYPT_VERIFY, 0 );
490     break;
491    
492     case WPT_AGENT_FORGET_ID:
493     rc = msg_box( hwnd, _("Remove all passphrases from cache?"),
494     _("WinPT"), MB_YESNO|MB_ICONQUESTION );
495     if( rc == IDYES )
496     agent_flush_cache();
497     break;
498     }
499     break;
500    
501     case WM_COMMAND:
502     if( gnupg_access_keyring( 1 ) ) {
503     if( log_box( "WinPT", MB_ERR|MB_YESNO,
504     _("Could not access public keyring, exit WinPT?") ) == IDYES )
505     SendMessage( hwnd, WM_DESTROY, 0, 0 );
506     break;
507     }
508     switch( wparam ) {
509     /** Clipboard operations **/
510     case ID_WINPT_SYMENC:
511     case ID_WINPT_ENCRYPT:
512     case ID_WINPT_SIGN:
513     case ID_WINPT_SIGNENCRYPT:
514     case ID_WINPT_DECRYPT_VERIFY:
515     err = gpg_clip_istext_avail( &has_data );
516     if( err ) {
517     msg_box( hwnd, gpgme_strerror( err ),_("Clipboard"), MB_ERR );
518     break;
519     }
520     if( !has_data ) {
521     msg_box( hwnd, winpt_strerror (WPTERR_CLIP_EMPTY),_("Clipboard"), MB_ERR );
522     break;
523     }
524 twoaday 129 clip_gpg_dlg (hwnd, (int)wparam);
525 werner 36 break;
526    
527     /** Current window operations **/
528     case ID_WINPT_CURRWND_SYMENC:
529     case ID_WINPT_CURRWND_ENCRYPT:
530     case ID_WINPT_CURRWND_SIGNENCRYPT:
531     case ID_WINPT_CURRWND_DECRYPT_VERIFY:
532     case ID_WINPT_CURRWND_SIGN:
533     rc = get_window_contents( hwnd, &currwnd, &use_hotkey );
534     if( rc ) {
535     log_box( _("WinPT Error"), MB_ERR,
536     _("Make sure that the window contains text.\n"
537     "%s."),
538     winpt_strerror( WPTERR_CURR_WND ) );
539     break;
540     }
541 twoaday 129 rc = currwnd_gpg_dlg (hwnd, (UINT)wparam, &set_wc);
542     if (!rc && set_wc)
543     set_window_contents (hwnd, &currwnd);
544 werner 36 break;
545    
546     /** File handling **/
547     case ID_WINPT_FILE:
548 twoaday 139 s = _("File Manager (use drag & drop to add files)");
549     wnd = FindWindow (NULL, s);
550     if (wnd && IsIconic (wnd))
551     ShowWindow (wnd, SW_RESTORE);
552     dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_FILE,
553     GetDesktopWindow (), file_manager_dlg_proc, 0,
554     s, IDS_WINPT_FILE);
555 werner 36 break;
556    
557     /** Misc **/
558     case ID_WINPT_KEY:
559 twoaday 139 wnd = FindWindow (NULL, _("Key Manager"));
560     if (wnd && IsIconic (wnd))
561     ShowWindow (wnd, SW_RESTORE);
562 twoaday 180 if (wnd)
563     SetForegroundWindow (wnd);
564 twoaday 73 param = 0;
565 twoaday 139 if (cmd)
566 werner 36 param = (LPARAM)cmd;
567 twoaday 139 dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYMISC,
568 werner 36 GetDesktopWindow(), keymanager_dlg_proc, param,
569 twoaday 139 _("Key Manager"), IDS_WINPT_KEYMISC);
570 werner 36 cmd = 0;
571     break;
572    
573     case ID_WINPT_CARD:
574 twoaday 121 load_card_manager ();
575 werner 36 break;
576    
577     case ID_WINPT_EDIT:
578     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,
579 twoaday 68 GetDesktopWindow(), clip_edit_dlg_proc, 0,
580 werner 36 _("Clipboard Editor"), IDS_WINPT_CLIPEDIT );
581     break;
582    
583     case ID_WINPT_ABOUT:
584     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ABOUT, GetDesktopWindow(),
585 twoaday 68 about_winpt_dlg_proc, 0,
586 werner 36 _("About WinPT"), IDS_WINPT_ABOUT );
587     break;
588    
589     case ID_WINPT_PREFS:
590     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_PREFS, GetDesktopWindow(),
591 twoaday 68 prefs_dlg_proc, 0,
592 werner 36 _("WinPT Preferences"), IDS_WINPT_PREFS );
593     break;
594    
595     case ID_WINPT_GPGPREFS:
596 twoaday 190 rc = dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS,
597     GetDesktopWindow(), gpgprefs_dlg_proc, 0,
598 werner 36 _("GnuPG Preferences"), IDS_WINPT_GPGPREFS);
599 twoaday 190 if (rc == TRUE)
600     update_keycache (GetDesktopWindow ());
601 werner 36 break;
602    
603 twoaday 185 /*
604 werner 36 case ID_WINPT_CDISKNEW:
605     DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_NEW,
606 twoaday 68 GetDesktopWindow (), cryptdisk_new_dlg_proc, 0);
607 werner 36 break;
608    
609     case ID_WINPT_CDISKMOUNT:
610     DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_MOUNT,
611 twoaday 68 GetDesktopWindow (), cryptdisk_mount_dlg_proc, 0);
612 werner 36 break;
613    
614     case ID_WINPT_CDISKUNMOUNT:
615     DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_UMOUNT,
616 twoaday 68 GetDesktopWindow (), cryptdisk_umount_dlg_proc, 0);
617 werner 36 break;
618    
619     case ID_WINPT_CDISKUMOUNTALL:
620     cryptdisk_unmount (0, 0);
621     break;
622 twoaday 185 */
623 werner 36
624     case ID_WINPT_QUIT:
625     SendMessage (hwnd, WM_DESTROY, 0, 0);
626     break;
627     }
628     break;
629     }
630    
631     return DefWindowProc (hwnd, msg, wparam, lparam);
632     }

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26