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

Diff of /trunk/Src/wptMainProc.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.25  
changed lines
  Added in v.105

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26