Commit 396ff908 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[JM-761] [JM-769] Can now log in, log out, communicate back and forth, and...

[JM-761] [JM-769] Can now log in, log out, communicate back and forth, and register.  Work coming on buddy lists and various other things.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@4528 b35dd754-fafc-0310-a699-88a17e54d16e
parent f43af2f3
......@@ -208,7 +208,7 @@ public abstract class BaseTransport implements Component {
// TODO: This can also represent a status change.
}
catch (NotFoundException e) {
session = this.registrationLoggedIn(registration);
session = this.registrationLoggedIn(registration, from);
//sessionManager.storeSession(registration.getJID(), session);
sessionManager.storeSession(from, session);
}
......@@ -230,6 +230,23 @@ public abstract class BaseTransport implements Component {
Log.debug("Ignoring unavailable presence for inactive seession.");
}
}
else if (packet.getType() == Presence.Type.probe) {
// Client is asking for presence status.
Log.debug("Got probe.");
TransportSession session = null;
try {
session = sessionManager.getSession(from);
if (session.isLoggedIn()) {
Presence p = new Presence();
p.setTo(from);
p.setFrom(to);
this.sendPacket(p);
}
}
catch (NotFoundException e) {
Log.debug("Ignoring probe presence for inactive session.");
}
}
else {
Log.debug("Ignoring this packet.");
// Anything else we will ignore for now.
......@@ -561,7 +578,7 @@ public abstract class BaseTransport implements Component {
* @param registration Registration used for log in.
* @return A session instance for the new login.
*/
public abstract TransportSession registrationLoggedIn(Registration registration);
public abstract TransportSession registrationLoggedIn(Registration registration, JID jid);
/**
* Will handle logging out of the legacy service.
......
......@@ -29,7 +29,8 @@ public abstract class TransportSession {
*
* @param registration Registration this session is associated with.
*/
public TransportSession(Registration registration, BaseTransport transport) {
public TransportSession(Registration registration, JID jid, BaseTransport transport) {
this.jid = jid;
this.registration = registration;
this.transport = transport;
}
......@@ -44,8 +45,15 @@ public abstract class TransportSession {
*/
public BaseTransport transport;
/**
* JID the session is associated with. (includes specific resource)
*/
public JID jid;
/**
* Retrieves the registration information associated with the session.
*
* @return Registration information of the user associated with the session.
*/
public Registration getRegistration() {
return registration;
......@@ -53,11 +61,22 @@ public abstract class TransportSession {
/**
* Retrieves the transport associated wtih the session.
*
* @return Transport associated with the session.
*/
public BaseTransport getTransport() {
return transport;
}
/**
* Retrieves the jid associated with the session.
*
* @return JID of the user associated with this session.
*/
public JID getJID() {
return jid;
}
/**
* Logs in to the legacy service.
*/
......
......@@ -40,7 +40,7 @@ public class TransportSessionManager {
* @return TransportSession instance requested.
*/
public TransportSession getSession(JID jid) throws NotFoundException {
TransportSession session = activeSessions.get(jid.toBareJID());
TransportSession session = activeSessions.get(new JID(jid.toBareJID()));
if (session == null) {
throw new NotFoundException("Could not find session requested.");
}
......
......@@ -44,8 +44,8 @@ public class OSCARSession extends TransportSession {
* @param info The subscription information to use during login.
* @param gateway The gateway that created this session.
*/
public OSCARSession(Registration registration, OSCARTransport transport) {
super(registration, transport);
public OSCARSession(Registration registration, JID jid, OSCARTransport transport) {
super(registration, jid, transport);
}
/**
......
......@@ -13,6 +13,7 @@ package org.jivesoftware.wildfire.gateway.protocols.oscar;
import org.jivesoftware.wildfire.gateway.BaseTransport;
import org.jivesoftware.wildfire.gateway.Registration;
import org.jivesoftware.wildfire.gateway.TransportSession;
import org.xmpp.packet.JID;
/**
* OSCAR Transport Interface.
......@@ -29,8 +30,8 @@ public class OSCARTransport extends BaseTransport {
*
* @param registration Registration information to be used to log in.
*/
public TransportSession registrationLoggedIn(Registration registration) {
TransportSession session = new OSCARSession(registration, this);
public TransportSession registrationLoggedIn(Registration registration, JID jid) {
TransportSession session = new OSCARSession(registration, jid, this);
session.logIn();
return session;
}
......
......@@ -35,8 +35,8 @@ public class YahooSession extends TransportSession {
*
* @param registration Registration informationed used for logging in.
*/
public YahooSession(Registration registration, YahooTransport transport) {
super(registration, transport);
public YahooSession(Registration registration, JID jid, YahooTransport transport) {
super(registration, jid, transport);
yahooSession = new Session();
yahooSession.addSessionListener(new YahooSessionListener(this));
......@@ -76,13 +76,14 @@ public class YahooSession extends TransportSession {
loggedIn = true;
Presence p = new Presence();
p.setTo(registration.getJID());
p.setTo(getJID());
p.setFrom(getTransport().getJID());
Log.debug("Logged in, sending: " + p.toString());
getTransport().sendPacket(p);
}
catch (LoginRefusedException e) {
yahooSession.reset();
Log.warn("Yahoo login failed for " + registration.getJID());
Log.warn("Yahoo login failed for " + getJID());
}
catch (IOException e) {
Log.error("Yahoo login caused IO exception: " + e.toString());
......@@ -108,7 +109,7 @@ public class YahooSession extends TransportSession {
loggingIn = false;
loginAttempts = 0;
Presence p = new Presence(Presence.Type.unavailable);
p.setTo(registration.getJID());
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
}
......
......@@ -53,7 +53,8 @@ public class YahooSessionListener implements SessionListener {
public void messageReceived(SessionEvent event) {
Log.debug(event.toString());
Message m = new Message();
m.setTo(yahooSession.getRegistration().getJID());
m.setType(Message.Type.chat);
m.setTo(yahooSession.getJID());
m.setFrom(yahooSession.getTransport().convertIDToJID(event.getFrom()));
m.setBody(event.getMessage());
yahooSession.getTransport().sendPacket(m);
......
......@@ -14,6 +14,7 @@ import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.gateway.BaseTransport;
import org.jivesoftware.wildfire.gateway.Registration;
import org.jivesoftware.wildfire.gateway.TransportSession;
import org.xmpp.packet.JID;
/**
* Yahoo Transport Interface.
......@@ -30,9 +31,9 @@ public class YahooTransport extends BaseTransport {
*
* @param registration Registration information to be used to log in.
*/
public TransportSession registrationLoggedIn(Registration registration) {
public TransportSession registrationLoggedIn(Registration registration, JID jid) {
Log.debug("Logging in to Yahoo gateway.");
TransportSession session = new YahooSession(registration, this);
TransportSession session = new YahooSession(registration, jid, this);
session.logIn();
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