aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>1999-08-14 01:41:18 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-08-14 01:41:18 +0800
commitec22bcd92061fcf6ce599d5fd777a9159beaff02 (patch)
treee0eef90af8229dd7a1453ab72a3403ceaea8db5b
parentc232c3eeaaf85c3e92a1c6bf7a802f7ffee30451 (diff)
downloadgsoc2013-evolution-ec22bcd92061fcf6ce599d5fd777a9159beaff02.tar
gsoc2013-evolution-ec22bcd92061fcf6ce599d5fd777a9159beaff02.tar.gz
gsoc2013-evolution-ec22bcd92061fcf6ce599d5fd777a9159beaff02.tar.bz2
gsoc2013-evolution-ec22bcd92061fcf6ce599d5fd777a9159beaff02.tar.lz
gsoc2013-evolution-ec22bcd92061fcf6ce599d5fd777a9159beaff02.tar.xz
gsoc2013-evolution-ec22bcd92061fcf6ce599d5fd777a9159beaff02.tar.zst
gsoc2013-evolution-ec22bcd92061fcf6ce599d5fd777a9159beaff02.zip
New field (message_list) which will hold a reference on each message
1999-08-13 bertrand <Bertrand.Guiheneuf@aful.org> * camel/camel-folder.h (struct _CamelFolder): New field (message_list) which will hold a reference on each message obtained by the folder, which is necessary in order for the caching procedure to work (Getting the same message from a folder twice will return the same CamelMimeMessage object). * camel/camel-folder.c (camel_folder_get_message): When the store retreives a message put it in its message list. (_finalize): free message list. * ChangeLog: fix typo (parmanent) svn path=/trunk/; revision=1112
-rw-r--r--ChangeLog18
-rw-r--r--camel/camel-folder.c32
-rw-r--r--camel/camel-folder.h2
-rw-r--r--camel/camel-mime-message.c64
-rw-r--r--camel/camel-mime-message.h4
5 files changed, 99 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 9444a4c60a..98c47aad07 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,21 @@
1999-08-13 bertrand <Bertrand.Guiheneuf@aful.org>
- * camel/camel-folder.c (_get_parmanent_flag_list):
- (camel_folder_get_parmanent_flag_list):
+ * camel/camel-folder.h (struct _CamelFolder):
+ New field (message_list) which will hold a
+ reference on each message obtained by the folder,
+ which is necessary in order for the caching procedure
+ to work (Getting the same message from a folder twice
+ will return the same CamelMimeMessage object).
+
+ * camel/camel-folder.c (camel_folder_get_message):
+ When the store retreives a message put it in its
+ message list.
+ (_finalize): free message list.
+
+ * ChangeLog: fix typo (parmanent)
+
+ * camel/camel-folder.c (_get_permanent_flag_list):
+ (camel_folder_get_permanent_flag_list):
new method, returns the list of permanent
flags supported by the folder.
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index 271b5e1644..8c4824168b 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -128,12 +128,22 @@ static void
_finalize (GtkObject *object)
{
CamelFolder *camel_folder = CAMEL_FOLDER (object);
+ GList *message_node;
+
CAMEL_LOG_FULL_DEBUG ("Entering CamelFolder::finalize\n");
if (camel_folder->name) g_free (camel_folder->name);
if (camel_folder->full_name) g_free (camel_folder->full_name);
if (camel_folder->permanent_flags) g_free (camel_folder->permanent_flags);
-
+ if (camel_folder->message_list) {
+ /* unref all messages got from the folder */
+ message_node = camel_folder->message_list;
+ while (message_node) {
+ gtk_object_unref (GTK_OBJECT (message_node->data));
+ g_list_next (message_node);
+ }
+ g_list_free (camel_folder->message_list);
+ }
GTK_OBJECT_CLASS (parent_class)->finalize (object);
CAMEL_LOG_FULL_DEBUG ("Leaving CamelFolder::finalize\n");
}
@@ -745,10 +755,10 @@ _expunge (CamelFolder *folder)
/**
- * camel_folder_expunge: physically delete messages marked as DELETED
+ * camel_folder_expunge: physically delete messages marked as "DELETED"
* @folder: the folder
*
- * Delete messages which have been marked as deleted.
+ * Delete messages which have been marked as "DELETED"
*
*
* Return value: list of expunged message objects.
@@ -761,10 +771,10 @@ camel_folder_expunge (CamelFolder *folder)
-
static CamelMimeMessage *
_get_message (CamelFolder *folder, gint number)
{
+
return NULL;
}
@@ -783,7 +793,19 @@ _get_message (CamelFolder *folder, gint number)
CamelMimeMessage *
camel_folder_get_message (CamelFolder *folder, gint number)
{
- return CF_CLASS (folder)->get_message (folder, number);
+ CamelMimeMessage *new_message;
+ new_message = CF_CLASS (folder)->get_message (folder, number);
+
+
+ /* now put the new message in the list of messages got from
+ * this folder. If people show concerns about this code being
+ * here, we will let the providers do it by themself */
+ if (!new_message) return NULL;
+ /* if the message has not been already put in
+ * this folder message list, put it in */
+ if (!g_list_find (folder->message_list, new_message))
+ folder->message_list = g_list_append (folder->message_list, new_message);
+ return new_message;
}
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index 10ed7d1718..724a03d524 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -71,6 +71,8 @@ struct _CamelFolder
CamelFolder *parent_folder;
GList *permanent_flags;
+ GList *message_list;
+
};
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c
index 417ccc9ff0..3d33f43446 100644
--- a/camel/camel-mime-message.c
+++ b/camel/camel-mime-message.c
@@ -207,7 +207,7 @@ camel_mime_message_new_with_session (CamelSession *session)
}
-/* two utils func */
+/* some utils func */
static void
_set_field (CamelMimeMessage *mime_message, gchar *name, gchar *value, gchar **variable)
@@ -225,6 +225,16 @@ _get_field (CamelMimeMessage *mime_message, gchar *name, gchar *variable)
{
return variable;
}
+
+static gboolean
+_check_not_expunged (CamelMimeMessage *mime_message)
+{
+ if (mime_message->expunged) {
+ CAMEL_LOG_WARNING ("CamelMimeMessage:: An invalid operation has been tempted on an expunged message\n");
+ }
+ return (!mime_message->expunged);
+}
+
/* * */
@@ -237,7 +247,9 @@ _set_received_date (CamelMimeMessage *mime_message, gchar *received_date)
void
camel_mime_message_set_received_date (CamelMimeMessage *mime_message, gchar *received_date)
{
- CMM_CLASS (mime_message)->set_received_date (mime_message, received_date);
+ g_assert (mime_message);
+ g_return_if_fail (_check_not_expunged (mime_message));
+ CMM_CLASS (mime_message)->set_received_date (mime_message, received_date);
}
@@ -250,7 +262,9 @@ _get_received_date (CamelMimeMessage *mime_message)
const gchar *
camel_mime_message_get_received_date (CamelMimeMessage *mime_message)
{
- return CMM_CLASS (mime_message)->get_received_date (mime_message);
+ g_assert (mime_message);
+ g_return_val_if_fail (_check_not_expunged (mime_message), NULL);
+ return CMM_CLASS (mime_message)->get_received_date (mime_message);
}
@@ -263,7 +277,9 @@ _get_sent_date (CamelMimeMessage *mime_message)
const gchar *
camel_mime_message_get_sent_date (CamelMimeMessage *mime_message)
{
- return CMM_CLASS (mime_message)->get_sent_date (mime_message);
+ g_assert (mime_message);
+ g_return_val_if_fail (_check_not_expunged (mime_message), NULL);
+ return CMM_CLASS (mime_message)->get_sent_date (mime_message);
}
@@ -276,7 +292,9 @@ _set_reply_to (CamelMimeMessage *mime_message, gchar *reply_to)
void
camel_mime_message_set_reply_to (CamelMimeMessage *mime_message, gchar *reply_to)
{
- CMM_CLASS (mime_message)->set_reply_to (mime_message, reply_to);
+ g_assert (mime_message);
+ g_return_if_fail (_check_not_expunged (mime_message));
+ CMM_CLASS (mime_message)->set_reply_to (mime_message, reply_to);
}
@@ -289,7 +307,9 @@ _get_reply_to (CamelMimeMessage *mime_message)
const gchar *
camel_mime_message_get_reply_to (CamelMimeMessage *mime_message)
{
- return CMM_CLASS (mime_message)->get_reply_to (mime_message);
+ g_assert (mime_message);
+ g_return_val_if_fail (_check_not_expunged (mime_message), NULL);
+ return CMM_CLASS (mime_message)->get_reply_to (mime_message);
}
@@ -304,7 +324,9 @@ _set_subject (CamelMimeMessage *mime_message, gchar *subject)
void
camel_mime_message_set_subject (CamelMimeMessage *mime_message, gchar *subject)
{
- CMM_CLASS (mime_message)->set_subject (mime_message, subject);
+ g_assert (mime_message);
+ g_return_if_fail (_check_not_expunged (mime_message));
+ CMM_CLASS (mime_message)->set_subject (mime_message, subject);
}
@@ -317,7 +339,9 @@ _get_subject (CamelMimeMessage *mime_message)
const gchar *
camel_mime_message_get_subject (CamelMimeMessage *mime_message)
{
- return CMM_CLASS (mime_message)->get_subject (mime_message);
+ g_assert (mime_message);
+ g_return_val_if_fail (_check_not_expunged (mime_message), NULL);
+ return CMM_CLASS (mime_message)->get_subject (mime_message);
}
@@ -332,7 +356,9 @@ _set_from (CamelMimeMessage *mime_message, gchar *from)
void
camel_mime_message_set_from (CamelMimeMessage *mime_message, gchar *from)
{
- CMM_CLASS (mime_message)->set_from (mime_message, from);
+ g_assert (mime_message);
+ g_return_if_fail (_check_not_expunged (mime_message));
+ CMM_CLASS (mime_message)->set_from (mime_message, from);
}
@@ -345,7 +371,9 @@ _get_from (CamelMimeMessage *mime_message)
const gchar *
camel_mime_message_get_from (CamelMimeMessage *mime_message)
{
- return CMM_CLASS (mime_message)->get_from (mime_message);
+ g_assert (mime_message);
+ g_return_val_if_fail (_check_not_expunged (mime_message), NULL);
+ return CMM_CLASS (mime_message)->get_from (mime_message);
}
@@ -393,7 +421,9 @@ _add_recipient (CamelMimeMessage *mime_message, gchar *recipient_type, gchar *re
void
camel_mime_message_add_recipient (CamelMimeMessage *mime_message, gchar *recipient_type, gchar *recipient)
{
- CMM_CLASS (mime_message)->add_recipient (mime_message, recipient_type, recipient);
+ g_assert (mime_message);
+ g_return_if_fail (_check_not_expunged (mime_message));
+ CMM_CLASS (mime_message)->add_recipient (mime_message, recipient_type, recipient);
}
@@ -442,7 +472,9 @@ _remove_recipient (CamelMimeMessage *mime_message, const gchar *recipient_type,
void
camel_mime_message_remove_recipient (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient)
{
- CMM_CLASS (mime_message)->remove_recipient (mime_message, recipient_type, recipient);
+ g_assert (mime_message);
+ g_return_if_fail (_check_not_expunged (mime_message));
+ CMM_CLASS (mime_message)->remove_recipient (mime_message, recipient_type, recipient);
}
@@ -455,6 +487,8 @@ _get_recipients (CamelMimeMessage *mime_message, const gchar *recipient_type)
const GList *
camel_mime_message_get_recipients (CamelMimeMessage *mime_message, const gchar *recipient_type)
{
+ g_assert (mime_message);
+ g_return_val_if_fail (_check_not_expunged (mime_message), NULL);
return CMM_CLASS (mime_message)->get_recipients (mime_message, recipient_type);
}
@@ -479,6 +513,8 @@ _set_flag (CamelMimeMessage *mime_message, const gchar *flag, gboolean value)
void
camel_mime_message_set_flag (CamelMimeMessage *mime_message, const gchar *flag, gboolean value)
{
+ g_assert (mime_message);
+ g_return_if_fail (_check_not_expunged (mime_message));
CMM_CLASS (mime_message)->set_flag (mime_message, flag, value);
}
@@ -495,6 +531,8 @@ _get_flag (CamelMimeMessage *mime_message, const gchar *flag)
gboolean
camel_mime_message_get_flag (CamelMimeMessage *mime_message, const gchar *flag)
{
+ g_assert (mime_message);
+ g_return_val_if_fail (_check_not_expunged (mime_message), FALSE);
return CMM_CLASS (mime_message)->get_flag (mime_message, flag);
}
@@ -524,6 +562,8 @@ _get_flag_list (CamelMimeMessage *mime_message)
GList *
camel_mime_message_get_flag_list (CamelMimeMessage *mime_message)
{
+ g_assert (mime_message);
+ g_return_val_if_fail (_check_not_expunged (mime_message), NULL);
return CMM_CLASS (mime_message)->get_flag_list (mime_message);
}
diff --git a/camel/camel-mime-message.h b/camel/camel-mime-message.h
index 27fa862f5e..da691fa05d 100644
--- a/camel/camel-mime-message.h
+++ b/camel/camel-mime-message.h
@@ -69,8 +69,8 @@ struct _CamelMimeMessage
/* other fields */
GHashTable *flags; /* boolean values */
- /* gboolean expunged;
- Will be enabled if proves necessary in the future */
+ gboolean expunged;
+
guint message_number; /* set by folder object when retrieving message */
CamelFolder *folder;
CamelSession *session;