aboutsummaryrefslogtreecommitdiffstats
path: root/src/empathy-import-dialog.c
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2008-10-17 20:46:32 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-10-17 20:46:32 +0800
commitec64c0ae745a2ea34556565cefaf263b31117b38 (patch)
treec48643349f948b4d95a77d6361f736a701d68b84 /src/empathy-import-dialog.c
parentb843121e84fa2ce69ceb1c0c952be755e102a099 (diff)
downloadgsoc2013-empathy-ec64c0ae745a2ea34556565cefaf263b31117b38.tar
gsoc2013-empathy-ec64c0ae745a2ea34556565cefaf263b31117b38.tar.gz
gsoc2013-empathy-ec64c0ae745a2ea34556565cefaf263b31117b38.tar.bz2
gsoc2013-empathy-ec64c0ae745a2ea34556565cefaf263b31117b38.tar.lz
gsoc2013-empathy-ec64c0ae745a2ea34556565cefaf263b31117b38.tar.xz
gsoc2013-empathy-ec64c0ae745a2ea34556565cefaf263b31117b38.tar.zst
gsoc2013-empathy-ec64c0ae745a2ea34556565cefaf263b31117b38.zip
Simplified the node looping code further. (Jonny Lamb)
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk> svn path=/trunk/; revision=1607
Diffstat (limited to 'src/empathy-import-dialog.c')
-rw-r--r--src/empathy-import-dialog.c135
1 files changed, 66 insertions, 69 deletions
diff --git a/src/empathy-import-dialog.c b/src/empathy-import-dialog.c
index d6d28eee2..89792f77a 100644
--- a/src/empathy-import-dialog.c
+++ b/src/empathy-import-dialog.c
@@ -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);
}