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

Functional is better than just lacking ability to remove buddies......

Functional is better than just lacking ability to remove buddies... backtracking to jml and may reevaluate others later or put more work into jml.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@5377 b35dd754-fafc-0310-a699-88a17e54d16e
parent da912e14
...@@ -10,16 +10,21 @@ ...@@ -10,16 +10,21 @@
package org.jivesoftware.wildfire.gateway.protocols.msn; package org.jivesoftware.wildfire.gateway.protocols.msn;
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 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 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. * MSN Listener Interface.
* *
...@@ -47,25 +52,153 @@ public class MSNListener extends MsnAdapter { ...@@ -47,25 +52,153 @@ public class MSNListener extends MsnAdapter {
/** /**
* Handles incoming messages from MSN users. * Handles incoming messages from MSN users.
*/ */
public void instantMessageReceived(SwitchboardSession switchboard, MsnFriend friend, MimeMessage message) { public void instantMessageReceived(MsnSwitchboard switchboard, MsnInstantMessage message, MsnContact friend) {
Message m = new Message(); Message m = new Message();
m.setType(Message.Type.chat); m.setType(Message.Type.chat);
m.setTo(msnSession.getJIDWithHighestPriority()); m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().convertIDToJID(friend.getLoginName())); m.setFrom(msnSession.getTransport().convertIDToJID(friend.getEmail().toString()));
m.setBody(message.getMessage()); m.setBody(message.getContent());
msnSession.getTransport().sendPacket(m); msnSession.getTransport().sendPacket(m);
} }
/**
* Handles incoming system messages from MSN.
*/
public void systemMessageReceived(MsnSwitchboard switchboard, MsnInstantMessage message) {
Message m = new Message();
m.setType(Message.Type.chat);
m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().getJID());
m.setBody(message.getContent());
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. * The user's login has completed and was accepted.
*/ */
public void loginComplete(MsnFriend me) { public void loginCompleted(MsnMessenger messenger) {
msnSession.getRegistration().setLastLogin(new Date()); msnSession.getRegistration().setLastLogin(new Date());
msnSession.setLoginStatus(true); 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(); 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());
msnSession.getTransport().sendPacket(p); 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);
}
}
} }
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
package org.jivesoftware.wildfire.gateway.protocols.msn; package org.jivesoftware.wildfire.gateway.protocols.msn;
import net.sf.jml.*;
import net.sf.jml.impl.MsnMessengerFactory;
import org.jivesoftware.wildfire.gateway.PresenceType; import org.jivesoftware.wildfire.gateway.PresenceType;
import org.jivesoftware.wildfire.gateway.Registration; import org.jivesoftware.wildfire.gateway.Registration;
import org.jivesoftware.wildfire.gateway.TransportSession; import org.jivesoftware.wildfire.gateway.TransportSession;
...@@ -23,19 +25,10 @@ import org.xmpp.packet.Presence; ...@@ -23,19 +25,10 @@ import org.xmpp.packet.Presence;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.io.IOException;
import java.awt.*;
import rath.msnm.MSNMessenger;
import rath.msnm.SwitchboardSession;
import rath.msnm.msg.MimeMessage;
import rath.msnm.entity.MsnFriend;
import rath.msnm.entity.Group;
import rath.msnm.entity.ServerInfo;
/** /**
* Represents a MSN session. * Represents a MSN session.
* *
* This is the interface with which the base transport functionality will * This is the interface with which the base transport functionality will
* communicate with MSN. * communicate with MSN.
* *
...@@ -54,23 +47,24 @@ public class MSNSession extends TransportSession { ...@@ -54,23 +47,24 @@ public class MSNSession extends TransportSession {
public MSNSession(Registration registration, JID jid, MSNTransport transport, Integer priority) { public MSNSession(Registration registration, JID jid, MSNTransport transport, Integer priority) {
super(registration, jid, transport, priority); super(registration, jid, transport, priority);
msnMessenger = new MSNMessenger(registration.getUsername(), registration.getPassword()); msnMessenger = MsnMessengerFactory.createMsnMessenger(registration.getUsername(), registration.getPassword());
msnMessenger.setSupportedProtocol(new MsnProtocol[] { MsnProtocol.MSNP12 });
} }
/** /**
* MSN session * MSN session
*/ */
private MSNMessenger msnMessenger = null; private MsnMessenger msnMessenger = null;
/** /**
* MSN contacts/friends. * MSN contacts/friends.
*/ */
private ConcurrentHashMap<String,MsnFriend> msnContacts = new ConcurrentHashMap<String,MsnFriend>(); private ConcurrentHashMap<String,MsnContact> msnContacts = new ConcurrentHashMap<String,MsnContact>();
/** /**
* MSN groups. * MSN groups.
*/ */
private ConcurrentHashMap<String, Group> msnGroups = new ConcurrentHashMap<String,Group>(); private ConcurrentHashMap<String,MsnGroup> msnGroups = new ConcurrentHashMap<String,MsnGroup>();
/** /**
* Login status * Login status
...@@ -85,8 +79,10 @@ public class MSNSession extends TransportSession { ...@@ -85,8 +79,10 @@ public class MSNSession extends TransportSession {
*/ */
public void logIn(PresenceType presenceType, String verboseStatus) { public void logIn(PresenceType presenceType, String verboseStatus) {
if (!this.isLoggedIn()) { if (!this.isLoggedIn()) {
msnMessenger.setInitialStatus(((MSNTransport)getTransport()).convertJabStatusToMSN(presenceType)); msnMessenger.getOwner().setInitStatus(((MSNTransport)getTransport()).convertJabStatusToMSN(presenceType));
msnMessenger.addMsnListener(new MSNListener(this)); msnMessenger.setLogIncoming(false);
msnMessenger.setLogOutgoing(false);
msnMessenger.addListener(new MSNListener(this));
msnMessenger.login(); msnMessenger.login();
} }
} }
...@@ -108,7 +104,7 @@ public class MSNSession extends TransportSession { ...@@ -108,7 +104,7 @@ public class MSNSession extends TransportSession {
/** /**
* Retrieves the manager for this session. * Retrieves the manager for this session.
*/ */
public MSNMessenger getManager() { public MsnMessenger getManager() {
return msnMessenger; return msnMessenger;
} }
...@@ -129,15 +125,15 @@ public class MSNSession extends TransportSession { ...@@ -129,15 +125,15 @@ public class MSNSession extends TransportSession {
/** /**
* Records information about a person on the user's contact list. * Records information about a person on the user's contact list.
*/ */
public void storeFriend(MsnFriend msnContact) { public void storeFriend(MsnContact msnContact) {
msnContacts.put(msnContact.getLoginName(), msnContact); msnContacts.put(msnContact.getEmail().toString(), msnContact);
} }
/** /**
* Records information about a group on the user's contact list. * Records information about a group on the user's contact list.
*/ */
public void storeGroup(Group msnGroup) { public void storeGroup(MsnGroup msnGroup) {
msnGroups.put(msnGroup.getName(), msnGroup); msnGroups.put(msnGroup.getGroupName(), msnGroup);
} }
/** /**
...@@ -145,12 +141,15 @@ public class MSNSession extends TransportSession { ...@@ -145,12 +141,15 @@ public class MSNSession extends TransportSession {
*/ */
public void syncUsers() { public void syncUsers() {
List<TransportBuddy> legacyusers = new ArrayList<TransportBuddy>(); List<TransportBuddy> legacyusers = new ArrayList<TransportBuddy>();
for (MsnFriend friend : msnContacts.values()) { for (MsnContact friend : msnContacts.values()) {
ArrayList<String> friendGroups = new ArrayList<String>(); ArrayList<String> friendGroups = new ArrayList<String>();
for (MsnGroup group : friend.getBelongGroups()) {
friendGroups.add(group.getGroupName());
}
if (friendGroups.size() < 1) { if (friendGroups.size() < 1) {
friendGroups.add("MSN Contacts"); friendGroups.add("MSN Contacts");
} }
legacyusers.add(new TransportBuddy(friend.getLoginName(), friend.getFriendlyName(), friendGroups.get(0))); legacyusers.add(new TransportBuddy(friend.getEmail().toString(), friend.getDisplayName(), friendGroups.get(0)));
} }
try { try {
getTransport().syncLegacyRoster(getJID(), legacyusers); getTransport().syncLegacyRoster(getJID(), legacyusers);
...@@ -160,10 +159,10 @@ public class MSNSession extends TransportSession { ...@@ -160,10 +159,10 @@ public class MSNSession extends TransportSession {
} }
// Lets send initial presence statuses // Lets send initial presence statuses
for (MsnFriend friend : msnContacts.values()) { for (MsnContact friend : msnContacts.values()) {
Presence p = new Presence(); Presence p = new Presence();
p.setTo(getJID()); p.setTo(getJID());
p.setFrom(getTransport().convertIDToJID(friend.getLoginName())); p.setFrom(getTransport().convertIDToJID(friend.getEmail().toString()));
((MSNTransport)getTransport()).setUpPresencePacket(p, friend.getStatus()); ((MSNTransport)getTransport()).setUpPresencePacket(p, friend.getStatus());
getTransport().sendPacket(p); getTransport().sendPacket(p);
} }
...@@ -173,42 +172,37 @@ public class MSNSession extends TransportSession { ...@@ -173,42 +172,37 @@ public class MSNSession extends TransportSession {
* @see org.jivesoftware.wildfire.gateway.TransportSession#addContact(org.jivesoftware.wildfire.roster.RosterItem) * @see org.jivesoftware.wildfire.gateway.TransportSession#addContact(org.jivesoftware.wildfire.roster.RosterItem)
*/ */
public void addContact(RosterItem item) { public void addContact(RosterItem item) {
// String contact = getTransport().convertJIDToID(item.getJid()); Email contact = Email.parseStr(getTransport().convertJIDToID(item.getJid()));
// String nickname = getTransport().convertJIDToID(item.getJid()); String nickname = getTransport().convertJIDToID(item.getJid());
// if (item.getNickname() != null && !item.getNickname().equals("")) { if (item.getNickname() != null && !item.getNickname().equals("")) {
// nickname = item.getNickname(); nickname = item.getNickname();
// } }
// try { msnMessenger.addFriend(contact, nickname);
// msnMessenger.addFriend(contact); syncContactGroups(contact, item.getGroups());
// }
// catch (IOException e) {
// Log.error("Error while adding MSN contact.");
// }
// syncContactGroups(contact, item.getGroups());
} }
/** /**
* @see org.jivesoftware.wildfire.gateway.TransportSession#removeContact(org.jivesoftware.wildfire.roster.RosterItem) * @see org.jivesoftware.wildfire.gateway.TransportSession#removeContact(org.jivesoftware.wildfire.roster.RosterItem)
*/ */
public void removeContact(RosterItem item) { public void removeContact(RosterItem item) {
// Email contact = Email.parseStr(getTransport().convertJIDToID(item.getJid())); Email contact = Email.parseStr(getTransport().convertJIDToID(item.getJid()));
// MsnContact msnContact = msnContacts.get(contact.toString()); MsnContact msnContact = msnContacts.get(contact.toString());
// for (MsnGroup msnGroup : msnContact.getBelongGroups()) { for (MsnGroup msnGroup : msnContact.getBelongGroups()) {
// msnMessenger.removeFriend(contact, msnGroup.getGroupId()); msnMessenger.removeFriend(contact, msnGroup.getGroupId());
// } }
} }
/** /**
* @see org.jivesoftware.wildfire.gateway.TransportSession#updateContact(org.jivesoftware.wildfire.roster.RosterItem) * @see org.jivesoftware.wildfire.gateway.TransportSession#updateContact(org.jivesoftware.wildfire.roster.RosterItem)
*/ */
public void updateContact(RosterItem item) { public void updateContact(RosterItem item) {
// Email contact = Email.parseStr(getTransport().convertJIDToID(item.getJid())); Email contact = Email.parseStr(getTransport().convertJIDToID(item.getJid()));
// String nickname = getTransport().convertJIDToID(item.getJid()); String nickname = getTransport().convertJIDToID(item.getJid());
// if (item.getNickname() != null && !item.getNickname().equals("")) { if (item.getNickname() != null && !item.getNickname().equals("")) {
// nickname = item.getNickname(); nickname = item.getNickname();
// } }
// msnMessenger.renameFriend(contact, nickname); msnMessenger.renameFriend(contact, nickname);
// syncContactGroups(contact, item.getGroups()); syncContactGroups(contact, item.getGroups());
} }
/** /**
...@@ -218,62 +212,41 @@ public class MSNSession extends TransportSession { ...@@ -218,62 +212,41 @@ public class MSNSession extends TransportSession {
* @param contact Email address of contact. * @param contact Email address of contact.
* @param groups List of groups contact should be in. * @param groups List of groups contact should be in.
*/ */
// public void syncContactGroups(String contact, List<String> groups) { public void syncContactGroups(Email contact, List<String> groups) {
// if (groups.isEmpty()) { if (groups.isEmpty()) {
// groups.add("Transport Buddies"); groups.add("Transport Buddies");
// } }
// MsnFriend msnContact = msnContacts.get(contact.toString()); MsnContact msnContact = msnContacts.get(contact.toString());
// // Create groups that do not currently exist. // Create groups that do not currently exist.
// for (String group : groups) { for (String group : groups) {
// if (!msnGroups.containsKey(group)) { if (!msnGroups.containsKey(group)) {
// try { msnMessenger.addGroup(group);
// msnMessenger.addGroup(group); }
// } }
// catch (IOException e) { // Lets update our list of groups.
// Log.error("Error while adding MSN group."); for (MsnGroup msnGroup : msnMessenger.getContactList().getGroups()) {
// } storeGroup(msnGroup);
// } }
// } // Make sure contact belongs to groups that we want.
// // Lets update our list of groups. for (String group : groups) {
// for (Group msnGroup : msnMessenger.getContactList().getGroups()) { MsnGroup msnGroup = msnGroups.get(group);
// storeGroup(msnGroup); if (!msnContact.belongGroup(msnGroup)) {
// } msnMessenger.copyFriend(contact, group);
// // Make sure contact belongs to groups that we want. }
// for (String group : groups) { }
// MsnGroup msnGroup = msnGroups.get(group); // Now we will clean up groups that we should no longer belong to.
// if (!msnContact.belongGroup(msnGroup)) { for (MsnGroup msnGroup : msnContact.getBelongGroups()) {
// msnMessenger.copyFriend(contact, group); if (!groups.contains(msnGroup.getGroupName())) {
// } msnMessenger.removeFriend(contact, msnGroup.getGroupId());
// } }
// // Now we will clean up groups that we should no longer belong to. }
// for (MsnGroup msnGroup : msnContact.getBelongGroups()) { }
// if (!groups.contains(msnGroup.getGroupName())) {
// msnMessenger.removeFriend(contact, msnGroup.getGroupId());
// }
// }
// }
/** /**
* @see org.jivesoftware.wildfire.gateway.TransportSession#sendMessage(org.xmpp.packet.JID, String) * @see org.jivesoftware.wildfire.gateway.TransportSession#sendMessage(org.xmpp.packet.JID, String)
*/ */
public void sendMessage(JID jid, String message) { public void sendMessage(JID jid, String message) {
String contact = getTransport().convertJIDToID(jid); msnMessenger.sendText(Email.parseStr(getTransport().convertJIDToID(jid)), message);
SwitchboardSession session = msnMessenger.findSwitchboardSession(contact);
if (session == null) {
Log.debug("New session being created.");
session = new SwitchboardSession(msnMessenger, ServerInfo.getDefaultServerInfo(), contact);
session.
}
try {
MimeMessage mimeMessage = new MimeMessage(message, Color.black);
mimeMessage.setKind(MimeMessage.KIND_MESSAGE);
mimeMessage.setFontName("");
// session.sendInstantMessage(mimeMessage);
msnMessenger.sendMessage(contact, mimeMessage);
}
catch (IOException e) {
Log.error("Failed to send MSN message.");
}
} }
/** /**
...@@ -287,13 +260,13 @@ public class MSNSession extends TransportSession { ...@@ -287,13 +260,13 @@ public class MSNSession extends TransportSession {
* @see org.jivesoftware.wildfire.gateway.TransportSession#retrieveContactStatus(org.xmpp.packet.JID) * @see org.jivesoftware.wildfire.gateway.TransportSession#retrieveContactStatus(org.xmpp.packet.JID)
*/ */
public void retrieveContactStatus(JID jid) { public void retrieveContactStatus(JID jid) {
MsnFriend msnContact = msnContacts.get(getTransport().convertJIDToID(jid)); MsnContact msnContact = msnContacts.get(getTransport().convertJIDToID(jid));
if (msnContact == null) { if (msnContact == null) {
return; return;
} }
Presence p = new Presence(); Presence p = new Presence();
p.setTo(getJID()); p.setTo(getJID());
p.setFrom(getTransport().convertIDToJID(msnContact.getLoginName())); p.setFrom(getTransport().convertIDToJID(msnContact.getEmail().toString()));
((MSNTransport)getTransport()).setUpPresencePacket(p, msnContact.getStatus()); ((MSNTransport)getTransport()).setUpPresencePacket(p, msnContact.getStatus());
getTransport().sendPacket(p); getTransport().sendPacket(p);
} }
...@@ -308,13 +281,13 @@ public class MSNSession extends TransportSession { ...@@ -308,13 +281,13 @@ public class MSNSession extends TransportSession {
} }
catch (IllegalStateException e) { catch (IllegalStateException e) {
// Hrm, not logged in? Lets fix that. // Hrm, not logged in? Lets fix that.
msnMessenger.setInitialStatus(((MSNTransport)getTransport()).convertJabStatusToMSN(presenceType)); msnMessenger.getOwner().setInitStatus(((MSNTransport)getTransport()).convertJabStatusToMSN(presenceType));
msnMessenger.login(); msnMessenger.login();
} }
} }
else { else {
// Hrm, not logged in? Lets fix that. // Hrm, not logged in? Lets fix that.
msnMessenger.setInitialStatus(((MSNTransport)getTransport()).convertJabStatusToMSN(presenceType)); msnMessenger.getOwner().setInitStatus(((MSNTransport)getTransport()).convertJabStatusToMSN(presenceType));
msnMessenger.login(); msnMessenger.login();
} }
} }
...@@ -323,10 +296,10 @@ public class MSNSession extends TransportSession { ...@@ -323,10 +296,10 @@ public class MSNSession 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) {
for (MsnFriend friend : msnContacts.values()) { for (MsnContact friend : msnContacts.values()) {
Presence p = new Presence(); Presence p = new Presence();
p.setTo(getJID()); p.setTo(getJID());
p.setFrom(getTransport().convertIDToJID(friend.getLoginName())); p.setFrom(getTransport().convertIDToJID(friend.getEmail().toString()));
((MSNTransport)getTransport()).setUpPresencePacket(p, friend.getStatus()); ((MSNTransport)getTransport()).setUpPresencePacket(p, friend.getStatus());
getTransport().sendPacket(p); getTransport().sendPacket(p);
} }
......
...@@ -18,7 +18,7 @@ import org.jivesoftware.wildfire.gateway.Registration; ...@@ -18,7 +18,7 @@ import org.jivesoftware.wildfire.gateway.Registration;
import org.jivesoftware.wildfire.gateway.TransportSession; import org.jivesoftware.wildfire.gateway.TransportSession;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.Presence; import org.xmpp.packet.Presence;
import rath.msnm.UserStatus; import net.sf.jml.MsnUserStatus;
/** /**
* MSN Transport Interface. * MSN Transport Interface.
...@@ -101,27 +101,27 @@ public class MSNTransport extends BaseTransport { ...@@ -101,27 +101,27 @@ public class MSNTransport extends BaseTransport {
* *
* @param jabStatus Jabber presence type. * @param jabStatus Jabber presence type.
*/ */
public String convertJabStatusToMSN(PresenceType jabStatus) { public MsnUserStatus convertJabStatusToMSN(PresenceType jabStatus) {
if (jabStatus == PresenceType.available) { if (jabStatus == PresenceType.available) {
return UserStatus.ONLINE; return MsnUserStatus.ONLINE;
} }
else if (jabStatus == PresenceType.away) { else if (jabStatus == PresenceType.away) {
return UserStatus.AWAY_FROM_COMPUTER; return MsnUserStatus.AWAY;
} }
else if (jabStatus == PresenceType.xa) { else if (jabStatus == PresenceType.xa) {
return UserStatus.AWAY_FROM_COMPUTER; return MsnUserStatus.AWAY;
} }
else if (jabStatus == PresenceType.dnd) { else if (jabStatus == PresenceType.dnd) {
return UserStatus.BUSY; return MsnUserStatus.BUSY;
} }
else if (jabStatus == PresenceType.chat) { else if (jabStatus == PresenceType.chat) {
return UserStatus.ONLINE; return MsnUserStatus.ONLINE;
} }
else if (jabStatus == PresenceType.unavailable) { else if (jabStatus == PresenceType.unavailable) {
return UserStatus.OFFLINE; return MsnUserStatus.OFFLINE;
} }
else { else {
return UserStatus.ONLINE; return MsnUserStatus.ONLINE;
} }
} }
...@@ -130,29 +130,29 @@ public class MSNTransport extends BaseTransport { ...@@ -130,29 +130,29 @@ public class MSNTransport extends BaseTransport {
* *
* @param msnStatus MSN ContactStatus constant. * @param msnStatus MSN ContactStatus constant.
*/ */
public void setUpPresencePacket(Presence packet, String msnStatus) { public void setUpPresencePacket(Presence packet, MsnUserStatus msnStatus) {
if (msnStatus.equals(UserStatus.ONLINE)) { if (msnStatus.equals(MsnUserStatus.ONLINE)) {
// We're good, send as is.. // We're good, send as is..
} }
else if (msnStatus.equals(UserStatus.AWAY_FROM_COMPUTER)) { else if (msnStatus.equals(MsnUserStatus.AWAY)) {
packet.setShow(Presence.Show.away); packet.setShow(Presence.Show.away);
} }
else if (msnStatus.equals(UserStatus.BE_RIGHT_BACK)) { else if (msnStatus.equals(MsnUserStatus.BE_RIGHT_BACK)) {
packet.setShow(Presence.Show.away); packet.setShow(Presence.Show.away);
} }
else if (msnStatus.equals(UserStatus.BUSY)) { else if (msnStatus.equals(MsnUserStatus.BUSY)) {
packet.setShow(Presence.Show.dnd); packet.setShow(Presence.Show.dnd);
} }
else if (msnStatus.equals(UserStatus.IDLE)) { else if (msnStatus.equals(MsnUserStatus.IDLE)) {
packet.setShow(Presence.Show.away); packet.setShow(Presence.Show.away);
} }
else if (msnStatus.equals(UserStatus.OFFLINE)) { else if (msnStatus.equals(MsnUserStatus.OFFLINE)) {
packet.setType(Presence.Type.unavailable); packet.setType(Presence.Type.unavailable);
} }
else if (msnStatus.equals(UserStatus.ON_THE_PHONE)) { else if (msnStatus.equals(MsnUserStatus.ON_THE_PHONE)) {
packet.setShow(Presence.Show.dnd); packet.setShow(Presence.Show.dnd);
} }
else if (msnStatus.equals(UserStatus.ON_THE_LUNCH)) { else if (msnStatus.equals(MsnUserStatus.OUT_TO_LUNCH)) {
packet.setShow(Presence.Show.xa); 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