Search in sources :

Example 51 with NotFoundException

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);
    }
}
Also used : UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) NotFoundException(org.jivesoftware.util.NotFoundException) FriendOnlineEntry(net.sf.jqql.beans.FriendOnlineEntry) UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) NotFoundException(org.jivesoftware.util.NotFoundException)

Example 52 with NotFoundException

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());
    }
}
Also used : MsnObject(net.sf.jml.MsnObject) MsnMessenger(net.sf.jml.MsnMessenger) NotFoundException(org.jivesoftware.util.NotFoundException) MsnObject(net.sf.jml.MsnObject) DisplayPictureRetrieveWorker(net.sf.jml.message.p2p.DisplayPictureRetrieveWorker) Avatar(net.sf.kraken.avatars.Avatar) UnknownMessageException(net.sf.jml.exception.UnknownMessageException) MsgNotSendException(net.sf.jml.exception.MsgNotSendException) IncorrectPasswordException(net.sf.jml.exception.IncorrectPasswordException) NotFoundException(org.jivesoftware.util.NotFoundException) UnsupportedProtocolException(net.sf.jml.exception.UnsupportedProtocolException) IOException(java.io.IOException) MsnProtocolException(net.sf.jml.exception.MsnProtocolException) LoginException(net.sf.jml.exception.LoginException) DisplayPictureListener(net.sf.jml.DisplayPictureListener)

Example 53 with NotFoundException

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);
}
Also used : Email(net.sf.jml.Email) NotFoundException(org.jivesoftware.util.NotFoundException) UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException)

Example 54 with NotFoundException

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();
}
Also used : UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) NotFoundException(org.jivesoftware.util.NotFoundException) Contact(net.sf.jmyspaceiml.contact.Contact)

Example 55 with NotFoundException

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.
    }
}
Also used : UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) TransportBuddy(net.sf.kraken.roster.TransportBuddy) NotFoundException(org.jivesoftware.util.NotFoundException) UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException)

Aggregations

NotFoundException (org.jivesoftware.util.NotFoundException)64 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)28 Element (org.dom4j.Element)16 JID (org.xmpp.packet.JID)15 ArrayList (java.util.ArrayList)10 Connection (java.sql.Connection)8 PreparedStatement (java.sql.PreparedStatement)8 SQLException (java.sql.SQLException)8 ResultSet (java.sql.ResultSet)7 TransportSession (net.sf.kraken.session.TransportSession)7 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)6 Avatar (net.sf.kraken.avatars.Avatar)5 TransportBuddy (net.sf.kraken.roster.TransportBuddy)5 Packet (org.xmpp.packet.Packet)5 Date (java.util.Date)4 UserRequest (org.jivesoftware.xmpp.workgroup.request.UserRequest)4 KrakenPlugin (net.sf.kraken.KrakenPlugin)3 Registration (net.sf.kraken.registration.Registration)3 PluginManager (org.jivesoftware.openfire.container.PluginManager)3 GroupNotFoundException (org.jivesoftware.openfire.group.GroupNotFoundException)3