1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-29 23:42:06 +01:00

. Modified #nicknameChanged to include old and new nicknames. SMACK-55

. Modified banning and kicking to include reason and actor. SMACK-81

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@3038 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2005-11-08 17:15:18 +00:00 committed by gato
parent 254c4a450a
commit f12f1c2a1e
4 changed files with 80 additions and 35 deletions

View file

@ -37,7 +37,7 @@ public class DefaultParticipantStatusListener implements ParticipantStatusListen
public void left(String participant) {
}
public void kicked(String participant) {
public void kicked(String participant, String actor, String reason) {
}
public void voiceGranted(String participant) {
@ -46,7 +46,7 @@ public class DefaultParticipantStatusListener implements ParticipantStatusListen
public void voiceRevoked(String participant) {
}
public void banned(String participant) {
public void banned(String participant, String actor, String reason) {
}
public void membershipGranted(String participant) {
@ -73,7 +73,7 @@ public class DefaultParticipantStatusListener implements ParticipantStatusListen
public void adminRevoked(String participant) {
}
public void nicknameChanged(String nickname) {
public void nicknameChanged(String participant, String newNickname) {
}
}

View file

@ -1986,7 +1986,7 @@ public class MultiUserChat {
}
}
private void fireParticipantStatusListeners(String methodName, String param) {
private void fireParticipantStatusListeners(String methodName, List params) {
ParticipantStatusListener[] listeners = null;
synchronized (participantStatusListeners) {
listeners = new ParticipantStatusListener[participantStatusListeners.size()];
@ -1994,12 +1994,13 @@ public class MultiUserChat {
}
try {
// Get the method to execute based on the requested methodName and parameter
Method method =
ParticipantStatusListener.class.getDeclaredMethod(
methodName,
new Class[] { String.class });
Class[] classes = new Class[params.size()];
for (int i=0;i<params.size(); i++) {
classes[i] = String.class;
}
Method method = ParticipantStatusListener.class.getDeclaredMethod(methodName, classes);
for (int i = 0; i < listeners.length; i++) {
method.invoke(listeners[i], new Object[] {param});
method.invoke(listeners[i], params.toArray());
}
} catch (NoSuchMethodException e) {
e.printStackTrace();
@ -2085,7 +2086,9 @@ public class MultiUserChat {
else {
// A new occupant has joined the room
if (!isUserStatusModification) {
fireParticipantStatusListeners("joined", from);
List params = new ArrayList();
params.add(from);
fireParticipantStatusListeners("joined", params);
}
}
}
@ -2104,7 +2107,9 @@ public class MultiUserChat {
} else {
// An occupant has left the room
if (!isUserStatusModification) {
fireParticipantStatusListeners("left", from);
List params = new ArrayList();
params.add(from);
fireParticipantStatusListeners("left", params);
}
}
}
@ -2180,7 +2185,9 @@ public class MultiUserChat {
fireUserStatusListeners("voiceGranted", new Object[] {});
}
else {
fireParticipantStatusListeners("voiceGranted", from);
List params = new ArrayList();
params.add(from);
fireParticipantStatusListeners("voiceGranted", params);
}
}
// The participant's voice was revoked from the room
@ -2191,7 +2198,9 @@ public class MultiUserChat {
fireUserStatusListeners("voiceRevoked", new Object[] {});
}
else {
fireParticipantStatusListeners("voiceRevoked", from);
List params = new ArrayList();
params.add(from);
fireParticipantStatusListeners("voiceRevoked", params);
}
}
// Moderator privileges were granted to a participant
@ -2201,14 +2210,18 @@ public class MultiUserChat {
fireUserStatusListeners("voiceGranted", new Object[] {});
}
else {
fireParticipantStatusListeners("voiceGranted", from);
List params = new ArrayList();
params.add(from);
fireParticipantStatusListeners("voiceGranted", params);
}
}
if (isUserModification) {
fireUserStatusListeners("moderatorGranted", new Object[] {});
}
else {
fireParticipantStatusListeners("moderatorGranted", from);
List params = new ArrayList();
params.add(from);
fireParticipantStatusListeners("moderatorGranted", params);
}
}
// Moderator privileges were revoked from a participant
@ -2218,14 +2231,18 @@ public class MultiUserChat {
fireUserStatusListeners("voiceRevoked", new Object[] {});
}
else {
fireParticipantStatusListeners("voiceRevoked", from);
List params = new ArrayList();
params.add(from);
fireParticipantStatusListeners("voiceRevoked", params);
}
}
if (isUserModification) {
fireUserStatusListeners("moderatorRevoked", new Object[] {});
}
else {
fireParticipantStatusListeners("moderatorRevoked", from);
List params = new ArrayList();
params.add(from);
fireParticipantStatusListeners("moderatorRevoked", params);
}
}
}
@ -2284,7 +2301,9 @@ public class MultiUserChat {
fireUserStatusListeners("ownershipRevoked", new Object[] {});
}
else {
fireParticipantStatusListeners("ownershipRevoked", from);
List params = new ArrayList();
params.add(from);
fireParticipantStatusListeners("ownershipRevoked", params);
}
}
// The user's administrative privileges to the room were revoked
@ -2293,7 +2312,9 @@ public class MultiUserChat {
fireUserStatusListeners("adminRevoked", new Object[] {});
}
else {
fireParticipantStatusListeners("adminRevoked", from);
List params = new ArrayList();
params.add(from);
fireParticipantStatusListeners("adminRevoked", params);
}
}
// The user's membership to the room was revoked
@ -2302,7 +2323,9 @@ public class MultiUserChat {
fireUserStatusListeners("membershipRevoked", new Object[] {});
}
else {
fireParticipantStatusListeners("membershipRevoked", from);
List params = new ArrayList();
params.add(from);
fireParticipantStatusListeners("membershipRevoked", params);
}
}
@ -2312,7 +2335,9 @@ public class MultiUserChat {
fireUserStatusListeners("ownershipGranted", new Object[] {});
}
else {
fireParticipantStatusListeners("ownershipGranted", from);
List params = new ArrayList();
params.add(from);
fireParticipantStatusListeners("ownershipGranted", params);
}
}
// The user was granted administrative privileges to the room
@ -2321,7 +2346,9 @@ public class MultiUserChat {
fireUserStatusListeners("adminGranted", new Object[] {});
}
else {
fireParticipantStatusListeners("adminGranted", from);
List params = new ArrayList();
params.add(from);
fireParticipantStatusListeners("adminGranted", params);
}
}
// The user was granted membership to the room
@ -2330,7 +2357,9 @@ public class MultiUserChat {
fireUserStatusListeners("membershipGranted", new Object[] {});
}
else {
fireParticipantStatusListeners("membershipGranted", from);
List params = new ArrayList();
params.add(from);
fireParticipantStatusListeners("membershipGranted", params);
}
}
}
@ -2364,7 +2393,11 @@ public class MultiUserChat {
userHasLeft();
}
else {
fireParticipantStatusListeners("kicked", from);
List params = new ArrayList();
params.add(from);
params.add(mucUser.getItem().getActor());
params.add(mucUser.getItem().getReason());
fireParticipantStatusListeners("kicked", params);
}
}
// A user was banned from the room
@ -2383,8 +2416,11 @@ public class MultiUserChat {
userHasLeft();
}
else {
// TODO Check if we have to send the JID of the banned user
fireParticipantStatusListeners("banned", from);
List params = new ArrayList();
params.add(from);
params.add(mucUser.getItem().getActor());
params.add(mucUser.getItem().getReason());
fireParticipantStatusListeners("banned", params);
}
}
// A user's membership was revoked from the room
@ -2403,7 +2439,10 @@ public class MultiUserChat {
}
// A occupant has changed his nickname in the room
else if ("303".equals(code)) {
fireParticipantStatusListeners("nicknameChanged", mucUser.getItem().getNick());
List params = new ArrayList();
params.add(from);
params.add(mucUser.getItem().getNick());
fireParticipantStatusListeners("nicknameChanged", params);
}
}

