Commit 1d8308b6 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Renamed property "invitationRequired" to "membersOnly".


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@706 b35dd754-fafc-0310-a699-88a17e54d16e
parent e10ab1fc
......@@ -599,22 +599,21 @@ public interface MUCRoom extends ChatDeliverer {
public void setDescription(String description);
/**
* Returns true if the room requires an invitation to enter. This is a "complicated" way to say
* whether the room is members-only or not.
* Returns true if the room requires an invitation to enter. That is if the room is
* members-only.
*
* @return true if the room requires an invitation to enter.
*/
public boolean isInvitationRequiredToEnter();
public boolean isMembersOnly();
/**
* Sets if the room requires an invitation to enter. This is a "complicated" way to say
* whether the room is members-only or not.
* Sets if the room requires an invitation to enter. That is if the room is members-only.
*
* @param invitationRequiredToEnter if true then the room is members-only.
* @param membersOnly 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 List<Presence> setInvitationRequiredToEnter(boolean invitationRequiredToEnter);
public List<Presence> setMembersOnly(boolean membersOnly);
/**
* Returns true if the room's conversation is being logged. If logging is activated the room
......
......@@ -139,7 +139,7 @@ public class IQAdminHandler {
else if ("member".equals(affiliation)) {
// The client is requesting the list of members
// In a members-only room members can get the list of members
if (!room.isInvitationRequiredToEnter()
if (!room.isMembersOnly()
&& MUCRole.ADMINISTRATOR != senderRole.getAffiliation()
&& MUCRole.OWNER != senderRole.getAffiliation()) {
throw new ForbiddenException();
......@@ -241,7 +241,7 @@ public class IQAdminHandler {
presences.addAll(room.addMember(jid.toBareJID(), null, senderRole));
// If the user had an affiliation don't send an invitation. Otherwise
// send an invitation if the room is members-only
if (!hadAffiliation && room.isInvitationRequiredToEnter()) {
if (!hadAffiliation && room.isMembersOnly()) {
room.sendInvitation(jid, null, senderRole);
}
}
......
......@@ -251,7 +251,7 @@ public class IQOwnerHandler {
presences.addAll(room.addMember(bareJID, null, senderRole));
// If the user had an affiliation don't send an invitation. Otherwise
// send an invitation if the room is members-only
if (!hadAffiliation && room.isInvitationRequiredToEnter()) {
if (!hadAffiliation && room.isMembersOnly()) {
room.sendInvitation(new JID(bareJID), null, senderRole);
}
}
......@@ -422,11 +422,11 @@ public class IQOwnerHandler {
room.setModerated(("1".equals(booleanValue) ? true : false));
}
field = completedForm.getField("muc#roomconfig_inviteonly");
field = completedForm.getField("muc#roomconfig_membersonly");
if (field != null) {
values = field.getValues();
booleanValue = (values.hasNext() ? values.next() : "1");
presences.addAll(room.setInvitationRequiredToEnter(("1".equals(booleanValue) ?
presences.addAll(room.setMembersOnly(("1".equals(booleanValue) ?
true : false)));
}
......@@ -557,9 +557,9 @@ public class IQOwnerHandler {
field.clearValues();
field.addValue((room.isModerated() ? "1" : "0"));
field = configurationForm.getField("muc#roomconfig_inviteonly");
field = configurationForm.getField("muc#roomconfig_membersonly");
field.clearValues();
field.addValue((room.isInvitationRequiredToEnter() ? "1" : "0"));
field.addValue((room.isMembersOnly() ? "1" : "0"));
field = configurationForm.getField("muc#roomconfig_allowinvites");
field.clearValues();
......@@ -668,9 +668,9 @@ public class IQOwnerHandler {
field.setLabel(LocaleUtils.getLocalizedString("muc.form.conf.owner_moderatedroom"));
configurationForm.addField(field);
field = new XFormFieldImpl("muc#roomconfig_inviteonly");
field = new XFormFieldImpl("muc#roomconfig_membersonly");
field.setType(FormField.TYPE_BOOLEAN);
field.setLabel(LocaleUtils.getLocalizedString("muc.form.conf.owner_inviteonly"));
field.setLabel(LocaleUtils.getLocalizedString("muc.form.conf.owner_membersonly"));
configurationForm.addField(field);
field = new XFormFieldImpl();
......
......@@ -42,7 +42,7 @@ public class MUCPersistenceManager {
"SELECT nickname FROM mucMember WHERE roomID=? AND jid=?";
private static final String LOAD_ROOM =
"SELECT roomID, creationDate, modificationDate, naturalName, description, " +
"canChangeSubject, maxUsers, publicRoom, moderated, invitationRequired, canInvite, " +
"canChangeSubject, maxUsers, publicRoom, moderated, membersOnly, canInvite, " +
"password, canDiscoverJID, logEnabled, subject, rolesToBroadcast " +
"FROM mucRoom WHERE name=?";
private static final String LOAD_AFFILIATIONS =
......@@ -54,7 +54,7 @@ public class MUCPersistenceManager {
"WHERE time>? AND roomID=? AND (nickname != \"\" OR subject IS NOT NULL) ORDER BY time";
private static final String LOAD_ALL_ROOMS =
"SELECT roomID, creationDate, modificationDate, name, naturalName, description, " +
"canChangeSubject, maxUsers, publicRoom, moderated, invitationRequired, canInvite, " +
"canChangeSubject, maxUsers, publicRoom, moderated, membersOnly, canInvite, " +
"password, canDiscoverJID, logEnabled, subject, rolesToBroadcast " +
"FROM mucRoom";
private static final String LOAD_ALL_AFFILIATIONS =
......@@ -66,12 +66,12 @@ public class MUCPersistenceManager {
"WHERE time>? AND (nickname != \"\" OR subject IS NOT NULL) ORDER BY time";
private static final String UPDATE_ROOM =
"UPDATE mucRoom SET modificationDate=?, naturalName=?, description=?, " +
"canChangeSubject=?, maxUsers=?, publicRoom=?, moderated=?, invitationRequired=?, " +
"canChangeSubject=?, maxUsers=?, publicRoom=?, moderated=?, membersOnly=?, " +
"canInvite=?, password=?, canDiscoverJID=?, logEnabled=?, rolesToBroadcast=? " +
"WHERE roomID=?";
private static final String ADD_ROOM =
"INSERT INTO mucRoom (roomID, creationDate, modificationDate, name, naturalName, " +
"description, canChangeSubject, maxUsers, publicRoom, moderated, invitationRequired, " +
"description, canChangeSubject, maxUsers, publicRoom, moderated, membersOnly, " +
"canInvite, password, canDiscoverJID, logEnabled, subject, rolesToBroadcast)" +
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
private static final String UPDATE_SUBJECT =
......@@ -159,7 +159,7 @@ public class MUCPersistenceManager {
room.setMaxUsers(rs.getInt(7));
room.setPublicRoom(rs.getInt(8) == 1 ? true : false);
room.setModerated(rs.getInt(9) == 1 ? true : false);
room.setInvitationRequiredToEnter(rs.getInt(10) == 1 ? true : false);
room.setMembersOnly(rs.getInt(10) == 1 ? true : false);
room.setCanOccupantsInvite(rs.getInt(11) == 1 ? true : false);
room.setPassword(rs.getString(12));
room.setCanAnyoneDiscoverJID(rs.getInt(13) == 1 ? true : false);
......@@ -283,7 +283,7 @@ public class MUCPersistenceManager {
pstmt.setInt(5, room.getMaxUsers());
pstmt.setInt(6, (room.isPublicRoom() ? 1 : 0));
pstmt.setInt(7, (room.isModerated() ? 1 : 0));
pstmt.setInt(8, (room.isInvitationRequiredToEnter() ? 1 : 0));
pstmt.setInt(8, (room.isMembersOnly() ? 1 : 0));
pstmt.setInt(9, (room.canOccupantsInvite() ? 1 : 0));
pstmt.setString(10, room.getPassword());
pstmt.setInt(11, (room.canAnyoneDiscoverJID() ? 1 : 0));
......@@ -304,7 +304,7 @@ public class MUCPersistenceManager {
pstmt.setInt(8, room.getMaxUsers());
pstmt.setInt(9, (room.isPublicRoom() ? 1 : 0));
pstmt.setInt(10, (room.isModerated() ? 1 : 0));
pstmt.setInt(11, (room.isInvitationRequiredToEnter() ? 1 : 0));
pstmt.setInt(11, (room.isMembersOnly() ? 1 : 0));
pstmt.setInt(12, (room.canOccupantsInvite() ? 1 : 0));
pstmt.setString(13, room.getPassword());
pstmt.setInt(14, (room.canAnyoneDiscoverJID() ? 1 : 0));
......@@ -394,7 +394,7 @@ public class MUCPersistenceManager {
room.setMaxUsers(rs.getInt(8));
room.setPublicRoom(rs.getInt(9) == 1 ? true : false);
room.setModerated(rs.getInt(10) == 1 ? true : false);
room.setInvitationRequiredToEnter(rs.getInt(11) == 1 ? true : false);
room.setMembersOnly(rs.getInt(11) == 1 ? true : false);
room.setCanOccupantsInvite(rs.getInt(12) == 1 ? true : false);
room.setPassword(rs.getString(13));
room.setCanAnyoneDiscoverJID(rs.getInt(14) == 1 ? true : false);
......
......@@ -188,7 +188,7 @@ public class MUCRoomImpl implements MUCRoom {
* Any user that is not a member of the room won't be able to join the room unless the user
* decides to register with the room (thus becoming a member).
*/
private boolean invitationRequiredToEnter = false;
private boolean membersOnly = false;
/**
* Some rooms may restrict the occupants that are able to send invitations. Sending an
......@@ -448,7 +448,7 @@ public class MUCRoomImpl implements MUCRoom {
}
else {
// The user has no affiliation (i.e. NONE). Set the role accordingly.
if (isInvitationRequiredToEnter()) {
if (isMembersOnly()) {
// The room is members-only and the user is not a member. Raise a
// "Registration Required" exception.
throw new RegistrationRequiredException();
......@@ -1038,7 +1038,7 @@ public class MUCRoomImpl implements MUCRoom {
public List<Presence> addMember(String bareJID, String nickname, MUCRole sendRole)
throws ForbiddenException, ConflictException {
int oldAffiliation = (members.containsKey(bareJID) ? MUCRole.MEMBER : MUCRole.NONE);
if (isInvitationRequiredToEnter()) {
if (isMembersOnly()) {
if (!canOccupantsInvite()) {
if (MUCRole.ADMINISTRATOR != sendRole.getAffiliation()
&& MUCRole.OWNER != sendRole.getAffiliation()) {
......@@ -1195,14 +1195,14 @@ public class MUCRoomImpl implements MUCRoom {
// Update the presence with the new affiliation and inform all occupants
try {
int newRole;
if (isInvitationRequiredToEnter() && wasMember) {
if (isMembersOnly() && wasMember) {
newRole = MUCRole.NONE_ROLE;
}
else {
newRole = isModerated() ? MUCRole.VISITOR : MUCRole.PARTICIPANT;
}
updatedPresences = changeOccupantAffiliation(bareJID, MUCRole.NONE, newRole);
if (isInvitationRequiredToEnter() && wasMember) {
if (isMembersOnly() && wasMember) {
// If the room is members-only, remove the user from the room including a status
// code of 321 to indicate that the user was removed because of an affiliation
// change
......@@ -1276,7 +1276,7 @@ public class MUCRoomImpl implements MUCRoom {
public void sendInvitation(JID to, String reason, MUCRole senderRole)
throws ForbiddenException {
if (!isInvitationRequiredToEnter() || canOccupantsInvite()
if (!isMembersOnly() || canOccupantsInvite()
|| MUCRole.ADMINISTRATOR == senderRole.getAffiliation()
|| MUCRole.OWNER == senderRole.getAffiliation()) {
// If the room is not members-only OR if the room is members-only and anyone can send
......@@ -1506,13 +1506,13 @@ public class MUCRoomImpl implements MUCRoom {
this.description = description;
}
public boolean isInvitationRequiredToEnter() {
return invitationRequiredToEnter;
public boolean isMembersOnly() {
return membersOnly;
}
public List<Presence> setInvitationRequiredToEnter(boolean invitationRequiredToEnter) {
public List<Presence> setMembersOnly(boolean membersOnly) {
List<Presence> presences = new ArrayList<Presence>();
if (invitationRequiredToEnter && !this.invitationRequiredToEnter) {
if (membersOnly && !this.membersOnly) {
// 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()) {
......@@ -1527,7 +1527,7 @@ public class MUCRoomImpl implements MUCRoom {
}
}
}
this.invitationRequiredToEnter = invitationRequiredToEnter;
this.membersOnly = membersOnly;
return presences;
}
......
......@@ -221,7 +221,7 @@ public class MUCUserImpl implements MUCUser {
// Add the user as a member of the room if the room is
// members only
if (room.isInvitationRequiredToEnter()) {
if (room.isMembersOnly()) {
room.lock.writeLock().lock();
try {
room.addMember(info.attributeValue("to"), null, role);
......
......@@ -716,7 +716,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
features.add("http://jabber.org/protocol/muc");
// Always add public since only public rooms can be discovered
features.add("muc_public");
if (room.isInvitationRequiredToEnter()) {
if (room.isMembersOnly()) {
features.add("muc_membersonly");
}
else {
......
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