diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-04-17 01:02:10 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-04-17 01:02:10 +0800 |
commit | 76e859fb6b176fea6b5c6b96516fa3cd54e155ac (patch) | |
tree | dcab43dda4c0932104a2e9c5613022e66c3907b4 /camel/camel-gpg-context.c | |
parent | 3c0ee2d3df563f09948351c9306c7bb7e8813f02 (diff) | |
download | gsoc2013-evolution-76e859fb6b176fea6b5c6b96516fa3cd54e155ac.tar.gz gsoc2013-evolution-76e859fb6b176fea6b5c6b96516fa3cd54e155ac.tar.zst gsoc2013-evolution-76e859fb6b176fea6b5c6b96516fa3cd54e155ac.zip |
The gpg child process exiting does not necessarily mean that we've ready
2003-04-15 Jeffrey Stedfast <fejj@ximian.com>
* camel-gpg-context.c (gpg_verify): The gpg child process exiting
does not necessarily mean that we've ready everything that we can
from its pipes, so don't use gpg_ctx_op_exited() as a loop-exit
condition. If for some reason the gpg child process does exit (due
to an error), gpg_ctx_op_step() will eventually fail (as soon as
it has finished reading any data in the pipes) and cause the loop
to be terminated anyway. This fixes truncation of the gpg --verify
stderr output that Evolution displays as the "validity report"
(for lack of a better description).
(gpg_ctx_op_step): Removed some debugging printf's
(gpg_ctx_get_diagnostics): Use a bitfield to decide if we've
already flushed the diagnostics stream, much simpler (plus we have
plenty of bits to spare so might as well use them).
(gpg_ctx_new): Fixed another logic bug which determined whether or
not we should convert the gpg output from the locale charset into
UTF-8.
svn path=/trunk/; revision=20865
Diffstat (limited to 'camel/camel-gpg-context.c')
-rw-r--r-- | camel/camel-gpg-context.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c index 7919056f9e..0483e8a16b 100644 --- a/camel/camel-gpg-context.c +++ b/camel/camel-gpg-context.c @@ -282,7 +282,9 @@ struct _GpgCtx { unsigned int validsig:1; unsigned int trust:3; - unsigned int padding:18; + unsigned int diagflushed:1; + + unsigned int padding:17; }; static struct _GpgCtx * @@ -334,8 +336,9 @@ gpg_ctx_new (CamelSession *session) stream = camel_stream_mem_new (); gpg->diagbuf = CAMEL_STREAM_MEM (stream)->buffer; + gpg->diagflushed = FALSE; - if ((charset = e_iconv_locale_charset ()) && !strcasecmp (charset, "UTF-8")) { + if ((charset = e_iconv_locale_charset ()) && strcasecmp (charset, "UTF-8") != 0) { CamelMimeFilterCharset *filter; CamelStreamFilter *fstream; @@ -426,7 +429,8 @@ gpg_ctx_set_ostream (struct _GpgCtx *gpg, CamelStream *ostream) static const char * gpg_ctx_get_diagnostics (struct _GpgCtx *gpg) { - if (!gpg->diagbuf->len || gpg->diagbuf->data[gpg->diagbuf->len - 1] != '\0') { + if (!gpg->diagflushed) { + gpg->diagflushed = TRUE; camel_stream_flush (gpg->diagnostics); if (gpg->diagbuf->len == 0) return NULL; @@ -1063,9 +1067,7 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex) goto exception; if (nread > 0) { - printf ("pre-diag: %.*s\n", nread, buffer); camel_stream_write (gpg->diagnostics, buffer, nread); - printf ("post-diag: %.*s\n", gpg->diagbuf->len, gpg->diagbuf->data); } else { gpg->seen_eof2 = TRUE; } @@ -1390,7 +1392,7 @@ gpg_verify (CamelCipherContext *context, CamelCipherHash hash, goto exception; } - while (!gpg_ctx_op_complete (gpg) && !gpg_ctx_op_exited (gpg)) { + while (!gpg_ctx_op_complete (gpg)) { if (camel_operation_cancel_check (NULL)) { camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled.")); |