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

Diff of /trunk/Src/wptKeylist.cpp

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

revision 166 by twoaday, Thu Jan 19 16:10:37 2006 UTC revision 167 by twoaday, Thu Jan 26 10:17:17 2006 UTC
# Line 362  get_key_trust2 (gpgme_key_t key, int val Line 362  get_key_trust2 (gpgme_key_t key, int val
362  }  }
363    
364    
365  const char *  const char*
366  get_key_trust (gpgme_key_t key, int uididx, int listmode)  get_key_trust (gpgme_key_t key, int uididx, int listmode)
367  {  {
368      return get_key_trust2 (key, 0, uididx, listmode);      return get_key_trust2 (key, 0, uididx, listmode);
369  }  }
370    
371    
372  const char *  const char*
373  get_key_trust_str (int val)  get_key_trust_str (int val)
374  {  {
375      return get_key_trust2 (NULL, val, 0, 0);      return get_key_trust2 (NULL, val, 0, 0);
# Line 408  get_key_status (gpgme_key_t key, int uid Line 408  get_key_status (gpgme_key_t key, int uid
408  }  }
409    
410    
411    /* Return human readable description of the key @key. */
412    char*
413    get_key_desc (gpgme_key_t key)
414    {
415        gpgme_key_t sk;
416        const char *state, *alg, *type;
417        char *p;
418    
419        /* XXX: problems with the German translation. */
420        state = "";
421        if (key->disabled)
422            state = _("Disabled");
423        if (key->expired)
424            state = _("Expired");
425        if (key->revoked)
426            state = _("Revoked");
427        alg = "OpenPGP";
428        if (strlen (key->subkeys->fpr) == 32)
429            alg = "RSA Legacy";
430        type = _("public key");
431        if (!get_seckey (key->subkeys->keyid+8, &sk))
432            type = _("key pair");
433        p = new char[strlen (state) + strlen (alg) + strlen (type) + 4 + 1];
434        if (!p)
435            BUG (0);
436        sprintf (p, "%s %s %s", state, alg, type);
437        return p;
438    }
439    
440    
441  /* Integer comparsion of @a and @b.  /* Integer comparsion of @a and @b.
442     Return values: same as in strcmp. */     Return values: same as in strcmp. */
443  static inline int  static inline int
# Line 498  keylist_cmp_cb (LPARAM first, LPARAM sec Line 528  keylist_cmp_cb (LPARAM first, LPARAM sec
528  }  }
529    
530    
 #if 0  
 /* Return the validity of the group @grp. */  
 static const char*  
 calc_validity (gpg_group_t grp)  
 {  
     int valid = 0;  
     gpg_member_t mbr;  
     gpgme_key_t key;  
   
     for (mbr = grp->list; mbr; mbr = mbr->next) {  
         if (get_pubkey (mbr->name, &key))  
             continue;  
         valid = key->uids->validity;  
         switch (valid) {  
         case GPGME_VALIDITY_MARGINAL:  
         case GPGME_VALIDITY_NEVER:  
         case GPGME_VALIDITY_UNDEFINED:  
             return get_key_trust2 (NULL, valid, 0, 0);  
         }  
     }  
     return _("Full");  
 }  
 #endif  
   
   
