aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-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
5 files changed, 190 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);