/[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 99 by twoaday, Fri Nov 25 07:47:51 2005 UTC revision 228 by twoaday, Thu Jun 15 11:37:53 2006 UTC
# Line 1  Line 1 
1  /* wptKeylist.cpp - Keylist element  /* wptKeylist.cpp - Keylist element
2   *      Copyright (C) 2001-2005 Timo Schulz   *      Copyright (C) 2001-2006 Timo Schulz
3   *      Copyright (C) 2004 Andreas Jobs   *      Copyright (C) 2004 Andreas Jobs
4   *   *
5   * This file is part of WinPT.   * This file is part of WinPT.
# Line 18  Line 18 
18   * along with WinPT; if not, write to the Free Software Foundation,   * along with WinPT; if not, write to the Free Software Foundation,
19   * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA   * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20   */   */
21    
22  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
23  #include <config.h>  #include <config.h>
24  #endif  #endif
# Line 37  Line 38 
38  #include "wptUTF8.h"  #include "wptUTF8.h"
39  #include "wptRegistry.h"  #include "wptRegistry.h"
40  #include "wptContext.h"  #include "wptContext.h"
41    #include "wptVersion.h"
42    #include "resource.h"
43    
44  #define key_is_useable(key) (!(key)->revoked && !(key)->expired && !(key)->disabled)  #define key_is_useable(key) (!(key)->revoked && !(key)->expired && !(key)->disabled)
45    
 static struct listview_column_s klist_enc[] = {  
     {0, 242, (char *)_("User ID")},  
     {1, 80, (char *)_("Key ID")},  
     {3, 46, (char *)_("Size")},  
     {4, 50, (char *)_("Cipher")},  
     {5, 70, (char *)_("Validity")},  
     {0, 0, NULL}  
 };  
 #define KLIST_ENC_ITEMS (DIM(klist_enc) -1)  
   
 static struct listview_column_s klist[] = {  
     {0, 242, (char *)_("User ID")},  
     {1, 78, (char *)_("Key ID")},  
     {2, 52, (char *)_("Type")},      
     {3, 68, (char *)_("Size")},  
     {4, 66, (char *)_("Cipher")},  
     {5, 70, (char *)_("Validity")},  
     {6, 40, (char *)_("Trust")},  
     {7, 72, (char *)_("Creation")},  
     {0, 0, NULL}  
 };  
 #define KLIST_ITEMS (DIM(klist) - 1)  
   
46  struct key_array_s {  struct key_array_s {
47      char keyid[32];      char keyid[32];
48      int checked;      int checked;
# Line 73  static int find_secret_key (gpgme_key_t Line 52  static int find_secret_key (gpgme_key_t
52    
53    
54  static key_array_s*  static key_array_s*
55  key_array_new( size_t items )  key_array_new (int items)
56  {  {
57      key_array_s *ka;      key_array_s *ka;
58      size_t j;      int j;
59            
60      if( items == 0 )      if (items == 0)
61          return NULL;          return NULL;
62      ka = new key_array_s[items + 1];      ka = new key_array_s[items + 1];
63      if( ka == NULL )      if (!ka)
64          return NULL;              BUG (NULL);
65      for ( j = 0; j < items; j++ )      for (j = 0; j < items; j++)
66          ka[j].checked = 0;          ka[j].checked = 0;
67      return ka;      return ka;
68  } /* key_array_new */  }
69    
70    
71  static void  static void
72  key_array_release( key_array_s *ka )  key_array_release (key_array_s *ka)
73  {  {
74      free_if_alloc( ka );      free_if_alloc (ka);
75  } /* key_array_release */  }
76    
77    
78    /* Check if the keyid @keyid is in the key array @ka.
79       Return value: 1 if it exists, 0 otherwise. */
80  static int  static int
81  key_array_search( key_array_s *ka, size_t items, const char *keyid )  key_array_search (key_array_s *ka, int items, const char *keyid)
82  {  {
83      size_t j;      int j;
84            
85      /* fixme: we need a faster search method */      for (j = 0; j < items; j++) {
86      for( j = 0; j < items; j++ ) {          if (!strcmp (keyid, ka[j].keyid))
         if( !strcmp( keyid, ka[j].keyid ) )  
87              return 1;                return 1;  
88      }      }
       
89      return 0;      return 0;
90  } /* key_array_search */  }
91    
92    
93  gpgme_user_id_t  gpgme_user_id_t
# Line 173  count_subkeys (gpgme_key_t key) Line 152  count_subkeys (gpgme_key_t key)
152  }  }
153    
154    
155    /* Return the self signature of the key @keyid.
156       If first is set, the first self sig will be returned. */
157  gpgme_key_sig_t  gpgme_key_sig_t
158  get_selfsig (gpgme_user_id_t uid, const char *keyid, int first)  get_selfsig (gpgme_key_sig_t sigs, const char *keyid, int first)
159  {  {
160      gpgme_key_sig_t s, self_sig=NULL;      gpgme_key_sig_t s, self_sig=NULL;
161      long timestamp=0;      long timestamp=0;
162        int off = 0;
163    
164      for (s = uid->signatures; s; s = s->next) {      if (strlen (keyid) == 8)
165          if (!strcmp (s->keyid+8, keyid) && s->timestamp > timestamp) {          off = 8;
166    
167        for (s = sigs; s; s = s->next) {
168            if (!strcmp (s->keyid+off, keyid) && s->timestamp > timestamp) {
169              self_sig = s;              self_sig = s;
170              timestamp = s->timestamp;              timestamp = s->timestamp;
171              if (first)              if (first)
# Line 191  get_selfsig (gpgme_user_id_t uid, const Line 176  get_selfsig (gpgme_user_id_t uid, const
176  }  }
177    
178    
   
179  const char*  const char*
180  get_key_algo (gpgme_key_t key, int keyidx)  get_key_algo (gpgme_key_t key, int keyidx)
181  {  {
# Line 204  get_key_algo (gpgme_key_t key, int keyid Line 188  get_key_algo (gpgme_key_t key, int keyid
188      if (keyidx > 0) {      if (keyidx > 0) {
189          k = get_nth_key (key, keyidx-1);          k = get_nth_key (key, keyidx-1);
190          subalg =  get_key_pubalgo (k->pubkey_algo);          subalg =  get_key_pubalgo (k->pubkey_algo);
191          _snprintf( algo_id, DIM (algo_id)-1, "%s", subalg);          _snprintf (algo_id, DIM (algo_id)-1, "%s", subalg);
192          return algo_id;          return algo_id;
193      }      }
194      strcpy (alg, get_key_pubalgo (key->subkeys->pubkey_algo));      strcpy (alg, get_key_pubalgo (key->subkeys->pubkey_algo));
195      n = count_subkeys (key);      n = count_subkeys (key);
196      if (n > 1) {      if (n > 1) {
197          k = get_nth_key (key, n-1);          do {
198                k = get_nth_key (key, --n);
199                if (k->revoked || k->expired)
200                    continue;
201                else
202                    break;
203            } while (n > 0);
204          subalg = get_key_pubalgo (k->pubkey_algo);          subalg = get_key_pubalgo (k->pubkey_algo);
205          _snprintf (algo_id, DIM (algo_id)-1, "%s/%s", alg, subalg);          if (k == key->subkeys)
206                _snprintf (algo_id, DIM (algo_id)-1, "%s", subalg);
207            else
208                _snprintf (algo_id, DIM (algo_id)-1, "%s/%s", alg, subalg);
209          return algo_id;          return algo_id;
210      }      }
211      return get_key_pubalgo (key->subkeys->pubkey_algo);      return get_key_pubalgo (key->subkeys->pubkey_algo);
212  } /* get_key_algo */  }
213    
214    
215  const char*  const char*
# Line 224  get_key_created (long timestamp) Line 217  get_key_created (long timestamp)
217  {  {
218      static char timebuf[128];      static char timebuf[128];
219      struct tm *warp;      struct tm *warp;
220        const char *dat;
221    
222      if (timestamp == 0 || timestamp == -1)      if (timestamp < 1)
223          return "????" "-??" "-??";          return "????" "-??" "-??";
224      warp = localtime( &timestamp );      dat = get_locale_date (timestamp, timebuf, sizeof (timebuf)-1);
225      _snprintf( timebuf, sizeof timebuf - 1, "%04d-%02d-%02d",      if (dat)
226                  warp->tm_year + 1900, warp->tm_mon + 1, warp->tm_mday );          return dat;
227        /* Fallback if locate date conversion failed. */
228        warp = localtime (&timestamp);
229        _snprintf (timebuf, sizeof timebuf - 1, "%04d-%02d-%02d",
230                   warp->tm_year + 1900, warp->tm_mon + 1, warp->tm_mday);
231      return timebuf;      return timebuf;
232  } /* get_key_created */  }
233    
234    
235  /* Return a string presentation of the time @timestamp. */  /* Return a string presentation of the time @timestamp. */
# Line 240  get_key_expire_date (long timestamp) Line 238  get_key_expire_date (long timestamp)
238  {  {
239      static char timebuf[64];      static char timebuf[64];
240      struct tm *warp;      struct tm *warp;
241        const char *dat;
242    
243      if( !timestamp )      if (timestamp == 0)
244          return _("Never");          return _("Never");
245      warp = localtime( &timestamp );      dat = get_locale_date (timestamp, timebuf, sizeof (timebuf)-1);
246        if (dat)
247            return dat;
248        warp = localtime (&timestamp);
249      _snprintf (timebuf, sizeof timebuf -1, "%04d-%02d-%02d",      _snprintf (timebuf, sizeof timebuf -1, "%04d-%02d-%02d",
250                 warp->tm_year + 1900, warp->tm_mon + 1, warp->tm_mday);                 warp->tm_year + 1900, warp->tm_mon + 1, warp->tm_mday);
251      return timebuf;      return timebuf;
# Line 260  get_key_type (gpgme_key_t key) Line 262  get_key_type (gpgme_key_t key)
262      else if (type == 2)      else if (type == 2)
263          return _("Key Pair (Card)");          return _("Key Pair (Card)");
264      return _("Public Key");      return _("Public Key");
265  } /* get_key_type */  }
266    
267    
268  const char*  const char*
# Line 281  get_key_size (gpgme_key_t key, int keyid Line 283  get_key_size (gpgme_key_t key, int keyid
283      if (n > 1) {      if (n > 1) {
284          k = get_nth_key (key, n-1);          k = get_nth_key (key, n-1);
285          size_sub = k->length;          size_sub = k->length;
286          _snprintf( size_id, sizeof (size_id) - 1, "%d/%d", size_main, size_sub );          _snprintf (size_id, sizeof (size_id) - 1, "%d/%d",
287                        size_main, size_sub);
288          return size_id;          return size_id;
289      }      }
290      _snprintf( size_id, sizeof (size_id) - 1, "%d", size_main );      _snprintf( size_id, sizeof (size_id) - 1, "%d", size_main );
291      return size_id;      return size_id;
292  } /* get_key_size */  }
293    
294    
295    const char*
296    get_key_pubalgo2 (gpgme_pubkey_algo_t alg)
297    {
298        switch (alg) {
299        case GPGME_PK_DSA: return "D";
300        case GPGME_PK_RSA: return "R";
301        case GPGME_PK_ELG: return "G";
302        default: return "?";
303        }
304        return "?";
305    }
306    
307    
308  const char*  const char*
# Line 296  get_key_pubalgo (gpgme_pubkey_algo_t alg Line 312  get_key_pubalgo (gpgme_pubkey_algo_t alg
312      case GPGME_PK_DSA: return "DSA";      case GPGME_PK_DSA: return "DSA";
313      case GPGME_PK_ELG:      case GPGME_PK_ELG:
314      case GPGME_PK_ELG_E: return "ELG";      case GPGME_PK_ELG_E: return "ELG";
315      case GPGME_PK_RSA: return "RSA";      case 0: /* XXX: do we still need this?? */
316        case GPGME_PK_RSA:
317        case GPGME_PK_RSA_S:
318        case GPGME_PK_RSA_E: return "RSA";
319      default: return "???";      default: return "???";
320      }      }
321      return "???";      return "???";
322  }  }
323    
324  const char *  const char*
325  get_key_fpr (gpgme_key_t key)  get_key_fpr (gpgme_key_t key)
326  {  {
327      static char fpr_md[64];      static char fpr_md[64];
# Line 331  get_key_fpr (gpgme_key_t key) Line 350  get_key_fpr (gpgme_key_t key)
350          }          }
351      }      }
352      return fpr_md;      return fpr_md;
353  } /* get_key_fpr */  }
354    
355    
356  const char *  /* Extract the key ID from the fingerprint.
357       A long ID will be converted into a short ID. */
358    const char*
359    get_keyid_from_fpr (const char *fpr)
360    {
361        if (!fpr)
362            return "????????";
363        if (strlen (fpr) == 40)
364            fpr += 32;
365        else if (strlen (fpr) == 32)
366            fpr += 24;
367        else if (strlen (fpr) == 16)
368            fpr += 8;
369        else
370            return "????????";
371        return fpr;
372    }
373    
374    
375    const char*
376  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)
377  {  {
378      if (key)      if (key)
# Line 348  get_key_trust2 (gpgme_key_t key, int val Line 386  get_key_trust2 (gpgme_key_t key, int val
386      case GPGME_VALIDITY_MARGINAL:      case GPGME_VALIDITY_MARGINAL:
387          return _("Marginal");          return _("Marginal");
388      case GPGME_VALIDITY_FULL:      case GPGME_VALIDITY_FULL:
     case GPGME_VALIDITY_ULTIMATE:  
389          return _("Full");          return _("Full");
390        case GPGME_VALIDITY_ULTIMATE:
391            return _("Ultimate");
392      }      }
393      return "";      return "";
394  }  }
395    
396    
397  const char *  const char*
398  get_key_trust (gpgme_key_t key, int uididx, int listmode)  get_key_trust (gpgme_key_t key, int uididx, int listmode)
399  {  {
400      return get_key_trust2 (key, 0, uididx, listmode);      return get_key_trust2 (key, 0, uididx, listmode);
401  }  }
402    
403    
404  const char *  const char*
405  get_key_trust_str (int val)  get_key_trust_str (int val)
406  {  {
407      return get_key_trust2 (NULL, val, 0, 0);      return get_key_trust2 (NULL, val, 0, 0);
# Line 380  get_key_status (gpgme_key_t key, int uid Line 419  get_key_status (gpgme_key_t key, int uid
419      if (uididx < 0 || count_userids (key) > uididx)      if (uididx < 0 || count_userids (key) > uididx)
420          uididx = 0;          uididx = 0;
421      if (listmode) {      if (listmode) {
422          const char *s;          const char *s;
         
423          if (key->revoked)          if (key->revoked)
424              s = _("Revoked");              s = _("Revoked");
425          else if (key->expired)          else if (key->expired)
426              s = _("Expired");              s = _("Expired");
427          else if (key->disabled)          else if (key->disabled)
428              s = _("Disabled");              s = _("Disabled");
429          else          else
430            s = "";              s = "";
           
431          /* if the key has a special status, we don't continue to figure out          /* if the key has a special status, we don't continue to figure out
432             what any user-id validities. */             the user-id validities. */
433          if (*s)          if (*s)
434              return m_strdup (s);              return m_strdup (s);
435      }      }
# Line 403  get_key_status (gpgme_key_t key, int uid Line 440  get_key_status (gpgme_key_t key, int uid
440  }  }
441    
442    
443    /* Return human readable description of the key @key. */
444    char*
445    get_key_desc (gpgme_key_t key)
446    {
447        gpgme_key_t sk;
448        const char *state, *alg, *type;
449        char *p;
450    
451        /* XXX: problems with the German translation. */
452        state = "";
453        if (key->disabled)
454            state = _("Disabled");
455        if (key->expired)
456            state = _("Expired");
457        if (key->revoked)
458            state = _("Revoked");
459        alg = "OpenPGP";
460        if (strlen (key->subkeys->fpr) == 32)
461            alg = "RSA Legacy";
462        type = _("public key");
463        if (!get_seckey (key->subkeys->keyid+8, &sk))
464            type = _("key pair");
465        p = new char[strlen (state) + strlen (alg) + strlen (type) + 4 + 1];
466        if (!p)
467            BUG (0);
468        sprintf (p, "%s %s %s", state, alg, type);
469        return p;
470    }
471    
472    
473  /* Integer comparsion of @a and @b.  /* Integer comparsion of @a and @b.
474     Return values: same as in strcmp. */     Return values: same as in strcmp. */
475  static inline int  static inline int
# Line 424  get_ext_validity (gpgme_key_t k) Line 491  get_ext_validity (gpgme_key_t k)
491          return GPGME_VALIDITY_ULTIMATE+1;          return GPGME_VALIDITY_ULTIMATE+1;
492      else if (k->expired)      else if (k->expired)
493          return GPGME_VALIDITY_ULTIMATE+2;          return GPGME_VALIDITY_ULTIMATE+2;
494        else if (k->disabled)
495            return GPGME_VALIDITY_ULTIMATE+3;
496      return k->uids->validity;      return k->uids->validity;
497  }  }
498    
# Line 432  get_ext_validity (gpgme_key_t k) Line 501  get_ext_validity (gpgme_key_t k)
501  static int CALLBACK  static int CALLBACK
502  keylist_cmp_cb (LPARAM first, LPARAM second, LPARAM sortby)  keylist_cmp_cb (LPARAM first, LPARAM second, LPARAM sortby)
503  {  {
504        struct keycache_s *aa, *bb;
505      gpgme_key_t a, b;      gpgme_key_t a, b;
506      int cmpresult = 0;      int cmpresult = 0;
507            
508      a = (gpgme_key_t)first;      aa = (struct keycache_s *)first;
509      b = (gpgme_key_t)second;      bb = (struct keycache_s *)second;
510      if (!a || !b)      if (!aa || !bb)
511          BUG (NULL);          BUG (NULL);
512        a = aa->key;
513        b = bb->key;
514            
515      switch (sortby & ~KEYLIST_SORT_DESC) {      switch (sortby & ~KEYLIST_SORT_DESC) {
516      case KEY_SORT_USERID:      case KEY_SORT_USERID:
# Line 491  keylist_cmp_cb (LPARAM first, LPARAM sec Line 563  keylist_cmp_cb (LPARAM first, LPARAM sec
563  }  }
564    
565    
 /* 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");  
 }  
   
   
566  int  int
567  keylist_add_groups( listview_ctrl_t lv )  keylist_add_groups (listview_ctrl_t lv)
568  {  {
 #if 0  
     gpg_optfile_t gh;  
     gpg_group_t grp;  
     const char *valid;  
   
     gh = km_groupdb_open( );      
     if( !gh )    
         return WPTERR_FILE_OPEN;  
   
     for( grp = gh->grp; grp; grp = grp->next ) {  
         valid = calc_validity( grp );  
         listview_add_item( lv, " " );    
         listview_add_sub_item( lv, 0, 0, grp->name );    
         listview_add_sub_item( lv, 0, 1, "gpg_group_t" );        
         listview_add_sub_item( lv, 0, 2, "" );    
         listview_add_sub_item( lv, 0, 3, "Unknown" );  
         listview_add_sub_item( lv, 0, 4, valid?valid : "Unknown" );  
     }  
 #endif  
569      return 0;      return 0;
570  } /* keylist_add_groups */  }
571    
572    
573  /* Create a listview for listing keys. Use the mode given in @mode  /* Create a listview for listing keys. Use the mode given in @mode
# Line 545  keylist_add_groups( listview_ctrl_t lv ) Line 575  keylist_add_groups( listview_ctrl_t lv )
575  static int  static int
576  keylist_build (listview_ctrl_t *r_lv, HWND ctrl, int mode)  keylist_build (listview_ctrl_t *r_lv, HWND ctrl, int mode)
577  {  {
578        struct listview_column_s klist_enc[] = {
579        {0, 242, (char *)_("User ID")},
580        {1, 80, (char *)_("Key ID")},
581        {3, 46, (char *)_("Size")},
582        {4, 50, (char *)_("Cipher")},
583        {5, 70, (char *)_("Validity")},
584        {0, 0, NULL}
585        };
586        struct listview_column_s klist[] = {
587        {0, 240, (char *)_("User ID")},
588        {1, 78, (char *)_("Key ID")},
589        {2, 52, (char *)_("Type")},    
590        {3, 66, (char *)_("Size")},
591        {4, 60, (char *)_("Cipher")},
592        {5, 66, (char *)_("Validity")},
593        {6, 58, (char *)_("Trust")},
594        {7, 72, (char *)_("Creation")},
595        {0, 0, NULL}
596        };
597        HICON ico[2];
598      listview_ctrl_t lv;      listview_ctrl_t lv;
599      listview_column_t col;      listview_column_t col;
600      int j, n = 0;      int j, n = 0, ext_chk = 0;
     int rc = 0;  
       
     rc = listview_new (&lv);  
     if( rc )  
         return rc;  
601            
602      lv->ctrl = ctrl;      listview_new (&lv, ctrl);
603      if ((mode & KEYLIST_ENCRYPT) || (mode & KEYLIST_ENCRYPT_MIN)) {      if (mode & KEYLIST_ENCRYPT_MIN) {
604          col = klist_enc;          col = klist_enc;
605          n = KLIST_ENC_ITEMS;          n = (DIM (klist_enc) -1);
606            ext_chk = 1;
607      }        }  
608      else if ((mode & KEYLIST_SIGN)) {      else if ((mode & KEYLIST_SIGN)) {
609          col = klist_enc;          col = klist_enc;
610          n = KLIST_ENC_ITEMS - 1;          n = (DIM (klist_enc) - 1) - 1;
611            ext_chk = 1;
612      }      }
613      else {      else {
614          col = klist;          col = klist;
615          n = KLIST_ITEMS;          n = (DIM (klist) - 1);
616      }      }
617            
618      for( j = 0; j < n; j++ )          for (j = 0; j < n; j++)
619          listview_add_column( lv, &col[j] );              listview_add_column (lv, &col[j]);
620      listview_set_ext_style( lv );      listview_set_ext_style (lv);
621        if (ext_chk)
622            listview_set_chkbox_style (lv);    
623        ico[0] = LoadIcon (glob_hinst, (LPCTSTR)IDI_PUBKEY);
624        ico[1] = LoadIcon (glob_hinst, (LPCTSTR)IDI_KEYPAIR);
625        listview_set_image_list (lv, 22, 14, ico, 2);
626        listview_del_all_items (lv);
627    
628      *r_lv = lv;      *r_lv = lv;
       
629      return 0;      return 0;
630  }  }
631    
# Line 583  keylist_load_keycache (listview_ctrl_t l Line 636  keylist_load_keycache (listview_ctrl_t l
636  {  {
637      gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);      gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);
638      gpgme_key_t key, skey;      gpgme_key_t key, skey;
639      const char * keyid;      struct keycache_s *c;
640        const char *keyid;
641    
642      if (pubkc && seckc) {      if (pubkc && seckc) {
643          gpg_keycache_rewind (pubkc);          gpg_keycache_rewind (pubkc);
644          while (!gpg_keycache_next_key (pubkc, 0, &key)) {          while (!gpg_keycache_next_key2 (pubkc, 0, &c, &key)) {
645              keyid = key->subkeys->keyid;              keyid = key->subkeys->keyid;
646              if (keyid && !gpg_keycache_find_key (seckc, keyid, 0, &skey))              if (keyid && !gpg_keycache_find_key (seckc, keyid, 0, &skey))
647                  keylist_add_key (lv, mode, key);                  keylist_add_key (lv, mode, c, key);
648          }                }      
649      }      }
650      else if (pubkc) {      else if (pubkc) {
651          gpg_keycache_rewind (pubkc);          gpg_keycache_rewind (pubkc);
652          while (!err) {              while (!err) {    
653              err = gpg_keycache_next_key (pubkc, 0, &key);              err = gpg_keycache_next_key2 (pubkc, 0, &c, &key);
654              if (!err)              if (!err)
655                  keylist_add_key (lv, mode, key);                  keylist_add_key (lv, mode, c, key);
656          }          }
657      }      }
658  }  }
# Line 618  keylist_load (HWND ctrl, gpg_keycache_t Line 672  keylist_load (HWND ctrl, gpg_keycache_t
672          return NULL;                      return NULL;            
673      keylist_load_keycache (lv, mode, pubkc, seckc);      keylist_load_keycache (lv, mode, pubkc, seckc);
674      keylist_sort (lv, sortby);      keylist_sort (lv, sortby);
675      if ((mode & KEYLIST_ENCRYPT) || (mode & KEYLIST_ENCRYPT_MIN))      if (mode & KEYLIST_ENCRYPT_MIN)
676          keylist_add_groups (lv);          keylist_add_groups (lv);
677      return lv;      return lv;
678  }  }
# Line 628  keylist_load (HWND ctrl, gpg_keycache_t Line 682  keylist_load (HWND ctrl, gpg_keycache_t
682  int  int
683  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)
684  {  {
685      listview_del_all (lv);      listview_del_all_items (lv);
686      keylist_load_keycache( lv, mode, pubkc, NULL );      keylist_load_keycache (lv, mode, pubkc, NULL);
687      keylist_sort (lv, sortby);      keylist_sort (lv, sortby);
688      return 0;      return 0;
689  }  }
# Line 664  find_secret_key (gpgme_key_t key) Line 718  find_secret_key (gpgme_key_t key)
718    
719    
720  static int  static int
721  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,
722               int uididx, int keyidx, int list)
723  {      {    
724      LV_ITEM lvi;      LV_ITEM lvi;
725      gpgme_user_id_t u;      gpgme_user_id_t u;
# Line 677  do_addkey (listview_ctrl_t lv, gpgme_key Line 732  do_addkey (listview_ctrl_t lv, gpgme_key
732      /* we check the pubkey algorithm here to make sure that no ElGamal      /* we check the pubkey algorithm here to make sure that no ElGamal
733         sign+encrypt key is used in _any_ mode */         sign+encrypt key is used in _any_ mode */
734      if (list != 1 && key->subkeys->pubkey_algo == GPGME_PK_ELG) {      if (list != 1 && key->subkeys->pubkey_algo == GPGME_PK_ELG) {
735          log_debug ("ElGamal (E+S) key found: %s (%s)\n",          log_debug ("ElGamal (E+S) key found: %s (%s)\n",
736                     key->uids->name, key->subkeys->keyid);                     key->uids->name, key->subkeys->keyid);
737          return 0;          return 0;
738      }      }
739    
740                if (listview_add_item2 (lv, " ", (void *)ctx))
     if (listview_add_item2 (lv, " ", (void *)key))        
741          return WPTERR_GENERAL;          return WPTERR_GENERAL;
742            
743      attr = key->uids->uid;      attr = ctx->uids->uid;
744      memset (&lvi, 0, sizeof lvi);      memset (&lvi, 0, sizeof lvi);
745      lvi.mask = LVIF_TEXT | LVIF_PARAM;      lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
746      lvi.pszText = (char *)attr;      lvi.pszText = (char *)attr;
747      lvi.lParam = (LPARAM )key;      lvi.iImage = find_secret_key (key)? 1 : 0;
748      if (ListView_SetItem( lv->ctrl, &lvi ) == FALSE)      lvi.lParam = (LPARAM )ctx;
749        if (ListView_SetItem (lv->ctrl, &lvi) == FALSE)
750          return WPTERR_GENERAL;          return WPTERR_GENERAL;
751                    
752      if (uididx == -1) { /* request the primary user-id of the key. */      if (uididx == -1) { /* request the primary user-id of the key. */
753          attr = key->uids->uid;          attr = ctx->uids->uid;
754          uididx = 0;          uididx = 0;
755      }      }
756      else {      else {
757          u = get_nth_userid (key, uididx);          u = get_nth_userid (key, uididx);
758          if (!u || u->revoked || uididx < 0)          if (!u || u->revoked || uididx < 0)
759              uididx = 0; /* fixme: this happen sometimes but it's illegal! (<0) */              uididx = 0;
760          u = get_nth_userid (key, uididx);          u = get_nth_userid (key, uididx);
         /*attr = key->uids->uid; XXX*/  
761          attr = u->uid;          attr = u->uid;
762      }      }
763      if (attr == NULL || strlen (attr) < 5) { /* normal userids are >= 5 chars */      if (attr == NULL || strlen (attr) < 5) { /* normal userids are > 5 chars */
764          attr = _("Invalid User ID");          attr = _("Invalid User ID");
765          listview_add_sub_item (lv, 0, idx++, attr);          listview_add_sub_item (lv, 0, idx++, attr);
766      }        }  
767      else {      else        
768          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);  
         }  
     }  
