* Danielle Madeley <danielle.madeley@collabora.co.uk>
*/
-#include <glib/gi18n.h>
-
-#include <telepathy-glib/util.h>
+#include "config.h"
+#include "mcp-account-manager-goa.h"
#define GOA_API_IS_SUBJECT_TO_CHANGE /* awesome! */
#include <goa/goa.h>
-#include "mcp-account-manager-goa.h"
-
#define DEBUG g_debug
#define GET_PRIVATE(self) (((McpAccountManagerGoa *) self)->priv)
#define DECLARE_GASYNC_CALLBACK(name) \
#define PLUGIN_NAME "goa"
#define PLUGIN_PRIORITY (MCP_ACCOUNT_STORAGE_PLUGIN_PRIO_KEYRING + 10)
#define PLUGIN_DESCRIPTION "Provide Telepathy Accounts from GOA"
-#define PLUGIN_PROVIDER "org.gnome.OnlineAccounts"
+#define PLUGIN_PROVIDER EMPATHY_GOA_PROVIDER
#define INITIAL_COMMENT "Parameters of GOA Telepathy accounts"
{
McpAccountManagerGoaPrivate *priv = GET_PRIVATE (self);
- g_hash_table_destroy (priv->accounts);
+ g_hash_table_unref (priv->accounts);
g_key_file_free (priv->store);
g_free (priv->filename);
PARAM ("param-extra-certificate-identities", "talk.google.com");
PARAM ("param-require-encryption", "true");
}
+ else if (!tp_strdiff (type, "facebook"))
+ {
+ PARAM ("manager", "gabble");
+ PARAM ("protocol", "jabber");
+ PARAM ("Icon", "im-facebook");
+ 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"))
+ {
+ PARAM ("manager", "gabble");
+ PARAM ("protocol", "jabber");
+ PARAM ("Icon", "im-msn");
+ PARAM ("Service", "windows-live");
+
+ 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
{
- /* unknown account type */
- g_hash_table_destroy (params);
+ DEBUG ("Unknown account type %s", type);
+ g_hash_table_unref (params);
return NULL;
}
- /* TODO: add Facebook support */
-
/* generic properties */
PARAM ("DisplayName", goa_account_get_presentation_identity (account));
- PARAM ("ConnectAutomatically", "true");
#undef PARAM
(char *) g_hash_table_lookup (params, "protocol"),
type, id);
- g_hash_table_destroy (params);
+ g_hash_table_unref (params);
return name;
}
static void
mcp_account_manager_goa_init (McpAccountManagerGoa *self)
{
- gchar *path;
-
DEBUG ("GOA MC plugin initialised");
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
gpointer user_data)
{
McpAccountManagerGoa *self = user_data;
- GoaClient *client;
GList *accounts, *ptr;
GError *error = NULL;
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;
/* load all keys */
GHashTable *params = get_tp_parameters (account);
GHashTableIter iter;
- gpointer key, value;
+ gpointer k, value;
GStrv keys;
guint i;
- gssize n;
+ 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_destroy (params);
+ g_hash_table_unref (params);
/* Stored properties */
- keys = g_key_file_get_keys (priv->store, acct, &n, NULL);
-
- if (keys == NULL)
- n = 0;
+ keys = g_key_file_get_keys (priv->store, acc, &nkeys, NULL);
- for (i = 0; i < n; i++)
+ 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);
}
}
+ 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
{
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_destroy (params);
+ g_hash_table_unref (params);
g_free (value);
}
return TRUE;
}
+static gboolean
+account_is_in_goa (const McpAccountStorage *self,
+ const gchar *account)
+{
+ McpAccountManagerGoaPrivate *priv = GET_PRIVATE (self);
+
+ return (g_hash_table_lookup (priv->accounts, account) != NULL);
+}
static gboolean
mcp_account_manager_goa_set (const McpAccountStorage *self,
const gchar *val)
{
McpAccountManagerGoaPrivate *priv = GET_PRIVATE (self);
- GError *error = NULL;
- /* No need to save Enabled, it's up to the GOA configuration if the account
- * is configured or not. */
- if (!tp_strdiff (key, "Enabled"))
- return TRUE;
+ if (!account_is_in_goa (self, account))
+ return FALSE;
DEBUG ("%s: (%s, %s, %s)", G_STRFUNC, account, key, val);
+ if (!tp_strdiff (key, "Enabled"))
+ {
+ GoaObject *object;
+ GoaAccount *acc;
+
+ 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;
}
{
McpAccountManagerGoaPrivate *priv = GET_PRIVATE (self);
+ if (!account_is_in_goa (self, account))
+ return FALSE;
+
DEBUG ("%s: (%s, %s)", G_STRFUNC, account, key);
if (key == NULL)
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);
static void
account_storage_iface_init (McpAccountStorageIface *iface)
{
- mcp_account_storage_iface_set_name (iface, PLUGIN_NAME);
- mcp_account_storage_iface_set_desc (iface, PLUGIN_DESCRIPTION);
- mcp_account_storage_iface_set_priority (iface, PLUGIN_PRIORITY);
- mcp_account_storage_iface_set_provider (iface, PLUGIN_PROVIDER);
+ iface->name = PLUGIN_NAME;
+ iface->desc = PLUGIN_DESCRIPTION;
+ iface->priority = PLUGIN_PRIORITY;
+ iface->provider = PLUGIN_PROVIDER;
-#define IMPLEMENT(x) mcp_account_storage_iface_implement_##x(iface, \
- mcp_account_manager_goa_##x)
+#define IMPLEMENT(x) iface->x = mcp_account_manager_goa_##x
IMPLEMENT (get);
IMPLEMENT (list);
IMPLEMENT (set);