/[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 272 by twoaday, Sun Nov 5 08:57:45 2006 UTC revision 273 by twoaday, Fri Dec 8 10:22:17 2006 UTC
# Line 44  Line 44 
44    
45  void remove_crit_file_attrs (const char *fname, int force);  void remove_crit_file_attrs (const char *fname, int force);
46  BOOL user_is_admin (void);  BOOL user_is_admin (void);
47  extern "C" int  pcsc_available (void);  int  pcsc_available (void);
48    
49  /* Global variables. */  /* Global variables. */
50  HINSTANCE glob_hinst;   /* global instance for the dialogs */  HINSTANCE glob_hinst;   /* global instance for the dialogs */
# Line 62  int Line 62  int
62  update_keycache (HWND hwnd)  update_keycache (HWND hwnd)
63  {  {
64      int err;      int err;
65        refresh_cache_s rcs;
66    
67      refresh_cache_s rcs = {0};      /* no need to rebuild the sig cache each time. */
68      rcs.kr_reload = 0;      memset (&rcs, 0, sizeof (rcs));
69      rcs.kr_update = 1;      rcs.kring_update = 1;
     rcs.tr_update = 1;  
70      err = DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, hwnd,      err = DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, hwnd,
71                      keycache_dlg_proc, (LPARAM)&rcs);                      keycache_dlg_proc, (LPARAM)&rcs);
72      if (err) {      if (err) {
# Line 212  load_gpg_env (void) Line 212  load_gpg_env (void)
212  /* check if the default key from the gpg.conf file is available in the  /* check if the default key from the gpg.conf file is available in the
213     keyring. if not, bail out because encryption won't work properly then. */     keyring. if not, bail out because encryption won't work properly then. */
214  static int  static int
215  check_default_key (gpg_keycache_t kc)  check_default_key (void)
216  {  {
217      gpgme_key_t key;      gpgme_key_t key;
218      gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);      gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);
219        gpg_keycache_t kc;
220      char *defkey;      char *defkey;
221    
222        kc = keycache_get_ctx (0);
223      defkey = get_gnupg_default_key ();      defkey = get_gnupg_default_key ();
224      if (defkey)      if (defkey) {
225          err = gpg_keycache_find_key (kc, defkey, 0, &key);          err = gpg_keycache_find_key (kc, defkey, 0, &key);
226      else          if (err) {
227                free_if_alloc (defkey);
228                return -1;
229            }
230        }
231        else {
232            /* Actually this is just a warning but we still continue. */
233          msg_box (NULL, _("No useable secret key found."),          msg_box (NULL, _("No useable secret key found."),
234                   _("WinPT Warning"), MB_WARN);                   _("WinPT Warning"), MB_WARN);
235            free_if_alloc (defkey);
236            return 0;
237        }
238    
239        /* Because the secret key listing has no information
240           about the validity/status, we need to check the public key. */
241        kc = keycache_get_ctx (1);
242        if (!gpg_keycache_find_key (kc, defkey, 0, &key) &&
243            (key->revoked || key->expired)) {
244            msg_box (NULL, _("Default secret key is unuseable"),
245                     _("WinPT Warning"), MB_ERR);
246            free_if_alloc (defkey);
247            return -1;
248        }
249      free_if_alloc (defkey);      free_if_alloc (defkey);
250      return err? -1 : 0;      return 0;
251  }  }
252    
253    
254  /* Return the WinPT program file name (with full pathname). */  /* Return the WinPT program file name (with full pathname). */
255  static const char*  static const char*
256  get_prog_part (const char * fname, int use_cwd)  get_prog_part (const char *fname, int use_cwd)
257  {  {
258      static char program[2*MAX_PATH+1];      static char program[2*MAX_PATH+1];
259      char currdir[MAX_PATH+1];      char currdir[MAX_PATH+1];
# Line 553  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 575  WinMain (HINSTANCE hinst, HINSTANCE hpre
575          memset (&reg_prefs, 0, sizeof (reg_prefs));          memset (&reg_prefs, 0, sizeof (reg_prefs));
576          get_reg_winpt_prefs (&reg_prefs);          get_reg_winpt_prefs (&reg_prefs);
577          reg_prefs.fm.progress = 0; /* XXX: fix the bug and enable it again */          reg_prefs.fm.progress = 0; /* XXX: fix the bug and enable it again */
578          gnupg_load_config ();          if (gnupg_load_config () == -2)
579                msg_box (NULL, _("The gpg.conf file contains the 'textmode' option\n"
580                                 "which leads to broken binary output during decryption.\n"
581                                 "If this is on purpose, just continue otherwise the option should be disabled."),
582                                _("WinPT Error"), MB_ERR);
583      }      }
584    
585      if (is_gpg4win_installed ())      if (is_gpg4win_installed ())
# Line 769  start: Line 795  start:
795          }          }
796      }      }
797      else {      else {
798          gpg_keycache_t c, sec_c;          gpg_keycache_t c;
799          if (update_keycache (hwnd)) {          if (update_keycache (hwnd)) {
800              DestroyWindow (hwnd);              DestroyWindow (hwnd);
801              free_gnupg_table ();              free_gnupg_table ();
# Line 796  start: Line 822  start:
822                  keycache_release (1);                  keycache_release (1);
823                  return 0;                  return 0;
824              }              }
825          }          }      
826          sec_c = keycache_get_ctx (0);          if (check_default_key ()) {
         if (check_default_key (sec_c)) {  
827              char *p = get_gnupg_default_key ();              char *p = get_gnupg_default_key ();
828              log_box (_("WinPT Error"), MB_ERR,              log_box (_("WinPT Error"), MB_ERR,
829                       _("Default key (from the GPG config file) could not be found.\n"                       _("Default key (from the GPG config file) could not be found or is unuseable.\n"
830                         "Please check your gpg.conf or set a new default key to correct it:\n\n"                         "The default key will be resetted and can be set later in the Key Manager again.\n\n"
831                         "%s: public key not found."), p? p : "[null]");                         "%s: secret key not found."), p? p : "?");
832              set_gnupg_default_key (NULL);              set_gnupg_default_key (NULL);
833                free_if_alloc (p);
834          }          }
835          if (count_insecure_elgkeys ())          if (count_insecure_elgkeys ())
836              DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_ELGWARN, glob_hwnd,              DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_ELGWARN, glob_hwnd,

Legend:
Removed from v.272  
changed lines
  Added in v.273

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26