cpw.darkrain42.xmpp.disco: aef41109: Remove most of the mappings, add in the ...

paul at darkrain42.org paul at darkrain42.org
Sat Apr 25 16:17:21 EDT 2009


-----------------------------------------------------------------
Revision: aef41109df2b8a7dc5971eb9c7e7cf540495e61a
Ancestor: 641dc58acdca4f27ccf9c42ee6d5fbc6cf599e42
Author: paul at darkrain42.org
Date: 2009-04-13T16:54:25
Branch: im.pidgin.cpw.darkrain42.xmpp.disco
URL: http://d.pidgin.im/viewmtn/revision/info/aef41109df2b8a7dc5971eb9c7e7cf540495e61a

Modified files:
        libpurple/protocols/jabber/disco.c

ChangeLog: 

Remove most of the mappings, add in the ones necessary from our prpls, and
use a loop + a mapping struct

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/disco.c	76e22e69554d2b0d21339400fe0c7092b791535a
+++ libpurple/protocols/jabber/disco.c	6fc5723e4652b783d543c4836981fdbe86a041fb
@@ -630,28 +630,29 @@ jabber_disco_category_from_string(const 
 	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;
 }


More information about the Commits mailing list