changeset 26685:6b3a23ecbb42

Remove most of the mappings, add in the ones necessary from our prpls, and use a loop + a mapping struct
author Paul Aurich <paul@darkrain42.org>
date Mon, 13 Apr 2009 16:54:25 +0000
parents 3371c36d77e8
children ff33b65b2448
files libpurple/protocols/jabber/disco.c
diffstat 1 files changed, 19 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/disco.c	Mon Apr 13 16:38:11 2009 +0000
+++ b/libpurple/protocols/jabber/disco.c	Mon Apr 13 16:54:25 2009 +0000
@@ -630,27 +630,28 @@
 	return PURPLE_DISCO_SERVICE_TYPE_OTHER;
 }
 
+static struct {
+	const char *from;
+	const char *to;
+} disco_type_mappings[] = {
+	{ "gadu-gadu", "gg" },
+	{ "sametime",  "meanwhile" },
+	{ "myspaceim", "myspace" },
+	{ "xmpp",      "jabber" },
+	{ NULL,        NULL }
+};
+
 static const gchar *
 jabber_disco_type_from_string(const gchar *str)
 {
-	if (!strcasecmp(str, "aim"))
-		return "aim";
-	else if (!strcasecmp(str, "gadu-gadu"))
-		return "gg";
-	else if (!strcasecmp(str, "icq"))
-		return "icq";
-	else if (!strcasecmp(str, "irc"))
-		return "irc";
-	else if (!strcasecmp(str, "msn"))
-		return "msn";
-	else if (!strcasecmp(str, "qq"))
-		return "qq";
-	else if (!strcasecmp(str, "smtp"))
-		return "smtp";
-	else if (!strcasecmp(str, "xmpp"))
-		return "jabber";
-	else if (!strcasecmp(str, "yahoo"))
-		return "yahoo";
+	int i = 0;
+
+	g_return_val_if_fail(str != NULL, "");
+
+	for ( ; disco_type_mappings[i].from; ++i) {
+		if (!strcasecmp(str, disco_type_mappings[i].from))
+			return disco_type_mappings[i].to;
+	}
 
 	/* fallback to the string itself */
 	return str;