From: Werner Koch Date: Fri, 7 Sep 2001 12:47:33 +0000 (+0000) Subject: added new status messages X-Git-Tag: gpgme-1.2.0@1385~1308 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7af04dfdef63337454dec8ca59ef653068d96051;p=gpgme.git added new status messages --- diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index 5437ad5..e4794d9 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/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/trunk/gpgme/encrypt.c b/trunk/gpgme/encrypt.c index 00531a0..3dc7eb0 100644 --- a/trunk/gpgme/encrypt.c +++ b/trunk/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/trunk/gpgme/rungpg.h b/trunk/gpgme/rungpg.h index 3c2da5d..6c6fc32 100644 --- a/trunk/gpgme/rungpg.h +++ b/trunk/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/trunk/gpgme/verify.c b/trunk/gpgme/verify.c index 3b2174b..ededc58 100644 --- a/trunk/gpgme/verify.c +++ b/trunk/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: