/[winpt]/trunk/Src/wptGPG.cpp
ViewVC logotype

Diff of /trunk/Src/wptGPG.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 137 by twoaday, Mon Jan 9 14:01:51 2006 UTC revision 181 by twoaday, Tue Mar 14 11:01:22 2006 UTC
# Line 116  get_gnupg_cfgfile (void) Line 116  get_gnupg_cfgfile (void)
116      if (!path)      if (!path)
117          return NULL;          return NULL;
118      p = get_reg_entry_gpg ("OptFile");      p = get_reg_entry_gpg ("OptFile");
119      if (p && !strcmp (p, "")) {      if (p) {
120          nlen = strlen (path) + 64;          nlen = strlen (p) + 4;
         optfile = new char[nlen + 1];  
         if (!optfile)  
             BUG (0);  
         _snprintf (optfile, nlen, "%s\\"GPG_CONF, path);  
     }  
     else if (p) {  
         nlen = strlen( p ) + 4;  
121          optfile = new char[nlen + 1];          optfile = new char[nlen + 1];
122          if (!optfile)          if (!optfile)
123              BUG (NULL);              BUG (NULL);
# Line 250  gnupg_load_config (void) Line 243  gnupg_load_config (void)
243      o = find_option (opt, "ask-cert-level");      o = find_option (opt, "ask-cert-level");
244      if (o)      if (o)
245          reg_prefs.gpg.ask_cert_level = 1;          reg_prefs.gpg.ask_cert_level = 1;
246        o = find_option (opt, "ask-cert-expire");
247        if (o)
248            reg_prefs.gpg.ask_cert_expire = 1;
249      release_gpg_options (opt);      release_gpg_options (opt);
250      free_if_alloc (conf);      free_if_alloc (conf);
251      return 0;      return 0;
# Line 364  check_gnupg_engine (const char *need_gpg Line 360  check_gnupg_engine (const char *need_gpg
360      int rc = 1;      int rc = 1;
361    
362      /* Convert the needed GPG version to the integer format. */      /* Convert the needed GPG version to the integer format. */
363      rc = parse_version_nr (need_gpg_ver,      if (parse_version_nr (need_gpg_ver,
364                             &need_major, &need_minor, &need_patch);                            &need_major, &need_minor, &need_patch))
365      if (rc)          return 1;
         return rc;  
366            
367      gpgme_new (&ctx);      gpgme_new (&ctx);
368      inf = gpgme_ctx_get_engine_info (ctx);      inf = gpgme_ctx_get_engine_info (ctx);
# Line 382  check_gnupg_engine (const char *need_gpg Line 377  check_gnupg_engine (const char *need_gpg
377      if (strstr (eng, "IDEA"))      if (strstr (eng, "IDEA"))
378          idea_available = 1;          idea_available = 1;
379      free (eng);      free (eng);
380      rc = parse_version_nr (inf->version, &major, &minor, &patch);      if (parse_version_nr (inf->version, &major, &minor, &patch)) {
     if (rc) {  
381          gpgme_release (ctx);          gpgme_release (ctx);
382          return rc;          return 1;
383      }      }
384    
385      if (major > need_major)      if (major > need_major)
# Line 563  leave: Line 557  leave:
557  } /* get_gnupg_config */  } /* get_gnupg_config */
558    
559    
560    /* Set the default key in the gpg.conf.
561       If @key is NULL, the entry will be deleted. */
562  int  int
563  set_gnupg_default_key (const char * key)  set_gnupg_default_key (const char *key)
564  {  {
565      gpg_optfile_t opt;      gpg_optfile_t opt;
566      gpg_option_t e;      gpg_option_t e;
# Line 573  set_gnupg_default_key (const char * key) Line 569  set_gnupg_default_key (const char * key)
569    
570      optfile = get_gnupg_cfgfile ();      optfile = get_gnupg_cfgfile ();
571      if (!optfile)      if (!optfile)
572          return -1;          return WPTERR_FILE_OPEN;
573      rc = parse_gpg_options (optfile, &opt);      rc = parse_gpg_options (optfile, &opt);
574      if( rc ) {      if (rc) {
575          free_if_alloc (optfile);          free_if_alloc (optfile);
576          return -1;          return WPTERR_GENERAL;
577      }      }
578      e = find_option (opt, "default-key");      e = find_option (opt, "default-key");
579      if (e) {      if (e && !key)
580            e->used = 0;
581        else if (e) {
582          free_if_alloc (e->val);          free_if_alloc (e->val);
583          e->val = m_strdup (key);          e->val = m_strdup (key);
584          e->used = 1;          e->used = 1;
# Line 593  set_gnupg_default_key (const char * key) Line 591  set_gnupg_default_key (const char * key)
591      release_gpg_options (opt);      release_gpg_options (opt);
592    
593      return rc;      return rc;
594  } /* set_gnupg_default_key */  }
595    
596    
597  /*  /*
# Line 916  gnupg_copy_keyrings (void) Line 914  gnupg_copy_keyrings (void)
914      hwnd = GetDesktopWindow ();      hwnd = GetDesktopWindow ();
915    
916      pring = get_fileopen_dlg (hwnd, _("Please choose your public keyring"),      pring = get_fileopen_dlg (hwnd, _("Please choose your public keyring"),
917                                _("GPG Keyrings (*.gpg)\0*.gpg\0\0"),NULL);                                "GPG Keyrings (*.gpg)\0*.gpg\0\0",NULL);
918      if (!pring) {      if (!pring) {
919          msg_box (hwnd, _("No keyring was chosen. Exit."), _("WinPT Error"), MB_ERR);          msg_box (hwnd, _("No keyring was chosen. Exit."), _("WinPT Error"), MB_ERR);
920          free_if_alloc (path);          free_if_alloc (path);
# Line 936  gnupg_copy_keyrings (void) Line 934  gnupg_copy_keyrings (void)
934      free_if_alloc (file);      free_if_alloc (file);
935    
936      sring = get_fileopen_dlg (hwnd, _("Please choose your secret keyring"),      sring = get_fileopen_dlg (hwnd, _("Please choose your secret keyring"),
937                                _("GPG Keyrings (*.gpg)\0*.gpg\0\0"), NULL);                                "GPG Keyrings (*.gpg)\0*.gpg\0\0", NULL);
938      if (!sring) {      if (!sring) {
939          msg_box( NULL, _("No keyring was chosen. Exit."), _("WinPT Error"), MB_ERR );          msg_box( NULL, _("No keyring was chosen. Exit."), _("WinPT Error"), MB_ERR );
940          return WPTERR_GENERAL;          return WPTERR_GENERAL;
# Line 1113  gnupg_backup_keyrings (void) Line 1111  gnupg_backup_keyrings (void)
1111  void  void
1112  gnupg_display_error (void)  gnupg_display_error (void)
1113  {        {      
1114      char tmpath[512], * errstr;      char tmpath[512], *errstr;
1115      size_t size = 0;      size_t size = 0;
1116      FILE * fp;      FILE *fp;
1117    
1118      GetTempPath (sizeof tmpath - 32, (tmpath));      get_temp_name (tmpath, sizeof (tmpath), "gpg_stderr");
     strcat (tmpath, "gpg_stderr");  
1119      size = get_file_size (tmpath);      size = get_file_size (tmpath);
1120      if (file_exist_check (tmpath) || size <= 0)      if (file_exist_check (tmpath) || size <= 0)
1121          return;          return;

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26