aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/ChangeLog20
-rw-r--r--mail/message-list.c60
-rw-r--r--mail/message-list.h4
3 files changed, 60 insertions, 24 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index e247c4296a..f90123431c 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,23 @@
+2000-05-04 NotZed <NotZed@HelixCode.com>
+
+ * message-list.c (message_list_set_folder): Get the whole message
+ summary right away.
+ (folder_changed): And if we change too.
+ (ml_row_count): Use the match count or summary table length as the
+ row count.
+ (get_message_info): Use array references to lookup message summary
+ info. For the search result list, use the summary_search_cache to
+ cache the info lookup.
+ (message_list_init): Allocate the summary search cache.
+ (message_list_destroy): Free the summary search cache and the
+ summary table, if there is one to free.
+ (message_list_set_search): Save the match count, and clear the
+ summary search cache for reuse.
+ (folder_changed): Re-retrieve the summary list if the folder has
+ changed.
+ (message_list_set_folder): Retrieve the summary list when opening
+ the folder.
+
2000-05-03 Jason Leach <leach@wam.umd.edu>
* Makefile.am (evolution_mail_LDADD): s/-lunicode/$(UNICODE_LIBS)/
diff --git a/mail/message-list.c b/mail/message-list.c
index 776d389220..b577650f11 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -59,24 +59,22 @@ CamelMessageInfo *get_message_info(MessageList *message_list, gint row)
{
CamelMessageInfo *info = NULL;
- if (message_list->matches) {
- char *uid;
-
- uid = g_list_nth_data(message_list->matches, row);
- if (uid) {
- info = camel_folder_summary_get_by_uid(message_list->folder, uid);
- } else {
- g_warning("trying to get data for nonexistant row %d", row);
+ if (message_list->search) {
+ if (row<message_list->match_count) {
+ info = message_list->summary_search_cache->pdata[row];
+ if (info == NULL) {
+ char *uid = g_list_nth_data(message_list->matches, row);
+ if (uid) {
+ info = message_list->summary_search_cache->pdata[row] =
+ camel_folder_summary_get_by_uid(message_list->folder, uid);
+ }
+ }
}
} else {
- GPtrArray *msg_info_array;
- msg_info_array = camel_folder_summary_get_message_info
- (message_list->folder, row, 1);
- if (msg_info_array && msg_info_array->len > 0) {
- info = msg_info_array->pdata[0];
- }
- g_ptr_array_free(msg_info_array, TRUE);
+ if (row<message_list->summary_table->len)
+ info = message_list->summary_table->pdata[row];
}
+
return info;
}
@@ -135,21 +133,16 @@ static int
ml_row_count (ETableModel *etm, void *data)
{
MessageList *message_list = data;
- CamelException ex;
int v;
if (!message_list->folder) {
return 0;
}
- if (message_list->matches) {
- v = g_list_length(message_list->matches);
+ if (message_list->search) {
+ v = message_list->match_count;
} else {
- camel_exception_init (&ex);
-
- v = camel_folder_get_message_count (message_list->folder, &ex);
- if (camel_exception_get_id (&ex))
- v = 0;
+ v = message_list->summary_table->len;
}
/* in the case where no message is available, return 1
@@ -544,6 +537,8 @@ message_list_init (GtkObject *object)
*/
gtk_object_ref (GTK_OBJECT (message_list->etable));
gtk_object_sink (GTK_OBJECT (message_list->etable));
+
+ message_list->summary_search_cache = g_ptr_array_new();
}
static void
@@ -567,6 +562,11 @@ message_list_destroy (GtkObject *object)
gtk_object_unref (GTK_OBJECT (message_list->etable));
+ if (message_list->summary_search_cache)
+ g_ptr_array_free(message_list->summary_search_cache, TRUE);
+ if (message_list->summary_table)
+ g_ptr_array_free(message_list->summary_table, TRUE);
+
for (i = 0; i < COL_LAST; i++)
gtk_object_unref (GTK_OBJECT (message_list->table_cols [i]));
@@ -702,6 +702,9 @@ message_list_set_search (MessageList *message_list, const char *search)
camel_exception_init (&ex);
message_list->matches = camel_folder_search_by_expression(message_list->folder, search, &ex);
message_list->search = g_strdup(search);
+ message_list->match_count = g_list_length(message_list->matches);
+ g_ptr_array_set_size(message_list->summary_search_cache, message_list->match_count);
+ memset(message_list->summary_search_cache->pdata, 0, sizeof(message_list->summary_search_cache->pdata[0]) * message_list->match_count);
}
e_table_model_changed (message_list->table_model);
@@ -711,6 +714,10 @@ message_list_set_search (MessageList *message_list, const char *search)
static void
folder_changed(CamelFolder *f, int type, MessageList *message_list)
{
+ if (message_list->summary_table)
+ g_ptr_array_free(message_list->summary_table, TRUE);
+ message_list->summary_table = camel_folder_summary_get_message_info (message_list->folder, 0, INT_MAX);
+
message_list_set_search(message_list, message_list->search);
}
@@ -731,6 +738,10 @@ message_list_set_folder (MessageList *message_list, CamelFolder *camel_folder)
g_list_free(message_list->matches);
message_list->matches = NULL;
}
+
+ if (message_list->summary_table)
+ g_ptr_array_free(message_list->summary_table, TRUE);
+ message_list->summary_table = NULL;
camel_exception_init (&ex);
@@ -772,7 +783,8 @@ message_list_set_folder (MessageList *message_list, CamelFolder *camel_folder)
gtk_signal_connect((GtkObject *)camel_folder, "folder_changed", folder_changed, message_list);
gtk_object_ref (GTK_OBJECT (camel_folder));
-
+
+ message_list->summary_table = camel_folder_summary_get_message_info (message_list->folder, 0, INT_MAX);
e_table_model_changed (message_list->table_model);
select_msg (message_list, 0);
diff --git a/mail/message-list.h b/mail/message-list.h
index 7c1e6bcb5b..f3d6d2fa7f 100644
--- a/mail/message-list.h
+++ b/mail/message-list.h
@@ -59,9 +59,13 @@ struct _MessageList {
CamelFolder *folder;
+ GPtrArray *summary_table; /* the summary of all messages */
+
char *search; /* search string */
/* FIXME: This should use a better format ... */
GList *matches; /* when a search has been performed ... */
+ int match_count;
+ GPtrArray *summary_search_cache; /* summary info cache for searches */
/* used by the idle-call to select a row */
int row_to_select;