aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>1999-08-14 02:28:56 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-08-14 02:28:56 +0800
commit920be6e190bf0dd0056a71695cf3350625e8318c (patch)
tree102e3b08b35febec6e718334a928e1bad6010e5e /camel
parentec22bcd92061fcf6ce599d5fd777a9159beaff02 (diff)
downloadgsoc2013-evolution-920be6e190bf0dd0056a71695cf3350625e8318c.tar.gz
gsoc2013-evolution-920be6e190bf0dd0056a71695cf3350625e8318c.tar.zst
gsoc2013-evolution-920be6e190bf0dd0056a71695cf3350625e8318c.zip
default implementation to be called first by providers methods. It looks
1999-08-13 bertrand <Bertrand.Guiheneuf@aful.org> * camel/camel-folder.c (_get_message): default implementation to be called first by providers methods. It looks in the folder message list (in memory) to see if the message has not already been retrieved, and in this case, returns the same CamelMimeMessage object Caching messages in folder kworks. Providers will have to do their job correctly. Enough for today. svn path=/trunk/; revision=1113
Diffstat (limited to 'camel')
-rw-r--r--camel/camel-folder.c27
-rw-r--r--camel/camel-mime-message.h1
-rw-r--r--camel/providers/MH/camel-mh-folder.c5
3 files changed, 29 insertions, 4 deletions
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index 8c4824168b..d7319c5017 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -774,8 +774,27 @@ camel_folder_expunge (CamelFolder *folder)
static CamelMimeMessage *
_get_message (CamelFolder *folder, gint number)
{
+ CamelMimeMessage *a_message;
+ CamelMimeMessage *new_message = NULL;
+ GList *message_node;
- return NULL;
+ message_node = folder->message_list;
+
+ /* look in folder message list if the
+ * if the message has not already been retreived */
+ while ((!new_message) && message_node) {
+ a_message = CAMEL_MIME_MESSAGE (message_node->data);
+ CAMEL_LOG_FULL_DEBUG ("CamelFolder::get_message Current message number is %d\n", a_message->message_number);
+ if (a_message && (a_message->message_number == number)) {
+ CAMEL_LOG_FULL_DEBUG ("CamelFolder::get_message message %d already retreived once: returning %pOK\n",
+ number, a_message);
+ new_message = a_message;
+ }
+ message_node = message_node->next;
+
+ CAMEL_LOG_FULL_DEBUG ("CamelFolder::get_message message node = %p\n", message_node);
+ }
+ return new_message;
}
@@ -803,7 +822,7 @@ camel_folder_get_message (CamelFolder *folder, gint number)
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))
+ if ((!folder->message_list) || (!g_list_find (folder->message_list, new_message)))
folder->message_list = g_list_append (folder->message_list, new_message);
return new_message;
}
@@ -840,8 +859,8 @@ _append_message (CamelFolder *folder, CamelMimeMessage *message)
gint camel_folder_append_message (CamelFolder *folder, CamelMimeMessage *message)
-{
- return CF_CLASS (folder)->append_message (folder, message);
+{
+ return CF_CLASS (folder)->append_message (folder, message);
}
diff --git a/camel/camel-mime-message.h b/camel/camel-mime-message.h
index da691fa05d..522173c765 100644
--- a/camel/camel-mime-message.h
+++ b/camel/camel-mime-message.h
@@ -66,6 +66,7 @@ struct _CamelMimeMessage
GHashTable *recipients;
/* -> each value is a GList of address strings */
/* each key is a recipient type string in lower-case */
+ /* FIXME: these should be relaced by dedicated structure */
/* other fields */
GHashTable *flags; /* boolean values */
diff --git a/camel/providers/MH/camel-mh-folder.c b/camel/providers/MH/camel-mh-folder.c
index a1c78fd309..a59566958a 100644
--- a/camel/providers/MH/camel-mh-folder.c
+++ b/camel/providers/MH/camel-mh-folder.c
@@ -410,6 +410,9 @@ _get_message (CamelFolder *folder, gint number)
g_assert(folder);
+ message = parent_class->get_message (folder, number);
+ if (message) return message;
+
directory_path = mh_folder->directory_path;
if (!directory_path) return NULL;
if (!camel_folder_exists (folder)) return NULL;
@@ -441,6 +444,8 @@ _get_message (CamelFolder *folder, gint number)
message = camel_mime_message_new_with_session ( (CamelSession *)NULL);
camel_data_wrapper_construct_from_stream ( CAMEL_DATA_WRAPPER (message), input_stream);
gtk_object_unref (GTK_OBJECT (input_stream));
+ message->message_number = number;
+#warning Set flags and all this stuff here
}
} else
CAMEL_LOG_FULL_DEBUG ("CanelMhFolder::get_message message number = %d, not found\n", number);