aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-recipient.c
diff options
context:
space:
mode:
Diffstat (limited to 'camel/camel-recipient.c')
-rw-r--r--camel/camel-recipient.c75
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);
}