/[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 150 by twoaday, Wed Jan 18 11:52:45 2006 UTC revision 205 by twoaday, Thu Apr 27 12:46:03 2006 UTC
# Line 303  get_key_pubalgo (gpgme_pubkey_algo_t alg Line 303  get_key_pubalgo (gpgme_pubkey_algo_t alg
303      case GPGME_PK_DSA: return "DSA";      case GPGME_PK_DSA: return "DSA";
304      case GPGME_PK_ELG:      case GPGME_PK_ELG:
305      case GPGME_PK_ELG_E: return "ELG";      case GPGME_PK_ELG_E: return "ELG";
306        case 0: /* XXX: gpgme returned pubkey algo 0 for a RSA made sig. */
307      case GPGME_PK_RSA: return "RSA";      case GPGME_PK_RSA: return "RSA";
308      default: return "???";      default: return "???";
309      }      }
# Line 341  get_key_fpr (gpgme_key_t key) Line 342  get_key_fpr (gpgme_key_t key)
342  }  }
343    
344    
345    /* Extract the key ID from the fingerprint.
346       A long ID will be converted into a short ID. */
347    const char*
348    get_keyid_from_fpr (const char *fpr)
349    {
350        if (!fpr)
351            return "????????";
352        if (strlen (fpr) == 40)
353            fpr += 32;
354        else if (strlen (fpr) == 32)
355            fpr += 24;
356        else if (strlen (fpr) == 16)
357            fpr += 8;
358        else
359            return "????????";
360        return fpr;
361    }
362    
363    
364  const char*  const char*
365  get_key_trust2 (gpgme_key_t key, int val, int uididx, int listmode)  get_key_trust2 (gpgme_key_t key, int val, int uididx, int listmode)
366  {  {
# Line 362  get_key_trust2 (gpgme_key_t key, int val Line 382  get_key_trust2 (gpgme_key_t key, int val
382  }  }
383    
384    
385  const char *  const char*
386  get_key_trust (gpgme_key_t key, int uididx, int listmode)  get_key_trust (gpgme_key_t key, int uididx, int listmode)
387  {  {
388      return get_key_trust2 (key, 0, uididx, listmode);      return get_key_trust2 (key, 0, uididx, listmode);
389  }  }
390    
391    
392  const char *  const char*
393  get_key_trust_str (int val)  get_key_trust_str (int val)
394  {  {
395      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 428  get_key_status (gpgme_key_t key, int uid
428  }  }
429    
430    
431    /* Return human readable description of the key @key. */
432    char*
433    get_key_desc (gpgme_key_t key)
434    {
435        gpgme_key_t sk;
436        const char *state, *alg, *type;
437        char *p;
438    
439        /* XXX: problems with the German translation. */
440        state = "";
441        if (key->disabled)
442            state = _("Disabled");
443        if (key->expired)
444            state = _("Expired");
445        if (key->revoked)
446            state = _("Revoked");
447        alg = "OpenPGP";
448        if (strlen (key->subkeys->fpr) == 32)
449            alg = "RSA Legacy";
450        type = _("public key");
451        if (!get_seckey (key->subkeys->keyid+8, &sk))
452            type = _("key pair");
453        p = new char[strlen (state) + strlen (alg) + strlen (type) + 4 + 1];
454        if (!p)
455            BUG (0);
456        sprintf (p, "%s %s %s", state, alg, type);
457        return p;
458    }
459    
460    
461  /* Integer comparsion of @a and @b.  /* Integer comparsion of @a and @b.
462     Return values: same as in strcmp. */     Return values: same as in strcmp. */
463  static inline int  static inline int
# Line 439  get_ext_validity (gpgme_key_t k) Line 489  get_ext_validity (gpgme_key_t k)
489  static int CALLBACK  static int CALLBACK
490  keylist_cmp_cb (LPARAM first, LPARAM second, LPARAM sortby)  keylist_cmp_cb (LPARAM first, LPARAM second, LPARAM sortby)
491  {  {
492        struct keycache_s *aa, *bb;
493      gpgme_key_t a, b;      gpgme_key_t a, b;
494      int cmpresult = 0;      int cmpresult = 0;
495            
496      a = (gpgme_key_t)first;      aa = (struct keycache_s *)first;
497      b = (gpgme_key_t)second;      bb = (struct keycache_s *)second;
498      if (!a || !b)      if (!aa || !bb)
499          BUG (NULL);          BUG (NULL);
500        a = aa->key;
501        b = bb->key;
502            
503      switch (sortby & ~KEYLIST_SORT_DESC) {      switch (sortby & ~KEYLIST_SORT_DESC) {
504      case KEY_SORT_USERID:      case KEY_SORT_USERID:
# Line 498  keylist_cmp_cb (LPARAM first, LPARAM sec Line 551  keylist_cmp_cb (LPARAM first, LPARAM sec
551  }  }
552    
553    
 #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  
   
   
554  int  int
555  keylist_add_groups (listview_ctrl_t lv)  keylist_add_groups (listview_ctrl_t lv)
556  {  {
# Line 557  keylist_build (listview_ctrl_t *r_lv, HW Line 585  keylist_build (listview_ctrl_t *r_lv, HW
585      HICON ico[2];      HICON ico[2];
586      listview_ctrl_t lv;      listview_ctrl_t lv;
587      listview_column_t col;      listview_column_t col;
588      int j, n = 0;      int j, n = 0, ext_chk = 0;
589      int rc = 0;      int rc = 0;
590            
591      rc = listview_new (&lv);      rc = listview_new (&lv);
# Line 565  keylist_build (listview_ctrl_t *r_lv, HW Line 593  keylist_build (listview_ctrl_t *r_lv, HW
593          return rc;          return rc;
594            
595      lv->ctrl = ctrl;      lv->ctrl = ctrl;
596      if ((mode & KEYLIST_ENCRYPT) || (mode & KEYLIST_ENCRYPT_MIN)) {      if (mode & KEYLIST_ENCRYPT_MIN) {
597          col = klist_enc;          col = klist_enc;
598          n = (DIM(klist_enc) -1);          n = (DIM(klist_enc) -1);
599            ext_chk = 1;
600      }        }  
601      else if ((mode & KEYLIST_SIGN)) {      else if ((mode & KEYLIST_SIGN)) {
602          col = klist_enc;          col = klist_enc;
603          n = (DIM(klist_enc) - 1) - 1;          n = (DIM(klist_enc) - 1) - 1;
604            ext_chk = 1;
605      }      }
606      else {      else {
607          col = klist;          col = klist;
# Line 579  keylist_build (listview_ctrl_t *r_lv, HW Line 609  keylist_build (listview_ctrl_t *r_lv, HW
609      }      }
610            
611      for (j = 0; j < n; j++)      for (j = 0; j < n; j++)
612          listview_add_column (lv, &col[j]);          listview_add_column (lv, &col[j]);    
613      listview_set_ext_style (lv);      listview_set_ext_style (lv);
614        if (ext_chk)
615            listview_set_chkbox_style (lv);
616      ico[0] = LoadIcon (glob_hinst, (LPCTSTR)IDI_PUBKEY);      ico[0] = LoadIcon (glob_hinst, (LPCTSTR)IDI_PUBKEY);
617      ico[1] = LoadIcon (glob_hinst, (LPCTSTR)IDI_KEYPAIR);      ico[1] = LoadIcon (glob_hinst, (LPCTSTR)IDI_KEYPAIR);
618      listview_set_image_list (lv, ico, 2);      listview_set_image_list (lv, 22, 14, ico, 2);
619      listview_del_all_items (lv);      listview_del_all_items (lv);
620    
621      *r_lv = lv;      *r_lv = lv;
# Line 597  keylist_load_keycache (listview_ctrl_t l Line 629  keylist_load_keycache (listview_ctrl_t l
629  {  {
630      gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);      gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);
631      gpgme_key_t key, skey;      gpgme_key_t key, skey;
632      const char * keyid;      struct keycache_s *c;
633        const char *keyid;
634    
635      if (pubkc && seckc) {      if (pubkc && seckc) {
636          gpg_keycache_rewind (pubkc);          gpg_keycache_rewind (pubkc);
637          while (!gpg_keycache_next_key (pubkc, 0, &key)) {          while (!gpg_keycache_next_key2 (pubkc, 0, &c, &key)) {
638              keyid = key->subkeys->keyid;              keyid = key->subkeys->keyid;
639              if (keyid && !gpg_keycache_find_key (seckc, keyid, 0, &skey))              if (keyid && !gpg_keycache_find_key (seckc, keyid, 0, &skey))
640                  keylist_add_key (lv, mode, key);                  keylist_add_key (lv, mode, c, key);
641          }                }      
642      }      }
643      else if (pubkc) {      else if (pubkc) {
644          gpg_keycache_rewind (pubkc);          gpg_keycache_rewind (pubkc);
645          while (!err) {              while (!err) {    
646              err = gpg_keycache_next_key (pubkc, 0, &key);              err = gpg_keycache_next_key2 (pubkc, 0, &c, &key);
647              if (!err)              if (!err)
648                  keylist_add_key (lv, mode, key);                  keylist_add_key (lv, mode, c, key);
649          }          }
650      }      }
651  }  }
# Line 632  keylist_load (HWND ctrl, gpg_keycache_t Line 665  keylist_load (HWND ctrl, gpg_keycache_t
665          return NULL;                      return NULL;            
666      keylist_load_keycache (lv, mode, pubkc, seckc);      keylist_load_keycache (lv, mode, pubkc, seckc);
667      keylist_sort (lv, sortby);      keylist_sort (lv, sortby);
668      if ((mode & KEYLIST_ENCRYPT) || (mode & KEYLIST_ENCRYPT_MIN))      if (mode & KEYLIST_ENCRYPT_MIN)
669          keylist_add_groups (lv);          keylist_add_groups (lv);
670      return lv;      return lv;
671  }  }
# Line 643  int Line 676  int
676  keylist_reload (listview_ctrl_t lv, gpg_keycache_t pubkc, int mode, int sortby)  keylist_reload (listview_ctrl_t lv, gpg_keycache_t pubkc, int mode, int sortby)
677  {  {
678      listview_del_all_items (lv);      listview_del_all_items (lv);
679      keylist_load_keycache( lv, mode, pubkc, NULL );      keylist_load_keycache (lv, mode, pubkc, NULL);
680      keylist_sort (lv, sortby);      keylist_sort (lv, sortby);
681      return 0;      return 0;
682  }  }
# Line 678  find_secret_key (gpgme_key_t key) Line 711  find_secret_key (gpgme_key_t key)
711    
712    
713  static int  static int
714  do_addkey (listview_ctrl_t lv, gpgme_key_t key, int uididx, int keyidx, int list)  do_addkey (listview_ctrl_t lv, struct keycache_s *ctx, gpgme_key_t key,
715               int uididx, int keyidx, int list)
716  {      {    
717      LV_ITEM lvi;      LV_ITEM lvi;
718      gpgme_user_id_t u;      gpgme_user_id_t u;
# Line 695  do_addkey (listview_ctrl_t lv, gpgme_key Line 729  do_addkey (listview_ctrl_t lv, gpgme_key
729                     key->uids->name, key->subkeys->keyid);                     key->uids->name, key->subkeys->keyid);
730          return 0;          return 0;
731      }      }
732            
733      if (listview_add_item2 (lv, " ", (void *)key))      if (listview_add_item2 (lv, " ", (void *)ctx))
734          return WPTERR_GENERAL;          return WPTERR_GENERAL;
735    
736      attr = key->uids->uid;      attr = ctx->uids->uid;
737      memset (&lvi, 0, sizeof lvi);      memset (&lvi, 0, sizeof lvi);
738      lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;      lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
739      lvi.pszText = (char *)attr;      lvi.pszText = (char *)attr;
740      lvi.iImage = find_secret_key (key)? 1 : 0;      lvi.iImage = find_secret_key (key)? 1 : 0;
741      lvi.lParam = (LPARAM )key;      lvi.lParam = (LPARAM )ctx;
742      if (ListView_SetItem (lv->ctrl, &lvi) == FALSE)      if (ListView_SetItem (lv->ctrl, &lvi) == FALSE)
743          return WPTERR_GENERAL;          return WPTERR_GENERAL;
744                    
745      if (uididx == -1) { /* request the primary user-id of the key. */      if (uididx == -1) { /* request the primary user-id of the key. */
746          attr = key->uids->uid;          attr = ctx->uids->uid;
747          uididx = 0;          uididx = 0;
748      }      }
749      else {      else {
# Line 723  do_addkey (listview_ctrl_t lv, gpgme_key Line 757  do_addkey (listview_ctrl_t lv, gpgme_key
757          attr = _("Invalid User ID");          attr = _("Invalid User ID");
758          listview_add_sub_item (lv, 0, idx++, attr);          listview_add_sub_item (lv, 0, idx++, attr);
759      }        }  
760      else {      else        
761          char *uid = utf8_to_wincp (attr, strlen (attr));          listview_add_sub_item (lv, 0, idx++, attr);
         if (uid) {  
             listview_add_sub_item (lv, 0, idx++, uid);  
             free (uid);  
         }  
     }  
