Commit 7f03368a authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Working on port to new MSN library. Cross your fingers. Note that current...

Working on port to new MSN library.  Cross your fingers.  Note that current code is not very functional.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5362 b35dd754-fafc-0310-a699-88a17e54d16e
parent 9c11e0d8
......@@ -5,6 +5,7 @@ commons-logging | 1.1
irclib.jar | 1.04
jml.jar | 1.0a2 (patched)
joscar.jar | 0.9.3 (patched)
msnm.jar | 2006-09-13 build
picocontainer.jar | 1.2.0
ymsg_network.jar | 0.61
ymsg_support.jar | 0.6
......@@ -10,21 +10,15 @@
package org.jivesoftware.wildfire.gateway.protocols.msn;
import org.jivesoftware.util.Log;
import org.xmpp.packet.Message;
import org.xmpp.packet.Presence;
import net.sf.jml.event.MsnAdapter;
import net.sf.jml.MsnSwitchboard;
import net.sf.jml.MsnContact;
import net.sf.jml.MsnMessenger;
import net.sf.jml.MsnGroup;
import net.sf.jml.message.MsnInstantMessage;
import net.sf.jml.message.MsnControlMessage;
import net.sf.jml.message.MsnDatacastMessage;
import net.sf.jml.message.MsnUnknownMessage;
import java.util.Date;
import rath.msnm.event.MsnAdapter;
import rath.msnm.SwitchboardSession;
import rath.msnm.msg.MimeMessage;
import rath.msnm.entity.MsnFriend;
/**
* MSN Listener Interface.
*
......@@ -52,153 +46,21 @@ public class MSNListener extends MsnAdapter {
/**
* Handles incoming messages from MSN users.
*/
public void instantMessageReceived(MsnSwitchboard switchboard, MsnInstantMessage message, MsnContact friend) {
Message m = new Message();
m.setType(Message.Type.chat);
m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().convertIDToJID(friend.getEmail().toString()));
m.setBody(message.getContent());
msnSession.getTransport().sendPacket(m);
}
/**
* Handles incoming system messages from MSN.
*/
public void systemMessageReceived(MsnSwitchboard switchboard, MsnInstantMessage message) {
public void instantMessageReceived(SwitchboardSession switchboard, MsnFriend friend, MimeMessage message) {
Message m = new Message();
m.setType(Message.Type.chat);
m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().getJID());
m.setBody(message.getContent());
m.setFrom(msnSession.getTransport().convertIDToJID(friend.getLoginName()));
m.setBody(message.getMessage());
msnSession.getTransport().sendPacket(m);
}
/**
* Handles incoming control messages from MSN.
*/
public void controlMessageReceived(MsnSwitchboard switchboard, MsnControlMessage message, MsnContact friend) {
Log.debug("MSN: Received control msg to " + switchboard + " from " + friend + ": " + message);
}
/**
* Handles incoming datacast messages from MSN.
*/
public void datacastMessageReceived(MsnSwitchboard switchboard, MsnDatacastMessage message, MsnContact friend) {
Log.debug("MSN: Received datacast message to " + switchboard + " from " + friend + ": " + message);
}
/**
* Handles incoming unknown messages from MSN.
*/
public void unknownMessageReceived(MsnSwitchboard switchboard, MsnUnknownMessage message, MsnContact friend) {
Log.debug("MSN: Received unknown message to " + switchboard + " from " + friend + ": " + message);
}
/**
* The user's login has completed and was accepted.
*/
public void loginCompleted(MsnMessenger messenger) {
public void loginComplete(MsnFriend me) {
msnSession.getRegistration().setLastLogin(new Date());
msnSession.setLoginStatus(true);
}
/**
* Contact list initialization has completed.
*/
public void contactListInitCompleted(MsnMessenger messenger) {
}
/**
* Contact list has been synced.
*/
public void contactListSyncCompleted(MsnMessenger messenger) {
for (MsnContact msnContact : messenger.getContactList().getContacts()) {
Log.debug("Got contact "+msnContact);
msnSession.storeFriend(msnContact);
}
for (MsnGroup msnGroup : messenger.getContactList().getGroups()) {
msnSession.storeGroup(msnGroup);
}
msnSession.syncUsers();
}
/**
* A friend for this user has changed status.
*/
public void contactStatusChanged(MsnMessenger messenger, MsnContact friend) {
Presence p = new Presence();
p.setTo(msnSession.getJID());
p.setFrom(msnSession.getTransport().convertIDToJID(friend.getEmail().toString()));
((MSNTransport)msnSession.getTransport()).setUpPresencePacket(p, friend.getStatus());
msnSession.getTransport().sendPacket(p);
msnSession.storeFriend(friend);
}
/**
* 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);
}
/**
* Catches MSN exceptions.
*/
public void exceptionCaught(MsnMessenger messenger, Throwable throwable) {
if (throwable.getClass().getName().equals("net.sf.jml.exception.IncorrectPasswordException")) {
Message m = new Message();
m.setType(Message.Type.error);
m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().getJID());
m.setBody("The password you registered with is incorrect. Please re-register with the correct password.");
msnSession.getTransport().sendPacket(m);
msnSession.logOut();
}
else if (throwable.getClass().getName().equals("net.sf.jml.exception.MsnProtocolException")) {
Message m = new Message();
m.setType(Message.Type.error);
m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().getJID());
m.setBody("MSN error: "+throwable.toString());
msnSession.getTransport().sendPacket(m);
}
else if (throwable.getClass().getName().equals("net.sf.jml.exception.MsgNotSendException")) {
Message m = new Message();
m.setType(Message.Type.error);
m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().getJID());
m.setBody("Unable to send MSN message. Reason: "+throwable.toString());
msnSession.getTransport().sendPacket(m);
}
else if (throwable.getClass().getName().equals("net.sf.jml.exception.UnknownMessageException")) {
Message m = new Message();
m.setType(Message.Type.error);
m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().getJID());
m.setBody("Unknown message from MSN: "+throwable.toString());
msnSession.getTransport().sendPacket(m);
}
else if (throwable.getClass().getName().equals("net.sf.jml.exception.UnsupportedProtocolException")) {
Message m = new Message();
m.setType(Message.Type.error);
m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().getJID());
m.setBody("MSN protocol error: "+throwable.toString());
msnSession.getTransport().sendPacket(m);
}
else {
Message m = new Message();
m.setType(Message.Type.error);
m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().getJID());
m.setBody("Unknown error from MSN: "+throwable.toString());
throwable.printStackTrace();
msnSession.getTransport().sendPacket(m);
}
}
}
......@@ -18,7 +18,7 @@ import org.jivesoftware.wildfire.gateway.Registration;
import org.jivesoftware.wildfire.gateway.TransportSession;
import org.xmpp.packet.JID;
import org.xmpp.packet.Presence;
import net.sf.jml.MsnUserStatus;
import rath.msnm.UserStatus;
/**
* MSN Transport Interface.
......@@ -101,27 +101,27 @@ public class MSNTransport extends BaseTransport {
*
* @param jabStatus Jabber presence type.
*/
public MsnUserStatus convertJabStatusToMSN(PresenceType jabStatus) {
public String convertJabStatusToMSN(PresenceType jabStatus) {
if (jabStatus == PresenceType.available) {
return MsnUserStatus.ONLINE;
return UserStatus.ONLINE;
}
else if (jabStatus == PresenceType.away) {
return MsnUserStatus.AWAY;
return UserStatus.AWAY_FROM_COMPUTER;
}
else if (jabStatus == PresenceType.xa) {
return MsnUserStatus.AWAY;
return UserStatus.AWAY_FROM_COMPUTER;
}
else if (jabStatus == PresenceType.dnd) {
return MsnUserStatus.BUSY;
return UserStatus.BUSY;
}
else if (jabStatus == PresenceType.chat) {
return MsnUserStatus.ONLINE;
return UserStatus.ONLINE;
}
else if (jabStatus == PresenceType.unavailable) {
return MsnUserStatus.OFFLINE;
return UserStatus.OFFLINE;
}
else {
return MsnUserStatus.ONLINE;
return UserStatus.ONLINE;
}
}
......@@ -130,29 +130,29 @@ public class MSNTransport extends BaseTransport {
*
* @param msnStatus MSN ContactStatus constant.
*/
public void setUpPresencePacket(Presence packet, MsnUserStatus msnStatus) {
if (msnStatus.equals(MsnUserStatus.ONLINE)) {
public void setUpPresencePacket(Presence packet, String msnStatus) {
if (msnStatus.equals(UserStatus.ONLINE)) {
// We're good, send as is..
}
else if (msnStatus.equals(MsnUserStatus.AWAY)) {
else if (msnStatus.equals(UserStatus.AWAY_FROM_COMPUTER)) {
packet.setShow(Presence.Show.away);
}
else if (msnStatus.equals(MsnUserStatus.BE_RIGHT_BACK)) {
else if (msnStatus.equals(UserStatus.BE_RIGHT_BACK)) {
packet.setShow(Presence.Show.away);
}
else if (msnStatus.equals(MsnUserStatus.BUSY)) {
else if (msnStatus.equals(UserStatus.BUSY)) {
packet.setShow(Presence.Show.dnd);
}
else if (msnStatus.equals(MsnUserStatus.IDLE)) {
else if (msnStatus.equals(UserStatus.IDLE)) {
packet.setShow(Presence.Show.away);
}
else if (msnStatus.equals(MsnUserStatus.OFFLINE)) {
else if (msnStatus.equals(UserStatus.OFFLINE)) {
packet.setType(Presence.Type.unavailable);
}
else if (msnStatus.equals(MsnUserStatus.ON_THE_PHONE)) {
else if (msnStatus.equals(UserStatus.ON_THE_PHONE)) {
packet.setShow(Presence.Show.dnd);
}
else if (msnStatus.equals(MsnUserStatus.OUT_TO_LUNCH)) {
else if (msnStatus.equals(UserStatus.ON_THE_LUNCH)) {
packet.setShow(Presence.Show.xa);
}
}
......
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