View file

@ -53,8 +53,10 @@ public interface ParticipantStatusListener {
*
* @param participant the participant that was kicked from the room
* (e.g. room@conference.jabber.org/nick).
* @param actor the moderator that kicked the occupant from the room (e.g. user@host.org).
* @param reason the reason provided by the actor to kick the occupant from the room.
*/
public abstract void kicked(String participant);
public abstract void kicked(String participant, String actor, String reason);
/**
* Called when a moderator grants voice to a visitor. This means that the visitor
@ -81,8 +83,10 @@ public interface ParticipantStatusListener {
*
* @param participant the participant that was banned from the room
* (e.g. room@conference.jabber.org/nick).
* @param actor the administrator that banned the occupant (e.g. user@host.org).
* @param reason the reason provided by the administrator to ban the occupant.
*/
public abstract void banned(String participant);
public abstract void banned(String participant, String actor, String reason);
/**
* Called when an administrator grants a user membership to the room. This means that the user
@ -166,8 +170,10 @@ public interface ParticipantStatusListener {
* Called when a participant changed his/her nickname in the room. The new participant's
* nickname will be informed with the next available presence.
*
* @param nickname the old nickname that the participant decided to change.
* @param participant the participant that was revoked administrator privileges
* (e.g. room@conference.jabber.org/nick).
* @param newNickname the new nickname that the participant decided to use.
*/
public abstract void nicknameChanged(String nickname);
public abstract void nicknameChanged(String participant, String newNickname);
}

View file

@ -681,8 +681,8 @@ public class MultiUserChatTest extends SmackTestCase {
muc3.join("testbot3");
// User3 will lister for user2's "kicking"
muc3.addParticipantStatusListener(new DefaultParticipantStatusListener() {
public void kicked(String participant) {
super.kicked(participant);
public void kicked(String participant, String actor, String reason) {
super.kicked(participant, actor, reason);
answer[2] = participant;
}
});
@ -758,8 +758,8 @@ public class MultiUserChatTest extends SmackTestCase {
muc3.join("testbot3");
// User3 will lister for user2's "banning"
muc3.addParticipantStatusListener(new DefaultParticipantStatusListener() {
public void banned(String participant) {
super.banned(participant);
public void banned(String participant, String actor, String reason) {
super.banned(participant, actor, reason);
answer[2] = participant;
}
});