aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-02-24 00:52:55 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-02-24 00:52:55 +0800
commitafd1cad2da1ace056f7882a1088ce3e3b7dba2da (patch)
tree8837f2b4ac974e7476fb7937e1eca8ef079861e7 /camel
parentac97d963b038541b84aa15b4eaa3d28fd9d60114 (diff)
downloadgsoc2013-evolution-afd1cad2da1ace056f7882a1088ce3e3b7dba2da.tar.gz
gsoc2013-evolution-afd1cad2da1ace056f7882a1088ce3e3b7dba2da.tar.zst
gsoc2013-evolution-afd1cad2da1ace056f7882a1088ce3e3b7dba2da.zip
init get_trash and init_trash. (camel_store_init): call the virtual
2001-02-23 Jeffrey Stedfast <fejj@ximian.com> * camel-store.c (camel_store_class_init): init get_trash and init_trash. (camel_store_init): call the virtual init_trash function. (camel_store_finalize): unref the vtrash folder/store if present. (camel_store_get_folder): Add the new folder to the vtrash vfolder. (init_trash): default implementation of init_trash. (get_trash): default implementation of get_trash. * camel-vee-store.c (vee_init_trash): No-op. (vee_get_trash): return NULL svn path=/trunk/; revision=8368
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog14
-rw-r--r--camel/camel-store.c90
-rw-r--r--camel/camel-store.h15
-rw-r--r--camel/camel-vee-store.c17
4 files changed, 125 insertions, 11 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index aeffd7473f..2572ce3763 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,17 @@
+2001-02-23 Jeffrey Stedfast <fejj@ximian.com>
+
+ * camel-store.c (camel_store_class_init): init get_trash and
+ init_trash.
+ (camel_store_init): call the virtual init_trash function.
+ (camel_store_finalize): unref the vtrash folder/store if present.
+ (camel_store_get_folder): Add the new folder to the vtrash
+ vfolder.
+ (init_trash): default implementation of init_trash.
+ (get_trash): default implementation of get_trash.
+
+ * camel-vee-store.c (vee_init_trash): No-op.
+ (vee_get_trash): return NULL
+
2001-02-23 Not Zed <NotZed@Ximian.com>
* camel-folder-summary.c (camel_message_info_new_from_header):
diff --git a/camel/camel-store.c b/camel/camel-store.c
index 3af355c92c..86a2a88871 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -29,6 +29,8 @@
#include "camel-store.h"
#include "camel-folder.h"
+#include "camel-vee-store.h"
+#include "camel-vee-folder.h"
#include "camel-exception.h"
#include "camel-private.h"
@@ -42,6 +44,9 @@ static CamelFolder *get_folder (CamelStore *store, const char *folder_name,
guint32 flags, CamelException *ex);
static CamelFolder *get_inbox (CamelStore *store, CamelException *ex);
+static void init_trash (CamelStore *store);
+static CamelFolder *get_trash (CamelStore *store, CamelException *ex);
+
static CamelFolderInfo *create_folder (CamelStore *store,
const char *parent_name,
const char *folder_name,
@@ -75,6 +80,8 @@ camel_store_class_init (CamelStoreClass *camel_store_class)
camel_store_class->compare_folder_name = g_str_equal;
camel_store_class->get_folder = get_folder;
camel_store_class->get_inbox = get_inbox;
+ camel_store_class->init_trash = init_trash;
+ camel_store_class->get_trash = get_trash;
camel_store_class->create_folder = create_folder;
camel_store_class->delete_folder = delete_folder;
camel_store_class->rename_folder = rename_folder;
@@ -103,9 +110,12 @@ camel_store_init (void *o)
store_class->compare_folder_name);
} else
store->folders = NULL;
+
store->flags = 0;
-
- store->priv = g_malloc0(sizeof(*store->priv));
+
+ store_class->init_trash (store);
+
+ store->priv = g_malloc0 (sizeof (*store->priv));
#ifdef ENABLE_THREADS
store->priv->folder_lock = g_mutex_new();
store->priv->cache_lock = g_mutex_new();
@@ -125,12 +135,19 @@ camel_store_finalize (CamelObject *object)
}
g_hash_table_destroy (store->folders);
}
-
+
+ if (store->vtrash) {
+ CamelStore *vstore = camel_folder_get_parent_store (store->vtrash);
+
+ camel_object_unref (CAMEL_OBJECT (store->vtrash));
+ camel_object_unref (CAMEL_OBJECT (vstore));
+ }
+
#ifdef ENABLE_THREADS
- g_mutex_free(store->priv->folder_lock);
- g_mutex_free(store->priv->cache_lock);
+ g_mutex_free (store->priv->folder_lock);
+ g_mutex_free (store->priv->cache_lock);
#endif
- g_free(store->priv);
+ g_free (store->priv);
}
@@ -214,7 +231,11 @@ camel_store_get_folder (CamelStore *store, const char *folder_name, guint32 flag
CAMEL_STORE_LOCK(store, cache_lock);
g_hash_table_insert (store->folders, g_strdup (folder_name), folder);
-
+
+ /* Add the folder to the vTrash folder if this store implements it */
+ if (store->vtrash)
+ camel_vee_folder_add_folder (CAMEL_VEE_FOLDER (store->vtrash), folder);
+
camel_object_hook_event (CAMEL_OBJECT (folder), "finalize", folder_finalize, store);
CAMEL_STORE_UNLOCK(store, cache_lock);
}
@@ -342,6 +363,61 @@ camel_store_get_inbox (CamelStore *store, CamelException *ex)
static void
+init_trash (CamelStore *store)
+{
+ CamelStore *vstore;
+ char *uri, *name;
+ CamelURL *url;
+
+ uri = g_strdup_printf ("vfolder:%p/%s", store, "vTrash");
+ name = g_strdup_printf ("%s?(match-all (system-flag \"Deleted\"))", "vTrash");
+
+ vstore = CAMEL_STORE (camel_vee_store_new ());
+
+ url = camel_url_new (uri, NULL);
+ g_free (uri);
+ CAMEL_SERVICE (vstore)->url = url;
+
+ store->vtrash = camel_store_get_folder (vstore, name, CAMEL_STORE_FOLDER_CREATE |
+ CAMEL_STORE_VEE_FOLDER_AUTO, NULL);
+ g_free (name);
+}
+
+
+static CamelFolder *
+get_trash (CamelStore *store, CamelException *ex)
+{
+ if (store->vtrash) {
+ camel_object_ref (CAMEL_OBJECT (store->vtrash));
+ return store->vtrash;
+ } else {
+ g_warning ("This store does not support vTrash.");
+ return NULL;
+ }
+}
+
+/**
+ * camel_store_get_trash:
+ * @store: a CamelStore
+ * @ex: a CamelException
+ *
+ * Return value: the folder in the store into which trash is
+ * delivered, or %NULL if no such folder exists.
+ **/
+CamelFolder *
+camel_store_get_trash (CamelStore *store, CamelException *ex)
+{
+ CamelFolder *folder;
+
+ CAMEL_STORE_LOCK(store, folder_lock);
+ folder = CS_CLASS (store)->get_trash (store, ex);
+ CAMEL_STORE_UNLOCK(store, folder_lock);
+
+ return folder;
+}
+
+
+static void
sync_folder (gpointer key, gpointer folder, gpointer ex)
{
if (!camel_exception_is_set (ex))
diff --git a/camel/camel-store.h b/camel/camel-store.h
index cd53b7813d..6ea20b4d2c 100644
--- a/camel/camel-store.h
+++ b/camel/camel-store.h
@@ -3,8 +3,7 @@
/*
*
- * Author :
- * Bertrand Guiheneuf <bertrand@helixcode.com>
+ * Authors: Bertrand Guiheneuf <bertrand@helixcode.com>
*
* Copyright 1999, 2000 Helix Code, Inc. (http://www.helixcode.com)
*
@@ -58,7 +57,9 @@ struct _CamelStore
{
CamelService parent_object;
struct _CamelStorePrivate *priv;
-
+
+ CamelFolder *vtrash;
+
/* should have cache_lock when accessing this (priv->cache_lock) */
GHashTable *folders;
@@ -82,7 +83,11 @@ typedef struct {
CamelException *ex);
CamelFolder * (*get_inbox) (CamelStore *store,
CamelException *ex);
-
+
+ void (*init_trash) (CamelStore *store);
+ CamelFolder * (*get_trash) (CamelStore *store,
+ CamelException *ex);
+
CamelFolderInfo *(*create_folder) (CamelStore *store,
const char *parent_name,
const char *folder_name,
@@ -129,6 +134,8 @@ CamelFolder * camel_store_get_folder (CamelStore *store,
CamelException *ex);
CamelFolder * camel_store_get_inbox (CamelStore *store,
CamelException *ex);
+CamelFolder * camel_store_get_trash (CamelStore *store,
+ CamelException *ex);
CamelFolderInfo *camel_store_create_folder (CamelStore *store,
const char *parent_name,
diff --git a/camel/camel-vee-store.c b/camel/camel-vee-store.c
index 4920e04a83..38d535dbee 100644
--- a/camel/camel-vee-store.c
+++ b/camel/camel-vee-store.c
@@ -23,6 +23,8 @@
#include "camel-vee-folder.h"
static CamelFolder *vee_get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex);
+static void vee_init_trash (CamelStore *store);
+static CamelFolder *vee_get_trash (CamelStore *store, CamelException *ex);
struct _CamelVeeStorePrivate {
};
@@ -62,6 +64,8 @@ camel_vee_store_class_init (CamelVeeStoreClass *klass)
/* virtual method overload */
store_class->get_folder = vee_get_folder;
+ store_class->init_trash = vee_init_trash;
+ store_class->get_trash = vee_get_trash;
}
static void
@@ -91,3 +95,16 @@ vee_get_folder (CamelStore *store, const char *folder_name, guint32 flags, Camel
{
return camel_vee_folder_new(store, folder_name, flags, ex);
}
+
+static void
+vee_init_trash (CamelStore *store)
+{
+ /* no-op */
+ ;
+}
+
+static CamelFolder *
+vee_get_trash (CamelStore *store, CamelException *ex)
+{
+ return NULL;
+}