From f5c17aa6f3ee36bba41d4f718e5678a33c83f272 Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Wed, 2 Feb 2005 22:42:57 +0000 Subject: [PATCH] Fixed to get the nickname of an occupant based on his presence. SMACK-43 git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2453 b35dd754-fafc-0310-a699-88a17e54d16e --- source/org/jivesoftware/smackx/muc/Occupant.java | 3 +++ test/org/jivesoftware/smackx/muc/MultiUserChatTest.java | 1 + 2 files changed, 4 insertions(+) diff --git a/source/org/jivesoftware/smackx/muc/Occupant.java b/source/org/jivesoftware/smackx/muc/Occupant.java index e497387a5..e82de84ad 100644 --- a/source/org/jivesoftware/smackx/muc/Occupant.java +++ b/source/org/jivesoftware/smackx/muc/Occupant.java @@ -23,6 +23,7 @@ package org.jivesoftware.smackx.muc; import org.jivesoftware.smackx.packet.MUCAdmin; import org.jivesoftware.smackx.packet.MUCUser; import org.jivesoftware.smack.packet.Presence; +import org.jivesoftware.smack.util.StringUtils; /** * Represents the information about an occupant in a given room. The information will always have @@ -54,6 +55,8 @@ public class Occupant { this.jid = item.getJid(); this.affiliation = item.getAffiliation(); this.role = item.getRole(); + // Get the nickname from the FROM attribute of the presence + this.nick = StringUtils.parseResource(presence.getFrom()); } /** diff --git a/test/org/jivesoftware/smackx/muc/MultiUserChatTest.java b/test/org/jivesoftware/smackx/muc/MultiUserChatTest.java index b79629fd3..936b21cbd 100644 --- a/test/org/jivesoftware/smackx/muc/MultiUserChatTest.java +++ b/test/org/jivesoftware/smackx/muc/MultiUserChatTest.java @@ -1576,6 +1576,7 @@ public class MultiUserChatTest extends SmackTestCase { assertEquals("Wrong occupant jid", getFullJID(1), occupant.getJid()); assertEquals("Wrong occupant affiliation", "member", occupant.getAffiliation()); assertEquals("Wrong occupant role", "participant", occupant.getRole()); + assertEquals("Wrong occupant nick", "testbot2", occupant.getNick()); try { // Check whether a member can get the list of owners