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

Diff of /trunk/Src/wptKeyCache.cpp

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

revision 204 by twoaday, Fri Apr 7 10:47:37 2006 UTC revision 205 by twoaday, Thu Apr 27 12:46:03 2006 UTC
# Line 37  Line 37 
37  #include "wptW32API.h"  #include "wptW32API.h"
38  #include "wptGPG.h"  #include "wptGPG.h"
39  #include "wptTypes.h"  #include "wptTypes.h"
40    #include "wptUTF8.h"
41    
42    
43  /* Attribute list which holds the image data. */  /* Attribute list which holds the image data. */
# Line 250  keycache_update_photos (gpg_keycache_t c Line 251  keycache_update_photos (gpg_keycache_t c
251  }  }
252    
253    
254    /* Store utf8 decoded user IDs in the code to avoid in-place decoding. */
255    static gpgme_error_t
256    keycache_decode_uids (gpg_keycache_t ctx)
257    {
258        struct native_uid_s *n, *t;
259        struct keycache_s *c;
260        gpgme_user_id_t u;
261    
262        for (c = ctx->item; c; c = c->next) {
263            for (u = c->key->uids; u; u = u->next) {
264                n = (struct native_uid_s*)calloc (1, sizeof *n);
265                if (!n)
266                    BUG (0);
267                if (is_8bit_string (u->uid)) {
268                    n->malloced = 1;
269                    n->uid = utf8_to_native (u->uid);
270                    if (u->name != NULL)
271                        n->name = utf8_to_native (u->name);
272                    if (u->email != NULL)
273                        n->email = strdup (u->email);
274                    if (u->comment != NULL)
275                        n->comment = utf8_to_native (u->comment);
276                }
277                else {
278                    n->malloced = 0;
279                    n->uid = u->uid;
280                    n->name = u->name;
281                    n->comment = u->comment;
282                    n->email = u->email;
283                }
284                if (!c->uids)
285                    c->uids = n;
286                else {
287                    for (t = c->uids; t->next; t=t->next)
288                        ;
289                    t->next = n;
290                }
291            }
292        }  
293        return 0;
294    }
295    
296    
297    static void
298    free_native_uids (struct native_uid_s *n)
299    {
300        struct native_uid_s *t;
301    
302        while (n != NULL) {
303            t = n->next;
304            if (n->malloced) {
305                safe_free (n->uid);
306                safe_free (n->name);
307                safe_free (n->comment);
308                safe_free (n->email);
309                safe_free (n->uid);
310            }
311            safe_free (n);
312            n = t;
313        }
314    }
315    
316    
317    
318  /* Merge the information from the keyrings into the key cache structure. */  /* Merge the information from the keyrings into the key cache structure. */
319  gpgme_error_t  gpgme_error_t
320  keycache_prepare2 (gpg_keycache_t ctx, const char *kid,  keycache_prepare2 (gpg_keycache_t ctx, const char *kid,
# Line 380  gpg_keycache_release (gpg_keycache_t ctx Line 445  gpg_keycache_release (gpg_keycache_t ctx
445          safe_free (c->sym_prefs);          safe_free (c->sym_prefs);
446          safe_free (c->attrib.d);          safe_free (c->attrib.d);
447          safe_free (c->card_type);          safe_free (c->card_type);
448            free_native_uids (c->uids);
449          safe_free (c);          safe_free (c);
450      }      }
451      safe_free (ctx);      safe_free (ctx);
# Line 658  gpg_keycache_init (gpg_keycache_t ctx, c Line 724  gpg_keycache_init (gpg_keycache_t ctx, c
724      if (gpgme_err_code (err) == GPG_ERR_EOF)      if (gpgme_err_code (err) == GPG_ERR_EOF)
725          err = gpg_error (GPG_ERR_NO_ERROR);          err = gpg_error (GPG_ERR_NO_ERROR);
726      keycache_update_photos (ctx);      keycache_update_photos (ctx);
727        keycache_decode_uids (ctx);
728      /* XXX: make sure the progress dialog is closed. */      /* XXX: make sure the progress dialog is closed. */
729      gpgme_op_keylist_end (c);      gpgme_op_keylist_end (c);
730      gpgme_release (c);      gpgme_release (c);
# Line 772  keycache_next_key (gpg_keycache_t ctx, i Line 839  keycache_next_key (gpg_keycache_t ctx, i
839      if (flags && ctx->tmp->pubpart == NULL)      if (flags && ctx->tmp->pubpart == NULL)
840          flags = 0;          flags = 0;
841      *r_key = flags? ctx->tmp->pubpart->key : ctx->tmp->key;      *r_key = flags? ctx->tmp->pubpart->key : ctx->tmp->key;
842      *c = ctx->tmp = ctx->tmp->next;      *c = ctx->tmp;
843        ctx->tmp = ctx->tmp->next;    
844      ctx->pos++;      ctx->pos++;
845    
846      return 0;      return 0;
# Line 786  gpgme_error_t Line 854  gpgme_error_t
854  gpg_keycache_next_key (gpg_keycache_t ctx, int flags, gpgme_key_t *r_key)  gpg_keycache_next_key (gpg_keycache_t ctx, int flags, gpgme_key_t *r_key)
855  {  {
856      struct keycache_s *c=NULL;      struct keycache_s *c=NULL;
857      gpgme_error_t err = 0;      gpgme_error_t err;
858    
859      err = keycache_next_key (ctx, flags, &c, r_key);      err = keycache_next_key (ctx, flags, &c, r_key);
860      return err;      return err;
861  }  }
862    
863    gpgme_error_t
864    gpg_keycache_next_key2 (gpg_keycache_t ctx, int flags,
865                            struct keycache_s **c, gpgme_key_t *r_key)
866    {
867        return keycache_next_key (ctx, flags, c, r_key);
868    }
869    
870    
871  /* Search for a key with the pattern @pattern and mark  /* Search for a key with the pattern @pattern and mark
872     this key as the default signing key if found.     this key as the default signing key if found.
# Line 931  gpg_keycache_update_attr (struct keycach Line 1006  gpg_keycache_update_attr (struct keycach
1006      safe_free (val);      safe_free (val);
1007      return err;      return err;
1008  }  }
   

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26