/[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 22 by twoaday, Wed Aug 10 11:33:35 2005 UTC revision 24 by twoaday, Sat Oct 8 10:43:08 2005 UTC
# Line 161  get_gnupg_keyring (int pub, int strict) Line 161  get_gnupg_keyring (int pub, int strict)
161   * appended string 'gpg.exe' is used.   * appended string 'gpg.exe' is used.
162   */   */
163  char*  char*
164  get_gnupg_prog( void )  get_gnupg_prog (void)
165  {      {    
166      char *p, *path, *pgm = NULL;      char *p, *path, *pgm = NULL;
167      size_t nlen = 0;      size_t nlen = 0;
# Line 193  default_key_from_cache (int * ret_no_use Line 193  default_key_from_cache (int * ret_no_use
193      if (!sec)      if (!sec)
194          BUG (0);          BUG (0);
195      gpgme_keycache_rewind (sec);      gpgme_keycache_rewind (sec);
196      while (!gpgme_keycache_next_key (sec, 1, &key))      while (!gpgme_keycache_next_key (sec, 1, &key)) {
197      {          if (key_is_useable (key)) {
198          if (gpgme_key_get_ulong_attr (key, GPGME_ATTR_KEY_USABLE, NULL, 0))              s = key->subkeys->keyid;
         {  
             s = gpgme_key_get_string_attr (key, GPGME_ATTR_KEYID, NULL, 0);  
199              if (s)                  if (s)    
200                  keyid = m_strdup (s+8);                  keyid = m_strdup (s+8);
201              break;              break;
202          }          }
203      }      }
204      if (!keyid)      if (!keyid) {
     {  
205          *ret_no_useable = 1;          *ret_no_useable = 1;
206          msg_box( NULL, _("No useable secret key found."), _("GPG Error"), MB_ERR);          msg_box( NULL, _("No useable secret key found."), _("GPG Error"), MB_ERR);
207      }      }
# Line 269  check_gnupg_prog( void ) Line 266  check_gnupg_prog( void )
266    
267    
268  static int  static int
269  parse_version_nr( const char * buf, int *major, int *minor, int *patch )  parse_version_nr (const char * buf, int *major, int *minor, int *patch)
270  {  {
271      char tmp[8];      char tmp[8];
272      int i;      int i;
273            
     if( strncmp( buf, "gpg ", 4 ) )  
         return -1;      
     buf += 4;  
     if( strncmp( buf, "(GnuPG) ", 8 ) )  
         return -1;      
     buf += 8;  
274      i=0;      i=0;
275      while( buf && *buf != '.' && i < 8 )      while( buf && *buf != '.' && i < 8 )
276          tmp[i++] = *buf++;          tmp[i++] = *buf++;
# Line 302  parse_version_nr( const char * buf, int Line 293  parse_version_nr( const char * buf, int
293  int  int
294  check_gnupg_engine (int * r_major, int * r_minor, int * r_patch)  check_gnupg_engine (int * r_major, int * r_minor, int * r_patch)
295  {  {
296      gpgme_error_t err;      gpgme_ctx_t ctx;
297        gpgme_engine_info_t inf;
298      char * eng = NULL;      char * eng = NULL;
299      int major=0, minor=0, patch=0;      int major=0, minor=0, patch=0;
300      int rc;      int rc;
301                    
302      err = gpgme_op_version( &eng );      gpgme_new (&ctx);
303      if( err )      inf = gpgme_ctx_get_engine_info (ctx);
304        if (!inf) {
305            gpgme_release (ctx);
306          return -1;          return -1;
307      if( strstr( eng, "IDEA" ) )      }
308        /* We need to exec GPG again to find out if IDEA is available. */
309        if (gpg_get_version (&eng))
310            return -1;
311        if (strstr (eng, "IDEA"))
312          idea_available = 1;          idea_available = 1;
313      rc = parse_version_nr( eng, &major, &minor, &patch );      free (eng);
314      free( eng ); eng = NULL;      rc = parse_version_nr( inf->version, &major, &minor, &patch );
315      if( rc )      if( rc ) {
316            gpgme_release (ctx);
317          return rc;          return rc;
318      if( major < *r_major      }
319       || minor < *r_minor)      if (major < *r_major || minor < *r_minor)
320          rc = 1;          rc = 1;
321      else {      else {
322          if (patch < *r_patch )          if (patch < *r_patch)
323              rc = 1;              rc = 1;
324          rc = 0;          rc = 0;
325      }      }
# Line 900  fail: Line 899  fail:
899    
900    
901  void  void
902  gnupg_backup_options (int keep)  gnupg_backup_options (void)
903  {  {
904      char *optfile = NULL;      char *cfgfile = NULL;
905      char bak[1024];      char bak[512];
906    
907      optfile = get_gnupg_cfgfile ();      cfgfile = get_gnupg_cfgfile ();
908      if (optfile == NULL)      if (cfgfile == NULL)
909          return;          return;
910      if (keep)      _snprintf (bak, DIM (bak)-1, "%s.bak", cfgfile);
911          _snprintf (bak, DIM (bak)-1, "%s.old", optfile);      CopyFile (cfgfile, bak, FALSE);
912      else      free_if_alloc (cfgfile);
         _snprintf (bak, DIM (bak)-1, "%s.O", optfile);  
     CopyFile (optfile, bak, keep);  
     free_if_alloc (optfile);  
913  } /* gnupg_backup_options */  } /* gnupg_backup_options */
914    
915    

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26