/[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 47 by werner, Mon Oct 31 14:04:59 2005 UTC revision 73 by twoaday, Tue Nov 8 07:15:13 2005 UTC
# Line 23  Line 23 
23  #endif  #endif
24    
25  #include <windows.h>  #include <windows.h>
 #include <windows.h>  
26  #include <commctrl.h>  #include <commctrl.h>
27  #include <io.h>  #include <io.h>
28    
# Line 45  Line 44 
44  #include "wptCard.h"  #include "wptCard.h"
45  #include "wptCryptdisk.h"  #include "wptCryptdisk.h"
46  #include "wptCardEdit.h"  #include "wptCardEdit.h"
47    #include "wptCrypto.h"
48    
49  extern HWND activ_hwnd;  extern HWND activ_hwnd;
50  static int cmd = 0;  static int cmd = 0;
# Line 59  elgamal_warn_dlg_proc (HWND dlg, UINT ms Line 59  elgamal_warn_dlg_proc (HWND dlg, UINT ms
59      gpgme_key_t key;      gpgme_key_t key;
60      char tmp[128+64+1];      char tmp[128+64+1];
61    
62      switch( msg ) {      switch (msg) {
63      case WM_INITDIALOG:      case WM_INITDIALOG:
64          pc = keycache_get_ctx (1);          pc = keycache_get_ctx (1);
65          while (!gpg_keycache_next_key (pc, 0, &key)) {          while (!gpg_keycache_next_key (pc, 0, &key)) {
# Line 148  confirm_delclipboard_dlg (HWND dlg, UINT Line 148  confirm_delclipboard_dlg (HWND dlg, UINT
148  static gpgme_error_t  static gpgme_error_t
149  currwnd_gpg_dlg (HWND hwnd, UINT id, int *ret_set)  currwnd_gpg_dlg (HWND hwnd, UINT id, int *ret_set)
150  {  {
151      gpgme_error_t err;      gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);
152      int type;      int type;
153            
154      if (ret_set)      if (ret_set)
# Line 160  currwnd_gpg_dlg (HWND hwnd, UINT id, int Line 160  currwnd_gpg_dlg (HWND hwnd, UINT id, int
160    
161      case ID_WINPT_CURRWND_ENCRYPT:      case ID_WINPT_CURRWND_ENCRYPT:
162          dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd,          dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd,
163                            clip_encrypt_dlg_proc, NULL,                            clip_encrypt_dlg_proc, 0,
164                            _("Encryption"), IDS_WINPT_ENCRYPT );                            _("Encryption"), IDS_WINPT_ENCRYPT );
165          break;          break;
166                    
167      case ID_WINPT_CURRWND_SIGNENCRYPT:      case ID_WINPT_CURRWND_SIGNENCRYPT:
168          dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd,          dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd,
169                            clip_signenc_dlg_proc, NULL,                            clip_signenc_dlg_proc, 0,
170                            _("Sign & Encrypt"), IDS_WINPT_SIGNENC );                            _("Sign & Encrypt"), IDS_WINPT_SIGNENC );
171          break;          break;
172                    
173      case ID_WINPT_CURRWND_SIGN:      case ID_WINPT_CURRWND_SIGN:
174          dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd,          dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd,
175                            clip_sign_dlg_proc, NULL,                            clip_sign_dlg_proc, 0,
176                            _("Signing"), IDS_WINPT_SIGN );                            _("Signing"), IDS_WINPT_SIGN );
177          break;          break;
178                    
# Line 188  currwnd_gpg_dlg (HWND hwnd, UINT id, int Line 188  currwnd_gpg_dlg (HWND hwnd, UINT id, int
188              err = clip_decrypt_dlg (hwnd);              err = clip_decrypt_dlg (hwnd);
189              if (!err && reg_prefs.use_viewer) {              if (!err && reg_prefs.use_viewer) {
190                  dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,                  dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,
191                                    GetDesktopWindow(), clip_edit_dlg_proc, NULL,                                    GetDesktopWindow(), clip_edit_dlg_proc, 0,
192                                   _("Clipboard Editor"), IDS_WINPT_CLIPEDIT);                                   _("Clipboard Editor"), IDS_WINPT_CLIPEDIT);
193                  if (ret_set)                  if (ret_set)
194                      *ret_set = 0;                      *ret_set = 0;
# Line 198  currwnd_gpg_dlg (HWND hwnd, UINT id, int Line 198  currwnd_gpg_dlg (HWND hwnd, UINT id, int
198              km_clip_import (GetDesktopWindow ());              km_clip_import (GetDesktopWindow ());
199          else {          else {
200              dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,              dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,
201                                clip_verify_dlg_proc, NULL,                                clip_verify_dlg_proc, 0,
202                                _("Verify"), IDS_WINPT_VERIFY );                                _("Verify"), IDS_WINPT_VERIFY );
203              err  = gpg_error (GPG_ERR_EOF); /* make sure window is ot updated. */              err  = gpg_error (GPG_ERR_EOF); /* make sure window is ot updated. */
204          }          }
# Line 214  clip_gpg_dlg (HWND hwnd, UINT id) Line 214  clip_gpg_dlg (HWND hwnd, UINT id)
214  {  {
215      gpgme_error_t err;      gpgme_error_t err;
216      int type;      int type;
     size_t size = 0;      
217            
218      if( (id == ID_WINPT_SIGN || id == ID_WINPT_SIGNENCRYPT)      if( (id == ID_WINPT_SIGN || id == ID_WINPT_SIGNENCRYPT)
219          && gnupg_access_keyring (0) ) {          && gnupg_access_keyring (0) ) {
# Line 229  clip_gpg_dlg (HWND hwnd, UINT id) Line 228  clip_gpg_dlg (HWND hwnd, UINT id)
228                    
229      case ID_WINPT_ENCRYPT:      case ID_WINPT_ENCRYPT:
230          dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd,          dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd,
231                            clip_encrypt_dlg_proc, NULL,                            clip_encrypt_dlg_proc, 0,
232                            _("Encryption"), IDS_WINPT_ENCRYPT );                            _("Encryption"), IDS_WINPT_ENCRYPT );
233          break;          break;
234                    
235      case ID_WINPT_SIGN:      case ID_WINPT_SIGN:
236          dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd,          dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd,
237                            clip_sign_dlg_proc, NULL,                            clip_sign_dlg_proc, 0,
238                            _("Signing"), IDS_WINPT_SIGN );                            _("Signing"), IDS_WINPT_SIGN );
239          break;          break;
240                    
241      case ID_WINPT_SIGNENCRYPT:      case ID_WINPT_SIGNENCRYPT:
242          dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd,          dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd,
243                            clip_signenc_dlg_proc, NULL,                            clip_signenc_dlg_proc, 0,
244                            _("Sign & Encrypt"), IDS_WINPT_SIGNENC );                            _("Sign & Encrypt"), IDS_WINPT_SIGNENC );
245          break;          break;
246                    
# Line 255  clip_gpg_dlg (HWND hwnd, UINT id) Line 254  clip_gpg_dlg (HWND hwnd, UINT id)
254              err = clip_decrypt_dlg (hwnd);              err = clip_decrypt_dlg (hwnd);
255              if (!err && reg_prefs.use_viewer) {              if (!err && reg_prefs.use_viewer) {
256                  dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,                  dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,
257                                    GetDesktopWindow(), clip_edit_dlg_proc, NULL,                                    GetDesktopWindow(), clip_edit_dlg_proc, 0,
258                                   _("Clipboard Editor"), IDS_WINPT_CLIPEDIT );                                   _("Clipboard Editor"), IDS_WINPT_CLIPEDIT );
259              }              }
260          }          }
# Line 285  clip_gpg_dlg (HWND hwnd, UINT id) Line 284  clip_gpg_dlg (HWND hwnd, UINT id)
284          }          }
285          else if (type & PGP_CLEARSIG) {          else if (type & PGP_CLEARSIG) {
286              dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,              dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,
287                                clip_verify_dlg_proc, NULL,                                clip_verify_dlg_proc, 0,
288                                _("Verify"), IDS_WINPT_VERIFY );                                _("Verify"), IDS_WINPT_VERIFY );
289          }          }
290          else if ((type & PGP_PUBKEY) || (type & PGP_SECKEY))          else if ((type & PGP_PUBKEY) || (type & PGP_SECKEY))
# Line 293  clip_gpg_dlg (HWND hwnd, UINT id) Line 292  clip_gpg_dlg (HWND hwnd, UINT id)
292          else          else
293              msg_box (hwnd, _("Unknown OpenPGP type."), _("Clipboard"), MB_ERR);              msg_box (hwnd, _("Unknown OpenPGP type."), _("Clipboard"), MB_ERR);
294      }      }
295  } /* clip_gpg_dlg */  }
296    
297    
298    static bool
299    secret_key_available (void)
300    {
301        gpg_keycache_t sec = keycache_get_ctx (0);
302        if (!sec || gpg_keycache_get_size (sec) == 0)
303            return false;
304        return true;
305    }
306    
307    
308  /* Load the Card Manager with the current card. */  /* Load the Card Manager with the current card. */
# Line 338  winpt_main_proc (HWND hwnd, UINT msg, WP Line 347  winpt_main_proc (HWND hwnd, UINT msg, WP
347      reminder_ctx_s ctx;      reminder_ctx_s ctx;
348      LPARAM param;      LPARAM param;
349      curr_wnd_ctx currwnd = {0};      curr_wnd_ctx currwnd = {0};
     size_t size = 0;  
