/[winpt]/trunk/Src/WinPT.cpp
ViewVC logotype

Diff of /trunk/Src/WinPT.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 42 by werner, Fri Oct 28 08:25:30 2005 UTC revision 102 by twoaday, Tue Nov 29 08:56:21 2005 UTC
# Line 22  Line 22 
22  #endif  #endif
23    
24  #include <windows.h>  #include <windows.h>
 #include <windows.h>  
25    
26  #include "../resource.h"  #include "resource.h"
27  #include "wptTypes.h"  #include "wptTypes.h"
28  #include "wptW32API.h"  #include "wptW32API.h"
29  #include "wptVersion.h"  #include "wptVersion.h"
# Line 39  Line 38 
38  #include "wptFileManager.h"  #include "wptFileManager.h"
39  #include "wptContext.h"  #include "wptContext.h"
40  #include "wptCardEdit.h"  #include "wptCardEdit.h"
41    #include "wptCrypto.h"
42    
43    #define MIN_GPG_VER   "1.4.2"   /* Minimal GPG version. */
 #define MIN_GPG_VER   "1.4.3"   /* Minimal GPG version. */  
44  #define MIN_GPGME_VER "1.2.0"   /* Minimal GPGME version. */  #define MIN_GPGME_VER "1.2.0"   /* Minimal GPGME version. */
 #define MIN_PTD_VER   "0.8.1"   /* Minimal PTD version. */  
