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