350      int rc, set_wc = 0, has_data = 0;      int rc, set_wc = 0, has_data = 0;
351      INITCOMMONCONTROLSEX cce;      INITCOMMONCONTROLSEX cce;
352      gpgme_error_t err;      gpgme_error_t err;
# Line 386  winpt_main_proc (HWND hwnd, UINT msg, WP Line 394  winpt_main_proc (HWND hwnd, UINT msg, WP
394              if (chk == -1)              if (chk == -1)
395                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CONFDELCLIP,                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CONFDELCLIP,
396                                  GetDesktopWindow (), confirm_delclipboard_dlg,                                  GetDesktopWindow (), confirm_delclipboard_dlg,
397                                  NULL);                                  0);
398              if (wipe_contents || chk)              if (wipe_contents || chk)
399                  set_clip_text (NULL, " ", 1);                  set_clip_text (NULL, " ", 1);
400              wipe_contents = 0;              wipe_contents = 0;
# Line 396  winpt_main_proc (HWND hwnd, UINT msg, WP Line 404  winpt_main_proc (HWND hwnd, UINT msg, WP
404          Shell_NotifyIcon (NIM_DELETE, &NID);          Shell_NotifyIcon (NIM_DELETE, &NID);
405          PostQuitMessage (0);          PostQuitMessage (0);
406          ExitProcess (0);          ExitProcess (0);
407          return 0;          break;
408                    
409      case WM_USER:      case WM_USER:
410          switch (lparam) {          switch (lparam) {
# Line 410  winpt_main_proc (HWND hwnd, UINT msg, WP Line 418  winpt_main_proc (HWND hwnd, UINT msg, WP
418              GetCursorPos (&p);              GetCursorPos (&p);
419              hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT));              hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT));
420              popup = GetSubMenu (hm, 0);              popup = GetSubMenu (hm, 0);
421  #ifndef LANG_DE  
422              set_menu_text( popup, ID_WINPT_FILE, _("File Manager") );              set_menu_text( popup, ID_WINPT_FILE, _("File Manager") );
423              set_menu_text( popup, ID_WINPT_KEY, _("Key Manager") );              set_menu_text( popup, ID_WINPT_KEY, _("Key Manager") );
424              set_menu_text( popup, ID_WINPT_CARD, _("Card Manager") );              set_menu_text( popup, ID_WINPT_CARD, _("Card Manager") );
# Line 427  winpt_main_proc (HWND hwnd, UINT msg, WP Line 435  winpt_main_proc (HWND hwnd, UINT msg, WP
435              set_menu_text (popup, ID_WINPT_QUIT, _("Exit"));              set_menu_text (popup, ID_WINPT_QUIT, _("Exit"));
436              set_menu_text (popup, ID_WINPT_SYMENC, _("Symmetric"));              set_menu_text (popup, ID_WINPT_SYMENC, _("Symmetric"));
437              set_menu_text (popup, ID_WINPT_ENCRYPT, _("Encrypt"));              set_menu_text (popup, ID_WINPT_ENCRYPT, _("Encrypt"));
438                set_menu_text (popup, ID_WINPT_SIGN, _("Sign"));
439              set_menu_text (popup, ID_WINPT_SIGNENCRYPT, _("Sign && Encrypt"));              set_menu_text (popup, ID_WINPT_SIGNENCRYPT, _("Sign && Encrypt"));
440              set_menu_text (popup, ID_WINPT_DECRYPT, _("Decrypt/Verify"));              set_menu_text (popup, ID_WINPT_DECRYPT, _("Decrypt/Verify"));
441              set_menu_text (popup, ID_WINPT_VERIFY, _("Verify"));              set_menu_text (popup, ID_WINPT_VERIFY, _("Verify"));
# Line 434  winpt_main_proc (HWND hwnd, UINT msg, WP Line 443  winpt_main_proc (HWND hwnd, UINT msg, WP
443              set_menu_text (popup, ID_WINPT_CURRWND_SIGNENCRYPT, _("Sign && Encrypt"));              set_menu_text (popup, ID_WINPT_CURRWND_SIGNENCRYPT, _("Sign && Encrypt"));
444              set_menu_text (popup, ID_WINPT_CURRWND_DECRYPT_VERIFY, _("Decrypt/Verify"));              set_menu_text (popup, ID_WINPT_CURRWND_DECRYPT_VERIFY, _("Decrypt/Verify"));
445              set_menu_text (popup, ID_WINPT_CURRWND_SIGN, _("Sign"));              set_menu_text (popup, ID_WINPT_CURRWND_SIGN, _("Sign"));
446                if (!secret_key_available ()) {
447                    set_menu_state (popup, ID_WINPT_SIGN, MF_DISABLED|MF_GRAYED);
448                    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                    set_menu_state (popup, ID_WINPT_CURRWND_SIGNENCRYPT, MF_DISABLED|MF_GRAYED);
451                }
452              /* change popup texts */              /* change popup texts */
453              set_menu_text_bypos (popup, 6, _("Clipboard"));              set_menu_text_bypos (popup, 6, _("Clipboard"));
454              set_menu_text_bypos (popup, 7, _("Current Window"));              set_menu_text_bypos (popup, 7, _("Current Window"));
455              set_menu_text_bypos (popup, 9, _("Preferences"));              set_menu_text_bypos (popup, 9, _("Preferences"));
456    
457  #endif              TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL);
458              TrackPopupMenu( popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL );              PostMessage (hwnd, WM_USER, 0, 0);
459              PostMessage( hwnd, WM_USER, 0, 0 );              DestroyMenu (popup);
460              DestroyMenu( popup );              DestroyMenu (hm);
             DestroyMenu( hm );  
