aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-folder.c
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 /camel/camel-folder.c
parent1755ff603bff086a19b3fbb39adc5f8022640159 (diff)
downloadgsoc2013-evolution-fb5218e3532444f4d4d9a4bb96186bdf6b0e6107.tar.gz
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
Diffstat (limited to 'camel/camel-folder.c')
-rw-r--r--camel/camel-folder.c121
1 files changed, 87 insertions, 34 deletions
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;
}
/cgit/cgit.cgi/freebsd-ports-gnome/commit/chinese?h=gnome-3.24&id=bc2a86354eb7b8db9a228d563b38aa2664cea151'>- Fix iconv linking in libcconv.sosunpoet2012-04-251-2/+2 * - upgrade to 3.5.2bapt2012-04-237-0/+44 * - Update to 3.3.2sunpoet2012-04-222-3/+3 * - Update to 3.3.2sunpoet2012-04-222-3/+3 * Upgrade to 2.7.6.1.vanilla2012-04-162-3/+3 * - Fix build post mail/mutt-devel upgrade. The patch-nbsp from master portrafan2012-04-142-47/+49 * Mark as deprecated and set expiration to 2012-05-10 for ports that are mark a...bapt2012-04-101-0/+3 * Upgrade to 2.7.5.vanilla2012-03-152-4/+4 * - Revert ports/165605 as requested by portmgr@pgollucci2012-03-141-0/+3 * - Remove ports that only work with < perl 5.12 (devel/p5-B-Size, devel/p5-Dev...pgollucci2012-03-091-3/+0 * Reformat for better readability.danfe2012-02-282-11/+9 * Overhaul the port before I attempt to make it more usable on modern FreeBSD:danfe2012-02-285-39/+208 * Upgrade to 2.7.4.vanilla2012-02-253-3/+5 * - Bump PORTREVISION to chase the update of multimedia/libvpxashish2012-02-162-0/+2 * Bump PORTREVISION due to pcre updatejohans2012-02-151-1/+1 * 1: Upgrade to 2.7.3vanilla2012-02-112-5/+6 * - Add intltool to GNOME dependency. [*]delphij2012-02-094-0/+4 * Fix pkg-plist.vanilla2012-02-091-0/+2 * fcitx-keyboard moved to textproc per request from the maintainer.delphij2012-02-085-45/+0 * Add fcitx-keyboard - X keyboard integration.delphij2012-02-085-0/+45 * Add fcitx-chewing - Chewing input method binding.delphij2012-02-085-0/+41 * Update fcitx and friends:delphij2012-02-0830-115/+181 * - Update to 3.0.10miwi2012-02-073-6/+3 * Add missing file to pkg-plist.vanilla2012-02-041-0/+1 * 1: Upgrade to 2.7.2.vanilla2012-02-044-6/+16 * - Fix pkg-plistchinsan2012-02-042-2/+2 * Upgrade to 2.7.1.vanilla2012-01-316-11/+49 * Fix typokevlo2012-01-311-1/+1 * - Install missing man pageskevlo2012-01-312-1/+12 * - Remove unused patchchinsan2012-01-311-0/+0 * - Update to 2.7.0chinsan2012-01-306-74/+60 * - Update to 1.13sunpoet2012-01-302-3/+4 * - Update to 3.3.1sunpoet2012-01-262-3/+3 * - Update to 3.3.1sunpoet2012-01-262-3/+3 * The KDE/FreeBSD team is pleased to announce KDE SC 4.7.4, whichavilla2012-01-252-4/+4 * - Update to 1.10culot2012-01-182-4/+4 * - Update to 1.3.10lwhsu2012-01-143-10/+13 * Update to 0.3.0cs2012-01-123-3/+18 * Update to 1.4.0.delphij2012-01-113-10/+56 * Chase pdflib.so version and bump PORTREVISION accordingly.ale2012-01-101-2/+2 * - The proper acronym for Apache Software License 2 is really AL2tabthorpe2012-01-091-1/+1 * - remove files/patch-tin.defaults and replace it with REINPLACE_CMDleeym2012-01-052-13/+6 * Restore PORTREVISION to prevent version going backwardsjohans2012-01-041-0/+1 * - update to 2.0.1leeym2012-01-026-65/+35 * Mark as broken on powerpc: fails to install with signal 11.linimon2011-12-281-1/+7 * - Stop redefining ECHO_MSG and breaking make readmescrees2011-12-171-13/+9 * - Update to 3.3sunpoet2011-12-142-3/+3 * Add opencc 0.2.0, open Chinese Convert library and utilities.vanilla2011-12-028-0/+136 * Remove trailing whitespaces.ehaupt2011-11-191-1/+1 * - Update to 1.9sunpoet2011-11-182-5/+5 * - Unbreak on 7.Xpav2011-11-145-21/+16 * Remove CMAKE_USE_PTHREAD from the ports using it.rakuco2011-11-142-2/+0 * The KDE on FreeBSD team is pleased to update the KDE4 ports to 4.7.3.rakuco2011-11-142-4/+4 * fcitx-cloudpinyin is not an input method engine. It adds candidatesclsung2011-11-145-0/+39 * - remove the x11 sub-categories of the fcitx-* ports, and put their distfilesclsung2011-11-148-13/+15 * Make @dirrms conditional for %%DOCSDIR%% on NOPORTDOCScrees2011-11-141-1/+1 * fcitx-ui-light is a very light weight UI for Fcitx, only using Xpmclsung2011-11-126-0/+50 * fcitx-googlepinyin provides libgooglepinyin, a fork of Google Pinyin IMEclsung2011-11-115-0/+37 * libgooglepinyin is a Chinese input method engine, forked from Googleclsung2011-11-116-0/+63 * fcitx-sunpinyin provides SunPinyin, a statistical language model basedclsung2011-11-118-0/+79 * - bump PORTREVISIONclsung2011-11-114-0/+134 * Fcitx is a simple and fast Chinese XIM server. It comes with a script,clsung2011-11-114-0/+36 * - pass maintainership (forgot do it in last commit)clsung2011-11-111-1/+1 * - Update to 4.1.2clsung2011-11-1120-220/+399 * SunPinyin is a statistical language model based Chinese input method, whichclsung2011-11-117-0/+161 * Fails to install on powerpc: signal 6.linimon2011-11-111-1/+7 * Mark as broken on powerpc.linimon2011-11-101-1/+7 * Mark broken on powerpc as well as sparc64. (In fact, on all the tier-2s.)linimon2011-11-101-2/+2 * - Remove WITH_FBSD10_FIX, is no longer neededmiwi2011-11-092-2/+0 * - Get rid FreeBSD 6.X supportmiwi2011-11-072-11/+1 * Remove ports@ ports that have been DEPRECATED for at least 1 monthdougb2011-11-026-80/+0 * Fix build with FreeBSD 10kwm2011-10-302-0/+2 * - Respect CCrafan2011-10-291-1/+1 * - Update to 1.8sunpoet2011-10-272-4/+4 * - Do not install PREFIX/include/unicode.h to avoid conflicts with devel/libun...sunpoet2011-10-272-1/+2 * The vast majority of pkg-descr files had the following format when theydougb2011-10-247-12/+1 * Remove more tags from pkg-descr files fo the form:dougb2011-10-242-5/+0 * - Update to 1.2.5clsung2011-10-192-4/+4 * The KDE/FreeBSD team is pleased to announce KDE Software Compilationavilla2011-10-174-14/+38 * - Update to 1.7lwhsu2011-10-152-10/+6 * Add reciteword back and update it to 0.8.4.delphij2011-10-075-0/+719 * Undeprecate by replacing local distribution site temporarily with freebsd.org'sdelphij2011-10-07