45    
46    
47  HINSTANCE glob_hinst;   /* global instance for the dialogs */  HINSTANCE glob_hinst;   /* global instance for the dialogs */
# Line 128  check_default_key (gpg_keycache_t kc) Line 126  check_default_key (gpg_keycache_t kc)
126      defkey = get_gnupg_default_key ();      defkey = get_gnupg_default_key ();
127      if (defkey)      if (defkey)
128          err = gpg_keycache_find_key (kc, defkey, 0, &key);          err = gpg_keycache_find_key (kc, defkey, 0, &key);
129        else
130            msg_box (NULL, _("No useable secret key found."), _("WinPT Error"), MB_ERR);
131      free_if_alloc (defkey);      free_if_alloc (defkey);
132      return err? -1 : 0;      return err? -1 : 0;
133  }  }
# Line 171  get_prog_part (const char * fname, int u Line 171  get_prog_part (const char * fname, int u
171  static int  static int
172  check_crypto_engine (void)  check_crypto_engine (void)
173  {  {
174      int ma=1, mi=4, pa=3; /* GPG 1.4.3 */      int ma=1, mi=4, pa=2; /* GPG 1.4.2 */
175      int rc;      int rc;
176    
177      rc = check_gnupg_engine (&ma, &mi, &pa);      rc = check_gnupg_engine (&ma, &mi, &pa);
# Line 187  check_crypto_engine (void) Line 187  check_crypto_engine (void)
187                     ma, mi, pa);                     ma, mi, pa);
188          return rc;          return rc;
189      }      }
190      /* We enable smartcard support for GPG: 1.9 or >= 1.4 */      /* We enable smartcard support for GPG: >= 2 or >= 1.4.3 */
191      if (ma >= 1 && mi >= 4)      if (ma > 1 || pa >= 3)
192          scard_support = 1;          scard_support = 1;
193    
194      gpgver[0] = ma;      gpgver[0] = ma;
# Line 255  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 255  WinMain (HINSTANCE hinst, HINSTANCE hpre
255    
256      glob_hinst = hinst;      glob_hinst = hinst;
257    
258      #ifdef _DEBUG      if (cmdline && stristr (cmdline, "--stop")) {
259      gpg_set_debug_mode (1);          hwnd = FindWindow ("WinPT", "WinPT");
260      debug = 1;          if (hwnd != NULL)
261      #endif              PostMessage (hwnd, WM_DESTROY, 0, 0);
   
     s = PTD_get_version ();  
     if (strcmp (s, MIN_PTD_VER)) {  
         log_box (_("Privacy Tray Dynamic (PTD)"), MB_ERR,  
                  _("Please update your PTD.dll to the newest version, "  
                    "the version (%s) you use is too old."), s);  
262          return 0;          return 0;
263      }      }
264        
265    #ifdef _DEBUG
266        gpg_set_debug_mode (1);
267        debug = 1;
268    #endif
269    
270      if (gpg_md_selftest ()) {      if (gpg_md_selftest ()) {
271          msg_box (NULL, _("Cryptographic selftest failed."),          msg_box (NULL, _("Cryptographic selftest failed."),
# Line 319  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 318  WinMain (HINSTANCE hinst, HINSTANCE hpre
318                   _("GPG home directory is not set correctly.\n"                   _("GPG home directory is not set correctly.\n"
319                     "Please check the GPG registry settings:\n%s."),                     "Please check the GPG registry settings:\n%s."),
320                   winpt_strerror (rc));                   winpt_strerror (rc));
321          const char * s = get_fileopen_dlg (GetActiveWindow (),          s = get_fileopen_dlg (GetActiveWindow (),
322                                             _("Select GPG Public Keyring"),                                _("Select GPG Public Keyring"),
323                                             _("GPG Keyrings (*.gpg)\0*.gpg\0\0"),                                _("GPG Keyrings (*.gpg)\0*.gpg\0\0"),
324                                             NULL);                                NULL);
325          if (s != NULL) {          if (s != NULL) {
326              size_t n;              size_t n;
327              char * p = strrchr (s, '\\');              char * p = strrchr (s, '\\');
# Line 398  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 397  WinMain (HINSTANCE hinst, HINSTANCE hpre
397    
398      if (cmdline && stristr (cmdline, "--wipe-freespace")) {      if (cmdline && stristr (cmdline, "--wipe-freespace")) {
399          dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_SPACE_SECDEL,          dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_SPACE_SECDEL,
400                              GetDesktopWindow(), space_wipefrees_dlg_proc, NULL,                              GetDesktopWindow(), space_wipefrees_dlg_proc, 0,
401                              _("Wipe Free Space"), IDS_WINPT_SPACE_SECDEL);                              _("Wipe Free Space"), IDS_WINPT_SPACE_SECDEL);
402          free_gnupg_table ();          free_gnupg_table ();
403          return 0;          return 0;
# Line 408  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 407  WinMain (HINSTANCE hinst, HINSTANCE hpre
407    
408      if (cmdline && (stristr (cmdline, "--keymanager")      if (cmdline && (stristr (cmdline, "--keymanager")
409                  || stristr (cmdline, "--cardmanager"))) {                  || stristr (cmdline, "--cardmanager"))) {
410            /* If an instance of WinPT is running, just send the command
411               to open the key manager. Otherwise start a new instance.
412             */
413            HWND tray = FindWindow ("WinPT", "WinPT");
414            if (tray != NULL) {
415                PostMessage (tray, WM_COMMAND, ID_WINPT_KEY, 0);
416                free_gnupg_table ();
417                return 0;
418            }
419          update_keycache (GetDesktopWindow ());          update_keycache (GetDesktopWindow ());
420          if (stristr (cmdline, "keymanager"))          if (stristr (cmdline, "keymanager"))
421              dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYMISC,              dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYMISC,
422                              GetDesktopWindow(), keymanager_dlg_proc, NULL,                              GetDesktopWindow(), keymanager_dlg_proc, 0,
423                              _("Key Manager"), IDS_WINPT_KEYMISC);                                _("Key Manager"), IDS_WINPT_KEYMISC);  
424          else {          else {
425              gpg_card_t crd = gpg_card_load ();              gpg_card_t crd = gpg_card_load ();
# Line 422  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 430  WinMain (HINSTANCE hinst, HINSTANCE hpre
430                                    IDS_WINPT_CARD_EDIT);                                    IDS_WINPT_CARD_EDIT);
431              gpg_card_release (crd);              gpg_card_release (crd);
432          }          }
433            /*
434          keycache_release (0);          keycache_release (0);
435          free_gnupg_table ();          free_gnupg_table ();
436          return 0;          return 0;
437            */
438      }      }
439    
440      /* If we found another WinPT instance, just quit to avoid it      /* If we found another WinPT instance, just quit to avoid it
# Line 479  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 489  WinMain (HINSTANCE hinst, HINSTANCE hpre
489            
490      if (start_gpgprefs) {      if (start_gpgprefs) {
491          char *ring;          char *ring;
492          size_t size = 0;  
493          DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd,          DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd,
494                          gpgprefs_dlg_proc, 0);                          gpgprefs_dlg_proc, 0);
495          ring = get_gnupg_keyring (0, !NO_STRICT);          ring = get_gnupg_keyring (0, !NO_STRICT);

Legend:
Removed from v.42  
changed lines
  Added in v.102

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26