aboutsummaryrefslogtreecommitdiffstats
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
parentec22bcd92061fcf6ce599d5fd777a9159beaff02 (diff)
downloadgsoc2013-evolution-920be6e190bf0dd0056a71695cf3350625e8318c.tar
gsoc2013-evolution-920be6e190bf0dd0056a71695cf3350625e8318c.tar.gz
gsoc2013-evolution-920be6e190bf0dd0056a71695cf3350625e8318c.tar.bz2
gsoc2013-evolution-920be6e190bf0dd0056a71695cf3350625e8318c.tar.lz
gsoc2013-evolution-920be6e190bf0dd0056a71695cf3350625e8318c.tar.xz
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
-rw-r--r--ChangeLog9
-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
-rw-r--r--tests/ui-tests/store_listing.c2
5 files changed, 39 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 98c47aad07..420fa42806 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
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
+
+ * camel/providers/MH/camel-mh-folder.c (_get_message): set
+ message->message_number correctly.
+
* camel/camel-folder.h (struct _CamelFolder):
New field (message_list) which will hold a
reference on each message obtained by the folder,
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);
diff --git a/tests/ui-tests/store_listing.c b/tests/ui-tests/store_listing.c
index a9f1d875cd..7b5a6e9133 100644
--- a/tests/ui-tests/store_listing.c
+++ b/tests/ui-tests/store_listing.c
@@ -74,7 +74,7 @@ show_folder_messages (CamelFolder *folder)
folder_message_count = camel_folder_get_message_count (folder);
for (i=0; i<folder_message_count; i++) {
message = camel_folder_get_message (folder, i);
-
+ gtk_object_ref (GTK_OBJECT (message));
sent_date = camel_mime_message_get_sent_date (message);
sender = camel_mime_message_get_from (message);
subject = camel_mime_message_get_subject (message);