/[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 14 by twoaday, Wed May 4 07:59:42 2005 UTC revision 24 by twoaday, Sat Oct 8 10:43:08 2005 UTC
# Line 33  Line 33 
33  #include "wptCard.h"  #include "wptCard.h"
34  #include "wptFileManager.h"  #include "wptFileManager.h"
35  #include "wptContext.h"  #include "wptContext.h"
36    #include "wptCardEdit.h"
37    
38  HINSTANCE glob_hinst; /* global instance for the dialogs */  HINSTANCE glob_hinst; /* global instance for the dialogs */
39  HWND glob_hwnd; /* global window handle for the dialogs */  HWND glob_hwnd; /* global window handle for the dialogs */
# Line 59  update_keycache (HWND hwnd) Line 60  update_keycache (HWND hwnd)
60  } /* update_keycache */  } /* update_keycache */
61    
62    
63    /* Set GPGME debug mode. If @val is 0, the debug mode is disabled. */
64    void
65    gpg_set_debug_mode (int val)
66    {      
67        if (val)
68            putenv ("GPGME_DEBUG=5:gpgme.dbg");
69        else
70            putenv ("GPGME_DEBUG=");
71    }
72    
73  static char *  static char *
74  get_gettext_lang (void)  get_gettext_lang (void)
75  {      {    
# Line 73  get_gettext_lang (void) Line 84  get_gettext_lang (void)
84  static void  static void
85  load_gettext (void)  load_gettext (void)
86  {  {
87      char * nls = NULL;      char *nls = NULL;
88      char * file = NULL;      char *file = NULL;
89    
90      nls = get_gettext_lang ();      nls = get_gettext_lang ();
91      if (nls) {      if (nls) {
# Line 97  static int Line 108  static int
108  check_default_key (gpgme_keycache_t kc)  check_default_key (gpgme_keycache_t kc)
109  {  {
110      gpgme_key_t key;      gpgme_key_t key;
111      gpgme_error_t err = GPGME_No_Error;      gpgme_error_t err = GPG_ERR_NO_ERROR;
112      char * defkey;      char * defkey;
113    
114      defkey = get_gnupg_default_key ();      defkey = get_gnupg_default_key ();
# Line 143  get_prog_part (const char * fname, int u Line 154  get_prog_part (const char * fname, int u
154  static int  static int
155  check_crypto_engine (void)  check_crypto_engine (void)
156  {  {
157      int ma=1, mi=2, pa=4; /* GPG 1.2.4 */      int ma=1, mi=4, pa=0; /* GPG 1.4.0 */
158      int rc;      int rc;
159    
160      rc = check_gnupg_engine (&ma, &mi, &pa);      rc = check_gnupg_engine (&ma, &mi, &pa);
# Line 154  check_crypto_engine (void) Line 165  check_crypto_engine (void)
165      else if (rc) {      else if (rc) {
166          log_box (_("WinPT Error"), MB_ERR,          log_box (_("WinPT Error"), MB_ERR,
167                   _("Sorry, you need a newer GPG version.\n"                   _("Sorry, you need a newer GPG version.\n"
168                     "GPG version %d.%d.%d requred GPG version 1.2.4"),                     "GPG version %d.%d.%d required GPG version 1.4.0"),
169                     ma, mi, pa);                     ma, mi, pa);
170          return rc;          return rc;
171      }      }
# Line 219  win_main (HINSTANCE hinst, HINSTANCE hpr Line 230  win_main (HINSTANCE hinst, HINSTANCE hpr
230      int first_start = 0, start_gpgprefs = 0;      int first_start = 0, start_gpgprefs = 0;
231      const char * s;      const char * s;
232      MSG msg;      MSG msg;
233      HWND hwnd;      HWND hwnd = NULL;
234    
235      glob_hinst = hinst;      glob_hinst = hinst;
236        
     gpgme_lib_init ();  
237      #ifdef _DEBUG      #ifdef _DEBUG
238      gpgme_set_debug_mode (1);      gpg_set_debug_mode (1);
239        debug = 1;
240      #endif      #endif
     gpgme_set_pgm_string ("WinPT "PGM_VERSION);  
241    
242      s = PTD_get_version ();      s = PTD_get_version ();
243      if (strcmp (s, "0.8.0")) {      if (strcmp (s, "0.8.0")) {
# Line 243  win_main (HINSTANCE hinst, HINSTANCE hpr Line 253  win_main (HINSTANCE hinst, HINSTANCE hpr
253          return 0;          return 0;
254      }      }
255    
256      if (cmdline && stristr (cmdline, "--mobile"))      s = gpgme_check_version ("1.1.0");
257        if (!s || !*s) {
258            msg_box (NULL, _("A newer GPGME version is needed."), "WinPT Error", MB_ERR);
259            return 0;
260        }
261    
262        if (cmdline && stristr (cmdline, "--mobile")) {
263            msg_box (NULL, "WARNING: mobile modus is not fully implemented yet!",
264                     "WinPT", MB_INFO);
265          mobile = 1;          mobile = 1;
266        }
267    
268      set_default_kserver ();      set_default_kserver ();
269    
# Line 277  win_main (HINSTANCE hinst, HINSTANCE hpr Line 296  win_main (HINSTANCE hinst, HINSTANCE hpr
296                                             _("Select GPG Public Keyring"),                                             _("Select GPG Public Keyring"),
297                                             _("GPG Keyrings (*.gpg)\0*.gpg\0\0"),                                             _("GPG Keyrings (*.gpg)\0*.gpg\0\0"),
298                                             NULL);                                             NULL);
299          if (s && !file_exist_check (s))          if (s != NULL) {
         {  
300              size_t n;              size_t n;
301              char * p = strrchr (s, '\\');              char * p = strrchr (s, '\\');
302              if (!p)              if (!p)
# Line 380  win_main (HINSTANCE hinst, HINSTANCE hpr Line 398  win_main (HINSTANCE hinst, HINSTANCE hpr
398                              GetDesktopWindow(), keymanager_dlg_proc, NULL,                              GetDesktopWindow(), keymanager_dlg_proc, NULL,
399                              _("Key Manager"), IDS_WINPT_KEYMISC);                                _("Key Manager"), IDS_WINPT_KEYMISC);  
400          else {          else {
401              gpgme_card_t crd = smartcard_init ();              gpg_card_t crd = smartcard_init ();
402              if (crd)              if (crd)
403                  dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_CARD_EDIT,                  dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_CARD_EDIT,
404                                    GetDesktopWindow(), card_edit_dlg_proc,                                    GetDesktopWindow(), card_edit_dlg_proc,
405                                    (LPARAM)crd, _("Card Manager"),                                    (LPARAM)crd, _("Card Manager"),
406                                    IDS_WINPT_CARD_EDIT);                                    IDS_WINPT_CARD_EDIT);
407              gpgme_card_release (crd);              gpg_card_release (crd);
408          }          }
409          keycache_release ();          keycache_release ();
410          free_gnupg_table ();          free_gnupg_table ();
# Line 401  win_main (HINSTANCE hinst, HINSTANCE hpr Line 419  win_main (HINSTANCE hinst, HINSTANCE hpr
419    
420      if (cmdline) {      if (cmdline) {
421          if (stristr (cmdline, "--enable-debug") || stristr (cmdline, "--debug")) {          if (stristr (cmdline, "--enable-debug") || stristr (cmdline, "--debug")) {
422              gpgme_set_debug_mode (1);              gpg_set_debug_mode (1);
423              winpt_debug_msg ();              winpt_debug_msg ();
424              debug = 1;              debug = 1;
425          }          }
# Line 431  win_main (HINSTANCE hinst, HINSTANCE hpr Line 449  win_main (HINSTANCE hinst, HINSTANCE hpr
449      UpdateWindow (hwnd);      UpdateWindow (hwnd);
450    
451      if (!first_start && !start_gpgprefs) {      if (!first_start && !start_gpgprefs) {
452          gnupg_backup_options (1);          gnupg_backup_options ();        
         gnupg_backup_options (0);  
           
453          rc = check_crypto_engine ();          rc = check_crypto_engine ();
454          if (rc) {          if (rc) {
455              DestroyWindow (hwnd);              DestroyWindow (hwnd);
# Line 441  win_main (HINSTANCE hinst, HINSTANCE hpr Line 457  win_main (HINSTANCE hinst, HINSTANCE hpr
457              return 0;              return 0;
458          }          }
459      }      }
460        
461      if (start_gpgprefs)      if (start_gpgprefs) {
     {  
462          char *ring;          char *ring;
463          size_t size = 0;          size_t size = 0;
464          DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd,          DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd,
# Line 455  win_main (HINSTANCE hinst, HINSTANCE hpr Line 470  win_main (HINSTANCE hinst, HINSTANCE hpr
470      }      }
471    
472      if (first_start) {      if (first_start) {
473          struct key_wizard_s c, dummy;          struct first_start_s fs;
474            struct genkey_s c;
475            HWND h;
476  start:  start:
477          DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_FIRST, hwnd,          h = GetDesktopWindow ();
478                          first_run_dlg_proc, (LPARAM)&dummy);          DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, h,
479          switch (dummy.interactive)                              gpgprefs_dlg_proc, NULL);
480          {          DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_FIRST, h,
481                            first_run_dlg_proc, (LPARAM)&fs);
482            switch (fs.choice) {
483          case SETUP_KEYGEN:          case SETUP_KEYGEN:
484              c.interactive = 1;              c.interactive = 1;
485                c.first_start = 1;
486              rc = DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYWIZARD,              rc = DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYWIZARD,
487                                   hwnd, keygen_wizard_dlg_proc, (LPARAM)&c);                                   h, keygen_wizard_dlg_proc, (LPARAM)&c);
488              if (!rc)              if (!rc)
489                  goto start;                  goto start;
490              break;              break;
# Line 477  start: Line 497  start:
497              }              }
498              break;              break;
499    
         case SETUP_EXISTING:  
             DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd,  
                             gpgprefs_dlg_proc, NULL);  
             break;  
   
500          case -1:          case -1:
501              DestroyWindow (hwnd);              DestroyWindow (hwnd);
502              free_gnupg_table ();              free_gnupg_table ();

Legend:
Removed from v.14  
changed lines
  Added in v.24

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26