001/**
002 *
003 * Copyright 2003-2007 Jive Software.
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.jivesoftware.smackx.muc;
019
020import org.jivesoftware.smack.packet.Presence;
021
022import org.jivesoftware.smackx.muc.packet.MUCUser;
023
024import org.jxmpp.jid.Jid;
025
026/**
027 * A listener that is fired anytime your participant's status in a room is changed, such as the user being kicked,
028 * banned, or granted admin permissions or the room is destroyed.
029 * <p>
030 * Note that the methods {@link #kicked(Jid, String)}, {@link #banned(Jid, String)} and
031 * {@link #roomDestroyed(MultiUserChat, String)} will be called before the generic {@link #removed(MUCUser, Presence)}
032 * callback will be invoked. The generic {@link #removed(MUCUser, Presence)} callback will be invoked every time the user
033 * was removed from the MUC involuntarily. It is hence the recommended callback to listen for and act upon.
034 * </p>
035 *
036 * @author Gaston Dombiak
037 */
038public interface UserStatusListener {
039
040    /**
041     * Called when a moderator kicked your user from the room. This means that you are no longer
042     * participanting in the room.
043     *
044     * @param actor the moderator that kicked your user from the room (e.g. user@host.org).
045     * @param reason the reason provided by the actor to kick you from the room.
046     * @see #removed(MUCUser, Presence)
047     */
048    default void kicked(Jid actor, String reason) {
049    }
050
051    /**
052     * Called when a moderator grants voice to your user. This means that you were a visitor in
053     * the moderated room before and now you can participate in the room by sending messages to
054     * all occupants.
055     *
056     */
057    default void voiceGranted() {
058    }
059
060    /**
061     * Called when a moderator revokes voice from your user. This means that you were a
062     * participant in the room able to speak and now you are a visitor that can't send
063     * messages to the room occupants.
064     *
065     */
066    default void voiceRevoked() {
067    }
068
069    /**
070     * Called when an administrator or owner banned your user from the room. This means that you
071     * will no longer be able to join the room unless the ban has been removed.
072     *
073     * @param actor the administrator that banned your user (e.g. user@host.org).
074     * @param reason the reason provided by the administrator to banned you.
075     * @see #removed(MUCUser, Presence)
076     */
077    default void banned(Jid actor, String reason) {
078    }
079
080     /**
081      * Called when a user is involuntarily removed from the room.
082      *
083      * @param mucUser the optional muc#user extension element
084      * @param presence the carrier presence
085      * @since 4.4.0
086      */
087     default void removed(MUCUser mucUser, Presence presence) {
088     }
089
090     /**
091     * Called when an administrator grants your user membership to the room. This means that you
092     * will be able to join the members-only room.
093     *
094     */
095    default void membershipGranted() {
096    }
097
098    /**
099     * Called when an administrator revokes your user membership to the room. This means that you
100     * will not be able to join the members-only room.
101     *
102     */
103    default void membershipRevoked() {
104    }
105
106    /**
107     * Called when an administrator grants moderator privileges to your user. This means that you
108     * will be able to kick users, grant and revoke voice, invite other users, modify room's
109     * subject plus all the partcipants privileges.
110     *
111     */
112    default void moderatorGranted() {
113    }
114
115    /**
116     * Called when an administrator revokes moderator privileges from your user. This means that
117     * you will no longer be able to kick users, grant and revoke voice, invite other users,
118     * modify room's subject plus all the partcipants privileges.
119     *
120     */
121    default void moderatorRevoked() {
122    }
123
124    /**
125     * Called when an owner grants to your user ownership on the room. This means that you
126     * will be able to change defining room features as well as perform all administrative
127     * functions.
128     *
129     */
130    default void ownershipGranted() {
131    }
132
133    /**
134     * Called when an owner revokes from your user ownership on the room. This means that you
135     * will no longer be able to change defining room features as well as perform all
136     * administrative functions.
137     *
138     */
139    default void ownershipRevoked() {
140    }
141
142    /**
143     * Called when an owner grants administrator privileges to your user. This means that you
144     * will be able to perform administrative functions such as banning users and edit moderator
145     * list.
146     *
147     */
148    default void adminGranted() {
149    }
150
151    /**
152     * Called when an owner revokes administrator privileges from your user. This means that you
153     * will no longer be able to perform administrative functions such as banning users and edit
154     * moderator list.
155     *
156     */
157    default void adminRevoked() {
158    }
159
160    /**
161     * Called when the room is destroyed.
162     *
163     * @param alternateMUC an alternate MultiUserChat, may be null.
164     * @param reason the reason why the room was closed, may be null.
165     * @see #removed(MUCUser, Presence)
166     */
167    default void roomDestroyed(MultiUserChat alternateMUC, String reason) {
168    }
169
170}