/[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 168 by twoaday, Fri Jan 27 10:08:10 2006 UTC revision 181 by twoaday, Tue Mar 14 11:01:22 2006 UTC
# Line 41  Line 41 
41  #include "wptCardEdit.h"  #include "wptCardEdit.h"
42  #include "wptCrypto.h"  #include "wptCrypto.h"
43    
44    void remove_crit_file_attrs (const char *fname, int force);
45    
46    
47  HINSTANCE glob_hinst;   /* global instance for the dialogs */  HINSTANCE glob_hinst;   /* global instance for the dialogs */
48  HWND glob_hwnd;         /* global window handle for the dialogs */  HWND glob_hwnd;         /* global window handle for the dialogs */
# Line 68  update_keycache (HWND hwnd) Line 70  update_keycache (HWND hwnd)
70  /* Set GPGME debug mode. If @val is 0, the debug mode is disabled. */  /* Set GPGME debug mode. If @val is 0, the debug mode is disabled. */
71  void  void
72  gpg_set_debug_mode (int val)  gpg_set_debug_mode (int val)
73  {        {
74        /* XXX: create the file in $user\$temp */
75      if (val)      if (val)
76          putenv ("GPGME_DEBUG=5:gpgme.dbg");          putenv ("GPGME_DEBUG=5:gpgme.dbg");
77      else      else
# Line 132  gpg_prefs_ok (void) Line 135  gpg_prefs_ok (void)
135  }  }
136    
137    
138    /* Check gpg files if they are read-only and ask the user
139       if this should be corrected. */
140    static void
141    check_readonly_attr (const char *homedir)
142    {
143        const char *files[] = {"pubring.gpg", "secring.gpg", "trustdb.gpg", NULL};
144        char *file;
145        int i;
146    
147        for (i=0; files[i] != NULL; i++) {
148            file = make_filename (homedir, files[i], NULL);
149            remove_crit_file_attrs (file, 0);
150            free_if_alloc (file);
151        }
152    }
153    
154    
155  /* Load the GPG environment. On the first start, some  /* Load the GPG environment. On the first start, some
156     checks are performed to find out in what state GPG is.     checks are performed to find out in what state GPG is.
# Line 169  load_gpg_env (void) Line 188  load_gpg_env (void)
188              return (2);              return (2);
189          }          }
190      }      }
191        check_readonly_attr (p);
192      pkr = make_filename (p, "pubring", "gpg");      pkr = make_filename (p, "pubring", "gpg");
193      free_if_alloc (p);      free_if_alloc (p);
194      if (!pkr)      if (!pkr)
# Line 349  enable_mobile_mode (void) Line 369  enable_mobile_mode (void)
369      reg_prefs.auto_backup = 0;      reg_prefs.auto_backup = 0;
370      reg_prefs.cache_time = 0;      reg_prefs.cache_time = 0;
371      reg_prefs.expert = 0;      reg_prefs.expert = 0;
     reg_prefs.keylist_mode = 1;  
372      reg_prefs.kserv_conf = m_strdup ("keyserver.conf");      reg_prefs.kserv_conf = m_strdup ("keyserver.conf");
373      reg_prefs.no_zip_mmedia = 1;      reg_prefs.no_zip_mmedia = 1;
374      reg_prefs.use_tmpfiles = 1;      reg_prefs.use_tmpfiles = 1;
# Line 358  enable_mobile_mode (void) Line 377  enable_mobile_mode (void)
377  }  }
378    
379    
380    void
381    set_default_keyserver (void)
382    {
383        char *host = get_reg_entry_keyserver ("Default");
384        char *str_port = get_reg_entry_keyserver ("Default_Port");
385        WORD port = HKP_PORT;
386    
387        if (!host)
388            keyserver_set_default (NULL, 0);
389        else {
390            if (str_port && *str_port)
391                port = atoi (str_port);
392            keyserver_set_default (host, port);
393        }
394        free_if_alloc (host);
395        free_if_alloc (str_port);
396    }
397    
398    
399  /* Main entry point. */  /* Main entry point. */
400  int WINAPI  int WINAPI
401  WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd)  WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd)
# Line 433  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 471  WinMain (HINSTANCE hinst, HINSTANCE hpre
471          mobile = 1;          mobile = 1;
472      }      }
473    
474      set_default_kserver ();      set_default_keyserver ();
475      load_gettext (winpt_inst_found);      load_gettext (winpt_inst_found);
476    
477      if (!mobile) {      if (!mobile) {
# Line 451  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 489  WinMain (HINSTANCE hinst, HINSTANCE hpre
489          reg_prefs.use_tmpfiles = 1; /* default */          reg_prefs.use_tmpfiles = 1; /* default */
490          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 */
491          get_reg_winpt_prefs (&reg_prefs);          get_reg_winpt_prefs (&reg_prefs);
         if (!reg_prefs.no_hotkeys)  
             hotkeys_modify ();  
492          gnupg_load_config ();          gnupg_load_config ();
493      }      }
     else { /* default settings. */  
         reg_prefs.keylist_mode = 1;  
     }  
494    
495      if (is_gpg4win_installed ())      if (is_gpg4win_installed ())
496          load_gpg_env (); /* XXX: check return code. */          load_gpg_env (); /* XXX: check return code. */
# Line 671  start: Line 704  start:
704          }          }
705      }      }
706      else {      else {
707          gpg_keycache_t c;          gpg_keycache_t c, sec_c;
708          update_keycache (hwnd);          update_keycache (hwnd);
709          c = keycache_get_ctx (1);          c = keycache_get_ctx (1);
710          if (!c || !gpg_keycache_get_size (c)) {          if (!c || !gpg_keycache_get_size (c)) {
# Line 693  start: Line 726  start:
726                  return 0;                  return 0;
727              }              }
728          }          }
729          if (check_default_key (c)) {          sec_c = keycache_get_ctx (0);
730            if (check_default_key (sec_c)) {
731              char *p = get_gnupg_default_key ();              char *p = get_gnupg_default_key ();
732              log_box (_("WinPT Error"), MB_ERR,              log_box (_("WinPT Error"), MB_ERR,
733                       _("Default key from the GPG options file could not be found.\n"                       _("Default key (from the GPG config file) could not be found.\n"
734                         "Please check your gpg.conf (options) to correct this:\n\n"                         "Please check your gpg.conf or set a new default key to correct it:\n\n"
735                         "%s: public key not found."), p? p : "[null]");                         "%s: public key not found."), p? p : "[null]");
736              free_if_alloc (p);              free_if_alloc (p);
737              DestroyWindow (hwnd);              DestroyWindow (hwnd);

Legend:
Removed from v.168  
changed lines
  Added in v.181

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26