From 7886ce66389ec021468a3ab7022c0603ae6a20b6 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 14 Nov 2013 18:01:33 +0000 Subject: [PATCH 26/26] McdAccountManager: ignore altered-one, deleted, toggled from wrong plugin Now that the account knows its own storage plugin, this is pretty easy. --- src/mcd-account-manager.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c index 1a9f687..c0d4dd7 100644 --- a/src/mcd-account-manager.c +++ b/src/mcd-account-manager.c @@ -171,7 +171,7 @@ async_altered_one_manager_cb (McdManager *cm, static void -altered_one_cb (GObject *storage, +altered_one_cb (McpAccountStorage *storage, const gchar *account_name, const gchar *key, gpointer data) @@ -181,6 +181,7 @@ altered_one_cb (GObject *storage, McdAccount *account = NULL; McdManager *cm = NULL; const gchar *cm_name = NULL; + McpAccountStorage *its_plugin; account = mcd_account_manager_lookup_account (am, account_name); @@ -190,6 +191,18 @@ altered_one_cb (GObject *storage, return; } + its_plugin = mcd_account_get_storage_plugin (account); + + if (storage != its_plugin) + { + DEBUG ("Ignoring altered-one from plugin %s because account %s " + "belongs to %s", + mcp_account_storage_name (storage), + account_name, + mcp_account_storage_name (its_plugin)); + return; + } + /* in theory, the CM is already ready by this point, but make sure: */ cm_name = mcd_account_get_manager_name (account); @@ -321,6 +334,7 @@ toggled_cb (GObject *plugin, const gchar *name, gboolean on, gpointer data) McdAccountManager *manager = MCD_ACCOUNT_MANAGER (data); McdAccount *account = NULL; GError *error = NULL; + McpAccountStorage *its_plugin; account = mcd_account_manager_lookup_account (manager, name); @@ -334,6 +348,18 @@ toggled_cb (GObject *plugin, const gchar *name, gboolean on, gpointer data) return; } + its_plugin = mcd_account_get_storage_plugin (account); + + if (storage_plugin != its_plugin) + { + DEBUG ("Ignoring toggled signal from plugin %s because account %s " + "belongs to %s", + mcp_account_storage_name (storage_plugin), + name, + mcp_account_storage_name (its_plugin)); + return; + } + _mcd_account_set_enabled (account, on, FALSE, MCD_DBUS_PROP_SET_FLAG_ALREADY_IN_STORAGE, &error); @@ -408,6 +434,18 @@ deleted_cb (GObject *plugin, const gchar *name, gpointer data) if (account != NULL) { const gchar * object_path = mcd_account_get_object_path (account); + McpAccountStorage *its_plugin = mcd_account_get_storage_plugin ( + account); + + if (storage_plugin != its_plugin) + { + DEBUG ("Ignoring altered-one from plugin %s because account %s " + "belongs to %s", + mcp_account_storage_name (storage_plugin), + name, + mcp_account_storage_name (its_plugin)); + return; + } g_object_ref (account); /* this unhooks the account's signal handlers */ -- 1.8.4.3