Commit 1f2d303e authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

Refactoring changes


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@600 b35dd754-fafc-0310-a699-88a17e54d16e
parent a69f4060
......@@ -12,14 +12,16 @@
package org.jivesoftware.messenger.forms.spi;
import org.jivesoftware.messenger.forms.FormField;
import org.jivesoftware.util.Log;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import java.io.IOException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.XMLWriter;
import org.xmlpull.v1.XmlPullParserException;
/**
* A concrete FormField capable of sending itself to a writer and recover its state from an XMPP
......@@ -244,17 +246,21 @@ public class XFormFieldImpl implements FormField {
return value;
}
public void send(XMLStreamWriter xmlSerializer, int version) throws XMLStreamException {
xmlSerializer.writeStartElement("jabber:x:data", "option");
public void send(XMLWriter xmlSerializer, int version) throws XmlPullParserException {
Element jabber = DocumentHelper.createElement("option").addNamespace("", "jabber:x:data");
if (getLabel() != null) {
xmlSerializer.writeAttribute("label", getLabel());
jabber.addAttribute("label", getLabel());
}
if (getValue() != null) {
xmlSerializer.writeStartElement("jabber:x:data", "value");
xmlSerializer.writeCharacters(getValue());
xmlSerializer.writeEndElement();
Element subElement = jabber.addElement("value", "jabber:x:data");
subElement.addText(getValue());
}
try {
xmlSerializer.write(jabber);
}
catch (IOException e) {
Log.error(e);
}
xmlSerializer.writeEndElement();
}
public Element asXMLElement() {
......
......@@ -362,7 +362,6 @@ public class PresenceSubscribeHandler extends BasicModule implements ChannelHand
public UserManager userManager;
public XMPPServer localServer;
public PacketDeliverer deliverer;
public PacketFactory packetFactory;
protected TrackInfo getTrackInfo() {
TrackInfo trackInfo = new TrackInfo();
......@@ -370,7 +369,6 @@ public class PresenceSubscribeHandler extends BasicModule implements ChannelHand
trackInfo.getTrackerClasses().put(RoutingTable.class, "routingTable");
trackInfo.getTrackerClasses().put(XMPPServer.class, "localServer");
trackInfo.getTrackerClasses().put(PacketDeliverer.class, "deliverer");
trackInfo.getTrackerClasses().put(PacketFactory.class, "packetFactory");
return trackInfo;
}
......
......@@ -23,10 +23,10 @@ import org.jivesoftware.messenger.user.RosterItem;
import org.jivesoftware.messenger.user.RosterManager;
import org.jivesoftware.messenger.user.UserNotFoundException;
import org.xmpp.packet.*;
import org.xmlpull.v1.XmlPullParserException;
import java.lang.ref.WeakReference;
import java.util.*;
import javax.xml.stream.XMLStreamException;
/**
* Implements the presence protocol. Clients use this protocol to
......@@ -169,8 +169,7 @@ public class PresenceUpdateHandler extends BasicModule implements ChannelHandler
* @throws UnauthorizedException If the caller doesn't have the right permissions
* @throws UserNotFoundException If the user being updated does not exist
*/
private void initSession(Session session)
throws UnauthorizedException, UserNotFoundException, XMLStreamException {
private void initSession(Session session) throws UnauthorizedException, UserNotFoundException, XmlPullParserException {
// Only user sessions need to be authenticated
if (!"".equals(session.getAddress().getNode())) {
......@@ -199,7 +198,7 @@ public class PresenceUpdateHandler extends BasicModule implements ChannelHandler
}
public Presence createSubscribePresence(JID senderAddress, boolean isSubscribe) {
Presence presence = packetFactory.getPresence();
Presence presence = new Presence();
presence.setFrom(senderAddress);
if (isSubscribe) {
presence.setType(Presence.Type.subscribe);
......@@ -382,7 +381,6 @@ public class PresenceUpdateHandler extends BasicModule implements ChannelHandler
public SessionManager sessionManager;
public PresenceManager presenceManager;
public PacketDeliverer deliverer;
public PacketFactory packetFactory;
public OfflineMessageStore messageStore;
protected TrackInfo getTrackInfo() {
......@@ -392,7 +390,6 @@ public class PresenceUpdateHandler extends BasicModule implements ChannelHandler
trackInfo.getTrackerClasses().put(SessionManager.class, "sessionManager");
trackInfo.getTrackerClasses().put(PresenceManager.class, "presenceManager");
trackInfo.getTrackerClasses().put(PacketDeliverer.class, "deliverer");
trackInfo.getTrackerClasses().put(PacketFactory.class, "packetFactory");
trackInfo.getTrackerClasses().put(OfflineMessageStore.class, "messageStore");
return trackInfo;
}
......
......@@ -11,33 +11,53 @@
package org.jivesoftware.messenger.muc.spi;
import org.jivesoftware.messenger.container.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.LinkedBlockingQueue;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.messenger.PacketDeliverer;
import org.jivesoftware.messenger.PacketRouter;
import org.jivesoftware.messenger.PresenceManager;
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.container.BasicModule;
import org.jivesoftware.messenger.container.Container;
import org.jivesoftware.messenger.container.TrackInfo;
import org.jivesoftware.messenger.disco.DiscoInfoProvider;
import org.jivesoftware.messenger.disco.DiscoItemsProvider;
import org.jivesoftware.messenger.disco.DiscoServerItem;
import org.jivesoftware.messenger.disco.ServerItemsProvider;
import org.jivesoftware.messenger.forms.DataForm;
import org.jivesoftware.messenger.forms.FormField;
import org.jivesoftware.messenger.forms.XDataForm;
import org.jivesoftware.messenger.forms.spi.XDataFormImpl;
import org.jivesoftware.messenger.forms.spi.XFormFieldImpl;
import org.jivesoftware.messenger.muc.*;
import org.jivesoftware.util.*;
import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.handler.IQRegisterHandler;
import org.jivesoftware.messenger.muc.HistoryStrategy;
import org.jivesoftware.messenger.muc.MUCRole;
import org.jivesoftware.messenger.muc.MUCRoom;
import org.jivesoftware.messenger.muc.MUCUser;
import org.jivesoftware.messenger.muc.MultiUserChatServer;
import org.jivesoftware.messenger.muc.NotAllowedException;
import org.jivesoftware.messenger.user.UserNotFoundException;
import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.xmpp.packet.JID;
import org.xmpp.packet.Presence;
import org.xmpp.packet.Packet;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
import org.xmpp.packet.Presence;
/**
* Implements the chat server as a cached memory resident chat server. The server is also
......@@ -772,7 +792,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
return features.iterator();
}
public XDataForm getExtendedInfo(String name, String node, JID senderJID) {
public XDataFormImpl getExtendedInfo(String name, String node, JID senderJID) {
if (name != null && node == null) {
// Answer the extended info of a given room
// TODO lock the room while gathering this info???
......
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