aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-folder-utils.c
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>1999-12-16 07:48:23 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-12-16 07:48:23 +0800
commit6bd8382bd68ada82117064bc3576c4b8374cfc04 (patch)
tree67bd3b2019313b7be3c18f12111914eef7f66a61 /camel/camel-folder-utils.c
parent78c9c2b070f74e18a7a676984e3ce633300c335d (diff)
downloadgsoc2013-evolution-6bd8382bd68ada82117064bc3576c4b8374cfc04.tar
gsoc2013-evolution-6bd8382bd68ada82117064bc3576c4b8374cfc04.tar.gz
gsoc2013-evolution-6bd8382bd68ada82117064bc3576c4b8374cfc04.tar.bz2
gsoc2013-evolution-6bd8382bd68ada82117064bc3576c4b8374cfc04.tar.lz
gsoc2013-evolution-6bd8382bd68ada82117064bc3576c4b8374cfc04.tar.xz
gsoc2013-evolution-6bd8382bd68ada82117064bc3576c4b8374cfc04.tar.zst
gsoc2013-evolution-6bd8382bd68ada82117064bc3576c4b8374cfc04.zip
implemented. The routines in this file will be called by providers to
1999-12-16 bertrand <Bertrand.Guiheneuf@aful.org> * camel/camel-folder-utils.c (camel_aml_expunge_messages): implemented. The routines in this file will be called by providers to handle the list of message already standing in memory. 1999-12-15 bertrand <Bertrand.Guiheneuf@aful.org> * camel/camel-folder-utils.c: * camel/camel-folder-utils.h: New files, misc utilities for the folder providers. Includes active message list utilities. * camel/camel-folder.c (_has_message_number_capability): (camel_folder_has_message_number_capability): Added this to know if a folder provides number-based message access. * camel/camel-folder.c (_get_message_count): added warning when called directly. (_append_message): ditto (_open_async): ditto (_close_async): ditto (_delete_messages): ditto (_expunge): ditto (_get_message_by_number): ditto (_get_message_uid): ditto (_get_message_uid_by_number): ditto (_get_message_by_uid): ditto (_get_uid_list): ditto svn path=/trunk/; revision=1492
Diffstat (limited to 'camel/camel-folder-utils.c')
-rw-r--r--camel/camel-folder-utils.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/camel/camel-folder-utils.c b/camel/camel-folder-utils.c
new file mode 100644
index 0000000000..e8459134ba
--- /dev/null
+++ b/camel/camel-folder-utils.c
@@ -0,0 +1,101 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* camel-folder-utils : Utility for camel folders */
+
+
+/*
+ *
+ * Author :
+ * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org>
+ *
+ * Copyright 1999, 2000 HelixCode (http://www.helixcode.com) .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+
+#include "camel-folder-utils.h"
+#include "camel-mime-message.h"
+
+
+
+/* Active Message List utilities */
+
+/* */
+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_aml_expunge_messages: Expunge the message marked as deleted in an Active Message List
+ * @aml: active message list
+ * @folder: folder object
+ *
+ * Expunge the message flagged as "DELETED" in an active message list.
+ * The messages are not freed nor really expunged on the disk, they
+ * are just removed from the active message list and marked as
+ * "EXPUNGED". The list of the message which have been expunged is
+ * return in a GList which must be freed by the caller.
+ * To be really expunged the providers must provide or call
+ * folder specific methods.
+ *
+ * Return value: the list of expunged messages.
+ **/
+GList *
+camel_aml_expunge_messages (GList *aml,
+ CamelFolder *folder)
+{
+ CamelMimeMessage *message;
+ GList *message_node;
+ GList *next_message_node;
+ guint nb_expunged = 0;
+ GList *expunged_messages;
+
+ 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) {
+ if (camel_mime_message_get_flag (message, "DELETED")) {
+
+ /* remove the message from active message list */
+ g_list_remove_link (folder->message_list, message_node);
+ g_list_free_1 (message_node);
+ camel_mime_message_set_flag (message, "EXPUNGED", TRUE);
+ expunged_messages = g_list_prepend (expunged_messages, message);
+
+ }
+ }
+ 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_messages;
+}