# HG changeset patch # User Paul Aurich # Date 1251690210 0 # Node ID 08a3da3bc2d7f889caa90215f7cac79549944abc # Parent 2e3678cd33a0d17d03cb6435aeb8f9619303ce7a# Parent f5a2e28a6fbda5c1a7b061719b24c83ffd48e651 merge of '2adbecd312414acb07814cfe297782c54ed76733' and 'a613c27148476d6bdacf3acb6b9aee9f9084364a' diff -r f5a2e28a6fbd -r 08a3da3bc2d7 ChangeLog --- a/ChangeLog Sun Aug 30 22:09:20 2009 +0000 +++ b/ChangeLog Mon Aug 31 03:43:30 2009 +0000 @@ -14,6 +14,10 @@ Windows. * Fix typing notifications with Pidgin 2.5.9 or earlier. * Fix connecting using BOSH and legacy authentication (XEP-0078). + * Adding buddies of the form "romeo@montague.net/Resource" are handled + properly. In addition, it is no longer possible to add buddies of + the form "room@conference.example.net/User", where + room@conference.example.net is a MUC. Finch: * Properly detect libpanel on OpenBSD. (Brad Smith) diff -r f5a2e28a6fbd -r 08a3da3bc2d7 libpurple/protocols/jabber/caps.c --- a/libpurple/protocols/jabber/caps.c Sun Aug 30 22:09:20 2009 +0000 +++ b/libpurple/protocols/jabber/caps.c Mon Aug 31 03:43:30 2009 +0000 @@ -601,8 +601,8 @@ jabber_caps_cbplususerdata *userdata; if (exts && hash) { - purple_debug_info("jabber", "Ignoring exts in new-style caps from %s\n", - who); + purple_debug_misc("jabber", "Ignoring exts in new-style caps from %s\n", + who); g_strfreev(exts); exts = NULL; } diff -r f5a2e28a6fbd -r 08a3da3bc2d7 libpurple/protocols/jabber/jutil.c --- a/libpurple/protocols/jabber/jutil.c Sun Aug 30 22:09:20 2009 +0000 +++ b/libpurple/protocols/jabber/jutil.c Mon Aug 31 03:43:30 2009 +0000 @@ -489,21 +489,31 @@ return out; } -char *jabber_get_bare_jid(const char *in) +char * +jabber_get_bare_jid(const char *in) { JabberID *jid = jabber_id_new(in); char *out; - if(!jid) + if (!jid) return NULL; - - out = g_strdup_printf("%s%s%s", jid->node ? jid->node : "", - jid->node ? "@" : "", jid->domain); + out = jabber_id_get_bare_jid(jid); jabber_id_free(jid); return out; } +char * +jabber_id_get_bare_jid(const JabberID *jid) +{ + g_return_val_if_fail(jid != NULL, NULL); + + return g_strconcat(jid->node ? jid->node : "", + jid->node ? "@" : "", + jid->domain, + NULL); +} + JabberID * jabber_id_new(const char *str) { diff -r f5a2e28a6fbd -r 08a3da3bc2d7 libpurple/protocols/jabber/jutil.h --- a/libpurple/protocols/jabber/jutil.h Sun Aug 30 22:09:20 2009 +0000 +++ b/libpurple/protocols/jabber/jutil.h Mon Aug 31 03:43:30 2009 +0000 @@ -37,6 +37,7 @@ char *jabber_get_resource(const char *jid); char *jabber_get_bare_jid(const char *jid); +char *jabber_id_get_bare_jid(const JabberID *jid); const char *jabber_normalize(const PurpleAccount *account, const char *in); diff -r f5a2e28a6fbd -r 08a3da3bc2d7 libpurple/protocols/jabber/roster.c --- a/libpurple/protocols/jabber/roster.c Sun Aug 30 22:09:20 2009 +0000 +++ b/libpurple/protocols/jabber/roster.c Mon Aug 31 03:43:30 2009 +0000 @@ -26,6 +26,7 @@ #include "util.h" #include "buddy.h" +#include "chat.h" #include "google.h" #include "presence.h" #include "roster.h" @@ -336,6 +337,7 @@ { JabberStream *js = gc->proto_data; char *who; + JabberID *jid; JabberBuddy *jb; JabberBuddyResource *jbr; const char *name; @@ -345,13 +347,39 @@ return; name = purple_buddy_get_name(buddy); - if(!(who = jabber_get_bare_jid(name))) + jid = jabber_id_new(name); + if (jid == NULL) { + /* TODO: Remove the buddy from the list? */ return; + } - jb = jabber_buddy_find(js, name, FALSE); + /* Adding a chat room or a chat buddy to the roster is *not* supported. */ + if (jabber_chat_find(js, jid->node, jid->domain) != NULL) { + /* + * This is the same thing Bonjour does. If it causes problems, move + * it to an idle callback. + */ + purple_debug_warning("jabber", "Cowardly refusing to add a MUC user " + "to your buddy list and removing the buddy. " + "Buddies can only be added by real (non-MUC) " + "JID\n"); + purple_blist_remove_buddy(buddy); + jabber_id_free(jid); + return; + } - purple_debug_info("jabber", "jabber_roster_add_buddy(): Adding %s\n", - name); + who = jabber_id_get_bare_jid(jid); + if (jid->resource != NULL) { + /* + * If the buddy name added contains a resource, strip that off and + * rename the buddy. + */ + purple_blist_rename_buddy(buddy, who); + } + + jb = jabber_buddy_find(js, who, FALSE); + + purple_debug_info("jabber", "jabber_roster_add_buddy(): Adding %s\n", who); jabber_roster_update(js, who, NULL);