/[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 179 by twoaday, Fri Feb 24 13:12:26 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 364  check_gnupg_engine (const char *need_gpg Line 357  check_gnupg_engine (const char *need_gpg
357      int rc = 1;      int rc = 1;
358    
359      /* Convert the needed GPG version to the integer format. */      /* Convert the needed GPG version to the integer format. */
360      rc = parse_version_nr (need_gpg_ver,      if (parse_version_nr (need_gpg_ver,
361                             &need_major, &need_minor, &need_patch);                            &need_major, &need_minor, &need_patch))
362      if (rc)          return 1;
         return rc;  
363            
364      gpgme_new (&ctx);      gpgme_new (&ctx);
365      inf = gpgme_ctx_get_engine_info (ctx);      inf = gpgme_ctx_get_engine_info (ctx);
# Line 382  check_gnupg_engine (const char *need_gpg Line 374  check_gnupg_engine (const char *need_gpg
374      if (strstr (eng, "IDEA"))      if (strstr (eng, "IDEA"))
375          idea_available = 1;          idea_available = 1;
376      free (eng);      free (eng);
377      rc = parse_version_nr (inf->version, &major, &minor, &patch);      if (parse_version_nr (inf->version, &major, &minor, &patch)) {
     if (rc) {  
378          gpgme_release (ctx);          gpgme_release (ctx);
379          return rc;          return 1;
380      }      }
381    
382      if (major > need_major)      if (major > need_major)
# Line 563  leave: Line 554  leave:
554  } /* get_gnupg_config */  } /* get_gnupg_config */
555    
556    
557    /* Set the default key in the gpg.conf.
558       If @key is NULL, the entry will be deleted. */
559  int  int
560  set_gnupg_default_key (const char * key)  set_gnupg_default_key (const char *key)
561  {  {
562      gpg_optfile_t opt;      gpg_optfile_t opt;
563      gpg_option_t e;      gpg_option_t e;
# Line 573  set_gnupg_default_key (const char * key) Line 566  set_gnupg_default_key (const char * key)
566    
567      optfile = get_gnupg_cfgfile ();      optfile = get_gnupg_cfgfile ();
568      if (!optfile)      if (!optfile)
569          return -1;          return WPTERR_FILE_OPEN;
570      rc = parse_gpg_options (optfile, &opt);      rc = parse_gpg_options (optfile, &opt);
571      if( rc ) {      if (rc) {
572          free_if_alloc (optfile);          free_if_alloc (optfile);
573          return -1;          return WPTERR_GENERAL;
574      }      }
575      e = find_option (opt, "default-key");      e = find_option (opt, "default-key");
576      if (e) {      if (e && !key)
577            e->used = 0;
578        else if (e) {
579          free_if_alloc (e->val);          free_if_alloc (e->val);
580          e->val = m_strdup (key);          e->val = m_strdup (key);
581          e->used = 1;          e->used = 1;
# Line 593  set_gnupg_default_key (const char * key) Line 588  set_gnupg_default_key (const char * key)
588      release_gpg_options (opt);      release_gpg_options (opt);
589    
590      return rc;      return rc;
591  } /* set_gnupg_default_key */  }
592    
593    
594  /*  /*
# Line 916  gnupg_copy_keyrings (void) Line 911  gnupg_copy_keyrings (void)
911      hwnd = GetDesktopWindow ();      hwnd = GetDesktopWindow ();
912    
913      pring = get_fileopen_dlg (hwnd, _("Please choose your public keyring"),      pring = get_fileopen_dlg (hwnd, _("Please choose your public keyring"),
914                                _("GPG Keyrings (*.gpg)\0*.gpg\0\0"),NULL);                                "GPG Keyrings (*.gpg)\0*.gpg\0\0",NULL);
915      if (!pring) {      if (!pring) {
916          msg_box (hwnd, _("No keyring was chosen. Exit."), _("WinPT Error"), MB_ERR);          msg_box (hwnd, _("No keyring was chosen. Exit."), _("WinPT Error"), MB_ERR);
917          free_if_alloc (path);          free_if_alloc (path);
# Line 936  gnupg_copy_keyrings (void) Line 931  gnupg_copy_keyrings (void)
931      free_if_alloc (file);      free_if_alloc (file);
932    
933      sring = get_fileopen_dlg (hwnd, _("Please choose your secret keyring"),      sring = get_fileopen_dlg (hwnd, _("Please choose your secret keyring"),
934                                _("GPG Keyrings (*.gpg)\0*.gpg\0\0"), NULL);                                "GPG Keyrings (*.gpg)\0*.gpg\0\0", NULL);
935      if (!sring) {      if (!sring) {
936          msg_box( NULL, _("No keyring was chosen. Exit."), _("WinPT Error"), MB_ERR );          msg_box( NULL, _("No keyring was chosen. Exit."), _("WinPT Error"), MB_ERR );
937          return WPTERR_GENERAL;          return WPTERR_GENERAL;
# Line 1113  gnupg_backup_keyrings (void) Line 1108  gnupg_backup_keyrings (void)
1108  void  void
1109  gnupg_display_error (void)  gnupg_display_error (void)
1110  {        {      
1111      char tmpath[512], * errstr;      char tmpath[512], *errstr;
1112      size_t size = 0;      size_t size = 0;
1113      FILE * fp;      FILE *fp;
1114    
1115      GetTempPath (sizeof tmpath - 32, (tmpath));      get_temp_name (tmpath, sizeof (tmpath), "gpg_stderr");
     strcat (tmpath, "gpg_stderr");  
1116      size = get_file_size (tmpath);      size = get_file_size (tmpath);
1117      if (file_exist_check (tmpath) || size <= 0)      if (file_exist_check (tmpath) || size <= 0)
1118          return;          return;

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26