/[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 5 by twoaday, Mon Mar 7 13:21:36 2005 UTC revision 14 by twoaday, Wed May 4 07:59:42 2005 UTC
# Line 17  Line 17 
17   * along with WinPT; if not, write to the Free Software Foundation,   * along with WinPT; if not, write to the Free Software Foundation,
18   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19   */   */
   
20  #include <windows.h>  #include <windows.h>
21    
22  #include "../resource.h"  #include "../resource.h"
# Line 41  HWND activ_hwnd; Line 40  HWND activ_hwnd;
40  LOCK mo_file;  LOCK mo_file;
41  int scard_support = 0;  int scard_support = 0;
42  int debug = 0;  int debug = 0;
43    int mobile = 0;
44  int gpg_read_only = 0;  int gpg_read_only = 0;
45  char gpgver[3];  char gpgver[3];
46    
47    /* Internal IPC */
48    int start_keymanager = 0;
49    
50  static void  static void
51  update_keycache (HWND hwnd)  update_keycache (HWND hwnd)
# Line 156  check_crypto_engine (void) Line 158  check_crypto_engine (void)
158                     ma, mi, pa);                     ma, mi, pa);
159          return rc;          return rc;
160      }      }
161      /* 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 */
162      if (ma > 1 || mi >= 9 || mi > 3)      if (ma >= 1 && mi >= 4)
163          scard_support = 1;          scard_support = 1;
164    
165      gpgver[0] = ma;      gpgver[0] = ma;
# Line 186  load_keyserver_conf (int quiet) Line 188  load_keyserver_conf (int quiet)
188  }  }
189    
190    
191    static void
192    enable_mobile_mode (void)
193    {
194        memset (&reg_prefs, 0, sizeof (reg_prefs));
195        reg_prefs.always_trust = 0;
196        reg_prefs.auto_backup = 0;
197        reg_prefs.cache_time = 0;
198        reg_prefs.expert = 0;
199        reg_prefs.keylist_mode = 1;
200        reg_prefs.kserv_conf = m_strdup ("keyserver.conf");
201        reg_prefs.no_zip_mmedia = 1;
202        reg_prefs.use_tmpfiles = 1;
203        reg_prefs.word_wrap = 80;
204        reg_prefs.use_viewer = 0; /* XXX */
205    }
206    
207    char* get_subkey_fingerprint (gpgme_ctx_t ctx, const char *keyid);
208    
209  int WINAPI  int WINAPI
210    #ifndef WINPT_IPC
211  WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd)  WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd)
212    #else
213    win_main (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd)
214    #endif
215  {  {
216      WNDCLASS wc = {0, winpt_main_proc, 0, 0, hinst, 0, 0, 0, 0, PGM_NAME};      WNDCLASS wc = {0, winpt_main_proc, 0, 0, hinst, 0, 0, 0, 0, PGM_NAME};
217      HACCEL accel_tab;      HACCEL accel_tab;
# Line 219  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 243  WinMain (HINSTANCE hinst, HINSTANCE hpre
243          return 0;          return 0;
244      }      }
245    
246        if (cmdline && stristr (cmdline, "--mobile"))
247            mobile = 1;
248    
249      set_default_kserver ();      set_default_kserver ();
250      regist_inst_gnupg (1);  
251      regist_inst_winpt (1, &created);      if (!mobile) {
252            regist_inst_gnupg (1);
253            regist_inst_winpt (1, &created);
254        }
255        else {
256            enable_mobile_mode ();
257            /* XXX: ask for GPG path */
258            created = 1; /* Disable registry writing */
259        }
260    
261      if (!created) {      if (!created) {
262          memset (&reg_prefs, 0, sizeof (reg_prefs));          memset (&reg_prefs, 0, sizeof (reg_prefs));
263          reg_prefs.use_tmpfiles = 1; /* default */          reg_prefs.use_tmpfiles = 1; /* default */
# Line 327  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 363  WinMain (HINSTANCE hinst, HINSTANCE hpre
363      }      }
364    
365      load_keyserver_conf (cmdline? 1 : 0);      load_keyserver_conf (cmdline? 1 : 0);
366        if (start_keymanager) {
367            dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYMISC,
368                                GetDesktopWindow(), keymanager_dlg_proc, NULL,
369                                _("Key Manager"), IDS_WINPT_KEYMISC);
370            keycache_release ();
371            free_gnupg_table ();
372            return 0;
373        }
374    
375      if (cmdline && (stristr (cmdline, "--keymanager")      if (cmdline && (stristr (cmdline, "--keymanager")
376                  || stristr (cmdline, "--cardmanager"))) {                  || stristr (cmdline, "--cardmanager"))) {
377          update_keycache (GetDesktopWindow ());          update_keycache (GetDesktopWindow ());
378          if (stristr (cmdline, "keymanager"))          if (stristr (cmdline, "keymanager"))
379              dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYMISC,              dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYMISC,
380                              GetDesktopWindow(), keymanager_dlg_proc, NULL,                              GetDesktopWindow(), keymanager_dlg_proc, NULL,
381                              _("Key Manager"), IDS_WINPT_KEYMISC);                              _("Key Manager"), IDS_WINPT_KEYMISC);  
382          else {          else {
383              gpgme_card_t crd = smartcard_init ();              gpgme_card_t crd = smartcard_init ();
384              if (crd)              if (crd)
# Line 354  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 399  WinMain (HINSTANCE hinst, HINSTANCE hpre
399          return 0;          return 0;
400      }      }
401    
402      /*if (file_exist_check ("loadimage.exe"))      if (cmdline) {
403          PTD_create_loadimage (NULL);*/          if (stristr (cmdline, "--enable-debug") || stristr (cmdline, "--debug")) {
404                        gpgme_set_debug_mode (1);
405      if (cmdline && stristr (cmdline, "--enable-debug")) {              winpt_debug_msg ();
406          gpgme_set_debug_mode (1);              debug = 1;
407          winpt_debug_msg ();          }
         debug = 1;  
408      }      }
409    
410      wc.hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_WINPT));      wc.hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_WINPT));

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26