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

Legend:
Removed from v.23  
changed lines
  Added in v.72

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26