]> git.0d.be Git - empathy.git/blobdiff - goa-mc-plugin/mcp-account-manager-goa.c
include telepathy-glib.h
[empathy.git] / goa-mc-plugin / mcp-account-manager-goa.c
index fd3942eaf359df2be0f1cb553828cc9b7ac9cbe1..4b64e546d988dd54c2b8418349f8edfdff85adea 100644 (file)
@@ -25,9 +25,7 @@
 
 #include "config.h"
 
-#include <glib/gi18n.h>
-
-#include <telepathy-glib/util.h>
+#include <telepathy-glib/telepathy-glib.h>
 
 #define GOA_API_IS_SUBJECT_TO_CHANGE /* awesome! */
 #include <goa/goa.h>
@@ -135,7 +133,10 @@ get_tp_parameters (GoaAccount *account)
       PARAM ("Service", "facebook");
 
       PARAM ("param-account", "chat.facebook.com");
+      PARAM ("param-server", "chat.facebook.com");
       PARAM ("param-require-encryption", "true");
+      PARAM ("param-fallback-servers",
+          "chat.facebook.com:443");
     }
   else if (!tp_strdiff (type, "windows_live"))
     {
@@ -146,6 +147,9 @@ get_tp_parameters (GoaAccount *account)
 
       PARAM ("param-account", "messenger.live.com");
       PARAM ("param-require-encryption", "true");
+      PARAM ("param-fallback-servers", "xmpp.messenger.live.com");
+      PARAM ("param-extra-certificate-identities",
+          "*.gateway.messenger.live.com");
     }
   else
     {
@@ -252,8 +256,6 @@ load_store (McpAccountManagerGoa *self)
 static void
 mcp_account_manager_goa_init (McpAccountManagerGoa *self)
 {
-  gchar *path;
-
   DEBUG ("GOA MC plugin initialised");
 
   self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
@@ -304,7 +306,6 @@ _goa_client_new_cb (GObject *obj,
     gpointer user_data)
 {
   McpAccountManagerGoa *self = user_data;
-  GoaClient *client;
   GList *accounts, *ptr;
   GError *error = NULL;
 
@@ -354,27 +355,27 @@ mcp_account_manager_goa_list (const McpAccountStorage *self,
 static void
 get_enabled (const McpAccountStorage *self,
     const McpAccountManager *am,
-    const gchar *acct,
-    GoaObject *object)
+    const gchar *acc,
+    GoaAccount *account)
 {
-  mcp_account_manager_set_value (am, acct, "Enabled",
-      goa_object_peek_chat (object) != NULL ? "true" : "false");
+  mcp_account_manager_set_value (am, acc, "Enabled",
+      goa_account_get_chat_disabled (account) == FALSE ? "true" : "false");
 }
 
 
 static gboolean
 mcp_account_manager_goa_get (const McpAccountStorage *self,
     const McpAccountManager *am,
-    const gchar *acct,
+    const gchar *acc,
     const gchar *key)
 {
   McpAccountManagerGoaPrivate *priv = GET_PRIVATE (self);
   GoaObject *object;
   GoaAccount *account;
 
-  DEBUG ("%s: %s, %s", G_STRFUNC, acct, key);
+  DEBUG ("%s: %s, %s", G_STRFUNC, acc, key);
 
-  object = g_hash_table_lookup (priv->accounts, acct);
+  object = g_hash_table_lookup (priv->accounts, acc);
 
   if (object == NULL)
     return FALSE;
@@ -389,28 +390,28 @@ mcp_account_manager_goa_get (const McpAccountStorage *self,
       /* load all keys */
       GHashTable *params = get_tp_parameters (account);
       GHashTableIter iter;
-      gpointer key, value;
+      gpointer k, value;
       GStrv keys;
       guint i;
-      gssize nkeys = 0;
+      gsize nkeys = 0;
 
       /* Properties from GOA */
       g_hash_table_iter_init (&iter, params);
-      while (g_hash_table_iter_next (&iter, &key, &value))
-        mcp_account_manager_set_value (am, acct, key, value);
+      while (g_hash_table_iter_next (&iter, &k, &value))
+        mcp_account_manager_set_value (am, acc, k, value);
 
       g_hash_table_unref (params);
 
       /* Stored properties */
-      keys = g_key_file_get_keys (priv->store, acct, &nkeys, NULL);
+      keys = g_key_file_get_keys (priv->store, acc, &nkeys, NULL);
 
       for (i = 0; i < nkeys; i++)
         {
-          gchar *v = g_key_file_get_value (priv->store, acct, keys[i], NULL);
+          gchar *v = g_key_file_get_value (priv->store, acc, keys[i], NULL);
 
           if (v != NULL)
             {
-              mcp_account_manager_set_value (am, acct, keys[i], v);
+              mcp_account_manager_set_value (am, acc, keys[i], v);
               g_free (v);
             }
         }
@@ -418,11 +419,11 @@ mcp_account_manager_goa_get (const McpAccountStorage *self,
       g_strfreev (keys);
 
       /* Enabled */
-      get_enabled (self, am, acct, object);
+      get_enabled (self, am, acc, account);
     }
   else if (!tp_strdiff (key, "Enabled"))
     {
-      get_enabled (self, am, acct, object);
+      get_enabled (self, am, acc, account);
     }
   else
     {
@@ -433,11 +434,11 @@ mcp_account_manager_goa_get (const McpAccountStorage *self,
       value = g_hash_table_lookup (params, key);
 
       if (value == NULL)
-        value = g_key_file_get_value (priv->store, acct, key, NULL);
+        value = g_key_file_get_value (priv->store, acc, key, NULL);
       else
         value = g_strdup (value);
 
-      mcp_account_manager_set_value (am, acct, key, value);
+      mcp_account_manager_set_value (am, acc, key, value);
 
       g_hash_table_unref (params);
       g_free (value);
@@ -452,7 +453,7 @@ account_is_in_goa (const McpAccountStorage *self,
 {
   McpAccountManagerGoaPrivate *priv = GET_PRIVATE (self);
 
-  return (g_hash_table_lookup (priv->accounts, acct) != NULL);
+  return (g_hash_table_lookup (priv->accounts, account) != NULL);
 }
 
 static gboolean
@@ -463,23 +464,37 @@ mcp_account_manager_goa_set (const McpAccountStorage *self,
     const gchar *val)
 {
   McpAccountManagerGoaPrivate *priv = GET_PRIVATE (self);
-  GError *error = NULL;
 
   if (!account_is_in_goa (self, account))
     return FALSE;
 
-  /* No need to save Enabled, it's up to the GOA configuration if the account
-   * is configured or not. */
+  DEBUG ("%s: (%s, %s, %s)", G_STRFUNC, account, key, val);
+
   if (!tp_strdiff (key, "Enabled"))
-    return TRUE;
+    {
+      GoaObject *object;
+      GoaAccount *acc;
 
-  DEBUG ("%s: (%s, %s, %s)", G_STRFUNC, account, key, val);
+      object = g_hash_table_lookup (priv->accounts, account);
+
+      if (object == NULL)
+        return FALSE;
+
+      acc = goa_object_peek_account (object);
+
+      if (acc == NULL)
+        return FALSE;
+
+      goa_account_set_chat_disabled (acc, tp_strdiff (val, "true"));
+      goto out;
+    }
 
   if (val != NULL)
     g_key_file_set_value (priv->store, account, key, val);
   else
     g_key_file_remove_key (priv->store, account, key, NULL);
 
+ out:
   /* Pretend we save everything so MC won't save this in accounts.cfg */
   return TRUE;
 }
@@ -562,21 +577,20 @@ mcp_account_manager_goa_get_restrictions (const McpAccountStorage *self,
     const gchar *account)
 {
   return TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_PARAMETERS |
-         TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_SERVICE |
-         TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_ENABLED;
+         TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_SERVICE;
 }
 
 
 static void
 mcp_account_manager_goa_get_identifier (const McpAccountStorage *self,
-    const gchar *acct,
+    const gchar *acc,
     GValue *identifier)
 {
   McpAccountManagerGoaPrivate *priv = GET_PRIVATE (self);
   GoaObject *object;
   GoaAccount *account;
 
-  object = g_hash_table_lookup (priv->accounts, acct);
+  object = g_hash_table_lookup (priv->accounts, acc);
   g_return_if_fail (object != NULL);
 
   account = goa_object_peek_account (object);