+2001-09-03 Werner Koch <wk@gnupg.org>
+
+ * rungpg.h: Added STATUS_INV_RECP.
+ * gpgme.c (_gpgme_release_result): Add support for new
+ EncryptResult object.
+ * encrypt.c (append_xml_encinfo): New.
+ (encrypt_status_handler): Add some status parsing.
+ (_gpgme_release_encrypt_result): New.
+
2001-08-29 Werner Koch <wk@gnupg.org>
+ * recipient.c (gpgme_recipients_release): Free the list. By Timo.
+
* keylist.c (keylist_colon_handler): Do a finish key if we receive
an EOF here. This is probably the reason for a lot of bugs
related to keylisting. It is so obvious. Kudos to Enno Cramer
#include "context.h"
#include "ops.h"
+#define SKIP_TOKEN_OR_RETURN(a) do { \
+ while (*(a) && *(a) != ' ') (a)++; \
+ while (*(a) == ' ') (a)++; \
+ if (!*(a)) \
+ return; /* oops */ \
+} while (0)
+
+
+
+struct encrypt_result_s {
+ GpgmeData xmlinfo;
+};
+
+
+void
+_gpgme_release_encrypt_result (EncryptResult res)
+{
+ gpgme_data_release (res->xmlinfo);
+ xfree (res);
+}
+
+
+/*
+ * Parse the args and save the information
+ * in an XML structure.
+ * With args of NULL the xml structure is closed.
+ */
+static void
+append_xml_encinfo (GpgmeData *rdh, char *args)
+{
+ GpgmeData dh;
+ char helpbuf[100];
+
+ if ( !*rdh ) {
+ if (gpgme_data_new (rdh)) {
+ return; /* fixme: We are ignoring out-of-core */
+ }
+ dh = *rdh;
+ _gpgme_data_append_string (dh, "<GnupgOperationInfo>\n");
+ }
+ else {
+ dh = *rdh;
+ _gpgme_data_append_string (dh, " </encryption>\n");
+ }
+
+ if (!args) { /* just close the XML containter */
+ _gpgme_data_append_string (dh, "</GnupgOperationInfo>\n");
+ return;
+ }
+
+ _gpgme_data_append_string (dh, " <encryption>\n"
+ " <error>\n"
+ " <invalidRecipient/>\n");
+
+ sprintf (helpbuf, " <reason>%d</reason>\n", atoi (args));
+ _gpgme_data_append_string (dh, helpbuf);
+ SKIP_TOKEN_OR_RETURN (args);
+
+ _gpgme_data_append_string (dh, " <name>");
+ _gpgme_data_append_percentstring_for_xml (dh, args);
+ _gpgme_data_append_string (dh, "</name>\n"
+ " </error>\n");
+}
+
+
+
+
+
static void
encrypt_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args )
{
- DEBUG2 ("encrypt_status: code=%d args=`%s'\n", code, args );
+ if ( ctx->out_of_core )
+ return;
+ if ( ctx->result_type == RESULT_TYPE_NONE ) {
+ assert ( !ctx->result.encrypt );
+ ctx->result.encrypt = xtrycalloc ( 1, sizeof *ctx->result.encrypt );
+ if ( !ctx->result.encrypt ) {
+ ctx->out_of_core = 1;
+ return;
+ }
+ ctx->result_type = RESULT_TYPE_ENCRYPT;
+ }
+ assert ( ctx->result_type == RESULT_TYPE_ENCRYPT );
+
+ switch (code) {
+ case STATUS_EOF:
+ if (ctx->result.encrypt->xmlinfo) {
+ append_xml_encinfo (&ctx->result.encrypt->xmlinfo, NULL);
+ _gpgme_set_op_info (ctx, ctx->result.encrypt->xmlinfo);
+ ctx->result.encrypt->xmlinfo = NULL;
+ }
+ break;
+
+ case STATUS_INV_RECP:
+ append_xml_encinfo (&ctx->result.encrypt->xmlinfo, args);
+ break;
+
+ default:
+ break;
+ }
}
fail_on_pending_request( c );
c->pending = 1;
+ _gpgme_release_result (c);
+ c->out_of_core = 0;
+
/* do some checks */
if ( !gpgme_recipients_count ( recp ) ) {
/* Fixme: In this case we should do symmentric encryption */
if ( !rc ) {
gpgme_wait (c, 1);
c->pending = 0;
- /* FIXME: gpg does not return status info for invalid
+ /* FIXME: old gpg versions don't return status info for invalid
* recipients, so we simply check whether we got any output at
* all and if not assume that we don't have valid recipients
* */