/[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 200 by twoaday, Mon Apr 17 09:12:50 2006 UTC revision 262 by twoaday, Sat Sep 30 10:24:34 2006 UTC
# Line 22  Line 22 
22  #include <config.h>  #include <config.h>
23  #endif  #endif
24    
25    #define _WIN32_IE 0x0600
26    
27  #include <windows.h>  #include <windows.h>
28  #include <commctrl.h>  #include <commctrl.h>
29  #include <io.h>  #include <io.h>
# Line 40  Line 42 
42  #include "wptRegistry.h"  #include "wptRegistry.h"
43  #include "wptKeyserver.h"  #include "wptKeyserver.h"
44  #include "wptAgent.h"  #include "wptAgent.h"
45    #include "wptUTF8.h"
46  #include "wptKeyManager.h"  #include "wptKeyManager.h"
47  #include "wptCard.h"  #include "wptCard.h"
 #include "wptCryptdisk.h"  
48  #include "wptCardEdit.h"  #include "wptCardEdit.h"
49    
50    
51  void update_keycache (HWND hwnd);  int update_keycache (HWND hwnd);
52    
53    /* Command for the Key Manager dialog. (0=no command) */
54  static int cmd = 0;  static int cmd = 0;
55    
56    /* 1 indicates that the clipboard will be emptied o exit. */
57  static int wipe_contents = 0;  static int wipe_contents = 0;
58    
59    
# Line 58  elgamal_warn_dlg_proc (HWND dlg, UINT ms Line 63  elgamal_warn_dlg_proc (HWND dlg, UINT ms
63  {  {
64      gpg_keycache_t pc;      gpg_keycache_t pc;
65      gpgme_key_t key;      gpgme_key_t key;
66        char *uid;
67      char tmp[128+64+1];      char tmp[128+64+1];
68    
69      switch (msg) {      switch (msg) {
# Line 65  elgamal_warn_dlg_proc (HWND dlg, UINT ms Line 71  elgamal_warn_dlg_proc (HWND dlg, UINT ms
71          pc = keycache_get_ctx (1);          pc = keycache_get_ctx (1);
72          while (!gpg_keycache_next_key (pc, 0, &key)) {          while (!gpg_keycache_next_key (pc, 0, &key)) {
73              if (key->subkeys->pubkey_algo == GPGME_PK_ELG) {              if (key->subkeys->pubkey_algo == GPGME_PK_ELG) {
74                    uid = utf8_to_native (key->uids->uid);
75                  _snprintf (tmp, sizeof (tmp)-1, "(0x%s) %s",                  _snprintf (tmp, sizeof (tmp)-1, "(0x%s) %s",
76                             key->subkeys->keyid+8, key->uids->uid);                             key->subkeys->keyid+8, uid);
77                  SendDlgItemMessage (dlg, IDC_ELGWARN_LIST, LB_ADDSTRING,                  SendDlgItemMessage (dlg, IDC_ELGWARN_LIST, LB_ADDSTRING,
78                                      0, (LPARAM)(const char *) tmp);                                      0, (LPARAM)(const char *)tmp);
79                    free_if_alloc (uid);
80              }              }
81          }          }
82          gpg_keycache_rewind (pc);          gpg_keycache_rewind (pc);
# Line 95  confirm_delclipboard_dlg (HWND dlg, UINT Line 103  confirm_delclipboard_dlg (HWND dlg, UINT
103      switch (msg) {      switch (msg) {
104      case WM_INITDIALOG:      case WM_INITDIALOG:
105          SetWindowText (dlg, _("Delete Clipboard Contents"));          SetWindowText (dlg, _("Delete Clipboard Contents"));
106          SetDlgItemText (dlg, IDC_CONFDELCLIP_BRAIN, _("&Remember the answer"));          SetDlgItemText (dlg, IDC_CONFDELCLIP_BRAIN,
107          SetDlgItemText (dlg, IDC_CONFDELCLIP_INFO, _("Do you want to delete the contents from the clipboard?"));                          _("&Remember the answer"));
108            SetDlgItemText (dlg, IDC_CONFDELCLIP_INFO,
109                            _("Do you want to delete the contents from the clipboard?"));
110          SetDlgItemText (dlg, IDYES, _("&Yes"));          SetDlgItemText (dlg, IDYES, _("&Yes"));
111          SetDlgItemText (dlg, IDNO, _("&No"));          SetDlgItemText (dlg, IDNO, _("&No"));
112          center_window (dlg, NULL);          center_window (dlg, NULL);
# Line 109  confirm_delclipboard_dlg (HWND dlg, UINT Line 119  confirm_delclipboard_dlg (HWND dlg, UINT
119              wipe_contents = 1;              wipe_contents = 1;
120              if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN))              if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN))
121                  set_reg_winpt_flag ("WipeClipboard", 1);                  set_reg_winpt_flag ("WipeClipboard", 1);
122              EndDialog (dlg, TRUE);              EndDialog (dlg, 1);
123              break;              break;
124    
125          case IDNO:          case IDNO:
126              wipe_contents = 0;              wipe_contents = 0;
127              if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN))              if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN))
128                  set_reg_winpt_flag ("WipeClipboard", 0);                  set_reg_winpt_flag ("WipeClipboard", 0);
129              EndDialog (dlg, FALSE);              EndDialog (dlg, 0);
130              break;              break;
131          }          }
132          break;          break;
# Line 125  confirm_delclipboard_dlg (HWND dlg, UINT Line 135  confirm_delclipboard_dlg (HWND dlg, UINT
135  }  }
136    
137    
138  static gpgme_error_t  /* Handle the various command requests for the clipboard
139  currwnd_gpg_dlg (HWND hwnd, UINT id, int *ret_set)     and the current window. */
140    static void
141    clip_gpg_dlg (HWND hwnd, UINT id, int *r_upd_window)
142  {  {
143      gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);      gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);
144      int type;      int type;
145        int disable_viewer = 0;
146            
147      if (ret_set)      if (r_upd_window) {
148          *ret_set = 1;          *r_upd_window = 1;
149      switch (id) {          /* for the current window mode it makes no sense to
150      case ID_WINPT_CURRWND_SYMENC:             use the clipboard viewer for decryption because the
151          gpg_encrypt_symmetric ();             text will be pasted directly into the window. */
152          break;          disable_viewer = 1;
   
     case ID_WINPT_CURRWND_ENCRYPT:  
         dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd,  
                           clip_encrypt_dlg_proc, 0,  
                           _("Encryption"), IDS_WINPT_ENCRYPT );  
         break;  
           
     case ID_WINPT_CURRWND_SIGNENCRYPT:  
         dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd,  
                           clip_signenc_dlg_proc, 0,  
                           _("Sign & Encrypt"), IDS_WINPT_SIGNENC );  
         break;  
           
     case ID_WINPT_CURRWND_SIGN:  
         dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd,  
                           clip_sign_dlg_proc, 0,  
                           _("Signing"), IDS_WINPT_SIGN );  
         break;  
           
     case ID_WINPT_CURRWND_DECRYPT_VERIFY:  
         err = gpg_clip_get_pgptype (&type);  
         if (err) {  
             msg_box (hwnd, gpgme_strerror (err), _("Clipboard"), MB_ERR);  
             break;  
         }  
         if( (type & PGP_MESSAGE) && !(type & PGP_CLEARSIG) ) {  
             /* It makes only sense to insert the data in the window if it's  
                really a ciphertext. Verfied data doesn't need this. */  
             err = clip_decrypt_dlg (hwnd);  
             if (!err && reg_prefs.use_viewer) {  
                 dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,  
                                   GetDesktopWindow(), clip_edit_dlg_proc, 0,  
                                  _("Clipboard Editor"), IDS_WINPT_CLIPEDIT);  
                 if (ret_set)  
                     *ret_set = 0;  
             }  
         }  
         else if ((type & PGP_PUBKEY) && !(type & PGP_CLEARSIG))  
             km_clip_import (GetDesktopWindow (), NULL, NULL);  
         else {  
             dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,  
                               clip_verify_dlg_proc, 0,  
                               _("Verify"), IDS_WINPT_VERIFY );  
             err  = gpg_error (GPG_ERR_EOF); /* make sure window is not updated. */  
         }  
         break;  
