use of net.sf.jml.MsnObject in project Openfire by igniterealtime.
the class MSNListener method contactListInitCompleted.
/**
* Contact list initialization has completed.
*/
public void contactListInitCompleted(MsnMessenger messenger) {
for (MsnGroup msnGroup : messenger.getContactList().getGroups()) {
Log.debug("MSN: Got group " + msnGroup);
getSession().storeGroup(msnGroup);
}
for (MsnContact msnContact : messenger.getContactList().getContacts()) {
Log.debug("MSN: Got contact " + msnContact);
if (msnContact.isInList(MsnList.FL) && msnContact.getEmail() != null) {
final MSNBuddy buddy = new MSNBuddy(getSession().getBuddyManager(), msnContact);
getSession().getBuddyManager().storeBuddy(buddy);
if (JiveGlobals.getBooleanProperty("plugin.gateway.msn.avatars", true)) {
final MsnObject msnAvatar = msnContact.getAvatar();
if (msnAvatar != null && (buddy.getAvatar() == null || !buddy.getAvatar().getLegacyIdentifier().equals(msnAvatar.getSha1c()))) {
try {
messenger.retrieveDisplayPicture(msnAvatar, new DisplayPictureListener() {
public void notifyMsnObjectRetrieval(MsnMessenger messenger, DisplayPictureRetrieveWorker worker, MsnObject msnObject, ResultStatus result, byte[] resultBytes, Object context) {
Log.debug("MSN: Got avatar retrieval result: " + result);
// Check for the value
if (result == ResultStatus.GOOD) {
try {
Log.debug("MSN: Found avatar of length " + resultBytes.length);
Avatar avatar = new Avatar(buddy.getJID(), msnAvatar.getSha1c(), resultBytes);
buddy.setAvatar(avatar);
} catch (IllegalArgumentException e) {
Log.debug("MSN: Got null avatar, ignoring.");
}
}
}
});
} catch (Exception e) {
Log.debug("MSN: Unable to retrieve MSN avatar: ", e);
}
} else if (buddy.getAvatar() != null && msnAvatar == null) {
buddy.setAvatar(null);
}
}
}
}
getSession().syncUsers();
}
use of net.sf.jml.MsnObject in project Openfire by igniterealtime.
the class MSNListener method contactStatusChanged.
/**
* A friend for this user has changed status.
*/
public void contactStatusChanged(MsnMessenger messenger, MsnContact friend) {
if (!friend.isInList(MsnList.FL) || friend.getEmail() == null) {
// Not in our buddy list, don't care, or null email address. We need that.
return;
}
if (getSession().getBuddyManager().isActivated()) {
try {
final MSNBuddy buddy = getSession().getBuddyManager().getBuddy(getSession().getTransport().convertIDToJID(friend.getEmail().toString()));
buddy.setPresenceAndStatus(((MSNTransport) getSession().getTransport()).convertMSNStatusToXMPP(friend.getStatus()), friend.getPersonalMessage());
buddy.setMsnContact(friend);
if (JiveGlobals.getBooleanProperty("plugin.gateway.msn.avatars", true)) {
final MsnObject msnAvatar = friend.getAvatar();
if (msnAvatar != null && (buddy.getAvatar() == null || !buddy.getAvatar().getLegacyIdentifier().equals(msnAvatar.getSha1c()))) {
try {
messenger.retrieveDisplayPicture(msnAvatar, new DisplayPictureListener() {
public void notifyMsnObjectRetrieval(MsnMessenger messenger, DisplayPictureRetrieveWorker worker, MsnObject msnObject, ResultStatus result, byte[] resultBytes, Object context) {
Log.debug("MSN: Got avatar retrieval result: " + result);
// Check for the value
if (result == ResultStatus.GOOD) {
try {
Log.debug("MSN: Found avatar of length " + resultBytes.length);
Avatar avatar = new Avatar(buddy.getJID(), msnAvatar.getSha1c(), resultBytes);
buddy.setAvatar(avatar);
} catch (IllegalArgumentException e) {
Log.debug("MSN: Got null avatar, ignoring.");
}
}
}
});
} catch (Exception e) {
Log.debug("MSN: Unable to retrieve MSN avatar: ", e);
}
} else if (buddy.getAvatar() != null && msnAvatar == null) {
buddy.setAvatar(null);
}
}
} catch (NotFoundException e) {
// Not in our contact list. Ignore.
Log.debug("MSN: Received presense notification for contact we don't care about: " + friend.getEmail().toString());
}
} else {
getSession().getBuddyManager().storePendingStatus(getSession().getTransport().convertIDToJID(friend.getEmail().toString()), ((MSNTransport) getSession().getTransport()).convertMSNStatusToXMPP(friend.getStatus()), friend.getPersonalMessage());
}
}
Aggregations