aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-recipient.c
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>1999-08-29 23:57:47 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-08-29 23:57:47 +0800
commit68a9dad22b742e3034eea24a57a0e7fad3356201 (patch)
tree852a65e1a2c0ab0a8d507bcdc8bba64bf2765be1 /camel/camel-recipient.c
parente826255bf13255f2b5c626192de4fd10a3885b6f (diff)
downloadgsoc2013-evolution-68a9dad22b742e3034eea24a57a0e7fad3356201.tar.gz
gsoc2013-evolution-68a9dad22b742e3034eea24a57a0e7fad3356201.tar.zst
gsoc2013-evolution-68a9dad22b742e3034eea24a57a0e7fad3356201.zip
text parameter declared const
1999-08-28 bertrand <Bertrand.Guiheneuf@aful.org> * camel/camel-mime-part.c (camel_mime_part_set_text): text parameter declared const * camel/camel-mime-part-utils.c (camel_mime_part_store_stream_in_buffer): actually test correctly nb_bytes_read_chunk is >0 * camel/gstring-util.c: * camel/gmime-content-field.c: * camel/providers/MH/camel-mh-folder.c: * camel/camel-stream-fs.c: include string.h * camel/camel-stream-mem.c (_write): return the numver of written bytes. * camel/camel-stream-buffered-fs.c (_eos): return sthg * camel/camel-stream.c (default_camel_seek): return something. * Started to work on new recipient code. * fixed various leaks. svn path=/trunk/; revision=1146
Diffstat (limited to 'camel/camel-recipient.c')
-rw-r--r--camel/camel-recipient.c112
1 files changed, 112 insertions, 0 deletions
diff --git a/camel/camel-recipient.c b/camel/camel-recipient.c
new file mode 100644
index 0000000000..d9d5863680
--- /dev/null
+++ b/camel/camel-recipient.c
@@ -0,0 +1,112 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* camel-recipient.h : handle recipients (addresses) and recipiemt lists */
+
+/*
+ *
+ * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+
+#include "glib.h"
+#include "hash-table-utils.h"
+
+
+CamelRecipientTable *
+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->ref_count = 1;
+ return recipient_table;
+}
+
+
+void
+camel_recipient_ref (CamelRecipientTable *recipient_table)
+{
+ g_return_if_fail (recipient_table);
+ recipient_table->ref_count += 1;
+}
+
+
+
+static void
+_free_recipient_list (gpointer key, gpointer value, gpointer user_data)
+{
+ GList *recipient_list = (GList *)value;
+ gchar *recipient_name = (gchar *key);
+
+ while (recipient_list) {
+ g_free (recipient_list->data);
+ recipient_list = recipient_list->next
+ }
+
+ g_free (recipient_name);
+
+}
+
+void
+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);
+}
+
+
+
+
+void
+camel_recipient_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);
+
+}
+
+
+
+void
+camel_recipient_add (CamelRecipientTable *recipient_table,
+ const gchar *recipient_type,
+ const gchar *recipient)
+{
+ 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_table, recipient_type);
+
+
+ /* 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);
+
+ 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);
+ else
+ g_free (recipient_type);
+
+}