From a036c22b744939540ce776e76826f215cf7d81a2 Mon Sep 17 00:00:00 2001
From: Jeffrey Stedfast <fejj@src.gnome.org>
Date: Wed, 29 Aug 2001 21:29:52 +0000
Subject: fix smime the same way...

svn path=/trunk/; revision=12520
---
 camel/ChangeLog             |  8 ++++++++
 camel/camel-smime-context.c | 41 ++++++++++++++++++++++++++---------------
 2 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/camel/ChangeLog b/camel/ChangeLog
index db3676d077..83abccbe9e 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,11 @@
 2001-08-29  Jeffrey Stedfast  <fejj@ximian.com>
 
+	* camel-smime-context.c (smime_sign_prepare): Do the same here as
+	what we did in the pgp code a moment ago.
+	(smime_sign_restore): And again here.
+	(smime_sign): And update thise code to pass in the address of the
+	encodings list when restoring parts.
+
 	* camel-pgp-mime.c (pgp_mime_part_sign_prepare_part): Special-case
 	message/rfc822 mime parts - don't set an encoding on these,
 	instead traverse into their subparts and set the encodings for
@@ -8,6 +14,8 @@
 	message/rfc822 parts in the above prepare_part() function and also
 	take a pointer to a GSList of encodings instead of just a GSList
 	so we can properly keep track of which encoding we are on.
+	(camel_pgp_mime_part_sign): Pass in the address to the encodings
+	list when restoring parts.
 
 2001-08-29  Not Zed  <NotZed@Ximian.com>
 
diff --git a/camel/camel-smime-context.c b/camel/camel-smime-context.c
index 8f944841fe..46ecf5c3a7 100644
--- a/camel/camel-smime-context.c
+++ b/camel/camel-smime-context.c
@@ -272,7 +272,7 @@ signed_data (CamelSMimeContext *ctx, const char *userid, gboolean signing_time,
 }
 
 static void
-smime_sign_restore (CamelMimePart *mime_part, GSList *encodings)
+smime_sign_restore (CamelMimePart *mime_part, GSList **encodings)
 {
 	CamelDataWrapper *wrapper;
 	
@@ -288,14 +288,19 @@ smime_sign_restore (CamelMimePart *mime_part, GSList *encodings)
 			CamelMimePart *part = camel_multipart_get_part (CAMEL_MULTIPART (wrapper), i);
 			
 			smime_sign_restore (part, encodings);
-			encodings = encodings->next;
+			*encodings = (*encodings)->next;
 		}
 	} else {
 		CamelMimePartEncodingType encoding;
 		
-		encoding = GPOINTER_TO_INT (encodings->data);
-		
-		camel_mime_part_set_encoding (mime_part, encoding);
+		if (CAMEL_IS_MIME_MESSAGE (wrapper)) {
+			/* restore the message parts' subparts */
+			smime_sign_restore (CAMEL_MIME_PART (wrapper), encodings);
+		} else {
+			encoding = GPOINTER_TO_INT ((*encodings)->data);
+			
+			camel_mime_part_set_encoding (mime_part, encoding);
+		}
 	}
 }
 
@@ -319,14 +324,19 @@ smime_sign_prepare (CamelMimePart *mime_part, GSList **encodings)
 	} else {
 		CamelMimePartEncodingType encoding;
 		
-		encoding = camel_mime_part_get_encoding (mime_part);
-		
-		/* FIXME: find the best encoding for this part and use that instead?? */
-		/* the encoding should really be QP or Base64 */
-		if (encoding != CAMEL_MIME_PART_ENCODING_BASE64)
-			camel_mime_part_set_encoding (mime_part, CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE);
-		
-		*encodings = g_slist_append (*encodings, GINT_TO_POINTER (encoding));
+		if (CAMEL_IS_MIME_MESSAGE (wrapper)) {
+			/* prepare the message parts' subparts */
+			smime_sign_prepare (CAMEL_MIME_PART (wrapper), encodings);
+		} else {
+			encoding = camel_mime_part_get_encoding (mime_part);
+			
+			/* FIXME: find the best encoding for this part and use that instead?? */
+			/* the encoding should really be QP or Base64 */
+			if (encoding != CAMEL_MIME_PART_ENCODING_BASE64)
+				camel_mime_part_set_encoding (mime_part, CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE);
+			
+			*encodings = g_slist_append (*encodings, GINT_TO_POINTER (encoding));
+		}
 	}
 }
 
@@ -343,7 +353,7 @@ smime_sign (CamelCMSContext *ctx, CamelMimeMessage *message,
 	NSSCMSEncoderContext *ecx;
 	SECItem output = { 0, 0, 0 };
 	CamelStream *stream;
-	GSList *encodings = NULL;
+	GSList *list, *encodings = NULL;
 	GByteArray *buf;
 	
 	cmsg = signed_data (CAMEL_SMIME_CONTEXT (ctx), userid, signing_time, detached, ex);
@@ -363,7 +373,8 @@ smime_sign (CamelCMSContext *ctx, CamelMimeMessage *message,
 	
 	smime_sign_prepare (CAMEL_MIME_PART (message), &encodings);
 	camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), stream);
-	smime_sign_restore (CAMEL_MIME_PART (message), encodings);
+	list = encodings;
+	smime_sign_restore (CAMEL_MIME_PART (message), &list);
 	g_slist_free (encodings);
 	
 	buf = CAMEL_STREAM_MEM (stream)->buffer;
-- 
cgit