aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-mime-message.c
diff options
context:
space:
mode:
authorBertrand Guiheneuf <bertrand@src.gnome.org>1999-05-28 05:37:01 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-05-28 05:37:01 +0800
commit69912fc470a36f52887f18cf8c633f34aaa34fb5 (patch)
tree2d464ffaccbd71aad35d80871b76edc383f368db /camel/camel-mime-message.c
parenta8a38c7a8076ca0f7976b01fe2cbd6e1e27a089b (diff)
downloadgsoc2013-evolution-69912fc470a36f52887f18cf8c633f34aaa34fb5.tar
gsoc2013-evolution-69912fc470a36f52887f18cf8c633f34aaa34fb5.tar.gz
gsoc2013-evolution-69912fc470a36f52887f18cf8c633f34aaa34fb5.tar.bz2
gsoc2013-evolution-69912fc470a36f52887f18cf8c633f34aaa34fb5.tar.lz
gsoc2013-evolution-69912fc470a36f52887f18cf8c633f34aaa34fb5.tar.xz
gsoc2013-evolution-69912fc470a36f52887f18cf8c633f34aaa34fb5.tar.zst
gsoc2013-evolution-69912fc470a36f52887f18cf8c633f34aaa34fb5.zip
rewrite message obtained via parsing into a file. Actually, it works
* tests/test2.c (main): rewrite message obtained via parsing into a file. Actually, it works pretty well :)) * camel/camel-mime-message.c (_set_recipient_list_from_string): create recipient list form a comma separated string. (_parse_header_pair): added recipient lists parsing. * camel/camel-mime-part.c (_parse_header_pair): new (protected) method. Parse a head pair and decides what to do with it. (_add_header): Call in _parse_header_pair * camel/camel-mime-message.c (_parse_header_pair): overload header parsing MimePart mthod. * camel/gstring-util.c (g_string_split): new func: split a gstring into a GList of substring. svn path=/trunk/; revision=950
Diffstat (limited to 'camel/camel-mime-message.c')
-rw-r--r--camel/camel-mime-message.c85
1 files changed, 79 insertions, 6 deletions
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c
index 01f9b48e27..2a4a9e8897 100644
--- a/camel/camel-mime-message.c
+++ b/camel/camel-mime-message.c
@@ -30,8 +30,14 @@
typedef enum {
HEADER_UNKNOWN,
- HEADER_FROM
+ HEADER_FROM,
+ HEADER_REPLY_TO,
+ HEADER_SUBJECT,
+ HEADER_TO,
+ HEADER_CC,
+ HEADER_BCC
} CamelHeaderType;
+
static GHashTable *header_name_table;
@@ -77,6 +83,11 @@ _init_header_name_table()
{
header_name_table = g_hash_table_new (g_string_hash, g_string_equal_for_hash);
g_hash_table_insert (header_name_table, g_string_new ("From"), (gpointer)HEADER_FROM);
+ g_hash_table_insert (header_name_table, g_string_new ("Reply-To"), (gpointer)HEADER_REPLY_TO);
+ g_hash_table_insert (header_name_table, g_string_new ("Subject"), (gpointer)HEADER_SUBJECT);
+ g_hash_table_insert (header_name_table, g_string_new ("To"), (gpointer)HEADER_TO);
+ g_hash_table_insert (header_name_table, g_string_new ("Cc"), (gpointer)HEADER_CC);
+ g_hash_table_insert (header_name_table, g_string_new ("Bcc"), (gpointer)HEADER_BCC);
}
@@ -542,28 +553,90 @@ _write_to_file (CamelDataWrapper *data_wrapper, FILE *file)
/*******************************/
/* mime message header parsing */
+static void
+_set_recipient_list_from_string (CamelMimeMessage *message, GString *recipient_type, GString *recipients_string)
+{
+ GList *recipients_list;
+ CAMEL_LOG (FULL_DEBUG,"CamelMimeMessage::_set_recipient_list_from_string parsing ##%s##\n", recipients_string->str);
+ recipients_list = g_string_split (recipients_string, ',');
+ g_hash_table_insert (message->recipients, recipient_type, recipients_list);
+
+}
+
static gboolean
_parse_header_pair (CamelMimePart *mime_part, GString *header_name, GString *header_value)
{
CamelHeaderType header_type;
CamelMimeMessage *message = CAMEL_MIME_MESSAGE (mime_part);
+ gboolean header_handled = FALSE;
header_type = (CamelHeaderType) g_hash_table_lookup (header_name_table, header_name);
switch (header_type) {
case HEADER_FROM:
- camel_log(FULL_DEBUG,
+ CAMEL_LOG (FULL_DEBUG,
"CamelMimeMessage::parse_header_pair found HEADER_FROM : %s\n",
header_value->str );
camel_mime_message_set_from (message, header_value);
- g_string_free (header_name, TRUE);
- return TRUE;
+ header_handled = TRUE;
+ break;
+
+ case HEADER_REPLY_TO:
+ CAMEL_LOG (FULL_DEBUG,
+ "CamelMimeMessage::parse_header_pair found HEADER_REPLY_YO : %s\n",
+ header_value->str );
+
+ camel_mime_message_set_reply_to (message, header_value);
+ header_handled = TRUE;
+ break;
+
+ case HEADER_SUBJECT:
+ CAMEL_LOG (FULL_DEBUG,
+ "CamelMimeMessage::parse_header_pair found HEADER_SUBJECT : %s\n",
+ header_value->str );
+
+ camel_mime_message_set_subject (message, header_value);
+ header_handled = TRUE;
+ break;
+
+ case HEADER_TO:
+ CAMEL_LOG (FULL_DEBUG,
+ "CamelMimeMessage::parse_header_pair found HEADER_TO : %s\n",
+ header_value->str );
+
+ _set_recipient_list_from_string (message, g_string_new ("To"), header_value);
+ g_string_free (header_value, TRUE);
+ header_handled = TRUE;
+ break;
+
+ case HEADER_CC:
+ CAMEL_LOG (FULL_DEBUG,
+ "CamelMimeMessage::parse_header_pair found HEADER_CC : %s\n",
+ header_value->str );
+
+ _set_recipient_list_from_string (message, g_string_new ("Cc"), header_value);
+ g_string_free (header_value, TRUE);
+ header_handled = TRUE;
+ break;
+
+ case HEADER_BCC:
+ CAMEL_LOG (FULL_DEBUG,
+ "CamelMimeMessage::parse_header_pair found HEADER_BCC : %s\n",
+ header_value->str );
+
+ _set_recipient_list_from_string (message, g_string_new ("Bcc"), header_value);
+ g_string_free (header_value, TRUE);
+ header_handled = TRUE;
break;
- }
- return parent_class->parse_header_pair (mime_part, header_name, header_value);
+ }
+ if (header_handled) {
+ g_string_free (header_name, TRUE);
+ return TRUE;
+ } else
+ return parent_class->parse_header_pair (mime_part, header_name, header_value);
}