Commit c5e9bc33 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Modified MUC code to be an internal component though it's still a module.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@944 b35dd754-fafc-0310-a699-88a17e54d16e
parent 507c70a1
...@@ -16,6 +16,7 @@ import java.util.Collection; ...@@ -16,6 +16,7 @@ import java.util.Collection;
import org.jivesoftware.messenger.auth.UnauthorizedException; import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.user.UserNotFoundException; import org.jivesoftware.messenger.user.UserNotFoundException;
import org.jivesoftware.messenger.Component;
import org.xmpp.packet.Message; import org.xmpp.packet.Message;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
...@@ -26,14 +27,15 @@ import org.xmpp.packet.JID; ...@@ -26,14 +27,15 @@ import org.xmpp.packet.JID;
* *
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
public interface MultiUserChatServer { public interface MultiUserChatServer extends Component {
/** /**
* Obtain the name of this chat service. * Obtain the domain of this chat service. The domain is composed by the service name and the
* name of the xmpp server where the service is running.
* *
* @return The chat server name (host name). * @return The chat server domain (service name + host name).
*/ */
String getServiceName(); String getServiceDomain();
/** /**
* Set the name of this chat service. The new name won't go into effect until the server is * Set the name of this chat service. The new name won't go into effect until the server is
......
...@@ -106,7 +106,7 @@ public class MUCRoleImpl implements MUCRole { ...@@ -106,7 +106,7 @@ public class MUCRoleImpl implements MUCRole {
extendedInformation = extendedInformation =
DocumentHelper.createElement(QName.get("x", "http://jabber.org/protocol/muc#user")); DocumentHelper.createElement(QName.get("x", "http://jabber.org/protocol/muc#user"));
calculateExtendedInformation(); calculateExtendedInformation();
rJID = new JID(room.getName(), server.getServiceName(), nick); rJID = new JID(room.getName(), server.getServiceDomain(), nick);
setPresence(presence); setPresence(presence);
} }
...@@ -181,7 +181,7 @@ public class MUCRoleImpl implements MUCRole { ...@@ -181,7 +181,7 @@ public class MUCRoleImpl implements MUCRole {
public void changeNickname(String nickname) { public void changeNickname(String nickname) {
this.nick = nickname; this.nick = nickname;
setRoleAddress(new JID(room.getName(), server.getServiceName(), nick)); setRoleAddress(new JID(room.getName(), server.getServiceDomain(), nick));
} }
public MUCUser getChatUser() { public MUCUser getChatUser() {
......
...@@ -881,7 +881,7 @@ public class MUCRoomImpl implements MUCRoom { ...@@ -881,7 +881,7 @@ public class MUCRoomImpl implements MUCRoom {
public JID getRoleAddress() { public JID getRoleAddress() {
if (crJID == null) { if (crJID == null) {
crJID = new JID(room.getName(), server.getServiceName(), ""); crJID = new JID(room.getName(), server.getServiceDomain(), "");
} }
return crJID; return crJID;
} }
......
...@@ -20,11 +20,7 @@ import java.text.SimpleDateFormat; ...@@ -20,11 +20,7 @@ import java.text.SimpleDateFormat;
import org.dom4j.DocumentHelper; import org.dom4j.DocumentHelper;
import org.dom4j.Element; import org.dom4j.Element;
import org.jivesoftware.messenger.JiveGlobals; import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.PacketRouter;
import org.jivesoftware.messenger.RoutableChannelHandler;
import org.jivesoftware.messenger.RoutingTable;
import org.jivesoftware.messenger.XMPPServer;
import org.jivesoftware.messenger.auth.UnauthorizedException; import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.container.BasicModule; import org.jivesoftware.messenger.container.BasicModule;
import org.jivesoftware.messenger.disco.DiscoInfoProvider; import org.jivesoftware.messenger.disco.DiscoInfoProvider;
...@@ -67,7 +63,7 @@ import org.xmpp.packet.Presence; ...@@ -67,7 +63,7 @@ import org.xmpp.packet.Presence;
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
public class MultiUserChatServerImpl extends BasicModule implements MultiUserChatServer, public class MultiUserChatServerImpl extends BasicModule implements MultiUserChatServer,
ServerItemsProvider, DiscoInfoProvider, DiscoItemsProvider, RoutableChannelHandler { ServerItemsProvider, DiscoInfoProvider, DiscoItemsProvider {
private static final DateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss"); private static final DateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
static { static {
...@@ -381,6 +377,10 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -381,6 +377,10 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
return chatServiceName; return chatServiceName;
} }
public String getServiceDomain() {
return chatServiceAddress.getDomain();
}
public HistoryStrategy getHistoryStrategy() { public HistoryStrategy getHistoryStrategy() {
return historyStrategy; return historyStrategy;
} }
...@@ -645,12 +645,12 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -645,12 +645,12 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
if (chatServiceName == null) { if (chatServiceName == null) {
chatServiceName = "conference"; chatServiceName = "conference";
} }
String serverName = null; String serverName = server.getServerInfo().getName();
serverName = server.getServerInfo().getName(); String domain = chatServiceName;
if (serverName != null) { if (serverName != null) {
chatServiceName += "." + serverName; domain = chatServiceName + "." + serverName;
} }
chatServiceAddress = new JID(null, chatServiceName, null); chatServiceAddress = new JID(null, domain, null);
// Run through the users every 5 minutes after a 5 minutes server startup delay (default // Run through the users every 5 minutes after a 5 minutes server startup delay (default
// values) // values)
userTimeoutTask = new UserTimeoutTask(); userTimeoutTask = new UserTimeoutTask();
...@@ -667,7 +667,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -667,7 +667,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
router = server.getPacketRouter(); router = server.getPacketRouter();
// TODO Remove the tracking for IQRegisterHandler when the component JEP gets implemented. // TODO Remove the tracking for IQRegisterHandler when the component JEP gets implemented.
registerHandler = server.getIQRegisterHandler(); registerHandler = server.getIQRegisterHandler();
registerHandler.addDelegate(getServiceName(), new IQMUCRegisterHandler(this)); registerHandler.addDelegate(getServiceDomain(), new IQMUCRegisterHandler(this));
} }
public void start() { public void start() {
...@@ -676,7 +676,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -676,7 +676,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
routingTable.addRoute(chatServiceAddress, this); routingTable.addRoute(chatServiceAddress, this);
ArrayList params = new ArrayList(); ArrayList params = new ArrayList();
params.clear(); params.clear();
params.add(chatServiceName); params.add(chatServiceAddress.getDomain());
Log.info(LocaleUtils.getLocalizedString("startup.starting.muc", params)); Log.info(LocaleUtils.getLocalizedString("startup.starting.muc", params));
// Load all the persistent rooms to memory // Load all the persistent rooms to memory
for (MUCRoom room : MUCPersistenceManager.loadRoomsFromDB(this, this.getCleanupDate(), for (MUCRoom room : MUCPersistenceManager.loadRoomsFromDB(this, this.getCleanupDate(),
...@@ -692,7 +692,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -692,7 +692,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
timer.cancel(); timer.cancel();
logAllConversation(); logAllConversation();
if (registerHandler != null) { if (registerHandler != null) {
registerHandler.removeDelegate(getServiceName()); registerHandler.removeDelegate(getServiceDomain());
} }
} }
...@@ -726,7 +726,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -726,7 +726,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
items.add(new DiscoServerItem() { items.add(new DiscoServerItem() {
public String getJID() { public String getJID() {
return chatServiceName; return chatServiceAddress.getDomain();
} }
public String getName() { public String getName() {
......
...@@ -58,18 +58,11 @@ ...@@ -58,18 +58,11 @@
else { else {
name = admin.getServerInfo().getName() == null ? "" : admin.getServerInfo().getName(); name = admin.getServerInfo().getName() == null ? "" : admin.getServerInfo().getName();
muc = admin.getMultiUserChatServer().getServiceName() == null ? "" : admin.getMultiUserChatServer().getServiceName(); muc = admin.getMultiUserChatServer().getServiceName() == null ? "" : admin.getMultiUserChatServer().getServiceName();
// Remove the server address part from the MUC domain name.
int index = muc.indexOf("." + name);
if (index > 0) {
muc = muc.substring(0, index);
}
} }
name = admin.getServerInfo().getName(); name = admin.getServerInfo().getName();
if (errors.size() == 0) { if (errors.size() == 0) {
muc = admin.getMultiUserChatServer().getServiceName(); muc = admin.getMultiUserChatServer().getServiceName();
int pos = muc.lastIndexOf("." + name);
muc = muc.substring(0, pos);
} }
%> %>
......
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