Commit 9adb3f21 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

More work on multiple resources.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@4829 b35dd754-fafc-0310-a699-88a17e54d16e
parent f9ff26eb
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
package org.jivesoftware.wildfire.gateway; package org.jivesoftware.wildfire.gateway;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.jivesoftware.util.Log;
import java.util.TreeMap; import java.util.TreeMap;
/** /**
...@@ -101,7 +103,7 @@ public abstract class TransportSession implements Runnable { ...@@ -101,7 +103,7 @@ public abstract class TransportSession implements Runnable {
* Handles monitoring of whether session is still valid. * Handles monitoring of whether session is still valid.
*/ */
public void run() { public void run() {
while (validSession) { } while (validSession) { Log.debug("This is the loop running. Just want to catch it doing so."); }
} }
/** /**
......
...@@ -50,7 +50,7 @@ public class MSNListener extends MessengerClientAdapter { ...@@ -50,7 +50,7 @@ public class MSNListener extends MessengerClientAdapter {
public void incomingMessage(IncomingMessageEvent event) { public void incomingMessage(IncomingMessageEvent event) {
Message m = new Message(); Message m = new Message();
m.setType(Message.Type.chat); m.setType(Message.Type.chat);
m.setTo(msnSession.getJID()); m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().convertIDToJID(event.getUserName())); m.setFrom(msnSession.getTransport().convertIDToJID(event.getUserName()));
m.setBody(event.getMessage()); m.setBody(event.getMessage());
msnSession.getTransport().sendPacket(m); msnSession.getTransport().sendPacket(m);
......
...@@ -33,6 +33,7 @@ import net.kano.joscar.snaccmd.icbm.*; ...@@ -33,6 +33,7 @@ import net.kano.joscar.snaccmd.icbm.*;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.xmpp.packet.Message; import org.xmpp.packet.Message;
import org.xmpp.packet.Presence; import org.xmpp.packet.Presence;
import org.xmpp.packet.JID;
public abstract class BasicFlapConnection extends BaseFlapConnection { public abstract class BasicFlapConnection extends BaseFlapConnection {
protected final ByteBlock cookie; protected final ByteBlock cookie;
...@@ -140,14 +141,12 @@ public abstract class BasicFlapConnection extends BaseFlapConnection { ...@@ -140,14 +141,12 @@ public abstract class BasicFlapConnection extends BaseFlapConnection {
String msg = OscarTools.stripHtml(message.getMessage()); String msg = OscarTools.stripHtml(message.getMessage());
Message jmessage = new Message(); Message jmessage = new Message();
jmessage.setTo(oscarSession.getRegistration().getJID()); jmessage.setTo(oscarSession.getJIDWithHighestPriority());
jmessage.setBody(msg); jmessage.setBody(msg);
jmessage.setType(Message.Type.chat); jmessage.setType(Message.Type.chat);
jmessage.setFrom(this.oscarSession.getTransport().convertIDToJID(sn)); jmessage.setFrom(this.oscarSession.getTransport().convertIDToJID(sn));
oscarSession.getTransport().sendPacket(jmessage); oscarSession.getTransport().sendPacket(jmessage);
//sendRequest(new SnacRequest(new SendImIcbm(sn, msg), null));
String str = dateFormat.format(new Date()) + " IM from " String str = dateFormat.format(new Date()) + " IM from "
+ sn + ": " + msg; + sn + ": " + msg;
Log.debug(str); Log.debug(str);
...@@ -351,4 +350,51 @@ public abstract class BasicFlapConnection extends BaseFlapConnection { ...@@ -351,4 +350,51 @@ public abstract class BasicFlapConnection extends BaseFlapConnection {
} }
} }
/**
* Retrieves and sends last known status for all buddies.
*
* This retrieves all known statuses and sends each one of them to the specified JID.
* This is typically used when a new resource comes online.
*
* @param jid JID (with resource) to send the list to.
*/
public void getAndSendAllStatuses(JID jid) {
for (FullUserInfo info : buddystore.values()) {
buddystore.put(info.getScreenname(), info);
Presence p = new Presence();
p.setTo(oscarSession.getJID());
p.setFrom(oscarSession.getTransport().convertIDToJID(info.getScreenname()));
if (info.getAwayStatus()) {
p.setShow(Presence.Show.away);
}
ExtraInfoBlock[] extraInfo = info.getExtraInfoBlocks();
if (extraInfo != null) {
for (ExtraInfoBlock i : extraInfo) {
ExtraInfoData data = i.getExtraData();
if (i.getType() == ExtraInfoBlock.TYPE_AVAILMSG) {
ByteBlock msgBlock = data.getData();
int len = BinaryTools.getUShort(msgBlock, 0);
byte[] msgBytes = msgBlock.subBlock(2, len).toByteArray(
);
String msg;
try {
msg = new String(msgBytes, "UTF-8");
}
catch (UnsupportedEncodingException e1) {
continue;
}
if (msg.length() > 0) {
p.setStatus(msg);
}
}
}
}
oscarSession.getTransport().sendPacket(p);
}
}
} }
...@@ -311,7 +311,7 @@ public class OSCARSession extends TransportSession { ...@@ -311,7 +311,7 @@ public class OSCARSession extends TransportSession {
* @see org.jivesoftware.wildfire.gateway.TransportSession#resendContactStatuses(org.xmpp.packet.JID) * @see org.jivesoftware.wildfire.gateway.TransportSession#resendContactStatuses(org.xmpp.packet.JID)
*/ */
public void resendContactStatuses(JID jid) { public void resendContactStatuses(JID jid) {
// @todo need to implement this bosConn.getAndSendAllStatuses(jid);
} }
} }
...@@ -129,6 +129,9 @@ public class YahooSession extends TransportSession { ...@@ -129,6 +129,9 @@ public class YahooSession extends TransportSession {
* Log out of Yahoo. * Log out of Yahoo.
*/ */
public void logOut() { public void logOut() {
loggedIn = false;
loggingIn = false;
loginAttempts = 0;
try { try {
yahooSession.logout(); yahooSession.logout();
} }
...@@ -136,9 +139,6 @@ public class YahooSession extends TransportSession { ...@@ -136,9 +139,6 @@ 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();
loggedIn = false;
loggingIn = false;
loginAttempts = 0;
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());
......
...@@ -61,12 +61,36 @@ public class YahooSessionListener implements SessionListener { ...@@ -61,12 +61,36 @@ public class YahooSessionListener implements SessionListener {
public void messageReceived(SessionEvent event) { public void messageReceived(SessionEvent event) {
Message m = new Message(); Message m = new Message();
m.setType(Message.Type.chat); m.setType(Message.Type.chat);
m.setTo(yahooSession.getJID()); m.setTo(yahooSession.getJIDWithHighestPriority());
m.setFrom(yahooSession.getTransport().convertIDToJID(event.getFrom())); m.setFrom(yahooSession.getTransport().convertIDToJID(event.getFrom()));
m.setBody(messageDecoder.decodeToText(event.getMessage())); m.setBody(messageDecoder.decodeToText(event.getMessage()));
yahooSession.getTransport().sendPacket(m); yahooSession.getTransport().sendPacket(m);
} }
/**
* @see ymsg.network.event.SessionListener#offlineMessageReceived(ymsg.network.event.SessionEvent)
*/
public void offlineMessageReceived(SessionEvent event) {
Message m = new Message();
m.setType(Message.Type.chat);
m.setTo(yahooSession.getJIDWithHighestPriority());
m.setFrom(yahooSession.getTransport().convertIDToJID(event.getFrom()));
m.setBody(messageDecoder.decodeToText(event.getMessage()));
yahooSession.getTransport().sendPacket(m);
}
/**
* @see ymsg.network.event.SessionListener#newMailReceived(ymsg.network.event.SessionNewMailEvent)
*/
public void newMailReceived(SessionNewMailEvent event) {
Message m = new Message();
m.setType(Message.Type.headline);
m.setTo(yahooSession.getJIDWithHighestPriority());
m.setFrom(yahooSession.getTransport().getJID());
m.setBody(messageDecoder.decodeToText(event.getMessage()));
yahooSession.getTransport().sendPacket(m);
}
/** /**
* @see ymsg.network.event.SessionListener#friendsUpdateReceived(ymsg.network.event.SessionFriendEvent) * @see ymsg.network.event.SessionListener#friendsUpdateReceived(ymsg.network.event.SessionFriendEvent)
*/ */
...@@ -107,19 +131,23 @@ public class YahooSessionListener implements SessionListener { ...@@ -107,19 +131,23 @@ public class YahooSessionListener implements SessionListener {
} }
/** /**
* @see ymsg.network.event.SessionListener#fileTransferReceived(ymsg.network.event.SessionFileTransferEvent) * @see ymsg.network.event.SessionListener#connectionClosed(ymsg.network.event.SessionEvent)
*/ */
public void fileTransferReceived(SessionFileTransferEvent event) { public void connectionClosed(SessionEvent event) {
Log.info(event.toString()); Log.error(event.toString());
if (yahooSession.isLoggedIn()) {
yahooSession.logOut();
}
} }
/** /**
* @see ymsg.network.event.SessionListener#connectionClosed(ymsg.network.event.SessionEvent) * @see ymsg.network.event.SessionListener#fileTransferReceived(ymsg.network.event.SessionFileTransferEvent)
*/ */
public void connectionClosed(SessionEvent event) { public void fileTransferReceived(SessionFileTransferEvent event) {
Log.info(event.toString()); Log.info(event.toString());
} }
/** /**
* @see ymsg.network.event.SessionListener#listReceived(ymsg.network.event.SessionEvent) * @see ymsg.network.event.SessionListener#listReceived(ymsg.network.event.SessionEvent)
*/ */
...@@ -134,13 +162,6 @@ public class YahooSessionListener implements SessionListener { ...@@ -134,13 +162,6 @@ public class YahooSessionListener implements SessionListener {
Log.debug(event.toString()); Log.debug(event.toString());
} }
/**
* @see ymsg.network.event.SessionListener#offlineMessageReceived(ymsg.network.event.SessionEvent)
*/
public void offlineMessageReceived(SessionEvent event) {
Log.debug(event.toString());
}
/** /**
* @see ymsg.network.event.SessionListener#errorPacketReceived(ymsg.network.event.SessionErrorEvent) * @see ymsg.network.event.SessionListener#errorPacketReceived(ymsg.network.event.SessionErrorEvent)
*/ */
...@@ -156,13 +177,6 @@ public class YahooSessionListener implements SessionListener { ...@@ -156,13 +177,6 @@ public class YahooSessionListener implements SessionListener {
Log.error(event.toString()); Log.error(event.toString());
} }
/**
* @see ymsg.network.event.SessionListener#newMailReceived(ymsg.network.event.SessionNewMailEvent)
*/
public void newMailReceived(SessionNewMailEvent event) {
Log.debug(event.toString());
}
/** /**
* @see ymsg.network.event.SessionListener#notifyReceived(ymsg.network.event.SessionNotifyEvent) * @see ymsg.network.event.SessionListener#notifyReceived(ymsg.network.event.SessionNotifyEvent)
*/ */
......
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