use of org.jivesoftware.util.NotFoundException in project Openfire by igniterealtime.
the class QQListener method processFriendOnline.
/**
* Handles an event when a friend has come online.
*
* @param p Event to be handled.
*/
private void processFriendOnline(_08GetOnlineOpReplyPacket p) {
Log.debug("QQ: Processing friend online notification");
try {
for (FriendOnlineEntry f : p.onlineFriends) {
Log.debug("QQ: Got an online friend");
if (getSession().getBuddyManager().isActivated()) {
try {
QQBuddy qqBuddy = getSession().getBuddyManager().getBuddy(getSession().getTransport().convertIDToJID(String.valueOf(f.status.qqNum)));
qqBuddy.setPresenceAndStatus(((QQTransport) getSession().getTransport()).convertQQStatusToXMPP(f.status.status), null);
} catch (NotFoundException ee) {
// Not in our list.
Log.debug("QQ: Received presense notification for contact we don't care about: " + String.valueOf(f.status.qqNum));
}
} else {
getSession().getBuddyManager().storePendingStatus(getSession().getTransport().convertIDToJID(String.valueOf(f.status.qqNum)), ((QQTransport) getSession().getTransport()).convertQQStatusToXMPP(f.status.status), null);
}
}
// if (!p.finished) {
// qqclient.getUser().user_GetOnline(p.position);
// }
} catch (Exception ex) {
Log.error("Failed to handle friend online event: ", ex);
}
}
use of org.jivesoftware.util.NotFoundException 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());
}
}
use of org.jivesoftware.util.NotFoundException in project Openfire by igniterealtime.
the class MSNSession method acceptAddContact.
/**
* @see net.sf.kraken.session.TransportSession#acceptAddContact(JID)
*/
@Override
public void acceptAddContact(JID jid) {
final String userID = getTransport().convertJIDToID(jid);
Log.debug("MSN: accept-adding " + userID);
// According to a packet dump made with Wireshark, 'accepting' a
// contact-add is done by adding the contact yourself (using an outgoing
// ADL).
final Email email = Email.parseStr(userID);
if (email == null) {
Log.warn("MSN: Unable to accept-add this illegal contact " + userID);
return;
}
final TransportBuddyManager<MSNBuddy> manager = this.getBuddyManager();
final String nickname;
if (manager.hasBuddy(jid)) {
try {
final MSNBuddy buddy = manager.getBuddy(jid);
nickname = buddy.getNickname();
} catch (NotFoundException ex) {
throw new RuntimeException("Buddy does not exist although manager.getBuddy() returns true: " + jid);
}
} else {
nickname = null;
}
msnMessenger.addFriend(email, nickname);
}
use of org.jivesoftware.util.NotFoundException in project Openfire by igniterealtime.
the class MySpaceIMListener method contactListUpdateReceived.
public void contactListUpdateReceived() {
Log.debug("MySpaceIM: Got contact list.");
List<Contact> contacts = getSession().getConnection().getContactManager().getContacts();
for (Contact contact : contacts) {
MySpaceIMBuddy buddy;
try {
buddy = getSession().getBuddyManager().getBuddy(getSession().getTransport().convertIDToJID(String.valueOf(contact.getContactID())));
} catch (NotFoundException e) {
buddy = new MySpaceIMBuddy(getSession().getBuddyManager(), contact.getContactID());
getSession().getBuddyManager().storeBuddy(buddy);
}
}
try {
getSession().getTransport().syncLegacyRoster(getSession().getJID(), getSession().getBuddyManager().getBuddies());
} catch (UserNotFoundException e) {
Log.debug("Unable to sync MySpaceIM contact list for " + getSession().getJID(), e);
}
getSession().getBuddyManager().activate();
}
use of org.jivesoftware.util.NotFoundException in project Openfire by igniterealtime.
the class OSCARSession method updateRosterNickname.
/**
* Updates roster nickname information about a contact.
*
* @param sn Screenname/UIN of contact
* @param nickname New nickname
*/
public void updateRosterNickname(String sn, String nickname) {
try {
TransportBuddy buddy = getBuddyManager().getBuddy(getTransport().convertIDToJID(sn));
buddy.setNickname(nickname);
try {
getTransport().addOrUpdateRosterItem(getJID(), buddy.getName(), buddy.getNickname(), buddy.getGroups());
} catch (UserNotFoundException e) {
// Can't update something that's not really in our list.
}
} catch (NotFoundException e) {
// Can't update something that's not really in our list.
}
}
Aggregations