From 92ca22fe6ba84dc5492a186207bb46be03f0bab2 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 7 Sep 2001 12:47:33 +0000 Subject: [PATCH] added new status messages --- gpgme/ChangeLog | 8 ++++++++ gpgme/encrypt.c | 26 ++++++++++++++++++++------ gpgme/rungpg.h | 3 ++- gpgme/verify.c | 6 +++++- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index 5437ad5e..e4794d9a 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,11 @@ +2001-09-07 Werner Koch + + * rungpg.h: Add NO_RECP. + * encrypt.c (encrypt_status_handler): Take on No_RECP. + (gpgme_op_encrypt): Better error return. + + * verify.c (verify_status_handler): Take on NODATA. + 2001-09-03 Werner Koch * rungpg.h: Added STATUS_INV_RECP. diff --git a/gpgme/encrypt.c b/gpgme/encrypt.c index 00531a01..3dc7eb03 100644 --- a/gpgme/encrypt.c +++ b/gpgme/encrypt.c @@ -39,6 +39,7 @@ struct encrypt_result_s { + int no_recipients; GpgmeData xmlinfo; }; @@ -126,6 +127,10 @@ encrypt_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args ) append_xml_encinfo (&ctx->result.encrypt->xmlinfo, args); break; + case STATUS_NO_RECP: + ctx->result.encrypt->no_recipients = 1; /* i.e. no usable ones */ + break; + default: break; } @@ -222,18 +227,27 @@ GpgmeError gpgme_op_encrypt ( GpgmeCtx c, GpgmeRecipients recp, GpgmeData in, GpgmeData out ) { - int rc = gpgme_op_encrypt_start ( c, recp, in, out ); - if ( !rc ) { + int err = gpgme_op_encrypt_start ( c, recp, in, out ); + if ( !err ) { gpgme_wait (c, 1); + if ( c->result_type != RESULT_TYPE_ENCRYPT ) + err = mk_error (General_Error); + else if ( c->out_of_core ) + err = mk_error (Out_Of_Core); + else { + assert ( c->result.encrypt ); + if (c->result.encrypt->no_recipients) + err = mk_error (No_Recipients); + } c->pending = 0; - /* FIXME: old gpg versions don't return status info for invalid + /* 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 * */ - if (gpgme_data_get_type (out) == GPGME_DATA_TYPE_NONE) - rc = mk_error (No_Recipients); + if (!err && gpgme_data_get_type (out) == GPGME_DATA_TYPE_NONE) + err = mk_error (No_Recipients); } - return rc; + return err; } diff --git a/gpgme/rungpg.h b/gpgme/rungpg.h index 3c2da5da..6c6fc32a 100644 --- a/gpgme/rungpg.h +++ b/gpgme/rungpg.h @@ -87,7 +87,8 @@ typedef enum { STATUS_POLICY_URL , STATUS_BEGIN_STREAM , STATUS_END_STREAM , - STATUS_INV_RECP + STATUS_INV_RECP , + STATUS_NO_RECP } GpgStatusCode; typedef void (*GpgStatusHandler)( GpgmeCtx, GpgStatusCode code, char *args ); diff --git a/gpgme/verify.c b/gpgme/verify.c index 3b2174b6..ededc580 100644 --- a/gpgme/verify.c +++ b/gpgme/verify.c @@ -152,8 +152,12 @@ verify_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args ) } switch (code) { + case STATUS_NODATA: + ctx->result.verify->status = GPGME_SIG_STAT_NOSIG; + break; + case STATUS_GOODSIG: - /* We just look at VALIDSIG */ + /* We only look at VALIDSIG */ break; case STATUS_VALIDSIG: