aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-vtrash-folder.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-03-27 09:41:21 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-03-27 09:41:21 +0800
commitefddd51d3b67fbf48a6c190fa7ddfb0244be5ddf (patch)
treef66dfbe73b34497b294dc65663c668169a5a1e92 /camel/camel-vtrash-folder.c
parent7b792443de265dbc80d29011bd1c200e515463c8 (diff)
downloadgsoc2013-evolution-efddd51d3b67fbf48a6c190fa7ddfb0244be5ddf.tar
gsoc2013-evolution-efddd51d3b67fbf48a6c190fa7ddfb0244be5ddf.tar.gz
gsoc2013-evolution-efddd51d3b67fbf48a6c190fa7ddfb0244be5ddf.tar.bz2
gsoc2013-evolution-efddd51d3b67fbf48a6c190fa7ddfb0244be5ddf.tar.lz
gsoc2013-evolution-efddd51d3b67fbf48a6c190fa7ddfb0244be5ddf.tar.xz
gsoc2013-evolution-efddd51d3b67fbf48a6c190fa7ddfb0244be5ddf.tar.zst
gsoc2013-evolution-efddd51d3b67fbf48a6c190fa7ddfb0244be5ddf.zip
Use camel_vtrash_folder_new() to create the vtrash folder now.
2001-03-26 Jeffrey Stedfast <fejj@ximian.com> * camel-store.c (init_trash): Use camel_vtrash_folder_new() to create the vtrash folder now. * camel-vtrash-folder.[c,h]: New subclass of CamelVeeFolder for our vTrash folders. * camel-folder.c (camel_folder_copy_messages_to): Don't watch for vtrash folders anymore. (camel_folder_move_messages_to): Same. * camel-vee-folder.c (camel_vee_folder_class_init): Update. (vee_move_messages_to): Rewrite to use the new move API. * camel-filter-driver.c (do_copy): Updated to reflect copy_message_to changes. Create a temporary uid array and use that. (do_move): Same. (camel_filter_driver_filter_message): And again, here... * providers/imap/camel-imap-folder.c (imap_copy_messages_to): Update to the new API. (imap_move_messages_to): Same. (get_uid_set): New function to create a `set' string based on an array of UIDs for use with imap_copy_messages_to. * camel-folder.c (camel_folder_copy_messages_to): Replaces camel_folder_copy_message_to (camel_folder_move_message_to): Replaces camel_folder_move_message_to. svn path=/trunk/; revision=8960
Diffstat (limited to 'camel/camel-vtrash-folder.c')
-rw-r--r--camel/camel-vtrash-folder.c138
1 files changed, 138 insertions, 0 deletions
diff --git a/camel/camel-vtrash-folder.c b/camel/camel-vtrash-folder.c
new file mode 100644
index 0000000000..acaa9c5b34
--- /dev/null
+++ b/camel/camel-vtrash-folder.c
@@ -0,0 +1,138 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Authors: Jeffrey Stedfast <fejj@ximian.com>
+ *
+ * Copyright 2001 Ximian, Inc. (www.ximian.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 Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <config.h>
+
+#include "camel-exception.h"
+#include "camel-vtrash-folder.h"
+#include "camel-store.h"
+#include "camel-vee-store.h"
+#include "camel-mime-message.h"
+
+#include <string.h>
+
+static CamelVeeFolderClass *camel_vtrash_folder_parent;
+
+static void vtrash_append_message (CamelFolder *folder, CamelMimeMessage *message,
+ const CamelMessageInfo *info, CamelException *ex);
+static void vtrash_copy_messages_to (CamelFolder *folder, GPtrArray *uids, CamelFolder *dest, CamelException *ex);
+static void vtrash_move_messages_to (CamelFolder *folder, GPtrArray *uids, CamelFolder *dest, CamelException *ex);
+
+static void
+camel_vtrash_folder_class_init (CamelVTrashFolderClass *klass)
+{
+ CamelFolderClass *folder_class = (CamelFolderClass *) klass;
+
+ camel_vtrash_folder_parent =
+ CAMEL_VEE_FOLDER_CLASS (camel_type_get_global_classfuncs (camel_folder_get_type ()));
+
+ folder_class->append_message = vtrash_append_message;
+ folder_class->copy_messages_to = vtrash_copy_messages_to;
+ folder_class->move_messages_to = vtrash_move_messages_to;
+}
+
+CamelType
+camel_vtrash_folder_get_type (void)
+{
+ static CamelType type = CAMEL_INVALID_TYPE;
+
+ if (type == CAMEL_INVALID_TYPE) {
+ type = camel_type_register (camel_vee_folder_get_type (),
+ "CamelVTrashFolder",
+ sizeof (CamelVTrashFolder),
+ sizeof (CamelVTrashFolderClass),
+ (CamelObjectClassInitFunc) camel_vtrash_folder_class_init,
+ NULL,
+ NULL,
+ NULL);
+ }
+
+ return type;
+}
+
+/**
+ * camel_vee_folder_new:
+ * @parent_store: the parent CamelVeeStore
+ * @name: the vfolder name
+ * @ex: a CamelException
+ *
+ * Create a new CamelVeeFolder object.
+ *
+ * Return value: A new CamelVeeFolder widget.
+ **/
+CamelFolder *
+camel_vtrash_folder_new (CamelStore *parent_store, const char *name)
+{
+ CamelFolder *vtrash;
+ char *vtrash_name;
+ guint32 flags;
+
+ vtrash = (CamelFolder *)camel_object_new (camel_vtrash_folder_get_type ());
+ vtrash_name = g_strdup_printf ("%s?(match-all (system-flag \"Deleted\"))", name);
+ flags = CAMEL_STORE_FOLDER_PRIVATE | CAMEL_STORE_FOLDER_CREATE | CAMEL_STORE_VEE_FOLDER_AUTO;
+
+ camel_vee_folder_construct (CAMEL_VEE_FOLDER (vtrash), parent_store, vtrash_name, flags);
+
+ return vtrash;
+}
+
+static void
+vtrash_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, CamelException *ex)
+{
+ /* no-op */
+}
+
+static void
+vtrash_copy_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, CamelException *ex)
+{
+ /* don't allow the user to copy to or from the vtrash folder */
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("You cannot copy messages from this trash folder."));
+}
+
+static void
+vtrash_move_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, CamelException *ex)
+{
+ CamelFolder *original;
+ int i;
+
+ for (i = 0; i < uids->len; i++) {
+ original = camel_vee_folder_get_message_folder (CAMEL_VEE_FOLDER (source), uids->pdata[i]);
+
+ if (dest == original) {
+ /* Just undelete the original message */
+ CAMEL_FOLDER_CLASS (dest)->set_message_flags (dest, uids->pdata[i], CAMEL_MESSAGE_DELETED, 0);
+ } else if (original) {
+ /* This means that the user is trying to move the message
+ from the vTrash to a folder other than the original. */
+ GPtrArray *tuids;
+
+ tuids = g_ptr_array_new ();
+ g_ptr_array_add (tuids, uids->pdata[i]);
+ CAMEL_FOLDER_CLASS (original)->move_messages_to (original, tuids, dest, ex);
+ g_ptr_array_free (tuids, TRUE);
+ }
+
+ if (original)
+ camel_object_unref (CAMEL_OBJECT (original));
+ }
+}