diff options
author | bertrand <Bertrand.Guiheneuf@aful.org> | 1999-09-01 22:36:17 +0800 |
---|---|---|
committer | Bertrand Guiheneuf <bertrand@src.gnome.org> | 1999-09-01 22:36:17 +0800 |
commit | 4ed34315759b8bb3b701133bcb704b5a4891100c (patch) | |
tree | 149574f5827f58f829b5485489547ba4727ef9a8 /camel/camel-recipient.c | |
parent | f5be7984b2ea1a4c3591cc11090220c080216aec (diff) | |
download | gsoc2013-evolution-4ed34315759b8bb3b701133bcb704b5a4891100c.tar.gz gsoc2013-evolution-4ed34315759b8bb3b701133bcb704b5a4891100c.tar.zst gsoc2013-evolution-4ed34315759b8bb3b701133bcb704b5a4891100c.zip |
now use CamelRecipientTable
1999-09-01 bertrand <Bertrand.Guiheneuf@aful.org>
* camel/camel-mime-message.c (_finalize):
(_add_recipient):
(_remove_recipient):
(_get_recipients): now use CamelRecipientTable
* camel/gmime-content-field.c:
(gmime_content_field_unref): test if object
to free is non void.
Still are some bugs in camel-recipient.c
svn path=/trunk/; revision=1152
Diffstat (limited to 'camel/camel-recipient.c')
-rw-r--r-- | camel/camel-recipient.c | 75 |
1 files changed, 55 insertions, 20 deletions
diff --git a/camel/camel-recipient.c b/camel/camel-recipient.c index 5db7420b94..b73152c238 100644 --- a/camel/camel-recipient.c +++ b/camel/camel-recipient.c @@ -28,7 +28,7 @@ CamelRecipientTable * -camel_recipient_new () +camel_recipient_table_new () { CamelRecipientTable *recipient_table; @@ -40,7 +40,7 @@ camel_recipient_new () void -camel_recipient_ref (CamelRecipientTable *recipient_table) +camel_recipient_table_ref (CamelRecipientTable *recipient_table) { g_return_if_fail (recipient_table); recipient_table->ref_count += 1; @@ -64,7 +64,7 @@ _free_recipient_list (gpointer key, gpointer value, gpointer user_data) } void -camel_recipient_free (CamelRecipientTable *recipient_table) +camel_recipient_table_free (CamelRecipientTable *recipient_table) { g_return_if_fail (recipient_table); @@ -77,21 +77,29 @@ camel_recipient_free (CamelRecipientTable *recipient_table) void -camel_recipient_unref (CamelRecipientTable *recipient_table) +camel_recipient_table_unref (CamelRecipientTable *recipient_table) { g_return_if_fail (recipient_table); recipient_table->ref_count -= 1; if (recipient_table->ref_count <1) - camel_recipient_free (recipient_table); + camel_recipient_table_free (recipient_table); } +/** + * camel_recipient_table_add: + * @recipient_table: + * @recipient_type: + * @recipient: + * + * + **/ void -camel_recipient_add (CamelRecipientTable *recipient_table, - const gchar *recipient_type, - const gchar *recipient) +camel_recipient_table_add (CamelRecipientTable *recipient_table, + const gchar *recipient_type, + const gchar *recipient) { GList *recipients_list; GList *existent_list; @@ -103,22 +111,49 @@ camel_recipient_add (CamelRecipientTable *recipient_table, /* append the new recipient to the recipient list if the existent_list is NULL, then a new GList is automagically created */ - recipients_list = g_list_append (existent_list, (gpointer)recipient); + recipients_list = g_list_append (existent_list, (gpointer)g_strdup (recipient)); if (!existent_list) /* if there was no recipient of this type create the section */ - g_hash_table_insert (recipient_table->recipient_hash_table, recipient_type, recipients_list); - else - g_free (recipient_type); + g_hash_table_insert (recipient_table->recipient_hash_table, g_strdup (recipient_type), recipients_list); + + +} + +/** + * camel_recipient_table_add_list: + * @recipient_table: + * @recipient_type: + * @recipient_list: + * + * be careful, that the list is used as is, and its element + * will be freed by camel_recipient_table_unref + **/ +void +camel_recipient_table_add_list (CamelRecipientTable *recipient_table, + const gchar *recipient_type, + GList *recipient_list) +{ + GList *recipients_list; + GList *existent_list; + + /* see if there is already a list for this recipient type */ + existent_list = (GList *)g_hash_table_lookup (recipient_table->recipient_hash_table, recipient_type); + + + if (existent_list) + g_list_concat (existent_list, recipient_type); + else + g_hash_table_insert (recipient_table->recipient_hash_table, g_strdup (recipient_type), recipients_list); } -static void -camel_recipient_remove (CamelRecipientTable *recipient_table, - const gchar *recipient_type, - const gchar *recipient) +void +camel_recipient_table_remove (CamelRecipientTable *recipient_table, + const gchar *recipient_type, + const gchar *recipient) { GList *recipients_list; GList *new_recipients_list; @@ -133,8 +168,8 @@ camel_recipient_remove (CamelRecipientTable *recipient_table, ) return; /* look for the recipient to remove */ - /* g_list_find_custom does use "const" for recipient, is it a mistake ? */ - old_element = g_list_find_custom (recipients_list, recipient, g_strcase_equal); + /* g_list_find_custom , use gpointer instead of gconstpointer */ + old_element = g_list_find_custom (recipients_list, (gpointer)recipient, g_strcase_equal); if (old_element) { /* if recipient exists, remove it */ new_recipients_list = g_list_remove_link (recipients_list, old_element); @@ -151,8 +186,8 @@ camel_recipient_remove (CamelRecipientTable *recipient_table, const GList * -camel_recipient_get (CamelRecipientTable *recipient_table, - const gchar *recipient_type) +camel_recipient_table_get (CamelRecipientTable *recipient_table, + const gchar *recipient_type) { return (const GList *)g_hash_table_lookup (recipient_table->recipient_hash_table, recipient_type); } |