~ubuntu-branches/ubuntu/natty/empathy/natty

« back to all changes in this revision

Viewing changes to debian/patches/enable_pidgin_imported_contacts.patch

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell, Omer Akram
  • Date: 2011-01-06 14:32:31 UTC
  • Revision ID: james.westby@ubuntu.com-20110106143231-ol0gyfqi7h1ch8kv
Tags: 2.32.2-0ubuntu3
* debian/patches/00git_folks_api.patch:
  - Update to latest folks API

[ Omer Akram ]
* debian/patches/enable_pidgin_imported_contacts.patch:
  - Enable pidgin imported accounts by default. (LP: #622215)
* debian/patches/reword_subscription_dailog_to_be_less_technical.patch:
  - Reword subscription request dialog to be less technical. (LP: #670197)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
6
 
 
7
---
 
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,
 
22
 
 
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);
 
27
   if (!tag_name)
 
28
     return;
 
29
 
 
30
@@ -183,10 +185,54 @@ import_dialog_pidgin_parse_setting (EmpathyImportAccountData *data,
 
31
   g_free (content);
 
32
 }
 
33
 
 
34
+static void
 
35
+import_dialog_pidgin_handle_settings (EmpathyImportAccountData *data,
 
36
+                                      xmlNodePtr settings)
 
37
+{
 
38
+  xmlNodePtr setting;
 
39
+  gchar *tag_ui, *name, *type, *content;
 
40
+
 
41
+  tag_ui = (gchar *) xmlGetProp (settings, (xmlChar *) PIDGIN_SETTING_PROP_UI);
 
42
+
 
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.
 
46
+   */
 
47
+  if (tag_ui && !tp_strdiff (tag_ui, "gtk-gaim"))
 
48
+    {
 
49
+      for (setting = settings->children; setting; setting = setting->next)
 
50
+        {
 
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'.
 
57
+           */
 
58
+          if (!tp_strdiff (name, "auto-login") && !tp_strdiff (type, "bool"))
 
59
+            {
 
60
+              content = (gchar *) xmlNodeGetContent (setting);
 
61
+              data->enabled = (0 != (gint) g_ascii_strtod (content, NULL));
 
62
+              g_free (content);
 
63
+            }
 
64
+          g_free (type);
 
65
+          g_free (name);
 
66
+        }
 
67
+    }
 
68
+  /* General settings. */
 
69
+  else
 
70
+    {
 
71
+      for (setting = settings->children; setting; setting = setting->next)
 
72
+        import_dialog_pidgin_parse_setting (data, setting);
 
73
+    }
 
74
+
 
75
+  g_free (tag_ui);
 
76
+}
 
77
+
 
78
 GList *
 
79
 empathy_import_pidgin_load (void)
 
80
 {
 
81
-  xmlNodePtr rootnode, node, child, setting;
 
82
+  xmlNodePtr rootnode, node, child;
 
83
   xmlParserCtxtPtr ctxt;
 
84
   xmlDocPtr doc;
 
85
   gchar *filename;
 
86
@@ -310,8 +356,7 @@ empathy_import_pidgin_load (void)
 
87
           /* Other settings */
 
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);
 
93
         }
 
94
 
 
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;
 
105
 
 
106
   return data;
 
107
 }
 
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 */
 
115
   gchar *source;
 
116
+  /* Indicates whether the account is enabled by default */
 
117
+  gboolean enabled;
 
118
 } EmpathyImportAccountData;
 
119
 
 
120
 typedef enum {
 
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,
 
127
   gpointer user_data)
 
128
 {
 
129
+  TpAccountManager *account_manager;
 
130
   TpAccount *account;
 
131
   GError *error = NULL;
 
132
   EmpathyImportWidget *self = user_data;
 
133
@@ -184,6 +185,13 @@ import_widget_create_account_cb (GObject *source,
 
134
 
 
135
   DEBUG ("account created\n");
 
136
 
 
137
+  if (tp_account_is_enabled (account))
 
138
+    {
 
139
+      account_manager = tp_account_manager_dup ();
 
140
+      empathy_connect_new_account (account, account_manager);
 
141
+      g_object_unref (account_manager);
 
142
+    }
 
143
+
 
144
   g_object_unref (self);
 
145
 }
 
146
 
 
147
@@ -208,7 +216,8 @@ import_widget_add_account (EmpathyImportWidget *self,
 
148
 
 
149
   DEBUG ("display name: %s\n", display_name);
 
150
 
 
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);
 
154
 
 
155
   tp_account_manager_create_account_async (account_manager,
 
156
       (const gchar*) data->connection_manager, data->protocol, display_name,
 
157
--
 
158
cgit v0.8.3.1