aboutsummaryrefslogtreecommitdiffstats
path: root/composer/e-msg-composer.c
diff options
context:
space:
mode:
authorLarry Ewing <lewing@helixcode.com>2000-11-07 04:52:22 +0800
committerLarry Ewing <lewing@src.gnome.org>2000-11-07 04:52:22 +0800
commitd6b8654b225b160faf6cf6002186d1c9d2839c3f (patch)
tree6befdaafa8ed18d1250af28a20b9947ab56d3492 /composer/e-msg-composer.c
parentd39b0dfc09e9be5866a078c66ad5903a3b5b1e15 (diff)
downloadgsoc2013-evolution-d6b8654b225b160faf6cf6002186d1c9d2839c3f.tar.gz
gsoc2013-evolution-d6b8654b225b160faf6cf6002186d1c9d2839c3f.tar.zst
gsoc2013-evolution-d6b8654b225b160faf6cf6002186d1c9d2839c3f.zip
set the content type on the plain part of outgoing messages.
2000-11-06 Larry Ewing <lewing@helixcode.com> * e-msg-composer.c (build_message): set the content type on the plain part of outgoing messages. (best_content): a helper function to get the best content type for the attachment. This should probably use the helper functions in the future. svn path=/trunk/; revision=6423
Diffstat (limited to 'composer/e-msg-composer.c')
-rw-r--r--composer/e-msg-composer.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 6fd10d578c..456b8a54f9 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -43,6 +43,7 @@
#include <gtkhtml/gtkhtml.h>
#include "camel/camel.h"
+#include "camel-charset-map.h"
#include "mail/mail.h"
#include "mail/mail-tools.h"
@@ -150,6 +151,21 @@ best_encoding (const guchar *text)
return CAMEL_MIME_PART_ENCODING_BASE64;
}
+static char *
+best_content (gchar *plain)
+{
+ char *result;
+ const char *best;
+
+ if ((best = camel_charset_best (plain, strlen (plain)))) {
+ result = g_strdup_printf ("text/plain ; charset=%s", best);
+ } else {
+ result = g_strdup ("text/plain");
+ }
+
+ return result;
+}
+
/* This functions builds a CamelMimeMessage for the message that the user has
composed in `composer'. */
static CamelMimeMessage *
@@ -164,8 +180,10 @@ build_message (EMsgComposer *composer)
gchar *from = NULL;
gboolean e8bit;
char *html = NULL, *plain = NULL;
+ char *content_type = NULL;
int i;
+
if (composer->persist_stream_interface == CORBA_OBJECT_NIL)
return NULL;
@@ -205,13 +223,15 @@ build_message (EMsgComposer *composer)
return NULL;
e8bit = is_8bit (plain);
-
+ content_type = best_content (plain);
+
if (type != MSG_FORMAT_PLAIN) {
html = get_text (composer->persist_stream_interface, "text/html");
/* the component has probably died */
if (html == NULL) {
g_free (plain);
+ g_free (content_type);
return NULL;
}
}
@@ -223,11 +243,14 @@ build_message (EMsgComposer *composer)
camel_multipart_set_boundary (body, NULL);
part = camel_mime_part_new ();
- camel_mime_part_set_content (part, plain, strlen (plain), "text/plain");
+
+ camel_mime_part_set_content (part, plain, strlen (plain), content_type);
+
if (e8bit)
- camel_mime_part_set_encoding (part, best_encoding (plain));
-
+ camel_mime_part_set_encoding (part, best_encoding (plain));
+
g_free (plain);
+ g_free (content_type);
camel_multipart_add_part (body, part);
camel_object_unref (CAMEL_OBJECT (part));
@@ -252,10 +275,13 @@ build_message (EMsgComposer *composer)
camel_object_unref (CAMEL_OBJECT (body));
break;
case MSG_FORMAT_PLAIN:
- camel_mime_part_set_content (part, plain, strlen (plain), "text/plain");
+ camel_mime_part_set_content (part, plain, strlen (plain), best_content (plain));
+
if (e8bit)
camel_mime_part_set_encoding (part, best_encoding (plain));
+
g_free (plain);
+ g_free (content_type);
break;
}
camel_multipart_add_part (multipart, part);
@@ -271,11 +297,15 @@ build_message (EMsgComposer *composer)
camel_medium_set_content_object (CAMEL_MEDIUM (new), CAMEL_DATA_WRAPPER (body));
camel_object_unref (CAMEL_OBJECT (body));
break;
+
case MSG_FORMAT_PLAIN:
- camel_mime_part_set_content (CAMEL_MIME_PART (new), plain, strlen (plain), "text/plain");
+ camel_mime_part_set_content (CAMEL_MIME_PART (new), plain, strlen (plain), best_content (plain));
+
if (e8bit)
camel_mime_part_set_encoding (CAMEL_MIME_PART (new), best_encoding (plain));
+
g_free (plain);
+ g_free (content_type);
break;
}
}