/[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 23 by twoaday, Fri Sep 30 10:10:16 2005 UTC revision 25 by twoaday, Wed Oct 12 10:04:26 2005 UTC
# Line 32  Line 32 
32  #include "wptErrors.h"  #include "wptErrors.h"
33  #include "wptUTF8.h"  #include "wptUTF8.h"
34  #include "wptRegistry.h"  #include "wptRegistry.h"
35    #include "wptContext.h"
36    
37    
38  #define key_is_useable(key) (!(key)->revoked && !(key)->expired && !(key)->disabled)  #define key_is_useable(key) (!(key)->revoked && !(key)->expired && !(key)->disabled)
# Line 124  int Line 125  int
125  count_userids (gpgme_key_t key)  count_userids (gpgme_key_t key)
126  {  {
127      gpgme_user_id_t u;      gpgme_user_id_t u;
128      int n = 0;      int n = 1;
129    
130      u = key->uids;      u = key->uids;
131      if (!u)      if (!u)
# Line 154  int Line 155  int
155  count_subkeys (gpgme_key_t key)  count_subkeys (gpgme_key_t key)
156  {  {
157      gpgme_subkey_t k;      gpgme_subkey_t k;
158      int n = -1; /* ignore primary key */      int n = 1;
159    
160      k = key->subkeys;      k = key->subkeys;
161      if (!n)      if (!k)
162          return 0;          return 0;
163      while (k->next) {      while (k->next) {
164          k = k->next;          k = k->next;
# Line 168  count_subkeys (gpgme_key_t key) Line 169  count_subkeys (gpgme_key_t key)
169    
170    
171  gpgme_key_sig_t  gpgme_key_sig_t
172  get_nth_uid_sig (gpgme_user_id_t uid, int idx)  get_selfsig (gpgme_user_id_t uid, const char *keyid, int first)
173  {  {
174      gpgme_key_sig_t ks;      gpgme_key_sig_t s, self_sig=NULL;
175        long timestamp=0;
176    
177      if (!uid->signatures)      for (s = uid->signatures; s; s = s->next) {
178          return NULL;          if (!strcmp (s->keyid+8, keyid) && s->timestamp > timestamp) {
179      ks = uid->signatures;              self_sig = s;
180      while (idx-- && ks->next)              timestamp = s->timestamp;
181          ks = ks->next;              if (first)
182      return ks;                  break;
183            }
184        }
185        return self_sig;
186  }  }
187    
 int  
 count_uid_sigs (gpgme_user_id_t uid)  
 {  
     gpgme_key_sig_t k;  
     int n = 0;  
   
     if (!uid->signatures)  
         return 0;  
     k = uid->signatures;  
     while (k->next)  
         n++;  
     return n;  
 }  
188    
189    
190  const char*  const char*
# Line 292  get_key_pubalgo (gpgme_pubkey_algo_t alg Line 284  get_key_pubalgo (gpgme_pubkey_algo_t alg
284  {  {
285      switch (alg) {      switch (alg) {
286      case GPGME_PK_DSA: return "DSA";      case GPGME_PK_DSA: return "DSA";
287        case GPGME_PK_ELG:
288      case GPGME_PK_ELG_E: return "ELG";      case GPGME_PK_ELG_E: return "ELG";
289      case GPGME_PK_RSA: return "RSA";      case GPGME_PK_RSA: return "RSA";
290      }      }
# Line 400  get_key_status (gpgme_key_t key, int uid Line 393  get_key_status (gpgme_key_t key, int uid
393  } /* get_key_status */  } /* get_key_status */
394    
395    
396    /* Integer comparsion of @a and @b.
397       Return values: same as in strcmp. */
398  static inline int  static inline int
399  int_cmp( int a, int b )  int_cmp (int a, int b)
400  {  {
401      if( a == b ) return 0;            if (a == b) return 0;      
402      else if( a > b ) return 1;      else if (a > b) return 1;
403      else return -1;      else return -1;
404      return 0;      return 0;
405  }  }
406    
407    
408    /* List view sorting callback. */
409  static int CALLBACK  static int CALLBACK
410  keylist_cmp_cb (LPARAM first, LPARAM second, LPARAM sortby)  keylist_cmp_cb (LPARAM first, LPARAM second, LPARAM sortby)
411  {  {
     static char tmpa[128], tmpb[128];      
412      gpgme_key_t a, b;          gpgme_key_t a, b;    
     const char *aa = NULL, *bb = NULL;  
     long ta, tb;  
     int na = 0, nb = 0;  
413      int cmpresult = 0;      int cmpresult = 0;
414            
415      a = (gpgme_key_t)first;      a = (gpgme_key_t)first;
416      b = (gpgme_key_t)second;          b = (gpgme_key_t)second;
417        if (!a || !b)
418            BUG (NULL);
419            
420      switch( sortby & ~KEYLIST_SORT_DESC ) {      switch (sortby & ~KEYLIST_SORT_DESC) {
421      case KEY_SORT_USERID:      case KEY_SORT_USERID:
422          aa = a->uids->uid;          cmpresult = strcmpi (a->uids->uid, b->uids->uid);
         bb = b->uids->uid;  
         cmpresult = strcmpi (aa? aa : "", bb? bb : "");  
423          break;          break;
424                    
425      case KEY_SORT_KEYID:      case KEY_SORT_KEYID:
426          aa = a->subkeys->keyid+8;          cmpresult = strcmpi (a->subkeys->keyid+8,
427          bb = b->subkeys->keyid+8;                               b->subkeys->keyid+8);
         cmpresult = strcmpi( aa? aa : "", bb? bb : "" );  
428          break;          break;
429    
430      case KEY_SORT_VALIDITY:      case KEY_SORT_VALIDITY: /* XXX: handle expire, revoked */
431          na = a->uids->validity;          cmpresult = int_cmp (a->uids->validity, b->uids->validity);
         nb = b->uids->validity;  
         cmpresult = int_cmp (na, nb);  
432          break;          break;
433    
434      case KEY_SORT_OTRUST:      case KEY_SORT_OTRUST: /* XXX: handle expire, revoked */
435          na = a->owner_trust;          cmpresult = int_cmp (a->owner_trust, b->owner_trust);
         nb = b->owner_trust;  
         cmpresult = int_cmp (na, nb);  
436          break;          break;
437    
438      case KEY_SORT_IS_SECRET:          case KEY_SORT_IS_SECRET:
439          aa = a->subkeys->keyid;          get_seckey (a->subkeys->keyid, &a);
440          bb = b->subkeys->keyid;          get_seckey (b->subkeys->keyid, &b);
441          get_seckey (aa, &a);          cmpresult = int_cmp (a? a->secret : 0, b? b->secret : 0);
         get_seckey (bb, &b);  
         if (a)  
             na = a->secret;  
         if (b)  
             nb = b->secret;  
         cmpresult = int_cmp (na, nb);  
442          break;          break;
443    
444      case KEY_SORT_LEN:      case KEY_SORT_LEN:
445          na = a->subkeys->length;          cmpresult = int_cmp (a->subkeys->length,
446          nb = b->subkeys->length;                               b->subkeys->length);
         cmpresult = int_cmp( na, nb );  
447          break;          break;
448    
449      case KEY_SORT_CREATED:      case KEY_SORT_CREATED:
450          ta = a->subkeys->timestamp;          cmpresult = int_cmp (a->subkeys->timestamp,
451          tb = b->subkeys->timestamp;                               b->subkeys->timestamp);
         strcpy( tmpa, get_key_created( ta ) ); aa = tmpa;  
         strcpy( tmpb, get_key_created( tb ) ); bb = tmpb;  
         cmpresult = strcmpi( aa? aa : "", bb? bb : "" );  
452          break;          break;
453    
454      case KEY_SORT_ALGO:      case KEY_SORT_ALGO:
455          na = a->subkeys->pubkey_algo;          cmpresult = int_cmp (a->subkeys->pubkey_algo,
456          nb = b->subkeys->pubkey_algo;                               b->subkeys->pubkey_algo);
         cmpresult = int_cmp (na, nb);  
457          break;          break;
458                    
459      default:      default:
460          aa = a->uids->uid;          cmpresult = strcmpi (a->uids->uid, b->uids->uid);
         bb = b->uids->uid;  
         cmpresult = strcmpi( aa? aa : "", bb? bb : "" );  
461          break;          break;
462      }      }
463      if (sortby & KEYLIST_SORT_DESC)      if (sortby & KEYLIST_SORT_DESC)
464          return (~cmpresult + 1);          return (~cmpresult + 1);
465      else      else
466          return cmpresult;          return cmpresult;
467  } /* keylist_cmp_cb */  }
468    
469    
470  static const char*  static const char*
471  calc_validity( gpg_group_t grp )  calc_validity (gpg_group_t grp)
472  {  {
473      int level = 0, valid;      int level = 0, valid;
474      gpg_member_t mbr;      gpg_member_t mbr;
# Line 578  keylist_build( listview_ctrl_t *r_lv, HW Line 552  keylist_build( listview_ctrl_t *r_lv, HW
552    
553  static void  static void
554  keylist_load_keycache (listview_ctrl_t lv, int mode,  keylist_load_keycache (listview_ctrl_t lv, int mode,
555                         gpgme_keycache_t pubkc, gpgme_keycache_t seckc)                         gpg_keycache_t pubkc, gpg_keycache_t seckc)
556  {  {
557      gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);      gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);
558      gpgme_key_t key, skey;      gpgme_key_t key, skey;
559      const char * keyid;      const char * keyid;
560    
561      if( pubkc && seckc ) {      if (pubkc && seckc) {
562          gpgme_keycache_rewind( pubkc );          gpg_keycache_rewind (pubkc);
563          while( !gpgme_keycache_next_key( pubkc, 0, &key ) ) {          while (!gpg_keycache_next_key (pubkc, 0, &key)) {
564              keyid = key->subkeys->keyid;              keyid = key->subkeys->keyid;
565              if( keyid && !gpgme_keycache_find_key( seckc, keyid, 0, &skey ) )              if (keyid && !gpg_keycache_find_key (seckc, keyid, 0, &skey))
566                  keylist_add_key (lv, mode, key);                  keylist_add_key (lv, mode, key);
567          }                }      
568      }      }
569      else if (pubkc) {      else if (pubkc) {
570          gpgme_keycache_rewind (pubkc);          gpg_keycache_rewind (pubkc);
571          while (!err) {              while (!err) {    
572              err = gpgme_keycache_next_key (pubkc, 0, &key);              err = gpg_keycache_next_key (pubkc, 0, &key);
573              if (!err)              if (!err)
574                  keylist_add_key (lv, mode, key);                  keylist_add_key (lv, mode, key);
575          }          }
# Line 604  keylist_load_keycache (listview_ctrl_t l Line 578  keylist_load_keycache (listview_ctrl_t l
578    
579    
580  listview_ctrl_t  listview_ctrl_t
581  keylist_load (HWND ctrl, gpgme_keycache_t pubkc, gpgme_keycache_t seckc,  keylist_load (HWND ctrl, gpg_keycache_t pubkc, gpg_keycache_t seckc,
582                int mode, int sortby)                int mode, int sortby)
583  {      {    
584      listview_ctrl_t lv;      listview_ctrl_t lv;
585      int rc = 0;      int rc = 0;    
586    
587      rc = keylist_build (&lv, ctrl, mode);      rc = keylist_build (&lv, ctrl, mode);
588      if (rc)      if (rc)
589          return NULL;                      return NULL;            
590      keylist_load_keycache (lv, mode, pubkc, seckc);      keylist_load_keycache (lv, mode, pubkc, seckc);
591      keylist_sort (lv, sortby);      keylist_sort (lv, sortby);
592      if( (mode & KEYLIST_ENCRYPT) || (mode & KEYLIST_ENCRYPT_MIN) )      if ((mode & KEYLIST_ENCRYPT) || (mode & KEYLIST_ENCRYPT_MIN))
593          keylist_add_groups (lv);          keylist_add_groups (lv);
594      return lv;      return lv;
595  } /* keylist_load */  } /* keylist_load */
596    
597    
598  int  int
599  keylist_reload( listview_ctrl_t lv, gpgme_keycache_t pubkc, int mode, int sortby )  keylist_reload( listview_ctrl_t lv, gpg_keycache_t pubkc, int mode, int sortby )
600  {  {
601      listview_del_all( lv );      listview_del_all( lv );
602      keylist_load_keycache( lv, mode, pubkc, NULL );      keylist_load_keycache( lv, mode, pubkc, NULL );
# Line 658  static int Line 632  static int
632  do_addkey (listview_ctrl_t lv, gpgme_key_t key, int uididx, int keyidx, int list)  do_addkey (listview_ctrl_t lv, gpgme_key_t key, int uididx, int keyidx, int list)
633  {      {    
634      LV_ITEM lvi;      LV_ITEM lvi;
     gpgme_key_t seckey;  
635      gpgme_user_id_t u;      gpgme_user_id_t u;
636      gpgme_subkey_t k;      gpgme_subkey_t k;
637      char fmt[128];      char fmt[128];
638      const char *attr;      const char *attr;
639      u32 key_attr;      u32 key_attr;
640      int idx = 0;      int idx = 0;    
641    
642      /* we check the pubkey algorithm here to make sure that no ElGamal      /* we check the pubkey algorithm here to make sure that no ElGamal
643         sign+encrypt key is used in _any_ mode */         sign+encrypt key is used in _any_ mode */
644      if (list != 1 && key->subkeys->pubkey_algo == GPGME_PK_ELG)      if (list != 1 && key->subkeys->pubkey_algo == GPGME_PK_ELG) {
645            log_debug ("ElGamal (E+S) key found: %s (%s)\n",
646                        key->uids->name, key->subkeys->keyid);
647          return 0;          return 0;
648        }    
649    
650                    
651      if (listview_add_item2 (lv, " ", (void *)key))            if (listview_add_item2 (lv, " ", (void *)key))      
652          return WPTERR_GENERAL;          return WPTERR_GENERAL;
# Line 682  do_addkey (listview_ctrl_t lv, gpgme_key Line 659  do_addkey (listview_ctrl_t lv, gpgme_key
659      if( ListView_SetItem( lv->ctrl, &lvi ) == FALSE )        if( ListView_SetItem( lv->ctrl, &lvi ) == FALSE )  
660          return WPTERR_GENERAL;          return WPTERR_GENERAL;
661                    
662      if( uididx == -1 ) {      if( uididx == -1 ) { /* request the primary user-id of the key. */
         /* request the primary user-id of the key. */  
663          attr = key->uids->uid;          attr = key->uids->uid;
664          uididx = 0;          uididx = 0;
665      }      }
# Line 700  do_addkey (listview_ctrl_t lv, gpgme_key Line 676  do_addkey (listview_ctrl_t lv, gpgme_key
676      }        }  
677      else {      else {
678          char * uid = utf8_to_wincp (attr, strlen (attr));          char * uid = utf8_to_wincp (attr, strlen (attr));
679          if( uid ) {                if (uid) {
680              listview_add_sub_item( lv, 0, idx++, uid );              listview_add_sub_item( lv, 0, idx++, uid );
681              free( uid );              free (uid);
682          }          }
683      }      }
684      k = get_nth_key (key, keyidx);      k = get_nth_key (key, keyidx);
685      attr = k->keyid;      if( k && k->keyid ) {
686      if( attr ) {          _snprintf( fmt, sizeof fmt -1, "0x%s", k->keyid + 8 );
         _snprintf( fmt, sizeof fmt -1, "0x%s", attr + 8 );  
687          listview_add_sub_item( lv, 0, idx++, fmt );          listview_add_sub_item( lv, 0, idx++, fmt );
688      }      }
689      if (list > 0) {      if (list > 0) {
690          attr = find_secret_key (key)? "pub/sec" : "pub";          attr = find_secret_key (key)? "pub/sec" : "pub";
691          if (strchr( attr, '/')) {          if (strchr( attr, '/')) {
692              const char * kid;              struct winpt_key_s k;
693              kid = key->subkeys->keyid;              winpt_get_seckey (key->subkeys->keyid, &k);
694              get_seckey( kid, &seckey );              if (k.ext->gloflags.divert_to_card)
695              /*if( gpgme_key_get_ulong_attr( seckey, GPGME_ATTR_DIVERT_CARD, NULL, 0 ) )                  attr = "pub/crd";
                 attr = "pub/crd"; XXX*/  
696          }          }
697          listview_add_sub_item( lv, 0, idx++, attr );          listview_add_sub_item( lv, 0, idx++, attr );
698      }      }
# Line 806  keylist_add_key (listview_ctrl_t lv, int Line 780  keylist_add_key (listview_ctrl_t lv, int
780  {  {
781      int uids, rc = 0, i, n = 0;      int uids, rc = 0, i, n = 0;
782      gpgme_subkey_t k;      gpgme_subkey_t k;
783            
784      for (i = 0; i < count_subkeys (key); i++) {      for (k=key->subkeys, i = 0; i < count_subkeys (key); i++, k=k->next) {
785          k = get_nth_key (key, i);          if (k->invalid) {
786          if (k->invalid)              log_debug ("keylist_add_key: invalid key \"%s\"\n", key->uids->name);
787              continue; /* Don't use invalid keys */              continue; /* Don't use invalid keys */
788            }
789    
790          if (mode & KEYLIST_ALL) {          if (mode & KEYLIST_ALL) {
791              uids = count_userids (key);              uids = count_userids (key);
# Line 862  keylist_add_key (listview_ctrl_t lv, int Line 837  keylist_add_key (listview_ctrl_t lv, int
837  int  int
838  keylist_sort (listview_ctrl_t lv, int sortby)  keylist_sort (listview_ctrl_t lv, int sortby)
839  {        {      
840      return listview_sort_items( lv, sortby, keylist_cmp_cb );      return listview_sort_items (lv, sortby, keylist_cmp_cb);
841  } /* keylist_sort */  }
842    
843    
844    /* Check that the validity @validity is at least >= marginal. */
845  static int  static int
846  key_check_validity (const char *validity)  key_check_validity (const char *validity)
847  {      {    
848      if (strstr (validity, "Unknown")      if (strstr (validity, "Unknown") ||
849          || strstr (validity, "Undefined")          strstr (validity, "Undefined") ||
850          || strstr (validity, "Never"))          strstr (validity, "Never") ||
851            strstr (validity, "None"))
852          return 0;            return 0;  
853      return 1;      return 1;
854  } /* key_check_validity */  }
855    
856    
857    /* Extract all selected recipients from the list @lv and return them
858       as a vector. @r_force_trust is >= 1 if one of the recipients is not
859       fully trusted. @r_count returns the number of selected keys.
860       Return value: the key list on success, NULL otherwise. */
861  gpgme_key_t*  gpgme_key_t*
862  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)
863  {  {
# Line 885  keylist_get_recipients (listview_ctrl_t Line 866  keylist_get_recipients (listview_ctrl_t
866      int k_pos=0;      int k_pos=0;
867      char keyid[32], valid[32], id[100];      char keyid[32], valid[32], id[100];
868      key_array_s *ka = NULL;      key_array_s *ka = NULL;
     gpgme_error_t err;  
869      gpgme_key_t *keybuf;      gpgme_key_t *keybuf;
870    
871      n = listview_count_items( lv, 0 );      n = listview_count_items( lv, 0 );
872        
873      ka = key_array_new( n );      ka = key_array_new( n );
874      if ( !ka )      if (!ka)
875          BUG (NULL);          BUG (NULL);
876    
877      keybuf = (gpgme_key_t*)calloc (n, sizeof (gpgme_key_t));      keybuf = (gpgme_key_t*)calloc (n, sizeof (gpgme_key_t));
# Line 898  keylist_get_recipients (listview_ctrl_t Line 879  keylist_get_recipients (listview_ctrl_t
879          BUG (NULL);          BUG (NULL);
880                    
881      for( j = 0; j < n; j++ ) {      for( j = 0; j < n; j++ ) {
882          if( listview_get_item_state( lv, j ) || n == 1 ) {          if( listview_get_item_state (lv, j) || n == 1) {
883              listview_get_item_text( lv, j, 1, keyid, sizeof keyid - 1 );                                      listview_get_item_text (lv, j, 0, id, sizeof id-1);
884              listview_get_item_text( lv, j, 4, valid, sizeof valid -1 );              listview_get_item_text (lv, j, 1, keyid, sizeof keyid - 1);                
885              listview_get_item_text( lv, j, 0, id, sizeof id-1 );              listview_get_item_text (lv, j, 4, valid, sizeof valid -1);
886              /*if( !strncmp( keyid, "gpg_group_t", 5 ) ) {              if( !key_check_validity (valid)
887                  listview_get_item_text( lv, j, 0, id, sizeof id -1 );                   && !key_array_search( ka, ka_pos, keyid )) {
                 rc = km_groupdb_expand_recipients( id, rset );  
                 if( rc )  
                     force_trust++;  
             }*/  
             if( !key_check_validity( valid )  
                     && !key_array_search( ka, ka_pos, keyid ) ) {  
888                  char *warn = new char[512+strlen (id) + 1];                  char *warn = new char[512+strlen (id) + 1];
889                  if (!warn)                  if (!warn)
890                      BUG (0);                      BUG (0);
# Line 949  keylist_get_recipients (listview_ctrl_t Line 924  keylist_get_recipients (listview_ctrl_t
924      if (r_count)      if (r_count)
925          *r_count = count;          *r_count = count;
926      return keybuf;      return keybuf;
927  } /* keylist_get_recipients */  }
928    
929    
930  static int  static int
# Line 982  keylist_enum_recipients (listview_ctrl_t Line 957  keylist_enum_recipients (listview_ctrl_t
957      int i, n, id, k_pos=0;      int i, n, id, k_pos=0;
958      char keyid[32], t[128], t2[128];      char keyid[32], t[128], t2[128];
959    
960      n = listview_count_items( lv, 0 );      n = listview_count_items (lv, 0);
961      if (!n)      if (!n)
962          return 0;          return 0;
963      rset = (gpgme_key_t*)calloc (n, sizeof (gpgme_key_t));      rset = (gpgme_key_t*)calloc (n, sizeof (gpgme_key_t));
# Line 1029  seclist_destroy (keylist_t * list) Line 1004  seclist_destroy (keylist_t * list)
1004  void  void
1005  seclist_init (HWND dlg, int ctlid, int flags, keylist_t * ret_list)  seclist_init (HWND dlg, int ctlid, int flags, keylist_t * ret_list)
1006  {      {    
1007      gpgme_keycache_t kc = NULL;      gpg_keycache_t kc = NULL;
1008      gpgme_key_t key = NULL;      gpgme_key_t key = NULL;
1009      HWND kb;      HWND kb;
1010      keylist_t list=NULL, l, l2;          keylist_t list=NULL, l, l2;    
# Line 1040  seclist_init (HWND dlg, int ctlid, int f Line 1015  seclist_init (HWND dlg, int ctlid, int f
1015      kc = keycache_get_ctx (0);      kc = keycache_get_ctx (0);
1016      if (!kc)      if (!kc)
1017          BUG (0);          BUG (0);
1018      gpgme_keycache_rewind (kc);      gpg_keycache_rewind (kc);
1019            
1020      while (!gpgme_keycache_next_key (kc, 1, &key)) {      while (!gpg_keycache_next_key (kc, 1, &key)) {
1021          char * inf = NULL, * uid = NULL;          char * inf = NULL, * uid = NULL;
1022          const char * id;          const char * id;
1023          const char * keyid;          const char * keyid;
# Line 1086  seclist_init (HWND dlg, int ctlid, int f Line 1061  seclist_init (HWND dlg, int ctlid, int f
1061          SendMessage( kb, CB_SETITEMDATA, pos, (LPARAM)(DWORD)l2->key );          SendMessage( kb, CB_SETITEMDATA, pos, (LPARAM)(DWORD)l2->key );
1062      SendMessage( kb, CB_SETCURSEL, 0, 0 );      SendMessage( kb, CB_SETCURSEL, 0, 0 );
1063      *ret_list = list;      *ret_list = list;
1064  } /* seclist_init */  }
1065                    
1066    
1067    /* Select a secret key from the combo box with the ID @ctlid.
1068       Return the code on success in @ret_key. */
1069  int  int
1070  seclist_select_key (HWND dlg, int ctlid, gpgme_key_t * ret_key)  seclist_select_key (HWND dlg, int ctlid, gpgme_key_t *ret_key)
1071  {  {
1072      int pos;      int pos;
1073      DWORD k = 0;      DWORD k = 0;
1074    
1075      pos = SendDlgItemMessage( dlg, ctlid, CB_GETCURSEL, 0, 0 );      pos = SendDlgItemMessage (dlg, ctlid, CB_GETCURSEL, 0, 0);
1076      if( pos == CB_ERR ) {      if (pos == CB_ERR) {
1077          msg_box( dlg, _("No key was selected."), _("Secret Key List"), MB_ERR );          msg_box (dlg, _("No key was selected."), _("Secret Key List"), MB_ERR);
1078          *ret_key = NULL;          *ret_key = NULL;
1079      }      }
1080      else {      else {
1081          k = SendDlgItemMessage( dlg, ctlid, CB_GETITEMDATA, pos, 0 );          k = SendDlgItemMessage (dlg, ctlid, CB_GETITEMDATA, pos, 0);
1082          *ret_key = (gpgme_key_t)k;          *ret_key = (gpgme_key_t)k;
1083      }      }
1084      return k? 0 : -1;      return k? 0 : -1;
1085  } /* seclist_dlg_proc */  }

Legend:
Removed from v.23  
changed lines
  Added in v.25

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26