Commit 9e57b587 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Allowes non-MUC compliant clients to create MUC rooms (will be instant rooms)....

Allowes non-MUC compliant clients to create MUC rooms (will be instant rooms). Before we returned a BAD_REQUEST error.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@174 b35dd754-fafc-0310-a699-88a17e54d16e
parent a9037b11
......@@ -495,8 +495,10 @@ public interface MUCRoom extends ChatDeliverer {
* Unlocks the room so that users can join the room. The room is locked when created and only
* the owner of the room can unlock it by sending the configuration form to the Multi-User Chat
* service.
*
* @param sendRole the role of the occupant that unlocked the room.
*/
public void unlockRoom();
public void unlockRoom(MUCRole sendRole);
public List addAdmins(List newAdmins, MUCRole sendRole) throws ForbiddenException,
ConflictException;
......
......@@ -21,7 +21,6 @@ import org.jivesoftware.messenger.muc.MUCRole;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.spi.MessageImpl;
import org.jivesoftware.messenger.user.UserNotFoundException;
import java.util.*;
......@@ -301,14 +300,7 @@ public class IQOwnerHandler {
// If the room was locked, unlock it and send to the owner the "room is now unlocked"
// message
if (room.isLocked()) {
room.unlockRoom();
Message message = new MessageImpl();
message.setType(Message.GROUP_CHAT);
message.setBody(LocaleUtils.getLocalizedString("muc.unlocked"));
message.setSender(room.getRole().getRoleAddress());
message.setRecipient(senderRole.getChatUser().getAddress());
router.route(message);
room.unlockRoom(senderRole);
}
}
}
......
......@@ -457,7 +457,7 @@ class MUCPersistentRoomSurrogate implements MUCRoom, Cacheable {
this.name = name;
}
public void unlockRoom() {
public void unlockRoom(MUCRole senderRole) {
throw new UnsupportedOperationException();
}
......
......@@ -1740,9 +1740,16 @@ public class MUCRoomImpl implements MUCRoom {
}
}
public void unlockRoom() {
public void unlockRoom(MUCRole senderRole) {
roomLocked = false;
this.lockedTime = 0;
// Send to the occupant the unlocked the room a message saying so
Message message = new MessageImpl();
message.setType(Message.GROUP_CHAT);
message.setBody(LocaleUtils.getLocalizedString("muc.unlocked"));
message.setSender(getRole().getRoleAddress());
message.setRecipient(senderRole.getChatUser().getAddress());
router.route(message);
}
public List addAdmins(List newAdmins, MUCRole senderRole) throws ForbiddenException,
......
......@@ -337,9 +337,8 @@ public class MUCUserImpl implements MUCUser {
else {
MUCRole role = roles.get(group.toLowerCase());
if (role == null) {
// If we're not already in a room, we either are joining it
// or it's not properly addressed and we drop it silently
// In the future, we'll need to support TYPE_IQ queries to the room for MUC
// If we're not already in a room, we either are joining it or it's not
// properly addressed and we drop it silently
if (recipient.getResource() != null
&& recipient.getResource().trim().length() > 0) {
if (packet.getType() == Presence.AVAILABLE
......@@ -348,32 +347,27 @@ public class MUCUserImpl implements MUCUser {
// Get or create the room
MUCRoom room = server.getChatRoom(group, packet.getSender());
// User must support MUC in order to create a room
MetaDataFragment mucInfo = (MetaDataFragment) packet.getFragment(
"x",
MetaDataFragment mucInfo = (MetaDataFragment) packet.getFragment("x",
"http://jabber.org/protocol/muc");
HistoryRequest historyRequest = null;
String password = null;
if (room.isLocked() && mucInfo == null) {
// Only users that support MUC are allowed to create roooms
// Remove the room since the intended owner doesn't support MUC
sendErrorPacket(packet, XMPPError.Code.BAD_REQUEST);
server.removeChatRoom(group);
}
else {
// Check for password & requested history if client supports MUC
if (mucInfo != null) {
password = mucInfo.getProperty("x.password");
if (mucInfo.includesProperty("x.history")) {
historyRequest = new HistoryRequest(mucInfo);
}
// Check for password & requested history if client supports MUC
if (mucInfo != null) {
password = mucInfo.getProperty("x.password");
if (mucInfo.includesProperty("x.history")) {
historyRequest = new HistoryRequest(mucInfo);
}
// The user joins the room
role = room.joinRoom(
recipient.getResource().trim(),
}
// The user joins the room
role = room.joinRoom(recipient.getResource().trim(),
password,
historyRequest,
this);
roles.put(group, role);
roles.put(group, role);
// If the client that created the room is non-MUC compliant then
// unlock the room thus creating an "instant" room
if (room.isLocked() && mucInfo == null) {
room.unlockRoom(role);
}
}
catch (UnauthorizedException e) {
......
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