diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java index 8c8b50647..0a2ce3060 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java @@ -265,6 +265,11 @@ public class MultiUserChat { } } } + if (isUserStatusModification) { + for (UserStatusListener listener : userStatusListeners) { + listener.removed(mucUser, presence); + } + } break; default: break; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/UserStatusListener.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/UserStatusListener.java index 105a09a0d..a727ee3cb 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/UserStatusListener.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/UserStatusListener.java @@ -17,11 +17,21 @@ package org.jivesoftware.smackx.muc; +import org.jivesoftware.smack.packet.Presence; + +import org.jivesoftware.smackx.muc.packet.MUCUser; + import org.jxmpp.jid.Jid; /** - * A listener that is fired anytime your participant's status in a room is changed, such as the - * user being kicked, banned, or granted admin permissions or the room is destroyed. + * A listener that is fired anytime your participant's status in a room is changed, such as the user being kicked, + * banned, or granted admin permissions or the room is destroyed. + *
+ * Note that the methods {@link #kicked(Jid, String)}, {@link #banned(Jid, String)} and + * {@link #roomDestroyed(MultiUserChat, String)} will be called before the generic {@link #removed(MUCUser, Presence)} + * callback will be invoked. The generic {@link #removed(MUCUser, Presence)} callback will be invoked every time the user + * was removed from the MUC involuntarily. It is hence the recommended callback to listen for and act upon. + *
* * @author Gaston Dombiak */ @@ -33,6 +43,7 @@ public interface UserStatusListener { * * @param actor the moderator that kicked your user from the room (e.g. user@host.org). * @param reason the reason provided by the actor to kick you from the room. + * @see #removed(MUCUser, Presence) */ void kicked(Jid actor, String reason); @@ -58,10 +69,21 @@ public interface UserStatusListener { * * @param actor the administrator that banned your user (e.g. user@host.org). * @param reason the reason provided by the administrator to banned you. + * @see #removed(MUCUser, Presence) */ void banned(Jid actor, String reason); - /** + /** + * Called when a user is involuntarily removed from the room. + * + * @param mucUser the optional muc#user extension element + * @param presence the carrier presence + * @since 4.5 + */ + default void removed(MUCUser mucUser, Presence presence) { + }; + + /** * Called when an administrator grants your user membership to the room. This means that you * will be able to join the members-only room. * @@ -128,6 +150,7 @@ public interface UserStatusListener { * * @param alternateMUC an alternate MultiUserChat, may be null. * @param reason the reason why the room was closed, may be null. + * @see #removed(MUCUser, Presence) */ void roomDestroyed(MultiUserChat alternateMUC, String reason);