153      }      }
       
     return err;  
 }  
   
   
 static void  
 clip_gpg_dlg (HWND hwnd, UINT id)  
 {  
     gpgme_error_t err;  
     int type;  
       
154      if ((id == ID_WINPT_SIGN || id == ID_WINPT_SIGNENCRYPT)      if ((id == ID_WINPT_SIGN || id == ID_WINPT_SIGNENCRYPT)
155          && gnupg_access_keyring (0)) {          && gnupg_access_keyring (0)) {
156          msg_box (hwnd, _("Could not access secret keyring."), _("Sign"), MB_ERR);          msg_box (hwnd, _("Could not access secret keyring."), _("Sign"), MB_ERR);
157          return;          return;
158      }      }
159            
160      switch( id ) {      switch (id) {
161      case ID_WINPT_SYMENC:      case ID_WINPT_SYMENC:
162          gpg_encrypt_symmetric ();      case ID_WINPT_CURRWND_SYMENC:
163            err = gpg_clip_sym_encrypt ();
164            if (err && r_upd_window)
165                *r_upd_window = 0;
166          break;          break;
167                    
168      case ID_WINPT_ENCRYPT:      case ID_WINPT_ENCRYPT:
169          dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd,      case ID_WINPT_CURRWND_ENCRYPT:
170            dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd,
171                            clip_encrypt_dlg_proc, 0,                            clip_encrypt_dlg_proc, 0,
172                            _("Encryption"), IDS_WINPT_ENCRYPT );                            _("Encryption"), IDS_WINPT_ENCRYPT);
173          break;          break;
174                    
175      case ID_WINPT_SIGN:      case ID_WINPT_SIGN:
176          dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd,      case ID_WINPT_CURRWND_SIGN:
177            dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd,
178                            clip_sign_dlg_proc, 0,                            clip_sign_dlg_proc, 0,
179                            _("Signing"), IDS_WINPT_SIGN );                            _("Signing"), IDS_WINPT_SIGN);
180          break;          break;
181                    
182      case ID_WINPT_SIGNENCRYPT:      case ID_WINPT_SIGNENCRYPT:
183          dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd,      case ID_WINPT_CURRWND_SIGNENCRYPT:
184            dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd,
185                            clip_signenc_dlg_proc, 0,                            clip_signenc_dlg_proc, 0,
186                            _("Sign & Encrypt"), IDS_WINPT_SIGNENC );                            _("Sign & Encrypt"), IDS_WINPT_SIGNENC);
187          break;          break;
188                    
189      case ID_WINPT_DECRYPT_VERIFY:      case ID_WINPT_DECRYPT_VERIFY:
190        case ID_WINPT_CURRWND_DECRYPT_VERIFY:
191          err = gpg_clip_get_pgptype (&type);          err = gpg_clip_get_pgptype (&type);
192          if (err) {          if (err) {
193              msg_box( hwnd, gpgme_strerror( err ), _("Clipboard"), MB_ERR );              msg_box (hwnd, gpgme_strerror (err), _("Clipboard"), MB_ERR);
194                if (r_upd_window)
195                    *r_upd_window = 0;
196              break;              break;
197          }          }
198          if( (type & PGP_MESSAGE) && !(type & PGP_CLEARSIG) ) {          if ((type & PGP_MESSAGE) && !(type & PGP_CLEARSIG))
199              err = clip_decrypt_dlg (hwnd);              err = clip_decrypt_dlg (hwnd, disable_viewer?
200              if (!err && reg_prefs.use_viewer) {                                            0 : reg_prefs.use_viewer);
201                  dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,          else if ((type & PGP_SIG) && !(type & PGP_CLEARSIG)) {
                                   GetDesktopWindow(), clip_edit_dlg_proc, 0,  
                                  _("Clipboard Editor"), IDS_WINPT_CLIPEDIT );  
             }  
         }  
         else if( (type & PGP_SIG) && !(type & PGP_CLEARSIG) ) {  
202              text_input_s input;              text_input_s input;
203              gpgme_data_t sig;              gpgme_data_t sig;
204                            
205              memset( &input, 0, sizeof (input) );              memset (&input, 0, sizeof (input));
206              err = gpg_data_new_from_clipboard (&sig, 0);              err = gpg_data_new_from_clipboard (&sig, 0);
207              if( err ) {              if (err) {
208                  msg_box( hwnd, gpgme_strerror( err ),_("Verify"), MB_ERR );                  msg_box (hwnd, gpgme_strerror (err),_("Verify"), MB_ERR);
209                    if (r_upd_window)
210                        *r_upd_window = 0;
211                  return;                  return;
212              }              }
213              input.type = 0;              input.type = 0;
214              dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_TEXT, hwnd,              dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_TEXT, hwnd,
215                               text_input_dlg_proc, (LPARAM)&input,                                text_input_dlg_proc, (LPARAM)&input,
216                               _("Text Input"), IDS_WINPT_TEXT );                                _("Text Input"), IDS_WINPT_TEXT);
217                            
218              gpg_data_release_and_set_clipboard( sig, 0 );              /* the dialog might have changed the clipboard, so we restore
219              if( input.length ) {                 the original state (again). */
220                  dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,              gpg_data_release_and_set_clipboard (sig, 0);
221                                   clip_verify_dlg_proc, (LPARAM)&input,              if (input.length > 0) {
222                                   _("Verify"), IDS_WINPT_VERIFY );                  dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,
223                                      clip_verify_dlg_proc, (LPARAM)&input,
224                                      _("Verify"), IDS_WINPT_VERIFY);
225                  input.length = 0;                  input.length = 0;
226                  free_if_alloc( input.data );                  free_if_alloc (input.data);
227              }              }
228                if (r_upd_window)
229                    *r_upd_window = 0;
230          }          }
231          else if (type & PGP_CLEARSIG) {          else if (type & PGP_CLEARSIG) {
232              dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,              dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,
233                                clip_verify_dlg_proc, 0,                                clip_verify_dlg_proc, 0,
234                                _("Verify"), IDS_WINPT_VERIFY );                                _("Verify"), IDS_WINPT_VERIFY);
235                if (r_upd_window)
236                    *r_upd_window = 0;
237          }          }
238          else if ((type & PGP_PUBKEY) || (type & PGP_SECKEY))          else if ((type & PGP_PUBKEY) || (type & PGP_SECKEY)) {
239              km_clip_import (GetDesktopWindow (), NULL, NULL);              km_clip_import (GetDesktopWindow (), NULL, NULL);
240          else              if (r_upd_window)
241                    *r_upd_window = 0;
242            }
243            else {
244              msg_box (hwnd, _("Unknown OpenPGP type."), _("Clipboard"), MB_ERR);              msg_box (hwnd, _("Unknown OpenPGP type."), _("Clipboard"), MB_ERR);
245                if (r_upd_window)
246                    *r_upd_window = 0;
247            }
248      }      }
249  }  }
250    
251    
 static bool  
 secret_key_available (void)  
 {  
     gpg_keycache_t sec = keycache_get_ctx (0);  
     if (!sec || gpg_keycache_get_size (sec) == 0)  
         return false;  
     return true;  
 }  
   
   
