aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@inria.fr>1999-05-15 18:32:30 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-05-15 18:32:30 +0800
commit6c99eb2e0cbc6f383aac6d34aacaa8cbceb2600e (patch)
tree1bc9d2c64c2132cad3136063d85396d257d0e2d4 /camel
parent4b376c242cf019e5fec6889422b8d777ae7a480d (diff)
downloadgsoc2013-evolution-6c99eb2e0cbc6f383aac6d34aacaa8cbceb2600e.tar.gz
gsoc2013-evolution-6c99eb2e0cbc6f383aac6d34aacaa8cbceb2600e.tar.zst
gsoc2013-evolution-6c99eb2e0cbc6f383aac6d34aacaa8cbceb2600e.zip
flags handling methods
1999-05-15 bertrand <Bertrand.Guiheneuf@inria.fr> * camel/camel-mime-message.c (*_flag): flags handling methods 1999-05-14 bertrand <Bertrand.Guiheneuf@inria.fr> * camel/camel-mime-message.c (camel_mime_message_class_init): added recipient handling class funcs. svn path=/trunk/; revision=926
Diffstat (limited to 'camel')
-rw-r--r--camel/camel-mime-message.c101
-rw-r--r--camel/camel-mime-message.h10
2 files changed, 105 insertions, 6 deletions
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c
index f190c82f6f..e53a41f8ad 100644
--- a/camel/camel-mime-message.c
+++ b/camel/camel-mime-message.c
@@ -51,6 +51,9 @@ static void _add_recipient (CamelMimeMessage *mime_message, GString *recipient_t
static void _remove_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient);
static GList *_get_recipients (CamelMimeMessage *mime_message, GString *recipient_type);
+static void _set_flag (CamelMimeMessage *mime_message, GString *flag, gboolean value);
+static gboolean _get_flag (CamelMimeMessage *mime_message, GString *flag);
+
/* Returns the class for a CamelMimeMessage */
#define CMM_CLASS(so) CAMEL_MIME_MESSAGE_CLASS (GTK_OBJECT(so)->klass)
@@ -80,6 +83,8 @@ camel_mime_message_class_init (CamelMimeMessageClass *camel_mime_message_class)
camel_mime_message_class->add_recipient = _add_recipient;
camel_mime_message_class->remove_recipient = _remove_recipient;
camel_mime_message_class->get_recipients = _get_recipients;
+ camel_mime_message_class->set_flag = _set_flag;
+ camel_mime_message_class->get_flag = _get_flag;
/* virtual method overload */
}
@@ -93,7 +98,8 @@ camel_mime_message_init (gpointer object, gpointer klass)
CamelMimeMessage *camel_mime_message = CAMEL_MIME_MESSAGE (object);
camel_mime_message->recipients = g_hash_table_new(g_string_hash, g_string_equal_for_hash);
-
+ camel_mime_message->flags = g_hash_table_new(g_string_hash, g_string_equal_for_hash);
+
}
@@ -133,7 +139,7 @@ static void
_set_field (CamelMimeMessage *mime_message, GString *name, GString *value, GString **variable)
{
if (variable) {
- if (*variable) G_string_free (*variable, TRUE);
+ if (*variable) G_string_free (*variable, FALSE);
*variable = value;
}
}
@@ -283,6 +289,7 @@ get_from (CamelMimeMessage *mime_message)
static void
_add_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient)
{
+ /* be careful, recipient_type and recipient may be freed within this func */
GList *recipients_list;
GList *existent_list;
@@ -290,9 +297,11 @@ _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_hash) ) {
+ g_string_free (recipient_type, FALSE);
+ g_string_free (recipient, FALSE);
return;
-
+ }
/* append the new recipient to the recipient list
if the existent_list is NULL, then a new GList is
automagically created */
@@ -300,6 +309,24 @@ _add_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString
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_string_free (recipient_type, FALSE);
+}
+
+
+/**
+ * add_recipient:
+ * @mime_message:
+ * @recipient_type:
+ * @recipient:
+ *
+ * Have to write the doc. IMPORTANT : @recipient_type and
+ * @recipient may be freed within this func
+ **/
+void
+add_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient)
+{
+ CMM_CLASS (mime_message)->add_recipient (mime_message, recipient_type, recipient);
}
@@ -338,12 +365,18 @@ _remove_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GStr
if (new_recipients_list != recipients_list)
g_hash_table_insert (mime_message->recipients, old_recipient_type, new_recipients_list);
- g_string_free( (GString *)(old_element->data), TRUE);
+ g_string_free( (GString *)(old_element->data), FALSE);
g_list_free_1(old_element);
}
}
+void
+remove_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient)
+{
+ CMM_CLASS (mime_message)->remove_recipient (mime_message, recipient_type, recipient);
+}
+
@@ -352,3 +385,61 @@ _get_recipients (CamelMimeMessage *mime_message, GString *recipient_type)
{
return (GList *)g_hash_table_lookup (mime_message->recipients, recipient_type);
}
+
+GList *
+get_recipients (CamelMimeMessage *mime_message, GString *recipient_type)
+{
+ return CMM_CLASS (mime_message)->get_recipients (mime_message, recipient_type);
+}
+
+
+
+
+static void
+_set_flag (CamelMimeMessage *mime_message, GString *flag, gboolean value)
+{
+ GString old_flags;
+ gboolean *ptr_value;
+ if (! g_hash_table_lookup_extended (mime_message->flags,
+ flag,
+ (gpointer)&(old_flags),
+ (gpointer)&(ptr_value)) ) {
+
+ ptr_value = g_new (gboolean, 1);
+ g_hash_table_insert (mime_message->flags, flag, ptr_value);
+ } else {
+ g_string_free (flag, FALSE);
+ }
+ *ptr_value = value;
+
+}
+
+void
+set_flag (CamelMimeMessage *mime_message, GString *flag, gboolean value)
+{
+ CMM_CLASS (mime_message)->set_flag (mime_message, flag, value);
+}
+
+
+
+static gboolean
+_get_flag (CamelMimeMessage *mime_message, GString *flag)
+{
+ gboolean *value;
+ value = (gboolean *)g_hash_table_lookup (mime_message->flags, flag);
+ return ( (value) && (*value));
+}
+
+gboolean
+get_flag (CamelMimeMessage *mime_message, GString *flag)
+{
+ return CMM_CLASS (mime_message)->get_flag (mime_message, flag);
+}
+
+
+
+
+
+
+
+
diff --git a/camel/camel-mime-message.h b/camel/camel-mime-message.h
index c81bbb4fc7..53cf269ea8 100644
--- a/camel/camel-mime-message.h
+++ b/camel/camel-mime-message.h
@@ -63,7 +63,8 @@ typedef struct
/* other fields */
GHashTable *flags; /* boolean values */
- gboolean expunged;
+ /* gboolean expunged;
+ Will be enabled if proves necessary in the future */
guint message_number; /* set by folder object when retrieving message */
CamelFolder *folder;
CamelSession *session;
@@ -88,6 +89,8 @@ typedef struct {
void (*add_recipient) (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient);
void (*remove_recipient) (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient);
GList * (*get_recipients) (CamelMimeMessage *mime_message, GString *recipient_type);
+ void (*set_flag) (CamelMimeMessage *mime_message, GString *flag, gboolean value);
+ gboolean (*get_flag) (CamelMimeMessage *mime_message, GString *flag);
} CamelMimeMessageClass;
@@ -109,7 +112,12 @@ GString *get_subject (CamelMimeMessage *mime_message);
void set_from (CamelMimeMessage *mime_message, GString *from);
GString *get_from (CamelMimeMessage *mime_message);
+void add_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient);
+void remove_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient);
+GList *get_recipients (CamelMimeMessage *mime_message, GString *recipient_type);
+void set_flag (CamelMimeMessage *mime_message, GString *flag, gboolean value);
+gboolean get_flag (CamelMimeMessage *mime_message, GString *flag);
#ifdef __cplusplus