From 1fd4799efc2579d109deeb4215afd1b6c3d1e838 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 25 Jul 2012 09:35:59 +0200 Subject: UOA mc-plugin: CANNOT_SET_PARAMETERS depends on account's settings A special key has been added in .service files of online accounts telling its args should be considered readonly. Generic accounts (e.g. AIM) can still be modified. https://bugzilla.gnome.org/show_bug.cgi?id=680646 --- .../mc-plugin/mcp-account-manager-uoa.c | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'ubuntu-online-accounts') diff --git a/ubuntu-online-accounts/mc-plugin/mcp-account-manager-uoa.c b/ubuntu-online-accounts/mc-plugin/mcp-account-manager-uoa.c index 87d966f7d..d30ab133d 100644 --- a/ubuntu-online-accounts/mc-plugin/mcp-account-manager-uoa.c +++ b/ubuntu-online-accounts/mc-plugin/mcp-account-manager-uoa.c @@ -39,6 +39,7 @@ #define SERVICE_TYPE "IM" #define KEY_PREFIX "telepathy/" #define KEY_ACCOUNT_NAME "mc-account-name" +#define KEY_READONLY_PARAMS "mc-readonly-params" static void account_storage_iface_init (McpAccountStorageIface *iface); @@ -703,11 +704,30 @@ account_manager_uoa_get_identifier (const McpAccountStorage *storage, } static guint -account_manager_uoa_get_restrictions (const McpAccountStorage *self, +account_manager_uoa_get_restrictions (const McpAccountStorage *storage, const gchar *account_name) { + McpAccountManagerUoa *self = (McpAccountManagerUoa *) storage; + AgAccountService *service; + guint restrictions = TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_SERVICE; + GValue value = G_VALUE_INIT; + + /* If we don't know this account, we cannot do anything */ + service = g_hash_table_lookup (self->priv->accounts, account_name); + if (service == NULL) + return G_MAXUINT; + + g_value_init (&value, G_TYPE_BOOLEAN); + ag_account_service_get_value (service, + KEY_PREFIX KEY_READONLY_PARAMS, &value); + + if (g_value_get_boolean (&value)) + restrictions |= TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_PARAMETERS; + + g_value_unset (&value); + /* FIXME: We can't set Icon either, but there is no flag for that */ - return TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_SERVICE; + return restrictions; } static void -- cgit v1.2.1