]> git.0d.be Git - empathy.git/commitdiff
Simplified the node looping code further. (Jonny Lamb)
authorJonny Lamb <jonny.lamb@collabora.co.uk>
Fri, 17 Oct 2008 12:46:32 +0000 (12:46 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 17 Oct 2008 12:46:32 +0000 (12:46 +0000)
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
svn path=/trunk/; revision=1607

src/empathy-import-dialog.c

index d6d28eee2b57e851d20800b8183abbc3c847937b..89792f77a62cfa645caf7278737a5b3e229d1edd 100644 (file)
@@ -276,92 +276,89 @@ empathy_import_dialog_pidgin_import_accounts ()
 
   for (node = rootnode->children; node; node = node->next)
     {
-      if (strcmp ((gchar *) node->name, PIDGIN_ACCOUNT_TAG_ACCOUNT) == 0)
-        {
-          child = node->children;
+      if (strcmp ((gchar *) node->name, PIDGIN_ACCOUNT_TAG_ACCOUNT) != 0)
+        continue;
+
+      settings = g_hash_table_new (g_str_hash, g_str_equal);
 
-          settings = g_hash_table_new (g_str_hash, g_str_equal);
+      for (child = node->children; child; child = child->next)
+        {
 
-          while (child)
+          if (strcmp ((gchar *) child->name,
+              PIDGIN_ACCOUNT_TAG_PROTOCOL) == 0)
             {
+              protocol = (gchar *) xmlNodeGetContent (child);
 
-              if (strcmp ((gchar *) child->name,
-                  PIDGIN_ACCOUNT_TAG_PROTOCOL) == 0)
-                {
-                  protocol = (gchar *) xmlNodeGetContent (child);
+              if (g_str_has_prefix (protocol, "prpl-"))
+                protocol = strchr (protocol, '-') + 1;
 
-                  if (g_str_has_prefix (protocol, "prpl-"))
-                    protocol = strchr (protocol, '-') + 1;
+              if (strcmp (protocol, PIDGIN_PROTOCOL_BONJOUR) == 0)
+                protocol = "salut";
+              else if (strcmp (protocol, PIDGIN_PROTOCOL_NOVELL) == 0)
+                protocol = "groupwise";
 
-                  if (strcmp (protocol, PIDGIN_PROTOCOL_BONJOUR) == 0)
-                    protocol = "salut";
-                  else if (strcmp (protocol, PIDGIN_PROTOCOL_NOVELL) == 0)
-                    protocol = "groupwise";
+              empathy_import_dialog_add_setting (settings, "protocol",
+                  (gpointer) protocol,
+                  EMPATHY_IMPORT_SETTING_TYPE_STRING);
 
-                  empathy_import_dialog_add_setting (settings, "protocol",
-                      (gpointer) protocol,
-                      EMPATHY_IMPORT_SETTING_TYPE_STRING);
+            }
+          else if (strcmp ((gchar *) child->name,
+              PIDGIN_ACCOUNT_TAG_NAME) == 0)
+            {
+              name = (gchar *) xmlNodeGetContent (child);
 
-                }
-              else if (strcmp ((gchar *) child->name,
-                  PIDGIN_ACCOUNT_TAG_NAME) == 0)
+              if (g_strrstr (name, "/") != NULL)
                 {
-                  name = (gchar *) xmlNodeGetContent (child);
-
-                  if (g_strrstr (name, "/") != NULL)
-                    {
-                      gchar **name_resource;
-                      name_resource = g_strsplit (name, "/", 2);
-                      username = g_strdup(name_resource[0]);
-                      g_free (name_resource);
-                    }
-                  else
-                    username = name;
-
-                 if (strstr (name, "@") && strcmp (protocol, "irc") == 0)
-                  {
-                    gchar **nick_server;
-                    nick_server = g_strsplit (name, "@", 2);
-                    username = nick_server[0];
-                    empathy_import_dialog_add_setting (settings,
-                        "server", (gpointer) nick_server[1],
-                        EMPATHY_IMPORT_SETTING_TYPE_STRING);
-                  }
-
-                  empathy_import_dialog_add_setting (settings, "account",
-                      (gpointer) username, EMPATHY_IMPORT_SETTING_TYPE_STRING);
-
+                  gchar **name_resource;
+                  name_resource = g_strsplit (name, "/", 2);
+                  username = g_strdup(name_resource[0]);
+                  g_free (name_resource);
                 }
-              else if (strcmp ((gchar *) child->name,
-                  PIDGIN_ACCOUNT_TAG_PASSWORD) == 0)
-                {
-                  empathy_import_dialog_add_setting (settings, "password",
-                      (gpointer) xmlNodeGetContent (child),
-                      EMPATHY_IMPORT_SETTING_TYPE_STRING);
+              else
+                username = name;
+
+             if (strstr (name, "@") && strcmp (protocol, "irc") == 0)
+              {
+                gchar **nick_server;
+                nick_server = g_strsplit (name, "@", 2);
+                username = nick_server[0];
+                empathy_import_dialog_add_setting (settings,
+                    "server", (gpointer) nick_server[1],
+                    EMPATHY_IMPORT_SETTING_TYPE_STRING);
+              }
+
+              empathy_import_dialog_add_setting (settings, "account",
+                  (gpointer) username, EMPATHY_IMPORT_SETTING_TYPE_STRING);
 
-                }
-              else if (strcmp ((gchar *) child->name,
-                  PIDGIN_ACCOUNT_TAG_SETTINGS) == 0)
-                {
-                  setting = child->children;
+            }
+          else if (strcmp ((gchar *) child->name,
+              PIDGIN_ACCOUNT_TAG_PASSWORD) == 0)
+            {
+              empathy_import_dialog_add_setting (settings, "password",
+                  (gpointer) xmlNodeGetContent (child),
+                  EMPATHY_IMPORT_SETTING_TYPE_STRING);
 
-                  while (setting)
-                    {
-                      empathy_import_dialog_pidgin_parse_setting (protocol,
-                          setting, settings);
-                          setting = setting->next;
-                    }
+            }
+          else if (strcmp ((gchar *) child->name,
+              PIDGIN_ACCOUNT_TAG_SETTINGS) == 0)
+            {
+              setting = child->children;
 
+              while (setting)
+                {
+                  empathy_import_dialog_pidgin_parse_setting (protocol,
+                      setting, settings);
+                      setting = setting->next;
                 }
-              child = child->next;
+
             }
+        }
 
-          if (g_hash_table_size (settings) > 0)
-              empathy_import_dialog_add_account (protocol, settings);
+      if (g_hash_table_size (settings) > 0)
+          empathy_import_dialog_add_account (protocol, settings);
 
-          g_free (username);
-          g_hash_table_unref (settings);
-        }
+      g_free (username);
+      g_hash_table_unref (settings);
 
     }