]> git.0d.be Git - empathy.git/blobdiff - src/empathy-import-pidgin.c
GNOME Goal: Update icon names
[empathy.git] / src / empathy-import-pidgin.c
index ab69d417be76aeddf899d2feb8b92340f2f99ddc..92adb861ea3204a96437f074b0675b1be019b204 100644 (file)
  * Authors: Jonny Lamb <jonny.lamb@collabora.co.uk>
  * */
 
-#include <config.h>
-
-#include <string.h>
-#include <unistd.h>
+#include "config.h"
+#include "empathy-import-pidgin.h"
 
-#include <glib.h>
 #include <glib/gstdio.h>
 #include <dbus/dbus-protocol.h>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include <telepathy-glib/util.h>
-#include <telepathy-glib/dbus.h>
 
 #include "empathy-import-utils.h"
-#include "empathy-import-pidgin.h"
+#include "empathy-utils.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include <libempathy/empathy-debug.h>
-#include <libempathy/empathy-utils.h>
-
-#include <libempathy-gtk/empathy-ui-utils.h>
+#include "empathy-debug.h"
 
 /* Pidgin to CM map */
 typedef struct
@@ -93,6 +82,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 +101,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;
 
@@ -142,7 +133,7 @@ import_dialog_pidgin_parse_setting (EmpathyImportAccountData *data,
   else if (!tp_strdiff (type, "int"))
     {
       TpConnectionManager *cm = NULL;
-      const TpConnectionManagerProtocol *proto;
+      TpProtocol *proto;
       const TpConnectionManagerParam *param;
       const gchar *signature;
       int signature_i;
@@ -150,8 +141,8 @@ import_dialog_pidgin_parse_setting (EmpathyImportAccountData *data,
       if (!empathy_import_protocol_is_supported (data->protocol, &cm))
         return;
 
-      proto = tp_connection_manager_get_protocol (cm, data->protocol);
-      param = tp_connection_manager_protocol_get_param (proto, item->cm_name);
+      proto = tp_connection_manager_get_protocol_object (cm, data->protocol);
+      param = tp_protocol_get_param (proto, item->cm_name);
       signature = tp_connection_manager_param_get_dbus_signature (param);
       signature_i = (int) (*signature);
 
@@ -183,10 +174,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 +345,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,