252  /* Load the Card Manager with the current card. */  /* Load the Card Manager with the current card. */
253  static void  static void
254  load_card_manager (void)  load_card_manager (void)
# Line 318  add_taskbar_icon (HWND hwnd, NOTIFYICOND Line 282  add_taskbar_icon (HWND hwnd, NOTIFYICOND
282  }  }
283    
284    
285    /* Initialize all needed common controls. */
286  static void  static void
287  init_common_controls (void)  init_common_controls (void)
288  {  {
# Line 330  init_common_controls (void) Line 295  init_common_controls (void)
295  }  }
296    
297    
298    /* Wipe the clipboard if the user requested it. */
299    static void
300    wipe_clipboard (int manual_shutdown)
301    {
302        int has_data = 0;
303    
304        if (!gpg_clip_istext_avail (&has_data) && has_data) {
305            int chk = get_reg_winpt_flag ("WipeClipboard");
306            if (chk == -1 && manual_shutdown)
307                DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CONFDELCLIP,
308                                GetDesktopWindow (), confirm_delclipboard_dlg, 0);
309            if (wipe_contents || chk)
310                set_clip_text (NULL, " ", 1);    
311            wipe_contents = 0;
312        }
313    }
314    
315    
316  /* Main message loop for the tray window. */  /* Main message loop for the tray window. */
317  LRESULT CALLBACK  LRESULT CALLBACK
318  winpt_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)  winpt_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
# Line 342  winpt_main_proc (HWND hwnd, UINT msg, WP Line 325  winpt_main_proc (HWND hwnd, UINT msg, WP
325      gpgme_error_t err;      gpgme_error_t err;
326      curr_wnd_ctx currwnd = {0};      curr_wnd_ctx currwnd = {0};
327      const char *s;      const char *s;
328      int rc, set_wc = 0, has_data = 0;      int rc, set_wc = 0;
329        int has_data = 0;
330    
331      switch (msg) {      switch (msg) {
332      case WM_CREATE:      case WM_CREATE:
# Line 373  winpt_main_proc (HWND hwnd, UINT msg, WP Line 357  winpt_main_proc (HWND hwnd, UINT msg, WP
357          mapi_deinit ();          mapi_deinit ();
358          wsock_end ();                  wsock_end ();        
359          keycache_release (1);          keycache_release (1);
360          gnupg_backup_keyrings (reg_prefs.auto_backup, reg_prefs.backup.mode);          gnupg_backup_keyrings (reg_prefs.auto_backup,
361                                   reg_prefs.backup.mode,
362                                   reg_prefs.backup.include_secr);
363          free_reg_prefs ();          free_reg_prefs ();
364          free_gnupg_table ();          free_gnupg_table ();
365          hotkeys_unregister (hwnd);          hotkeys_unregister (hwnd);
366          PTD_delete ();          PTD_delete ();
367          agent_flush_cache ();          agent_flush_cache ();
368          html_help_deinit (cookie);          html_help_deinit (cookie);
369          if (!gpg_clip_istext_avail (&has_data) && has_data) {          wipe_clipboard (manual_shutdown);
             int chk = get_reg_winpt_flag ("WipeClipboard");  
             if (chk == -1 && manual_shutdown)  
                 DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CONFDELCLIP,  
                                 GetDesktopWindow (), confirm_delclipboard_dlg,  
                                 0);  
             if (wipe_contents || chk)  
                 set_clip_text (NULL, " ", 1);  
             wipe_contents = 0;  
         }  
370          debug_end ();          debug_end ();
371          Shell_NotifyIcon (NIM_DELETE, &NID);          Shell_NotifyIcon (NIM_DELETE, &NID);
372          PostQuitMessage (0);          PostQuitMessage (0);
# Line 402  winpt_main_proc (HWND hwnd, UINT msg, WP Line 379  winpt_main_proc (HWND hwnd, UINT msg, WP
379              HMENU hm, popup;              HMENU hm, popup;
380              POINT p;              POINT p;
381    
382                if (!wait_for_progress_cb (0))
383                    break;
384              gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1;              gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1;
   
385              SetForegroundWindow (hwnd);              SetForegroundWindow (hwnd);
386              GetCursorPos (&p);              GetCursorPos (&p);
387              hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT));              hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT));
388              popup = GetSubMenu (hm, 0);              popup = GetSubMenu (hm, 0);
389    
390                if (!scard_support)
391                    set_menu_state (popup, ID_WINPT_CARD, MF_DISABLED|MF_GRAYED);
392              set_menu_text (popup, ID_WINPT_FILE, _("File Manager"));              set_menu_text (popup, ID_WINPT_FILE, _("File Manager"));
393              set_menu_text (popup, ID_WINPT_KEY, _("Key Manager"));              set_menu_text (popup, ID_WINPT_KEY, _("Key Manager"));
394              set_menu_text (popup, ID_WINPT_CARD, _("Card Manager"));              set_menu_text (popup, ID_WINPT_CARD, _("Card Manager"));
395              if (!scard_support)              set_menu_text (popup, ID_WINPT_EDIT, _("Edit"));
                 set_menu_state (popup, ID_WINPT_CARD, MF_DISABLED|MF_GRAYED);  
             set_menu_text (popup, ID_WINPT_EDIT, _("Edit Clipboard"));  
