1
From: Vitaly Minko <vitaly.minko@gmail.com>
2
Subject: Enable imported Pidgin accounts if needed.
3
Origin: http://git.gnome.org/browse/empathy/commit/?id=888df7fc53595e18c5de077860881bd10f327cc5
4
Bug: https://bugs.gnome.org/594145
5
Bug-Ubuntu: https://launchpad.net/bugs/622215
8
diff --git a/src/empathy-import-pidgin.c b/src/empathy-import-pidgin.c
9
index ab69d41..4de9bce 100644
10
--- a/src/empathy-import-pidgin.c
11
+++ b/src/empathy-import-pidgin.c
12
@@ -93,6 +93,8 @@ static PidginCmMapItem pidgin_cm_map[] =
13
#define PIDGIN_ACCOUNT_TAG_PROTOCOL "protocol"
14
#define PIDGIN_ACCOUNT_TAG_PASSWORD "password"
15
#define PIDGIN_ACCOUNT_TAG_SETTINGS "settings"
16
+#define PIDGIN_SETTING_PROP_UI "ui"
17
+#define PIDGIN_SETTING_PROP_NAME "name"
18
#define PIDGIN_SETTING_PROP_TYPE "type"
19
#define PIDGIN_PROTOCOL_BONJOUR "bonjour"
20
#define PIDGIN_PROTOCOL_NOVELL "novell"
21
@@ -110,7 +112,7 @@ import_dialog_pidgin_parse_setting (EmpathyImportAccountData *data,
23
/* We can't do anything if the setting don't have a name */
24
tag_name = (gchar *) xmlGetProp (setting,
25
- (xmlChar *) PIDGIN_ACCOUNT_TAG_NAME);
26
+ (xmlChar *) PIDGIN_SETTING_PROP_NAME);
30
@@ -183,10 +185,54 @@ import_dialog_pidgin_parse_setting (EmpathyImportAccountData *data,
35
+import_dialog_pidgin_handle_settings (EmpathyImportAccountData *data,
36
+ xmlNodePtr settings)
39
+ gchar *tag_ui, *name, *type, *content;
41
+ tag_ui = (gchar *) xmlGetProp (settings, (xmlChar *) PIDGIN_SETTING_PROP_UI);
43
+ /* UI settings - fetch the Enabled parameter.
44
+ * The expected value of the ui property is 'gtk-gaim', which looks obsolete,
45
+ * but still valid for 2.7.3.
47
+ if (tag_ui && !tp_strdiff (tag_ui, "gtk-gaim"))
49
+ for (setting = settings->children; setting; setting = setting->next)
51
+ name = (gchar *) xmlGetProp (setting,
52
+ (xmlChar *) PIDGIN_SETTING_PROP_NAME);
53
+ type = (gchar *) xmlGetProp (setting,
54
+ (xmlChar *) PIDGIN_SETTING_PROP_TYPE);
55
+ /* The Enabled parameter is supposed to be boolean.
56
+ * Pidgin name of the setting is 'auto-login'.
58
+ if (!tp_strdiff (name, "auto-login") && !tp_strdiff (type, "bool"))
60
+ content = (gchar *) xmlNodeGetContent (setting);
61
+ data->enabled = (0 != (gint) g_ascii_strtod (content, NULL));
68
+ /* General settings. */
71
+ for (setting = settings->children; setting; setting = setting->next)
72
+ import_dialog_pidgin_parse_setting (data, setting);
79
empathy_import_pidgin_load (void)
81
- xmlNodePtr rootnode, node, child, setting;
82
+ xmlNodePtr rootnode, node, child;
83
xmlParserCtxtPtr ctxt;
86
@@ -310,8 +356,7 @@ empathy_import_pidgin_load (void)
88
else if (!tp_strdiff ((gchar *) child->name,
89
PIDGIN_ACCOUNT_TAG_SETTINGS))
90
- for (setting = child->children; setting; setting = setting->next)
91
- import_dialog_pidgin_parse_setting (data, setting);
92
+ import_dialog_pidgin_handle_settings (data, child);
95
/* If we have the needed settings, add the account data to the list,
96
diff --git a/src/empathy-import-utils.c b/src/empathy-import-utils.c
97
index 520f056..7e69d62 100644
98
--- a/src/empathy-import-utils.c
99
+++ b/src/empathy-import-utils.c
100
@@ -40,6 +40,7 @@ empathy_import_account_data_new (const gchar *source)
101
data->source = g_strdup (source);
102
data->protocol = NULL;
103
data->connection_manager = NULL;
104
+ data->enabled = FALSE;
108
diff --git a/src/empathy-import-utils.h b/src/empathy-import-utils.h
109
index 20af25a..09b85e0 100644
110
--- a/src/empathy-import-utils.h
111
+++ b/src/empathy-import-utils.h
112
@@ -37,6 +37,8 @@ typedef struct
113
gchar *connection_manager;
114
/* The name of the account import source */
116
+ /* Indicates whether the account is enabled by default */
118
} EmpathyImportAccountData;
121
diff --git a/src/empathy-import-widget.c b/src/empathy-import-widget.c
122
index 0989818..fc1e2f5 100644
123
--- a/src/empathy-import-widget.c
124
+++ b/src/empathy-import-widget.c
125
@@ -167,6 +167,7 @@ import_widget_create_account_cb (GObject *source,
126
GAsyncResult *result,
129
+ TpAccountManager *account_manager;
131
GError *error = NULL;
132
EmpathyImportWidget *self = user_data;
133
@@ -184,6 +185,13 @@ import_widget_create_account_cb (GObject *source,
135
DEBUG ("account created\n");
137
+ if (tp_account_is_enabled (account))
139
+ account_manager = tp_account_manager_dup ();
140
+ empathy_connect_new_account (account, account_manager);
141
+ g_object_unref (account_manager);
144
g_object_unref (self);
147
@@ -208,7 +216,8 @@ import_widget_add_account (EmpathyImportWidget *self,
149
DEBUG ("display name: %s\n", display_name);
151
- properties = g_hash_table_new (NULL, NULL);
152
+ properties = tp_asv_new (NULL, NULL);
153
+ tp_asv_set_boolean (properties, TP_IFACE_ACCOUNT ".Enabled", data->enabled);
155
tp_account_manager_create_account_async (account_manager,
156
(const gchar*) data->connection_manager, data->protocol, display_name,