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

Annotation of /trunk/Src/wptMainProc.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26