/[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 74 by twoaday, Tue Nov 8 07:23:16 2005 UTC revision 117 by twoaday, Thu Dec 8 09:26:32 2005 UTC
# Line 342  parse_version_nr (const char * buf, int Line 342  parse_version_nr (const char * buf, int
342      tmp[i] = 0; buf++;      tmp[i] = 0; buf++;
343      *minor = atol (tmp);      *minor = atol (tmp);
344      i=0;      i=0;
345      while (buf && isdigit( *buf ) && i < 8)      while (buf && isdigit (*buf) && i < 8)
346          tmp[i++] = *buf++;          tmp[i++] = *buf++;
347      tmp[i] = 0;      tmp[i] = 0;
348      *patch = atol (tmp);      *patch = atol (tmp);
# Line 358  check_gnupg_engine (int *r_major, int *r Line 358  check_gnupg_engine (int *r_major, int *r
358  {  {
359      gpgme_ctx_t ctx;      gpgme_ctx_t ctx;
360      gpgme_engine_info_t inf;      gpgme_engine_info_t inf;
361      char * eng = NULL;      char *eng = NULL;
362      int major=0, minor=0, patch=0;      int major=0, minor=0, patch=0;
363      int rc;      int rc = 1;
364                    
365      gpgme_new (&ctx);      gpgme_new (&ctx);
366      inf = gpgme_ctx_get_engine_info (ctx);      inf = gpgme_ctx_get_engine_info (ctx);
# Line 368  check_gnupg_engine (int *r_major, int *r Line 368  check_gnupg_engine (int *r_major, int *r
368          gpgme_release (ctx);          gpgme_release (ctx);
369          return -1;          return -1;
370      }      }
371    
372      /* We need to exec GPG again to find out if IDEA is available. */      /* We need to exec GPG again to find out if IDEA is available. */
373      if (gpg_get_version (&eng))      if (gpg_get_version (&eng))
374          return -1;          return -1;
375      if (strstr (eng, "IDEA"))      if (strstr (eng, "IDEA"))
376          idea_available = 1;          idea_available = 1;
377      free (eng);      free (eng);
378      rc = parse_version_nr( inf->version, &major, &minor, &patch );      rc = parse_version_nr (inf->version, &major, &minor, &patch);
379      if( rc ) {      if (rc) {
380          gpgme_release (ctx);          gpgme_release (ctx);
381          return rc;          return rc;
382      }      }
383      /* FIXME: This check is wrong! */  
384      if (major < *r_major || minor < *r_minor)      if (major > *r_major)
         rc = 1;  
     else {  
         if (patch < *r_patch)  
             rc = 1;  
385          rc = 0;          rc = 0;
386      }      else if (major == *r_major && minor > *r_minor)          
387            rc = 0;
388        else if (major == *r_major && minor == *r_minor &&
389                 patch >= *r_patch)
390            rc = 0;
391    
392      *r_major = major;      *r_major = major;
393      *r_minor = minor;      *r_minor = minor;
394      *r_patch = patch;      *r_patch = patch;
# Line 669  check_last_gnupg_access (gpg_watcher_s * Line 671  check_last_gnupg_access (gpg_watcher_s *
671      if (ctx->last_access.dwHighDateTime != ctx->access.dwHighDateTime &&      if (ctx->last_access.dwHighDateTime != ctx->access.dwHighDateTime &&
672          ctx->last_access.dwLowDateTime != ctx->access.dwLowDateTime)          ctx->last_access.dwLowDateTime != ctx->access.dwLowDateTime)
673          ctx->modified = 1;          ctx->modified = 1;
674        
675        /* XXX: find a better way. without it, winpt --keymanager loads
676                the key cache twice. */
677        if (ctx->last_access.dwLowDateTime == 0)
678            ctx->modified = 0;
679    
680      ctx->last_access.dwLowDateTime = ctx->access.dwLowDateTime;      ctx->last_access.dwLowDateTime = ctx->access.dwLowDateTime;
681      ctx->last_access.dwHighDateTime = ctx->access.dwHighDateTime;      ctx->last_access.dwHighDateTime = ctx->access.dwHighDateTime;
# Line 787  my_access (const char * fname) Line 794  my_access (const char * fname)
794  }  }
795    
796    
797    /* Check the file permissions of the public keyring.
798       If @showmsg is 1 output a message in case of errors.
799       Return value: 1 if read-only attribute
800                     2 if file is opened by another process exclusively. */
801  int  int
802  gpg_check_permissions (int showmsg)  gpg_check_permissions (int showmsg)
803  {  {
# Line 813  gpg_check_permissions (int showmsg) Line 824  gpg_check_permissions (int showmsg)
824                  }                  }
825              }              }
826              else if (ans == IDNO) {              else if (ans == IDNO) {
827                  /*                  /* All commands with write access will be disabled. */
                 msg_box (NULL, _("All commands with write access to the keyring\n"  
                                  "will be disabled."), _("GPG Information"), MB_INFO);  
                 */  
828                  failed = 1;                  failed = 1;
829              }              }
830          }          }
# Line 834  gpg_check_permissions (int showmsg) Line 842  gpg_check_permissions (int showmsg)
842      }      }
843      free_if_alloc (name);      free_if_alloc (name);
844      return failed;      return failed;
845  } /* gpg_check_permissions */  }
846    
847    
848  /* Check the GPG home dir. If all methods failed, try to  /* Check the GPG home dir. If all methods failed, try to
# Line 938  gnupg_copy_keyrings (void) Line 946  gnupg_copy_keyrings (void)
946          return WPTERR_GENERAL;          return WPTERR_GENERAL;
947      hwnd = GetDesktopWindow ();      hwnd = GetDesktopWindow ();
948    
949      pring = get_filename_dlg (hwnd, FILE_OPEN, _("Please choose your public keyring"),      pring = get_fileopen_dlg (hwnd, _("Please choose your public keyring"),
950                                _("GPG Keyrings (*.gpg)\0*.gpg\0\0"),NULL);                                _("GPG Keyrings (*.gpg)\0*.gpg\0\0"),NULL);
951      if (!pring) {      if (!pring) {
952          msg_box (hwnd, _("No keyring was chosen. Exit."), _("WinPT Error"), MB_ERR);          msg_box (hwnd, _("No keyring was chosen. Exit."), _("WinPT Error"), MB_ERR);
# Line 958  gnupg_copy_keyrings (void) Line 966  gnupg_copy_keyrings (void)
966      }      }
967      free_if_alloc (file);      free_if_alloc (file);
968    
969      sring = get_filename_dlg (hwnd, FILE_OPEN, _("Please choose your secret keyring"),      sring = get_fileopen_dlg (hwnd, _("Please choose your secret keyring"),
970                                _("GPG Keyrings (*.gpg)\0*.gpg\0\0"), NULL);                                _("GPG Keyrings (*.gpg)\0*.gpg\0\0"), NULL);
971      if (!sring) {      if (!sring) {
972          msg_box( NULL, _("No keyring was chosen. Exit."), _("WinPT Error"), MB_ERR );          msg_box( NULL, _("No keyring was chosen. Exit."), _("WinPT Error"), MB_ERR );
# Line 1074  get_backup_name (const char *templ) Line 1082  get_backup_name (const char *templ)
1082  }  }
1083    
1084    
1085    /* Make backups of all keyrings. The public key ring is
1086       rotated like this pubring-%d.gpg. */
1087  void  void
1088  gnupg_backup_keyrings (void)  gnupg_backup_keyrings (void)
1089  {  {
# Line 1084  gnupg_backup_keyrings (void) Line 1094  gnupg_backup_keyrings (void)
1094      if (!reg_prefs.auto_backup)      if (!reg_prefs.auto_backup)
1095          return;          return;
1096      bakmode = reg_prefs.backup.mode;      bakmode = reg_prefs.backup.mode;
1097      srcpath =  get_gnupg_path ();      srcpath = get_gnupg_path ();
1098      check_keyring (&srcpath);      check_keyring (&srcpath);
1099      if (bakmode == 1) {      if (bakmode == 1) {
1100          dstpath = get_gnupg_path ();          dstpath = multi_gnupg_path (1);
1101          check_keyring (&dstpath);          check_keyring (&dstpath);
1102      }      }
1103      else if (bakmode == 2) {      else if (bakmode == 2) {
1104          char * tmpfile;          char *tmpfile;
1105          FILE * fp;          FILE *fp;
1106    
1107          dstpath = m_strdup (reg_prefs.backup.path);          dstpath = m_strdup (reg_prefs.backup.path);
1108          if (!dstpath)          if (!dstpath)
# Line 1123  gnupg_backup_keyrings (void) Line 1133  gnupg_backup_keyrings (void)
1133      free_if_alloc (name);      free_if_alloc (name);
1134      free_if_alloc (srcpath);      free_if_alloc (srcpath);
1135      free_if_alloc (dstpath);      free_if_alloc (dstpath);
1136  } /* gnupg_backup_keyrings */  }
1137    
1138    
1139  /* Display GPG error from file if possible. */  /* Display GPG error from file if possible. */

Legend:
Removed from v.74  
changed lines
  Added in v.117

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26