diff options
author | bertrand <Bertrand.Guiheneuf@aful.org> | 1999-09-06 00:15:12 +0800 |
---|---|---|
committer | Bertrand Guiheneuf <bertrand@src.gnome.org> | 1999-09-06 00:15:12 +0800 |
commit | 4e4eb45bf69d539996b298a13bf650c5ebea7f16 (patch) | |
tree | 359e98c1b0f050769df800a8e7456db192c03310 | |
parent | 0fe7101224105602a18e63eb83af4611648c9d91 (diff) | |
download | gsoc2013-evolution-4e4eb45bf69d539996b298a13bf650c5ebea7f16.tar.gz gsoc2013-evolution-4e4eb45bf69d539996b298a13bf650c5ebea7f16.tar.zst gsoc2013-evolution-4e4eb45bf69d539996b298a13bf650c5ebea7f16.zip |
use folder summary instead of opening all messages.
1999-09-05 bertrand <Bertrand.Guiheneuf@aful.org>
* tests/ui-tests/store_listing.c (show_folder_messages):
use folder summary instead of opening all messages.
* camel/providers/MH/camel-mh-folder.c (_create_summary):
basic and highly non-efficient summary implementation.
Should be seen as a proof of concept only.
subfolder summary still has to be implemented.
* camel/providers/maildir/camel-maildir-folder.c (_init_with_store):
hasn't summary for the moment.
* camel/providers/maildir/camel-maildir-folder.c
cosmetic changes.
svn path=/trunk/; revision=1178
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | camel/camel-folder.c | 13 | ||||
-rw-r--r-- | camel/camel-folder.h | 3 | ||||
-rw-r--r-- | camel/providers/MH/camel-mh-folder.c | 49 | ||||
-rw-r--r-- | camel/providers/maildir/camel-maildir-folder.c | 374 | ||||
-rw-r--r-- | tests/ui-tests/store_listing.c | 45 |
6 files changed, 320 insertions, 180 deletions
@@ -1,3 +1,19 @@ +1999-09-05 bertrand <Bertrand.Guiheneuf@aful.org> + + * tests/ui-tests/store_listing.c (show_folder_messages): + use folder summary instead of opening all messages. + + * camel/providers/MH/camel-mh-folder.c (_create_summary): + basic and highly non-efficient summary implementation. + Should be seen as a proof of concept only. + subfolder summary still has to be implemented. + + * camel/providers/maildir/camel-maildir-folder.c (_init_with_store): + hasn't summary for the moment. + * camel/providers/maildir/camel-maildir-folder.c + cosmetic changes. + + 1999-09-04 bertrand <Bertrand.Guiheneuf@aful.org> * camel/providers/MH/camel-mh-folder.c (_create_summary): diff --git a/camel/camel-folder.c b/camel/camel-folder.c index 49c886dc98..1cd3b41dc6 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -167,6 +167,10 @@ _init_with_store (CamelFolder *folder, CamelStore *parent_store) if (folder->parent_store) gtk_object_unref (GTK_OBJECT (folder->parent_store)); folder->parent_store = parent_store; if (parent_store) gtk_object_ref (GTK_OBJECT (parent_store)); + folder->open_mode = FOLDER_OPEN_UNKNOWN; + folder->open_state = FOLDER_CLOSE; + folder->name = NULL; + folder->full_name = NULL; } @@ -187,6 +191,13 @@ _open (CamelFolder *folder, CamelFolderOpenMode mode) } +void camel_folder_open (CamelFolder *folder, CamelFolderOpenMode mode) +{ + CF_CLASS(folder)->open (folder, mode); +} + + + /** * _close:Close a folder. * @folder: @@ -972,7 +983,7 @@ camel_folder_has_summary_capability (CamelFolder *folder) } -const CamelFolderSummary * +CamelFolderSummary * camel_folder_get_summary (CamelFolder *folder) { return folder->summary; diff --git a/camel/camel-folder.h b/camel/camel-folder.h index 4554cb4b0c..0715396ca7 100644 --- a/camel/camel-folder.h +++ b/camel/camel-folder.h @@ -120,6 +120,7 @@ GtkType camel_folder_get_type (void); /* public methods */ CamelFolder *camel_folder_get_folder (CamelFolder *folder, gchar *folder_name); +void camel_folder_open (CamelFolder *folder, CamelFolderOpenMode mode); gboolean camel_folder_create (CamelFolder *folder); gboolean camel_folder_delete (CamelFolder *folder, gboolean recurse); gboolean camel_folder_delete_messages (CamelFolder *folder); @@ -138,7 +139,9 @@ gint camel_folder_get_message_count (CamelFolder *folder); gint camel_folder_append_message (CamelFolder *folder, CamelMimeMessage *message); const GList *camel_folder_list_permanent_flags (CamelFolder *folder); void camel_folder_copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder); + gboolean camel_folder_has_summary_capability (CamelFolder *folder); +CamelFolderSummary *camel_folder_get_summary (CamelFolder *folder); #ifdef __cplusplus diff --git a/camel/providers/MH/camel-mh-folder.c b/camel/providers/MH/camel-mh-folder.c index 300d8366d3..fa6661c722 100644 --- a/camel/providers/MH/camel-mh-folder.c +++ b/camel/providers/MH/camel-mh-folder.c @@ -37,6 +37,7 @@ #include "camel-stream-fs.h" #include "camel-stream-buffered-fs.h" #include "camel-folder-summary.h" +#include "gmime-utils.h" static CamelFolderClass *parent_class=NULL; @@ -46,7 +47,7 @@ static CamelFolderClass *parent_class=NULL; #define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) #define CMHS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass) -static int copy_reg (const char *src_path, const char *dst_path); + static void _set_name(CamelFolder *folder, const gchar *name); static void _init_with_store (CamelFolder *folder, CamelStore *parent_store); static gboolean _exists (CamelFolder *folder); @@ -61,6 +62,9 @@ static void _expunge (CamelFolder *folder); static void _copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder); static void _open (CamelFolder *folder, CamelFolderOpenMode mode); + +/* some utility functions */ +static int copy_reg (const char *src_path, const char *dst_path); static gboolean _is_a_message_file (const gchar *file_name, const gchar *file_path); static void @@ -148,18 +152,51 @@ static void _create_summary (CamelFolder *folder) { CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder); + CamelFolderSummary *summary = folder->summary; CamelMessageInfo *message_info; - CamelFolderSummary *subfolder_info; - + CamelFolderInfo *subfolder_info; + CamelStream *message_stream; GList *file_list = mh_folder->file_name_list; gchar *filename; + gchar *message_fullpath; + gchar *directory_path = mh_folder->directory_path; + GArray *header_array; + Rfc822Header *cur_header; + int i; + + summary = folder->summary; while (file_list) { filename = (gchar *)(file_list->data); message_info = g_new0 (CamelMessageInfo, 1); - message_info->subject = NULL; + message_fullpath = g_strdup_printf ("%s/%s", directory_path, filename); + message_stream = camel_stream_buffered_fs_new_with_name (message_fullpath, + CAMEL_STREAM_BUFFERED_FS_READ); + header_array = get_header_array_from_stream (message_stream); + gtk_object_unref (GTK_OBJECT (message_stream)); + + for (i=0; i<header_array->len; i++) { + cur_header = (Rfc822Header *)header_array->data + i; + if (!g_strcasecmp (cur_header->name, "subject")) { + message_info->subject = cur_header->value; + g_free (cur_header->name); + } else if (!g_strcasecmp (cur_header->name, "sender")) { + message_info->date = cur_header->value; + g_free (cur_header->name); + } else if (!g_strcasecmp (cur_header->name, "date")) { + message_info->date = cur_header->value; + g_free (cur_header->name); + } else { + g_free (cur_header->name); + g_free (cur_header->value); + } + } + g_array_free (header_array, TRUE); + + message_info->UID = NULL; + summary->message_info_list = g_list_append (summary->message_info_list, message_info); file_list = file_list->next; } } @@ -172,7 +209,8 @@ _open (CamelFolder *folder, CamelFolderOpenMode mode) CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder); struct dirent *dir_entry; DIR *dir_handle; - + + if (folder->open_state == FOLDER_OPEN) return; @@ -194,6 +232,7 @@ _open (CamelFolder *folder, CamelFolderOpenMode mode) closedir (dir_handle); + _create_summary (folder); } /** diff --git a/camel/providers/maildir/camel-maildir-folder.c b/camel/providers/maildir/camel-maildir-folder.c index 489fd37009..9b663aa191 100644 --- a/camel/providers/maildir/camel-maildir-folder.c +++ b/camel/providers/maildir/camel-maildir-folder.c @@ -20,6 +20,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ + +/* + * AUTHORS : Jukka Zitting + * + */ + + #include <config.h> #include <sys/stat.h> #include <sys/param.h> @@ -53,131 +60,76 @@ static CamelFolderClass *parent_class=NULL; #define GETMSG "CamelMaildirFolder::get_message" #define NUMMSGS "CamelMaildirFolder::get_message_count" -static DIR * -_xopendir (const gchar *path) -{ - DIR *handle; - g_assert (path); - - handle = opendir (path); - if (!handle) { - CAMEL_LOG_WARNING ("ERROR: opendir (%s);\n", path); - CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", - errno, strerror(errno)); - } - - return handle; -} - -static gboolean -_xstat (const gchar *path, struct stat *buf) -{ - gint stat_error; - g_assert (path); - g_assert (buf); - - stat_error = stat (path, buf); - if (stat_error == 0) { - return TRUE; - } else if (errno == ENOENT) { - buf->st_mode = 0; - return TRUE; - } else { - CAMEL_LOG_WARNING ("ERROR: stat (%s, %p);\n", path, buf); - CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", - errno, strerror(errno)); - return FALSE; - } -} - -static gboolean -_xmkdir (const gchar *path) -{ - g_assert (path); - if (mkdir (path, S_IRWXU) == -1) { - CAMEL_LOG_WARNING ("ERROR: mkdir (%s, S_IRWXU);\n", path); - CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", - errno, strerror(errno)); - return FALSE; - } +static void _init_with_store (CamelFolder *folder, CamelStore *parent_store); +static void _set_name (CamelFolder *folder, const gchar *name); +static gboolean _exists (CamelFolder *folder); +static gboolean _create (CamelFolder *folder); +static gboolean _delete (CamelFolder *folder, gboolean recurse); +static gboolean _delete_messages (CamelFolder *folder); +static CamelMimeMessage *_get_message (CamelFolder *folder, gint number); +static gint _get_message_count (CamelFolder *folder); +static void _expunge (CamelFolder *folder); + +/* fs utility functions */ +static DIR * _xopendir (const gchar *path); +static gboolean _xstat (const gchar *path, struct stat *buf); +static gboolean _xmkdir (const gchar *path); +static gboolean _xlink (const gchar *from, const gchar *to); +static gboolean _xunlink (const gchar *path); +static gboolean _xrmdir (const gchar *path); +/* ** */ - return TRUE; -} - -static gboolean -_xlink (const gchar *from, const gchar *to) +static void +camel_maildir_folder_class_init (CamelMaildirFolderClass *camel_maildir_folder_class) { - g_assert (from); - g_assert (to); + CamelFolderClass *camel_folder_class = + CAMEL_FOLDER_CLASS (camel_maildir_folder_class); - if (link (from, to) == 0) { - return TRUE; - } else { - CAMEL_LOG_WARNING ("ERROR: link (%s, %s);\n", from, to); - CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", - errno, strerror(errno)); - return FALSE; - } + parent_class = gtk_type_class (camel_folder_get_type ()); + + /* virtual method definition */ + /* virtual method overload */ + camel_folder_class->init_with_store = _init_with_store; + camel_folder_class->set_name = _set_name; + camel_folder_class->exists = _exists; + camel_folder_class->create = _create; + camel_folder_class->delete = _delete; + camel_folder_class->delete_messages = _delete_messages; + camel_folder_class->expunge = _expunge; + camel_folder_class->get_message = _get_message; + camel_folder_class->get_message_count = _get_message_count; } -static gboolean -_xunlink (const gchar *path) +GtkType +camel_maildir_folder_get_type (void) { - g_assert (path); - - if (unlink (path) == 0) { - return TRUE; - } else if (errno == ENOENT) { - return TRUE; - } else { - CAMEL_LOG_WARNING ("ERROR: unlink (%s);\n", path); - CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", - errno, strerror(errno)); - return FALSE; + static GtkType camel_maildir_folder_type = 0; + + if (!camel_maildir_folder_type) { + GtkTypeInfo camel_maildir_folder_info = + { + "CamelMaildirFolder", + sizeof (CamelMaildirFolder), + sizeof (CamelMaildirFolderClass), + (GtkClassInitFunc) camel_maildir_folder_class_init, + (GtkObjectInitFunc) NULL, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL, + }; + + camel_maildir_folder_type = + gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_maildir_folder_info); } + + return camel_maildir_folder_type; } -static gboolean -_xrmdir (const gchar *path) -{ - DIR *dir_handle; - struct dirent *dir_entry; - gchar *file; - struct stat statbuf; - g_assert (path); - dir_handle = opendir (path); - if (!dir_handle && errno == ENOENT) { - return TRUE; - } else if (!dir_handle) { - CAMEL_LOG_WARNING ("ERROR: opendir (%s);\n", path); - CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", - errno, strerror(errno)); - return FALSE; - } - while ((dir_entry = readdir (dir_handle))) { - file = g_strconcat (path, G_DIR_SEPARATOR_S, dir_entry->d_name, - NULL); - if (_xstat (file, &statbuf) && S_ISREG (statbuf.st_mode)) - _xunlink (file); - g_free (file); - } - closedir (dir_handle); - if (rmdir (path) == 0) { - return TRUE; - } else if (errno == ENOENT) { - return TRUE; - } else { - CAMEL_LOG_WARNING ("ERROR: rmdir (%s);\n", path); - CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", - errno, strerror(errno)); - return FALSE; - } -} /** * CamelMaildirFolder::init_with_store: initializes the folder object @@ -188,8 +140,8 @@ _xrmdir (const gchar *path) * Perhaps we'll later implement subfolders too... */ static void -camel_maildir_folder_init_with_store (CamelFolder *folder, - CamelStore *parent_store) +_init_with_store (CamelFolder *folder, + CamelStore *parent_store) { CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::init_with_store\n"); g_assert(folder); @@ -200,6 +152,7 @@ camel_maildir_folder_init_with_store (CamelFolder *folder, folder->can_hold_messages = TRUE; folder->can_hold_folders = FALSE; + folder->has_summary_capability = FALSE; CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::init_with_store\n"); } @@ -213,7 +166,7 @@ camel_maildir_folder_init_with_store (CamelFolder *folder, * the given name is not checked in this function. */ static void -camel_maildir_folder_set_name (CamelFolder *folder, const gchar *name) +_set_name (CamelFolder *folder, const gchar *name) { CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER (folder); @@ -250,7 +203,7 @@ camel_maildir_folder_set_name (CamelFolder *folder, const gchar *name) * Return value: TRUE if the maildir exists, FALSE otherwise */ static gboolean -camel_maildir_folder_exists (CamelFolder *folder) +_exists (CamelFolder *folder) { CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER (folder); static const gchar *dir[3] = { "new", "cur", "tmp" }; @@ -303,7 +256,7 @@ camel_maildir_folder_exists (CamelFolder *folder) * FALSE otherwise */ static gboolean -camel_maildir_folder_create (CamelFolder *folder) +_create (CamelFolder *folder) { CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER (folder); static const gchar *dir[3] = { "new", "cur", "tmp" }; @@ -354,7 +307,7 @@ camel_maildir_folder_create (CamelFolder *folder) * maildir directory won't be removed, but it might no longer be a valid maildir. */ static gboolean -camel_maildir_folder_delete (CamelFolder *folder, gboolean recurse) +_delete (CamelFolder *folder, gboolean recurse) { CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER (folder); static const gchar *dir[3] = { "new", "cur", "tmp" }; @@ -412,7 +365,7 @@ camel_maildir_folder_delete (CamelFolder *folder, gboolean recurse) * TRUE otherwise. */ static gboolean -camel_maildir_folder_delete_messages (CamelFolder *folder) +_delete_messages (CamelFolder *folder) { CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER (folder); const gchar *maildir; @@ -469,7 +422,7 @@ camel_maildir_folder_delete_messages (CamelFolder *folder) * Return value: the message, NULL on error */ static CamelMimeMessage * -camel_maildir_folder_get_message (CamelFolder *folder, gint number) +_get_message (CamelFolder *folder, gint number) { CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER(folder); DIR *dir_handle; @@ -540,7 +493,7 @@ camel_maildir_folder_get_message (CamelFolder *folder, gint number) * Return value: number of messages in the maildir, -1 on error */ static gint -camel_maildir_folder_get_message_count (CamelFolder *folder) +_get_message_count (CamelFolder *folder) { CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER(folder); const gchar *maildir; @@ -599,6 +552,9 @@ camel_maildir_folder_get_message_count (CamelFolder *folder) return count; } + + + /** * CamelMaildirFolder::expunge: expunge messages marked as deleted * @folder: the folder object @@ -606,7 +562,7 @@ camel_maildir_folder_get_message_count (CamelFolder *folder) * Physically deletes the messages marked as deleted in the folder. */ static void -camel_maildir_folder_expunge (CamelFolder *folder) +_expunge (CamelFolder *folder) { CamelMimeMessage *message; GList *node; @@ -648,54 +604,142 @@ camel_maildir_folder_expunge (CamelFolder *folder) CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::expunge\n"); } -static void -camel_maildir_folder_class_init ( - CamelMaildirFolderClass *camel_maildir_folder_class) + + + + + + +/* + * fs utility function + * + */ + +static DIR * +_xopendir (const gchar *path) { - CamelFolderClass *camel_folder_class = - CAMEL_FOLDER_CLASS (camel_maildir_folder_class); + DIR *handle; + g_assert (path); - parent_class = gtk_type_class (camel_folder_get_type ()); - - /* virtual method definition */ - /* virtual method overload */ - camel_folder_class-> - init_with_store = camel_maildir_folder_init_with_store; - camel_folder_class->set_name = camel_maildir_folder_set_name; - camel_folder_class->exists = camel_maildir_folder_exists; - camel_folder_class->create = camel_maildir_folder_create; - camel_folder_class->delete = camel_maildir_folder_delete; - camel_folder_class-> - delete_messages = camel_maildir_folder_delete_messages; - camel_folder_class->expunge = camel_maildir_folder_expunge; - camel_folder_class-> - get_message = camel_maildir_folder_get_message; - camel_folder_class-> - get_message_count = camel_maildir_folder_get_message_count; + handle = opendir (path); + if (!handle) { + CAMEL_LOG_WARNING ("ERROR: opendir (%s);\n", path); + CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", + errno, strerror(errno)); + } + + return handle; } -GtkType -camel_maildir_folder_get_type (void) +static gboolean +_xstat (const gchar *path, struct stat *buf) { - static GtkType camel_maildir_folder_type = 0; - - if (!camel_maildir_folder_type) { - GtkTypeInfo camel_maildir_folder_info = - { - "CamelMaildirFolder", - sizeof (CamelMaildirFolder), - sizeof (CamelMaildirFolderClass), - (GtkClassInitFunc) camel_maildir_folder_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_maildir_folder_type = - gtk_type_unique (CAMEL_FOLDER_TYPE, - &camel_maildir_folder_info); + gint stat_error; + g_assert (path); + g_assert (buf); + + stat_error = stat (path, buf); + if (stat_error == 0) { + return TRUE; + } else if (errno == ENOENT) { + buf->st_mode = 0; + return TRUE; + } else { + CAMEL_LOG_WARNING ("ERROR: stat (%s, %p);\n", path, buf); + CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", + errno, strerror(errno)); + return FALSE; + } +} + +static gboolean +_xmkdir (const gchar *path) +{ + g_assert (path); + + if (mkdir (path, S_IRWXU) == -1) { + CAMEL_LOG_WARNING ("ERROR: mkdir (%s, S_IRWXU);\n", path); + CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", + errno, strerror(errno)); + return FALSE; + } + + return TRUE; +} + +static gboolean +_xlink (const gchar *from, const gchar *to) +{ + g_assert (from); + g_assert (to); + + if (link (from, to) == 0) { + return TRUE; + } else { + CAMEL_LOG_WARNING ("ERROR: link (%s, %s);\n", from, to); + CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", + errno, strerror(errno)); + return FALSE; + } +} + +static gboolean +_xunlink (const gchar *path) +{ + g_assert (path); + + if (unlink (path) == 0) { + return TRUE; + } else if (errno == ENOENT) { + return TRUE; + } else { + CAMEL_LOG_WARNING ("ERROR: unlink (%s);\n", path); + CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", + errno, strerror(errno)); + return FALSE; } - - return camel_maildir_folder_type; } + +static gboolean +_xrmdir (const gchar *path) +{ + DIR *dir_handle; + struct dirent *dir_entry; + gchar *file; + struct stat statbuf; + g_assert (path); + + dir_handle = opendir (path); + if (!dir_handle && errno == ENOENT) { + return TRUE; + } else if (!dir_handle) { + CAMEL_LOG_WARNING ("ERROR: opendir (%s);\n", path); + CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", + errno, strerror(errno)); + return FALSE; + } + + while ((dir_entry = readdir (dir_handle))) { + file = g_strconcat (path, G_DIR_SEPARATOR_S, dir_entry->d_name, + NULL); + if (_xstat (file, &statbuf) && S_ISREG (statbuf.st_mode)) + _xunlink (file); + g_free (file); + } + + closedir (dir_handle); + + if (rmdir (path) == 0) { + return TRUE; + } else if (errno == ENOENT) { + return TRUE; + } else { + CAMEL_LOG_WARNING ("ERROR: rmdir (%s);\n", path); + CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", + errno, strerror(errno)); + return FALSE; + } +} + +/** *** **/ + diff --git a/tests/ui-tests/store_listing.c b/tests/ui-tests/store_listing.c index 526bd3c9f7..ca69985221 100644 --- a/tests/ui-tests/store_listing.c +++ b/tests/ui-tests/store_listing.c @@ -14,6 +14,7 @@ #include "camel-mh-folder.h" #include "camel-mh-store.h" #include "camel.h" +#include "camel-folder-summary.h" static GladeXML *xml; static CamelSession *_session; @@ -132,19 +133,22 @@ show_folder_messages (CamelFolder *folder) const gchar *clist_row_text[3]; const char *sent_date, *subject, *sender; gint current_row; + CamelFolderSummary *summary; message_clist = glade_xml_get_widget (xml, "message-clist"); /* clear old message list */ gtk_clist_clear (GTK_CLIST (message_clist)); - + +#if 0 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); + 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); if (sent_date) clist_row_text [0] = sent_date; @@ -158,12 +162,32 @@ show_folder_messages (CamelFolder *folder) gtk_clist_set_row_data_full (GTK_CLIST (message_clist), current_row, (gpointer)message, message_destroy_notify); } - - +#endif + + if (camel_folder_has_summary_capability (folder)) { + const GList *message_info_list; + CamelMessageInfo *msg_info; + + printf ("Folder has summary. Good\n"); + summary = camel_folder_get_summary (folder); + message_info_list = camel_folder_summary_get_message_info_list (summary); + printf ("message_info_list = %p\n", message_info_list); + while (message_info_list) { + msg_info = (CamelMessageInfo *)message_info_list->data; + clist_row_text [0] = msg_info->date; + clist_row_text [1] = msg_info->sender; + clist_row_text [2] = msg_info->subject; + printf ("New message : subject = %s\n", msg_info->subject); + current_row = gtk_clist_append (GTK_CLIST (message_clist), clist_row_text); + + message_info_list = message_info_list->next; + } + } else { + printf ("Folder does not have summary. Skipping\n"); + } } - /* add a mail store given by its URL */ static void add_mail_store (const gchar *store_url) @@ -200,10 +224,13 @@ add_mail_store (const gchar *store_url) /* normally, use get_root_folder */ root_folder = camel_store_get_folder (store, ""); + camel_folder_open (root_folder, FOLDER_OPEN_RW); subfolder_list = camel_folder_list_subfolders (root_folder); while (subfolder_list) { new_tree_text[0] = subfolder_list->data; new_folder = camel_store_get_folder (store, subfolder_list->data); + camel_folder_open (new_folder, FOLDER_OPEN_RW); + new_folder_node = gtk_ctree_insert_node (GTK_CTREE (mailbox_and_store_tree), new_store_node, NULL, |