Search in sources :

Example 1 with Email

use of net.sf.jml.Email in project Openfire by igniterealtime.

the class MSNSession method completedPendingContactAdd.

/**
     * Completes the addition of groups to a new contact after the contact has been created.
     *
     * @param msnContact Contact that was added.
     */
public void completedPendingContactAdd(MsnContact msnContact) {
    try {
        Roster roster = getTransport().getRosterManager().getRoster(getJID().getNode());
        Email contact = msnContact.getEmail();
        JID contactJID = getTransport().convertIDToJID(contact.toString());
        RosterItem item = roster.getRosterItem(contactJID);
        getBuddyManager().storeBuddy(new MSNBuddy(getBuddyManager(), msnContact));
        syncContactGroups(contact, item.getGroups());
    } catch (UserNotFoundException e) {
        Log.debug("MSN: Unable to find roster when adding pendingcontact for " + getJID());
    }
}
Also used : UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) RosterItem(org.jivesoftware.openfire.roster.RosterItem) Email(net.sf.jml.Email) Roster(org.jivesoftware.openfire.roster.Roster) JID(org.xmpp.packet.JID)

Example 2 with Email

use of net.sf.jml.Email in project Openfire by igniterealtime.

the class MSNSession method updateContact.

/**
     * @see net.sf.kraken.session.TransportSession#updateContact(net.sf.kraken.roster.TransportBuddy)
     */
@Override
public void updateContact(MSNBuddy contact) {
    Email email = Email.parseStr(getTransport().convertJIDToID(contact.getJID()));
    if (email == null) {
        Log.debug("MSN: Unable to update illegal contact " + contact.getJID());
        return;
    }
    String nickname = getTransport().convertJIDToID(contact.getJID());
    if (contact.getNickname() != null && !contact.getNickname().equals("")) {
        nickname = contact.getNickname();
    }
    try {
        MSNBuddy msnBuddy = getBuddyManager().getBuddy(contact.getJID());
        if (msnBuddy.msnContact == null) {
            MsnContact msnContact = msnMessenger.getContactList().getContactByEmail(email);
            if (msnContact == null) {
                Log.debug("MSN: Contact updated but doesn't exist?  Adding.");
                addContact(contact.getJID(), nickname, (ArrayList<String>) contact.getGroups());
                return;
            } else {
                msnBuddy.setMsnContact(msnContact);
            }
        }
        if (!msnBuddy.msnContact.getFriendlyName().equals(nickname)) {
            msnMessenger.renameFriend(email, nickname);
        }
        syncContactGroups(email, (List<String>) contact.getGroups());
    } catch (NotFoundException e) {
        Log.debug("MSN: Newly added buddy not found in buddy manager: " + email.getEmailAddress());
    }
}
Also used : Email(net.sf.jml.Email) NotFoundException(org.jivesoftware.util.NotFoundException) UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) MsnContact(net.sf.jml.MsnContact)

Example 3 with Email

use of net.sf.jml.Email in project Openfire by igniterealtime.

the class MSNSession method completedPendingGroupAdd.

/**
     * Completes the addition of a contact to a new group after the group has been created.
     *
     * @param msnGroup Group that was added.
     */
public void completedPendingGroupAdd(MsnGroup msnGroup) {
    if (!msnPendingGroups.containsKey(msnGroup.getGroupName())) {
        // Nothing to do, no pending.
        return;
    }
    try {
        Roster roster = getTransport().getRosterManager().getRoster(getJID().getNode());
        for (Email contact : msnPendingGroups.get(msnGroup.getGroupName())) {
            JID contactJID = getTransport().convertIDToJID(contact.toString());
            RosterItem item = roster.getRosterItem(contactJID);
            syncContactGroups(contact, item.getGroups());
        }
    } catch (UserNotFoundException e) {
        Log.debug("MSN: Unable to find roster when adding pending group contacts for " + getJID());
    }
}
Also used : UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) RosterItem(org.jivesoftware.openfire.roster.RosterItem) Email(net.sf.jml.Email) Roster(org.jivesoftware.openfire.roster.Roster) JID(org.xmpp.packet.JID)

Example 4 with Email

use of net.sf.jml.Email in project Openfire by igniterealtime.

the class MSNSession method removeContact.

/**
     * @see net.sf.kraken.session.TransportSession#removeContact(net.sf.kraken.roster.TransportBuddy)
     */
@Override
public void removeContact(MSNBuddy contact) {
    Email email = Email.parseStr(getTransport().convertJIDToID(contact.getJID()));
    if (email == null) {
        Log.debug("MSN: Unable to remove illegal contact " + contact.getJID());
        return;
    }
    msnMessenger.removeFriend(email, false);
}
Also used : Email(net.sf.jml.Email)

Example 5 with Email

use of net.sf.jml.Email in project Openfire by igniterealtime.

the class MSNSession method sendBuzzNotification.

/**
     * @see net.sf.kraken.session.TransportSession#sendBuzzNotification(org.xmpp.packet.JID, String)
     */
@Override
public void sendBuzzNotification(JID jid, String message) {
    final MsnDatacastMessage nudge = new MsnDatacastMessage();
    // 1=nudge, 2=wink
    nudge.setId(1);
    final Email jidEmail = Email.parseStr(getTransport().convertJIDToID(jid));
    for (MsnSwitchboard sb : msnMessenger.getActiveSwitchboards()) {
        if (sb.containContact(jidEmail)) {
            sb.sendMessage(nudge, false);
        }
    }
}
Also used : Email(net.sf.jml.Email) MsnSwitchboard(net.sf.jml.MsnSwitchboard) MsnDatacastMessage(net.sf.jml.message.MsnDatacastMessage)

Aggregations

Email (net.sf.jml.Email)8 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)4 MsnSwitchboard (net.sf.jml.MsnSwitchboard)2 Roster (org.jivesoftware.openfire.roster.Roster)2 RosterItem (org.jivesoftware.openfire.roster.RosterItem)2 NotFoundException (org.jivesoftware.util.NotFoundException)2 JID (org.xmpp.packet.JID)2 MsnContact (net.sf.jml.MsnContact)1 MsnControlMessage (net.sf.jml.message.MsnControlMessage)1 MsnDatacastMessage (net.sf.jml.message.MsnDatacastMessage)1