Commit 7d75b83c 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/src/plugins/gateway@4828 b35dd754-fafc-0310-a699-88a17e54d16e
parent 26bd8f33
...@@ -4,12 +4,10 @@ Gateway Plugin ...@@ -4,12 +4,10 @@ Gateway Plugin
Main Todo List: Main Todo List:
- Switch to using shared rosters instead of direct roster edit for 'buddy 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 - Evaluate whether shared rosters or direct roster edit should be used for actual transport
l transport
- Use threads for transport sessions - Use threads for transport sessions
- MUC/Groupchat support - MUC/Groupchat support
- DB files for other DB types - DB files for other DB types
- Test embedded DB
- Typing notifications - Typing notifications
- Add/remove buddies from legacy contact list - Add/remove buddies from legacy contact list
- AIM/ICQ is not pulling entire buddy list? - AIM/ICQ is not pulling entire buddy list?
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
package org.jivesoftware.wildfire.gateway; package org.jivesoftware.wildfire.gateway;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import java.util.TreeMap;
/** /**
* Interface for a transport session. * Interface for a transport session.
...@@ -46,10 +47,15 @@ public abstract class TransportSession implements Runnable { ...@@ -46,10 +47,15 @@ public abstract class TransportSession implements Runnable {
public BaseTransport transport; public BaseTransport transport;
/** /**
* JID the session is associated with. (includes specific resource) * The bare JID the session is associated with.
*/ */
public JID jid; 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. * Is this session valid? Set to false when session is done.
*/ */
...@@ -74,7 +80,7 @@ public abstract class TransportSession implements Runnable { ...@@ -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. * @return JID of the user associated with this session.
*/ */
...@@ -82,6 +88,15 @@ public abstract class TransportSession implements Runnable { ...@@ -82,6 +88,15 @@ public abstract class TransportSession implements Runnable {
return jid; 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. * Handles monitoring of whether session is still valid.
*/ */
...@@ -142,4 +157,11 @@ public abstract class TransportSession implements Runnable { ...@@ -142,4 +157,11 @@ public abstract class TransportSession implements Runnable {
*/ */
public abstract void retrieveContactStatus(JID jid); 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 { ...@@ -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() { public Boolean isLoggedIn() {
return msnManager.isConnected(); return msnManager.isConnected();
} }
/** /**
* Adds a contact to the user's MSN contact list. * @see org.jivesoftware.wildfire.gateway.TransportSession#addContact(org.xmpp.packet.JID)
*
* @param jid JID of contact to be added.
*/ */
public void addContact(JID 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. * @see org.jivesoftware.wildfire.gateway.TransportSession#removeContact(org.xmpp.packet.JID)
*
* @param jid JID of contact to be added.
*/ */
public void removeContact(JID 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. * @see org.jivesoftware.wildfire.gateway.TransportSession#sendMessage(org.xmpp.packet.JID, String)
*
* @param jid JID of contact to send message to.
* @param message Message to send to yahoo contact.
*/ */
public void sendMessage(JID jid, String message) { public void sendMessage(JID jid, String message) {
try { try {
...@@ -133,16 +133,14 @@ public class MSNSession extends TransportSession { ...@@ -133,16 +133,14 @@ public class MSNSession extends TransportSession {
} }
/** /**
* Asks for transport to send information about a contact if possible. * @see org.jivesoftware.wildfire.gateway.TransportSession#retrieveContactStatus(org.xmpp.packet.JID)
*
* @param jid JID of contact to be probed.
*/ */
public void retrieveContactStatus(JID 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) { public void updateStatus(PresenceType presenceType, String verboseStatus) {
try { try {
...@@ -154,10 +152,10 @@ public class MSNSession extends TransportSession { ...@@ -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() { public void resendContactStatuses(JID jid) {
return msnManager; // @todo need to implement this
} }
} }
...@@ -104,6 +104,9 @@ public class OSCARSession extends TransportSession { ...@@ -104,6 +104,9 @@ public class OSCARSession extends TransportSession {
getTransport().sendPacket(p); getTransport().sendPacket(p);
} }
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#addContact(org.xmpp.packet.JID)
*/
public void addContact(JID jid) { public void addContact(JID jid) {
Integer newBuddyId = highestBuddyId + 1; Integer newBuddyId = highestBuddyId + 1;
Integer groupId = -1; Integer groupId = -1;
...@@ -123,6 +126,9 @@ public class OSCARSession extends TransportSession { ...@@ -123,6 +126,9 @@ public class OSCARSession extends TransportSession {
new BuddyItem(getTransport().convertJIDToID(jid), newBuddyId, groupId).toSsiItem() })); new BuddyItem(getTransport().convertJIDToID(jid), newBuddyId, groupId).toSsiItem() }));
} }
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#removeContact(org.xmpp.packet.JID)
*/
public void removeContact(JID jid) { public void removeContact(JID jid) {
for (BuddyItem i : buddies.values()) { for (BuddyItem i : buddies.values()) {
if (i.getScreenname().equals(getTransport().convertJIDToID(jid))) { if (i.getScreenname().equals(getTransport().convertJIDToID(jid))) {
...@@ -132,6 +138,9 @@ public class OSCARSession extends TransportSession { ...@@ -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) { public void sendMessage(JID jid, String message) {
request(new SendImIcbm(getTransport().convertJIDToID(jid), message)); request(new SendImIcbm(getTransport().convertJIDToID(jid), message));
} }
...@@ -153,6 +162,7 @@ public class OSCARSession extends TransportSession { ...@@ -153,6 +162,7 @@ public class OSCARSession extends TransportSession {
} }
} }
}); });
synchronized void handleRequest(SnacRequest request) { synchronized void handleRequest(SnacRequest request) {
int family = request.getCommand().getFamily(); int family = request.getCommand().getFamily();
if (snacMgr.isPending(family)) { if (snacMgr.isPending(family)) {
...@@ -272,16 +282,14 @@ public class OSCARSession extends TransportSession { ...@@ -272,16 +282,14 @@ public class OSCARSession extends TransportSession {
} }
/** /**
* Asks for transport to send information about a contact if possible. * @see org.jivesoftware.wildfire.gateway.TransportSession#retrieveContactStatus(org.xmpp.packet.JID)
*
* @param jid JID of contact to be probed.
*/ */
public void retrieveContactStatus(JID jid) { public void retrieveContactStatus(JID jid) {
bosConn.getAndSendStatus(getTransport().convertJIDToID(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) { public void updateStatus(PresenceType presenceType, String verboseStatus) {
if (presenceType != PresenceType.available && presenceType != PresenceType.chat) { if (presenceType != PresenceType.available && presenceType != PresenceType.chat) {
...@@ -299,4 +307,11 @@ public class OSCARSession extends TransportSession { ...@@ -299,4 +307,11 @@ public class OSCARSession extends TransportSession {
this.verboseStatus = verboseStatus; 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 { ...@@ -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() { public Boolean isLoggedIn() {
return loggedIn; return loggedIn;
...@@ -188,12 +188,10 @@ public class YahooSession extends TransportSession { ...@@ -188,12 +188,10 @@ public class YahooSession extends TransportSession {
} }
/** /**
* Adds a contact to the user's Yahoo contact list. * @see org.jivesoftware.wildfire.gateway.TransportSession#addContact(org.xmpp.packet.JID)
*
* @param jid JID of contact to be added.
*/ */
public void addContact(JID jid) { public void addContact(JID jid) {
// TODO: check jabber group and use it // @todo check jabber group and use it
try { try {
yahooSession.addFriend(jid.getNode(), "Yahoo Transport"); yahooSession.addFriend(jid.getNode(), "Yahoo Transport");
} }
...@@ -203,12 +201,10 @@ public class YahooSession extends TransportSession { ...@@ -203,12 +201,10 @@ public class YahooSession extends TransportSession {
} }
/** /**
* Removes a contact from the user's Yahoo contact list. * @see org.jivesoftware.wildfire.gateway.TransportSession#removeContact(org.xmpp.packet.JID)
*
* @param jid JID of contact to be added.
*/ */
public void removeContact(JID jid) { public void removeContact(JID jid) {
// TODO: check jabber group and use it // @todo check jabber group and use it
try { try {
yahooSession.removeFriend(jid.getNode(), "Yahoo Transport"); yahooSession.removeFriend(jid.getNode(), "Yahoo Transport");
} }
...@@ -218,10 +214,7 @@ public class YahooSession extends TransportSession { ...@@ -218,10 +214,7 @@ public class YahooSession extends TransportSession {
} }
/** /**
* Sends a message from the jabber user to a Yahoo contact. * @see org.jivesoftware.wildfire.gateway.TransportSession#sendMessage(org.xmpp.packet.JID, String)
*
* @param jid JID of contact to send message to.
* @param message Message to send to yahoo contact.
*/ */
public void sendMessage(JID jid, String message) { public void sendMessage(JID jid, String message) {
try { try {
...@@ -233,7 +226,7 @@ public class YahooSession extends TransportSession { ...@@ -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) { public void updateStatus(PresenceType presenceType, String verboseStatus) {
try { try {
...@@ -247,9 +240,7 @@ public class YahooSession extends TransportSession { ...@@ -247,9 +240,7 @@ public class YahooSession extends TransportSession {
} }
/** /**
* Asks for transport to send information about a contact if possible. * @see org.jivesoftware.wildfire.gateway.TransportSession#retrieveContactStatus(org.xmpp.packet.JID)
*
* @param jid JID of contact to be probed.
*/ */
public void retrieveContactStatus(JID jid) { public void retrieveContactStatus(JID jid) {
YahooUser user = yahooSession.getUser(jid.getNode()); YahooUser user = yahooSession.getUser(jid.getNode());
...@@ -266,4 +257,24 @@ public class YahooSession extends TransportSession { ...@@ -266,4 +257,24 @@ public class YahooSession extends TransportSession {
getTransport().sendPacket(p); 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