aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-12-29 03:29:33 +0800
committerDan Winship <danw@src.gnome.org>2000-12-29 03:29:33 +0800
commit847506be0e0ed8dd9ee0613ede2fbc9adf50c1a5 (patch)
tree93ca38ccdc8a246071660a0d3538fa66d65fd1ac
parent87d3886d23295d8dc8ce02a717696af927d8833a (diff)
downloadgsoc2013-evolution-847506be0e0ed8dd9ee0613ede2fbc9adf50c1a5.tar
gsoc2013-evolution-847506be0e0ed8dd9ee0613ede2fbc9adf50c1a5.tar.gz
gsoc2013-evolution-847506be0e0ed8dd9ee0613ede2fbc9adf50c1a5.tar.bz2
gsoc2013-evolution-847506be0e0ed8dd9ee0613ede2fbc9adf50c1a5.tar.lz
gsoc2013-evolution-847506be0e0ed8dd9ee0613ede2fbc9adf50c1a5.tar.xz
gsoc2013-evolution-847506be0e0ed8dd9ee0613ede2fbc9adf50c1a5.tar.zst
gsoc2013-evolution-847506be0e0ed8dd9ee0613ede2fbc9adf50c1a5.zip
Use CamelContentType, and use header_content_type_is instead of doing it
* mail-format.c (mail_part_is_inline, mail_get_message_body): Use CamelContentType, and use header_content_type_is instead of doing it by hand. (handle_text_plain): (handle_multipart_related): (find_preferred_alternative): (handle_message_external_body): Use CamelContentType and header_content_type_* functions instead of GMimeContentField. * mail-display.c (write_data_to_file, launch_cb): Use CamelContentType and header_content_type_* functions instead of GMimeContentField. svn path=/trunk/; revision=7189
-rw-r--r--mail/ChangeLog16
-rw-r--r--mail/mail-display.c10
-rw-r--r--mail/mail-format.c50
3 files changed, 45 insertions, 31 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index ec9b1c4028..e3a077a3dc 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,19 @@
+2000-12-28 Dan Winship <danw@helixcode.com>
+
+ * mail-format.c (mail_part_is_inline, mail_get_message_body): Use
+ CamelContentType, and use header_content_type_is instead of doing
+ it by hand.
+
+ (handle_text_plain):
+ (handle_multipart_related):
+ (find_preferred_alternative):
+ (handle_message_external_body): Use CamelContentType and
+ header_content_type_* functions instead of GMimeContentField.
+
+ * mail-display.c (write_data_to_file, launch_cb): Use
+ CamelContentType and header_content_type_* functions instead of
+ GMimeContentField.
+
2000-12-26 Iain Holmes <iain@helixcode.com>
* mail-display.c (mail_display_init): Initialise the thumbnail cache.
diff --git a/mail/mail-display.c b/mail/mail-display.c
index 41a5daad1a..46946bf6ab 100644
--- a/mail/mail-display.c
+++ b/mail/mail-display.c
@@ -60,7 +60,7 @@ static gboolean
write_data_to_file (CamelMimePart *part, const char *name, gboolean unique)
{
CamelMimeFilterCharset *charsetfilter;
- GMimeContentField *content_type;
+ CamelContentType *content_type;
CamelStreamFilter *filtered_stream;
CamelStream *stream_fs;
CamelDataWrapper *data;
@@ -110,8 +110,8 @@ write_data_to_file (CamelMimePart *part, const char *name, gboolean unique)
the same algorithm camel uses */
content_type = camel_mime_part_get_content_type (part);
- if (gmime_content_field_is_type(content_type, "text", "*")
- && (charset = gmime_content_field_get_parameter (content_type, "charset"))
+ if (header_content_type_is(content_type, "text", "*")
+ && (charset = header_content_type_param (content_type, "charset"))
&& strcasecmp(charset, "utf-8") != 0) {
charsetfilter = camel_mime_filter_charset_new_convert ("utf-8", charset);
filtered_stream = camel_stream_filter_new_with_stream (stream_fs);
@@ -245,11 +245,11 @@ launch_cb (GtkWidget *widget, gpointer user_data)
{
CamelMimePart *part = gtk_object_get_data (user_data, "CamelMimePart");
GnomeVFSMimeApplication *app;
- GMimeContentField *content_type;
+ CamelContentType *content_type;
char *mime_type, *tmpl, *tmpdir, *filename, *argv[2];
content_type = camel_mime_part_get_content_type (part);
- mime_type = gmime_content_field_get_mime_type (content_type);
+ mime_type = header_content_type_format (content_type);
app = gnome_vfs_mime_get_default_application (mime_type);
g_free (mime_type);
diff --git a/mail/mail-format.c b/mail/mail-format.c
index 1576c261e4..0cb1fb37ec 100644
--- a/mail/mail-format.c
+++ b/mail/mail-format.c
@@ -460,8 +460,7 @@ gboolean
mail_part_is_inline (CamelMimePart *part)
{
const char *disposition;
- GMimeContentField *content_type;
- const char *mime_type;
+ CamelContentType *content_type;
/* If it has an explicit disposition, return that. */
disposition = camel_mime_part_get_disposition (part);
@@ -472,14 +471,13 @@ mail_part_is_inline (CamelMimePart *part)
* be customizable.
*/
content_type = camel_mime_part_get_content_type (part);
- mime_type = gmime_content_field_get_mime_type (content_type);
- if (!g_strncasecmp (mime_type, "message/", 8))
+ if (!header_content_type_is (content_type, "message", "*"))
return TRUE;
/* Otherwise, display it inline if it's "anonymous", and
* as an attachment otherwise.
*/
- return is_anonymous (part, mime_type);
+ return is_anonymous (part, header_content_type_format (content_type));
}
static void
@@ -692,7 +690,7 @@ handle_text_plain (CamelMimePart *part, const char *mime_type,
CamelDataWrapper *wrapper =
camel_medium_get_content_object (CAMEL_MEDIUM (part));
char *text, *p, *start;
- GMimeContentField *type;
+ CamelContentType *type;
const char *format;
int i;
@@ -702,7 +700,7 @@ handle_text_plain (CamelMimePart *part, const char *mime_type,
/* Check for RFC 2646 flowed text. */
type = camel_mime_part_get_content_type (part);
- format = gmime_content_field_get_parameter (type, "format");
+ format = header_content_type_param (type, "format");
if (format && !g_strcasecmp (format, "flowed"))
return handle_text_plain_flowed (text, md);
@@ -1264,7 +1262,7 @@ handle_multipart_related (CamelMimePart *part, const char *mime_type,
camel_medium_get_content_object (CAMEL_MEDIUM (part));
CamelMultipart *mp;
CamelMimePart *body_part, *display_part = NULL;
- GMimeContentField *content_type;
+ CamelContentType *content_type;
const char *start;
int i, nparts;
@@ -1273,7 +1271,7 @@ handle_multipart_related (CamelMimePart *part, const char *mime_type,
nparts = camel_multipart_get_number (mp);
content_type = camel_mime_part_get_content_type (part);
- start = gmime_content_field_get_parameter (content_type, "start");
+ start = header_content_type_param (content_type, "start");
if (start) {
int len;
@@ -1328,8 +1326,8 @@ find_preferred_alternative (CamelMultipart *multipart, gboolean want_plain)
nparts = camel_multipart_get_number (multipart);
for (i = 0; i < nparts; i++) {
CamelMimePart *part = camel_multipart_get_part (multipart, i);
- char *mime_type = gmime_content_field_get_mime_type (
- camel_mime_part_get_content_type (part));
+ CamelContentType *type = camel_mime_part_get_content_type (part);
+ char *mime_type = header_content_type_format (type);
g_strdown (mime_type);
if (want_plain && !strcmp (mime_type, "text/plain"))
@@ -1402,12 +1400,12 @@ static gboolean
handle_message_external_body (CamelMimePart *part, const char *mime_type,
MailDisplay *md)
{
- GMimeContentField *type;
+ CamelContentType *type;
const char *access_type;
char *url = NULL, *desc = NULL;
type = camel_mime_part_get_content_type (part);
- access_type = gmime_content_field_get_parameter (type, "access-type");
+ access_type = header_content_type_param (type, "access-type");
if (!access_type)
goto fallback;
@@ -1416,12 +1414,12 @@ handle_message_external_body (CamelMimePart *part, const char *mime_type,
const char *name, *site, *dir, *mode, *ftype;
char *path;
- name = gmime_content_field_get_parameter (type, "name");
- site = gmime_content_field_get_parameter (type, "site");
+ name = header_content_type_param (type, "name");
+ site = header_content_type_param (type, "site");
if (name == NULL || site == NULL)
goto fallback;
- dir = gmime_content_field_get_parameter (type, "directory");
- mode = gmime_content_field_get_parameter (type, "mode");
+ dir = header_content_type_param (type, "directory");
+ mode = header_content_type_param (type, "mode");
/* Generate the path. */
if (dir) {
@@ -1451,10 +1449,10 @@ handle_message_external_body (CamelMimePart *part, const char *mime_type,
} else if (!g_strcasecmp (access_type, "local-file")) {
const char *name, *site;
- name = gmime_content_field_get_parameter (type, "name");
+ name = header_content_type_param (type, "name");
if (name == NULL)
goto fallback;
- site = gmime_content_field_get_parameter (type, "site");
+ site = header_content_type_param (type, "site");
url = g_strdup_printf ("file://%s%s", *name == '/' ? "" : "/",
name);
@@ -1472,7 +1470,7 @@ handle_message_external_body (CamelMimePart *part, const char *mime_type,
/* RFC 2017 */
- urlparam = gmime_content_field_get_parameter (type, "url");
+ urlparam = header_content_type_param (type, "url");
if (urlparam == NULL)
goto fallback;
@@ -1534,7 +1532,7 @@ mail_get_message_body (CamelDataWrapper *data, gboolean want_plain, gboolean *is
char *subtext, *old;
const char *boundary;
char *text = NULL;
- GMimeContentField *mime_type;
+ CamelContentType *mime_type;
/* We only include text, message, and multipart bodies. */
mime_type = camel_data_wrapper_get_mime_type_field (data);
@@ -1543,25 +1541,25 @@ mail_get_message_body (CamelDataWrapper *data, gboolean want_plain, gboolean *is
* images. But if we don't do it this way, we don't get
* the headers...
*/
- if (g_strcasecmp (mime_type->type, "message") == 0) {
+ if (header_content_type_is (mime_type, "message", "*")) {
*is_html = FALSE;
return get_data_wrapper_text (data);
}
- if (g_strcasecmp (mime_type->type, "text") == 0) {
- *is_html = !g_strcasecmp (mime_type->subtype, "html");
+ if (header_content_type_is (mime_type, "text", "*")) {
+ *is_html = header_content_type_is (mime_type, "text", "html");
return get_data_wrapper_text (data);
}
/* If it's not message and it's not text, and it's not
* multipart, we don't want to deal with it.
*/
- if (g_strcasecmp (mime_type->type, "multipart") != 0)
+ if (!header_content_type_is (mime_type, "multipart", "*"))
return NULL;
mp = CAMEL_MULTIPART (data);
- if (g_strcasecmp (mime_type->subtype, "alternative") == 0) {
+ if (header_content_type_is (mime_type, "multipart", "alternative")) {
/* Pick our favorite alternative and reply to it. */
subpart = find_preferred_alternative (mp, want_plain);