X-Git-Url: https://git.0d.be/?p=empathy.git;a=blobdiff_plain;f=goa-mc-plugin%2Fmcp-account-manager-goa.c;h=fd3942eaf359df2be0f1cb553828cc9b7ac9cbe1;hp=7319f8cfc29036cadb5adb684d3bdff1e78d1173;hb=2a7fa12bcf9c0ee5a9ff506bc88af2194990dabc;hpb=fe369729ae300f341fa250420b1596900da58742 diff --git a/goa-mc-plugin/mcp-account-manager-goa.c b/goa-mc-plugin/mcp-account-manager-goa.c index 7319f8cf..fd3942ea 100644 --- a/goa-mc-plugin/mcp-account-manager-goa.c +++ b/goa-mc-plugin/mcp-account-manager-goa.c @@ -23,6 +23,8 @@ * Danielle Madeley */ +#include "config.h" + #include #include @@ -40,7 +42,7 @@ #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" @@ -80,7 +82,7 @@ mcp_account_manager_goa_finalize (GObject *self) { 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); @@ -125,18 +127,35 @@ get_tp_parameters (GoaAccount *account) 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-require-encryption", "true"); + } + 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"); + } 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 @@ -160,7 +179,7 @@ get_tp_account_name (GoaAccount *account) (char *) g_hash_table_lookup (params, "protocol"), type, id); - g_hash_table_destroy (params); + g_hash_table_unref (params); return name; } @@ -373,22 +392,19 @@ mcp_account_manager_goa_get (const McpAccountStorage *self, gpointer key, value; GStrv keys; guint i; - gssize n; + gssize 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); - 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, acct, &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); @@ -399,6 +415,8 @@ mcp_account_manager_goa_get (const McpAccountStorage *self, } } + g_strfreev (keys); + /* Enabled */ get_enabled (self, am, acct, object); } @@ -421,13 +439,21 @@ mcp_account_manager_goa_get (const McpAccountStorage *self, mcp_account_manager_set_value (am, acct, 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, acct) != NULL); +} static gboolean mcp_account_manager_goa_set (const McpAccountStorage *self, @@ -439,6 +465,9 @@ mcp_account_manager_goa_set (const McpAccountStorage *self, 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. */ if (!tp_strdiff (key, "Enabled")) @@ -464,6 +493,9 @@ mcp_account_manager_goa_delete (const McpAccountStorage *self, { 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)