[evolution-data-server] Bug #386468 - gpg encrypted message not shown



commit eaaf8ddc06adb7d8bc48db40295e93c124bdd3a2
Author: Milan Crha <mcrha redhat com>
Date:   Fri Oct 16 10:35:58 2009 +0200

    Bug #386468 - gpg encrypted message not shown

 camel/camel-gpg-context.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c
index ccdcf5d..e254c29 100644
--- a/camel/camel-gpg-context.c
+++ b/camel/camel-gpg-context.c
@@ -64,6 +64,7 @@
 #include "camel-stream-filter.h"
 #include "camel-stream-fs.h"
 #include "camel-stream-mem.h"
+#include "camel-stream-null.h"
 
 #define d(x)
 
@@ -1111,7 +1112,8 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex)
 			goto exception;
 
 		if (nread > 0) {
-			if (camel_stream_write (gpg->ostream, buffer, (gsize) nread) == -1)
+			gsize written = camel_stream_write (gpg->ostream, buffer, (gsize) nread);
+			if (written != nread)
 				goto exception;
 		} else {
 			gpg->seen_eof1 = TRUE;
@@ -1798,8 +1800,21 @@ gpg_decrypt(CamelCipherContext *context, CamelMimePart *ipart, CamelMimePart *op
 
 	camel_stream_reset(ostream);
 	if (camel_content_type_is(ct, "multipart", "encrypted")) {
+		CamelDataWrapper *dw;
+		CamelStream *null = camel_stream_null_new ();
+
 		/* Multipart encrypted - parse a full mime part */
-		rv = camel_data_wrapper_construct_from_stream((CamelDataWrapper *)opart, ostream);
+		rv = camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)opart, ostream);
+
+		dw = camel_medium_get_content_object ((CamelMedium *)opart);
+		if (!camel_data_wrapper_decode_to_stream (dw, null)) {
+			/* nothing had been decoded from the stream, it doesn't
+			   contain any header, like Content-Type or such, thus
+			   write it as a message body */
+			rv = camel_data_wrapper_construct_from_stream (dw, ostream);
+		}
+
+		camel_object_unref (null);
 	} else {
 		/* Inline signed - raw data (may not be a mime part) */
 		CamelDataWrapper *dw;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]