[evolution-ews] Remove the store-summary so that the esources are created when the EAccount is disabled/enabled.
- From: Chenthill Palanisamy <pchen src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Remove the store-summary so that the esources are created when the EAccount is disabled/enabled.
- Date: Fri, 15 Jul 2011 05:55:05 +0000 (UTC)
commit 050e9bd9c9b2f66fd6a6ed1bddf1dee944b97e2b
Author: Chenthill Palanisamy <pchenthill novell com>
Date: Fri Jul 15 11:22:32 2011 +0530
Remove the store-summary so that the esources are created when
the EAccount is disabled/enabled.
Look into the comments in code for more details.
.../exchange-ews-account-listener.c | 31 +++++++++++------
src/camel/camel-ews-store-summary.c | 34 ++++++++++++++++++++
src/camel/camel-ews-store.c | 2 +
3 files changed, 56 insertions(+), 11 deletions(-)
---
diff --git a/src/account-setup-eplugin/exchange-ews-account-listener.c b/src/account-setup-eplugin/exchange-ews-account-listener.c
index 4656d59..2924856 100644
--- a/src/account-setup-eplugin/exchange-ews-account-listener.c
+++ b/src/account-setup-eplugin/exchange-ews-account-listener.c
@@ -25,6 +25,7 @@
#include <string.h>
#include <glib/gi18n-lib.h>
+#include <glib/gstdio.h>
#include <shell/e-shell.h>
#if EDS_CHECK_VERSION(2,33,0)
#include <mail/e-mail-session.h>
@@ -116,14 +117,18 @@ ews_account_info_free (EwsAccountInfo *info)
}
}
+EVO2 (CamelSession *session;)
+
static void
ews_account_removed (EAccountList *account_listener, EAccount *account)
{
EVO3(EShell *shell;)
EVO3(EShellBackend *shell_backend;)
- EVO3(EMailSession *session;)
+ EVO3(CamelSession *session;)
EwsAccountInfo *info = NULL;
- EVO3(CamelStore *store;)
+ CamelService *service;
+ gchar *summary_file, *storage_path;
+
if (!is_ews_account (account))
return;
@@ -137,16 +142,20 @@ ews_account_removed (EAccountList *account_listener, EAccount *account)
EVO3(shell = e_shell_get_default ();)
EVO3(shell_backend = e_shell_get_backend_by_name (shell, "mail");)
- EVO3(session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend));)
- EVO3(store = (CamelStore *) camel_session_get_service (CAMEL_SESSION (session),
- account->source->url, CAMEL_PROVIDER_STORE, NULL);)
-
- /* FIXME This has to go through the CamelStore instead of accessing through derived class.
- Ideally Evo should delete the cache when the email account is removed */
- EVO3(camel_ews_store_summary_remove (((CamelEwsStore *)store)->summary);)
+ EVO3 (session = (CamelSession *) e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend));)
+ service = camel_session_get_service (session, account->source->url, CAMEL_PROVIDER_STORE, NULL);
+ /* FIXME Use this until CamelStore gets camel_store_remove_storage API which would be available eds 3.2 onwards */
+ storage_path = camel_session_get_storage_path (session, service, NULL);
+ summary_file = g_build_filename (storage_path, "folder-tree-v2", NULL);
+ g_unlink (summary_file);
+
+ d(g_print ("Removed ews store summary: %s \n", summary_file);)
+
+ g_free (storage_path);
+ g_free (summary_file);
ews_account_info_free (info);
- EVO3(g_object_unref (store);)
+ g_object_unref (service);
}
static gboolean
diff --git a/src/camel/camel-ews-store-summary.c b/src/camel/camel-ews-store-summary.c
index 88e449f..0b65a3c 100644
--- a/src/camel/camel-ews-store-summary.c
+++ b/src/camel/camel-ews-store-summary.c
@@ -19,6 +19,8 @@ struct _CamelEwsStoreSummaryPrivate {
GHashTable *id_fname_hash;
GHashTable *fname_id_hash;
GStaticRecMutex s_lock;
+
+ GFileMonitor *monitor_delete;
};
G_DEFINE_TYPE (CamelEwsStoreSummary, camel_ews_store_summary, CAMEL_TYPE_OBJECT)
@@ -34,6 +36,8 @@ ews_store_summary_finalize (GObject *object)
g_hash_table_destroy (priv->fname_id_hash);
g_hash_table_destroy (priv->id_fname_hash);
g_static_rec_mutex_free (&priv->s_lock);
+ if (priv->monitor_delete)
+ g_object_unref (priv->monitor_delete);
g_free (priv);
@@ -118,14 +122,44 @@ load_id_fname_hash (CamelEwsStoreSummary *ews_summary)
g_slist_free (folders);
}
+/* we only care about delete and ignore create */
+static void
+monitor_delete_cb (GFileMonitor *monitor, GFile *file, GFile *other_file, GFileMonitorEvent event, gpointer user_data)
+{
+ CamelEwsStoreSummary *ews_summary = (CamelEwsStoreSummary *) user_data;
+
+ if (event == G_FILE_MONITOR_EVENT_DELETED) {
+ S_LOCK(ews_summary);
+
+ if (ews_summary->priv->key_file)
+ camel_ews_store_summary_clear (ews_summary);
+
+ S_UNLOCK(ews_summary);
+ }
+}
+
CamelEwsStoreSummary *
camel_ews_store_summary_new (const gchar *path)
{
CamelEwsStoreSummary *ews_summary;
+ GError *error = NULL;
+ GFile *file;
ews_summary = g_object_new (CAMEL_TYPE_EWS_STORE_SUMMARY, NULL);
ews_summary->priv->path = g_strdup (path);
+ file = g_file_new_for_path (path);
+ ews_summary->priv->monitor_delete = g_file_monitor_file (file, G_FILE_MONITOR_SEND_MOVED, NULL, &error);
+
+ /* Remove this once we have camel_store_remove_storage api, which should be available from 3.2 */
+ if (!error)
+ g_signal_connect (ews_summary->priv->monitor_delete, "changed", G_CALLBACK (monitor_delete_cb), ews_summary);
+ else {
+ g_warning ("CamelEwsStoreSummary: Error create monitor_delete: %s \n", error->message);
+ g_clear_error (&error);
+ }
+
+ g_object_unref (file);
return ews_summary;
}
diff --git a/src/camel/camel-ews-store.c b/src/camel/camel-ews-store.c
index 017bc1f..3f4a1fa 100644
--- a/src/camel/camel-ews-store.c
+++ b/src/camel/camel-ews-store.c
@@ -133,6 +133,8 @@ ews_store_construct (CamelService *service, CamelSession *session,
return FALSE;
}
+ /* Note. update account-listener plugin if filename is changed here, as it would remove the summary
+ by forming the path itself */
g_mkdir_with_parents (ews_store->storage_path, 0700);
summary_file = g_build_filename (ews_store->storage_path, "folder-tree-v2", NULL);
ews_store->summary = camel_ews_store_summary_new (summary_file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]