diff options
author | bertrand <Bertrand.Guiheneuf@aful.org> | 1999-09-09 02:59:27 +0800 |
---|---|---|
committer | Bertrand Guiheneuf <bertrand@src.gnome.org> | 1999-09-09 02:59:27 +0800 |
commit | 68ceb01f60817ca7b719f7d2fee25c4ec50f7c5f (patch) | |
tree | 1c36f691b413aa8ddb92a90bd92e210ddb643bbd | |
parent | 13dce8b3355c97c426a3a975bfba5cbae875b9cc (diff) | |
download | gsoc2013-evolution-68ceb01f60817ca7b719f7d2fee25c4ec50f7c5f.tar gsoc2013-evolution-68ceb01f60817ca7b719f7d2fee25c4ec50f7c5f.tar.gz gsoc2013-evolution-68ceb01f60817ca7b719f7d2fee25c4ec50f7c5f.tar.bz2 gsoc2013-evolution-68ceb01f60817ca7b719f7d2fee25c4ec50f7c5f.tar.lz gsoc2013-evolution-68ceb01f60817ca7b719f7d2fee25c4ec50f7c5f.tar.xz gsoc2013-evolution-68ceb01f60817ca7b719f7d2fee25c4ec50f7c5f.tar.zst gsoc2013-evolution-68ceb01f60817ca7b719f7d2fee25c4ec50f7c5f.zip |
Summary files are here and work !!!
1999-09-08 bertrand <Bertrand.Guiheneuf@aful.org>
* camel/providers/MH/mh-summary.c
(mh_load_summary):
(mh_save_summary):
(mh_create_summary):
implemented summary (files) for MH folders.
* camel/providers/MH/camel-mh-folder.c
(_get_message_by_uid): implemented.
(camel_mh_folder_class_init):
(_get_message_uid): implemented
svn path=/trunk/; revision=1219
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | camel/camel-folder-summary.h | 2 | ||||
-rw-r--r-- | camel/camel-folder.c | 3 | ||||
-rw-r--r-- | camel/gstring-util.h | 4 | ||||
-rw-r--r-- | camel/providers/MH/Makefile.am | 2 | ||||
-rw-r--r-- | camel/providers/MH/camel-mh-folder.c | 153 | ||||
-rw-r--r-- | camel/providers/MH/mh-uid.c | 3 | ||||
-rw-r--r-- | camel/string-utils.h | 4 |
8 files changed, 107 insertions, 74 deletions
@@ -1,7 +1,15 @@ 1999-09-08 bertrand <Bertrand.Guiheneuf@aful.org> + * camel/providers/MH/mh-summary.c + (mh_load_summary): + (mh_save_summary): + (mh_create_summary): + implemented summary (files) for MH folders. + * camel/providers/MH/camel-mh-folder.c - (_get_message_by_uid): impemented. + (_get_message_by_uid): implemented. + (camel_mh_folder_class_init): + (_get_message_uid): implemented * camel/camel-folder.c (camel_folder_has_uid_capability): (camel_folder_get_message_uid): diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h index 293dbdb637..e654881cf4 100644 --- a/camel/camel-folder-summary.h +++ b/camel/camel-folder-summary.h @@ -51,7 +51,7 @@ typedef struct { typedef struct { gchar *subject; - gchar *UID; + gchar *uid; gchar *date; gchar *sender; diff --git a/camel/camel-folder.c b/camel/camel-folder.c index 524252da1c..c82541e262 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -1116,7 +1116,8 @@ _get_uid_list (CamelFolder *folder) * get the list of UID available in a folder. This * routine is usefull to know what messages are * available when the folder does not support - * summaries. + * summaries. The UIDs in the list must not be freed, + * the folder object caches them. * * Return value: Glist of UID correspondind to the messages available in the folder. **/ diff --git a/camel/gstring-util.h b/camel/gstring-util.h index 1afdf97cb7..6773537b20 100644 --- a/camel/gstring-util.h +++ b/camel/gstring-util.h @@ -38,14 +38,14 @@ typedef enum { GSTRING_DICHOTOMY_NONE = 0, GSTRING_DICHOTOMY_RIGHT_DIR = 1, GSTRING_DICHOTOMY_STRIP_TRAILING = 2, - GSTRING_DICHOTOMY_STRIP_LEADING = 4, + GSTRING_DICHOTOMY_STRIP_LEADING = 4 } GStringDichotomyOption; typedef enum { GSTRING_TRIM_NONE = 0, GSTRING_TRIM_STRIP_TRAILING = 1, - GSTRING_TRIM_STRIP_LEADING = 2, + GSTRING_TRIM_STRIP_LEADING = 2 } GStringTrimOption; diff --git a/camel/providers/MH/Makefile.am b/camel/providers/MH/Makefile.am index 2442be6912..dab6bec199 100644 --- a/camel/providers/MH/Makefile.am +++ b/camel/providers/MH/Makefile.am @@ -15,12 +15,14 @@ libcamelmh_la_SOURCES = \ camel-mh-folder.c \ camel-mh-provider.c \ camel-mh-store.c \ + mh-summary.c \ mh-uid.c \ mh-utils.c libcamelmhinclude_HEADERS = \ camel-mh-folder.h \ camel-mh-store.h \ + mh-summary.c \ mh-uid.h \ mh-utils.h diff --git a/camel/providers/MH/camel-mh-folder.c b/camel/providers/MH/camel-mh-folder.c index 231c79039a..ee658b52dd 100644 --- a/camel/providers/MH/camel-mh-folder.c +++ b/camel/providers/MH/camel-mh-folder.c @@ -40,6 +40,7 @@ #include "gmime-utils.h" #include "mh-utils.h" #include "mh-uid.h" +#include "mh-summary.h" static CamelFolderClass *parent_class=NULL; @@ -65,6 +66,9 @@ static void _copy_message_to (CamelFolder *folder, CamelMimeMessage *message, Ca static void _open (CamelFolder *folder, CamelFolderOpenMode mode); static void _close (CamelFolder *folder, gboolean expunge); +static const gchar *_get_message_uid (CamelFolder *folder, CamelMimeMessage *message); +static CamelMimeMessage *_get_message_by_uid (CamelFolder *folder, const gchar *uid); +static GList *_get_uid_list (CamelFolder *folder); /* some utility functions */ static int copy_reg (const char *src_path, const char *dst_path); @@ -91,7 +95,10 @@ camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class) camel_folder_class->copy_message_to = _copy_message_to; camel_folder_class->open = _open; camel_folder_class->close = _close; - + camel_folder_class->get_message_uid = _get_message_uid; + camel_folder_class->get_message_by_uid = _get_message_by_uid; + camel_folder_class->get_uid_list = _get_uid_list; + } @@ -146,62 +153,10 @@ _init_with_store (CamelFolder *folder, CamelStore *parent_store) folder->can_hold_messages = TRUE; folder->can_hold_folders = TRUE; folder->has_summary_capability = TRUE; - - folder->summary = camel_folder_summary_new (); -} - - -static void -_create_summary (CamelFolder *folder) -{ - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder); - CamelFolderSummary *summary = folder->summary; - CamelMessageInfo *message_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_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; - } + folder->has_uid_capability = TRUE; + + folder->summary = NULL; + } @@ -235,11 +190,16 @@ _open (CamelFolder *folder, CamelFolderOpenMode mode) closedir (dir_handle); - _create_summary (folder); - /* get (or create) uid list */ if (!(mh_load_uid_list (mh_folder) > 0)) mh_generate_uid_list (mh_folder); + + /* get or create summary */ + /* it is important that it comes after uid list reading/generation */ + if (!(mh_load_summary (mh_folder) > 0)) + mh_generate_summary (folder); + printf ("**** summary = %p\n", folder->summary); + } @@ -248,9 +208,15 @@ static void _close (CamelFolder *folder, gboolean expunge) { CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder); + + /* save uid list, if any */ if (mh_folder->uid_array) mh_save_uid_list (mh_folder); + /* save summary, if any */ + if (folder->summary) + mh_save_summary (mh_folder); + /* call parent implementation */ parent_class->close (folder, expunge); } @@ -277,9 +243,9 @@ _set_name (CamelFolder *folder, const gchar *name) gchar separator; CAMEL_LOG_FULL_DEBUG ("Entering CamelMhFolder::set_name\n"); - g_assert(folder); - g_assert(name); - g_assert(folder->parent_store); + g_assert (folder); + g_assert (name); + g_assert (folder->parent_store); /* call default implementation */ parent_class->set_name (folder, name); @@ -546,8 +512,8 @@ _get_message (CamelFolder *folder, gint number) camel_data_wrapper_construct_from_stream ( CAMEL_DATA_WRAPPER (message), input_stream); gtk_object_unref (GTK_OBJECT (input_stream)); message->message_number = number; - gtk_object_set_data_full (GTK_OBJECT (message), "fullpath", - g_strdup (message_file_name), _filename_free); + gtk_object_set_data_full (GTK_OBJECT (message), "filename", + g_strdup (message_name), _filename_free); #warning Set flags and all this stuff here } @@ -680,15 +646,21 @@ _expunge (CamelFolder *folder) * the gtk_object->destroy signal be used to expunge * freed messages objects marked DELETED ? */ + CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); CamelMimeMessage *message; GList *message_node; gchar *fullpath; + gchar *filename; gint unlink_error; + const gchar *directory_path; CAMEL_LOG_FULL_DEBUG ("Entering CamelFolder::expunge\n"); message_node = folder->message_list; + directory_path = mh_folder->directory_path; + if (!directory_path) return; + /* look in folder message list which messages * need to be expunged */ while ( message_node) { @@ -697,7 +669,8 @@ _expunge (CamelFolder *folder) if (message && camel_mime_message_get_flag (message, "DELETED")) { CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::expunge, expunging message %d\n", message->message_number); /* expunge the message */ - fullpath = gtk_object_get_data (GTK_OBJECT (message), "fullpath"); + filename = gtk_object_get_data (GTK_OBJECT (message), "filename"); + fullpath = g_strdup_printf ("%s/%s", directory_path, filename); CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::expunge, message fullpath is %s\n", fullpath); unlink_error = unlink(fullpath); @@ -744,7 +717,36 @@ _copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *d static const gchar * _get_message_uid (CamelFolder *folder, CamelMimeMessage *message) { + CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder); + GArray *uid_array; + gboolean found = FALSE; + MhUidCouple *uid_couple; + gchar *filename; + guint file_number; + gint i; + + /* if the message already has its uid stored, + return it */ + if (message->message_uid) + return (message->message_uid); + + /* else, it has a filename associated to it */ + filename = gtk_object_get_data (GTK_OBJECT (message), "filename"); + file_number = atoi (file_number); + uid_array = mh_folder->uid_array; + uid_couple = (MhUidCouple *)uid_array->data; + + /* look in the uid array for the file number */ + found = (uid_couple->file_number == file_number); + for (i=0; (i<uid_array->len) && (!found); i++) { + uid_couple++; + found = (uid_couple->file_number == file_number); + } + + if (found) return uid_couple->uid; + else return NULL; + } @@ -801,11 +803,30 @@ _get_message_by_uid (CamelFolder *folder, const gchar *uid) static GList * _get_uid_list (CamelFolder *folder) { - return NULL; + CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder); + GList *uid_list; + GArray *uid_array; + MhUidCouple *uid_couple; + int i; + + uid_array = mh_folder->uid_array; + uid_couple = (MhUidCouple *)uid_array->data; + + for (i=0; i<uid_array->len; i++) { + uid_list = g_list_prepend (uid_list, uid_couple->uid); + uid_couple++; + } + + return uid_list; } + + + + + /************************************************************************/ /*** Took directly from GNU fileutils-4.0 ***/ diff --git a/camel/providers/MH/mh-uid.c b/camel/providers/MH/mh-uid.c index 1c71f10fb6..425cc27697 100644 --- a/camel/providers/MH/mh-uid.c +++ b/camel/providers/MH/mh-uid.c @@ -134,7 +134,8 @@ mh_load_uid_list (CamelMhFolder *mh_folder) if (!((stat_error != -1) && S_ISREG (stat_buf.st_mode))) { - CAMEL_LOG_FULL_DEBUG ("file %s does not exist. Exiting.\n", uidfile_path); + CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::load_uid_list " + "file %s does not exist. Exiting.\n", uidfile_path); g_free (uidfile_path); return -1; } diff --git a/camel/string-utils.h b/camel/string-utils.h index a2457c5de7..e10aeaf6f6 100644 --- a/camel/string-utils.h +++ b/camel/string-utils.h @@ -38,14 +38,14 @@ typedef enum { STRING_DICHOTOMY_NONE = 0, STRING_DICHOTOMY_RIGHT_DIR = 1, STRING_DICHOTOMY_STRIP_TRAILING = 2, - STRING_DICHOTOMY_STRIP_LEADING = 4, + STRING_DICHOTOMY_STRIP_LEADING = 4 } StringDichotomyOption; typedef enum { STRING_TRIM_NONE = 0, STRING_TRIM_STRIP_TRAILING = 1, - STRING_TRIM_STRIP_LEADING = 2, + STRING_TRIM_STRIP_LEADING = 2 } StringTrimOption; gboolean string_equal_for_glist (gconstpointer v, gconstpointer v2); |