void EventLoopInteractor::Private::eventIOCb(void *data, gpgme_event_io_t type, void *type_data) { assert(instance()); Context *ctx = static_cast<Context *>(data); switch (type) { case GPGME_EVENT_START: { instance()->operationStartEvent(ctx); // TODO: what's in type_data? } break; case GPGME_EVENT_DONE: { gpgme_error_t e = *static_cast<gpgme_error_t *>(type_data); if (ctx && ctx->impl()) { ctx->impl()->lasterr = e; } instance()->operationDoneEvent(ctx, Error(e)); } break; case GPGME_EVENT_NEXT_KEY: { gpgme_key_t key = static_cast<gpgme_key_t>(type_data); instance()->nextKeyEvent(ctx, Key(key, false)); } break; case GPGME_EVENT_NEXT_TRUSTITEM: { gpgme_trust_item_t item = static_cast<gpgme_trust_item_t>(type_data); instance()->nextTrustItemEvent(ctx, TrustItem(item)); gpgme_trust_item_unref(item); } break; default: // warn ; } }
/* This handler is used to parse the output of --list-trust-path: Format: level:keyid:type:recno:ot:val:mc:cc:name: With TYPE = U for a user ID K for a key The RECNO is either the one of the dir record or the one of the uid record. OT is the the usual trust letter and only availabel on K lines. VAL is the calcualted validity MC is the marginal trust counter and only available on U lines CC is the same for the complete count NAME ist the username and only printed on U lines. */ static gpgme_error_t trustlist_colon_handler (void *priv, char *line) { gpgme_ctx_t ctx = (gpgme_ctx_t) priv; gpgme_error_t err; char *p, *pend; int field = 0; gpgme_trust_item_t item = NULL; if (!line) return 0; /* EOF */ for (p = line; p; p = pend) { field++; pend = strchr (p, ':'); if (pend) *pend++ = 0; switch (field) { case 1: /* level */ err = _gpgme_trust_item_new (&item); if (err) return err; item->level = atoi (p); break; case 2: /* long keyid */ if (strlen (p) == DIM(item->keyid) - 1) strcpy (item->keyid, p); break; case 3: /* type */ item->type = *p == 'K'? 1 : *p == 'U'? 2 : 0; break; case 5: /* owner trust */ item->_owner_trust[0] = *p; break; case 6: /* validity */ item->_validity[0] = *p; break; case 9: /* user ID */ item->name = strdup (p); if (!item->name) { int saved_errno = errno; gpgme_trust_item_unref (item); return gpg_error_from_errno (saved_errno); } break; } } if (item) _gpgme_engine_io_event (ctx->engine, GPGME_EVENT_NEXT_TRUSTITEM, item); return 0; }
void _gpgme_op_trustlist_event_cb (void *data, gpgme_event_io_t type, void *type_data) { gpgme_ctx_t ctx = (gpgme_ctx_t) data; gpgme_error_t err; void *hook; op_data_t opd; gpgme_trust_item_t item = (gpgme_trust_item_t) type_data; struct trust_queue_item_s *q, *q2; assert (type == GPGME_EVENT_NEXT_TRUSTITEM); err = _gpgme_op_data_lookup (ctx, OPDATA_TRUSTLIST, &hook, -1, NULL); opd = hook; if (err) return; q = malloc (sizeof *q); if (!q) { gpgme_trust_item_unref (item); /* FIXME: GPGME_Out_Of_Core; */ return; } q->item = item; q->next = NULL; /* FIXME: Use a tail pointer */ q2 = opd->trust_queue; if (!q2) opd->trust_queue = q; else { while (q2->next) q2 = q2->next; q2->next = q; } /* FIXME: unlock queue */ opd->trust_cond = 1; }
/* Compatibility interfaces. */ void gpgme_trust_item_release(gpgme_trust_item_t item) { gpgme_trust_item_unref(item); }