Commit 9a434fd3 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[GATE-55] Restructuring work to incorporate lack of need of transports in roster.

[GATE-13] Working on "what features the client supports" functionality for things like typing notifications.
[GATE-1] Messing with threads a tad.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@5787 b35dd754-fafc-0310-a699-88a17e54d16e
parent fc67ab7c
/**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway;
/**
* An enumeration for supported features.
*
* This represents features that the client supports that we have detected and
* can make use of.
*
* @author Daniel Henninger
*/
public enum SupportedFeature {
/**
* Chat States (XEP-0085)
*/
chatstates
}
...@@ -17,6 +17,7 @@ import org.jivesoftware.wildfire.roster.Roster; ...@@ -17,6 +17,7 @@ import org.jivesoftware.wildfire.roster.Roster;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.ArrayList;
/** /**
* Interface for a transport session. * Interface for a transport session.
...@@ -90,6 +91,11 @@ public abstract class TransportSession implements Runnable { ...@@ -90,6 +91,11 @@ public abstract class TransportSession implements Runnable {
*/ */
public TransportLoginStatus loginStatus = TransportLoginStatus.LOGGED_OUT; public TransportLoginStatus loginStatus = TransportLoginStatus.LOGGED_OUT;
/**
* Supported features.
*/
public ArrayList<SupportedFeature> supportedFeatures = new ArrayList<SupportedFeature>();
/** /**
* Associates a resource with the session, and tracks it's priority. * Associates a resource with the session, and tracks it's priority.
* *
...@@ -250,6 +256,43 @@ public abstract class TransportSession implements Runnable { ...@@ -250,6 +256,43 @@ public abstract class TransportSession implements Runnable {
return (resources.containsValue(resource)); return (resources.containsValue(resource));
} }
/**
* Sets a feature that the client supports.
*
* @param feature Feature that the session supports.
*/
public void setSupportedFeature(SupportedFeature feature) {
if (!supportedFeatures.contains(feature)) {
supportedFeatures.add(feature);
}
}
/**
* Removes a feature that the client supports.
*
* @param feature Feature to be removed from the supported list.
*/
public void removeSupportedFeature(SupportedFeature feature) {
supportedFeatures.remove(feature);
}
/**
* Clears all of the supported features recorded.
*/
public void clearSupportedFeatures() {
supportedFeatures.clear();
}
/**
* Retrieves whether this session supports a specific feature.
*
* @param feature Feature to check for support of.
* @return True or false if the session supports the specified feature.
*/
public Boolean isFeatureSupported(SupportedFeature feature) {
return supportedFeatures.contains(feature);
}
/** /**
* Updates the login status. * Updates the login status.
* *
......
...@@ -53,6 +53,11 @@ public class TransportSessionManager { ...@@ -53,6 +53,11 @@ public class TransportSessionManager {
*/ */
BaseTransport transport; BaseTransport transport;
/**
* Group of all threads related to this session.
*/
public ThreadGroup threadGroup;
/** /**
* Creates the transport session manager instance and initializes. * Creates the transport session manager instance and initializes.
* *
...@@ -72,6 +77,34 @@ public class TransportSessionManager { ...@@ -72,6 +77,34 @@ public class TransportSessionManager {
timer.cancel(); timer.cancel();
} }
/**
* Initialize the thread group manager.
*
* @param jid JID for naming purposes of the thread group manager.
*/
public void startThreadManager(JID jid) {
threadGroup = new ThreadGroup(jid.toString());
}
/**
* Destroys the thread group manager.
*/
public void stopThreadManager() {
threadGroup.destroy();
}
/**
* Starts a thread associated with a session.
*
* @param session Session the thread will be associated with.
* @return A thread wrapped around the session.
*/
public Thread startThread(TransportSession session) {
Thread sessionThread = new Thread(threadGroup, session);
sessionThread.start();
return sessionThread;
}
/** /**
* Retrieve the session instance for a given JID. * Retrieve the session instance for a given JID.
* *
......
...@@ -81,8 +81,7 @@ public class IRCTransport extends BaseTransport { ...@@ -81,8 +81,7 @@ public class IRCTransport extends BaseTransport {
public TransportSession registrationLoggedIn(Registration registration, JID jid, PresenceType presenceType, String verboseStatus, Integer priority) { public TransportSession registrationLoggedIn(Registration registration, JID jid, PresenceType presenceType, String verboseStatus, Integer priority) {
Log.debug("Logging in to IRC gateway."); Log.debug("Logging in to IRC gateway.");
TransportSession session = new IRCSession(registration, jid, this, priority); TransportSession session = new IRCSession(registration, jid, this, priority);
Thread sessionThread = new Thread(session); this.getSessionManager().startThread(session);
sessionThread.start();
((IRCSession)session).logIn(presenceType, verboseStatus); ((IRCSession)session).logIn(presenceType, verboseStatus);
return session; return session;
} }
......
...@@ -83,8 +83,7 @@ public class MSNTransport extends BaseTransport { ...@@ -83,8 +83,7 @@ public class MSNTransport extends BaseTransport {
public TransportSession registrationLoggedIn(Registration registration, JID jid, PresenceType presenceType, String verboseStatus, Integer priority) { public TransportSession registrationLoggedIn(Registration registration, JID jid, PresenceType presenceType, String verboseStatus, Integer priority) {
Log.debug("Logging in to MSN gateway."); Log.debug("Logging in to MSN gateway.");
TransportSession session = new MSNSession(registration, jid, this, priority); TransportSession session = new MSNSession(registration, jid, this, priority);
Thread sessionThread = new Thread(session); this.getSessionManager().startThread(session);
sessionThread.start();
((MSNSession)session).logIn(presenceType, verboseStatus); ((MSNSession)session).logIn(presenceType, verboseStatus);
return session; return session;
} }
......
...@@ -84,8 +84,7 @@ public class OSCARTransport extends BaseTransport { ...@@ -84,8 +84,7 @@ public class OSCARTransport extends BaseTransport {
*/ */
public TransportSession registrationLoggedIn(Registration registration, JID jid, PresenceType presenceType, String verboseStatus, Integer priority) { public TransportSession registrationLoggedIn(Registration registration, JID jid, PresenceType presenceType, String verboseStatus, Integer priority) {
TransportSession session = new OSCARSession(registration, jid, this, priority); TransportSession session = new OSCARSession(registration, jid, this, priority);
Thread sessionThread = new Thread(session); this.getSessionManager().startThread(session);
sessionThread.start();
((OSCARSession)session).logIn(presenceType, verboseStatus); ((OSCARSession)session).logIn(presenceType, verboseStatus);
return session; return session;
} }
......
...@@ -83,8 +83,7 @@ public class YahooTransport extends BaseTransport { ...@@ -83,8 +83,7 @@ public class YahooTransport extends BaseTransport {
public TransportSession registrationLoggedIn(Registration registration, JID jid, PresenceType presenceType, String verboseStatus, Integer priority) { public TransportSession registrationLoggedIn(Registration registration, JID jid, PresenceType presenceType, String verboseStatus, Integer priority) {
Log.debug("Logging in to Yahoo gateway."); Log.debug("Logging in to Yahoo gateway.");
TransportSession session = new YahooSession(registration, jid, this, priority); TransportSession session = new YahooSession(registration, jid, this, priority);
Thread sessionThread = new Thread(session); this.getSessionManager().startThread(session);
sessionThread.start();
((YahooSession)session).logIn(presenceType, verboseStatus); ((YahooSession)session).logIn(presenceType, verboseStatus);
return session; return session;
} }
......
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