/[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 246 by twoaday, Tue Jul 11 08:55:57 2006 UTC revision 248 by twoaday, Fri Jul 28 11:11:09 2006 UTC
# Line 40  Line 40 
40  #include "wptRegistry.h"  #include "wptRegistry.h"
41  #include "wptKeyserver.h"  #include "wptKeyserver.h"
42  #include "wptAgent.h"  #include "wptAgent.h"
43    #include "wptUTF8.h"
44  #include "wptKeyManager.h"  #include "wptKeyManager.h"
45  #include "wptCard.h"  #include "wptCard.h"
46  #include "wptCryptdisk.h"  #include "wptCryptdisk.h"
# Line 48  Line 49 
49    
50  void update_keycache (HWND hwnd);  void update_keycache (HWND hwnd);
51    
52    /* Command for the Key Manager dialog. (0=no command) */
53  static int cmd = 0;  static int cmd = 0;
54    
55    /* 1 indicates that the clipboard will be emptied o exit. */
56  static int wipe_contents = 0;  static int wipe_contents = 0;
57    
58    
# Line 58  elgamal_warn_dlg_proc (HWND dlg, UINT ms Line 62  elgamal_warn_dlg_proc (HWND dlg, UINT ms
62  {  {
63      gpg_keycache_t pc;      gpg_keycache_t pc;
64      gpgme_key_t key;      gpgme_key_t key;
65        char *uid;
66      char tmp[128+64+1];      char tmp[128+64+1];
67    
68      switch (msg) {      switch (msg) {
# Line 65  elgamal_warn_dlg_proc (HWND dlg, UINT ms Line 70  elgamal_warn_dlg_proc (HWND dlg, UINT ms
70          pc = keycache_get_ctx (1);          pc = keycache_get_ctx (1);
71          while (!gpg_keycache_next_key (pc, 0, &key)) {          while (!gpg_keycache_next_key (pc, 0, &key)) {
72              if (key->subkeys->pubkey_algo == GPGME_PK_ELG) {              if (key->subkeys->pubkey_algo == GPGME_PK_ELG) {
73                    uid = utf8_to_native (key->uids->uid);
74                  _snprintf (tmp, sizeof (tmp)-1, "(0x%s) %s",                  _snprintf (tmp, sizeof (tmp)-1, "(0x%s) %s",
75                             key->subkeys->keyid+8, key->uids->uid);                             key->subkeys->keyid+8, uid);
76                  SendDlgItemMessage (dlg, IDC_ELGWARN_LIST, LB_ADDSTRING,                  SendDlgItemMessage (dlg, IDC_ELGWARN_LIST, LB_ADDSTRING,
77                                      0, (LPARAM)(const char *) tmp);                                      0, (LPARAM)(const char *)tmp);
78                    free_if_alloc (uid);
79              }              }
80          }          }
81          gpg_keycache_rewind (pc);          gpg_keycache_rewind (pc);
# Line 111  confirm_delclipboard_dlg (HWND dlg, UINT Line 118  confirm_delclipboard_dlg (HWND dlg, UINT
118              wipe_contents = 1;              wipe_contents = 1;
119              if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN))              if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN))
120                  set_reg_winpt_flag ("WipeClipboard", 1);                  set_reg_winpt_flag ("WipeClipboard", 1);
121              EndDialog (dlg, TRUE);              EndDialog (dlg, 1);
122              break;              break;
123    
124          case IDNO:          case IDNO:
125              wipe_contents = 0;              wipe_contents = 0;
126              if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN))              if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN))
127                  set_reg_winpt_flag ("WipeClipboard", 0);                  set_reg_winpt_flag ("WipeClipboard", 0);
128              EndDialog (dlg, FALSE);              EndDialog (dlg, 0);
129              break;              break;
130          }          }
131          break;          break;
# Line 141  currwnd_gpg_dlg (HWND hwnd, UINT id, int Line 148  currwnd_gpg_dlg (HWND hwnd, UINT id, int
148          break;          break;
149    
150      case ID_WINPT_CURRWND_ENCRYPT:      case ID_WINPT_CURRWND_ENCRYPT:
151          dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd,          dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd,
152                            clip_encrypt_dlg_proc, 0,                            clip_encrypt_dlg_proc, 0,
153                            _("Encryption"), IDS_WINPT_ENCRYPT );                            _("Encryption"), IDS_WINPT_ENCRYPT);
154          break;          break;
155                    
156      case ID_WINPT_CURRWND_SIGNENCRYPT:      case ID_WINPT_CURRWND_SIGNENCRYPT:
# Line 314  init_common_controls (void) Line 321  init_common_controls (void)
321  }  }
322    
323    
324    /* Wipe the clipboard if the user requested it. */
325    static void
326    wipe_clipboard (int manual_shutdown)
327    {
328        int has_data = 0;
329    
330        if (!gpg_clip_istext_avail (&has_data) && has_data) {
331            int chk = get_reg_winpt_flag ("WipeClipboard");
332            if (chk == -1 && manual_shutdown)
333                DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CONFDELCLIP,
334                                GetDesktopWindow (), confirm_delclipboard_dlg, 0);
335            if (wipe_contents || chk)
336                set_clip_text (NULL, " ", 1);    
337            wipe_contents = 0;
338        }
339    }
340    
341    
342  /* Main message loop for the tray window. */  /* Main message loop for the tray window. */
343  LRESULT CALLBACK  LRESULT CALLBACK
344  winpt_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)  winpt_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
# Line 326  winpt_main_proc (HWND hwnd, UINT msg, WP Line 351  winpt_main_proc (HWND hwnd, UINT msg, WP
351      gpgme_error_t err;      gpgme_error_t err;
352      curr_wnd_ctx currwnd = {0};      curr_wnd_ctx currwnd = {0};
353      const char *s;      const char *s;
354      int rc, set_wc = 0, has_data = 0;      int rc, set_wc = 0;
355        int has_data = 0;
356    
357      switch (msg) {      switch (msg) {
358      case WM_CREATE:      case WM_CREATE:
# Line 358  winpt_main_proc (HWND hwnd, UINT msg, WP Line 384  winpt_main_proc (HWND hwnd, UINT msg, WP
384          wsock_end ();                  wsock_end ();        
385          keycache_release (1);          keycache_release (1);
386          gnupg_backup_keyrings (reg_prefs.auto_backup,          gnupg_backup_keyrings (reg_prefs.auto_backup,
387                                  reg_prefs.backup.mode,                                 reg_prefs.backup.mode,
388                                  reg_prefs.backup.include_secr);                                 reg_prefs.backup.include_secr);
389          free_reg_prefs ();          free_reg_prefs ();
390          free_gnupg_table ();          free_gnupg_table ();
391          hotkeys_unregister (hwnd);          hotkeys_unregister (hwnd);
392          PTD_delete ();          PTD_delete ();
393          agent_flush_cache ();          agent_flush_cache ();
394          html_help_deinit (cookie);          html_help_deinit (cookie);
395          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;  
         }  
396          debug_end ();          debug_end ();
397          Shell_NotifyIcon (NIM_DELETE, &NID);          Shell_NotifyIcon (NIM_DELETE, &NID);
398          PostQuitMessage (0);          PostQuitMessage (0);
# Line 388  winpt_main_proc (HWND hwnd, UINT msg, WP Line 405  winpt_main_proc (HWND hwnd, UINT msg, WP
405              HMENU hm, popup;              HMENU hm, popup;
406              POINT p;              POINT p;
407    
             gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1;  
   
408              if (!wait_for_progress_cb (0))              if (!wait_for_progress_cb (0))
409                  break;                  break;
410                gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1;
411              SetForegroundWindow (hwnd);              SetForegroundWindow (hwnd);
412              GetCursorPos (&p);              GetCursorPos (&p);
413              hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT));              hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT));
414              popup = GetSubMenu (hm, 0);              popup = GetSubMenu (hm, 0);
415    
416                if (!scard_support)
417                    set_menu_state (popup, ID_WINPT_CARD, MF_DISABLED|MF_GRAYED);
418              set_menu_text (popup, ID_WINPT_FILE, _("File Manager"));              set_menu_text (popup, ID_WINPT_FILE, _("File Manager"));
419              set_menu_text (popup, ID_WINPT_KEY, _("Key Manager"));              set_menu_text (popup, ID_WINPT_KEY, _("Key Manager"));
420              set_menu_text (popup, ID_WINPT_CARD, _("Card Manager"));              set_menu_text (popup, ID_WINPT_CARD, _("Card Manager"));
             if (!scard_support)  
                 set_menu_state (popup, ID_WINPT_CARD, MF_DISABLED|MF_GRAYED);  
