diff options
author | Not Zed <NotZed@Ximian.com> | 2004-03-15 16:32:08 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-03-15 16:32:08 +0800 |
commit | 1043413b4066785b4ee0ba8c38a71c3567e89b8d (patch) | |
tree | 33dd9e68cbc55b4496e719c8665f022feaaa6844 /camel | |
parent | f2a8b1d3388127f9040b17137273a27333361235 (diff) | |
download | gsoc2013-evolution-1043413b4066785b4ee0ba8c38a71c3567e89b8d.tar gsoc2013-evolution-1043413b4066785b4ee0ba8c38a71c3567e89b8d.tar.gz gsoc2013-evolution-1043413b4066785b4ee0ba8c38a71c3567e89b8d.tar.bz2 gsoc2013-evolution-1043413b4066785b4ee0ba8c38a71c3567e89b8d.tar.lz gsoc2013-evolution-1043413b4066785b4ee0ba8c38a71c3567e89b8d.tar.xz gsoc2013-evolution-1043413b4066785b4ee0ba8c38a71c3567e89b8d.tar.zst gsoc2013-evolution-1043413b4066785b4ee0ba8c38a71c3567e89b8d.zip |
set the mime-type field on the content the same way as
2004-03-15 Not Zed <NotZed@Ximian.com>
* providers/imap/camel-imap-folder.c (get_content, get_message):
set the mime-type field on the content the same way as
construct_from_stream does. Bug #55472.
* camel-mime-message.c (camel_mime_message_dump): utility function
to dump message content to stdout.
(camel_mime_message_init): default mime type to message/rfc822.
* camel.c (camel_init): change camel verbose debug to be an int, a
bitmask of debug options.
svn path=/trunk/; revision=25064
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 11 | ||||
-rw-r--r-- | camel/camel-folder.c | 8 | ||||
-rw-r--r-- | camel/camel-mime-message.c | 61 | ||||
-rw-r--r-- | camel/camel-mime-message.h | 2 | ||||
-rw-r--r-- | camel/camel-mime-part.c | 2 | ||||
-rw-r--r-- | camel/camel.c | 4 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-folder.c | 13 |
7 files changed, 92 insertions, 9 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 0d284bc912..66a11c947d 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,5 +1,16 @@ 2004-03-15 Not Zed <NotZed@Ximian.com> + * providers/imap/camel-imap-folder.c (get_content, get_message): + set the mime-type field on the content the same way as + construct_from_stream does. Bug #55472. + + * camel-mime-message.c (camel_mime_message_dump): utility function + to dump message content to stdout. + (camel_mime_message_init): default mime type to message/rfc822. + + * camel.c (camel_init): change camel verbose debug to be an int, a + bitmask of debug options. + * camel-mime-utils.c (camel_header_location_decode): drop embedded whitespace characters, and don't do unquoting, etc. See rfc2557 4.4.2 and rfc2017 3.1. diff --git a/camel/camel-folder.c b/camel/camel-folder.c index bf9bd13763..5e971667c4 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -46,6 +46,8 @@ #define d(x) #define w(x) +extern int camel_verbose_debug; + static CamelObjectClass *parent_class = NULL; /* Returns the class for a CamelFolder */ @@ -1015,6 +1017,12 @@ camel_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException CAMEL_FOLDER_UNLOCK(folder, lock); + /* FIXME: need a better verbose debug framework */ + if (ret && (camel_verbose_debug & 2)) { + printf("CamelFolder:get_message('%s', '%s') =\n", folder->full_name, uid); + camel_mime_message_dump(ret, FALSE); + } + return ret; } diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c index bc2a418af5..16b58d991a 100644 --- a/camel/camel-mime-message.c +++ b/camel/camel-mime-message.c @@ -49,6 +49,8 @@ #define d(x) +extern int camel_verbose_debug; + /* these 2 below should be kept in sync */ typedef enum { HEADER_UNKNOWN, @@ -112,11 +114,10 @@ camel_mime_message_class_init (CamelMimeMessageClass *camel_mime_message_class) camel_medium_class->add_header = add_header; camel_medium_class->set_header = set_header; camel_medium_class->remove_header = remove_header; - + camel_mime_part_class->construct_from_parser = construct_from_parser; } - static void camel_mime_message_init (gpointer object, gpointer klass) { @@ -128,6 +129,10 @@ camel_mime_message_init (gpointer object, gpointer klass) g_hash_table_insert(mime_message->recipients, recipient_names[i], camel_internet_address_new()); } + if (((CamelDataWrapper *)mime_message)->mime_type) + camel_content_type_unref(((CamelDataWrapper *)mime_message)->mime_type); + ((CamelDataWrapper *)mime_message)->mime_type = camel_content_type_new("message", "rfc822"); + mime_message->subject = NULL; mime_message->reply_to = NULL; mime_message->from = NULL; @@ -157,7 +162,6 @@ camel_mime_message_finalize (CamelObject *object) g_hash_table_destroy (message->recipients); } - CamelType camel_mime_message_get_type (void) { @@ -961,3 +965,54 @@ camel_mime_message_build_mbox_from (CamelMimeMessage *message) return ret; } + +static void +cmm_dump_rec(CamelMimeMessage *msg, CamelMimePart *part, int body, int depth) +{ + CamelDataWrapper *containee; + int parts, i; + int go = TRUE; + char *s; + + s = alloca(depth+1); + memset(s, ' ', depth); + s[depth] = 0; + /* yes this leaks, so what its only debug stuff */ + printf("%sclass: %s\n", s, ((CamelObject *)part)->klass->name); + printf("%smime-type: %s\n", s, camel_content_type_format(((CamelDataWrapper *)part)->mime_type)); + + containee = camel_medium_get_content_object((CamelMedium *)part); + + if (containee == NULL) + return; + + printf("%scontent class: %s\n", s, ((CamelObject *)containee)->klass->name); + printf("%scontent mime-type: %s\n", s, camel_content_type_format(((CamelDataWrapper *)containee)->mime_type)); + + /* using the object types is more accurate than using the mime/types */ + if (CAMEL_IS_MULTIPART(containee)) { + parts = camel_multipart_get_number((CamelMultipart *)containee); + for (i = 0; go && i < parts; i++) { + CamelMimePart *part = camel_multipart_get_part((CamelMultipart *)containee, i); + + cmm_dump_rec(msg, part, body, depth+2); + } + } else if (CAMEL_IS_MIME_MESSAGE(containee)) { + cmm_dump_rec(msg, (CamelMimePart *)containee, body, depth+2); + } +} + +/** + * camel_mime_message_dump: + * @msg: + * @body: + * + * Dump information about the mime message to stdout. + * + * If body is TRUE, then dump body content of the message as well (currently unimplemented). + **/ +void +camel_mime_message_dump(CamelMimeMessage *msg, int body) +{ + cmm_dump_rec(msg, (CamelMimePart *)msg, body, 0); +} diff --git a/camel/camel-mime-message.h b/camel/camel-mime-message.h index c1149d5ef5..d420c48676 100644 --- a/camel/camel-mime-message.h +++ b/camel/camel-mime-message.h @@ -133,6 +133,8 @@ CamelMimePart *camel_mime_message_get_part_by_content_id (CamelMime char *camel_mime_message_build_mbox_from (CamelMimeMessage *mime_message); +void camel_mime_message_dump(CamelMimeMessage *msg, int body); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c index e48ea4adc9..b87beca370 100644 --- a/camel/camel-mime-part.c +++ b/camel/camel-mime-part.c @@ -469,6 +469,7 @@ camel_mime_part_get_content_MD5 (CamelMimePart *mime_part) void camel_mime_part_set_content_location (CamelMimePart *mime_part, const char *location) { + /* FIXME: this should perform content-location folding */ camel_medium_set_header (CAMEL_MEDIUM (mime_part), "Content-Location", location); } @@ -534,7 +535,6 @@ camel_mime_part_get_content_type (CamelMimePart *mime_part) return ((CamelDataWrapper *) mime_part)->mime_type; } - static void set_content_object (CamelMedium *medium, CamelDataWrapper *content) { diff --git a/camel/camel.c b/camel/camel.c index e926203732..8241b5b0ac 100644 --- a/camel/camel.c +++ b/camel/camel.c @@ -40,7 +40,7 @@ #include "camel-mime-utils.h" #include "camel-provider.h" -gboolean camel_verbose_debug = FALSE; +int camel_verbose_debug = 0; static int initialised = FALSE; @@ -78,7 +78,7 @@ camel_init (const char *configdir, gboolean nss_init) return 0; if (getenv ("CAMEL_VERBOSE_DEBUG")) - camel_verbose_debug = TRUE; + camel_verbose_debug = atoi(getenv("CAMEL_VERBOSE_DEBUG")); /* initialise global camel_object_type */ camel_object_get_type(); diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index c0f49e7194..0835534ea1 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -1745,7 +1745,9 @@ get_content (CamelImapFolder *imap_folder, const char *uid, char *part_spec; part_spec = content_info_get_part_spec (ci); - + + d(printf("get content '%s' '%s'\n", part_spec, camel_content_type_format(ci->type))); + /* There are three cases: multipart/signed, multipart, message/rfc822, and "other" */ if (camel_content_type_is (ci->type, "multipart", "signed")) { CamelMultipartSigned *body_mp; @@ -1826,8 +1828,10 @@ get_content (CamelImapFolder *imap_folder, const char *uid, return NULL; } + camel_data_wrapper_set_mime_type_field(content, camel_mime_part_get_content_type(part)); camel_medium_set_content_object (CAMEL_MEDIUM (part), content); camel_object_unref (CAMEL_OBJECT (content)); + camel_multipart_add_part (body_mp, part); camel_object_unref (CAMEL_OBJECT (part)); @@ -1869,7 +1873,9 @@ get_message (CamelImapFolder *imap_folder, const char *uid, g_free (section_text); if (!stream) return NULL; - + + d(printf("get message '%s'\n", part_spec)); + msg = camel_mime_message_new (); ret = camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream); camel_object_unref (CAMEL_OBJECT (stream)); @@ -1883,7 +1889,8 @@ get_message (CamelImapFolder *imap_folder, const char *uid, camel_object_unref (CAMEL_OBJECT (msg)); return NULL; } - + + camel_data_wrapper_set_mime_type_field(content, camel_mime_part_get_content_type((CamelMimePart *)msg)); camel_medium_set_content_object (CAMEL_MEDIUM (msg), content); camel_object_unref (CAMEL_OBJECT (content)); |