]> git.0d.be Git - empathy.git/commitdiff
UOA mc-plugin: CANNOT_SET_PARAMETERS depends on account's settings
authorXavier Claessens <xavier.claessens@collabora.co.uk>
Wed, 25 Jul 2012 07:35:59 +0000 (09:35 +0200)
committerXavier Claessens <xavier.claessens@collabora.co.uk>
Thu, 26 Jul 2012 13:26:08 +0000 (15:26 +0200)
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

ubuntu-online-accounts/mc-plugin/mcp-account-manager-uoa.c

index 87d966f7d8069f381dcdf3413530d7fdfd301f12..d30ab133d3d41d9f3d85685c5698061890040766 100644 (file)
@@ -39,6 +39,7 @@
 #define SERVICE_TYPE "IM"
 #define KEY_PREFIX "telepathy/"
 #define KEY_ACCOUNT_NAME "mc-account-name"
 #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);
 
 
 static void account_storage_iface_init (McpAccountStorageIface *iface);
 
@@ -703,11 +704,30 @@ account_manager_uoa_get_identifier (const McpAccountStorage *storage,
 }
 
 static guint
 }
 
 static guint
-account_manager_uoa_get_restrictions (const McpAccountStorage *self,
+account_manager_uoa_get_restrictions (const McpAccountStorage *storage,
     const gchar *account_name)
 {
     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 */
   /* 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
 }
 
 static void