aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-ops.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-02-20 07:38:53 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-02-20 07:38:53 +0800
commit63f1ba7ab140cada16c54ad9913a3f95ff565410 (patch)
treef9b4b1859a92a3963266455d8e6e5e28af981089 /mail/mail-ops.c
parentd0cb488f876f17c41e03beec37ecae3b79971294 (diff)
downloadgsoc2013-evolution-63f1ba7ab140cada16c54ad9913a3f95ff565410.tar.gz
gsoc2013-evolution-63f1ba7ab140cada16c54ad9913a3f95ff565410.tar.zst
gsoc2013-evolution-63f1ba7ab140cada16c54ad9913a3f95ff565410.zip
New handy dandy function to ref and return the vfolder storage (will
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. svn path=/trunk/; revision=8288
Diffstat (limited to 'mail/mail-ops.c')
-rw-r--r--mail/mail-ops.c318
1 files changed, 1 insertions, 317 deletions
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 {