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

Annotation of /trunk/Src/wptMainProc.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25 - (hide annotations)
Wed Oct 12 10:04:26 2005 UTC (19 years, 4 months ago) by twoaday
File size: 20388 byte(s)
First testing phase finished.
Provide bug fixes for a lot of (minor) problems.

1 twoaday 2 /* wptMainProc.cpp - Main window procedure
2     * Copyright (C) 2000-2005 Timo Schulz
3     *
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     #include <windows.h>
22     #include <commctrl.h>
23     #include <io.h>
24    
25     #include "../resource.h"
26     #include "wptTypes.h"
27     #include "wptGPG.h"
28     #include "wptW32API.h"
29     #include "wptVersion.h"
30     #include "wptCommonCtl.h"
31     #include "wptContext.h" /* for passphrase_s */
32     #include "wptDlgs.h"
33     #include "wptErrors.h"
34     #include "wptNLS.h"
35     #include "wptHotkey.h"
36     #include "wptRegistry.h"
37     #include "wptKeyserver.h"
38     #include "wptAgent.h"
39     #include "wptKeyManager.h"
40     #include "wptCard.h"
41     #include "wptCryptdisk.h"
42 twoaday 23 #include "wptCardEdit.h"
43 twoaday 2
44     extern HWND activ_hwnd;
45     static int cmd = 0;
46     static int wipe_contents = 0;
47    
48    
49 twoaday 25 /* Dialog box procedure to display all insecure all ElGamal keys. */
50 twoaday 2 BOOL CALLBACK
51     elgamal_warn_dlg_proc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam )
52     {
53 twoaday 25 gpg_keycache_t pc;
54 twoaday 2 gpgme_key_t key;
55 twoaday 25 char tmp[128+64+1];
56 twoaday 2
57     switch( msg ) {
58     case WM_INITDIALOG:
59 twoaday 25 pc = keycache_get_ctx (1);
60     while (!gpg_keycache_next_key (pc, 0, &key)) {
61     if (key->subkeys->pubkey_algo == GPGME_PK_ELG) {
62     _snprintf (tmp, sizeof (tmp)-1, "(0x%s) %s",
63 twoaday 23 key->subkeys->keyid+8, key->uids->uid);
64 twoaday 2 SendDlgItemMessage( dlg, IDC_ELGWARN_LIST, LB_ADDSTRING,
65     0, (LPARAM)(const char *) tmp );
66     }
67     }
68 twoaday 25 gpg_keycache_rewind (pc);
69     center_window (dlg, NULL);
70     SetForegroundWindow (dlg);
71 twoaday 2 break;
72    
73     case WM_COMMAND:
74 twoaday 25 switch (LOWORD (wparam)) {
75 twoaday 2 case IDOK:
76 twoaday 25 EndDialog (dlg, TRUE);
77 twoaday 2 break;
78     }
79     break;
80     }
81     return FALSE;
82 twoaday 25 }
83 twoaday 2
84    
85 twoaday 25
86     static int
87 twoaday 2 cleanup_tmp_files (void)
88     {
89     struct _finddata_t dat;
90     char tmp[384];
91     long hd;
92    
93     if (GetTempPath (sizeof (tmp)-1, tmp) == FALSE ||
94     SetCurrentDirectory (tmp) == FALSE) {
95     winpt_errmsg ("GetTempPath", 0);
96 twoaday 25 return WPTERR_GENERAL;
97 twoaday 2 }
98     hd = _findfirst ("gpgmeOUT*", &dat);
99     if (hd == -1)
100 twoaday 25 return 0;
101 twoaday 2 do {
102     secure_unlink (dat.name, WIPE_MODE_SIMPLE);
103     } while (_findnext (hd, &dat) == 0);
104     _findclose (hd);
105 twoaday 25 return 0;
106 twoaday 2 }
107    
108    
109 twoaday 25 /* Dialog box procedure to confirm to delete the clipboard contents. */
110 twoaday 2 static BOOL CALLBACK
111     confirm_delclipboard_dlg (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
112     {
113     switch (msg) {
114     case WM_INITDIALOG:
115 twoaday 23 center_window (dlg, NULL);
116 twoaday 2 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     EndDialog (dlg, TRUE);
126     break;
127    
128     case IDNO:
129     wipe_contents = 0;
130     if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN))
131     set_reg_winpt_flag ("WipeClipboard", 0);
132     EndDialog (dlg, FALSE);
133     break;
134     }
135     break;
136     }
137     return FALSE;
138 twoaday 25 }
139 twoaday 2
140    
141 twoaday 23 static gpgme_error_t
142 twoaday 2 currwnd_gpg_dlg (HWND hwnd, UINT id, int *ret_set)
143     {
144     gpgme_error_t err;
145 twoaday 25 gpg_pgptype_t type;
146 twoaday 2
147 twoaday 25 if (ret_set)
148 twoaday 2 *ret_set = 1;
149 twoaday 25 switch (id) {
150 twoaday 2 case ID_WINPT_CURRWND_SYMENC:
151 twoaday 24 gpg_encrypt_symmetric ();
152 twoaday 2 break;
153    
154     case ID_WINPT_CURRWND_ENCRYPT:
155     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd,
156     clip_encrypt_dlg_proc, NULL,
157     _("Encryption"), IDS_WINPT_ENCRYPT );
158     break;
159    
160     case ID_WINPT_CURRWND_SIGNENCRYPT:
161     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd,
162     clip_signenc_dlg_proc, NULL,
163     _("Sign & Encrypt"), IDS_WINPT_SIGNENC );
164     break;
165    
166     case ID_WINPT_CURRWND_SIGN:
167     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd,
168     clip_sign_dlg_proc, NULL,
169     _("Signing"), IDS_WINPT_SIGN );
170     break;
171    
172     case ID_WINPT_CURRWND_DECRYPT_VERIFY:
173 twoaday 25 err = gpg_clip_get_pgptype (&type);
174     if (err) {
175     msg_box (hwnd, gpgme_strerror (err), _("Clipboard"), MB_ERR);
176 twoaday 2 break;
177     }
178 twoaday 23 if( (type & PGP_MESSAGE) && !(type & PGP_CLEARSIG) ) {
179 twoaday 2 /* It makes only sense to insert the data in the window if it's
180     really a ciphertext. Verfied data doesn't need this. */
181 twoaday 23 err = clip_decrypt_dlg (hwnd);
182     if (!err && reg_prefs.use_viewer) {
183 twoaday 2 dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,
184     GetDesktopWindow(), clip_edit_dlg_proc, NULL,
185 twoaday 23 _("Clipboard Editor"), IDS_WINPT_CLIPEDIT);
186     if (ret_set)
187 twoaday 2 *ret_set = 0;
188     }
189     }
190 twoaday 23 else if ((type & PGP_PUBKEY) && !(type & PGP_CLEARSIG))
191 twoaday 2 km_clip_import (GetDesktopWindow ());
192     else {
193     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,
194     clip_verify_dlg_proc, NULL,
195     _("Verify"), IDS_WINPT_VERIFY );
196 twoaday 23 err = gpg_error (GPG_ERR_EOF); /* make sure window is ot updated. */
197 twoaday 2 }
198     break;
199     }
200    
201 twoaday 23 return err;
202 twoaday 25 }
203 twoaday 2
204    
205     static void
206 twoaday 25 clip_gpg_dlg (HWND hwnd, UINT id)
207 twoaday 2 {
208 twoaday 23 gpgme_error_t err;
209 twoaday 25 gpg_pgptype_t type;
210 twoaday 23 size_t size = 0;
211 twoaday 2
212     if( (id == ID_WINPT_SIGN || id == ID_WINPT_SIGNENCRYPT)
213     && gnupg_access_keyring (0) ) {
214     msg_box( hwnd, _("Could not access secret keyring."), _("Sign"), MB_ERR );
215     return;
216     }
217    
218     switch( id ) {
219     case ID_WINPT_SYMENC:
220 twoaday 24 gpg_encrypt_symmetric();
221 twoaday 2 break;
222    
223     case ID_WINPT_ENCRYPT:
224     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd,
225     clip_encrypt_dlg_proc, NULL,
226     _("Encryption"), IDS_WINPT_ENCRYPT );
227     break;
228    
229     case ID_WINPT_SIGN:
230     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd,
231     clip_sign_dlg_proc, NULL,
232     _("Signing"), IDS_WINPT_SIGN );
233     break;
234    
235     case ID_WINPT_SIGNENCRYPT:
236     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd,
237     clip_signenc_dlg_proc, NULL,
238     _("Sign & Encrypt"), IDS_WINPT_SIGNENC );
239     break;
240    
241     case ID_WINPT_DECRYPT_VERIFY:
242 twoaday 25 err = gpg_clip_get_pgptype (&type);
243     if (err) {
244 twoaday 23 msg_box( hwnd, gpgme_strerror( err ), _("Clipboard"), MB_ERR );
245 twoaday 2 break;
246     }
247 twoaday 23 if( (type & PGP_MESSAGE) && !(type & PGP_CLEARSIG) ) {
248     err = clip_decrypt_dlg (hwnd);
249     if (!err && reg_prefs.use_viewer) {
250 twoaday 2 dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,
251     GetDesktopWindow(), clip_edit_dlg_proc, NULL,
252     _("Clipboard Editor"), IDS_WINPT_CLIPEDIT );
253     }
254     }
255 twoaday 23 else if( (type & PGP_SIG) && !(type & PGP_CLEARSIG) ) {
256 twoaday 2 text_input_s input;
257     gpgme_data_t sig;
258    
259     memset( &input, 0, sizeof (input) );
260 twoaday 23 err = gpg_data_new_from_clipboard (&sig, 0);
261     if( err ) {
262     msg_box( hwnd, gpgme_strerror( err ),_("Verify"), MB_ERR );
263 twoaday 2 return;
264     }
265     input.type = 0;
266     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_TEXT, hwnd,
267     text_input_dlg_proc, (LPARAM)&input,
268     _("Text Input"), IDS_WINPT_TEXT );
269    
270 twoaday 23 gpg_data_release_and_set_clipboard( sig, 0 );
271 twoaday 2 if( input.length ) {
272     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,
273     clip_verify_dlg_proc, (LPARAM)&input,
274     _("Verify"), IDS_WINPT_VERIFY );
275     input.length = 0;
276     free_if_alloc( input.data );
277     }
278     }
279 twoaday 23 else if (type & PGP_CLEARSIG) {
280 twoaday 2 dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,
281     clip_verify_dlg_proc, NULL,
282     _("Verify"), IDS_WINPT_VERIFY );
283     }
284 twoaday 23 else if ((type & PGP_PUBKEY) || (type & PGP_SECKEY))
285 twoaday 2 km_clip_import (GetDesktopWindow ());
286     else
287     msg_box (hwnd, _("Unknown OpenPGP type."), _("Clipboard"), MB_ERR);
288     }
289     } /* clip_gpg_dlg */
290    
291    
292 twoaday 23 gpg_card_t
293 twoaday 2 smartcard_init (void)
294     {
295     /*
296     pcsc_loadlib (scard_support);
297     rc = show_card_status ();
298     if( rc )
299     break;
300     */
301     return gpg_load_scard ();
302 twoaday 25 }
303 twoaday 2
304    
305 twoaday 25 /* 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 twoaday 2 LRESULT CALLBACK
322     winpt_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
323     {
324     static NOTIFYICONDATA NID;
325     static int use_hotkey = 0;
326     reminder_ctx_s ctx;
327     LPARAM param;
328     curr_wnd_ctx currwnd = {0};
329     size_t size = 0;
330     int rc, set_wc = 0, has_data = 0;
331     INITCOMMONCONTROLSEX cce;
332 twoaday 23 gpgme_error_t err;
333     gpg_card_t card;
334 twoaday 2
335 twoaday 25 switch (msg) {
336 twoaday 2 case WM_CREATE:
337 twoaday 25 add_taskbar_icon (hwnd, &NID);
338 twoaday 2 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 twoaday 25 msg_box (hwnd, _("Could not set current window mode hooks."),
349     _("WinPT Error"), MB_OK);
350 twoaday 2 mapi_init ();
351     /* init common controls: date control. */
352     cce.dwSize = sizeof (INITCOMMONCONTROLSEX);
353     cce.dwICC = ICC_DATE_CLASSES;
354     InitCommonControlsEx (&cce);
355     LoadLibrary ("RichEd32.Dll");
356     break;
357    
358 twoaday 20 case WM_ENDSESSION:
359 twoaday 2 case WM_DESTROY:
360     case WM_CLOSE:
361 twoaday 20 case WM_QUIT:
362 twoaday 2 cryptdisk_cleanup ();
363     mapi_deinit ();
364     wsock_end ();
365 twoaday 25 keycache_release (1);
366 twoaday 2 gnupg_backup_keyrings ();
367     free_reg_prefs ();
368     free_gnupg_table ();
369     hotkeys_unregister (hwnd);
370     release_file_lock (&mo_file);
371     PTD_delete ();
372     agent_flush_cache ();
373 twoaday 25 if (!gpg_clip_istext_avail (&has_data) && has_data) {
374 twoaday 2 int chk = get_reg_winpt_flag ("WipeClipboard");
375     if (chk == -1)
376     DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CONFDELCLIP,
377     GetDesktopWindow (), confirm_delclipboard_dlg,
378     NULL);
379     if (wipe_contents || chk)
380     set_clip_text (NULL, " ", 1);
381     wipe_contents = 0;
382     }
383     cleanup_tmp_files ();
384     Shell_NotifyIcon (NIM_DELETE, &NID);
385     PostQuitMessage (0);
386     ExitProcess (0);
387     return 0;
388    
389     case WM_USER:
390     switch (lparam) {
391     case WM_RBUTTONUP:
392     HMENU hm, popup;
393     POINT p;
394    
395     gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1;
396    
397     SetForegroundWindow (hwnd);
398     GetCursorPos (&p);
399     hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT));
400     popup = GetSubMenu (hm, 0);
401     #ifndef LANG_DE
402     set_menu_text( popup, ID_WINPT_FILE, _("File Manager") );
403     set_menu_text( popup, ID_WINPT_KEY, _("Key Manager") );
404     set_menu_text( popup, ID_WINPT_CARD, _("Card Manager") );
405     if (!scard_support)
406     set_menu_state (popup, ID_WINPT_CARD, MF_DISABLED|MF_GRAYED);
407     if (!cryptdisk_available ()) {
408     set_menu_state (popup, ID_WINPT_CDISKNEW, MF_DISABLED|MF_GRAYED);
409     set_menu_state (popup, ID_WINPT_CDISKMOUNT, MF_DISABLED|MF_GRAYED);
410     set_menu_state (popup, ID_WINPT_CDISKUNMOUNT, MF_DISABLED|MF_GRAYED);
411     }
412    
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     #if 0
418     set_menu_text( popup, ID_WINPT_ENCRYPT, _("Encrypt") );
419     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     #endif
427     #endif
428     TrackPopupMenu( popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL );
429     PostMessage( hwnd, WM_USER, 0, 0 );
430     DestroyMenu( popup );
431     DestroyMenu( hm );
432     break;
433    
434     case WM_LBUTTONDBLCLK:
435     SendMessage( hwnd, WM_COMMAND, ID_WINPT_KEY, 0 );
436     break;
437     }
438     break;
439    
440     case WM_HOTKEY:
441     cmd = 0;
442     switch( wparam ) {
443     case WPT_CLIP_ENCRYPT_ID:
444     SendMessage( hwnd, WM_COMMAND, ID_WINPT_ENCRYPT, 0 );
445     break;
446    
447     case WPT_CLIP_DECRYPT_VERIFY_ID:
448     SendMessage( hwnd, WM_COMMAND, ID_WINPT_DECRYPT_VERIFY, 0 );
449     break;
450    
451     case WPT_CLIP_SIGN_ID:
452     SendMessage( hwnd, WM_COMMAND, ID_WINPT_SIGN, 0 );
453     break;
454    
455     case WPT_CLIP_SIGN_ENCRYPT_ID:
456     SendMessage( hwnd, WM_COMMAND, ID_WINPT_SIGNENCRYPT, 0 );
457     break;
458    
459     case WPT_CURRWND_ENCRYPT_ID:
460     use_hotkey = 1;
461     SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_ENCRYPT, 0 );
462     break;
463    
464     case WPT_CURRWND_SIGN_ID:
465     use_hotkey = 1;
466     SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_SIGN, 0 );
467     break;
468    
469     case WPT_CURRWND_SIGN_ENCRYPT_ID:
470     use_hotkey = 1;
471     SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_SIGNENCRYPT, 0 );
472     break;
473    
474     case WPT_CURRWND_DECRYPT_VERIFY_ID:
475     use_hotkey = 1;
476     SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_DECRYPT_VERIFY, 0 );
477     break;
478    
479     case WPT_AGENT_FORGET_ID:
480     rc = msg_box( hwnd, _("Remove all passphrases from cache?"),
481     _("WinPT"), MB_YESNO|MB_ICONQUESTION );
482     if( rc == IDYES )
483     agent_flush_cache();
484     break;
485     }
486     break;
487    
488     case WM_COMMAND:
489     if( gnupg_access_keyring( 1 ) ) {
490     if( log_box( "WinPT", MB_ERR|MB_YESNO,
491     _("Could not access public keyring, exit WinPT?") ) == IDYES )
492     SendMessage( hwnd, WM_DESTROY, 0, 0 );
493     break;
494     }
495     switch( wparam ) {
496     /** Clipboard operations **/
497     case ID_WINPT_SYMENC:
498     case ID_WINPT_ENCRYPT:
499     case ID_WINPT_SIGN:
500     case ID_WINPT_SIGNENCRYPT:
501     case ID_WINPT_DECRYPT_VERIFY:
502 twoaday 25 err = gpg_clip_istext_avail( &has_data );
503 twoaday 23 if( err ) {
504     msg_box( hwnd, gpgme_strerror( err ),_("Clipboard"), MB_ERR );
505 twoaday 2 break;
506     }
507     if( !has_data ) {
508 twoaday 23 msg_box( hwnd, winpt_strerror (WPTERR_CLIP_EMPTY),_("Clipboard"), MB_ERR );
509 twoaday 2 break;
510     }
511     ctx.msecs = 500;
512     window_reminder( &ctx );
513     clip_gpg_dlg( hwnd, (int)wparam );
514     break;
515    
516     /** Current window operations **/
517     case ID_WINPT_CURRWND_SYMENC:
518     case ID_WINPT_CURRWND_ENCRYPT:
519     case ID_WINPT_CURRWND_SIGNENCRYPT:
520     case ID_WINPT_CURRWND_DECRYPT_VERIFY:
521     case ID_WINPT_CURRWND_SIGN:
522     rc = get_window_contents( hwnd, &currwnd, &use_hotkey );
523     if( rc ) {
524     log_box( _("WinPT Error"), MB_ERR,
525     _("Make sure that the window contains text.\n"
526     "%s."),
527     winpt_strerror( WPTERR_CURR_WND ) );
528     break;
529     }
530     ctx.msecs = 500;
531     window_reminder( &ctx );
532     rc = currwnd_gpg_dlg( hwnd, (UINT)wparam, &set_wc );
533     if( !rc && set_wc )
534     set_window_contents( hwnd, &currwnd );
535     break;
536    
537     /** File handling **/
538     case ID_WINPT_FILE:
539     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_FILE,
540     GetDesktopWindow(), file_manager_dlg_proc, NULL,
541     _("File Manager (use drag & drop to add files)"), IDS_WINPT_FILE );
542     break;
543    
544     /** Misc **/
545     case ID_WINPT_KEY:
546     param = NULL;
547     if( cmd )
548     param = (LPARAM)cmd;
549     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYMISC,
550     GetDesktopWindow(), keymanager_dlg_proc, param,
551     _("Key Manager"), IDS_WINPT_KEYMISC );
552     cmd = 0;
553     break;
554    
555     case ID_WINPT_CARD:
556     card = smartcard_init ();
557     if( card ) {
558     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CARD_EDIT,
559     GetDesktopWindow(), card_edit_dlg_proc,
560     (LPARAM)card,
561     _("Card Edit"), IDS_WINPT_CARD_EDIT );
562 twoaday 23 gpg_card_release( card ); card = NULL;
563 twoaday 2 }
564     break;
565    
566     case ID_WINPT_EDIT:
567     dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,
568     GetDesktopWindow(), clip_edit_dlg_proc, NULL,
569     _("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     about_winpt_dlg_proc, NULL,
575     _("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     prefs_dlg_proc, NULL,
581     _("WinPT Preferences"), IDS_WINPT_PREFS );
582     break;
583    
584     case ID_WINPT_GPGPREFS:
585 twoaday 25 dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS, GetDesktopWindow(),
586 twoaday 2 gpgprefs_dlg_proc, NULL,
587 twoaday 25 _("GnuPG Preferences"), IDS_WINPT_GPGPREFS);
588 twoaday 2 break;
589    
590     case ID_WINPT_CDISKNEW:
591     DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_NEW,
592     GetDesktopWindow (), cryptdisk_new_dlg_proc, NULL);
593     break;
594    
595     case ID_WINPT_CDISKMOUNT:
596     DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_MOUNT,
597     GetDesktopWindow (), cryptdisk_mount_dlg_proc, NULL);
598     break;
599    
600     case ID_WINPT_CDISKUNMOUNT:
601     DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_UMOUNT,
602     GetDesktopWindow (), cryptdisk_umount_dlg_proc, NULL);
603     break;
604    
605     case ID_WINPT_CDISKUMOUNTALL:
606     cryptdisk_unmount (0, 0);
607     break;
608    
609     case ID_WINPT_QUIT:
610     SendMessage (hwnd, WM_DESTROY, 0, 0);
611     break;
612     }
613     break;
614     }
615    
616     return DefWindowProc (hwnd, msg, wparam, lparam);
617     } /* winpt_main_proc */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26