aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>1999-08-30 14:29:37 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-08-30 14:29:37 +0800
commit122f27a2aae0c712339b39bd3b7581624b8a03b5 (patch)
tree290cff49019ea39a0a6cc5bf2760af6068147506
parentd938232d3ce8c76d3296437710aedbb401fba7f2 (diff)
downloadgsoc2013-evolution-122f27a2aae0c712339b39bd3b7581624b8a03b5.tar
gsoc2013-evolution-122f27a2aae0c712339b39bd3b7581624b8a03b5.tar.gz
gsoc2013-evolution-122f27a2aae0c712339b39bd3b7581624b8a03b5.tar.bz2
gsoc2013-evolution-122f27a2aae0c712339b39bd3b7581624b8a03b5.tar.lz
gsoc2013-evolution-122f27a2aae0c712339b39bd3b7581624b8a03b5.tar.xz
gsoc2013-evolution-122f27a2aae0c712339b39bd3b7581624b8a03b5.tar.zst
gsoc2013-evolution-122f27a2aae0c712339b39bd3b7581624b8a03b5.zip
new func. More work on new independant recipient code.
1999-08-30 bertrand <Bertrand.Guiheneuf@aful.org> * camel/camel-recipient.c (camel_recipient_get): (camel_recipient_remove): (camel_recipient_add): new func. More work on new independant recipient code. 1999-08-29 bertrand <Bertrand.Guiheneuf@aful.org> * MAINTAINERS: updated my e-mail address. svn path=/trunk/; revision=1148
-rw-r--r--ChangeLog7
-rw-r--r--camel/Makefile.am2
-rw-r--r--camel/camel-recipient.c60
-rw-r--r--camel/camel-recipient.h4
4 files changed, 64 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 71965bfbe7..81c72b62c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+1999-08-30 bertrand <Bertrand.Guiheneuf@aful.org>
+
+ * camel/camel-recipient.c (camel_recipient_get):
+ (camel_recipient_remove):
+ (camel_recipient_add):
+ new func. More work on new independant recipient code.
+
1999-08-29 bertrand <Bertrand.Guiheneuf@aful.org>
* MAINTAINERS: updated my e-mail address.
diff --git a/camel/Makefile.am b/camel/Makefile.am
index 3fdedaac43..a71e7ce20b 100644
--- a/camel/Makefile.am
+++ b/camel/Makefile.am
@@ -24,6 +24,7 @@ libcamel_la_SOURCES = \
camel-mime-part-utils.c \
camel-multipart.c \
camel-provider.c \
+ camel-recipient.c \
camel-service.c \
camel-session.c \
camel-store.c \
@@ -52,6 +53,7 @@ libcamelinclude_HEADERS = \
camel-mime-part-utils.h \
camel-multipart.h \
camel-provider.h \
+ camel-recipient.h \
camel-service.h \
camel-session.h \
camel-store.h \
diff --git a/camel/camel-recipient.c b/camel/camel-recipient.c
index d9d5863680..5db7420b94 100644
--- a/camel/camel-recipient.c
+++ b/camel/camel-recipient.c
@@ -24,6 +24,7 @@
#include "glib.h"
#include "hash-table-utils.h"
+#include "camel-recipient.h"
CamelRecipientTable *
@@ -32,7 +33,7 @@ camel_recipient_new ()
CamelRecipientTable *recipient_table;
recipient_table = g_new0 (CamelRecipientTable, 1);
- recipient_table->recipient_table = g_hash_table_new (g_strcase_cmp, g_strcase_hash);
+ recipient_table->recipient_hash_table = g_hash_table_new (g_strcase_hash, g_strcase_equal);
recipient_table->ref_count = 1;
return recipient_table;
}
@@ -51,11 +52,11 @@ static void
_free_recipient_list (gpointer key, gpointer value, gpointer user_data)
{
GList *recipient_list = (GList *)value;
- gchar *recipient_name = (gchar *key);
+ gchar *recipient_name = (gchar *)key;
while (recipient_list) {
g_free (recipient_list->data);
- recipient_list = recipient_list->next
+ recipient_list = recipient_list->next;
}
g_free (recipient_name);
@@ -68,8 +69,8 @@ camel_recipient_free (CamelRecipientTable *recipient_table)
g_return_if_fail (recipient_table);
/* free each recipient list */
- g_hash_table_foreach (recipient_table->recipient_table, _free_recipient_list);
- g_hash_table_destroy (recipient_table->recipient_table);
+ g_hash_table_foreach (recipient_table->recipient_hash_table, _free_recipient_list, NULL);
+ g_hash_table_destroy (recipient_table->recipient_hash_table);
}
@@ -96,7 +97,7 @@ camel_recipient_add (CamelRecipientTable *recipient_table,
GList *existent_list;
/* see if there is already a list for this recipient type */
- existent_list = (GList *)g_hash_table_lookup (recipient_table->recipient_table, recipient_type);
+ existent_list = (GList *)g_hash_table_lookup (recipient_table->recipient_hash_table, recipient_type);
/* append the new recipient to the recipient list
@@ -105,8 +106,53 @@ camel_recipient_add (CamelRecipientTable *recipient_table,
recipients_list = g_list_append (existent_list, (gpointer)recipient);
if (!existent_list) /* if there was no recipient of this type create the section */
- g_hash_table_insert (mime_message->recipients, recipient_type, recipients_list);
+ g_hash_table_insert (recipient_table->recipient_hash_table, recipient_type, recipients_list);
else
g_free (recipient_type);
}
+
+
+
+
+static void
+camel_recipient_remove (CamelRecipientTable *recipient_table,
+ const gchar *recipient_type,
+ const gchar *recipient)
+{
+ GList *recipients_list;
+ GList *new_recipients_list;
+ GList *old_element;
+ gchar *old_recipient_type;
+
+ /* if the recipient type section does not exist, do nothing */
+ if (! g_hash_table_lookup_extended (recipient_table->recipient_hash_table,
+ recipient_type,
+ (gpointer)&(old_recipient_type),
+ (gpointer)&(recipients_list))
+ ) 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);
+ if (old_element) {
+ /* if recipient exists, remove it */
+ new_recipients_list = g_list_remove_link (recipients_list, old_element);
+
+ /* if glist head has changed, fix up hash table */
+ if (new_recipients_list != recipients_list)
+ g_hash_table_insert (recipient_table->recipient_hash_table, old_recipient_type, new_recipients_list);
+
+ g_free( (gchar *)(old_element->data));
+ g_list_free_1 (old_element);
+ }
+}
+
+
+
+const GList *
+camel_recipient_get (CamelRecipientTable *recipient_table,
+ const gchar *recipient_type)
+{
+ return (const GList *)g_hash_table_lookup (recipient_table->recipient_hash_table, recipient_type);
+}
diff --git a/camel/camel-recipient.h b/camel/camel-recipient.h
index a0d2317459..6b07d84478 100644
--- a/camel/camel-recipient.h
+++ b/camel/camel-recipient.h
@@ -35,10 +35,10 @@ extern "C" {
typedef struct {
- GHashTable *recipient_table;
+ GHashTable *recipient_hash_table;
gint ref_count;
-} CamelRecipient;
+} CamelRecipientTable;