diff options
author | Marcus Brinkmann <[email protected]> | 2002-07-03 01:57:03 +0000 |
---|---|---|
committer | Marcus Brinkmann <[email protected]> | 2002-07-03 01:57:03 +0000 |
commit | b92c8f057ce62a6676955dccdbae2aa8d083d0ee (patch) | |
tree | d70f62575f06045dd48c3dcf7fbcac8071c756d3 /gpgme/trustlist.c | |
parent | Fix news item. (diff) | |
download | gpgme-b92c8f057ce62a6676955dccdbae2aa8d083d0ee.tar.gz gpgme-b92c8f057ce62a6676955dccdbae2aa8d083d0ee.zip |
2002-07-03 Marcus Brinkmann <[email protected]>
* gpgme.c (gpgme_set_io_cbs): Deal with CTX being NULL.
* gpgme.c (_gpgme_op_event_cb_user): New function.
* op-support.c (_gpgme_op_reset): Support a new mode of operation
for private or user event loop. Use new user event callback
wrapper.
* trustlist.c (gpgme_op_trustlist_start): Use this new mode.
* keylist.c (gpgme_op_keylist_start): Likewise.
* rungpg.c (_gpgme_gpg_io_event): New function.
* rungpg.h (_gpgme_gpg_io_event): New prototype.
* engine-gpgsm.c (_gpgme_gpg_io_event): New function.
* engine-gpgsm.h (_gpgme_gpgsm_io_event): New prototype.
* engine.c (_gpgme_engine_io_event): New function.
* engine.h (_gpgme_engine_io_event): New prototype.
* keylist.c (finish_key): Call _gpgme_engine_io_event, and move
the real work for the default IO callback routines to ...
(_gpgme_op_keylist_event_cb): ... here. New function.
* trustlist.c (trustlist_colon_handler): Signal
GPGME_EVENT_NEXT_TRUSTITEM. Move queue manipulation to ...
(_gpgme_op_trustlist_event_cb): ... here. New function.
* gpgme.c (_gpgme_op_event_cb): Call _gpgme_op_keylist_event_cb
and _gpgme_op_trustlist_event_cb when appropriate.
* ops.h (_gpgme_op_keylist_event_cb): New prototype.
(_gpgme_op_trustlist_event_cb): Likewise.
* op-support.c (_gpgme_op_reset): Add comment why we don't use the
user provided event handler directly.
* gpgme.h (GpgmeRegisterIOCb): Return GpgmeError value, and TAG in
a pointer argument.
* wait.c (_gpgme_add_io_cb): Likewise.
* wait.h (_gpgme_add_io_cb): Likewise for prototype.
* rungpg.c (_gpgme_gpg_add_io_cb): Call IO_CBS->add with new
argument. Fix up error handling.
* engine-gpgsm.c (_gpgme_gpgsm_add_io_cb): Call IO_CBS->add with
new argument, fix up error handling.
Diffstat (limited to '')
-rw-r--r-- | gpgme/trustlist.c | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/gpgme/trustlist.c b/gpgme/trustlist.c index 3d10e511..2fd4b9c7 100644 --- a/gpgme/trustlist.c +++ b/gpgme/trustlist.c @@ -87,7 +87,6 @@ trustlist_colon_handler (GpgmeCtx ctx, char *line) char *p, *pend; int field = 0; GpgmeTrustItem item = NULL; - struct trust_queue_item_s *q, *q2; if (ctx->error) return; @@ -104,31 +103,12 @@ trustlist_colon_handler (GpgmeCtx ctx, char *line) switch (field) { case 1: /* level */ - q = xtrymalloc (sizeof *q); - if (!q) - { - ctx->error = mk_error (Out_Of_Core); - return; - } - q->next = NULL; - q->item = item = trust_item_new (); - if (!q->item) + item = trust_item_new (); + if (!item) { - xfree (q); ctx->error = mk_error (Out_Of_Core); return; } - /* fixme: lock queue, keep a tail pointer */ - q2 = ctx->trust_queue; - if (!q2) - ctx->trust_queue = q; - else - { - while (q2->next) - q2 = q2->next; - q2->next = q; - } - /* fixme: unlock queue */ item->level = atoi (p); break; case 2: /* long keyid */ @@ -154,8 +134,41 @@ trustlist_colon_handler (GpgmeCtx ctx, char *line) } } - if (field) - ctx->key_cond = 1; + if (item) + _gpgme_engine_io_event (ctx->engine, GPGME_EVENT_NEXT_TRUSTITEM, item); +} + + +void +_gpgme_op_trustlist_event_cb (void *data, GpgmeEventIO type, void *type_data) +{ + GpgmeCtx ctx = (GpgmeCtx) data; + GpgmeTrustItem item = (GpgmeTrustItem) type_data; + struct trust_queue_item_s *q, *q2; + + assert (type == GPGME_EVENT_NEXT_KEY); + + q = xtrymalloc (sizeof *q); + if (!q) + { + gpgme_trust_item_release (item); + ctx->error = mk_error (Out_Of_Core); + return; + } + q->item = item; + q->next = NULL; + /* FIXME: lock queue, keep a tail pointer */ + q2 = ctx->trust_queue; + if (!q2) + ctx->trust_queue = q; + else + { + while (q2->next) + q2 = q2->next; + q2->next = q; + } + /* FIXME: unlock queue */ + ctx->key_cond = 1; } @@ -167,9 +180,7 @@ gpgme_op_trustlist_start (GpgmeCtx ctx, const char *pattern, int max_level) if (!pattern || !*pattern) return mk_error (Invalid_Value); - /* Trustlist operations are always "synchronous" in the sense that - we don't add ourself to the global FD table. */ - err = _gpgme_op_reset (ctx, 1); + err = _gpgme_op_reset (ctx, 2); if (err) goto leave; |