aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-05-07 06:10:24 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-05-07 06:10:24 +0800
commit04576b92e0a2d2c2a8ceb83e78cf80eefff06e53 (patch)
tree2a9898566a43ad9cba43a79203aab86a9834f3c9 /camel
parent287b864f7f4ae03249ad61609ad8b0b862e383a0 (diff)
downloadgsoc2013-evolution-04576b92e0a2d2c2a8ceb83e78cf80eefff06e53.tar.gz
gsoc2013-evolution-04576b92e0a2d2c2a8ceb83e78cf80eefff06e53.tar.zst
gsoc2013-evolution-04576b92e0a2d2c2a8ceb83e78cf80eefff06e53.zip
Use CamelMimeFilterBestenc to get a more appropriate encoding rather than
2002-05-06 Jeffrey Stedfast <fejj@ximian.com> * camel-pgp-mime.c (pgp_mime_part_sign_prepare_part): Use CamelMimeFilterBestenc to get a more appropriate encoding rather than just blindling assigning QP. svn path=/trunk/; revision=16699
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog4
-rw-r--r--camel/camel-pgp-mime.c36
2 files changed, 33 insertions, 7 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 1d31a6ce16..a5192f8110 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,9 @@
2002-05-06 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-pgp-mime.c (pgp_mime_part_sign_prepare_part): Use
+ CamelMimeFilterBestenc to get a more appropriate encoding rather
+ than just blindling assigning QP.
+
* providers/imap/camel-imap-folder.c (do_append): Call
camel_mime_message_encode_8bit_parts() which fixes bug #10885.
diff --git a/camel/camel-pgp-mime.c b/camel/camel-pgp-mime.c
index 47458803a5..b16232c085 100644
--- a/camel/camel-pgp-mime.c
+++ b/camel/camel-pgp-mime.c
@@ -28,10 +28,12 @@
#include "camel-pgp-mime.h"
#include "camel-mime-message.h"
#include "camel-mime-filter-from.h"
+#include "camel-mime-filter-bestenc.h"
#include "camel-mime-filter-crlf.h"
#include "camel-mime-filter-charset.h"
#include "camel-mime-filter-chomp.h"
#include "camel-stream-filter.h"
+#include "camel-stream-null.h"
#include "camel-stream-mem.h"
#include "camel-stream-fs.h"
@@ -197,7 +199,10 @@ pgp_mime_part_sign_prepare_part (CamelMimePart *mime_part, GSList **encodings)
pgp_mime_part_sign_prepare_part (part, encodings);
}
} else {
- CamelMimePartEncodingType encoding;
+ CamelMimePartEncodingType encoding, best;
+ CamelStream *stream, *filtered_stream;
+ CamelMimeFilterBestenc *bestenc;
+ guint32 flags;
if (CAMEL_IS_MIME_MESSAGE (wrapper)) {
/* prepare the message parts' subparts */
@@ -205,12 +210,29 @@ pgp_mime_part_sign_prepare_part (CamelMimePart *mime_part, GSList **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));
+ if (encoding != CAMEL_MIME_PART_ENCODING_BASE64) {
+ flags = CAMEL_BESTENC_GET_ENCODING;
+
+ stream = camel_stream_null_new ();
+ filtered_stream = (CamelStream *) camel_stream_filter_new_with_stream (stream);
+ camel_object_unref (CAMEL_OBJECT (stream));
+ bestenc = camel_mime_filter_bestenc_new (flags);
+ camel_stream_filter_add (CAMEL_STREAM_FILTER (filtered_stream),
+ CAMEL_MIME_FILTER (bestenc));
+
+ camel_data_wrapper_write_to_stream (wrapper, filtered_stream);
+
+ best = camel_mime_filter_bestenc_get_best_encoding (bestenc, CAMEL_BESTENC_7BIT);
+
+ camel_object_unref (CAMEL_OBJECT (filtered_stream));
+ camel_object_unref (CAMEL_OBJECT (bestenc));
+
+ if (encoding != best) {
+ camel_mime_part_set_encoding (mime_part, best);
+
+ *encodings = g_slist_append (*encodings, GINT_TO_POINTER (encoding));
+ }
+ }
}
}
}