396              set_menu_text (popup, ID_WINPT_ABOUT, _("About..."));              set_menu_text (popup, ID_WINPT_ABOUT, _("About..."));
397              set_menu_text (popup, ID_WINPT_QUIT, _("Exit"));              set_menu_text (popup, ID_WINPT_QUIT, _("Exit"));
398              set_menu_text (popup, ID_WINPT_SYMENC, _("Symmetric"));              set_menu_text (popup, ID_WINPT_SYMENC, _("Symmetric"));
# Line 427  winpt_main_proc (HWND hwnd, UINT msg, WP Line 405  winpt_main_proc (HWND hwnd, UINT msg, WP
405              set_menu_text (popup, ID_WINPT_CURRWND_SIGNENCRYPT, _("Sign && Encrypt"));              set_menu_text (popup, ID_WINPT_CURRWND_SIGNENCRYPT, _("Sign && Encrypt"));
406              set_menu_text (popup, ID_WINPT_CURRWND_DECRYPT_VERIFY, _("Decrypt/Verify"));              set_menu_text (popup, ID_WINPT_CURRWND_DECRYPT_VERIFY, _("Decrypt/Verify"));
407              set_menu_text (popup, ID_WINPT_CURRWND_SIGN, _("Sign"));              set_menu_text (popup, ID_WINPT_CURRWND_SIGN, _("Sign"));
408                set_menu_text (popup, ID_WINPT_CURRWND_SYMENC, _("Symmetric"));
409              if (!secret_key_available ()) {              if (!secret_key_available ()) {
410                  set_menu_state (popup, ID_WINPT_SIGN, MF_DISABLED|MF_GRAYED);                  set_menu_state (popup, ID_WINPT_SIGN, MF_DISABLED|MF_GRAYED);
411                  set_menu_state (popup, ID_WINPT_CURRWND_SIGN, MF_DISABLED|MF_GRAYED);                  set_menu_state (popup, ID_WINPT_CURRWND_SIGN, MF_DISABLED|MF_GRAYED);
412                  set_menu_state (popup, ID_WINPT_SIGNENCRYPT, MF_DISABLED|MF_GRAYED);                  set_menu_state (popup, ID_WINPT_SIGNENCRYPT, MF_DISABLED|MF_GRAYED);
413                  set_menu_state (popup, ID_WINPT_CURRWND_SIGNENCRYPT, MF_DISABLED|MF_GRAYED);                  set_menu_state (popup, ID_WINPT_CURRWND_SIGNENCRYPT, MF_DISABLED|MF_GRAYED);
414              }              }
415              /* change popup texts */              /* change popup texts */      
416              set_menu_text_bypos (popup, 6, _("Clipboard"));              set_menu_text_bypos (popup, 4, _("Clipboard"));
417              set_menu_text_bypos (popup, 7, _("Current Window"));              set_menu_text_bypos (popup, 5, _("Current Window"));
418              set_menu_text_bypos (popup, 9, _("Preferences"));              set_menu_text_bypos (popup, 7, _("Preferences"));
419    
420              TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL);              TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL);
421              PostMessage (hwnd, WM_USER, 0, 0);              PostMessage (hwnd, WM_USER, 0, 0);
# Line 445  winpt_main_proc (HWND hwnd, UINT msg, WP Line 424  winpt_main_proc (HWND hwnd, UINT msg, WP
424              break;              break;
425                            
426          case WM_LBUTTONDBLCLK:          case WM_LBUTTONDBLCLK:
427                if (!wait_for_progress_cb (0))
428                    break;
429              gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1;              gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1;
430              SendMessage (hwnd, WM_COMMAND, ID_WINPT_KEY, 0);              SendMessage (hwnd, WM_COMMAND, ID_WINPT_KEY, 0);
431              break;              break;
# Line 453  winpt_main_proc (HWND hwnd, UINT msg, WP Line 434  winpt_main_proc (HWND hwnd, UINT msg, WP
434                    
435      case WM_HOTKEY:      case WM_HOTKEY:
436          cmd = 0;          cmd = 0;
437          switch( wparam ) {          switch (wparam) {
438          case WPT_CLIP_ENCRYPT_ID:                                case WPT_CLIP_ENCRYPT_ID:                      
439              SendMessage( hwnd, WM_COMMAND, ID_WINPT_ENCRYPT, 0 );              SendMessage( hwnd, WM_COMMAND, ID_WINPT_ENCRYPT, 0 );
440              break;              break;
# Line 491  winpt_main_proc (HWND hwnd, UINT msg, WP Line 472  winpt_main_proc (HWND hwnd, UINT msg, WP
472              break;              break;
473                            
474          case WPT_AGENT_FORGET_ID:          case WPT_AGENT_FORGET_ID:
475              rc = msg_box( hwnd, _("Remove all passphrases from cache?"),              rc = msg_box (hwnd, _("Remove all passphrases from cache?"),
476                            _("WinPT"), MB_YESNO|MB_ICONQUESTION );                            _("WinPT"), MB_YESNO|MB_ICONQUESTION);
477              if( rc == IDYES )              if (rc == IDYES)
478                  agent_flush_cache();                  agent_flush_cache ();
479              break;              break;
480          }                        }              
481          break;          break;
482                    
483      case WM_COMMAND:      case WM_COMMAND:
484          if( gnupg_access_keyring( 1 ) ) {          if (gnupg_access_keyring (1)) {
485              if( log_box( "WinPT", MB_ERR|MB_YESNO,              if (log_box( "WinPT", MB_ERR|MB_YESNO,
486                  _("Could not access public keyring, exit WinPT?") ) == IDYES )                  _("Could not access public keyring, exit WinPT?") ) == IDYES)
487                  SendMessage( hwnd, WM_DESTROY, 0, 0 );                  SendMessage (hwnd, WM_DESTROY, 0, 0);
488              break;              break;
489          }          }
490          switch( wparam ) {          switch (wparam) {
491              /** Clipboard operations **/              /** Clipboard operations **/
492          case ID_WINPT_SYMENC:          case ID_WINPT_SYMENC:
493          case ID_WINPT_ENCRYPT:          case ID_WINPT_ENCRYPT:
# Line 523  winpt_main_proc (HWND hwnd, UINT msg, WP Line 504  winpt_main_proc (HWND hwnd, UINT msg, WP
504                           _("Clipboard"), MB_ERR);                           _("Clipboard"), MB_ERR);
505                  break;                  break;
506              }              }
507              clip_gpg_dlg (hwnd, (int)wparam);              clip_gpg_dlg (hwnd, (int)wparam, NULL);
508              break;              break;
509    
510              /** Current window operations **/              /** Current window operations **/
# Line 532  winpt_main_proc (HWND hwnd, UINT msg, WP Line 513  winpt_main_proc (HWND hwnd, UINT msg, WP
513          case ID_WINPT_CURRWND_SIGNENCRYPT:          case ID_WINPT_CURRWND_SIGNENCRYPT:
514          case ID_WINPT_CURRWND_DECRYPT_VERIFY:          case ID_WINPT_CURRWND_DECRYPT_VERIFY:
515          case ID_WINPT_CURRWND_SIGN:          case ID_WINPT_CURRWND_SIGN:
516              rc = get_window_contents( hwnd, &currwnd, &use_hotkey );              rc = get_window_contents (hwnd, &currwnd, &use_hotkey);
517              if( rc ) {              if (rc) {
518                  log_box( _("WinPT Error"), MB_ERR,                  log_box (_("WinPT Error"), MB_ERR,
519                           _("Make sure that the window contains text.\n"                           _("Make sure that the window contains text.\n"
520                             "%s."),                             "%s."),
521                          winpt_strerror( WPTERR_CURR_WND ) );                          winpt_strerror (WPTERR_CURR_WND));
522                  break;                  break;
523              }              }
524              rc = currwnd_gpg_dlg (hwnd, (UINT)wparam, &set_wc);              clip_gpg_dlg (hwnd, (int)wparam, &set_wc);
525              if (!rc && set_wc)              if (set_wc == 1)
526                  set_window_contents (hwnd, &currwnd);                  set_window_contents (hwnd, &currwnd);
527              break;              break;
528                            

Legend:
Removed from v.200  
changed lines
  Added in v.262

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26