aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-vtrash.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-02-24 00:51:45 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-02-24 00:51:45 +0800
commitac97d963b038541b84aa15b4eaa3d28fd9d60114 (patch)
treebd75dd9084c6315c49f094e5989ba5741f16e7ef /mail/mail-vtrash.c
parentc06709a5751b39e4a9cbf931759245f6abaa3d53 (diff)
downloadgsoc2013-evolution-ac97d963b038541b84aa15b4eaa3d28fd9d60114.tar
gsoc2013-evolution-ac97d963b038541b84aa15b4eaa3d28fd9d60114.tar.gz
gsoc2013-evolution-ac97d963b038541b84aa15b4eaa3d28fd9d60114.tar.bz2
gsoc2013-evolution-ac97d963b038541b84aa15b4eaa3d28fd9d60114.tar.lz
gsoc2013-evolution-ac97d963b038541b84aa15b4eaa3d28fd9d60114.tar.xz
gsoc2013-evolution-ac97d963b038541b84aa15b4eaa3d28fd9d60114.tar.zst
gsoc2013-evolution-ac97d963b038541b84aa15b4eaa3d28fd9d60114.zip
No longer need to do a vtrash_cleanup() (it also doesn't exist anymore).
2001-02-23 Jeffrey Stedfast <fejj@ximian.com> * main.c (main): No longer need to do a vtrash_cleanup() (it also doesn't exist anymore). * component-factory.c (mail_load_storages): Updated to use the new vtrash code. (owner_set_cb): Same. * mail-tools.c (mail_tool_uri_to_folder): Update to handle the "vtrash:" url prefix so that we can extract the REAL uri and know to get the trash folder. * mail-vtrash.c (mail_vtrash_add): Add the vTrash folder to the EvolutionStorage. (mail_vtrash_create): Get the store based on the uri (async) and then call mail_trash_add. (vtrash_cleanup): Removed. (vtrash_uri_to_folder): Removed. (vtrash_create): Replaced by mail_vtrash_create() svn path=/trunk/; revision=8367
Diffstat (limited to 'mail/mail-vtrash.c')
-rw-r--r--mail/mail-vtrash.c198
1 files changed, 16 insertions, 182 deletions
diff --git a/mail/mail-vtrash.c b/mail/mail-vtrash.c
index e2777dde63..bc26afd9a5 100644
--- a/mail/mail-vtrash.c
+++ b/mail/mail-vtrash.c
@@ -36,45 +36,14 @@
#include "mail-mt.h"
#include "camel/camel.h"
-#include "camel/camel-vee-store.h"
-#include "filter/vfolder-rule.h"
-#include "filter/filter-part.h"
#define d(x)
-#define VTRASH_LOCK(x) pthread_mutex_lock(&x)
-#define VTRASH_UNLOCK(x) pthread_mutex_unlock(&x)
-
-static GHashTable *vtrash_hash = NULL;
-static pthread_mutex_t vtrash_hash_lock = PTHREAD_MUTEX_INITIALIZER;
-
extern char *evolution_dir;
extern CamelSession *session;
-/* maps the shell's uri to the real vtrash folder */
-CamelFolder *
-vtrash_uri_to_folder (const char *uri, CamelException *ex)
-{
- CamelFolder *folder = NULL;
-
- g_return_val_if_fail (uri != NULL, NULL);
-
- if (strncmp (uri, "vtrash:", 7))
- return NULL;
-
- VTRASH_LOCK (vtrash_hash_lock);
- if (vtrash_hash) {
- folder = g_hash_table_lookup (vtrash_hash, uri);
-
- camel_object_ref (CAMEL_OBJECT (folder));
- }
- VTRASH_UNLOCK (vtrash_hash_lock);
-
- return folder;
-}
-
-static void
-vtrash_add (CamelStore *store, CamelFolder *folder, const char *store_uri, const char *name)
+void
+mail_vtrash_add (CamelStore *store, const char *store_uri, const char *name)
{
EvolutionStorage *storage;
char *uri, *path;
@@ -83,16 +52,6 @@ vtrash_add (CamelStore *store, CamelFolder *folder, const char *store_uri, const
uri = g_strdup_printf ("vtrash:%s", store_uri);
- VTRASH_LOCK (vtrash_hash_lock);
-
- if (!vtrash_hash) {
- vtrash_hash = g_hash_table_new (g_str_hash, g_str_equal);
- } else if (g_hash_table_lookup (vtrash_hash, uri) != NULL) {
- VTRASH_UNLOCK (vtrash_hash_lock);
- g_free (uri);
- return;
- }
-
if (!strcmp (store_uri, "file:/")) {
storage = mail_vfolder_get_vfolder_storage ();
} else {
@@ -100,7 +59,6 @@ vtrash_add (CamelStore *store, CamelFolder *folder, const char *store_uri, const
}
if (!storage) {
- VTRASH_UNLOCK (vtrash_hash_lock);
g_free (uri);
return;
}
@@ -111,11 +69,6 @@ vtrash_add (CamelStore *store, CamelFolder *folder, const char *store_uri, const
gtk_object_unref (GTK_OBJECT (storage));
g_free (path);
-
- g_hash_table_insert (vtrash_hash, uri, folder);
- camel_object_ref (CAMEL_OBJECT (folder));
-
- VTRASH_UNLOCK (vtrash_hash_lock);
}
struct _get_trash_msg {
@@ -123,9 +76,7 @@ struct _get_trash_msg {
CamelStore *store;
char *store_uri;
- CamelFolder *folder;
- void (*done) (char *store_uri, CamelFolder *folder, void *data);
- void *data;
+ char *name;
};
static char *
@@ -136,80 +87,13 @@ get_trash_desc (struct _mail_msg *mm, int done)
return g_strdup_printf (_("Opening Trash folder for %s"), m->store_uri);
}
-/* maps the shell's uri to the real vfolder uri and open the folder */
-static CamelFolder *
-create_trash_vfolder (CamelStore *store, const char *name, GPtrArray *urls, CamelException *ex)
-{
- void camel_vee_folder_add_folder (CamelFolder *, CamelFolder *);
-
- char *storeuri, *foldername;
- CamelFolder *folder = NULL, *sourcefolder;
- int source = 0;
-
- d(fprintf (stderr, "Creating Trash vfolder\n"));
-
- storeuri = g_strdup_printf ("vfolder:%s/vfolder/%p/%s", evolution_dir, store, name);
- foldername = g_strdup ("mbox?(match-all (system-flag \"Deleted\"))");
-
- /* we dont have indexing on vfolders */
- folder = mail_tool_get_folder_from_urlname (storeuri, foldername,
- CAMEL_STORE_FOLDER_CREATE | CAMEL_STORE_VEE_FOLDER_AUTO,
- ex);
- g_free (foldername);
- g_free (storeuri);
- if (camel_exception_is_set (ex))
- return NULL;
-
- while (source < urls->len) {
- const char *sourceuri;
-
- sourceuri = urls->pdata[source];
- d(fprintf (stderr, "adding vfolder source: %s\n", sourceuri));
-
- sourcefolder = mail_tool_uri_to_folder (sourceuri, ex);
- d(fprintf (stderr, "source folder = %p\n", sourcefolder));
-
- if (sourcefolder) {
- camel_vee_folder_add_folder (folder, sourcefolder);
- } else {
- /* we'll just silently ignore now-missing sources */
- camel_exception_clear (ex);
- }
-
- g_free (urls->pdata[source]);
- source++;
- }
-
- g_ptr_array_free (urls, TRUE);
-
- return folder;
-}
-
-static void
-populate_folder_urls (CamelFolderInfo *info, GPtrArray *urls)
-{
- if (!info)
- return;
-
- g_ptr_array_add (urls, g_strdup (info->url));
-
- if (info->child)
- populate_folder_urls (info->child, urls);
-
- if (info->sibling)
- populate_folder_urls (info->sibling, urls);
-}
-
static void
get_trash_get (struct _mail_msg *mm)
{
struct _get_trash_msg *m = (struct _get_trash_msg *)mm;
- GPtrArray *urls;
-
- camel_operation_register(mm->cancel);
- camel_operation_start(mm->cancel, _("Getting matches"));
-
- urls = g_ptr_array_new ();
+
+ camel_operation_register (mm->cancel);
+ camel_operation_start (mm->cancel, _("Getting matches"));
/* we don't want to connect */
m->store = (CamelStore *) camel_session_get_service (session, m->store_uri,
@@ -218,55 +102,31 @@ get_trash_get (struct _mail_msg *mm)
g_warning ("Couldn't get service %s: %s\n", m->store_uri,
camel_exception_get_description (&mm->ex));
camel_exception_clear (&mm->ex);
-
- m->folder = NULL;
- } else {
- /* First try to see if we can save time by looking the folder up in the hash table */
- char *uri;
-
- uri = g_strdup_printf ("vtrash:%s", m->store_uri);
- m->folder = vtrash_uri_to_folder (uri, &mm->ex);
- g_free (uri);
-
- if (!m->folder) {
- /* Create and add this new vTrash folder */
- CamelFolderInfo *info;
-
- info = camel_store_get_folder_info (m->store, NULL, TRUE, TRUE, TRUE, &mm->ex);
- populate_folder_urls (info, urls);
- camel_store_free_folder_info (m->store, info);
-
- m->folder = create_trash_vfolder (m->store, _("vTrash"), urls, &mm->ex);
- }
}
-
- camel_operation_end(mm->cancel);
- camel_operation_unregister(mm->cancel);
+
+ camel_operation_end (mm->cancel);
+ camel_operation_unregister (mm->cancel);
}
static void
get_trash_got (struct _mail_msg *mm)
{
struct _get_trash_msg *m = (struct _get_trash_msg *)mm;
-
- if (m->store)
- vtrash_add (m->store, m->folder, m->store_uri, _("vTrash"));
- if (m->done)
- m->done (m->store_uri, m->folder, m->data);
+ if (m->store)
+ mail_vtrash_add (m->store, m->store_uri, m->name);
}
static void
get_trash_free (struct _mail_msg *mm)
{
struct _get_trash_msg *m = (struct _get_trash_msg *)mm;
-
+
if (m->store)
camel_object_unref (CAMEL_OBJECT (m->store));
-
+
g_free (m->store_uri);
- if (m->folder)
- camel_object_unref (CAMEL_OBJECT (m->folder));
+ g_free (m->name);
}
static struct _mail_msg_op get_trash_op = {
@@ -277,43 +137,17 @@ static struct _mail_msg_op get_trash_op = {
};
int
-vtrash_create (const char *store_uri,
- void (*done) (char *store_uri, CamelFolder *folder, void *data),
- void *data)
+mail_vtrash_create (const char *store_uri, const char *name)
{
struct _get_trash_msg *m;
int id;
m = mail_msg_new (&get_trash_op, NULL, sizeof (*m));
m->store_uri = g_strdup (store_uri);
- m->data = data;
- m->done = done;
+ m->name = g_strdup (name);
id = m->msg.seq;
e_thread_put (mail_thread_new, (EMsg *)m);
return id;
}
-
-static void
-free_folder (gpointer key, gpointer value, gpointer data)
-{
- CamelFolder *folder = CAMEL_FOLDER (value);
- char *uri = key;
-
- g_free (uri);
- camel_object_unref (CAMEL_OBJECT (folder));
-}
-
-void
-vtrash_cleanup (void)
-{
- VTRASH_LOCK (vtrash_hash_lock);
-
- if (vtrash_hash) {
- g_hash_table_foreach (vtrash_hash, free_folder, NULL);
- g_hash_table_destroy (vtrash_hash);
- }
-
- VTRASH_UNLOCK (vtrash_hash_lock);
-}