diff options
author | bertrand <Bertrand.Guiheneuf@aful.org> | 1999-09-08 07:08:03 +0800 |
---|---|---|
committer | Bertrand Guiheneuf <bertrand@src.gnome.org> | 1999-09-08 07:08:03 +0800 |
commit | ed7fc1eaa25aaa22652279986a994869fd1d6445 (patch) | |
tree | d1bc3b749189941f03b0cc616a8a21dbb55b5018 | |
parent | dba244cf65b620c514c94ffc3165836c28002a29 (diff) | |
download | gsoc2013-evolution-ed7fc1eaa25aaa22652279986a994869fd1d6445.tar gsoc2013-evolution-ed7fc1eaa25aaa22652279986a994869fd1d6445.tar.gz gsoc2013-evolution-ed7fc1eaa25aaa22652279986a994869fd1d6445.tar.bz2 gsoc2013-evolution-ed7fc1eaa25aaa22652279986a994869fd1d6445.tar.lz gsoc2013-evolution-ed7fc1eaa25aaa22652279986a994869fd1d6445.tar.xz gsoc2013-evolution-ed7fc1eaa25aaa22652279986a994869fd1d6445.tar.zst gsoc2013-evolution-ed7fc1eaa25aaa22652279986a994869fd1d6445.zip |
More work on UID list in Mh provider.
1999-09-08 bertrand <Bertrand.Guiheneuf@aful.org>
* tests/ui-tests/store_listing.c (close_all):
close all open folders and stores. (necessary
for UID list saving ).
* camel/providers/MH/mh-uid.c (mh_generate_uid_list):
fix: store UID list in CamelMHFolder object.
* camel/providers/MH/camel-mh-folder.c (_open):
read or create UID list.
(_close): save UID list.
svn path=/trunk/; revision=1192
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | camel/providers/MH/camel-mh-folder.c | 7 | ||||
-rw-r--r-- | camel/providers/MH/mh-uid.c | 59 | ||||
-rw-r--r-- | tests/ui-tests/store_listing.c | 27 |
4 files changed, 84 insertions, 22 deletions
@@ -1,3 +1,16 @@ +1999-09-08 bertrand <Bertrand.Guiheneuf@aful.org> + + * tests/ui-tests/store_listing.c (close_all): + close all open folders and stores. (necessary + for UID list saving ). + + * camel/providers/MH/mh-uid.c (mh_generate_uid_list): + fix: store UID list in CamelMHFolder object. + + * camel/providers/MH/camel-mh-folder.c (_open): + read or create UID list. + (_close): save UID list. + 1999-09-07 bertrand <Bertrand.Guiheneuf@aful.org> * camel/md5-utils.c (md5_get_digest_from_file): diff --git a/camel/providers/MH/camel-mh-folder.c b/camel/providers/MH/camel-mh-folder.c index 272090fa0e..1afc441cad 100644 --- a/camel/providers/MH/camel-mh-folder.c +++ b/camel/providers/MH/camel-mh-folder.c @@ -62,6 +62,7 @@ static gint _append_message (CamelFolder *folder, CamelMimeMessage *message); static void _expunge (CamelFolder *folder); static void _copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder); static void _open (CamelFolder *folder, CamelFolderOpenMode mode); +static void _close (CamelFolder *folder, gboolean expunge); /* some utility functions */ @@ -88,6 +89,7 @@ camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class) camel_folder_class->expunge = _expunge; camel_folder_class->copy_message_to = _copy_message_to; camel_folder_class->open = _open; + camel_folder_class->close = _close; } @@ -235,7 +237,7 @@ _open (CamelFolder *folder, CamelFolderOpenMode mode) _create_summary (folder); /* get (or create) uid list */ - if (!mh_load_uid_list (mh_folder)) + if (!(mh_load_uid_list (mh_folder) > 0)) mh_generate_uid_list (mh_folder); } @@ -245,10 +247,9 @@ static void _close (CamelFolder *folder, gboolean expunge) { CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder); - if (mh_folder->uid_array) mh_save_uid_list (mh_folder); - + /* call parent implementation */ parent_class->close (folder, expunge); } diff --git a/camel/providers/MH/mh-uid.c b/camel/providers/MH/mh-uid.c index b112caa003..f0a3e93417 100644 --- a/camel/providers/MH/mh-uid.c +++ b/camel/providers/MH/mh-uid.c @@ -88,20 +88,27 @@ mh_save_uid_list (CamelMhFolder *mh_folder) gchar *uidfile_path; int fd; int i; - + + uidfile_path = g_strdup_printf ("%s/%s", directory_path, ".camel-uid-list"); + CAMEL_LOG_FULL_DEBUG ("In the process of writing %s\n", uidfile_path); fd = open (uidfile_path, O_WRONLY | O_CREAT ); + + if (!fd) { + CAMEL_LOG_FULL_DEBUG ("could not open file %s for writing. Exiting.\n", uidfile_path); + g_free (uidfile_path); + return; + } g_free (uidfile_path); - if (!fd) return; uid_array = mh_folder->uid_array; first_uid_couple = (MhUidCouple *)uid_array->data; /* write the number of uid contained in the file */ - write (fd, &(uid_array->len), sizeof (uid_array->len)); - + write (fd, &(uid_array->len), sizeof (guint)); + CAMEL_LOG_FULL_DEBUG ("%d entrie present in the list\n", uid_array->len); /* now write the array of uid self */ - write (fd, first_uid_couple, sizeof (first_uid_couple) * uid_array->len); + write (fd, first_uid_couple, sizeof (MhUidCouple) * uid_array->len); close (fd); } @@ -116,22 +123,36 @@ mh_load_uid_list (CamelMhFolder *mh_folder) gchar *uidfile_path; int fd; guint uid_nb; - + struct stat stat_buf; + gint stat_error = 0; + uidfile_path = g_strdup_printf ("%s/%s", directory_path, ".camel-uid-list"); + + /* tests if file exists */ + stat_error = stat (uidfile_path, &stat_buf); + + + if (!((stat_error != -1) && S_ISREG (stat_buf.st_mode))) { + CAMEL_LOG_FULL_DEBUG ("file %s does not exist. Exiting.\n", uidfile_path); + g_free (uidfile_path); + return -1; + } + fd = open (uidfile_path, O_RDONLY); g_free (uidfile_path); if (!fd) return -1; - + if (mh_folder->uid_array) g_array_free (mh_folder->uid_array, FALSE); - read (fd, &uid_nb, sizeof (uid_nb)); - + /* read the number of uids in the file */ + read (fd, &uid_nb, sizeof (guint)); + CAMEL_LOG_FULL_DEBUG ("reading %d uid_entries\n", uid_nb); new_uid_array = g_array_new (FALSE, FALSE, sizeof (MhUidCouple)); new_uid_array = g_array_set_size (new_uid_array, uid_nb); first_uid_couple = (MhUidCouple *)new_uid_array->data; - /* read the number of uids in the file */ - read (fd, first_uid_couple, sizeof (first_uid_couple) * uid_nb); + + read (fd, first_uid_couple, sizeof (MhUidCouple) * uid_nb); mh_folder->uid_array = new_uid_array; @@ -151,13 +172,19 @@ mh_generate_uid_list (CamelMhFolder *mh_folder) MhUidCouple *uid_couple; guint file_number; - g_assert(mh_folder); - + g_assert (mh_folder); + CAMEL_LOG_FULL_DEBUG ("in the process of creating uid list \n"); directory_path = mh_folder->directory_path; - if (!directory_path) return -1; + if (!directory_path) { + CAMEL_LOG_FULL_DEBUG ("folder has no directory path. Exiting\n"); + return -1; + } msg_count = camel_folder_get_message_count (CAMEL_FOLDER (mh_folder)); - if (!msg_count) return -1; + if (!msg_count) { + CAMEL_LOG_FULL_DEBUG ("no message in %s. Exiting\n", directory_path); + return -1; + } new_uid_array = g_array_new (FALSE, FALSE, sizeof (MhUidCouple)); new_uid_array = g_array_set_size (new_uid_array, msg_count); @@ -187,5 +214,5 @@ mh_generate_uid_list (CamelMhFolder *mh_folder) } closedir (dir_handle); - + mh_folder->uid_array = new_uid_array; } diff --git a/tests/ui-tests/store_listing.c b/tests/ui-tests/store_listing.c index dc845597b7..fb7c2ae0f7 100644 --- a/tests/ui-tests/store_listing.c +++ b/tests/ui-tests/store_listing.c @@ -20,6 +20,9 @@ static GladeXML *xml; static CamelSession *_session; static CamelFolder *currently_selected_folder = NULL; +static GList *store_list; +static GList *folder_list; + static void add_mail_store (const gchar *store_url); static void show_folder_messages (CamelFolder *folder); @@ -153,7 +156,7 @@ show_folder_messages (CamelFolder *folder) 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; @@ -204,6 +207,9 @@ add_mail_store (const gchar *store_url) store = camel_session_get_store (_session, store_url); if (!store) return; + /* remember store */ + store_list = g_list_prepend (store_list, store); + //store_list = g_list_append (store_list, (gpointer)store); mailbox_and_store_tree = glade_xml_get_widget (xml, "store-and-mailbox-tree"); new_tree_text[0] = g_strdup (store_url); @@ -227,6 +233,7 @@ add_mail_store (const gchar *store_url) 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); + folder_list = g_list_prepend (folder_list, new_folder); new_folder_node = gtk_ctree_insert_node (GTK_CTREE (mailbox_and_store_tree), new_store_node, @@ -244,8 +251,6 @@ add_mail_store (const gchar *store_url) gtk_ctree_node_set_row_data (GTK_CTREE (mailbox_and_store_tree), new_folder_node, (gpointer)new_folder); subfolder_list = subfolder_list->next; } - - } static void @@ -305,10 +310,26 @@ expunge_selected_folders () } +void +close_all () +{ + while (folder_list) { + camel_folder_close (CAMEL_FOLDER (folder_list->data), TRUE); + folder_list = folder_list->next; + } + + while (store_list) { + //camel_store_close (CAMEL_STORE (store_list->data)); + store_list = store_list->next; + } + +} + /* ----- libglade callbacks */ void on_exit_activate (GtkWidget *widget, void *data) { + close_all (); gtk_main_quit (); } |