diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-02-27 03:56:58 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-02-27 03:56:58 +0800 |
commit | a596227e1c1b3225751a276e9efab60e9eea4110 (patch) | |
tree | ca810c809d303abf0c4d94d37b888b51124a07a3 /camel/camel-mime-message.c | |
parent | 43f2a52819c061bd0df80388d3877df508590485 (diff) | |
download | gsoc2013-evolution-a596227e1c1b3225751a276e9efab60e9eea4110.tar gsoc2013-evolution-a596227e1c1b3225751a276e9efab60e9eea4110.tar.gz gsoc2013-evolution-a596227e1c1b3225751a276e9efab60e9eea4110.tar.bz2 gsoc2013-evolution-a596227e1c1b3225751a276e9efab60e9eea4110.tar.lz gsoc2013-evolution-a596227e1c1b3225751a276e9efab60e9eea4110.tar.xz gsoc2013-evolution-a596227e1c1b3225751a276e9efab60e9eea4110.tar.zst gsoc2013-evolution-a596227e1c1b3225751a276e9efab60e9eea4110.zip |
Made thread-safe and moved to above the test code.
2001-02-26 Jeffrey Stedfast <fejj@ximian.com>
* camel-mime-utils.c: Made thread-safe and moved to above the test
code.
* camel-mime-message.c (camel_mime_message_init): Set the
message_id to NULL.
(camel_mime_message_finalize): Free the message_id.
(camel_mime_message_set_message_id): New function to set the
Message-Id.
(camel_mime_message_get_message_id): New function to get the
Message-Id.
(process_header): Decode the message-id.
svn path=/trunk/; revision=8393
Diffstat (limited to 'camel/camel-mime-message.c')
-rw-r--r-- | camel/camel-mime-message.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c index 40199eac21..9e0fb7de11 100644 --- a/camel/camel-mime-message.c +++ b/camel/camel-mime-message.c @@ -51,12 +51,13 @@ typedef enum { HEADER_TO, HEADER_CC, HEADER_BCC, - HEADER_DATE + HEADER_DATE, + HEADER_MESSAGE_ID } CamelHeaderType; static char *header_names[] = { /* dont include HEADER_UNKNOWN string */ - "From", "Reply-To", "Subject", "To", "Cc", "Bcc", "Date", NULL + "From", "Reply-To", "Subject", "To", "Cc", "Bcc", "Date", "Message-Id", NULL }; static GHashTable *header_name_table; @@ -124,6 +125,7 @@ camel_mime_message_init (gpointer object, gpointer klass) mime_message->date_offset = 0; mime_message->date_received = CAMEL_MESSAGE_DATE_CURRENT; mime_message->date_received_offset = 0; + mime_message->message_id = NULL; } static void @@ -133,6 +135,8 @@ camel_mime_message_finalize (CamelObject *object) g_free(message->subject); + g_free(message->message_id); + if (message->reply_to) camel_object_unref((CamelObject *)message->reply_to); @@ -235,6 +239,37 @@ camel_mime_message_get_date_received(CamelMimeMessage *msg, int *offset) return msg->date_received; } +/* **** Message-Id: */ + +void +camel_mime_message_set_message_id (CamelMimeMessage *mime_message, const char *message_id) +{ + char *id; + + g_assert (mime_message); + + g_free (mime_message->message_id); + + if (message_id) { + id = g_strstrip (g_strdup (message_id)); + } else { + id = header_msgid_generate (); + } + + mime_message->message_id = id; + id = g_strdup_printf ("<%s>", mime_message->message_id); + CAMEL_MEDIUM_CLASS (parent_class)->set_header (CAMEL_MEDIUM (mime_message), "Message-Id", id); + g_free (id); +} + +const char * +camel_mime_message_get_message_id (CamelMimeMessage *mime_message) +{ + g_assert (mime_message); + + return mime_message->message_id; +} + /* **** Reply-To: */ void @@ -429,6 +464,10 @@ write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) g_warning("Application did not set subject, creating one"); camel_mime_message_set_subject(mm, "No Subject"); } + if (mm->message_id == NULL) { + g_warning ("Application did not set message-id, creating one"); + camel_mime_message_set_message_id (mm, NULL); + } /* FIXME: "To" header needs to be set explicitly as well ... */ @@ -481,6 +520,13 @@ process_header (CamelMedium *medium, const char *header_name, const char *header message->date_offset = 0; } break; + case HEADER_MESSAGE_ID: + g_free (message->message_id); + if (header_value) + message->message_id = header_msgid_decode (header_value); + else + message->message_id = NULL; + break; default: return FALSE; } |