pidgin: 2adbecd3: jabber: Properly handle adding buddies t...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Sun Aug 30 23:50:37 EDT 2009
-----------------------------------------------------------------
Revision: 2adbecd312414acb07814cfe297782c54ed76733
Ancestor: 80c8a25280889c6319ece5c822fd2629d0f9ebef
Author: darkrain42 at pidgin.im
Date: 2009-08-31T03:39:34
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/2adbecd312414acb07814cfe297782c54ed76733
Modified files:
ChangeLog libpurple/protocols/jabber/jutil.c
libpurple/protocols/jabber/jutil.h
libpurple/protocols/jabber/roster.c
ChangeLog:
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Need to strip the resource when adding a buddy, so that the core doesn't
think the buddy is named "juliet at capulet.lit/chamber", which apparently
causes very strange issues.
-------------- next part --------------
============================================================
--- ChangeLog faacc1ca92b083af7e61cd7e464ea5316892f255
+++ ChangeLog 4532ec455543bdeed620353d98cea7624fac4e8b
@@ -14,6 +14,10 @@ version 2.6.2 (??/??/2009):
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 at montague.net/Resource" are handled
+ properly. In addition, it is no longer possible to add buddies of
+ the form "room at conference.example.net/User", where
+ room at conference.example.net is a MUC.
Finch:
* Properly detect libpanel on OpenBSD. (Brad Smith)
============================================================
--- libpurple/protocols/jabber/jutil.c 694a03e07125889652733d996810266608851f69
+++ libpurple/protocols/jabber/jutil.c 9047c2dfd575de6ec516dd8377bce70df42d5063
@@ -489,21 +489,31 @@ char *jabber_get_resource(const char *in
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)
{
============================================================
--- libpurple/protocols/jabber/jutil.h e0417ca1a378a3e81e02a26897010617cd82fa14
+++ libpurple/protocols/jabber/jutil.h 02b6b2dd78e434bf836d385baa5748633b7885d3
@@ -37,6 +37,7 @@ char *jabber_get_bare_jid(const char *ji
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);
============================================================
--- libpurple/protocols/jabber/roster.c f16245707b130deccc6312346161c6f3065763a3
+++ libpurple/protocols/jabber/roster.c 4b11bd34ec3b831e400b1775eefadc667e7390f0
@@ -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 @@ void jabber_roster_add_buddy(PurpleConne
{
JabberStream *js = gc->proto_data;
char *who;
+ JabberID *jid;
JabberBuddy *jb;
JabberBuddyResource *jbr;
const char *name;
@@ -345,14 +347,40 @@ void jabber_roster_add_buddy(PurpleConne
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);
if (jb == js->user_jb) {
More information about the Commits
mailing list