Commit 1e661f89 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Still working on multiple resources, and misc documentation.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@4861 b35dd754-fafc-0310-a699-88a17e54d16e
parent d39f3401
......@@ -12,8 +12,11 @@ package org.jivesoftware.wildfire.gateway;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.PropertyEventListener;
import org.xmpp.component.ComponentManager;
import java.util.Map;
/**
* Transport Instance
*
......@@ -21,7 +24,7 @@ import org.xmpp.component.ComponentManager;
*
* @author Daniel Henninger
*/
public class TransportInstance {
public class TransportInstance implements PropertyEventListener {
private ComponentManager componentManager;
private String description = null;
......@@ -158,4 +161,36 @@ public class TransportInstance {
return transport;
}
public void propertySet(String property, Map params) {
if (property.equals("plugin.gateway."+this.type.toString()+"Enabled")) {
enabled = Boolean.parseBoolean((String)params.get("value"));
if (enabled) {
if (!running) {
startInstance();
}
}
else {
if (running) {
stopInstance();
}
}
}
}
public void propertyDeleted(String property, Map params) {
if (property.equals("plugin.gateway."+this.type.toString()+"Enabled")) {
if (running) {
stopInstance();
}
}
}
public void xmlPropertySet(String property, Map params) {
// Ignore
}
public void xmlPropertyDeleted(String property, Map params) {
// Ignore
}
}
......@@ -31,13 +31,30 @@ public abstract class TransportSession implements Runnable {
* Creates a TransportSession instance.
*
* @param registration Registration this session is associated with.
* @param jid JID of user associated with this session.
* @param transport Transport this session is associated with.
*/
public TransportSession(Registration registration, JID jid, BaseTransport transport) {
this.jid = jid;
this.jid = new JID(jid.toBareJID());
this.registration = registration;
this.transport = transport;
}
/**
* Convenience constructor that includes priority.
*
* @param registration Registration this session is associated with.
* @param jid JID of user associated with this session.
* @param transport Transport this session is associated with.
* @param priority Priority associated with session.
*/
public TransportSession(Registration registration, JID jid, BaseTransport transport, Integer priority) {
this.jid = new JID(jid.toBareJID());
this.registration = registration;
this.transport = transport;
addResource(jid.getResource(), priority);
}
/**
* Registration that this session is associated with.
*/
......@@ -63,6 +80,34 @@ public abstract class TransportSession implements Runnable {
*/
public boolean validSession = true;
/**
* Associates a resource with the session, and tracks it's priority.
*/
public void addResource(String resource, Integer priority) {
resources.put(priority, resource);
}
/**
* Removes an association of a resource with the session.
*/
public void removeResource(String resource) {
for (Integer i : resources.keySet()) {
if (resources.get(i).equals(resource)) {
resources.remove(i);
break;
}
}
}
/**
* Returns the number of active resources.
*
* @return Number of active resources.
*/
public int getResourceCount() {
return resources.size();
}
/**
* Retrieves the registration information associated with the session.
*
......
......@@ -26,6 +26,12 @@ import net.kano.joscar.ssiitem.*;
import java.net.InetAddress;
/**
* Handles BOS related packets.
*
* @author Daniel Henninger
* Heavily inspired by joscardemo from the joscar project.
*/
public class BOSConnection extends BasicFlapConnection {
protected SsiItemObjectFactory itemFactory = new DefaultSsiItemObjFactory();
......
......@@ -22,6 +22,12 @@ import net.kano.joscar.snaccmd.*;
import java.net.InetAddress;
/**
* Base class for all FLAP handlers.
*
* @author Daniel Henninger
* Heavily inspired by joscardemo from the joscar project.
*/
public abstract class BaseFlapConnection extends ClientFlapConn {
protected ClientSnacProcessor sp;
OSCARSession oscarSession;
......
......@@ -35,6 +35,12 @@ import org.xmpp.packet.Message;
import org.xmpp.packet.Presence;
import org.xmpp.packet.JID;
/**
* Handles incoming FLAP packets.
*
* @author Daniel Henninger
* Heavily inspired by joscardemo from the joscar project.
*/
public abstract class BasicFlapConnection extends BaseFlapConnection {
protected final ByteBlock cookie;
protected boolean sentClientReady = false;
......
......@@ -23,6 +23,12 @@ import net.kano.joscar.snaccmd.auth.*;
import java.net.InetAddress;
/**
* Handles the login process with the OSCAR login server.
*
* @author Daniel Henninger
* Heavily inspired by joscardemo from the joscar project.
*/
public class LoginConnection extends BaseFlapConnection {
protected boolean loggedin = false;
......
......@@ -14,6 +14,12 @@ package org.jivesoftware.wildfire.gateway.protocols.oscar;
import net.kano.joscar.snac.SnacRequest;
/**
* Handles events from pending SNAC manager.
*
* @author Daniel Henninger
* Heavily inspired by joscardemo from the joscar project.
*/
public interface PendingSnacListener {
void dequeueSnacs(SnacRequest[] pending);
}
......@@ -19,6 +19,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Handles pending SNAC commands.
*
* @author Daniel Henninger
* Heavily inspired by joscardemo from the joscar project.
*/
public class PendingSnacMgr {
protected Map<Integer,List<SnacRequest>> snacs = new HashMap<Integer,List<SnacRequest>>();
......
......@@ -23,6 +23,12 @@ import net.kano.joscar.snaccmd.search.*;
import java.net.InetAddress;
/**
* Represents a connection to a particular OSCAR service.
*
* @author Daniel Henninger
* Heavily inspired by joscardemo from the joscar project.
*/
public class ServiceConnection extends BasicFlapConnection {
protected int serviceFamily;
......
......@@ -21,6 +21,12 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* Handles incoming SNAC packets.
*
* @author Daniel Henninger
* Heavily inspired by joscardemo from the joscar project.
*/
public class SnacManager {
protected Map<Integer,List<BasicFlapConnection>> conns = new HashMap<Integer,List<BasicFlapConnection>>();
protected PendingSnacMgr pendingSnacs = new PendingSnacMgr();
......
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