531  int  int
532  keylist_add_groups (listview_ctrl_t lv)  keylist_add_groups (listview_ctrl_t lv)
533  {  {
# Line 753  do_addkey (listview_ctrl_t lv, gpgme_key Line 758  do_addkey (listview_ctrl_t lv, gpgme_key
758          if (attr)          if (attr)
759              listview_add_sub_item( lv, 0, idx++, attr);              listview_add_sub_item( lv, 0, idx++, attr);
760      }      }
761      if( lv->cols >= 4 ) {      if (lv->cols >= 4) {
762          p = get_key_status( key, uididx, list > 0? 1 : 0 );          p = get_key_status( key, uididx, list > 0? 1 : 0 );
763          if (!p)          if (!p)
764              return WPTERR_GENERAL;              return WPTERR_GENERAL;
# Line 784  keylist_upd_col (listview_ctrl_t lv, int Line 789  keylist_upd_col (listview_ctrl_t lv, int
789  {  {
790      gpgme_key_t key;      gpgme_key_t key;
791      const char *s;      const char *s;
792      char buf[32];      char buf[32], *p;
793      int i;      int i;
794    
795      for (i=0; i < listview_count_items (lv, 0); i++) {      for (i=0; i < listview_count_items (lv, 0); i++) {
# Line 811  keylist_upd_col (listview_ctrl_t lv, int Line 816  keylist_upd_col (listview_ctrl_t lv, int
816              s = get_key_created (key->subkeys->timestamp);              s = get_key_created (key->subkeys->timestamp);
817              listview_add_sub_item (lv, i, col, s);              listview_add_sub_item (lv, i, col, s);
818              break;              break;
819    
820            case KM_COL_DESC:
821                p = get_key_desc (key);
822                listview_add_sub_item (lv, i, col, p);
823                free_if_alloc (p);
824                break;
825          }          }
826      }      }
827  }  }
# Line 822  void Line 833  void
833  keylist_upd_key (listview_ctrl_t lv, int pos, gpgme_key_t key)  keylist_upd_key (listview_ctrl_t lv, int pos, gpgme_key_t key)
834  {  {
835      const char *s;      const char *s;
836      char *uid;      char *uid, *p;
837      char tmp[32];      char tmp[32];
838    
839      listview_set_item2 (lv, pos, (void *)key);      listview_set_item2 (lv, pos, (void *)key);
# Line 831  keylist_upd_key (listview_ctrl_t lv, int Line 842  keylist_upd_key (listview_ctrl_t lv, int
842      s = key->uids->uid;      s = key->uids->uid;
843      if (s) {      if (s) {
844          uid = utf8_to_wincp2 (s);          uid = utf8_to_wincp2 (s);
845          listview_add_sub_item (lv, pos, 0, uid);          listview_add_sub_item (lv, pos, KM_COL_UID, uid);
846          free (uid);          free (uid);
847      }      }
848    
849      s = key->subkeys->keyid;      s = key->subkeys->keyid;
850      if (s) {      if (s) {
851          sprintf (tmp, "0x%s", s+8);          sprintf (tmp, "0x%s", s+8);
852          listview_add_sub_item (lv, pos, 1, tmp);          listview_add_sub_item (lv, pos, KM_COL_KEYID, tmp);
853      }      }
854    
855      s = find_secret_key (key)? "pub/sec" : "pub";      s = find_secret_key (key)? "pub/sec" : "pub";
856      listview_add_sub_item (lv, pos, 2, s);      listview_add_sub_item (lv, pos, KM_COL_TYPE, s);
857    
858      s = get_key_size (key, 0);      s = get_key_size (key, 0);
859      if (s)      if (s)
860          listview_add_sub_item (lv, pos, 3, s);          listview_add_sub_item (lv, pos, KM_COL_SIZE, s);
861    
862      s = get_key_algo (key, 0);      s = get_key_algo (key, 0);
863      if (s)      if (s)
864          listview_add_sub_item (lv, pos, 4, s);          listview_add_sub_item (lv, pos, KM_COL_CIPHER, s);
865    
866      s = get_key_status (key, 0, 1);      p = get_key_status (key, 0, 1);
867      if (s)      if (p) {
868          listview_add_sub_item (lv, pos, 5, s);          listview_add_sub_item (lv, pos, KM_COL_VALID, p);
869            free_if_alloc (p);
870        }
871    
872      s = get_key_trust (key, 0, 1);      s = get_key_trust (key, 0, 1);
873      if (s)      if (s)
874          listview_add_sub_item (lv, pos, 6, s);          listview_add_sub_item (lv, pos, KM_COL_TRUST, s);
875    
876      long t = key->subkeys->timestamp;      long t = key->subkeys->timestamp;
877      s = get_key_created (t);      s = get_key_created (t);
878      if (s)      if (s)
879          listview_add_sub_item (lv, pos, 7, s);          listview_add_sub_item (lv, pos, KM_COL_CREAT, s);
880  }  }
881    
882    

Legend:
Removed from v.166  
changed lines
  Added in v.167

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26