762      k = get_nth_key (key, keyidx);      k = get_nth_key (key, keyidx);
763      if (k && k->keyid) {      if (k && k->keyid) {
764          _snprintf (fmt, sizeof fmt -1, "0x%s", k->keyid + 8);          _snprintf (fmt, sizeof fmt -1, "0x%s", k->keyid + 8);
765          listview_add_sub_item( lv, 0, idx++, fmt );          listview_add_sub_item (lv, 0, idx++, fmt);
766      }      }
767      if (list > 0) {      if (list > 0) {
768          key_attr = find_secret_key (key);          key_attr = find_secret_key (key);
# Line 753  do_addkey (listview_ctrl_t lv, gpgme_key Line 782  do_addkey (listview_ctrl_t lv, gpgme_key
782          if (attr)          if (attr)
783              listview_add_sub_item( lv, 0, idx++, attr);              listview_add_sub_item( lv, 0, idx++, attr);
784      }      }
785      if( lv->cols >= 4 ) {      if (lv->cols >= 4) {
786          p = get_key_status( key, uididx, list > 0? 1 : 0 );          p = get_key_status( key, uididx, list > 0? 1 : 0 );
787          if (!p)          if (!p)
788              return WPTERR_GENERAL;              return WPTERR_GENERAL;
# Line 784  keylist_upd_col (listview_ctrl_t lv, int Line 813  keylist_upd_col (listview_ctrl_t lv, int
813  {  {
814      gpgme_key_t key;      gpgme_key_t key;
815      const char *s;      const char *s;
816      char buf[32];      char buf[32], *p;
817      int i;      int i;
818    
819      for (i=0; i < listview_count_items (lv, 0); i++) {      for (i=0; i < listview_count_items (lv, 0); i++) {
820          key = (gpgme_key_t)listview_get_item2 (lv, i);          key = km_get_key_ptr (lv, i, NULL);
821          if (!key)          if (!key)
822              continue;              continue;
823          switch (col) {          switch (col) {
# Line 811  keylist_upd_col (listview_ctrl_t lv, int Line 840  keylist_upd_col (listview_ctrl_t lv, int
840              s = get_key_created (key->subkeys->timestamp);              s = get_key_created (key->subkeys->timestamp);
841              listview_add_sub_item (lv, i, col, s);              listview_add_sub_item (lv, i, col, s);
842              break;              break;
843    
844            case KM_COL_DESC:
845                p = get_key_desc (key);
846                listview_add_sub_item (lv, i, col, p);
847                free_if_alloc (p);
848                break;
849          }          }
850      }      }
851  }  }
# Line 819  keylist_upd_col (listview_ctrl_t lv, int Line 854  keylist_upd_col (listview_ctrl_t lv, int
854  /* Update the listview item at position @pos with the data from  /* Update the listview item at position @pos with the data from
855     the key @key. */     the key @key. */
856  void  void
857  keylist_upd_key (listview_ctrl_t lv, int pos, gpgme_key_t key)  keylist_upd_key (listview_ctrl_t lv, int pos,
858                     struct keycache_s *ctx, gpgme_key_t key)
859  {  {
860      const char *s;      const char *s;
861      char *uid;      char *p;
862      char tmp[32];      char tmp[32];
863    
864      listview_set_item2 (lv, pos, (void *)key);      listview_set_item2 (lv, pos, (void *)ctx);
865      /* the only mode we support is KYLIST_LIST in the Key Manager */      /* the only mode we support is KEYLIST_LIST in the Key Manager */
866            
867      s = key->uids->uid;      s = ctx->uids->uid;
868      if (s) {      if (s)
869          uid = utf8_to_wincp2 (s);          listview_add_sub_item (lv, pos, KM_COL_UID, s);
         listview_add_sub_item (lv, pos, 0, uid);  
         free (uid);  
     }  
870    
871      s = key->subkeys->keyid;      s = key->subkeys->keyid;
872      if (s) {      if (s) {
873          sprintf (tmp, "0x%s", s+8);          sprintf (tmp, "0x%s", s+8);
874          listview_add_sub_item (lv, pos, 1, tmp);          listview_add_sub_item (lv, pos, KM_COL_KEYID, tmp);
875      }      }
876    
877      s = find_secret_key (key)? "pub/sec" : "pub";      s = find_secret_key (key)? "pub/sec" : "pub";
878      listview_add_sub_item (lv, pos, 2, s);      listview_add_sub_item (lv, pos, KM_COL_TYPE, s);
879    
880      s = get_key_size (key, 0);      s = get_key_size (key, 0);
881      if (s)      if (s)
882          listview_add_sub_item (lv, pos, 3, s);          listview_add_sub_item (lv, pos, KM_COL_SIZE, s);
883    
884      s = get_key_algo (key, 0);      s = get_key_algo (key, 0);
885      if (s)      if (s)
886          listview_add_sub_item (lv, pos, 4, s);          listview_add_sub_item (lv, pos, KM_COL_CIPHER, s);
887    
888      s = get_key_status (key, 0, 1);      p = get_key_status (key, 0, 1);
889      if (s)      if (p) {
890          listview_add_sub_item (lv, pos, 5, s);          listview_add_sub_item (lv, pos, KM_COL_VALID, p);
891            free_if_alloc (p);
892        }
893    
894      s = get_key_trust (key, 0, 1);      s = get_key_trust (key, 0, 1);
895      if (s)      if (s)
896          listview_add_sub_item (lv, pos, 6, s);          listview_add_sub_item (lv, pos, KM_COL_TRUST, s);
897    
898      long t = key->subkeys->timestamp;      long t = key->subkeys->timestamp;
899      s = get_key_created (t);      s = get_key_created (t);
900      if (s)      if (s)
901          listview_add_sub_item (lv, pos, 7, s);          listview_add_sub_item (lv, pos, KM_COL_CREAT, s);
902  }  }
903    
904    
905  int  int
906  keylist_add_key (listview_ctrl_t lv, int mode, gpgme_key_t key)  keylist_add_key (listview_ctrl_t lv, int mode,
907                     struct keycache_s *ctx, gpgme_key_t key)
908  {  {
909      int uids, rc = 0, i;      int uids, rc = 0, i;
910      gpgme_subkey_t k;      gpgme_subkey_t k;
# Line 885  keylist_add_key (listview_ctrl_t lv, int Line 921  keylist_add_key (listview_ctrl_t lv, int
921    
922          if (mode & KEYLIST_ALL) {          if (mode & KEYLIST_ALL) {
923              uids = count_userids (key);              uids = count_userids (key);
924              rc = do_addkey (lv, key, uids, i, 0);              rc = do_addkey (lv, ctx, key, uids, i, 0);
925              if (rc)              if (rc)
926                  return rc;                  return rc;
927          }          }
928          else if (mode & KEYLIST_LIST)          else if (mode & KEYLIST_LIST)
929              return do_addkey (lv, key, -1, i, 1);              return do_addkey (lv, ctx, key, -1, i, 1);
930          else if (mode & KEYLIST_ENCRYPT) {          else if (mode & KEYLIST_ENCRYPT) {
931              if (k->can_encrypt && key_is_useable (k)) {              if (k->can_encrypt && key_is_useable (k)) {
932                  if (mode & KEYLIST_FLAG_FILE) {                  if (mode & KEYLIST_FLAG_FILE) {
933                      rc = do_addkey (lv, key, -1, i, -1);                      rc = do_addkey (lv, ctx, key, -1, i, -1);
934                      if (rc)                      if (rc)
935                          return rc;                          return rc;
936                  }                  }
937                  else {                  else {
938                      for (uids = 0;  uids < count_userids (key); uids++) {                      for (uids = 0;  uids < count_userids (key); uids++) {
939                          rc = do_addkey (lv, key, uids, i, -1);                          rc = do_addkey (lv, ctx, key, uids, i, -1);
940                          if (rc)                          if (rc)
941                              return rc;                              return rc;
942                      }                      }
# Line 910  keylist_add_key (listview_ctrl_t lv, int Line 946  keylist_add_key (listview_ctrl_t lv, int
946          else if (mode & KEYLIST_ENCRYPT_MIN) {          else if (mode & KEYLIST_ENCRYPT_MIN) {
947              if( k->can_encrypt && key_is_useable (k))              if( k->can_encrypt && key_is_useable (k))
948              {              {
949                  rc = do_addkey (lv, key, -1, i, -1);                  rc = do_addkey (lv, ctx, key, -1, i, -1);
950                  return rc;                  return rc;
951              }              }
952          }                }      
# Line 918  keylist_add_key (listview_ctrl_t lv, int Line 954  keylist_add_key (listview_ctrl_t lv, int
954              if (k->can_sign              if (k->can_sign
955                  && find_secret_key (key)                  && find_secret_key (key)
956                  && key_is_useable (k)) {                  && key_is_useable (k)) {
957                  rc = do_addkey (lv, key, -1, i, -1);                  rc = do_addkey (lv, ctx, key, -1, i, -1);
958                  if (rc)                  if (rc)
959                      return rc;                        return rc;  
960              }              }
# Line 959  gpgme_key_t* Line 995  gpgme_key_t*
995  keylist_get_recipients (listview_ctrl_t lv, int *r_force_trust, int *r_count)  keylist_get_recipients (listview_ctrl_t lv, int *r_force_trust, int *r_count)
996  {  {
997      key_array_s *ka = NULL;      key_array_s *ka = NULL;
998        keycache_s *c;
999      gpgme_key_t *keybuf, key;      gpgme_key_t *keybuf, key;
1000      int count = 0, force_trust = 0;      int count = 0, force_trust = 0;
1001      int n, j, ka_pos = 0, rc = 0;      int n, j, ka_pos = 0, rc = 0;
# Line 970  keylist_get_recipients (listview_ctrl_t Line 1007  keylist_get_recipients (listview_ctrl_t
1007      if (!ka)      if (!ka)
1008          BUG (NULL);          BUG (NULL);
1009    
1010      keybuf = (gpgme_key_t*)calloc (n, sizeof (gpgme_key_t));      keybuf = (gpgme_key_t*)calloc (n+1, sizeof (gpgme_key_t));
1011      if (!keybuf)      if (!keybuf)
1012          BUG (NULL);          BUG (NULL);
1013                    
1014      for (j = 0; j < n; j++) {      for (j = 0; j < n; j++) {
1015          if (listview_get_item_state (lv, j) || n == 1) {          if (listview_get_item_state (lv, j) || n == 1) {
1016              key = (gpgme_key_t)listview_get_item2 (lv, j);              key = km_get_key_ptr (lv, j, &c);
1017              if (!key)              if (!key)
1018                  BUG (0);                  BUG (0);
1019              if (!key_check_validity (key) &&              if (!key_check_validity (key) &&
1020                  !key_array_search (ka, ka_pos, key->subkeys->keyid)) {                  !key_array_search (ka, ka_pos, key->subkeys->keyid)) {
1021                  char *warn = new char[512+strlen (key->uids->uid) + 1];                  char *warn = new char[512+strlen (c->uids->uid) + 1];
1022                  if (!warn)                  if (!warn)
1023                      BUG (0);                      BUG (0);
1024                  sprintf (warn,                  sprintf (warn,
# Line 989  keylist_get_recipients (listview_ctrl_t Line 1026  keylist_get_recipients (listview_ctrl_t
1026                        "named in the user ID.  If you *really* know what you are\n"                        "named in the user ID.  If you *really* know what you are\n"
1027                        "doing, you may answer the next question with yes\n"                        "doing, you may answer the next question with yes\n"
1028                        "\n"                        "\n"
1029                        "Use \"%s\" anyway?"), key->uids->uid);                        "Use \"%s\" anyway?"), c->uids->uid);
1030                  if (reg_prefs.always_trust)                  if (reg_prefs.always_trust)
1031                      rc = IDYES;                      rc = IDYES;
1032                  else                  else
# Line 1037  keylist_get_keyflags (gpgme_key_t key) Line 1074  keylist_get_keyflags (gpgme_key_t key)
1074  gpgme_key_t*  gpgme_key_t*
1075  keylist_enum_recipients (listview_ctrl_t lv,  int listype, int *r_count)  keylist_enum_recipients (listview_ctrl_t lv,  int listype, int *r_count)
1076  {  {
1077        struct keycache_s *c;
1078      gpgme_key_t *rset;      gpgme_key_t *rset;
1079      gpgme_key_t key;      gpgme_key_t key;
1080      int i, n, id, k_pos=0;      int i, n, id, k_pos=0;
# Line 1044  keylist_enum_recipients (listview_ctrl_t Line 1082  keylist_enum_recipients (listview_ctrl_t
1082      n = listview_count_items (lv, 0);      n = listview_count_items (lv, 0);
1083      if (!n)      if (!n)
1084          return 0;          return 0;
1085      rset = (gpgme_key_t*)calloc (n, sizeof (gpgme_key_t));      rset = (gpgme_key_t*)calloc (n+1, sizeof (gpgme_key_t));
1086      if (!rset)      if (!rset)
1087          BUG (NULL);          BUG (NULL);
1088      for (i = 0; i < n; i++) {      for (i = 0; i < n; i++) {
1089          if (!listview_get_item_state (lv, i))          if (!listview_get_item_state (lv, i))
1090              continue;              continue;
1091          key = (gpgme_key_t)listview_get_item2 (lv, i);          key = km_get_key_ptr (lv, i, &c);
         if (!key)  
             BUG (0);  
1092          switch (listype) {          switch (listype) {
1093          case KEYLIST_LIST:          case KEYLIST_LIST:
1094              if (keylist_get_keyflags (key) & KEYFLAG_REVOKED) {              if (keylist_get_keyflags (key) & KEYFLAG_REVOKED) {
1095                  id = printf_box (_("Recipients"), MB_INFO|MB_YESNO,                  id = printf_box (_("Recipients"), MB_INFO|MB_YESNO,
1096                  _("KeyID %s.\nDo you really want to export a revoked key?"),                  _("KeyID %s.\nDo you really want to export a revoked key?"),
1097                                   key->uids->uid);                                   c->uids->uid);
1098                  if (id == IDNO)                  if (id == IDNO)
1099                      continue;                      continue;
1100              }              }
# Line 1119  seclist_init (HWND dlg, int ctlid, int f Line 1155  seclist_init (HWND dlg, int ctlid, int f
1155          if (key->disabled || !key_is_useable (key->subkeys))          if (key->disabled || !key_is_useable (key->subkeys))
1156              continue;              continue;
1157    
1158          uid = utf8_to_wincp (id, strlen (id));          uid = utf8_to_native (id);
1159          size = strlen (uid) + strlen (keyid) + 32;          size = strlen (uid) + strlen (keyid) + 32;
1160          inf = new char[size+1];          inf = new char[size+1];
1161          if (!inf)          if (!inf)

Legend:
Removed from v.150  
changed lines
  Added in v.205

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26