aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVitaly Minko <vitaly.minko@gmail.com>2010-10-11 21:51:38 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-10-11 21:53:38 +0800
commit888df7fc53595e18c5de077860881bd10f327cc5 (patch)
tree60c12c1d33b4443fe7d5cdba6b26ac06fc95c030 /src
parent4722911e579557b37f543ee03d51562c02272184 (diff)
downloadgsoc2013-empathy-888df7fc53595e18c5de077860881bd10f327cc5.tar
gsoc2013-empathy-888df7fc53595e18c5de077860881bd10f327cc5.tar.gz
gsoc2013-empathy-888df7fc53595e18c5de077860881bd10f327cc5.tar.bz2
gsoc2013-empathy-888df7fc53595e18c5de077860881bd10f327cc5.tar.lz
gsoc2013-empathy-888df7fc53595e18c5de077860881bd10f327cc5.tar.xz
gsoc2013-empathy-888df7fc53595e18c5de077860881bd10f327cc5.tar.zst
gsoc2013-empathy-888df7fc53595e18c5de077860881bd10f327cc5.zip
enable imported Pidgin accounts if needed (#594145)
Diffstat (limited to 'src')
-rw-r--r--src/empathy-import-pidgin.c53
-rw-r--r--src/empathy-import-utils.c1
-rw-r--r--src/empathy-import-utils.h2
-rw-r--r--src/empathy-import-widget.c11
4 files changed, 62 insertions, 5 deletions
diff --git a/src/empathy-import-pidgin.c b/src/empathy-import-pidgin.c
index ab69d417b..4de9bce96 100644
--- a/src/empathy-import-pidgin.c
+++ b/src/empathy-import-pidgin.c
@@ -93,6 +93,8 @@ static PidginCmMapItem pidgin_cm_map[] =
#define PIDGIN_ACCOUNT_TAG_PROTOCOL "protocol"
#define PIDGIN_ACCOUNT_TAG_PASSWORD "password"
#define PIDGIN_ACCOUNT_TAG_SETTINGS "settings"
+#define PIDGIN_SETTING_PROP_UI "ui"
+#define PIDGIN_SETTING_PROP_NAME "name"
#define PIDGIN_SETTING_PROP_TYPE "type"
#define PIDGIN_PROTOCOL_BONJOUR "bonjour"
#define PIDGIN_PROTOCOL_NOVELL "novell"
@@ -110,7 +112,7 @@ import_dialog_pidgin_parse_setting (EmpathyImportAccountData *data,
/* We can't do anything if the setting don't have a name */
tag_name = (gchar *) xmlGetProp (setting,
- (xmlChar *) PIDGIN_ACCOUNT_TAG_NAME);
+ (xmlChar *) PIDGIN_SETTING_PROP_NAME);
if (!tag_name)
return;
@@ -183,10 +185,54 @@ import_dialog_pidgin_parse_setting (EmpathyImportAccountData *data,
g_free (content);
}
+static void
+import_dialog_pidgin_handle_settings (EmpathyImportAccountData *data,
+ xmlNodePtr settings)
+{
+ xmlNodePtr setting;
+ gchar *tag_ui, *name, *type, *content;
+
+ tag_ui = (gchar *) xmlGetProp (settings, (xmlChar *) PIDGIN_SETTING_PROP_UI);
+
+ /* UI settings - fetch the Enabled parameter.
+ * The expected value of the ui property is 'gtk-gaim', which looks obsolete,
+ * but still valid for 2.7.3.
+ */
+ if (tag_ui && !tp_strdiff (tag_ui, "gtk-gaim"))
+ {
+ for (setting = settings->children; setting; setting = setting->next)
+ {
+ name = (gchar *) xmlGetProp (setting,
+ (xmlChar *) PIDGIN_SETTING_PROP_NAME);
+ type = (gchar *) xmlGetProp (setting,
+ (xmlChar *) PIDGIN_SETTING_PROP_TYPE);
+ /* The Enabled parameter is supposed to be boolean.
+ * Pidgin name of the setting is 'auto-login'.
+ */
+ if (!tp_strdiff (name, "auto-login") && !tp_strdiff (type, "bool"))
+ {
+ content = (gchar *) xmlNodeGetContent (setting);
+ data->enabled = (0 != (gint) g_ascii_strtod (content, NULL));
+ g_free (content);
+ }
+ g_free (type);
+ g_free (name);
+ }
+ }
+ /* General settings. */
+ else
+ {
+ for (setting = settings->children; setting; setting = setting->next)
+ import_dialog_pidgin_parse_setting (data, setting);
+ }
+
+ g_free (tag_ui);
+}
+
GList *
empathy_import_pidgin_load (void)
{
- xmlNodePtr rootnode, node, child, setting;
+ xmlNodePtr rootnode, node, child;
xmlParserCtxtPtr ctxt;
xmlDocPtr doc;
gchar *filename;
@@ -310,8 +356,7 @@ empathy_import_pidgin_load (void)
/* Other settings */
else if (!tp_strdiff ((gchar *) child->name,
PIDGIN_ACCOUNT_TAG_SETTINGS))
- for (setting = child->children; setting; setting = setting->next)
- import_dialog_pidgin_parse_setting (data, setting);
+ import_dialog_pidgin_handle_settings (data, child);
}
/* If we have the needed settings, add the account data to the list,
diff --git a/src/empathy-import-utils.c b/src/empathy-import-utils.c
index 520f056f4..7e69d6235 100644
--- a/src/empathy-import-utils.c
+++ b/src/empathy-import-utils.c
@@ -40,6 +40,7 @@ empathy_import_account_data_new (const gchar *source)
data->source = g_strdup (source);
data->protocol = NULL;
data->connection_manager = NULL;
+ data->enabled = FALSE;
return data;
}
diff --git a/src/empathy-import-utils.h b/src/empathy-import-utils.h
index 20af25a91..09b85e0bc 100644
--- a/src/empathy-import-utils.h
+++ b/src/empathy-import-utils.h
@@ -37,6 +37,8 @@ typedef struct
gchar *connection_manager;
/* The name of the account import source */
gchar *source;
+ /* Indicates whether the account is enabled by default */
+ gboolean enabled;
} EmpathyImportAccountData;
typedef enum {
diff --git a/src/empathy-import-widget.c b/src/empathy-import-widget.c
index 09898180a..fc1e2f532 100644
--- a/src/empathy-import-widget.c
+++ b/src/empathy-import-widget.c
@@ -167,6 +167,7 @@ import_widget_create_account_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
+ TpAccountManager *account_manager;
TpAccount *account;
GError *error = NULL;
EmpathyImportWidget *self = user_data;
@@ -184,6 +185,13 @@ import_widget_create_account_cb (GObject *source,
DEBUG ("account created\n");
+ if (tp_account_is_enabled (account))
+ {
+ account_manager = tp_account_manager_dup ();
+ empathy_connect_new_account (account, account_manager);
+ g_object_unref (account_manager);
+ }
+
g_object_unref (self);
}
@@ -208,7 +216,8 @@ import_widget_add_account (EmpathyImportWidget *self,
DEBUG ("display name: %s\n", display_name);
- properties = g_hash_table_new (NULL, NULL);
+ properties = tp_asv_new (NULL, NULL);
+ tp_asv_set_boolean (properties, TP_IFACE_ACCOUNT ".Enabled", data->enabled);
tp_account_manager_create_account_async (account_manager,
(const gchar*) data->connection_manager, data->protocol, display_name,