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

[GATE-55] Little bit more work on this while I was thinking about it.

[GATE-99] Handling caught oscar errors better.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5927 b35dd754-fafc-0310-a699-88a17e54d16e
parent acf39069
......@@ -77,11 +77,20 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
/**
* Sets legacy roster mode for the transport.
* @param mode new legacy mode status
*/
public void setLegacyMode(boolean mode) {
this.legacyMode = mode;
}
/**
* Retrieves the current legacy roster mode for the transport.
* @return legacy mode status setting
*/
public boolean getLegacyMode() {
return this.legacyMode;
}
/**
* Manages all active sessions.
* @see org.jivesoftware.wildfire.gateway.TransportSessionManager
......
......@@ -71,10 +71,12 @@ public class IRCListener implements IRCEventListener {
public void onRegistered() {
Log.debug("IRC registered");
getSession().getRegistration().setLastLogin(new Date());
if (getSession().getTransport().getLegacyMode()) {
Presence p = new Presence();
p.setFrom(getSession().getTransport().getJID());
p.setTo(getSession().getJID());
getSession().getTransport().sendPacket(p);
}
statusCheck = new StatusCheck();
timer.schedule(statusCheck, timerInterval, timerInterval);
getSession().setLoginStatus(TransportLoginStatus.LOGGED_IN);
......@@ -82,10 +84,12 @@ public class IRCListener implements IRCEventListener {
public void onDisconnected() {
Log.debug("IRC disconnected");
if (getSession().getTransport().getLegacyMode()) {
Presence p = new Presence(Presence.Type.unavailable);
p.setTo(getSession().getJID());
p.setFrom(getSession().getTransport().getJID());
getSession().getTransport().sendPacket(p);
}
getSession().getConnection().close();
timer.cancel();
getSession().setLoginStatus(TransportLoginStatus.LOGGED_OUT);
......@@ -184,10 +188,12 @@ public class IRCListener implements IRCEventListener {
public void onQuit(IRCUser ircUser, String string) {
Log.debug("IRC quit: "+ircUser+", "+string);
if (getSession().getTransport().getLegacyMode()) {
Presence p = new Presence(Presence.Type.unavailable);
p.setTo(getSession().getJID());
p.setFrom(getSession().getTransport().getJID());
getSession().getTransport().sendPacket(p);
}
getSession().getConnection().close();
getSession().setLoginStatus(TransportLoginStatus.LOGGED_OUT);
}
......
......@@ -166,13 +166,16 @@ public class IRCSession extends TransportSession {
String awayMsg = ((IRCTransport)getTransport()).convertJabStatusToIRC(presenceType, verboseStatus);
if (awayMsg == null) {
conn.doAway();
if (getTransport().getLegacyMode()) {
Presence p = new Presence();
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
}
}
else {
conn.doAway(awayMsg);
if (getTransport().getLegacyMode()) {
Presence p = new Presence();
p.setShow(Presence.Show.away);
p.setTo(getJID());
......@@ -180,6 +183,7 @@ public class IRCSession extends TransportSession {
getTransport().sendPacket(p);
}
}
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#addContact(org.jivesoftware.wildfire.roster.RosterItem)
......
......@@ -169,12 +169,14 @@ public class MSNListener extends MsnAdapter {
* Owner status has changed.
*/
public void ownerStatusChanged(MsnMessenger messenger) {
if (msnSession.getTransport().getLegacyMode()) {
Presence p = new Presence();
p.setTo(msnSession.getJID());
p.setFrom(msnSession.getTransport().getJID());
((MSNTransport)msnSession.getTransport()).setUpPresencePacket(p, messenger.getOwner().getStatus());
msnSession.getTransport().sendPacket(p);
}
}
/**
* Catches MSN exceptions.
......
......@@ -102,10 +102,12 @@ public class MSNSession extends TransportSession {
setLoginStatus(TransportLoginStatus.LOGGING_OUT);
msnMessenger.logout();
}
if (getTransport().getLegacyMode()) {
Presence p = new Presence(Presence.Type.unavailable);
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
}
setLoginStatus(TransportLoginStatus.LOGGED_OUT);
}
......
......@@ -123,10 +123,12 @@ public class BOSConnection extends BasicFlapConnection {
request(new ActivateSsiCmd());
clientReady();
if (oscarSession.getTransport().getLegacyMode()) {
Presence p = new Presence();
p.setTo(oscarSession.getJID());
p.setFrom(oscarSession.getTransport().getJID());
oscarSession.getTransport().sendPacket(p);
}
oscarSession.setLoginStatus(TransportLoginStatus.LOGGED_IN);
oscarSession.gotCompleteSSI();
......
......@@ -13,7 +13,9 @@
package org.jivesoftware.wildfire.gateway.protocols.oscar;
import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.gateway.TransportLoginStatus;
import org.xmpp.packet.Message;
import org.xmpp.packet.Presence;
import net.kano.joscar.*;
import net.kano.joscar.flap.*;
......@@ -29,8 +31,6 @@ import net.kano.joscar.snaccmd.auth.*;
* Heavily inspired by joscardemo from the joscar project.
*/
public class LoginConnection extends BaseFlapConnection {
protected boolean loggedin = false;
public LoginConnection(ConnDescriptor cd, OSCARSession mainSession) {
super(cd, mainSession); // Hand off to BaseFlapConnection
}
......@@ -138,9 +138,18 @@ public class LoginConnection extends BaseFlapConnection {
m.setFrom(getMainSession().getTransport().getJID());
m.setBody(errormsg);
getMainSession().getTransport().sendPacket(m);
if (getMainSession().getTransport().getLegacyMode()) {
Presence p = new Presence();
p.setTo(getMainSession().getJID());
p.setFrom(getMainSession().getTransport().getJID());
p.setType(Presence.Type.unavailable);
getMainSession().getTransport().sendPacket(p);
}
getMainSession().setLoginStatus(TransportLoginStatus.LOGGED_OUT);
}
else {
loggedin = true;
getMainSession().setLoginStatus(TransportLoginStatus.LOGGED_IN);
oscarSession.startBosConn(ar.getServer(), ar.getPort(), ar.getCookie());
Log.info("OSCAR connection to " + ar.getServer() + ":"
+ ar.getPort());
......
......@@ -127,10 +127,12 @@ public class OSCARSession extends TransportSession {
// Ignore.
}
}
if (getTransport().getLegacyMode()) {
Presence p = new Presence(Presence.Type.unavailable);
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
}
setLoginStatus(TransportLoginStatus.LOGGED_OUT);
}
}
......@@ -471,19 +473,23 @@ public class OSCARSession extends TransportSession {
awayMsg = verboseStatus;
}
request(new SetInfoCmd(new InfoData(awayMsg, null, MY_CAPS, null)));
if (getTransport().getLegacyMode()) {
Presence p = new Presence();
p.setShow(Presence.Show.away);
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
}
}
else {
request(new SetInfoCmd(new InfoData(InfoData.NOT_AWAY, null, MY_CAPS, null)));
if (getTransport().getLegacyMode()) {
Presence p = new Presence();
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
}
}
this.presenceType = presenceType;
this.verboseStatus = verboseStatus;
......
......@@ -104,10 +104,12 @@ public class YahooSession extends TransportSession {
yahooSession.login(registration.getUsername(), registration.getPassword());
setLoginStatus(TransportLoginStatus.LOGGED_IN);
if (getTransport().getLegacyMode()) {
Presence p = new Presence();
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
}
yahooSession.setStatus(((YahooTransport)getTransport()).convertJabStatusToYahoo(pType));
......@@ -156,11 +158,13 @@ public class YahooSession extends TransportSession {
Log.debug("Failed to log out from Yahoo.");
}
yahooSession.reset();
if (getTransport().getLegacyMode()) {
Presence p = new Presence(Presence.Type.unavailable);
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
}
}
/**
* Syncs up the yahoo roster with the jabber roster.
......
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