From 066999baa8215c538540cd010745942b386916f8 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 13 Nov 2013 20:21:49 +0000 Subject: [PATCH 18/26] McdStorage: remove "owns" method We now know whose account it is, without having to do this. --- mission-control-plugins/account-storage.c | 45 ------------------------------- mission-control-plugins/account-storage.h | 7 ----- src/mcd-storage.c | 15 +++-------- tests/twisted/dbus-account-plugin.c | 17 ------------ 4 files changed, 4 insertions(+), 80 deletions(-) diff --git a/mission-control-plugins/account-storage.c b/mission-control-plugins/account-storage.c index b64e998..098e336 100644 --- a/mission-control-plugins/account-storage.c +++ b/mission-control-plugins/account-storage.c @@ -65,7 +65,6 @@ * iface->get_additional_info = foo_plugin_get_additional_info; * iface->get_restrictions = foo_plugin_get_restrictions; * iface->create = foo_plugin_create; - * iface->owns = foo_plugin_owns; * iface->set_attribute = foo_plugin_set_attribute; * iface->set_parameter = foo_plugin_set_parameter; * } @@ -219,19 +218,6 @@ default_set_parameter (McpAccountStorage *storage, return FALSE; } -static gboolean -default_owns (McpAccountStorage *storage, - McpAccountManager *am, - const gchar *account) -{ - /* This has the side-effect of pushing the "manager" key back into @am, - * but that should be a no-op in practice: we always call this - * method in priority order and stop at the first one that says "yes", - * and @am's idea of what "manager" is should have come from that same - * plugin anyway. */ - return mcp_account_storage_get (storage, am, account, "manager"); -} - static void class_init (gpointer klass, gpointer data) @@ -249,7 +235,6 @@ class_init (gpointer klass, iface->get_identifier = default_get_identifier; iface->get_additional_info = default_get_additional_info; iface->get_restrictions = default_get_restrictions; - iface->owns = default_owns; iface->set_attribute = default_set_attribute; iface->set_parameter = default_set_parameter; @@ -1086,33 +1071,3 @@ mcp_account_storage_emit_reconnect (McpAccountStorage *storage, { g_signal_emit (storage, signals[RECONNECT], 0, account); } - -/** - * mcp_account_storage_owns: - * @storage: an #McpAccountStorage instance - * @am: an #McpAccountManager instance - * @account: the unique name (object-path tail) of an account - * - * Check whether @account is stored in @storage. The highest-priority - * plugin for which this function returns %TRUE is considered to be - * responsible for @account. - * - * There is a default implementation, which calls mcp_account_storage_get() - * for the well-known key "manager". - * - * Returns: %TRUE if @account is stored in @storage - * - * Since: 5.15.0 - */ -gboolean -mcp_account_storage_owns (McpAccountStorage *storage, - McpAccountManager *am, - const gchar *account) -{ - McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage); - - g_return_val_if_fail (iface != NULL, FALSE); - g_return_val_if_fail (iface->owns != NULL, FALSE); - - return iface->owns (storage, am, account); -} diff --git a/mission-control-plugins/account-storage.h b/mission-control-plugins/account-storage.h index ff3633e..44f7bd6 100644 --- a/mission-control-plugins/account-storage.h +++ b/mission-control-plugins/account-storage.h @@ -124,9 +124,6 @@ struct _McpAccountStorageIface McpAccountStorageCreate create; /* Since 5.15.0 */ - gboolean (*owns) (McpAccountStorage *storage, - McpAccountManager *am, - const gchar *account); gboolean (*set_attribute) (McpAccountStorage *storage, McpAccountManager *am, const gchar *account, @@ -193,10 +190,6 @@ const gchar *mcp_account_storage_name (const McpAccountStorage *storage); const gchar *mcp_account_storage_description (const McpAccountStorage *storage); const gchar *mcp_account_storage_provider (const McpAccountStorage *storage); -gboolean mcp_account_storage_owns (McpAccountStorage *storage, - McpAccountManager *am, - const gchar *account); - gboolean mcp_account_storage_set_attribute (McpAccountStorage *storage, McpAccountManager *am, const gchar *account, diff --git a/src/mcd-storage.c b/src/mcd-storage.c index 020c037..92a2eef 100644 --- a/src/mcd-storage.c +++ b/src/mcd-storage.c @@ -727,22 +727,15 @@ McpAccountStorage * mcd_storage_get_plugin (McdStorage *self, const gchar *account) { - GList *store = stores; - McpAccountManager *ma = MCP_ACCOUNT_MANAGER (self); - McpAccountStorage *owner = NULL; + McdStorageAccount *sa; g_return_val_if_fail (MCD_IS_STORAGE (self), NULL); g_return_val_if_fail (account != NULL, NULL); - for (; store != NULL && owner == NULL; store = g_list_next (store)) - { - McpAccountStorage *plugin = store->data; - - if (mcp_account_storage_owns (plugin, ma, account)) - owner = plugin; - } + sa = lookup_account (self, account); + g_return_val_if_fail (account != NULL, NULL); - return owner; + return sa->plugin; } /* diff --git a/tests/twisted/dbus-account-plugin.c b/tests/twisted/dbus-account-plugin.c index 01410a1..733fbef 100644 --- a/tests/twisted/dbus-account-plugin.c +++ b/tests/twisted/dbus-account-plugin.c @@ -1552,22 +1552,6 @@ test_dbus_account_plugin_get_restrictions (const McpAccountStorage *storage, return account->restrictions; } -static gboolean -test_dbus_account_plugin_owns (McpAccountStorage *storage, - McpAccountManager *am, - const gchar *account_name) -{ - TestDBusAccountPlugin *self = TEST_DBUS_ACCOUNT_PLUGIN (storage); - Account *account = lookup_account (self, account_name); - - DEBUG ("%s", account_name); - - if (!self->active || account == NULL) - return FALSE; - - return TRUE; -} - static void account_storage_iface_init (McpAccountStorageIface *iface) { @@ -1588,5 +1572,4 @@ account_storage_iface_init (McpAccountStorageIface *iface) iface->get_additional_info = test_dbus_account_plugin_get_additional_info; iface->get_restrictions = test_dbus_account_plugin_get_restrictions; iface->create = test_dbus_account_plugin_create; - iface->owns = test_dbus_account_plugin_owns; } -- 1.8.4.3