769      k = get_nth_key (key, keyidx);      k = get_nth_key (key, keyidx);
770      if (k && k->keyid) {      if (k && k->keyid) {
771          _snprintf (fmt, sizeof fmt -1, "0x%s", k->keyid + 8);          _snprintf (fmt, sizeof fmt -1, "0x%s", k->keyid + 8);
772          listview_add_sub_item( lv, 0, idx++, fmt );          listview_add_sub_item (lv, 0, idx++, fmt);
773      }      }
774      if (list > 0) {      if (list > 0) {
775          key_attr = find_secret_key (key);          key_attr = find_secret_key (key);
# Line 740  do_addkey (listview_ctrl_t lv, gpgme_key Line 789  do_addkey (listview_ctrl_t lv, gpgme_key
789          if (attr)          if (attr)
790              listview_add_sub_item( lv, 0, idx++, attr);              listview_add_sub_item( lv, 0, idx++, attr);
791      }      }
792      if( lv->cols >= 4 ) {      if (lv->cols >= 4) {
793          p = get_key_status( key, uididx, list > 0? 1 : 0 );          p = get_key_status( key, uididx, list > 0? 1 : 0 );
794          if (!p)          if (!p)
795              return WPTERR_GENERAL;              return WPTERR_GENERAL;
# Line 764  do_addkey (listview_ctrl_t lv, gpgme_key Line 813  do_addkey (listview_ctrl_t lv, gpgme_key
813  }  }
814    
815    
816    /* Update a single column @col but for each element in the
817       listview @lv. */
818  void  void
819  keylist_upd_key (listview_ctrl_t lv, int pos, gpgme_key_t key)  keylist_upd_col (listview_ctrl_t lv, int col)
820  {  {
821        gpgme_key_t key;
822      const char *s;      const char *s;
823        char buf[32], *p;
824        int i;
825    
826        for (i=0; i < listview_count_items (lv, 0); i++) {
827            key = km_get_key_ptr (lv, i, NULL);
828            if (!key)
829                continue;
830            switch (col) {
831            case KM_COL_KEYID:
832                _snprintf (buf, sizeof (buf)-1, "0x%s", key->subkeys->keyid+8);
833                listview_add_sub_item (lv, i, col, buf);
834                break;
835    
836            case KM_COL_CIPHER:
837                s = get_key_algo (key, 0);
838                listview_add_sub_item (lv, i, col, s);
839                break;
840    
841            case KM_COL_TYPE:
842                s = find_secret_key (key)? "pub/sec" : "pub";
843                listview_add_sub_item (lv, i, col, s);
844                break;
845    
846            case KM_COL_CREAT:
847                s = get_key_created (key->subkeys->timestamp);
848                listview_add_sub_item (lv, i, col, s);
849                break;
850    
851            case KM_COL_DESC:
852                p = get_key_desc (key);
853                listview_add_sub_item (lv, i, col, p);
854                free_if_alloc (p);
855                break;
856            }
857        }
858    }
859    
860    
861    /* Update the listview item at position @pos with the data from
862       the key @key. */
863    void
864    keylist_upd_key (listview_ctrl_t lv, int pos,
865                     struct keycache_s *ctx, gpgme_key_t key)
866    {
867        const char *s;
868        char *p;
869      char tmp[32];      char tmp[32];
870    
871      listview_set_item2 (lv, pos, (void *)key);      listview_set_item2 (lv, pos, (void *)ctx);
872      /* the only mode we support is KYLIST_LIST in the Key Manager */      /* the only mode we support is KEYLIST_LIST in the Key Manager */
873            
874      s = key->uids->uid;      s = ctx->uids->uid;
875      if (s)      if (s)
876          listview_add_sub_item (lv, pos, 0, s);          listview_add_sub_item (lv, pos, KM_COL_UID, s);
877    
878      s = key->subkeys->keyid;      s = key->subkeys->keyid;
879      if (s) {      if (s) {
880          sprintf (tmp, "0x%s", s+8);          sprintf (tmp, "0x%s", s+8);
881          listview_add_sub_item (lv, pos, 1, tmp);          listview_add_sub_item (lv, pos, KM_COL_KEYID, tmp);
882      }      }
883    
884      s = find_secret_key (key)? "pub/sec" : "pub";      s = find_secret_key (key)? "pub/sec" : "pub";
885      listview_add_sub_item (lv, pos, 2, s);      listview_add_sub_item (lv, pos, KM_COL_TYPE, s);
886    
887      s = get_key_size (key, 0);      s = get_key_size (key, 0);
888      if (s)      if (s)
889          listview_add_sub_item (lv, pos, 3, s);          listview_add_sub_item (lv, pos, KM_COL_SIZE, s);
890    
891      s = get_key_algo (key, 0);      s = get_key_algo (key, 0);
892      if (s)      if (s)
893          listview_add_sub_item (lv, pos, 4, s);          listview_add_sub_item (lv, pos, KM_COL_CIPHER, s);
894    
895      s = get_key_status (key, 0, 1);      p = get_key_status (key, 0, 1);
896      if (s)      if (p) {
897          listview_add_sub_item (lv, pos, 5, s);          listview_add_sub_item (lv, pos, KM_COL_VALID, p);
898            free_if_alloc (p);
899        }
900    
901      s = get_key_trust (key, 0, 1);      s = get_key_trust (key, 0, 1);
902      if (s)      if (s)
903          listview_add_sub_item (lv, pos, 6, s);          listview_add_sub_item (lv, pos, KM_COL_TRUST, s);
904    
905      long t = key->subkeys->timestamp;      long t = key->subkeys->timestamp;
906      s = get_key_created (t);      s = get_key_created (t);
907      if (s)      if (s)
908          listview_add_sub_item (lv, pos, 7, s);          listview_add_sub_item (lv, pos, KM_COL_CREAT, s);
909  }  }
910    
911    
912  int  int
913  keylist_add_key (listview_ctrl_t lv, int mode, gpgme_key_t key)  keylist_add_key (listview_ctrl_t lv, int mode,
914                     struct keycache_s *ctx, gpgme_key_t key)
915  {  {
916      int uids, rc = 0, i;      int uids, rc = 0, i;
917      gpgme_subkey_t k;      gpgme_subkey_t k;
# Line 827  keylist_add_key (listview_ctrl_t lv, int Line 928  keylist_add_key (listview_ctrl_t lv, int
928    
929          if (mode & KEYLIST_ALL) {          if (mode & KEYLIST_ALL) {
930              uids = count_userids (key);              uids = count_userids (key);
931              rc = do_addkey (lv, key, uids, i, 0);              rc = do_addkey (lv, ctx, key, uids, i, 0);
932              if( rc )              if (rc)
933                  return rc;                  return rc;
934          }          }
935          else if (mode & KEYLIST_LIST)          else if (mode & KEYLIST_LIST)
936              return do_addkey (lv, key, -1, i, 1);              return do_addkey (lv, ctx, key, -1, i, 1);
937          else if (mode & KEYLIST_ENCRYPT) {          else if (mode & KEYLIST_ENCRYPT) {
938              if (k->can_encrypt && key_is_useable (k)) {              if (k->can_encrypt && key_is_useable (k)) {
939                  if (mode & KEYLIST_FLAG_FILE) {                  if (mode & KEYLIST_FLAG_FILE) {
940                      rc = do_addkey (lv, key, -1, i, -1);                      rc = do_addkey (lv, ctx, key, -1, i, -1);
941                      if (rc)                      if (rc)
942                          return rc;                          return rc;
943                  }                  }
944                  else {                  else {
945                      for( uids = 0;  uids < count_userids (key); uids++ ) {                      for (uids = 0;  uids < count_userids (key); uids++) {
946                          rc = do_addkey( lv, key, uids, i, -1 );                          rc = do_addkey (lv, ctx, key, uids, i, -1);
947                          if( rc )                          if (rc)
948                              return rc;                              return rc;
949                      }                      }
950                  }                  }
# Line 852  keylist_add_key (listview_ctrl_t lv, int Line 953  keylist_add_key (listview_ctrl_t lv, int
953          else if (mode & KEYLIST_ENCRYPT_MIN) {          else if (mode & KEYLIST_ENCRYPT_MIN) {
954              if( k->can_encrypt && key_is_useable (k))              if( k->can_encrypt && key_is_useable (k))
955              {              {
956                  rc = do_addkey (lv, key, -1, i, -1);                  rc = do_addkey (lv, ctx, key, -1, i, -1);
957                  return rc;                  return rc;
958              }              }
959          }                }      
# Line 860  keylist_add_key (listview_ctrl_t lv, int Line 961  keylist_add_key (listview_ctrl_t lv, int
961              if (k->can_sign              if (k->can_sign
962                  && find_secret_key (key)                  && find_secret_key (key)
963                  && key_is_useable (k)) {                  && key_is_useable (k)) {
964                  rc = do_addkey (lv, key, -1, i, -1);                  rc = do_addkey (lv, ctx, key, -1, i, -1);
965                  if (rc)                  if (rc)
966                      return rc;                        return rc;  
967              }              }
# Line 868  keylist_add_key (listview_ctrl_t lv, int Line 969  keylist_add_key (listview_ctrl_t lv, int
969      }      }
970    
971      return rc;        return rc;  
972  } /* keylist_add_key */  }
973    
974    
975  int  int
976  keylist_sort (listview_ctrl_t lv, int sortby)  keylist_sort (listview_ctrl_t lv, int sortby)
977  {        {
978      return listview_sort_items (lv, sortby, keylist_cmp_cb);      return listview_sort_items (lv, sortby, keylist_cmp_cb);
979  }  }
980    
981    
982  /* Check that the validity @validity is at least >= marginal. */  /* Check that the validity @validity is at least >= marginal. */
983  static int  static int
984  key_check_validity (const char *validity)  key_check_validity (gpgme_key_t key)
985  {      {
986      if (strstr (validity, _("Unknown")) ||      gpgme_user_id_t u;
987          strstr (validity, _("Undefined")) ||  
988          strstr (validity, _("Never")) ||      for (u=key->uids; u; u =u->next) {
989          strstr (validity, _("None")))          if (u->validity >= GPGME_VALIDITY_MARGINAL)
990          return 0;                return -1;
991      return 1;      }
992    
993        return 0;
994  }  }
995    
996    
# Line 898  key_check_validity (const char *validity Line 1001  key_check_validity (const char *validity
1001  gpgme_key_t*  gpgme_key_t*
1002  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)
1003  {  {
1004        key_array_s *ka = NULL;
1005        keycache_s *c;
1006        gpgme_key_t *keybuf, key;
1007      int count = 0, force_trust = 0;      int count = 0, force_trust = 0;
1008      int n, j, ka_pos = 0, rc = 0;      int n, j, ka_pos = 0, rc = 0;
1009      int k_pos=0;      int k_pos=0;
     char keyid[32], valid[32], id[100];  
     key_array_s *ka = NULL;  
     gpgme_key_t *keybuf;  
1010    
1011      n = listview_count_items( lv, 0 );      n = listview_count_items (lv, 0);
1012            
1013      ka = key_array_new( n );      ka = key_array_new (n);
1014      if (!ka)      if (!ka)
1015          BUG (NULL);          BUG (NULL);
1016    
1017      keybuf = (gpgme_key_t*)calloc (n, sizeof (gpgme_key_t));      keybuf = (gpgme_key_t*)calloc (n+1, sizeof (gpgme_key_t));
1018      if (!keybuf)      if (!keybuf)
1019          BUG (NULL);          BUG (NULL);
1020                    
1021      for( j = 0; j < n; j++ ) {      for (j = 0; j < n; j++) {
1022          if( listview_get_item_state (lv, j) || n == 1) {          if (listview_get_item_state (lv, j) || n == 1) {
1023              listview_get_item_text (lv, j, 0, id, sizeof id-1);              key = km_get_key_ptr (lv, j, &c);
1024              listview_get_item_text (lv, j, 1, keyid, sizeof keyid - 1);                              if (!key)
1025              listview_get_item_text (lv, j, 4, valid, sizeof valid -1);                  BUG (0);
1026              if( !key_check_validity (valid)              if (!key_check_validity (key) &&
1027                   && !key_array_search( ka, ka_pos, keyid )) {                  !key_array_search (ka, ka_pos, key->subkeys->keyid)) {
1028                  char *warn = new char[512+strlen (id) + 1];                  char *warn = new char[512+strlen (c->uids->uid) + 1];
1029                  if (!warn)                  if (!warn)
1030                      BUG (0);                      BUG (0);
1031                  sprintf (warn,                  sprintf (warn,
# Line 930  keylist_get_recipients (listview_ctrl_t Line 1033  keylist_get_recipients (listview_ctrl_t
1033                        "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"
1034                        "doing, you may answer the next question with yes\n"                        "doing, you may answer the next question with yes\n"
1035                        "\n"                        "\n"
1036                        "Use \"%s\" anyway?"), id);                        "Use \"%s\" anyway?"), c->uids->uid);
1037                  if (reg_prefs.always_trust)                  if (reg_prefs.always_trust)
1038                      rc = IDYES;                      rc = IDYES;
1039                  else                  else
1040                      rc = msg_box (NULL, warn, _("Recipients"), MB_ERR_ASK);                      rc = msg_box (NULL, warn, _("Recipients"), MB_ERR_ASK);
1041                  if (rc == IDYES) {                  if (rc == IDYES) {
1042                      gpgme_key_t k;                      keybuf[k_pos++] = key;
                     get_pubkey (keyid, &k);  
                     keybuf[k_pos++] = k;  
1043                      force_trust++;                      force_trust++;
1044                      ka[ka_pos].checked = 1;                      ka[ka_pos].checked = 1;
1045                      strcpy (ka[ka_pos++].keyid, keyid);                      strcpy (ka[ka_pos++].keyid, key->subkeys->keyid);
1046                      count++;                      count++;
1047                  }                  }
1048                  free_if_alloc (warn);                  free_if_alloc (warn);
1049              }              }
1050              else {              else {
1051                  gpgme_key_t k;                  keybuf[k_pos++] = key;
                 listview_get_item_text( lv, j, 1, keyid, sizeof keyid -1 );  
                 get_pubkey (keyid, &k);  
                 keybuf[k_pos++] = k;  
1052                  count++;                          count++;        
1053              }              }
1054          }          }
# Line 965  keylist_get_recipients (listview_ctrl_t Line 1063  keylist_get_recipients (listview_ctrl_t
1063    
1064    
1065  static int  static int
1066  keylist_get_keyflags (const char *buf, size_t buflen)  keylist_get_keyflags (gpgme_key_t key)
1067  {  {
1068      int c = 0, flags = 0;      int flags = KEYFLAG_NONE;
1069    
1070      if( *buf != '[' )      if (key->revoked)
1071          return KEYFLAG_NONE;          flags |= KEYFLAG_REVOKED;
1072      while (buf && c != ']')      if (key->expired)
1073      {          flags |= KEYFLAG_EXPIRED;
1074          c = *buf++;      if (key->disabled)
1075          if (c == 'R')          flags |= KEYFLAG_DISABLED;
             flags |= KEYFLAG_REVOKED;  
         if (c == 'E')  
             flags |= KEYFLAG_EXPIRED;  
         if (c == 'D')  
             flags |= KEYFLAG_DISABLED;  
     }  
1076    
1077      return flags;      return flags;
1078  } /* keylist_get_keyflags */  }
1079    
1080    
1081  gpgme_key_t*  gpgme_key_t*
1082  keylist_enum_recipients (listview_ctrl_t lv,  int listype, int *r_count)  keylist_enum_recipients (listview_ctrl_t lv,  int listype, int *r_count)
1083  {  {
1084      gpgme_key_t* rset;      struct keycache_s *c;
1085      gpgme_key_t k;      gpgme_key_t *rset;
1086        gpgme_key_t key;
1087      int i, n, id, k_pos=0;      int i, n, id, k_pos=0;
     char keyid[32], t[128], t2[128];  
1088    
1089      n = listview_count_items (lv, 0);      n = listview_count_items (lv, 0);
1090      if (!n)      if (!n)
1091          return 0;          return 0;
1092      rset = (gpgme_key_t*)calloc (n, sizeof (gpgme_key_t));      rset = (gpgme_key_t*)calloc (n+1, sizeof (gpgme_key_t));
1093      if (!rset)      if (!rset)
1094          BUG (NULL);          BUG (NULL);
1095      for( i = 0; i < n; i++ ) {      for (i = 0; i < n; i++) {
1096          if( !listview_get_item_state( lv, i ) )          if (!listview_get_item_state (lv, i))
1097              continue;              continue;
1098          listview_get_item_text( lv, i, 1, keyid, sizeof keyid - 1 );          key = km_get_key_ptr (lv, i, &c);
1099          switch( listype ) {          switch (listype) {
1100          case KEYLIST_LIST:          case KEYLIST_LIST:
1101              listview_get_item_text( lv, i, 5, t, sizeof t - 1 );              if (keylist_get_keyflags (key) & KEYFLAG_REVOKED) {
1102              if( keylist_get_keyflags( t, strlen( t ) ) & KEYFLAG_REVOKED ) {                  id = printf_box (_("Recipients"), MB_INFO|MB_YESNO,
1103                  _snprintf( t2, sizeof t2 -1,                  _("KeyID %s.\nDo you really want to export a revoked key?"),
1104                              _("KeyID %s.\nDo you really want to export a revoked key?"), keyid );                                   c->uids->uid);
1105                  id = msg_box( lv->ctrl, t2, _("Recipients"), MB_INFO|MB_YESNO );                  if (id == IDNO)
1106                  if( id == IDNO )                      continue;
                     continue;            
1107              }              }
1108              break;              break;
1109          }          }
1110          get_pubkey (keyid, &k);          rset[k_pos++] = key;
         rset[k_pos++] = k;  
1111      }      }
1112      if (r_count)      if (r_count)
1113          *r_count = k_pos;          *r_count = k_pos;
1114      return rset;      return rset;
1115  } /* keylist_enum_recipients */  }
1116    
1117    
1118  void  void
1119  seclist_destroy (keylist_t * list)  seclist_destroy (keylist_t *list)
1120  {  {
1121      keylist_t l2;      keylist_t l2;
1122      while (*list) {      while (*list) {
# Line 1035  seclist_destroy (keylist_t * list) Line 1125  seclist_destroy (keylist_t * list)
1125          *list = l2;              *list = l2;    
1126      }      }
1127      list = NULL;      list = NULL;
1128  } /* seclist_destroy */  }
1129    
1130    
1131  void  void
# Line 1072  seclist_init (HWND dlg, int ctlid, int f Line 1162  seclist_init (HWND dlg, int ctlid, int f
1162          if (key->disabled || !key_is_useable (key->subkeys))          if (key->disabled || !key_is_useable (key->subkeys))
1163              continue;              continue;
1164    
1165          uid = utf8_to_wincp (id, strlen (id));          uid = utf8_to_native (id);
1166          size = strlen( uid ) + strlen( keyid ) + 32;          size = strlen (uid) + strlen (keyid) + 32;
1167          inf = new char[size+1];          inf = new char[size+1];
1168          if( !inf )          if (!inf)
1169              BUG( NULL );              BUG (NULL);
1170          _snprintf (inf, size, "%s (%s/0x%s)", uid,          _snprintf (inf, size, "%s (%s/0x%s)", uid,
1171                     get_key_pubalgo (key->subkeys->pubkey_algo), keyid + 8);                     get_key_pubalgo (key->subkeys->pubkey_algo), keyid + 8);
1172          combox_add_string (kb, inf);          combox_add_string (kb, inf);
1173          free_if_alloc (inf);          free_if_alloc (inf);
# Line 1094  seclist_init (HWND dlg, int ctlid, int f Line 1184  seclist_init (HWND dlg, int ctlid, int f
1184              l2->next = l;              l2->next = l;
1185          }          }
1186      }      }
1187      for( pos = 0, l2=list; pos < SendMessage( kb, CB_GETCOUNT, 0, 0 ); pos++, l2=l2->next )      for (pos = 0, l2=list; pos < SendMessage (kb, CB_GETCOUNT, 0, 0);
1188          SendMessage( kb, CB_SETITEMDATA, pos, (LPARAM)(DWORD)l2->key );           pos++, l2=l2->next)
1189      SendMessage( kb, CB_SETCURSEL, 0, 0 );          SendMessage (kb, CB_SETITEMDATA, pos, (LPARAM)(DWORD)l2->key);
1190        SendMessage (kb, CB_SETCURSEL, 0, 0);
1191      *ret_list = list;      *ret_list = list;
1192  }  }
1193                    

Legend:
Removed from v.99  
changed lines
  Added in v.228

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26