/[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 181 by twoaday, Tue Mar 14 11:01:22 2006 UTC revision 190 by twoaday, Mon Mar 27 10:05:14 2006 UTC
# Line 40  Line 40 
40  #include "wptContext.h"  #include "wptContext.h"
41  #include "wptCardEdit.h"  #include "wptCardEdit.h"
42  #include "wptCrypto.h"  #include "wptCrypto.h"
43    #include "wptUTF8.h"
44    
45  void remove_crit_file_attrs (const char *fname, int force);  void remove_crit_file_attrs (const char *fname, int force);
46    
# Line 49  HWND glob_hwnd;                /* global window handle Line 50  HWND glob_hwnd;                /* global window handle
50  HWND activ_hwnd;  HWND activ_hwnd;
51  int scard_support = 0;  int scard_support = 0;
52  int debug = 0;  int debug = 0;
53  int mobile = 0;  int mobile_mode_active = 0;
54  int gpg_read_only = 0;  int gpg_read_only = 0;
55  char gpgver[3];  char gpgver[3];
56    
57    
58  /* Load the key cache and rebuild the signature cache. */  /* Load the key cache and rebuild the signature cache. */
59  static void  void
60  update_keycache (HWND hwnd)  update_keycache (HWND hwnd)
61  {  {
62      refresh_cache_s rcs = {0};      refresh_cache_s rcs = {0};
# Line 71  update_keycache (HWND hwnd) Line 72  update_keycache (HWND hwnd)
72  void  void
73  gpg_set_debug_mode (int val)  gpg_set_debug_mode (int val)
74  {  {
75      /* XXX: create the file in $user\$temp */      static char buf[256];
76      if (val)      char tmp[128];
77          putenv ("GPGME_DEBUG=5:gpgme.dbg");      
78        /* XXX: no gpgme.dbg is created. */
79        if (val > 0) {
80            GetTempPath (sizeof (tmp)-1, tmp);
81            _snprintf (buf, sizeof (buf)-1, "GPGME_DEBUG=5:%sgpgme.dbg", tmp);
82            putenv (buf);
83        }
84      else      else
85          putenv ("GPGME_DEBUG=");          putenv ("GPGME_DEBUG=");
86  }  }
# Line 117  gpg_prefs_ok (void) Line 124  gpg_prefs_ok (void)
124          p = get_reg_entry_gpg ("gpgProgram");          p = get_reg_entry_gpg ("gpgProgram");
125          if (!p || file_exist_check (p) != 0) {          if (!p || file_exist_check (p) != 0) {
126              free_if_alloc (p);              free_if_alloc (p);
127                log_debug ("gpg_prefs_ok: could not locate gpg.exe");
128              return false;              return false;
129          }          }
130      }      }
# Line 127  gpg_prefs_ok (void) Line 135  gpg_prefs_ok (void)
135          p = get_reg_entry_gpg ("HomeDir");          p = get_reg_entry_gpg ("HomeDir");
136          if (!p || dir_exist_check (p) != 0) {          if (!p || dir_exist_check (p) != 0) {
137              free_if_alloc (p);              free_if_alloc (p);
138                log_debug ("gpg_prefs_ok: could not determine home directory");
139              return false;              return false;
140          }          }
141      }      }
# Line 361  check_for_empty_keyrings (bool pub_only) Line 370  check_for_empty_keyrings (bool pub_only)
370    
371    
372  /* Enable the mobility mode. */  /* Enable the mobility mode. */
373  static void  static int
374  enable_mobile_mode (void)  enable_mobile_mode (void)
375  {  {
376        if (dir_exist_check ("temp") != 0) {
377            if (!CreateDirectory ("temp", NULL)) {
378                MessageBox (NULL, "Could not create mobile temp directory",
379                            "WinPT Mobile Error", MB_ERR);
380                return -1;
381            }
382        }
383    
384      memset (&reg_prefs, 0, sizeof (reg_prefs));      memset (&reg_prefs, 0, sizeof (reg_prefs));
385      reg_prefs.always_trust = 0;      reg_prefs.always_trust = 0;
386      reg_prefs.auto_backup = 0;      reg_prefs.auto_backup = 0;
# Line 374  enable_mobile_mode (void) Line 391  enable_mobile_mode (void)
391      reg_prefs.use_tmpfiles = 1;      reg_prefs.use_tmpfiles = 1;
392      reg_prefs.word_wrap = 80;      reg_prefs.word_wrap = 80;
393      reg_prefs.use_viewer = 0; /* XXX */      reg_prefs.use_viewer = 0; /* XXX */
394        return 0;
395  }  }
396    
397    
# Line 396  set_default_keyserver (void) Line 414  set_default_keyserver (void)
414  }  }
415    
416    
417    /* Display info message that WinPT is now in debug mode. */
418    void
419    winpt_debug_msg (void)
420    {      
421        char output[512];
422        char temp[128];
423            
424        GetTempPath (sizeof temp -1, temp);
425        _snprintf (output, sizeof output - 1,
426            "The GPGME output file is %sgpgme.dbg\n"
427            "The WinPT output file is %swinpt.log\n", temp, temp);
428        MessageBox (NULL, output, "WinPT now runs in DEBUG MODE", MB_INFO);
429    }
430    
431    
432  /* Main entry point. */  /* Main entry point. */
433  int WINAPI  int WINAPI
434  WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd)  WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd)
# Line 468  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 501  WinMain (HINSTANCE hinst, HINSTANCE hpre
501      if (cmdline && stristr (cmdline, "--mobile")) {      if (cmdline && stristr (cmdline, "--mobile")) {
502          msg_box (NULL, "WARNING: mobile modus is not fully implemented yet!",          msg_box (NULL, "WARNING: mobile modus is not fully implemented yet!",
503                   "WinPT", MB_INFO);                   "WinPT", MB_INFO);
504          mobile = 1;          mobile_mode_active = 1;
505      }      }
506        
507      set_default_keyserver ();      set_default_keyserver ();
508      load_gettext (winpt_inst_found);      load_gettext (winpt_inst_found);
509    
510      if (!mobile) {      if (!mobile_mode_active) {
511          regist_inst_gnupg (1);          regist_inst_gnupg (1);
512          regist_inst_winpt (1, &created);          regist_inst_winpt (1, &created);
513      }      }
514      else {      else {
515          enable_mobile_mode ();          if (enable_mobile_mode ())
516          /* XXX: ask for GPG path */              return 0;
517          created = 1; /* Disable registry writing */          created = 1; /* Disable registry writing */
518      }      }
519    
# Line 612  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 645  WinMain (HINSTANCE hinst, HINSTANCE hpre
645          return 0;          return 0;
646      }      }
647    
648      if (cmdline) {      if (cmdline && (stristr (cmdline, "--enable-debug") ||
649          if (stristr (cmdline, "--enable-debug") ||                      stristr (cmdline, "--debug"))) {
650              stristr (cmdline, "--debug")) {          gpg_set_debug_mode (1);
651              gpg_set_debug_mode (1);          winpt_debug_msg ();
652              winpt_debug_msg ();          debug = 1;
             debug = 1;  
         }  
653      }      }
654    
655      wc.hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_WINPT));      wc.hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_WINPT));

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26