Commit f9ff26eb authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Working on multiple resource support.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@4828 b35dd754-fafc-0310-a699-88a17e54d16e
parent 95bab525
......@@ -4,12 +4,10 @@ Gateway Plugin
Main Todo List:
- Switch to using shared rosters instead of direct roster edit for 'buddy list'
- Evaluate whether shared rosters or direct roster edit should be used for actua
l transport
- Evaluate whether shared rosters or direct roster edit should be used for actual transport
- Use threads for transport sessions
- MUC/Groupchat support
- DB files for other DB types
- Test embedded DB
- Typing notifications
- Add/remove buddies from legacy contact list
- AIM/ICQ is not pulling entire buddy list?
......
......@@ -11,6 +11,7 @@
package org.jivesoftware.wildfire.gateway;
import org.xmpp.packet.JID;
import java.util.TreeMap;
/**
* Interface for a transport session.
......@@ -46,10 +47,15 @@ public abstract class TransportSession implements Runnable {
public BaseTransport transport;
/**
* JID the session is associated with. (includes specific resource)
* The bare JID the session is associated with.
*/
public JID jid;
/**
* All JIDs (including resources) that are associated with this session.
*/
public TreeMap<Integer,String> resources = new TreeMap<Integer,String>();
/**
* Is this session valid? Set to false when session is done.
*/
......@@ -74,7 +80,7 @@ public abstract class TransportSession implements Runnable {
}
/**
* Retrieves the jid associated with the session.
* Retrieves the bare jid associated with the session.
*
* @return JID of the user associated with this session.
*/
......@@ -82,6 +88,15 @@ public abstract class TransportSession implements Runnable {
return jid;
}
/**
* Retrieves the JID of the highest priority resource.
*
* @return Full JID including resource with highest priority.
*/
public JID getJIDWithHighestPriority() {
return new JID(jid.getNode(),jid.getDomain(),resources.get(resources.lastKey()));
}
/**
* Handles monitoring of whether session is still valid.
*/
......@@ -142,4 +157,11 @@ public abstract class TransportSession implements Runnable {
*/
public abstract void retrieveContactStatus(JID jid);
/**
* Asks the legacy service to send presence packets for all known contacts.
*
* @param jid JID to have the presence packets sent to.
*/
public abstract void resendContactStatuses(JID jid);
}
......@@ -93,35 +93,35 @@ public class MSNSession extends TransportSession {
}
/**
* Have we successfully logged in to MSN?
* Retrieves the manager for this session.
*/
public MessengerServerManager getManager() {
return msnManager;
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#isLoggedIn()
*/
public Boolean isLoggedIn() {
return msnManager.isConnected();
}
/**
* Adds a contact to the user's MSN contact list.
*
* @param jid JID of contact to be added.
* @see org.jivesoftware.wildfire.gateway.TransportSession#addContact(org.xmpp.packet.JID)
*/
public void addContact(JID jid) {
// TODO: check jabber group and use it
// @todo check jabber group and use it
}
/**
* Removes a contact from the user's MSN contact list.
*
* @param jid JID of contact to be added.
* @see org.jivesoftware.wildfire.gateway.TransportSession#removeContact(org.xmpp.packet.JID)
*/
public void removeContact(JID jid) {
// TODO: check jabber group and use it
// @todo check jabber group and use it
}
/**
* Sends a message from the jabber user to a MSN contact.
*
* @param jid JID of contact to send message to.
* @param message Message to send to yahoo contact.
* @see org.jivesoftware.wildfire.gateway.TransportSession#sendMessage(org.xmpp.packet.JID, String)
*/
public void sendMessage(JID jid, String message) {
try {
......@@ -133,16 +133,14 @@ public class MSNSession extends TransportSession {
}
/**
* Asks for transport to send information about a contact if possible.
*
* @param jid JID of contact to be probed.
* @see org.jivesoftware.wildfire.gateway.TransportSession#retrieveContactStatus(org.xmpp.packet.JID)
*/
public void retrieveContactStatus(JID jid) {
// TODO: yeah
// @todo need to implement this
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#updateStatus
* @see org.jivesoftware.wildfire.gateway.TransportSession#updateStatus(org.jivesoftware.wildfire.gateway.PresenceType, String)
*/
public void updateStatus(PresenceType presenceType, String verboseStatus) {
try {
......@@ -154,10 +152,10 @@ public class MSNSession extends TransportSession {
}
/**
* Retrieves the manager for this session.
* @see org.jivesoftware.wildfire.gateway.TransportSession#resendContactStatuses(org.xmpp.packet.JID)
*/
public MessengerServerManager getManager() {
return msnManager;
public void resendContactStatuses(JID jid) {
// @todo need to implement this
}
}
......@@ -103,7 +103,10 @@ public class OSCARSession extends TransportSession {
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#addContact(org.xmpp.packet.JID)
*/
public void addContact(JID jid) {
Integer newBuddyId = highestBuddyId + 1;
Integer groupId = -1;
......@@ -123,6 +126,9 @@ public class OSCARSession extends TransportSession {
new BuddyItem(getTransport().convertJIDToID(jid), newBuddyId, groupId).toSsiItem() }));
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#removeContact(org.xmpp.packet.JID)
*/
public void removeContact(JID jid) {
for (BuddyItem i : buddies.values()) {
if (i.getScreenname().equals(getTransport().convertJIDToID(jid))) {
......@@ -132,6 +138,9 @@ public class OSCARSession extends TransportSession {
}
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#sendMessage(org.xmpp.packet.JID, String)
*/
public void sendMessage(JID jid, String message) {
request(new SendImIcbm(getTransport().convertJIDToID(jid), message));
}
......@@ -153,6 +162,7 @@ public class OSCARSession extends TransportSession {
}
}
});
synchronized void handleRequest(SnacRequest request) {
int family = request.getCommand().getFamily();
if (snacMgr.isPending(family)) {
......@@ -272,16 +282,14 @@ public class OSCARSession extends TransportSession {
}
/**
* Asks for transport to send information about a contact if possible.
*
* @param jid JID of contact to be probed.
* @see org.jivesoftware.wildfire.gateway.TransportSession#retrieveContactStatus(org.xmpp.packet.JID)
*/
public void retrieveContactStatus(JID jid) {
bosConn.getAndSendStatus(getTransport().convertJIDToID(jid));
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#updateStatus
* @see org.jivesoftware.wildfire.gateway.TransportSession#updateStatus(org.jivesoftware.wildfire.gateway.PresenceType, String)
*/
public void updateStatus(PresenceType presenceType, String verboseStatus) {
if (presenceType != PresenceType.available && presenceType != PresenceType.chat) {
......@@ -299,4 +307,11 @@ public class OSCARSession extends TransportSession {
this.verboseStatus = verboseStatus;
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#resendContactStatuses(org.xmpp.packet.JID)
*/
public void resendContactStatuses(JID jid) {
// @todo need to implement this
}
}
......@@ -146,7 +146,7 @@ public class YahooSession extends TransportSession {
}
/**
* Have we successfully logged in to Yahoo?
* @see org.jivesoftware.wildfire.gateway.TransportSession#isLoggedIn()
*/
public Boolean isLoggedIn() {
return loggedIn;
......@@ -188,12 +188,10 @@ public class YahooSession extends TransportSession {
}
/**
* Adds a contact to the user's Yahoo contact list.
*
* @param jid JID of contact to be added.
* @see org.jivesoftware.wildfire.gateway.TransportSession#addContact(org.xmpp.packet.JID)
*/
public void addContact(JID jid) {
// TODO: check jabber group and use it
// @todo check jabber group and use it
try {
yahooSession.addFriend(jid.getNode(), "Yahoo Transport");
}
......@@ -203,12 +201,10 @@ public class YahooSession extends TransportSession {
}
/**
* Removes a contact from the user's Yahoo contact list.
*
* @param jid JID of contact to be added.
* @see org.jivesoftware.wildfire.gateway.TransportSession#removeContact(org.xmpp.packet.JID)
*/
public void removeContact(JID jid) {
// TODO: check jabber group and use it
// @todo check jabber group and use it
try {
yahooSession.removeFriend(jid.getNode(), "Yahoo Transport");
}
......@@ -218,10 +214,7 @@ public class YahooSession extends TransportSession {
}
/**
* Sends a message from the jabber user to a Yahoo contact.
*
* @param jid JID of contact to send message to.
* @param message Message to send to yahoo contact.
* @see org.jivesoftware.wildfire.gateway.TransportSession#sendMessage(org.xmpp.packet.JID, String)
*/
public void sendMessage(JID jid, String message) {
try {
......@@ -233,7 +226,7 @@ public class YahooSession extends TransportSession {
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#updateStatus
* @see org.jivesoftware.wildfire.gateway.TransportSession#updateStatus(org.jivesoftware.wildfire.gateway.PresenceType, String)
*/
public void updateStatus(PresenceType presenceType, String verboseStatus) {
try {
......@@ -247,9 +240,7 @@ public class YahooSession extends TransportSession {
}
/**
* Asks for transport to send information about a contact if possible.
*
* @param jid JID of contact to be probed.
* @see org.jivesoftware.wildfire.gateway.TransportSession#retrieveContactStatus(org.xmpp.packet.JID)
*/
public void retrieveContactStatus(JID jid) {
YahooUser user = yahooSession.getUser(jid.getNode());
......@@ -264,6 +255,26 @@ public class YahooSession extends TransportSession {
((YahooTransport)getTransport()).setUpPresencePacket(p, user.getStatus());
getTransport().sendPacket(p);
}
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#resendContactStatuses(org.xmpp.packet.JID)
*/
public void resendContactStatuses(JID jid) {
for (Object userObj : yahooSession.getUsers().values()) {
YahooUser user = (YahooUser)userObj;
Presence p = new Presence();
p.setTo(jid);
p.setFrom(getTransport().convertIDToJID(user.getId()));
String custommsg = user.getCustomStatusMessage();
if (custommsg != null) {
p.setStatus(custommsg);
}
((YahooTransport)getTransport()).setUpPresencePacket(p, user.getStatus());
getTransport().sendPacket(p);
}
}
}
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