/[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 132 by twoaday, Fri Dec 30 13:56:10 2005 UTC revision 133 by twoaday, Mon Jan 9 09:15:29 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 38  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    
# Line 51  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 151  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_user_id_t uid, 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        if (strlen (keyid) == 8)
165            off = 8;
166    
167      for (s = uid->signatures; s; s = s->next) {      for (s = uid->signatures; s; s = s->next) {
168          if (!strcmp (s->keyid+8, keyid) && s->timestamp > timestamp) {          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 182  get_key_algo (gpgme_key_t key, int keyid Line 189  get_key_algo (gpgme_key_t key, int keyid
189      if (keyidx > 0) {      if (keyidx > 0) {
190          k = get_nth_key (key, keyidx-1);          k = get_nth_key (key, keyidx-1);
191          subalg =  get_key_pubalgo (k->pubkey_algo);          subalg =  get_key_pubalgo (k->pubkey_algo);
192          _snprintf( algo_id, DIM (algo_id)-1, "%s", subalg);          _snprintf (algo_id, DIM (algo_id)-1, "%s", subalg);
193          return algo_id;          return algo_id;
194      }      }
195      strcpy (alg, get_key_pubalgo (key->subkeys->pubkey_algo));      strcpy (alg, get_key_pubalgo (key->subkeys->pubkey_algo));
# Line 194  get_key_algo (gpgme_key_t key, int keyid Line 201  get_key_algo (gpgme_key_t key, int keyid
201          return algo_id;          return algo_id;
202      }      }
203      return get_key_pubalgo (key->subkeys->pubkey_algo);      return get_key_pubalgo (key->subkeys->pubkey_algo);
204  } /* get_key_algo */  }
205    
206    
207  const char*  const char*
208  get_key_created (long timestamp)  get_key_created (long timestamp)
209  {  {
210      static char timebuf[128];      static char timebuf[128];
     const char *dat;  
211      struct tm *warp;      struct tm *warp;
212        const char *dat;
213    
214      if (timestamp == 0 || timestamp == -1)      if (timestamp < 1)
215          return "????" "-??" "-??";          return "????" "-??" "-??";
216      dat = get_locale_date (timestamp, timebuf, sizeof (timebuf)-1);      dat = get_locale_date (timestamp, timebuf, sizeof (timebuf)-1);
217      if (dat)      if (dat)
# Line 222  get_key_expire_date (long timestamp) Line 229  get_key_expire_date (long timestamp)
229  {  {
230      static char timebuf[64];      static char timebuf[64];
231      struct tm *warp;      struct tm *warp;
232        const char *dat;
233    
234      if( !timestamp )      if (timestamp == 0)
235          return _("Never");          return _("Never");
236      warp = localtime( &timestamp );      dat = get_locale_date (timestamp, timebuf, sizeof (timebuf)-1);
237        if (dat)
238            return dat;
239        warp = localtime (&timestamp);
240      _snprintf (timebuf, sizeof timebuf -1, "%04d-%02d-%02d",      _snprintf (timebuf, sizeof timebuf -1, "%04d-%02d-%02d",
241                 warp->tm_year + 1900, warp->tm_mon + 1, warp->tm_mday);                 warp->tm_year + 1900, warp->tm_mon + 1, warp->tm_mday);
242      return timebuf;      return timebuf;
# Line 263  get_key_size (gpgme_key_t key, int keyid Line 274  get_key_size (gpgme_key_t key, int keyid
274      if (n > 1) {      if (n > 1) {
275          k = get_nth_key (key, n-1);          k = get_nth_key (key, n-1);
276          size_sub = k->length;          size_sub = k->length;
277          _snprintf( size_id, sizeof (size_id) - 1, "%d/%d", size_main, size_sub );          _snprintf (size_id, sizeof (size_id) - 1, "%d/%d",
278                        size_main, size_sub);
279          return size_id;          return size_id;
280      }      }
281      _snprintf( size_id, sizeof (size_id) - 1, "%d", size_main );      _snprintf( size_id, sizeof (size_id) - 1, "%d", size_main );
# Line 283  get_key_pubalgo2 (gpgme_pubkey_algo_t al Line 295  get_key_pubalgo2 (gpgme_pubkey_algo_t al
295      return "?";      return "?";
296  }  }
297    
298    
299  const char*  const char*
300  get_key_pubalgo (gpgme_pubkey_algo_t alg)  get_key_pubalgo (gpgme_pubkey_algo_t alg)
301  {  {
# Line 296  get_key_pubalgo (gpgme_pubkey_algo_t alg Line 309  get_key_pubalgo (gpgme_pubkey_algo_t alg
309      return "???";      return "???";
310  }  }
311    
312  const char *  const char*
313  get_key_fpr (gpgme_key_t key)  get_key_fpr (gpgme_key_t key)
314  {  {
315      static char fpr_md[64];      static char fpr_md[64];
# Line 328  get_key_fpr (gpgme_key_t key) Line 341  get_key_fpr (gpgme_key_t key)
341  }  }
342    
343    
344  const char *  const char*
345  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)
346  {  {
347      if (key)      if (key)
# Line 384  get_key_status (gpgme_key_t key, int uid Line 397  get_key_status (gpgme_key_t key, int uid
397          else          else
398              s = "";              s = "";
399          /* 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
400             what any user-id validities. */             the user-id validities. */
401          if (*s)          if (*s)
402              return m_strdup (s);              return m_strdup (s);
403      }      }
# Line 483  keylist_cmp_cb (LPARAM first, LPARAM sec Line 496  keylist_cmp_cb (LPARAM first, LPARAM sec
496  }  }
497    
498    
499    #if 0
500  /* Return the validity of the group @grp. */  /* Return the validity of the group @grp. */
501  static const char*  static const char*
502  calc_validity (gpg_group_t grp)  calc_validity (gpg_group_t grp)
# Line 504  calc_validity (gpg_group_t grp) Line 518  calc_validity (gpg_group_t grp)
518      }      }
519      return _("Full");      return _("Full");
520  }  }
521    #endif
522    
523    
524  int  int
525  keylist_add_groups( listview_ctrl_t lv )  keylist_add_groups (listview_ctrl_t lv)
526  {  {
 #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  
527      return 0;      return 0;
528  } /* keylist_add_groups */  }
529    
530    
531  /* 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_build (listview_ctrl_t *r_lv, HW Line 541  keylist_build (listview_ctrl_t *r_lv, HW
541      {5, 70, (char *)_("Validity")},      {5, 70, (char *)_("Validity")},
542      {0, 0, NULL}      {0, 0, NULL}
543      };      };
   
544      struct listview_column_s klist[] = {      struct listview_column_s klist[] = {
545      {0, 240, (char *)_("User ID")},      {0, 240, (char *)_("User ID")},
546      {1, 78, (char *)_("Key ID")},      {1, 78, (char *)_("Key ID")},
# Line 557  keylist_build (listview_ctrl_t *r_lv, HW Line 552  keylist_build (listview_ctrl_t *r_lv, HW
552      {7, 72, (char *)_("Creation")},      {7, 72, (char *)_("Creation")},
553      {0, 0, NULL}      {0, 0, NULL}
554      };      };
555        HICON ico[2];
556      listview_ctrl_t lv;      listview_ctrl_t lv;
557      listview_column_t col;      listview_column_t col;
558      int j, n = 0;      int j, n = 0;
# Line 581  keylist_build (listview_ctrl_t *r_lv, HW Line 576  keylist_build (listview_ctrl_t *r_lv, HW
576          n = (DIM(klist) - 1);          n = (DIM(klist) - 1);
577      }      }
578            
579      for( j = 0; j < n; j++ )          for (j = 0; j < n; j++)
580          listview_add_column( lv, &col[j] );              listview_add_column (lv, &col[j]);
581      listview_set_ext_style( lv );      listview_set_ext_style (lv);
582        ico[0] = LoadIcon (glob_hinst, (LPCTSTR)IDI_PUBKEY);
583        ico[1] = LoadIcon (glob_hinst, (LPCTSTR)IDI_KEYPAIR);
584        listview_set_image_list (lv, ico, 2);
585    
586      *r_lv = lv;      *r_lv = lv;
       
587      return 0;      return 0;
588  }  }
589    
# Line 694  do_addkey (listview_ctrl_t lv, gpgme_key Line 692  do_addkey (listview_ctrl_t lv, gpgme_key
692                     key->uids->name, key->subkeys->keyid);                     key->uids->name, key->subkeys->keyid);
693          return 0;          return 0;
694      }      }
   
695                    
696      if (listview_add_item2 (lv, " ", (void *)key))      if (listview_add_item2 (lv, " ", (void *)key))
697          return WPTERR_GENERAL;          return WPTERR_GENERAL;
698    
699      attr = key->uids->uid;      attr = key->uids->uid;
700      memset (&lvi, 0, sizeof lvi);      memset (&lvi, 0, sizeof lvi);
701      lvi.mask = LVIF_TEXT | LVIF_PARAM;      lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
702      lvi.pszText = (char *)attr;      lvi.pszText = (char *)attr;
703        lvi.iImage = find_secret_key (key)? 1 : 0;
704      lvi.lParam = (LPARAM )key;      lvi.lParam = (LPARAM )key;
705      if (ListView_SetItem (lv->ctrl, &lvi) == FALSE)      if (ListView_SetItem (lv->ctrl, &lvi) == FALSE)
706          return WPTERR_GENERAL;          return WPTERR_GENERAL;
# Line 714  do_addkey (listview_ctrl_t lv, gpgme_key Line 712  do_addkey (listview_ctrl_t lv, gpgme_key
712      else {      else {
713          u = get_nth_userid (key, uididx);          u = get_nth_userid (key, uididx);
714          if (!u || u->revoked || uididx < 0)          if (!u || u->revoked || uididx < 0)
715              uididx = 0; /* fixme: this happen sometimes but it's illegal! (<0) */              uididx = 0;
716          u = get_nth_userid (key, uididx);          u = get_nth_userid (key, uididx);
717          attr = u->uid;          attr = u->uid;
718      }      }
719      if (attr == NULL || strlen (attr) < 5) { /* normal userids are >= 5 chars */      if (attr == NULL || strlen (attr) < 5) { /* normal userids are > 5 chars */
720          attr = _("Invalid User ID");          attr = _("Invalid User ID");
721          listview_add_sub_item (lv, 0, idx++, attr);          listview_add_sub_item (lv, 0, idx++, attr);
722      }        }  
# Line 814  keylist_upd_col (listview_ctrl_t lv, int Line 812  keylist_upd_col (listview_ctrl_t lv, int
812      }      }
813  }  }
814    
815    
816  /* Update the listview item at position @pos with the data from  /* Update the listview item at position @pos with the data from
817     the key @key. */     the key @key. */
818  void  void
# Line 924  keylist_add_key (listview_ctrl_t lv, int Line 923  keylist_add_key (listview_ctrl_t lv, int
923      }      }
924    
925      return rc;        return rc;  
926  } /* keylist_add_key */  }
927    
928    
929  int  int
# Line 936  keylist_sort (listview_ctrl_t lv, int so Line 935  keylist_sort (listview_ctrl_t lv, int so
935    
936  /* Check that the validity @validity is at least >= marginal. */  /* Check that the validity @validity is at least >= marginal. */
937  static int  static int
938  key_check_validity (const char *validity)  key_check_validity (gpgme_key_t key)
939  {      {
940      if (strstr (validity, _("Unknown")) ||      gpgme_user_id_t u;
941          strstr (validity, _("Undefined")) ||  
942          strstr (validity, _("Never")) ||      for (u=key->uids; u; u =u->next) {
943          strstr (validity, _("None")))          if (u->validity >= GPGME_VALIDITY_MARGINAL)
944          return 0;                return -1;
945      return 1;      }
946    
947        return 0;
948  }  }
949    
950    
# Line 954  key_check_validity (const char *validity Line 955  key_check_validity (const char *validity
955  gpgme_key_t*  gpgme_key_t*
956  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)
957  {  {
958        key_array_s *ka = NULL;
959        gpgme_key_t *keybuf, key;
960      int count = 0, force_trust = 0;      int count = 0, force_trust = 0;
961      int n, j, ka_pos = 0, rc = 0;      int n, j, ka_pos = 0, rc = 0;
962      int k_pos=0;      int k_pos=0;
     char keyid[32], valid[32], id[100];  
     key_array_s *ka = NULL;  
     gpgme_key_t *keybuf;  
963    
964      n = listview_count_items( lv, 0 );      n = listview_count_items (lv, 0);
965            
966      ka = key_array_new( n );      ka = key_array_new (n);
967      if (!ka)      if (!ka)
968          BUG (NULL);          BUG (NULL);
969    
# Line 971  keylist_get_recipients (listview_ctrl_t Line 971  keylist_get_recipients (listview_ctrl_t
971      if (!keybuf)      if (!keybuf)
972          BUG (NULL);          BUG (NULL);
973                    
974      for( j = 0; j < n; j++ ) {      for (j = 0; j < n; j++) {
975          if( listview_get_item_state (lv, j) || n == 1) {          if (listview_get_item_state (lv, j) || n == 1) {
976              listview_get_item_text (lv, j, 0, id, sizeof id-1);              key = (gpgme_key_t)listview_get_item2 (lv, j);
977              listview_get_item_text (lv, j, 1, keyid, sizeof keyid - 1);                              if (!key)
978              listview_get_item_text (lv, j, 4, valid, sizeof valid -1);                  BUG (0);
979              if( !key_check_validity (valid)              if (!key_check_validity (key) &&
980                   && !key_array_search( ka, ka_pos, keyid )) {                  !key_array_search (ka, ka_pos, key->subkeys->keyid)) {
981                  char *warn = new char[512+strlen (id) + 1];                  char *warn = new char[512+strlen (key->uids->uid) + 1];
982                  if (!warn)                  if (!warn)
983                      BUG (0);                      BUG (0);
984                  sprintf (warn,                  sprintf (warn,
# Line 986  keylist_get_recipients (listview_ctrl_t Line 986  keylist_get_recipients (listview_ctrl_t
986                        "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"
987                        "doing, you may answer the next question with yes\n"                        "doing, you may answer the next question with yes\n"
988                        "\n"                        "\n"
989                        "Use \"%s\" anyway?"), id);                        "Use \"%s\" anyway?"), key->uids->uid);
990                  if (reg_prefs.always_trust)                  if (reg_prefs.always_trust)
991                      rc = IDYES;                      rc = IDYES;
992                  else                  else
993                      rc = msg_box (NULL, warn, _("Recipients"), MB_ERR_ASK);                      rc = msg_box (NULL, warn, _("Recipients"), MB_ERR_ASK);
994                  if (rc == IDYES) {                  if (rc == IDYES) {
995                      gpgme_key_t k;                      keybuf[k_pos++] = key;
                     get_pubkey (keyid, &k);  
                     keybuf[k_pos++] = k;  
996                      force_trust++;                      force_trust++;
997                      ka[ka_pos].checked = 1;                      ka[ka_pos].checked = 1;
998                      strcpy (ka[ka_pos++].keyid, keyid);                      strcpy (ka[ka_pos++].keyid, key->subkeys->keyid);
999                      count++;                      count++;
1000                  }                  }
1001                  free_if_alloc (warn);                  free_if_alloc (warn);
1002              }              }
1003              else {              else {
1004                  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;  
1005                  count++;                          count++;        
1006              }              }
1007          }          }
# Line 1021  keylist_get_recipients (listview_ctrl_t Line 1016  keylist_get_recipients (listview_ctrl_t
1016    
1017    
1018  static int  static int
1019  keylist_get_keyflags (const char *buf, size_t buflen)  keylist_get_keyflags (gpgme_key_t key)
1020  {  {
1021      int c = 0, flags = 0;      int flags = KEYFLAG_NONE;
1022    
1023      if( *buf != '[' )      if (key->revoked)
1024          return KEYFLAG_NONE;          flags |= KEYFLAG_REVOKED;
1025      while (buf && c != ']')      if (key->expired)
1026      {          flags |= KEYFLAG_EXPIRED;
1027          c = *buf++;      if (key->disabled)
1028          if (c == 'R')          flags |= KEYFLAG_DISABLED;
             flags |= KEYFLAG_REVOKED;  
         if (c == 'E')  
             flags |= KEYFLAG_EXPIRED;  
         if (c == 'D')  
             flags |= KEYFLAG_DISABLED;  
     }  
1029    
1030      return flags;      return flags;
1031  } /* keylist_get_keyflags */  }
1032    
1033    
1034  gpgme_key_t*  gpgme_key_t*
1035  keylist_enum_recipients (listview_ctrl_t lv,  int listype, int *r_count)  keylist_enum_recipients (listview_ctrl_t lv,  int listype, int *r_count)
1036  {  {
1037      gpgme_key_t* rset;      gpgme_key_t *rset;
1038      gpgme_key_t k;      gpgme_key_t key;
1039      int i, n, id, k_pos=0;      int i, n, id, k_pos=0;
     char keyid[32], t[128], t2[128];  
1040    
1041      n = listview_count_items (lv, 0);      n = listview_count_items (lv, 0);
1042      if (!n)      if (!n)
# Line 1056  keylist_enum_recipients (listview_ctrl_t Line 1044  keylist_enum_recipients (listview_ctrl_t
1044      rset = (gpgme_key_t*)calloc (n, sizeof (gpgme_key_t));      rset = (gpgme_key_t*)calloc (n, sizeof (gpgme_key_t));
1045      if (!rset)      if (!rset)
1046          BUG (NULL);          BUG (NULL);
1047      for( i = 0; i < n; i++ ) {      for (i = 0; i < n; i++) {
1048          if( !listview_get_item_state( lv, i ) )          if (!listview_get_item_state (lv, i))
1049              continue;              continue;
1050          listview_get_item_text( lv, i, 1, keyid, sizeof keyid - 1 );          key = (gpgme_key_t)listview_get_item2 (lv, i);
1051          switch( listype ) {          if (!key)
1052                BUG (0);
1053            switch (listype) {
1054          case KEYLIST_LIST:          case KEYLIST_LIST:
1055              listview_get_item_text( lv, i, 5, t, sizeof t - 1 );              if (keylist_get_keyflags (key) & KEYFLAG_REVOKED) {
1056              if( keylist_get_keyflags( t, strlen( t ) ) & KEYFLAG_REVOKED ) {                  id = printf_box (_("Recipients"), MB_INFO|MB_YESNO,
1057                  _snprintf( t2, sizeof t2 -1,                  _("KeyID %s.\nDo you really want to export a revoked key?"),
1058                              _("KeyID %s.\nDo you really want to export a revoked key?"), keyid );                                   key->uids->uid);
1059                  id = msg_box( lv->ctrl, t2, _("Recipients"), MB_INFO|MB_YESNO );                  if (id == IDNO)
1060                  if( id == IDNO )                      continue;
                     continue;            
1061              }              }
1062              break;              break;
1063          }          }
1064          get_pubkey (keyid, &k);          rset[k_pos++] = key;
         rset[k_pos++] = k;  
1065      }      }
1066      if (r_count)      if (r_count)
1067          *r_count = k_pos;          *r_count = k_pos;
1068      return rset;      return rset;
1069  } /* keylist_enum_recipients */  }
1070    
1071    
1072  void  void
1073  seclist_destroy (keylist_t * list)  seclist_destroy (keylist_t *list)
1074  {  {
1075      keylist_t l2;      keylist_t l2;
1076      while (*list) {      while (*list) {
# Line 1091  seclist_destroy (keylist_t * list) Line 1079  seclist_destroy (keylist_t * list)
1079          *list = l2;              *list = l2;    
1080      }      }
1081      list = NULL;      list = NULL;
1082  } /* seclist_destroy */  }
1083    
1084    
1085  void  void
# Line 1129  seclist_init (HWND dlg, int ctlid, int f Line 1117  seclist_init (HWND dlg, int ctlid, int f
1117              continue;              continue;
1118    
1119          uid = utf8_to_wincp (id, strlen (id));          uid = utf8_to_wincp (id, strlen (id));
1120          size = strlen( uid ) + strlen( keyid ) + 32;          size = strlen (uid) + strlen (keyid) + 32;
1121          inf = new char[size+1];          inf = new char[size+1];
1122          if( !inf )          if (!inf)
1123              BUG( NULL );              BUG (NULL);
1124          _snprintf (inf, size, "%s (%s/0x%s)", uid,          _snprintf (inf, size, "%s (%s/0x%s)", uid,
1125                     get_key_pubalgo (key->subkeys->pubkey_algo), keyid + 8);                     get_key_pubalgo (key->subkeys->pubkey_algo), keyid + 8);
1126          combox_add_string (kb, inf);          combox_add_string (kb, inf);
1127          free_if_alloc (inf);          free_if_alloc (inf);
# Line 1150  seclist_init (HWND dlg, int ctlid, int f Line 1138  seclist_init (HWND dlg, int ctlid, int f
1138              l2->next = l;              l2->next = l;
1139          }          }
1140      }      }
1141      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);
1142          SendMessage( kb, CB_SETITEMDATA, pos, (LPARAM)(DWORD)l2->key );           pos++, l2=l2->next)
1143      SendMessage( kb, CB_SETCURSEL, 0, 0 );          SendMessage (kb, CB_SETITEMDATA, pos, (LPARAM)(DWORD)l2->key);
1144        SendMessage (kb, CB_SETCURSEL, 0, 0);
1145      *ret_list = list;      *ret_list = list;
1146  }  }
1147                    

Legend:
Removed from v.132  
changed lines
  Added in v.133

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26