diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | camel/camel-mime-message.c | 37 | ||||
-rw-r--r-- | camel/camel-mime-message.h | 4 | ||||
-rw-r--r-- | camel/gstring-util.c | 8 | ||||
-rw-r--r-- | camel/gstring-util.h | 1 | ||||
-rw-r--r-- | tests/test1.c | 12 |
6 files changed, 62 insertions, 7 deletions
@@ -1,3 +1,10 @@ +1999-05-20 bertrand <Bertrand.Guiheneuf@inria.fr> + + * camel/camel-mime-message.c (_write_to_file): + recipient list printing + + * tests/test1.c (main): more tests. + 1999-05-19 bertrand <Bertrand.Guiheneuf@inria.fr> * camel/camel-mime-part.c (_write_to_file): test if content diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c index c561b89fee..270cbcc5ef 100644 --- a/camel/camel-mime-message.c +++ b/camel/camel-mime-message.c @@ -320,7 +320,7 @@ _add_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString existent_list = (GList *)g_hash_table_lookup (mime_message->recipients, recipient_type); /* if the recipient is already in this list, do nothing */ - if ( existent_list && g_list_find_custom (existent_list, (gpointer)recipient, g_string_equal_for_hash) ) { + if ( existent_list && g_list_find_custom (existent_list, (gpointer)recipient, g_string_equal_for_glist) ) { g_string_free (recipient_type, FALSE); g_string_free (recipient, FALSE); return; @@ -378,7 +378,7 @@ _remove_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GStr (gpointer)&(recipients_list)) ) return; - /* look for the recipient to remoce */ + /* look for the recipient to remove */ old_element = g_list_find_custom (recipients_list, recipient, g_string_equal_for_hash); if (old_element) { /* if recipient exists, remove it */ @@ -490,11 +490,39 @@ camel_mime_message_get_message_number (CamelMimeMessage *mime_message) #endif #define WHPTF gmime_write_header_pair_to_file +static void +_write_one_recipient_to_file (gpointer key, gpointer value, gpointer user_data) +{ + GString *recipient_type = (GString *)key; + GList *recipients = (GList *)value; + GString *current; + FILE *file = (FILE *)user_data; + + if ( (recipient_type) && (recipient_type->str) && + (recipients) ) + { + gboolean first; + + fprintf(file, "%s: ", recipient_type->str); + first = TRUE; + while (recipients) { + current = (GString *)recipients->data; + if ( (current) && (current->str) ) { + if (!first) fprintf(file, ", "); + else first = FALSE; + fprintf(file, "%s", current->str); + } + recipients = g_list_next(recipients); + + } + fprintf(file, "\n"); + } +} static void -_write_recipients_to_file (CamelDataWrapper *data_wrapper, FILE *file) +_write_recipients_to_file (CamelMimeMessage *mime_message, FILE *file) { - + g_hash_table_foreach (mime_message->recipients, _write_one_recipient_to_file, (gpointer)file); } static void @@ -504,6 +532,7 @@ _write_to_file (CamelDataWrapper *data_wrapper, FILE *file) WHPTF (file, "From", mm->from); WHPTF (file, "Reply-To", mm->reply_to); + _write_recipients_to_file (mm, file); WHPTF (file, "Date", mm->received_date); WHPTF (file, "Subject", mm->subject); CAMEL_DATA_WRAPPER_CLASS (parent_class)->write_to_file (data_wrapper, file); diff --git a/camel/camel-mime-message.h b/camel/camel-mime-message.h index 6bb0a789b9..b00f723f21 100644 --- a/camel/camel-mime-message.h +++ b/camel/camel-mime-message.h @@ -37,6 +37,10 @@ extern "C" { #include "camel-session.h" +#define RECIPIENT_TYPE_TO "To" +#define RECIPIENT_TYPE_CC "Cc" +#define RECIPIENT_TYPE_BCC "Bcc" + #define CAMEL_MIME_MESSAGE_TYPE (camel_mime_message_get_type ()) #define CAMEL_MIME_MESSAGE(obj) (GTK_CHECK_CAST((obj), CAMEL_MIME_MESSAGE_TYPE, CamelMimeMessage)) diff --git a/camel/gstring-util.c b/camel/gstring-util.c index 05cdc08beb..4d0411de33 100644 --- a/camel/gstring-util.c +++ b/camel/gstring-util.c @@ -37,7 +37,7 @@ * @Return Value : true if the strings equal, false otherwise **/ gboolean -g_string_equals(GString *string1, GString *string2) +g_string_equals (GString *string1, GString *string2) { g_assert(string1); g_assert(string2); @@ -46,6 +46,7 @@ g_string_equals(GString *string1, GString *string2) + /** * g_string_clone : clone a GString * @@ -192,6 +193,11 @@ g_string_equal_for_hash (gconstpointer v, gconstpointer v2) return strcmp ( ((const GString*)v)->str, ((const GString*)v2)->str) == 0; } +g_string_equal_for_glist (gconstpointer v, gconstpointer v2) +{ + return !strcmp ( ((const GString*)v)->str, ((const GString*)v2)->str) == 0; +} + /** * g_string_hash: computes a hash value for a Gstring diff --git a/camel/gstring-util.h b/camel/gstring-util.h index fcd2c5dc69..f8b7ee3fd1 100644 --- a/camel/gstring-util.h +++ b/camel/gstring-util.h @@ -48,6 +48,7 @@ gchar g_string_right_dichotomy( GString *string, gchar sep, GString **prefix, GS void g_string_append_g_string(GString *dest_string, GString *other_string); gboolean g_string_equal_for_hash (gconstpointer v, gconstpointer v2); +gboolean g_string_equal_for_glist (gconstpointer v, gconstpointer v2); guint g_string_hash (gconstpointer v); void g_string_list_free (GList *string_list); diff --git a/tests/test1.c b/tests/test1.c index 7ec4b49145..f75d9046ca 100644 --- a/tests/test1.c +++ b/tests/test1.c @@ -15,8 +15,16 @@ main (int argc, char**argv) camel_mime_message_set_subject (message, g_string_new ("A test message")); camel_mime_message_set_reply_to (message, g_string_new ("toto@toto.com")); camel_mime_message_set_from (message, g_string_new ("Bertrand.Guiheneuf@inria.fr")); - camel_mime_message_add_recipient (message, g_string_new ("To"), g_string_new ("franck.dechamps@alseve.fr")); - + + camel_mime_message_add_recipient (message, g_string_new (RECIPIENT_TYPE_TO), g_string_new ("franck.dechamps@alseve.fr")); + camel_mime_message_add_recipient (message, g_string_new (RECIPIENT_TYPE_TO), g_string_new ("mc@alseve.fr")); + camel_mime_message_add_recipient (message, g_string_new (RECIPIENT_TYPE_TO), g_string_new ("richard.lengagne@inria.fr")); + + camel_mime_message_add_recipient (message, g_string_new (RECIPIENT_TYPE_CC), g_string_new ("Francois.fleuret@inria.fr")); + camel_mime_message_add_recipient (message, g_string_new (RECIPIENT_TYPE_CC), g_string_new ("maury@justmagic.com")); + + camel_mime_message_add_recipient (message, g_string_new (RECIPIENT_TYPE_BCC), g_string_new ("guiheneu@aful.org")); + output_file = fopen ("mail.test", "w"); if (!output_file) { |