From cda07b9ab4f09ac87bc1aebbbe113f125eedeb02 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Tue, 10 Nov 2009 14:49:35 +0000 Subject: [PATCH] 2009-11-10 Marcus Brinkmann * gpgme.h.in (gpgme_get_sub_protocol): Add prototype. * gpgme.def, libgpgme.vers: Add gpgme_get_sub_protocol. * context.h (struct gpgme_context): New member sub_protocol. * gpgme.c (gpgme_set_sub_protocol): Set CTX->sub_protocol. (gpgme_get_sub_protocol): New function. * op-support.c (_gpgme_op_reset): Set sub protocol. --- src/ChangeLog | 7 +++++++ src/context.h | 3 +++ src/gpgme.c | 21 +++++++++++++++------ src/gpgme.def | 1 + src/gpgme.h.in | 4 +++- src/libgpgme.vers | 1 + src/op-support.c | 4 ++++ 7 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index b758b7b..91ea9da 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,12 @@ 2009-11-10 Marcus Brinkmann + * gpgme.h.in (gpgme_get_sub_protocol): Add prototype. + * gpgme.def, libgpgme.vers: Add gpgme_get_sub_protocol. + * context.h (struct gpgme_context): New member sub_protocol. + * gpgme.c (gpgme_set_sub_protocol): Set CTX->sub_protocol. + (gpgme_get_sub_protocol): New function. + * op-support.c (_gpgme_op_reset): Set sub protocol. + * Makefile.am (uiserver_components): New variable. (main_sources): Add it. * ops.h, key.c (_gpgme_key_append_name): Take CONVERT argument, diff --git a/src/context.h b/src/context.h index 6818e7e..6ab0154 100644 --- a/src/context.h +++ b/src/context.h @@ -89,6 +89,9 @@ struct gpgme_context /* The running engine process. */ engine_t engine; + /* Engine's sub protocol. */ + gpgme_protocol_t sub_protocol; + /* True if armor mode should be used. */ unsigned int use_armor : 1; diff --git a/src/gpgme.c b/src/gpgme.c index b6c79a0..7c52385 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -305,13 +305,22 @@ gpgme_get_protocol (gpgme_ctx_t ctx) gpgme_error_t gpgme_set_sub_protocol (gpgme_ctx_t ctx, gpgme_protocol_t protocol) { - gpgme_error_t err; - TRACE_BEG2 (DEBUG_CTX, "gpgme_set_sub_protocol", ctx, "protocol=%i (%s)", - protocol, gpgme_get_protocol_name (protocol) - ? gpgme_get_protocol_name (protocol) : "invalid"); + TRACE2 (DEBUG_CTX, "gpgme_set_sub_protocol", ctx, "protocol=%i (%s)", + protocol, gpgme_get_protocol_name (protocol) + ? gpgme_get_protocol_name (protocol) : "invalid"); + ctx->sub_protocol = protocol; + return 0; +} - err = _gpgme_engine_set_protocol (ctx->engine, protocol); - return TRACE_ERR (err); + +gpgme_error_t +gpgme_get_sub_protocol (gpgme_ctx_t ctx) +{ + TRACE2 (DEBUG_CTX, "gpgme_get_sub_protocol", ctx, + "ctx->sub_protocol=%i (%s)", ctx->sub_protocol, + gpgme_get_protocol_name (ctx->sub_protocol) + ? gpgme_get_protocol_name (ctx->sub_protocol) : "invalid"); + return ctx->sub_protocol; } diff --git a/src/gpgme.def b/src/gpgme.def index 5a1b2c1..eee2531 100644 --- a/src/gpgme.def +++ b/src/gpgme.def @@ -194,6 +194,7 @@ EXPORTS gpgme_key_from_uid @149 gpgme_set_sub_protocol @150 + gpgme_get_sub_protocol @151 ; END diff --git a/src/gpgme.h.in b/src/gpgme.h.in index 2a3acd4..13a3399 100644 --- a/src/gpgme.h.in +++ b/src/gpgme.h.in @@ -810,8 +810,10 @@ gpgme_protocol_t gpgme_get_protocol (gpgme_ctx_t ctx); prococol (for example, an UISERVER can support OpenPGP and CMS). This is reset to the default with gpgme_set_protocol. */ gpgme_error_t gpgme_set_sub_protocol (gpgme_ctx_t ctx, - gpgme_protocol_t proto); + gpgme_protocol_t proto); +/* Get the sub protocol. */ +gpgme_protocol_t gpgme_get_sub_protocol (gpgme_ctx_t ctx); /* Get the string describing protocol PROTO, or NULL if invalid. */ const char *gpgme_get_protocol_name (gpgme_protocol_t proto); diff --git a/src/libgpgme.vers b/src/libgpgme.vers index 449197c..a9ddfb3 100644 --- a/src/libgpgme.vers +++ b/src/libgpgme.vers @@ -75,6 +75,7 @@ GPGME_1.1 { gpgme_key_from_uid; gpgme_set_sub_protocol; + gpgme_get_sub_protocol; }; diff --git a/src/op-support.c b/src/op-support.c index 90e1283..8dfe15d 100644 --- a/src/op-support.c +++ b/src/op-support.c @@ -130,6 +130,10 @@ _gpgme_op_reset (gpgme_ctx_t ctx, int type) } } + err = _gpgme_engine_set_protocol (ctx->engine, ctx->sub_protocol); + if (err) + return err; + if (type == 1 || (type == 2 && !ctx->io_cbs.add)) { /* Use private event loop. */ -- 2.26.2