aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>1999-08-16 04:40:11 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-08-16 04:40:11 +0800
commitfb5218e3532444f4d4d9a4bb96186bdf6b0e6107 (patch)
treece5993fbbec1d803ceb8e4a13ef46332737176ed
parent1755ff603bff086a19b3fbb39adc5f8022640159 (diff)
downloadgsoc2013-evolution-fb5218e3532444f4d4d9a4bb96186bdf6b0e6107.tar
gsoc2013-evolution-fb5218e3532444f4d4d9a4bb96186bdf6b0e6107.tar.gz
gsoc2013-evolution-fb5218e3532444f4d4d9a4bb96186bdf6b0e6107.tar.bz2
gsoc2013-evolution-fb5218e3532444f4d4d9a4bb96186bdf6b0e6107.tar.lz
gsoc2013-evolution-fb5218e3532444f4d4d9a4bb96186bdf6b0e6107.tar.xz
gsoc2013-evolution-fb5218e3532444f4d4d9a4bb96186bdf6b0e6107.tar.zst
gsoc2013-evolution-fb5218e3532444f4d4d9a4bb96186bdf6b0e6107.zip
moved the active list readjustment code here. Much saner, providers won't
1999-08-15 bertrand <Bertrand.Guiheneuf@aful.org> * camel/camel-folder.c (camel_folder_expunge): moved the active list readjustment code here. Much saner, providers won't have to worry about that. * camel/providers/MH/camel-mh-folder.c (_expunge): no more active list readjustment stuff. * camel/camel-folder.h: the expunge virtual no more returns a list of expunged messages. Now providers only have to set the expunge flag on the expunged messages. * camel/camel-folder.c (camel_folder_get_message): moved the caching code here. Finally, I don't want providers to crash the libs with a bad message cache implementation. (_close): do not call the CamelFolder virtual expunge method directly, use camel_folder_expunge() instead. (camel_folder_expunge): added the want_list param. The client can decide if it wants the expunged message list or not. If yes, it'll have to unref the messages itself. svn path=/trunk/; revision=1117
-rw-r--r--ChangeLog26
-rw-r--r--camel/camel-folder.c121
-rw-r--r--camel/camel-folder.h4
-rw-r--r--camel/providers/MH/camel-mh-folder.c73
-rw-r--r--tests/ui-tests/store_listing.c10
-rw-r--r--tests/ui-tests/store_listing.glade3
6 files changed, 141 insertions, 96 deletions
diff --git a/ChangeLog b/ChangeLog
index d5436f54f5..218efecd06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+1999-08-15 bertrand <Bertrand.Guiheneuf@aful.org>
+
+ * camel/camel-folder.c (camel_folder_expunge):
+ moved the active list readjustment code here.
+ Much saner, providers won't have to worry about
+ that.
+
+ * camel/providers/MH/camel-mh-folder.c (_expunge):
+ no more active list readjustment stuff.
+
+ * camel/camel-folder.h: the expunge virtual no more
+ returns a list of expunged messages. Now providers
+ only have to set the expunge flag on the expunged
+ messages.
+
+ * camel/camel-folder.c (camel_folder_get_message):
+ moved the caching code here. Finally, I don't want
+ providers to crash the libs with a bad message cache
+ implementation.
+ (_close): do not call the CamelFolder virtual expunge
+ method directly, use camel_folder_expunge() instead.
+ (camel_folder_expunge): added the want_list param.
+ The client can decide if it wants the expunged message
+ list or not. If yes, it'll have to unref the messages
+ itself.
+
1999-08-14 bertrand <Bertrand.Guiheneuf@aful.org>
* tests/ui-tests/store_listing.c (delete_selected_messages):
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index ef09b061e1..d701345dad 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -49,7 +49,7 @@ static CamelFolder *_get_parent_folder (CamelFolder *folder);
static CamelStore *_get_parent_store (CamelFolder *folder);
static CamelFolderOpenMode _get_mode (CamelFolder *folder);
static GList *_list_subfolders (CamelFolder *folder);
-static GList *_expunge (CamelFolder *folder);
+static void _expunge (CamelFolder *folder);
static CamelMimeMessage *_get_message (CamelFolder *folder, gint number);
static gint _get_message_count (CamelFolder *folder);
static gint _append_message (CamelFolder *folder, CamelMimeMessage *message);
@@ -196,7 +196,7 @@ _open (CamelFolder *folder, CamelFolderOpenMode mode)
static void
_close (CamelFolder *folder, gboolean expunge)
{
- if (expunge) CF_CLASS(folder)->expunge(folder);
+ if (expunge) camel_folder_expunge (folder, FALSE);
folder->open_state = FOLDER_CLOSE;
}
@@ -747,12 +747,21 @@ camel_folder_list_subfolders (CamelFolder *folder)
-static GList *
+static void
_expunge (CamelFolder *folder)
{
- return NULL;
+
}
+/* util func. Should not stay here */
+gint
+camel_mime_message_number_cmp (gconstpointer a, gconstpointer b)
+{
+ CamelMimeMessage *m_a = CAMEL_MIME_MESSAGE (a);
+ CamelMimeMessage *m_b = CAMEL_MIME_MESSAGE (b);
+
+ return (m_a->message_number - (m_b->message_number));
+}
/**
* camel_folder_expunge: physically delete messages marked as "DELETED"
@@ -764,9 +773,59 @@ _expunge (CamelFolder *folder)
* Return value: list of expunged message objects.
**/
GList *
-camel_folder_expunge (CamelFolder *folder)
+camel_folder_expunge (CamelFolder *folder, gboolean want_list)
{
- return CF_CLASS (folder)->expunge (folder);
+ GList *expunged_list = NULL;
+ CamelMimeMessage *message;
+ GList *message_node;
+ GList *next_message_node;
+ guint nb_expunged = 0;
+
+
+ /* sort message list by ascending message number */
+ if (folder->message_list)
+ folder->message_list = g_list_sort (folder->message_list, camel_mime_message_number_cmp);
+
+ /* call provider method,
+ * PROVIDERS MUST SET THE EXPUNGED FLAGS TO TRUE
+ * when they expunge a message of the active message list */
+ CF_CLASS (folder)->expunge (folder);
+
+ message_node = folder->message_list;
+
+ /* look in folder message list which messages
+ * need to be expunged */
+ while ( message_node) {
+ message = CAMEL_MIME_MESSAGE (message_node->data);
+
+ /* we may free message_node so get the next node now */
+ next_message_node = message_node->next;
+
+ if (message) {
+ CAMEL_LOG_FULL_DEBUG ("CamelFolder::expunge, examining message %d\n", message->message_number);
+ if (message->expunged) {
+ if (want_list)
+ expunged_list = g_list_append (expunged_list, message);
+ /* remove the message from active message list */
+ g_list_remove_link (folder->message_list, message_node);
+ g_list_free_1 (message_node);
+ nb_expunged++;
+ } else {
+ /* readjust message number */
+ CAMEL_LOG_FULL_DEBUG ("CamelFolder:: Readjusting message number %d",
+ message->message_number);
+ message->message_number -= nb_expunged;
+ CAMEL_LOG_FULL_DEBUG (" to %d\n", message->message_number);
+ }
+ }
+ else {
+ CAMEL_LOG_WARNING ("CamelFolder::expunge warning message_node contains no message\n");
+ }
+ message_node = next_message_node;
+ CAMEL_LOG_FULL_DEBUG ("CamelFolder::expunge, examined message node %p\n", message_node);
+ }
+
+ return expunged_list;
}
@@ -774,6 +833,24 @@ camel_folder_expunge (CamelFolder *folder)
static CamelMimeMessage *
_get_message (CamelFolder *folder, gint number)
{
+ return NULL;
+}
+
+
+
+
+/**
+ * _get_message: return the message corresponding to that number in the folder
+ * @folder: a CamelFolder object
+ * @number: the number of the message within the folder.
+ *
+ * Return the message corresponding to that number within the folder.
+ *
+ * Return value: A pointer on the corresponding message or NULL if no corresponding message exists
+ **/
+CamelMimeMessage *
+camel_folder_get_message (CamelFolder *folder, gint number)
+{
CamelMimeMessage *a_message;
CamelMimeMessage *new_message = NULL;
GList *message_node;
@@ -803,38 +880,14 @@ _get_message (CamelFolder *folder, gint number)
CAMEL_LOG_FULL_DEBUG ("CamelFolder::get_message message node = %p\n", message_node);
}
- return new_message;
-}
-
-
-
-
-/**
- * _get_message: return the message corresponding to that number in the folder
- * @folder: a CamelFolder object
- * @number: the number of the message within the folder.
- *
- * Return the message corresponding to that number within the folder.
- *
- * Return value: A pointer on the corresponding message or NULL if no corresponding message exists
- **/
-CamelMimeMessage *
-camel_folder_get_message (CamelFolder *folder, gint number)
-{
- CamelMimeMessage *new_message;
- new_message = CF_CLASS (folder)->get_message (folder, number);
-
-
- /* now put the new message in the list of messages got from
- * this folder. If people show concerns about this code being
- * here, we will let the providers do it by themself
- * Update: I am actually concern. This will go into util routines
- * and providers will have to do the job themself :) */
+ if (!new_message) new_message = CF_CLASS (folder)->get_message (folder, number);
if (!new_message) return NULL;
+
/* if the message has not been already put in
- * this folder message list, put it in */
+ * this folder active message list, put it in */
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;
}
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index 724a03d524..4ec63a65f7 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -100,7 +100,7 @@ typedef struct {
CamelStore * (*get_parent_store) (CamelFolder *folder);
CamelFolderOpenMode (*get_mode) (CamelFolder *folder);
GList * (*list_subfolders) (CamelFolder *folder);
- GList * (*expunge) (CamelFolder *folder);
+ void (*expunge) (CamelFolder *folder);
CamelMimeMessage * (*get_message) (CamelFolder *folder, gint number);
gint (*get_message_count) (CamelFolder *folder);
gint (*append_message) (CamelFolder *folder, CamelMimeMessage *message);
@@ -124,7 +124,7 @@ CamelFolder *camel_folder_get_parent_folder (CamelFolder *folder);
CamelStore *camel_folder_get_parent_store (CamelFolder *folder);
CamelFolderOpenMode camel_folder_get_mode (CamelFolder *folder);
GList *camel_folder_list_subfolders (CamelFolder *folder);
-GList *camel_folder_expunge (CamelFolder *folder);
+GList *camel_folder_expunge (CamelFolder *folder, gboolean want_list);
void camel_folder_set_name (CamelFolder *folder, const gchar *name);
const gchar *camel_folder_get_name (CamelFolder *folder);
/* void camel_folder_set_full_name (CamelFolder *folder, const gchar *name); */
diff --git a/camel/providers/MH/camel-mh-folder.c b/camel/providers/MH/camel-mh-folder.c
index 4b91d5bc2d..c47a18e1ec 100644
--- a/camel/providers/MH/camel-mh-folder.c
+++ b/camel/providers/MH/camel-mh-folder.c
@@ -52,7 +52,7 @@ static GList *_list_subfolders (CamelFolder *folder);
static CamelMimeMessage *_get_message (CamelFolder *folder, gint number);
static gint _get_message_count (CamelFolder *folder);
static gint _append_message (CamelFolder *folder, CamelMimeMessage *message);
-static GList *_expunge (CamelFolder *folder);
+static void _expunge (CamelFolder *folder);
static void
@@ -421,8 +421,6 @@ _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;
@@ -573,17 +571,9 @@ _append_message (CamelFolder *folder, CamelMimeMessage *message)
-gint
-camel_mime_message_number_cmp (gconstpointer a, gconstpointer b)
-{
- CamelMimeMessage *m_a = CAMEL_MIME_MESSAGE (a);
- CamelMimeMessage *m_b = CAMEL_MIME_MESSAGE (b);
-
- return (m_a->message_number - (m_b->message_number));
-}
-static GList *
+static void
_expunge (CamelFolder *folder)
{
/* For the moment, we look in the folder active message
@@ -591,67 +581,38 @@ _expunge (CamelFolder *folder)
* the gtk_object->destroy signal be used to expunge
* freed messages objects marked DELETED ?
*/
- GList *expunged_list = NULL;
CamelMimeMessage *message;
GList *message_node;
- GList *next_message_node;
gchar *fullpath;
gint unlink_error;
- guint nb_expunged = 0;
CAMEL_LOG_FULL_DEBUG ("Entering CamelFolder::expunge\n");
- /* sort message list by ascending message number */
- if (folder->message_list)
- folder->message_list = g_list_sort (folder->message_list, camel_mime_message_number_cmp);
-
message_node = folder->message_list;
/* look in folder message list which messages
* need to be expunged */
while ( message_node) {
message = CAMEL_MIME_MESSAGE (message_node->data);
-
- /* we may free message_node so get the next node now */
- next_message_node = message_node->next;
-
- if (message) {
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::expunge, examining message %d\n", message->message_number);
- if (camel_mime_message_get_flag (message, "DELETED")) {
- /* expunge the message */
- fullpath = gtk_object_get_data (GTK_OBJECT (message), "fullpath");
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::expunge, message fullpath is %s\n",
- fullpath);
- unlink_error = unlink(fullpath);
- if (unlink_error != -1) {
- expunged_list = g_list_append (expunged_list, message);
- message->expunged = TRUE;
- /* remove the message from active message list */
- g_list_remove_link (folder->message_list, message_node);
- g_list_free_1 (message_node);
- nb_expunged++;
- } else {
- CAMEL_LOG_WARNING ("CamelMhFolder:: could not unlink %s (message %d)\n",
- fullpath, message->message_number);
- CAMEL_LOG_FULL_DEBUG (" Full error text is : %s\n", strerror(errno));
- }
-
+
+ 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");
+ CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::expunge, message fullpath is %s\n",
+ fullpath);
+ unlink_error = unlink(fullpath);
+ if (unlink_error != -1) {
+ message->expunged = TRUE;
} else {
- /* readjust message number */
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder:: Readjusting message number %d",
- message->message_number);
- message->message_number -= nb_expunged;
- CAMEL_LOG_FULL_DEBUG (" to %d\n", message->message_number);
+ CAMEL_LOG_WARNING ("CamelMhFolder:: could not unlink %s (message %d)\n",
+ fullpath, message->message_number);
+ CAMEL_LOG_FULL_DEBUG (" Full error text is : %s\n", strerror(errno));
}
}
- else {
- CAMEL_LOG_WARNING ("CamelMhFolder::expunge warning message_node contains no message\n");
-
- }
- message_node = next_message_node;
+ message_node = message_node->next;
CAMEL_LOG_FULL_DEBUG ("CamelFolder::expunge, examined message node %p\n", message_node);
}
-
+
CAMEL_LOG_FULL_DEBUG ("Leaving CamelFolder::expunge\n");
- return expunged_list;
}
diff --git a/tests/ui-tests/store_listing.c b/tests/ui-tests/store_listing.c
index 02a5066164..377c17baf7 100644
--- a/tests/ui-tests/store_listing.c
+++ b/tests/ui-tests/store_listing.c
@@ -198,7 +198,7 @@ expunge_selected_folders ()
if (folder && IS_CAMEL_FOLDER (folder)) {
folder_name = camel_folder_get_name (folder);
printf ("folder to expunge : %s\n", folder_name);
- camel_folder_expunge (folder);
+ camel_folder_expunge (folder, FALSE);
/* reshowing the folder this way is uggly
but allows to check the message are
correctly renoved and the cache works correctly */
@@ -277,7 +277,8 @@ on_message_delete_activate (GtkWidget *widget, void *data)
int
main(int argc, char *argv[])
{
-
+ GtkWidget *new_store_gnome_entry;
+
gnome_init ("store_listing", "1.0", argc, argv);
glade_gnome_init ();
@@ -288,8 +289,11 @@ main(int argc, char *argv[])
_session = camel_session_new ();
camel_provider_register_as_module ("../../camel/providers/MH/.libs/libcamelmh.so");
+ new_store_gnome_entry = glade_xml_get_widget (xml, "new-store-entry");
+ gnome_entry_load_history (GNOME_ENTRY (new_store_gnome_entry));
gtk_main ();
-
+ gnome_entry_save_history (GNOME_ENTRY (new_store_gnome_entry));
+
return 0;
}
diff --git a/tests/ui-tests/store_listing.glade b/tests/ui-tests/store_listing.glade
index 2a90aa327a..34acf37e6f 100644
--- a/tests/ui-tests/store_listing.glade
+++ b/tests/ui-tests/store_listing.glade
@@ -421,7 +421,8 @@
<widget>
<class>GnomeEntry</class>
<name>new-store-entry</name>
- <max_saved>10</max_saved>
+ <history_id>store_name_history</history_id>
+ <max_saved>15</max_saved>
<child>
<padding>0</padding>
<expand>False</expand>