aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathon Jongsma <jonathon@quotidian.org>2009-12-12 01:51:55 +0800
committerJonathon Jongsma <jonathon@quotidian.org>2009-12-16 04:16:09 +0800
commit0eef4618ca677cd11d54ce0ae8804b5b1ededf3b (patch)
tree0672e4006fe079420010fa34bd7ab46ae55af1c5
parent6e73a7a8f31c3b890ad900960a24b930cfeb13ed (diff)
downloadgsoc2013-evolution-0eef4618ca677cd11d54ce0ae8804b5b1ededf3b.tar
gsoc2013-evolution-0eef4618ca677cd11d54ce0ae8804b5b1ededf3b.tar.gz
gsoc2013-evolution-0eef4618ca677cd11d54ce0ae8804b5b1ededf3b.tar.bz2
gsoc2013-evolution-0eef4618ca677cd11d54ce0ae8804b5b1ededf3b.tar.lz
gsoc2013-evolution-0eef4618ca677cd11d54ce0ae8804b5b1ededf3b.tar.xz
gsoc2013-evolution-0eef4618ca677cd11d54ce0ae8804b5b1ededf3b.tar.zst
gsoc2013-evolution-0eef4618ca677cd11d54ce0ae8804b5b1ededf3b.zip
Remove mail-config, vfolder, and filter deps from mail-folder-cache
Instead of pushing the updates to the right places, the folder cache simply emits the appropriate signals and other objects are responsible for listening and handling them appropriately. This allows us to cut down the dependencies of MailFolderCache significantly, which is a huge step towards allowing us to split it off for the backend. Another nice thing about this is that it allows us to trim a lot of 'public' api from the filter, vfolder, and config classes that were only used by the cache. Now that stuff can all be internal since they're pulling changes rather than having the changes pushed. The last remaining problematic dependency in MailFolderCache is EmFolderTreeModel. That is next on the chopping block. https://bugzilla.gnome.org/show_bug.cgi?id=604627
-rw-r--r--mail/mail-config.c279
-rw-r--r--mail/mail-config.h4
-rw-r--r--mail/mail-folder-cache.c20
-rw-r--r--mail/mail-vfolder.c41
-rw-r--r--mail/mail-vfolder.h9
-rw-r--r--modules/mail/e-mail-shell-backend.c22
6 files changed, 212 insertions, 163 deletions
diff --git a/mail/mail-config.c b/mail/mail-config.c
index 7f0fa42504..41ac85a373 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -58,12 +58,13 @@
#include <libedataserverui/e-passwords.h>
-#include "mail-session.h"
+#include "e-mail-local.h"
+#include "em-utils.h"
#include "mail-config.h"
+#include "mail-folder-cache.h"
#include "mail-mt.h"
+#include "mail-session.h"
#include "mail-tools.h"
-#include "em-utils.h"
-#include "e-mail-local.h"
typedef struct {
GConfClient *gconf;
@@ -251,131 +252,6 @@ gconf_int_value_changed (GConfClient *client,
}
}
-/* Config struct routines */
-void
-mail_config_init (void)
-{
- GConfClientNotifyFunc func;
- const gchar *key;
-
- if (config)
- return;
-
- config = g_new0 (MailConfig, 1);
- config->gconf = gconf_client_get_default ();
- config->gtkrc = g_build_filename (
- e_get_user_data_dir (), "mail",
- "config", "gtkrc-mail-fonts", NULL);
-
- mail_config_clear ();
-
- gtk_rc_parse (config->gtkrc);
-
- /* Composer Configuration */
-
- gconf_client_add_dir (
- config->gconf, "/apps/evolution/mail/composer",
- GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
-
- key = "/apps/evolution/mail/composer/spell_color";
- func = (GConfClientNotifyFunc) gconf_style_changed;
- gconf_client_notify_add (
- config->gconf, key, func, NULL, NULL, NULL);
-
- key = "/apps/evolution/mail/composer/outlook_filenames";
- func = (GConfClientNotifyFunc) gconf_outlook_filenames_changed;
- gconf_outlook_filenames_changed (config->gconf, 0, NULL, NULL);
- gconf_client_notify_add (
- config->gconf, key, func, NULL, NULL, NULL);
-
- /* Display Configuration */
-
- gconf_client_add_dir (
- config->gconf, "/apps/evolution/mail/display",
- GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
-
- key = "/apps/evolution/mail/display/address_compress";
- func = (GConfClientNotifyFunc) gconf_bool_value_changed;
- gconf_client_notify_add (
- config->gconf, key, func,
- &config->address_compress, NULL, NULL);
- config->address_compress =
- gconf_client_get_bool (config->gconf, key, NULL);
-
- key = "/apps/evolution/mail/display/address_count";
- func = (GConfClientNotifyFunc) gconf_int_value_changed;
- gconf_client_notify_add (
- config->gconf, key, func,
- &config->address_count, NULL, NULL);
- config->address_count =
- gconf_client_get_int (config->gconf, key, NULL);
-
- key = "/apps/evolution/mail/display/citation_colour";
- func = (GConfClientNotifyFunc) gconf_style_changed;
- gconf_client_notify_add (
- config->gconf, key, func, NULL, NULL, NULL);
-
- key = "/apps/evolution/mail/display/mark_citations";
- func = (GConfClientNotifyFunc) gconf_style_changed;
- gconf_client_notify_add (
- config->gconf, key, func, NULL, NULL, NULL);
-
- /* Font Configuration */
-
- gconf_client_add_dir (
- config->gconf, "/apps/evolution/mail/display/fonts",
- GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
-
- key = "/apps/evolution/mail/display/fonts";
- func = (GConfClientNotifyFunc) gconf_style_changed;
- gconf_client_notify_add (
- config->gconf, key, func, NULL, NULL, NULL);
-
- /* Junk Configuration */
-
- gconf_client_add_dir (
- config->gconf, "/apps/evolution/mail/junk",
- GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
-
- key = "/apps/evolution/mail/junk/check_custom_header";
- func = (GConfClientNotifyFunc) gconf_jh_check_changed;
- gconf_client_notify_add (
- config->gconf, key, func, NULL, NULL, NULL);
- config->jh_check =
- gconf_client_get_bool (config->gconf, key, NULL);
-
- key = "/apps/evolution/mail/junk/custom_header";
- func = (GConfClientNotifyFunc) gconf_jh_headers_changed;
- gconf_client_notify_add (
- config->gconf, key, func, NULL, NULL, NULL);
-
- key = "/apps/evolution/mail/junk/lookup_addressbook";
- func = (GConfClientNotifyFunc) gconf_bool_value_changed;
- gconf_client_notify_add (
- config->gconf, key, func,
- &config->book_lookup, NULL, NULL);
- config->book_lookup =
- gconf_client_get_bool (config->gconf, key, NULL);
-
- key = "/apps/evolution/mail/junk/lookup_addressbook_local_only";
- func = (GConfClientNotifyFunc) gconf_bool_value_changed;
- gconf_client_notify_add (
- config->gconf, key, func,
- &config->book_lookup_local_only, NULL, NULL);
- config->book_lookup_local_only =
- gconf_client_get_bool (config->gconf, key, NULL);
-
- key = "/desktop/gnome/lockdown/disable_command_line";
- func = (GConfClientNotifyFunc) gconf_bool_value_changed;
- gconf_client_notify_add (
- config->gconf, key, func,
- &config->scripts_disabled, NULL, NULL);
- config->scripts_disabled =
- gconf_client_get_bool (config->gconf, key, NULL);
-
- gconf_jh_check_changed (config->gconf, 0, NULL, config);
-}
-
void
mail_config_clear (void)
{
@@ -578,7 +454,7 @@ uri_to_evname (const gchar *uri, const gchar *prefix)
return tmp;
}
-void
+static void
mail_config_uri_renamed (GCompareFunc uri_cmp, const gchar *old, const gchar *new)
{
EAccountList *account_list;
@@ -633,7 +509,7 @@ mail_config_uri_renamed (GCompareFunc uri_cmp, const gchar *old, const gchar *ne
mail_config_write ();
}
-void
+static void
mail_config_uri_deleted (GCompareFunc uri_cmp, const gchar *uri)
{
EAccountList *account_list;
@@ -737,3 +613,146 @@ mail_config_get_lookup_book_local_only (void)
return config->book_lookup_local_only;
}
+
+static void
+folder_deleted_cb (MailFolderCache *cache, CamelStore *store, const gchar *uri, gpointer user_data)
+{
+ mail_config_uri_deleted(CAMEL_STORE_CLASS(CAMEL_OBJECT_GET_CLASS(store))->compare_folder_name, uri);
+}
+
+static void
+folder_renamed_cb (MailFolderCache *cache, CamelStore *store, const gchar *olduri, const gchar *newuri, gpointer user_data)
+{
+ mail_config_uri_renamed(CAMEL_STORE_CLASS(CAMEL_OBJECT_GET_CLASS(store))->compare_folder_name,
+ olduri, newuri);
+}
+
+/* Config struct routines */
+void
+mail_config_init (void)
+{
+ GConfClientNotifyFunc func;
+ const gchar *key;
+
+ if (config)
+ return;
+
+ config = g_new0 (MailConfig, 1);
+ config->gconf = gconf_client_get_default ();
+ config->gtkrc = g_build_filename (
+ e_get_user_data_dir (), "mail",
+ "config", "gtkrc-mail-fonts", NULL);
+
+ mail_config_clear ();
+
+ gtk_rc_parse (config->gtkrc);
+
+ /* Composer Configuration */
+
+ gconf_client_add_dir (
+ config->gconf, "/apps/evolution/mail/composer",
+ GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+
+ key = "/apps/evolution/mail/composer/spell_color";
+ func = (GConfClientNotifyFunc) gconf_style_changed;
+ gconf_client_notify_add (
+ config->gconf, key, func, NULL, NULL, NULL);
+
+ key = "/apps/evolution/mail/composer/outlook_filenames";
+ func = (GConfClientNotifyFunc) gconf_outlook_filenames_changed;
+ gconf_outlook_filenames_changed (config->gconf, 0, NULL, NULL);
+ gconf_client_notify_add (
+ config->gconf, key, func, NULL, NULL, NULL);
+
+ /* Display Configuration */
+
+ gconf_client_add_dir (
+ config->gconf, "/apps/evolution/mail/display",
+ GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+
+ key = "/apps/evolution/mail/display/address_compress";
+ func = (GConfClientNotifyFunc) gconf_bool_value_changed;
+ gconf_client_notify_add (
+ config->gconf, key, func,
+ &config->address_compress, NULL, NULL);
+ config->address_compress =
+ gconf_client_get_bool (config->gconf, key, NULL);
+
+ key = "/apps/evolution/mail/display/address_count";
+ func = (GConfClientNotifyFunc) gconf_int_value_changed;
+ gconf_client_notify_add (
+ config->gconf, key, func,
+ &config->address_count, NULL, NULL);
+ config->address_count =
+ gconf_client_get_int (config->gconf, key, NULL);
+
+ key = "/apps/evolution/mail/display/citation_colour";
+ func = (GConfClientNotifyFunc) gconf_style_changed;
+ gconf_client_notify_add (
+ config->gconf, key, func, NULL, NULL, NULL);
+
+ key = "/apps/evolution/mail/display/mark_citations";
+ func = (GConfClientNotifyFunc) gconf_style_changed;
+ gconf_client_notify_add (
+ config->gconf, key, func, NULL, NULL, NULL);
+
+ /* Font Configuration */
+
+ gconf_client_add_dir (
+ config->gconf, "/apps/evolution/mail/display/fonts",
+ GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+
+ key = "/apps/evolution/mail/display/fonts";
+ func = (GConfClientNotifyFunc) gconf_style_changed;
+ gconf_client_notify_add (
+ config->gconf, key, func, NULL, NULL, NULL);
+
+ /* Junk Configuration */
+
+ gconf_client_add_dir (
+ config->gconf, "/apps/evolution/mail/junk",
+ GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+
+ key = "/apps/evolution/mail/junk/check_custom_header";
+ func = (GConfClientNotifyFunc) gconf_jh_check_changed;
+ gconf_client_notify_add (
+ config->gconf, key, func, NULL, NULL, NULL);
+ config->jh_check =
+ gconf_client_get_bool (config->gconf, key, NULL);
+
+ key = "/apps/evolution/mail/junk/custom_header";
+ func = (GConfClientNotifyFunc) gconf_jh_headers_changed;
+ gconf_client_notify_add (
+ config->gconf, key, func, NULL, NULL, NULL);
+
+ key = "/apps/evolution/mail/junk/lookup_addressbook";
+ func = (GConfClientNotifyFunc) gconf_bool_value_changed;
+ gconf_client_notify_add (
+ config->gconf, key, func,
+ &config->book_lookup, NULL, NULL);
+ config->book_lookup =
+ gconf_client_get_bool (config->gconf, key, NULL);
+
+ key = "/apps/evolution/mail/junk/lookup_addressbook_local_only";
+ func = (GConfClientNotifyFunc) gconf_bool_value_changed;
+ gconf_client_notify_add (
+ config->gconf, key, func,
+ &config->book_lookup_local_only, NULL, NULL);
+ config->book_lookup_local_only =
+ gconf_client_get_bool (config->gconf, key, NULL);
+
+ key = "/desktop/gnome/lockdown/disable_command_line";
+ func = (GConfClientNotifyFunc) gconf_bool_value_changed;
+ gconf_client_notify_add (
+ config->gconf, key, func,
+ &config->scripts_disabled, NULL, NULL);
+ config->scripts_disabled =
+ gconf_client_get_bool (config->gconf, key, NULL);
+
+ gconf_jh_check_changed (config->gconf, 0, NULL, config);
+
+ g_signal_connect (mail_folder_cache_get_default (), "folder-deleted",
+ (GCallback) folder_deleted_cb, NULL);
+ g_signal_connect (mail_folder_cache_get_default (), "folder-renamed",
+ (GCallback) folder_renamed_cb, NULL);
+}
diff --git a/mail/mail-config.h b/mail/mail-config.h
index 6f127ece44..dc55403d93 100644
--- a/mail/mail-config.h
+++ b/mail/mail-config.h
@@ -85,10 +85,6 @@ gint mail_config_get_address_count (void);
EAccountService *mail_config_get_default_transport (void);
-/* uri's got changed by the store, etc */
-void mail_config_uri_renamed (GCompareFunc uri_cmp, const gchar *old, const gchar *new);
-void mail_config_uri_deleted (GCompareFunc uri_cmp, const gchar *uri);
-
/* static utility functions */
gchar *mail_config_folder_to_cachename (CamelFolder *folder, const gchar *prefix);
gchar *mail_config_folder_to_safe_url (CamelFolder *folder);
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index 9d9a9b4ec2..769fa1df10 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -58,9 +58,6 @@
#include "mail-tools.h"
/* For notifications of changes */
-#include "mail-vfolder.h"
-#include "mail-autofilter.h"
-#include "mail-config.h"
#include "em-folder-tree-model.h"
#include "em-event.h"
@@ -187,26 +184,17 @@ real_flush_updates (gpointer o, gpointer event_data, gpointer data)
g_mutex_unlock (self->priv->stores_mutex);
if (up->remove) {
- /* XXX: what's going on here? */
if (up->delete) {
- mail_vfolder_delete_uri(up->store, up->uri);
- mail_filter_delete_uri(up->store, up->uri);
- mail_config_uri_deleted(CAMEL_STORE_CLASS(CAMEL_OBJECT_GET_CLASS(up->store))->compare_folder_name, up->uri);
-
+ g_signal_emit (self, signals[FOLDER_DELETED], 0, up->store, up->uri);
} else
- mail_vfolder_notify_uri_unavailable (up->store, up->uri);
+ g_signal_emit (self, signals[FOLDER_UNAVAILABLE], 0, up->store, up->uri);
} else {
- /* We can tell the vfolder code though */
if (up->olduri && up->add) {
- d(printf("renaming folder '%s' to '%s'\n", up->olduri, up->uri));
- mail_vfolder_rename_uri(up->store, up->olduri, up->uri);
- mail_filter_rename_uri(up->store, up->olduri, up->uri);
- mail_config_uri_renamed(CAMEL_STORE_CLASS(CAMEL_OBJECT_GET_CLASS(up->store))->compare_folder_name,
- up->olduri, up->uri);
+ g_signal_emit (self, signals[FOLDER_RENAMED], 0, up->store, up->olduri, up->uri);
}
if (!up->olduri && up->add)
- mail_vfolder_notify_uri_available (up->store, up->uri);
+ g_signal_emit (self, signals[FOLDER_AVAILABLE], 0, up->store, up->uri);
}
/* update unread counts */
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 9380922d26..b4a8330776 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -550,7 +550,7 @@ done:
* uri. This function has a transient effect and does not permanently modify
* the vfolder filter rules on disk.
*/
-void
+static void
mail_vfolder_notify_uri_available (CamelStore *store, const gchar *uri)
{
mail_vfolder_add_uri (store, uri, FALSE);
@@ -565,7 +565,7 @@ mail_vfolder_notify_uri_available (CamelStore *store, const gchar *uri)
* uri. This function has a transient effect and does not permanently modify
* the vfolder filter rules on disk.
*/
-void
+static void
mail_vfolder_notify_uri_unavailable (CamelStore *store, const gchar *uri)
{
mail_vfolder_add_uri (store, uri, TRUE);
@@ -588,7 +588,7 @@ mail_vfolder_notify_uri_unavailable (CamelStore *store, const gchar *uri)
*
* NOTE: This function must be called from the main thread.
*/
-void
+static void
mail_vfolder_delete_uri(CamelStore *store, const gchar *curi)
{
EFilterRule *rule;
@@ -679,7 +679,7 @@ done:
}
/* called when a uri is renamed in a store */
-void
+static void
mail_vfolder_rename_uri(CamelStore *store, const gchar *cfrom, const gchar *cto)
{
EFilterRule *rule;
@@ -972,6 +972,30 @@ store_folder_renamed(CamelObject *o, gpointer event_data, gpointer data)
}
}
+static void
+folder_available_cb (MailFolderCache *cache, CamelStore *store, const gchar *uri, gpointer user_data)
+{
+ mail_vfolder_notify_uri_available (store, uri);
+}
+
+static void
+folder_unavailable_cb (MailFolderCache *cache, CamelStore *store, const gchar *uri, gpointer user_data)
+{
+ mail_vfolder_notify_uri_unavailable (store, uri);
+}
+
+static void
+folder_deleted_cb (MailFolderCache *cache, CamelStore *store, const gchar *uri, gpointer user_data)
+{
+ mail_vfolder_delete_uri (store, uri);
+}
+
+static void
+folder_renamed_cb (MailFolderCache *cache, CamelStore *store, const gchar *olduri, const gchar *newuri, gpointer user_data)
+{
+ mail_vfolder_rename_uri (store, olduri, newuri);
+}
+
void
vfolder_load_storage(void)
{
@@ -1049,6 +1073,15 @@ vfolder_load_storage(void)
gconf = mail_config_get_gconf_client();
if (!gconf_client_get_bool (gconf, "/apps/evolution/mail/display/enable_vfolders", NULL))
gconf_client_set_bool (gconf, "/apps/evolution/mail/display/enable_vfolders", TRUE, NULL);
+
+ g_signal_connect (mail_folder_cache_get_default (), "folder-available",
+ (GCallback) folder_available_cb, NULL);
+ g_signal_connect (mail_folder_cache_get_default (), "folder-unavailable",
+ (GCallback) folder_unavailable_cb, NULL);
+ g_signal_connect (mail_folder_cache_get_default (), "folder-deleted",
+ (GCallback) folder_deleted_cb, NULL);
+ g_signal_connect (mail_folder_cache_get_default (), "folder-renamed",
+ (GCallback) folder_renamed_cb, NULL);
}
void
diff --git a/mail/mail-vfolder.h b/mail/mail-vfolder.h
index 8e44ec44d5..a70cdd8757 100644
--- a/mail/mail-vfolder.h
+++ b/mail/mail-vfolder.h
@@ -44,15 +44,6 @@ void vfolder_gui_add_from_address (CamelInternetAddress *addr, gint flags, const
GList * mail_vfolder_get_sources_local (void);
GList * mail_vfolder_get_sources_remote (void);
-void mail_vfolder_notify_uri_available(CamelStore *store, const gchar *uri);
-void mail_vfolder_notify_uri_unavailable(CamelStore *store, const gchar *uri);
-
-/* note that a folder has changed name (uri) */
-void mail_vfolder_rename_uri(CamelStore *store, const gchar *from, const gchar *to);
-
-/* remove a uri that should be removed from vfolders permanently */
-void mail_vfolder_delete_uri(CamelStore *store, const gchar *uri);
-
/* close up, clean up */
void mail_vfolder_shutdown (void);
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index f1a85a8927..be6bd1d199 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -56,7 +56,9 @@
#include "em-mailer-prefs.h"
#include "em-network-prefs.h"
#include "em-utils.h"
+#include "mail-autofilter.h"
#include "mail-config.h"
+#include "mail-folder-cache.h"
#include "mail-ops.h"
#include "mail-send-recv.h"
#include "mail-session.h"
@@ -768,6 +770,18 @@ mail_shell_backend_window_created_cb (EShell *shell,
}
static void
+folder_deleted_cb (MailFolderCache *cache, CamelStore *store, const gchar *uri, gpointer user_data)
+{
+ mail_filter_delete_uri(store, uri);
+}
+
+static void
+folder_renamed_cb (MailFolderCache *cache, CamelStore *store, const gchar *olduri, const gchar *newuri, gpointer user_data)
+{
+ mail_filter_rename_uri(store, olduri, newuri);
+}
+
+static void
mail_shell_backend_constructed (GObject *object)
{
EMailShellBackendPrivate *priv;
@@ -833,6 +847,14 @@ mail_shell_backend_constructed (GObject *object)
G_CALLBACK (mail_shell_backend_window_created_cb),
shell_backend);
+ g_signal_connect (
+ mail_folder_cache_get_default (), "folder-deleted",
+ G_CALLBACK (folder_deleted_cb), NULL);
+
+ g_signal_connect (
+ mail_folder_cache_get_default (), "folder-renamed",
+ G_CALLBACK (folder_renamed_cb), NULL);
+
mail_config_init ();
mail_msg_init ();