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.jxmpp.jid.EntityFullJid;
021import org.jxmpp.jid.Jid;
022import org.jxmpp.jid.parts.Resourcepart;
023
024/**
025 * A listener that is fired anytime a participant's status in a room is changed, such as the
026 * user being kicked, banned, or granted admin permissions.
027 *
028 * @author Gaston Dombiak
029 */
030public interface ParticipantStatusListener {
031
032    /**
033     * Called when a new room occupant has joined the room. Note: Take in consideration that when
034     * you join a room you will receive the list of current occupants in the room. This message will
035     * be sent for each occupant.
036     *
037     * @param participant the participant that has just joined the room
038     * (e.g. room@conference.jabber.org/nick).
039     */
040    default void joined(EntityFullJid participant) {
041    }
042
043    /**
044     * Called when a room occupant has left the room on its own. This means that the occupant was
045     * neither kicked nor banned from the room.
046     *
047     * @param participant the participant that has left the room on its own.
048     * (e.g. room@conference.jabber.org/nick).
049     */
050    default void left(EntityFullJid participant) {
051    }
052
053    /**
054     * Called when a participant is parted for whatever reason. This callback is always invoked if a participant
055     * parted the room, either voluntarily or involuntarily. Prior this callback, a callback with a more specific
056     * reason for the removal, like {@link #left(EntityFullJid)} may be invoked.
057     *
058     * @param participant the participant that was removed from the room.
059     * @since 4.4
060     */
061    default void parted(EntityFullJid participant) {
062    }
063
064    /**
065     * Called when a room participant has been kicked from the room. This means that the kicked
066     * participant is no longer participating in the room.
067     *
068     * @param participant the participant that was kicked from the room
069     * (e.g. room@conference.jabber.org/nick).
070     * @param actor the moderator that kicked the occupant from the room (e.g. user@host.org).
071     * @param reason the reason provided by the actor to kick the occupant from the room.
072     */
073    default void kicked(EntityFullJid participant, Jid actor, String reason) {
074    }
075
076    /**
077     * Called when a moderator grants voice to a visitor. This means that the visitor
078     * can now participate in the moderated room sending messages to all occupants.
079     *
080     * @param participant the participant that was granted voice in the room
081     * (e.g. room@conference.jabber.org/nick).
082     */
083    default void voiceGranted(EntityFullJid participant) {
084    }
085
086    /**
087     * Called when a moderator revokes voice from a participant. This means that the participant
088     * in the room was able to speak and now is a visitor that can't send messages to the room
089     * occupants.
090     *
091     * @param participant the participant that was revoked voice from the room
092     * (e.g. room@conference.jabber.org/nick).
093     */
094    default void voiceRevoked(EntityFullJid participant) {
095    }
096
097    /**
098     * Called when an administrator or owner banned a participant from the room. This means that
099     * banned participant will no longer be able to join the room unless the ban has been removed.
100     *
101     * @param participant the participant that was banned from the room
102     * (e.g. room@conference.jabber.org/nick).
103     * @param actor the administrator that banned the occupant (e.g. user@host.org).
104     * @param reason the reason provided by the administrator to ban the occupant.
105     */
106    default void banned(EntityFullJid participant, Jid actor, String reason) {
107    }
108
109    /**
110     * Called when an administrator grants a user membership to the room. This means that the user
111     * will be able to join the members-only room.
112     *
113     * @param participant the participant that was granted membership in the room
114     * (e.g. room@conference.jabber.org/nick).
115     */
116    default void membershipGranted(EntityFullJid participant) {
117    }
118
119    /**
120     * Called when an administrator revokes a user membership to the room. This means that the
121     * user will not be able to join the members-only room.
122     *
123     * @param participant the participant that was revoked membership from the room
124     * (e.g. room@conference.jabber.org/nick).
125     */
126    default void membershipRevoked(EntityFullJid participant) {
127    }
128
129    /**
130     * Called when an administrator grants moderator privileges to a user. This means that the user
131     * will be able to kick users, grant and revoke voice, invite other users, modify room's
132     * subject plus all the partcipants privileges.
133     *
134     * @param participant the participant that was granted moderator privileges in the room
135     * (e.g. room@conference.jabber.org/nick).
136     */
137    default void moderatorGranted(EntityFullJid participant) {
138    }
139
140    /**
141     * Called when an administrator revokes moderator privileges from a user. This means that the
142     * user will no longer be able to kick users, grant and revoke voice, invite other users,
143     * modify room's subject plus all the partcipants privileges.
144     *
145     * @param participant the participant that was revoked moderator privileges in the room
146     * (e.g. room@conference.jabber.org/nick).
147     */
148    default void moderatorRevoked(EntityFullJid participant) {
149    }
150
151    /**
152     * Called when an owner grants a user ownership on the room. This means that the user
153     * will be able to change defining room features as well as perform all administrative
154     * functions.
155     *
156     * @param participant the participant that was granted ownership on the room
157     * (e.g. room@conference.jabber.org/nick).
158     */
159    default void ownershipGranted(EntityFullJid participant) {
160    }
161
162    /**
163     * Called when an owner revokes a user ownership on the room. This means that the user
164     * will no longer be able to change defining room features as well as perform all
165     * administrative functions.
166     *
167     * @param participant the participant that was revoked ownership on the room
168     * (e.g. room@conference.jabber.org/nick).
169     */
170    default void ownershipRevoked(EntityFullJid participant) {
171    }
172
173    /**
174     * Called when an owner grants administrator privileges to a user. This means that the user
175     * will be able to perform administrative functions such as banning users and edit moderator
176     * list.
177     *
178     * @param participant the participant that was granted administrator privileges
179     * (e.g. room@conference.jabber.org/nick).
180     */
181    default void adminGranted(EntityFullJid participant) {
182    }
183
184    /**
185     * Called when an owner revokes administrator privileges from a user. This means that the user
186     * will no longer be able to perform administrative functions such as banning users and edit
187     * moderator list.
188     *
189     * @param participant the participant that was revoked administrator privileges
190     * (e.g. room@conference.jabber.org/nick).
191     */
192    default void adminRevoked(EntityFullJid participant) {
193    }
194
195    /**
196     * Called when a participant changed his/her nickname in the room. The new participant's
197     * nickname will be informed with the next available presence.
198     *
199     * @param participant the participant that was revoked administrator privileges
200     * (e.g. room@conference.jabber.org/nick).
201     * @param newNickname the new nickname that the participant decided to use.
202     */
203    default void nicknameChanged(EntityFullJid participant, Resourcepart newNickname) {
204    }
205
206}