Add roomDestroyed callback to MUC UserStatusListener

Fixes SMACK-619
This commit is contained in:
meisterfuu 2015-03-16 10:06:16 +01:00 committed by Florian Schmaus
parent 0d8f3185e5
commit 05c97c494b
3 changed files with 24 additions and 1 deletions

View File

@ -66,4 +66,7 @@ public class DefaultUserStatusListener implements UserStatusListener {
public void adminRevoked() {
}
public void roomDestroyed(MultiUserChat alternateMUC, String reason) {
}
}

View File

@ -2179,6 +2179,18 @@ public class MultiUserChat {
listener.nicknameChanged(from, mucUser.getItem().getNick());
}
}
//The room has been destroyed
if (mucUser.getDestroy() != null) {
MultiUserChat alternateMUC = multiUserChatManager.getMultiUserChat(mucUser.getDestroy().getJid());
for (UserStatusListener listener : userStatusListeners) {
listener.roomDestroyed(alternateMUC, mucUser.getDestroy().getReason());
}
// Reset occupant information.
occupantsMap.clear();
nickname = null;
userHasLeft();
}
}
@Override

View File

@ -21,7 +21,7 @@ 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.
* user being kicked, banned, or granted admin permissions or the room is destroyed.
*
* @author Gaston Dombiak
*/
@ -123,4 +123,12 @@ public interface UserStatusListener {
*/
public abstract void adminRevoked();
/**
* Called when the room is destroyed.
*
* @param alternateMUC an alternate MultiUserChat, may be null.
* @param reason the reason why the room was closed, may be null.
*/
public abstract void roomDestroyed(MultiUserChat alternateMUC, String reason);
}