# HG changeset patch # User Paul Aurich # Date 1239641665 0 # Node ID 6b3a23ecbb423a44cc63862557bf628b139161b4 # Parent 3371c36d77e8fbd0739aec2c2b47a163e2a2d74a Remove most of the mappings, add in the ones necessary from our prpls, and use a loop + a mapping struct diff -r 3371c36d77e8 -r 6b3a23ecbb42 libpurple/protocols/jabber/disco.c --- 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;