421              set_menu_text (popup, ID_WINPT_EDIT, _("Edit"));              set_menu_text (popup, ID_WINPT_EDIT, _("Edit"));
422              set_menu_text (popup, ID_WINPT_ABOUT, _("About..."));              set_menu_text (popup, ID_WINPT_ABOUT, _("About..."));
423              set_menu_text (popup, ID_WINPT_QUIT, _("Exit"));              set_menu_text (popup, ID_WINPT_QUIT, _("Exit"));
# Line 482  winpt_main_proc (HWND hwnd, UINT msg, WP Line 498  winpt_main_proc (HWND hwnd, UINT msg, WP
498              break;              break;
499                            
500          case WPT_AGENT_FORGET_ID:          case WPT_AGENT_FORGET_ID:
501              rc = msg_box( hwnd, _("Remove all passphrases from cache?"),              rc = msg_box (hwnd, _("Remove all passphrases from cache?"),
502                            _("WinPT"), MB_YESNO|MB_ICONQUESTION );                            _("WinPT"), MB_YESNO|MB_ICONQUESTION);
503              if( rc == IDYES )              if (rc == IDYES)
504                  agent_flush_cache();                  agent_flush_cache ();
505              break;              break;
506          }                        }              
507          break;          break;
508                    
509      case WM_COMMAND:      case WM_COMMAND:
510          if( gnupg_access_keyring( 1 ) ) {          if (gnupg_access_keyring (1)) {
511              if( log_box( "WinPT", MB_ERR|MB_YESNO,              if (log_box( "WinPT", MB_ERR|MB_YESNO,
512                  _("Could not access public keyring, exit WinPT?") ) == IDYES )                  _("Could not access public keyring, exit WinPT?") ) == IDYES)
513                  SendMessage( hwnd, WM_DESTROY, 0, 0 );                  SendMessage (hwnd, WM_DESTROY, 0, 0);
514              break;              break;
515          }          }
516          switch( wparam ) {          switch (wparam) {
517              /** Clipboard operations **/              /** Clipboard operations **/
518          case ID_WINPT_SYMENC:          case ID_WINPT_SYMENC:
519          case ID_WINPT_ENCRYPT:          case ID_WINPT_ENCRYPT:
# Line 523  winpt_main_proc (HWND hwnd, UINT msg, WP Line 539  winpt_main_proc (HWND hwnd, UINT msg, WP
539          case ID_WINPT_CURRWND_SIGNENCRYPT:          case ID_WINPT_CURRWND_SIGNENCRYPT:
540          case ID_WINPT_CURRWND_DECRYPT_VERIFY:          case ID_WINPT_CURRWND_DECRYPT_VERIFY:
541          case ID_WINPT_CURRWND_SIGN:          case ID_WINPT_CURRWND_SIGN:
542              rc = get_window_contents( hwnd, &currwnd, &use_hotkey );              rc = get_window_contents (hwnd, &currwnd, &use_hotkey);
543              if( rc ) {              if (rc) {
544                  log_box( _("WinPT Error"), MB_ERR,                  log_box (_("WinPT Error"), MB_ERR,
545                           _("Make sure that the window contains text.\n"                           _("Make sure that the window contains text.\n"
546                             "%s."),                             "%s."),
547                          winpt_strerror( WPTERR_CURR_WND ) );                          winpt_strerror (WPTERR_CURR_WND));
548                  break;                  break;
549              }              }
550              rc = currwnd_gpg_dlg (hwnd, (UINT)wparam, &set_wc);              rc = currwnd_gpg_dlg (hwnd, (UINT)wparam, &set_wc);

Legend:
Removed from v.246  
changed lines
  Added in v.248

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26