aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog30
-rw-r--r--mail/Makefile.am2
-rw-r--r--mail/component-factory.c6
-rw-r--r--mail/mail-local.c2
-rw-r--r--mail/mail-ops.c318
-rw-r--r--mail/mail-ops.h8
-rw-r--r--mail/mail-tools.c10
-rw-r--r--mail/mail-vfolder.c6
-rw-r--r--mail/mail-vfolder.h2
-rw-r--r--mail/mail-vtrash.c291
-rw-r--r--mail/mail-vtrash.h46
-rw-r--r--mail/main.c5
12 files changed, 394 insertions, 332 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 173aa89c07..37240b38d4 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,33 @@
+2001-02-19 Jeffrey Stedfast <fejj@ximian.com>
+
+ * mail-vfolder.c (mail_vfolder_get_vfolder_storage): New handy
+ dandy function to ref and return the vfolder storage (will
+ probably be disavowed once I figure out how to get the vTrash
+ folder to show up in the EvolutionLocalStorage).
+
+ * main.c (main): Call vtrash_cleanup().
+
+ * mail-vtrash.c: New file.
+ (vtrash_uri_to_folder): vtrash: URI handler
+ (vtrash_create): Replacement async vtrash function for the old one
+ in mail-ops.c
+ (vtrash_cleanup): Cleanup code - unrefs the cached vtrash folders
+ and free's the hashtable.
+
+ * Makefile.am: Added mail-vtrash.[c,h].
+
+ * mail-tools.c (mail_tool_uri_to_folder): If we have a vtrash:
+ URI, call the vtrash URI handler function rather than continuing
+ on. Yes, I know this is a hack and it needs to be fixed.
+
+ * mail-ops.c (mail_do_setup_trash): Removed.
+ (mail_trash_get): Removed.
+
+ * component-factory.c (owner_set_cb): Create the vTrash folder for
+ the LocalStore here.
+
+ * mail-local.c (get_folder_info): Implement.
+
2001-02-20 Not Zed <NotZed@Ximian.com>
* mail-ops.c (fetch_mail_fetch): Unref the driver here, in the
diff --git a/mail/Makefile.am b/mail/Makefile.am
index c2ffbfe5e1..15901728bb 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -93,6 +93,8 @@ evolution_mail_SOURCES = \
mail-vfolder.c \
mail-vfolder.h \
mail-view.c \
+ mail-vtrash.c \
+ mail-vtrash.h \
main.c \
message-list.c \
message-list.h \
diff --git a/mail/component-factory.c b/mail/component-factory.c
index f2c977ab34..11adaefcac 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -43,6 +43,7 @@
#include "mail-mt.h"
#include "mail-importer.h"
#include "mail-vfolder.h" /* vfolder_create_storage */
+#include "mail-vtrash.h"
#include "openpgp-utils.h"
#include <gal/widgets/e-gui-utils.h>
@@ -54,7 +55,6 @@
CamelFolder *drafts_folder = NULL;
CamelFolder *outbox_folder = NULL;
CamelFolder *sent_folder = NULL; /* this one should be configurable? */
-CamelFolder *trash_folder = NULL;
char *evolution_dir;
#define COMPONENT_FACTORY_ID "OAFIID:GNOME_Evolution_Mail_ShellComponentFactory"
@@ -215,9 +215,7 @@ owner_set_cb (EvolutionShellComponent *shell_component,
g_free (uri);
}
- /*mail_msg_wait (mail_get_trash ("file:/", got_folder, &trash_folder));*/
- mail_do_setup_trash (_("Trash"), "file:/", &trash_folder);
- mail_operation_wait_for_finish ();
+ mail_msg_wait (vtrash_create ("file:/", NULL, NULL));
mail_session_enable_interaction (TRUE);
diff --git a/mail/mail-local.c b/mail/mail-local.c
index 2d63168dc3..0cdc45daac 100644
--- a/mail/mail-local.c
+++ b/mail/mail-local.c
@@ -629,7 +629,7 @@ mail_local_storage_startup (EvolutionShellClient *shellclient,
camel_object_unref (CAMEL_OBJECT (local_store));
return;
}
-
+
local_store->local_storage_listener =
evolution_storage_listener_new ();
corba_local_storage_listener =
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 6c5f3b5693..f1d72acf8c 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -35,6 +35,7 @@
#include "mail-threads.h"
#include "mail-tools.h"
#include "mail-ops.h"
+#include "mail-vfolder.h"
#include "composer/e-msg-composer.h"
#include "folder-browser.h"
#include "e-util/e-html-utils.h"
@@ -1636,323 +1637,6 @@ mail_operation_run(const mail_operation_spec *op, void *in, int free)
return TRUE;
}
-/* ** SETUP TRASH VFOLDER ************************************************* */
-
-struct _get_trash_msg {
- struct _mail_msg msg;
-
- char *store_uri;
- CamelFolder *folder;
- void (*done) (char *store_uri, CamelFolder *folder, void *data);
- void *data;
-};
-
-static char *
-get_trash_desc (struct _mail_msg *mm, int done)
-{
- struct _get_trash_msg *m = (struct _get_trash_msg *)mm;
-
- 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 (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/%s", evolution_dir, 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, 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) {
- mail_tool_camel_lock_up ();
- camel_vee_folder_add_folder (folder, sourcefolder);
- mail_tool_camel_lock_down ();
- } 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;
- CamelStore *store;
- GPtrArray *urls;
-
- urls = g_ptr_array_new ();
-
- /* we don't want to connect */
- store = (CamelStore *) camel_session_get_service (session, m->store_uri,
- CAMEL_PROVIDER_STORE, &mm->ex);
- if (store == NULL) {
- 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 {
- CamelFolderInfo *info;
-
- info = camel_store_get_folder_info (store, "/", TRUE, TRUE, TRUE, &mm->ex);
- populate_folder_urls (info, urls);
- camel_store_free_folder_info (store, info);
-
- m->folder = create_trash_vfolder (_("Trash"), urls, &mm->ex);
- }
-}
-
-static void
-get_trash_got (struct _mail_msg *mm)
-{
- struct _get_trash_msg *m = (struct _get_trash_msg *)mm;
-
- if (m->done)
- m->done (m->store_uri, m->folder, m->data);
-}
-
-static void
-get_trash_free (struct _mail_msg *mm)
-{
- struct _get_trash_msg *m = (struct _get_trash_msg *)mm;
-
- g_free (m->store_uri);
- if (m->folder)
- camel_object_unref (CAMEL_OBJECT (m->folder));
-}
-
-static struct _mail_msg_op get_trash_op = {
- get_trash_desc,
- get_trash_get,
- get_trash_got,
- get_trash_free,
-};
-
-int
-mail_get_trash (const char *store_uri,
- void (*done) (char *store_uri, CamelFolder *folder, void *data),
- void *data)
-{
- 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;
-
- id = m->msg.seq;
- e_thread_put (mail_thread_new, (EMsg *)m);
-
- return id;
-}
-
-/* This next one is the older implementation ... */
-
-typedef struct setup_trash_input_s {
- gchar *name;
- gchar *store_uri;
- CamelFolder **folder;
-} setup_trash_input_t;
-
-static gchar *
-describe_setup_trash (gpointer in_data, gboolean gerund)
-{
- setup_trash_input_t *input = (setup_trash_input_t *) in_data;
-
- if (gerund)
- return g_strdup_printf (_("Loading %s Folder for %s"), input->name, input->store_uri);
- else
- return g_strdup_printf (_("Load %s Folder for %s"), input->name, input->store_uri);
-}
-
-#if 0
-/* maps the shell's uri to the real vfolder uri and open the folder */
-static CamelFolder *
-create_trash_vfolder (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/%s", evolution_dir, 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, 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];
- 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) {
- mail_tool_camel_lock_up ();
- camel_vee_folder_add_folder (folder, sourcefolder);
- mail_tool_camel_lock_down ();
- } 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);
-}
-#endif
-
-static void
-do_setup_trash (gpointer in_data, gpointer op_data, CamelException *ex)
-{
- setup_trash_input_t *input = (setup_trash_input_t *) in_data;
- EvolutionStorage *storage;
- CamelFolderInfo *info;
- CamelStore *store;
- GPtrArray *urls;
-
- urls = g_ptr_array_new ();
-
- /* we don't want to connect */
- store = (CamelStore *) camel_session_get_service (session, input->store_uri,
- CAMEL_PROVIDER_STORE, ex);
- if (store == NULL) {
- g_warning ("Couldn't get service %s: %s\n", input->store_uri,
- camel_exception_get_description (ex));
- camel_exception_clear (ex);
- } else {
- char *path, *uri;
-
- info = camel_store_get_folder_info (store, "/", TRUE, TRUE, TRUE, ex);
- populate_folder_urls (info, urls);
- camel_store_free_folder_info (store, info);
-
- *(input->folder) = create_trash_vfolder (input->name, urls, ex);
- if (camel_exception_is_set (ex))
- return;
-
- storage = mail_lookup_storage (store);
- g_return_if_fail (storage != NULL);
-
- uri = g_strdup_printf ("vfolder:%s", input->name);
- path = g_strdup_printf ("/%s", input->name);
- evolution_storage_new_folder (storage, path, g_basename (path),
- "mail", uri, input->name, FALSE);
- gtk_object_unref (GTK_OBJECT (storage));
- g_free (path);
- g_free (uri);
- }
-}
-
-static void
-cleanup_setup_trash (gpointer in_data, gpointer op_data, CamelException *ex)
-{
- setup_trash_input_t *input = (setup_trash_input_t *) in_data;
-
- g_free (input->name);
- g_free (input->store_uri);
-}
-
-static const mail_operation_spec op_setup_trash = {
- describe_setup_trash,
- 0,
- NULL,
- do_setup_trash,
- cleanup_setup_trash
-};
-
-void
-mail_do_setup_trash (const char *name, const char *store_uri, CamelFolder **folder)
-{
- setup_trash_input_t *input;
-
- g_return_if_fail (name != NULL);
- g_return_if_fail (store_uri != NULL);
- g_return_if_fail (folder != NULL);
-
- input = g_new (setup_trash_input_t, 1);
- input->name = g_strdup (name);
- input->store_uri = g_strdup (store_uri);
- input->folder = folder;
- mail_operation_queue (&op_setup_trash, input, TRUE);
-}
-
/* ** SAVE MESSAGES ******************************************************* */
struct _save_messages_msg {
diff --git a/mail/mail-ops.h b/mail/mail-ops.h
index eb47c68c4f..3ef3239100 100644
--- a/mail/mail-ops.h
+++ b/mail/mail-ops.h
@@ -43,7 +43,6 @@ void mail_do_append_mail (CamelFolder *folder,
void mail_do_transfer_messages (CamelFolder *source, GPtrArray *uids,
gboolean delete_from_source,
gchar *dest_uri);
-void mail_do_setup_trash (const char *name, const char *store_uri, CamelFolder **folder);
/* get a single message, asynchronously */
void mail_get_message(CamelFolder *folder, const char *uid,
@@ -58,9 +57,6 @@ void mail_get_messages(CamelFolder *folder, GPtrArray *uids,
int mail_get_folder(const char *uri,
void (*done) (char *uri, CamelFolder *folder, void *data), void *data);
-int mail_get_trash (const char *uri,
- void (*done) (char *store_uri, CamelFolder *folder, void *data), void *data);
-
/* and for a store */
int mail_get_store(const char *uri,
void (*done) (char *uri, CamelStore *store, void *data), void *data);
@@ -119,7 +115,3 @@ void mail_filter_folder(CamelFolder *source_folder, GPtrArray *uids,
/* convenience function for above */
void mail_filter_on_demand(CamelFolder *folder, GPtrArray *uids);
-
-
-
-
diff --git a/mail/mail-tools.c b/mail/mail-tools.c
index cb4325ca70..87a8872ffc 100644
--- a/mail/mail-tools.c
+++ b/mail/mail-tools.c
@@ -31,6 +31,7 @@
#include "camel/camel.h"
#include "camel/providers/vee/camel-vee-folder.h"
#include "mail-vfolder.h"
+#include "mail-vtrash.h"
#include "filter/vfolder-rule.h"
#include "filter/vfolder-context.h"
#include "filter/filter-option.h"
@@ -307,7 +308,14 @@ mail_tool_uri_to_folder (const char *uri, CamelException *ex)
CamelURL *url;
CamelStore *store = NULL;
CamelFolder *folder = NULL;
-
+
+ /* FIXME: This is a hack. */
+ if (!strncmp (uri, "vtrash:", 7)) {
+ folder = vtrash_uri_to_folder (uri, ex);
+ if (folder)
+ return folder;
+ }
+
url = camel_url_new (uri, ex);
if (!url)
return NULL;
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index e420a24178..6426979f36 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -344,3 +344,9 @@ vfolder_gui_add_from_message(CamelMimeMessage *msg, int flags, const char *sourc
vfolder_gui_add_rule(rule);
}
+EvolutionStorage *
+mail_vfolder_get_vfolder_storage (void)
+{
+ gtk_object_ref (GTK_OBJECT (vfolder_storage));
+ return vfolder_storage;
+}
diff --git a/mail/mail-vfolder.h b/mail/mail-vfolder.h
index 2ff19cc3ea..dc2d995d43 100644
--- a/mail/mail-vfolder.h
+++ b/mail/mail-vfolder.h
@@ -21,4 +21,6 @@ FilterPart *vfolder_create_part(const char *name);
void vfolder_gui_add_rule(VfolderRule *rule);
void vfolder_gui_add_from_message(CamelMimeMessage *msg, int flags, const char *source);
+EvolutionStorage *mail_vfolder_get_vfolder_storage (void);
+
#endif
diff --git a/mail/mail-vtrash.c b/mail/mail-vtrash.c
new file mode 100644
index 0000000000..c8e91ea669
--- /dev/null
+++ b/mail/mail-vtrash.c
@@ -0,0 +1,291 @@
+/* -*- 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.
+ *
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Evolution.h"
+#include "evolution-storage.h"
+#include "evolution-shell-component.h"
+
+#include "mail.h"
+#include "mail-vfolder.h"
+#include "mail-vtrash.h"
+#include "mail-tools.h"
+#include "mail-mt.h"
+
+#include "camel/camel.h"
+#include "filter/vfolder-rule.h"
+#include "filter/filter-part.h"
+
+#define d(x)
+
+static GHashTable *vtrash_hash = NULL;
+
+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;
+
+ if (!vtrash_hash)
+ return NULL;
+
+ if (strncmp (uri, "vtrash:", 7))
+ return NULL;
+
+ folder = g_hash_table_lookup (vtrash_hash, uri);
+
+ camel_object_ref (CAMEL_OBJECT (folder));
+
+ return folder;
+}
+
+static void
+vtrash_add (CamelStore *store, CamelFolder *folder, const char *store_uri, const char *name)
+{
+ EvolutionStorage *storage;
+ char *uri, *path;
+
+ g_return_if_fail (CAMEL_IS_STORE (store));
+
+ uri = g_strdup_printf ("vtrash:%s", store_uri);
+
+ 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) {
+ g_free (uri);
+ return;
+ }
+
+ if (!strcmp (store_uri, "file:/")) {
+ storage = mail_vfolder_get_vfolder_storage ();
+ } else {
+ storage = mail_lookup_storage (store);
+ }
+
+ if (!storage) {
+ g_free (uri);
+ return;
+ }
+
+ path = g_strdup_printf ("/%s", name);
+ evolution_storage_new_folder (storage, path, g_basename (path),
+ "mail", uri, name, FALSE);
+ gtk_object_unref (GTK_OBJECT (storage));
+
+ g_hash_table_insert (vtrash_hash, uri, folder);
+ camel_object_ref (CAMEL_OBJECT (folder));
+
+ g_free (path);
+}
+
+struct _get_trash_msg {
+ struct _mail_msg msg;
+
+ char *store_uri;
+ CamelFolder *folder;
+ void (*done) (char *store_uri, CamelFolder *folder, void *data);
+ void *data;
+};
+
+static char *
+get_trash_desc (struct _mail_msg *mm, int done)
+{
+ struct _get_trash_msg *m = (struct _get_trash_msg *)mm;
+
+ 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 (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/%s", evolution_dir, 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, 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) {
+ mail_tool_camel_lock_up ();
+ camel_vee_folder_add_folder (folder, sourcefolder);
+ mail_tool_camel_lock_down ();
+ } 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;
+ CamelStore *store;
+ GPtrArray *urls;
+
+ urls = g_ptr_array_new ();
+
+ /* we don't want to connect */
+ store = (CamelStore *) camel_session_get_service (session, m->store_uri,
+ CAMEL_PROVIDER_STORE, &mm->ex);
+ if (store == NULL) {
+ 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 (store, "/", TRUE, TRUE, TRUE, &mm->ex);
+ populate_folder_urls (info, urls);
+ camel_store_free_folder_info (store, info);
+
+ m->folder = create_trash_vfolder (_("vTrash"), urls, &mm->ex);
+ vtrash_add (store, m->folder, m->store_uri, _("vTrash"));
+ }
+ }
+}
+
+static void
+get_trash_got (struct _mail_msg *mm)
+{
+ struct _get_trash_msg *m = (struct _get_trash_msg *)mm;
+
+ if (m->done)
+ m->done (m->store_uri, m->folder, m->data);
+}
+
+static void
+get_trash_free (struct _mail_msg *mm)
+{
+ struct _get_trash_msg *m = (struct _get_trash_msg *)mm;
+
+ g_free (m->store_uri);
+ if (m->folder)
+ camel_object_unref (CAMEL_OBJECT (m->folder));
+}
+
+static struct _mail_msg_op get_trash_op = {
+ get_trash_desc,
+ get_trash_get,
+ get_trash_got,
+ get_trash_free,
+};
+
+int
+vtrash_create (const char *store_uri,
+ void (*done) (char *store_uri, CamelFolder *folder, void *data),
+ void *data)
+{
+ 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;
+
+ 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)
+{
+ if (!vtrash_hash)
+ return;
+
+ g_hash_table_foreach (vtrash_hash, free_folder, NULL);
+ g_hash_table_destroy (vtrash_hash);
+}
diff --git a/mail/mail-vtrash.h b/mail/mail-vtrash.h
new file mode 100644
index 0000000000..a53269e236
--- /dev/null
+++ b/mail/mail-vtrash.h
@@ -0,0 +1,46 @@
+/* -*- 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.
+ *
+ */
+
+#ifndef MAIL_VTRASH_H
+#define MAIL_VTRASH_H
+
+#include <camel/camel-store.h>
+#include <camel/camel-folder.h>
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+CamelFolder *vtrash_uri_to_folder (const char *uri, CamelException *ex);
+
+int vtrash_create (const char *store_uri,
+ void (*done) (char *store_uri, CamelFolder *folder, void *data),
+ void *data);
+
+void vtrash_cleanup (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* MAIL_VTRASH_H */
diff --git a/mail/main.c b/mail/main.c
index 6637ec5000..41e230765e 100644
--- a/mail/main.c
+++ b/mail/main.c
@@ -30,6 +30,7 @@
#include "composer/evolution-composer.h"
#include "mail.h"
#include "mail-mt.h"
+#include "mail-vtrash.h"
#if 0
static int blowup(int status)
@@ -121,7 +122,9 @@ main (int argc, char *argv [])
GDK_THREADS_ENTER ();
bonobo_main ();
GDK_THREADS_LEAVE ();
-
+
+ vtrash_cleanup ();
+
mail_config_write_on_exit ();
return 0;