461              break;              break;
462                            
463          case WM_LBUTTONDBLCLK:          case WM_LBUTTONDBLCLK:
# Line 552  winpt_main_proc (HWND hwnd, UINT msg, WP Line 566  winpt_main_proc (HWND hwnd, UINT msg, WP
566              /** File handling **/              /** File handling **/
567          case ID_WINPT_FILE:          case ID_WINPT_FILE:
568              dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_FILE,              dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_FILE,
569                                GetDesktopWindow(), file_manager_dlg_proc, NULL,                                GetDesktopWindow(), file_manager_dlg_proc, 0,
570                                _("File Manager (use drag & drop to add files)"), IDS_WINPT_FILE );                                _("File Manager (use drag & drop to add files)"), IDS_WINPT_FILE );
571              break;              break;
572                            
573              /** Misc **/              /** Misc **/
574          case ID_WINPT_KEY:          case ID_WINPT_KEY:
575              param = NULL;              param = 0;
576              if( cmd )              if( cmd )
577                  param = (LPARAM)cmd;                  param = (LPARAM)cmd;
578              dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYMISC,              dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYMISC,
# Line 573  winpt_main_proc (HWND hwnd, UINT msg, WP Line 587  winpt_main_proc (HWND hwnd, UINT msg, WP
587                            
588          case ID_WINPT_EDIT:          case ID_WINPT_EDIT:
589              dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,              dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT,
590                                GetDesktopWindow(), clip_edit_dlg_proc, NULL,                                GetDesktopWindow(), clip_edit_dlg_proc, 0,
591                               _("Clipboard Editor"), IDS_WINPT_CLIPEDIT );                               _("Clipboard Editor"), IDS_WINPT_CLIPEDIT );
592              break;              break;
593                            
594          case ID_WINPT_ABOUT:          case ID_WINPT_ABOUT:
595              dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ABOUT, GetDesktopWindow(),              dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ABOUT, GetDesktopWindow(),
596                                about_winpt_dlg_proc, NULL,                                about_winpt_dlg_proc, 0,
597                               _("About WinPT"), IDS_WINPT_ABOUT );                               _("About WinPT"), IDS_WINPT_ABOUT );
598              break;              break;
599                            
600          case ID_WINPT_PREFS:          case ID_WINPT_PREFS:
601              dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_PREFS, GetDesktopWindow(),              dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_PREFS, GetDesktopWindow(),
602                                prefs_dlg_proc, NULL,                                prefs_dlg_proc, 0,
603                               _("WinPT Preferences"), IDS_WINPT_PREFS );                               _("WinPT Preferences"), IDS_WINPT_PREFS );
604              break;              break;
605                            
606          case ID_WINPT_GPGPREFS:          case ID_WINPT_GPGPREFS:
607              dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS, GetDesktopWindow(),              dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS, GetDesktopWindow(),
608                                gpgprefs_dlg_proc, NULL,                                gpgprefs_dlg_proc, 0,
609                                _("GnuPG Preferences"), IDS_WINPT_GPGPREFS);                                _("GnuPG Preferences"), IDS_WINPT_GPGPREFS);
610              break;              break;
611    
612          case ID_WINPT_CDISKNEW:          case ID_WINPT_CDISKNEW:
613              DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_NEW,              DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_NEW,
614                          GetDesktopWindow (), cryptdisk_new_dlg_proc, NULL);                          GetDesktopWindow (), cryptdisk_new_dlg_proc, 0);
615              break;              break;
616    
617          case ID_WINPT_CDISKMOUNT:          case ID_WINPT_CDISKMOUNT:
618              DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_MOUNT,              DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_MOUNT,
619                          GetDesktopWindow (), cryptdisk_mount_dlg_proc, NULL);                          GetDesktopWindow (), cryptdisk_mount_dlg_proc, 0);
620              break;              break;
621    
622          case ID_WINPT_CDISKUNMOUNT:          case ID_WINPT_CDISKUNMOUNT:
623              DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_UMOUNT,              DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_UMOUNT,
624                          GetDesktopWindow (), cryptdisk_umount_dlg_proc, NULL);                          GetDesktopWindow (), cryptdisk_umount_dlg_proc, 0);
625              break;              break;
626    
627          case ID_WINPT_CDISKUMOUNTALL:          case ID_WINPT_CDISKUMOUNTALL:

Legend:
Removed from v.47  
changed lines
  Added in v.73

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26