/[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 2 by twoaday, Mon Jan 31 11:02:21 2005 UTC revision 6 by twoaday, Mon Apr 4 06:59:24 2005 UTC
# Line 41  HWND activ_hwnd; Line 41  HWND activ_hwnd;
41  LOCK mo_file;  LOCK mo_file;
42  int scard_support = 0;  int scard_support = 0;
43  int debug = 0;  int debug = 0;
44    int mobile = 0;
45  int gpg_read_only = 0;  int gpg_read_only = 0;
46  char gpgver[3];  char gpgver[3];
47    
# Line 127  get_prog_part (const char * fname, int u Line 128  get_prog_part (const char * fname, int u
128              return NULL;              return NULL;
129          strncpy (currdir, cmd, 255);          strncpy (currdir, cmd, 255);
130          j = strlen (currdir);          j = strlen (currdir);
131          while (j--)          while (j--) {
         {        
132              if (currdir[j] == '\\')              if (currdir[j] == '\\')
133                  break;                            break;          
134          }          }
# Line 157  check_crypto_engine (void) Line 157  check_crypto_engine (void)
157                     ma, mi, pa);                     ma, mi, pa);
158          return rc;          return rc;
159      }      }
160      /* We enable smartcard support for GPG: 1.9.x and >= 1.3.90 */      /* We enable smartcard support for GPG: 1.9.x or >= 1.4.0 */
161      if (ma > 1 || mi >= 9 || mi > 3)      if (ma > 1 || mi >= 9 || mi >= 4)
162          scard_support = 1;          scard_support = 1;
163    
164      gpgver[0] = ma;      gpgver[0] = ma;
# Line 187  load_keyserver_conf (int quiet) Line 187  load_keyserver_conf (int quiet)
187  }  }
188    
189    
190    static void
191    enable_mobile_mode (void)
192    {
193        memset (&reg_prefs, 0, sizeof (reg_prefs));
194        reg_prefs.always_trust = 0;
195        reg_prefs.auto_backup = 0;
196        reg_prefs.cache_time = 0;
197        reg_prefs.expert = 0;
198        reg_prefs.keylist_mode = 1;
199        reg_prefs.kserv_conf = m_strdup ("keyserver.conf");
200        reg_prefs.no_zip_mmedia = 1;
201        reg_prefs.use_tmpfiles = 1;
202        reg_prefs.word_wrap = 80;
203        reg_prefs.use_viewer = 0; /* XXX */
204    }
205    
206    
207  int WINAPI  int WINAPI
208  WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd)  WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd)
209  {  {
# Line 207  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 224  WinMain (HINSTANCE hinst, HINSTANCE hpre
224      gpgme_set_pgm_string ("WinPT "PGM_VERSION);      gpgme_set_pgm_string ("WinPT "PGM_VERSION);
225    
226      s = PTD_get_version ();      s = PTD_get_version ();
227      if (strcmp (s, "0.8.0"))      if (strcmp (s, "0.8.0")) {
     {  
228          log_box (_("Privacy Tray Dynamic (PTD)"), MB_ERR,          log_box (_("Privacy Tray Dynamic (PTD)"), MB_ERR,
229                   _("Please update your PTD.dll to the newest version, "                   _("Please update your PTD.dll to the newest version, "
230                     "the version (%s) you use is too old."), s);                     "the version (%s) you use is too old."), s);
231          return 0;          return 0;
232      }      }
233    
234      if (gpg_md_selftest ())      if (gpg_md_selftest ()) {
     {  
235          msg_box (NULL, _("Cryptographic selftest failed."),          msg_box (NULL, _("Cryptographic selftest failed."),
236                   _("WinPT Error"), MB_ERR);                   _("WinPT Error"), MB_ERR);
237          return 0;          return 0;
238      }      }
239    
240        if (cmdline && stristr (cmdline, "--mobile"))
241            mobile = 1;
242    
243      set_default_kserver ();      set_default_kserver ();
244      regist_inst_gnupg (1);  
245      regist_inst_winpt (1, &created);      if (!mobile) {
246      if (!created)          regist_inst_gnupg (1);
247      {          regist_inst_winpt (1, &created);
248        }
249        else {
250            enable_mobile_mode ();
251            /* XXX: ask for GPG path */
252            created = 1; /* Disable registry writing */
253        }
254    
255        if (!created) {
256          memset (&reg_prefs, 0, sizeof (reg_prefs));          memset (&reg_prefs, 0, sizeof (reg_prefs));
257          reg_prefs.use_tmpfiles = 1; /* default */          reg_prefs.use_tmpfiles = 1; /* default */
258            reg_prefs.fm.progress = 0; /* XXX: fix the bug and enable it again */
259          get_reg_winpt_prefs (&reg_prefs);          get_reg_winpt_prefs (&reg_prefs);
260          if (!reg_prefs.no_hotkeys)          if (!reg_prefs.no_hotkeys)
261              hotkeys_modify ();              hotkeys_modify ();
262      }      }
263    
264      rc = gnupg_check_homedir ();      rc = gnupg_check_homedir ();
265      if (rc)      if (rc) {
     {  
266          log_box (_("WinPT Error"), MB_ERR,          log_box (_("WinPT Error"), MB_ERR,
267                   _("GPG home directory is not set correctly.\n"                   _("GPG home directory is not set correctly.\n"
268                     "Please check the GPG registry settings:\n%s."),                     "Please check the GPG registry settings:\n%s."),
# Line 265  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 291  WinMain (HINSTANCE hinst, HINSTANCE hpre
291                  gnupg_check_homedir (); /* change gpgProgram if needed */                  gnupg_check_homedir (); /* change gpgProgram if needed */
292              }              }
293          }          }
294          else          else {
         {  
295              msg_box (NULL, _("GPG home directory could not be determited."),              msg_box (NULL, _("GPG home directory could not be determited."),
296                       _("WinPT Error"), MB_ERR);                       _("WinPT Error"), MB_ERR);
297              goto start;              goto start;
# Line 274  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 299  WinMain (HINSTANCE hinst, HINSTANCE hpre
299      }      }
300    
301      rc = check_gnupg_prog ();      rc = check_gnupg_prog ();
302      if (rc)      if (rc) {
     {  
303          if (msg_box (NULL, _("Could not find the GPG binary (gpg.exe).\n"          if (msg_box (NULL, _("Could not find the GPG binary (gpg.exe).\n"
304                               "Do you want to start the GPG preferences to "                               "Do you want to start the GPG preferences to "
305                               "correct  this problem?"), _("WinPT Error"),                               "correct  this problem?"), _("WinPT Error"),
# Line 360  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 384  WinMain (HINSTANCE hinst, HINSTANCE hpre
384          return 0;          return 0;
385      }      }
386    
387      /*if (file_exist_check ("loadimage.exe"))      if (cmdline) {
388          PTD_create_loadimage (NULL);*/          if (stristr (cmdline, "--enable-debug") || stristr (cmdline, "--debug")) {
389                        gpgme_set_debug_mode (1);
390      if (cmdline && stristr (cmdline, "--enable-debug")) {              winpt_debug_msg ();
391          gpgme_set_debug_mode (1);              debug = 1;
392          winpt_debug_msg ();          }
         debug = 1;  
393      }      }
394    
395      wc.hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_WINPT));      wc.hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_WINPT));
# Line 429  start: Line 452  start:
452                                   hwnd, keygen_wizard_dlg_proc, (LPARAM)&c);                                   hwnd, keygen_wizard_dlg_proc, (LPARAM)&c);
453              if (!rc)              if (!rc)
454                  goto start;                  goto start;
             update_keycache (hwnd);  
             check_crypto_engine ();  
455              break;              break;
456    
457          case SETUP_IMPORT:          case SETUP_IMPORT:
# Line 439  start: Line 460  start:
460                  msg_box (hwnd, winpt_strerror (rc), _("WinPT Error"), MB_ERR);                  msg_box (hwnd, winpt_strerror (rc), _("WinPT Error"), MB_ERR);
461                  goto start;                  goto start;
462              }              }
             update_keycache (hwnd);  
             check_crypto_engine ();  
463              break;              break;
464    
465          case SETUP_EXISTING:          case SETUP_EXISTING:
466              break; /* todo */              DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd,
467                                gpgprefs_dlg_proc, NULL);
468                break;
469    
470          case -1:          case -1:
471              DestroyWindow (hwnd);              DestroyWindow (hwnd);
472              free_gnupg_table ();              free_gnupg_table ();
473              return 0;              return 0;
474          }          }
475            update_keycache (hwnd);
476            check_crypto_engine ();
477      }      }
478      else {      else {
479          gpgme_keycache_t c;          gpgme_keycache_t c;

Legend:
Removed from v.2  
changed lines
  Added in v.6

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26