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());
Presence p = new Presence();
p.setFrom(getSession().getTransport().getJID());
p.setTo(getSession().getJID());
getSession().getTransport().sendPacket(p);
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");
Presence p = new Presence(Presence.Type.unavailable);
p.setTo(getSession().getJID());
p.setFrom(getSession().getTransport().getJID());
getSession().getTransport().sendPacket(p);
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);
Presence p = new Presence(Presence.Type.unavailable);
p.setTo(getSession().getJID());
p.setFrom(getSession().getTransport().getJID());
getSession().getTransport().sendPacket(p);
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,18 +166,22 @@ public class IRCSession extends TransportSession {
String awayMsg = ((IRCTransport)getTransport()).convertJabStatusToIRC(presenceType, verboseStatus);
if (awayMsg == null) {
conn.doAway();
Presence p = new Presence();
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
if (getTransport().getLegacyMode()) {
Presence p = new Presence();
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
}
}
else {
conn.doAway(awayMsg);
Presence p = new Presence();
p.setShow(Presence.Show.away);
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
if (getTransport().getLegacyMode()) {
Presence p = new Presence();
p.setShow(Presence.Show.away);
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
}
}
}
......
......@@ -169,11 +169,13 @@ public class MSNListener extends MsnAdapter {
* Owner status has changed.
*/
public void ownerStatusChanged(MsnMessenger messenger) {
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);
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);
}
}
/**
......
......@@ -102,10 +102,12 @@ public class MSNSession extends TransportSession {
setLoginStatus(TransportLoginStatus.LOGGING_OUT);
msnMessenger.logout();
}
Presence p = new Presence(Presence.Type.unavailable);
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
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();
Presence p = new Presence();
p.setTo(oscarSession.getJID());
p.setFrom(oscarSession.getTransport().getJID());
oscarSession.getTransport().sendPacket(p);
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.
}
}
Presence p = new Presence(Presence.Type.unavailable);
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
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,18 +473,22 @@ public class OSCARSession extends TransportSession {
awayMsg = verboseStatus;
}
request(new SetInfoCmd(new InfoData(awayMsg, null, MY_CAPS, null)));
Presence p = new Presence();
p.setShow(Presence.Show.away);
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
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)));
Presence p = new Presence();
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
if (getTransport().getLegacyMode()) {
Presence p = new Presence();
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
}
}
this.presenceType = presenceType;
......
......@@ -104,10 +104,12 @@ public class YahooSession extends TransportSession {
yahooSession.login(registration.getUsername(), registration.getPassword());
setLoginStatus(TransportLoginStatus.LOGGED_IN);
Presence p = new Presence();
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
if (getTransport().getLegacyMode()) {
Presence p = new Presence();
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
}
yahooSession.setStatus(((YahooTransport)getTransport()).convertJabStatusToYahoo(pType));
......@@ -156,10 +158,12 @@ public class YahooSession extends TransportSession {
Log.debug("Failed to log out from Yahoo.");
}
yahooSession.reset();
Presence p = new Presence(Presence.Type.unavailable);
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
if (getTransport().getLegacyMode()) {
Presence p = new Presence(Presence.Type.unavailable);
p.setTo(getJID());
p.setFrom(getTransport().getJID());
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