diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-02-24 00:51:45 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-02-24 00:51:45 +0800 |
commit | ac97d963b038541b84aa15b4eaa3d28fd9d60114 (patch) | |
tree | bd75dd9084c6315c49f094e5989ba5741f16e7ef /mail | |
parent | c06709a5751b39e4a9cbf931759245f6abaa3d53 (diff) | |
download | gsoc2013-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')
-rw-r--r-- | mail/ChangeLog | 29 | ||||
-rw-r--r-- | mail/component-factory.c | 6 | ||||
-rw-r--r-- | mail/mail-ops.c | 2 | ||||
-rw-r--r-- | mail/mail-tools.c | 25 | ||||
-rw-r--r-- | mail/mail-vtrash.c | 198 | ||||
-rw-r--r-- | mail/mail-vtrash.h | 8 | ||||
-rw-r--r-- | mail/main.c | 2 |
7 files changed, 59 insertions, 211 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 8257b94375..1dd0f0a163 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,11 +1,32 @@ +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() + 2001-02-23 Iain Holmes <iain@ximian.com> * component-factory.c (owner_set_cb): Init the importer here. - * mail-importer.[ch] (mail_importer_create_folder): Add a function that creates - new folders in the shell. - (mail_importer_init): Take in an EvolutionShellClient, and get the local_storage - corba_object from it. + * mail-importer.[ch] (mail_importer_create_folder): Add a function + that creates new folders in the shell. + (mail_importer_init): Take in an EvolutionShellClient, and get the + local_storage corba_object from it. 2001-02-22 Jeffrey Stedfast <fejj@ximian.com> diff --git a/mail/component-factory.c b/mail/component-factory.c index 2c408db446..94945c8ad1 100644 --- a/mail/component-factory.c +++ b/mail/component-factory.c @@ -216,7 +216,7 @@ owner_set_cb (EvolutionShellComponent *shell_component, g_free (uri); } - vtrash_create ("file:/", NULL, NULL); + mail_vtrash_create ("file:/", _("vTrash")); mail_session_enable_interaction (TRUE); @@ -443,8 +443,8 @@ mail_load_storages (GNOME_Evolution_Shell shell, const GSList *sources, gboolean camel_exception_get_description (&ex)); camel_exception_clear (&ex); } else { - /* create the vTrash folder */ - vtrash_create (service->url, NULL, NULL); + /* add the vTrash folder */ + mail_vtrash_add (CAMEL_STORE (store), service->url, _("vTrash")); } } diff --git a/mail/mail-ops.c b/mail/mail-ops.c index d0d8c930dc..6a68cbd6be 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -1091,7 +1091,7 @@ static void get_folder_got(struct _mail_msg *mm) struct _get_folder_msg *m = (struct _get_folder_msg *)mm; if (m->done) - m->done(m->uri, m->folder, m->data); + m->done (m->uri, m->folder, m->data); } static void get_folder_free(struct _mail_msg *mm) diff --git a/mail/mail-tools.c b/mail/mail-tools.c index ba457bd4cd..dcffb8ce50 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -31,7 +31,6 @@ #include "camel/camel.h" #include "camel/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" @@ -171,7 +170,6 @@ mail_tool_get_inbox (const gchar *url, CamelException *ex) return folder; } - /* why is this function so stupidly complex when allthe work is done elsehwere? */ char * @@ -308,33 +306,34 @@ mail_tool_uri_to_folder (const char *uri, CamelException *ex) CamelURL *url; CamelStore *store = NULL; CamelFolder *folder = NULL; + int offset = 0; g_return_val_if_fail (uri != NULL, NULL); - /* FIXME: This is a hack. */ - if (!strncmp (uri, "vtrash:", 7)) { - folder = vtrash_uri_to_folder (uri, ex); - if (folder) - return folder; - } + if (!strncmp (uri, "vtrash:", 7)) + offset = 7; - url = camel_url_new (uri, ex); + url = camel_url_new (uri + offset, ex); if (!url) return NULL; if (!strcmp (url->protocol, "vfolder")) { folder = vfolder_uri_to_folder (uri, ex); } else { - store = camel_session_get_store (session, uri, ex); + store = camel_session_get_store (session, uri + offset, ex); if (store) { char *name; - + if (url->path && *url->path) name = url->path + 1; else name = ""; - folder = camel_store_get_folder ( - store, name, CAMEL_STORE_FOLDER_CREATE, ex); + + if (offset) + folder = camel_store_get_trash (store, ex); + else + folder = camel_store_get_folder (store, name, + CAMEL_STORE_FOLDER_CREATE, ex); } } 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); -} diff --git a/mail/mail-vtrash.h b/mail/mail-vtrash.h index a53269e236..1aac0c1e9f 100644 --- a/mail/mail-vtrash.h +++ b/mail/mail-vtrash.h @@ -31,13 +31,9 @@ extern "C" { #pragma } #endif /* __cplusplus */ -CamelFolder *vtrash_uri_to_folder (const char *uri, CamelException *ex); +void mail_vtrash_add (CamelStore *store, const char *store_uri, const char *name); -int vtrash_create (const char *store_uri, - void (*done) (char *store_uri, CamelFolder *folder, void *data), - void *data); - -void vtrash_cleanup (void); +int mail_vtrash_create (const char *store_uri, const char *name); #ifdef __cplusplus } diff --git a/mail/main.c b/mail/main.c index 41e230765e..8da4c9420b 100644 --- a/mail/main.c +++ b/mail/main.c @@ -123,8 +123,6 @@ main (int argc, char *argv []) bonobo_main (); GDK_THREADS_LEAVE (); - vtrash_cleanup (); - mail_config_write_on_exit (); return 0; |