Commit 904f18f1 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Kick occupants that aren't members of the room which is now members-only.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@426 b35dd754-fafc-0310-a699-88a17e54d16e
parent d7aae331
...@@ -583,8 +583,10 @@ public interface MUCRoom extends ChatDeliverer { ...@@ -583,8 +583,10 @@ public interface MUCRoom extends ChatDeliverer {
* whether the room is members-only or not. * whether the room is members-only or not.
* *
* @param invitationRequiredToEnter if true then the room is members-only. * @param invitationRequiredToEnter if true then the room is members-only.
* @return the list of updated presences of all the occupants that aren't members of the room if
* the room is now members-only.
*/ */
public void setInvitationRequiredToEnter(boolean invitationRequiredToEnter); public List<Presence> setInvitationRequiredToEnter(boolean invitationRequiredToEnter);
/** /**
* Returns true if the room's conversation is being logged. If logging is activated the room * Returns true if the room's conversation is being logged. If logging is activated the room
......
...@@ -412,7 +412,8 @@ public class IQOwnerHandler { ...@@ -412,7 +412,8 @@ public class IQOwnerHandler {
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
booleanValue = (values.hasNext() ? values.next() : "1"); booleanValue = (values.hasNext() ? values.next() : "1");
room.setInvitationRequiredToEnter(("1".equals(booleanValue) ? true : false)); presences.addAll(room.setInvitationRequiredToEnter(("1".equals(booleanValue) ?
true : false)));
} }
field = completedForm.getField("muc#roomconfig_allowinvites"); field = completedForm.getField("muc#roomconfig_allowinvites");
......
...@@ -386,8 +386,9 @@ class MUCPersistentRoomSurrogate implements MUCRoom, Cacheable { ...@@ -386,8 +386,9 @@ class MUCPersistentRoomSurrogate implements MUCRoom, Cacheable {
return invitationRequiredToEnter; return invitationRequiredToEnter;
} }
public void setInvitationRequiredToEnter(boolean invitationRequiredToEnter) { public List<Presence> setInvitationRequiredToEnter(boolean invitationRequiredToEnter) {
this.invitationRequiredToEnter = invitationRequiredToEnter; this.invitationRequiredToEnter = invitationRequiredToEnter;
return Collections.EMPTY_LIST;
} }
public boolean isLogEnabled() { public boolean isLogEnabled() {
......
...@@ -1531,8 +1531,27 @@ public class MUCRoomImpl implements MUCRoom { ...@@ -1531,8 +1531,27 @@ public class MUCRoomImpl implements MUCRoom {
return invitationRequiredToEnter; return invitationRequiredToEnter;
} }
public void setInvitationRequiredToEnter(boolean invitationRequiredToEnter) { public List<Presence> setInvitationRequiredToEnter(boolean invitationRequiredToEnter) {
List<Presence> presences = new ArrayList<Presence>();
if (invitationRequiredToEnter && !this.invitationRequiredToEnter) {
// If the room was not members-only and now it is, kick occupants that aren't member
// of the room
for (MUCRole occupant : occupants.values()) {
if (occupant.getAffiliation() > MUCRole.MEMBER) {
try {
presences.add(kickOccupant(occupant.getChatUser().getAddress()
.toStringPrep(), null,
LocaleUtils.getLocalizedString("muc.roomIsNowMembersOnly")));
}
catch (NotAllowedException e) {
// Do Nothing
}
}
}
}
this.invitationRequiredToEnter = invitationRequiredToEnter; this.invitationRequiredToEnter = invitationRequiredToEnter;
return presences;
} }
public boolean isLogEnabled() { public boolean isLogEnabled() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment