2009-11-10 Marcus Brinkmann <marcus@g10code.de>

* 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.
This commit is contained in:
Marcus Brinkmann 2009-11-10 14:49:35 +00:00
parent 96cf17b159
commit cda07b9ab4
7 changed files with 34 additions and 7 deletions

View File

@ -1,5 +1,12 @@
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* 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,

View File

@ -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;

View File

@ -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;
}

View File

@ -194,6 +194,7 @@ EXPORTS
gpgme_key_from_uid @149
gpgme_set_sub_protocol @150
gpgme_get_sub_protocol @151
; END

View File

@ -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);

View File

@ -75,6 +75,7 @@ GPGME_1.1 {
gpgme_key_from_uid;
gpgme_set_sub_protocol;
gpgme_get_sub_protocol;
};

View File

@ -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. */