251 |
} |
} |
252 |
|
|
253 |
|
|
254 |
|
static void |
255 |
|
keycache_decode_uid (struct keycache_s *ctx) |
256 |
|
{ |
257 |
|
gpgme_user_id_t u; |
258 |
|
struct native_uid_s *n, *t; |
259 |
|
|
260 |
|
for (u = ctx->key->uids; u; u = u->next) { |
261 |
|
n = (struct native_uid_s*)calloc (1, sizeof *n); |
262 |
|
if (!n) |
263 |
|
BUG (0); |
264 |
|
if (is_8bit_string (u->uid)) { |
265 |
|
n->malloced = 1; |
266 |
|
n->uid = utf8_to_native (u->uid); |
267 |
|
if (u->name != NULL) |
268 |
|
n->name = utf8_to_native (u->name); |
269 |
|
if (u->email != NULL) |
270 |
|
n->email = strdup (u->email); |
271 |
|
if (u->comment != NULL) |
272 |
|
n->comment = utf8_to_native (u->comment); |
273 |
|
} |
274 |
|
else { |
275 |
|
n->malloced = 0; |
276 |
|
n->uid = u->uid; |
277 |
|
n->name = u->name; |
278 |
|
n->comment = u->comment; |
279 |
|
n->email = u->email; |
280 |
|
} |
281 |
|
n->validity = u->validity; |
282 |
|
n->revoked = u->revoked; |
283 |
|
if (!ctx->uids) |
284 |
|
ctx->uids = n; |
285 |
|
else { |
286 |
|
for (t = ctx->uids; t->next; t=t->next) |
287 |
|
; |
288 |
|
t->next = n; |
289 |
|
} |
290 |
|
} |
291 |
|
} |
292 |
|
|
293 |
|
|
294 |
/* Store utf8 decoded user IDs in the code to avoid in-place decoding. */ |
/* Store utf8 decoded user IDs in the code to avoid in-place decoding. */ |
295 |
static gpgme_error_t |
static void |
296 |
keycache_decode_uids (gpg_keycache_t ctx) |
keycache_decode_uids (gpg_keycache_t ctx) |
297 |
{ |
{ |
|
struct native_uid_s *n, *t; |
|
298 |
struct keycache_s *c; |
struct keycache_s *c; |
|
gpgme_user_id_t u; |
|
299 |
|
|
300 |
for (c = ctx->item; c; c = c->next) { |
for (c = ctx->item; c; c = c->next) |
301 |
for (u = c->key->uids; u; u = u->next) { |
keycache_decode_uid (c); |
|
n = (struct native_uid_s*)calloc (1, sizeof *n); |
|
|
if (!n) |
|
|
BUG (0); |
|
|
if (is_8bit_string (u->uid)) { |
|
|
n->malloced = 1; |
|
|
n->uid = utf8_to_native (u->uid); |
|
|
if (u->name != NULL) |
|
|
n->name = utf8_to_native (u->name); |
|
|
if (u->email != NULL) |
|
|
n->email = strdup (u->email); |
|
|
if (u->comment != NULL) |
|
|
n->comment = utf8_to_native (u->comment); |
|
|
} |
|
|
else { |
|
|
n->malloced = 0; |
|
|
n->uid = u->uid; |
|
|
n->name = u->name; |
|
|
n->comment = u->comment; |
|
|
n->email = u->email; |
|
|
} |
|
|
if (!c->uids) |
|
|
c->uids = n; |
|
|
else { |
|
|
for (t = c->uids; t->next; t=t->next) |
|
|
; |
|
|
t->next = n; |
|
|
} |
|
|
} |
|
|
} |
|
|
return 0; |
|
302 |
} |
} |
303 |
|
|
304 |
|
|
305 |
static void |
static void |
306 |
free_native_uids (struct native_uid_s *n) |
free_native_uids (struct native_uid_s **r_n) |
307 |
{ |
{ |
308 |
struct native_uid_s *t; |
struct native_uid_s *t; |
309 |
|
struct native_uid_s *n = *r_n; |
310 |
|
|
311 |
while (n != NULL) { |
while (n != NULL) { |
312 |
t = n->next; |
t = n->next; |
320 |
safe_free (n); |
safe_free (n); |
321 |
n = t; |
n = t; |
322 |
} |
} |
323 |
|
*r_n = NULL; |
324 |
} |
} |
325 |
|
|
326 |
|
|
455 |
safe_free (c->sym_prefs); |
safe_free (c->sym_prefs); |
456 |
safe_free (c->attrib.d); |
safe_free (c->attrib.d); |
457 |
safe_free (c->card_type); |
safe_free (c->card_type); |
458 |
free_native_uids (c->uids); |
free_native_uids (&c->uids); |
459 |
safe_free (c); |
safe_free (c); |
460 |
} |
} |
461 |
safe_free (ctx); |
safe_free (ctx); |
646 |
} |
} |
647 |
/* XXX: this is also called for keys without a photo-id. */ |
/* XXX: this is also called for keys without a photo-id. */ |
648 |
keycache_reload_photo (ctx, keyid); |
keycache_reload_photo (ctx, keyid); |
649 |
|
|
650 |
|
/* refresh utf8 user ID list. */ |
651 |
|
free_native_uids (&c->uids); |
652 |
|
keycache_decode_uid (c); |
653 |
} |
} |
654 |
else { |
else { |
655 |
log_debug ("keycache add: sync public part\r\n"); |
log_debug ("keycache add: sync public part\r\n"); |