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

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26