Search in sources :

Example 1 with YahooUser

use of org.openymsg.network.YahooUser in project Openfire by igniterealtime.

the class YahooSession method syncUsers.

/**
     * Syncs up the yahoo roster with the jabber roster.
     */
public void syncUsers() {
    // Run through the entire list of users and set up our sync group.
    for (Object userObj : yahooSession.getRoster().toArray()) {
        YahooUser user = (YahooUser) userObj;
        PseudoRosterItem rosterItem = pseudoRoster.getItem(user.getId());
        String nickname = null;
        if (rosterItem != null) {
            nickname = rosterItem.getNickname();
        }
        if (nickname == null) {
            nickname = user.getId();
        }
        getBuddyManager().storeBuddy(new YahooBuddy(this.getBuddyManager(), user, nickname, user.getGroupIds(), rosterItem));
    }
    // Lets try the actual sync.
    try {
        getTransport().syncLegacyRoster(getJID(), getBuddyManager().getBuddies());
    } catch (UserNotFoundException e) {
        Log.debug("Unable to sync yahoo contact list for " + getJID());
    }
    getBuddyManager().activate();
}
Also used : UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) YahooUser(org.openymsg.network.YahooUser) PseudoRosterItem(net.sf.kraken.pseudoroster.PseudoRosterItem)

Example 2 with YahooUser

use of org.openymsg.network.YahooUser in project Openfire by igniterealtime.

the class YahooSession method addContact.

/**
     * @see net.sf.kraken.session.TransportSession#addContact(org.xmpp.packet.JID, String, java.util.ArrayList)
     */
@Override
public void addContact(JID jid, String nickname, ArrayList<String> groups) {
    // OpenYMSG requires a user to be in at least one group.
    if (groups == null) {
        groups = new ArrayList<String>();
    }
    if (groups.isEmpty()) {
        // add the default Yahoo group
        groups.add(DEFAULT_GROUPNAME);
    }
    // Syncing will take care of add.
    String contact = getTransport().convertJIDToID(jid);
    PseudoRosterItem rosterItem;
    if (pseudoRoster.hasItem(contact)) {
        rosterItem = pseudoRoster.getItem(contact);
        rosterItem.setNickname(nickname);
    } else {
        rosterItem = pseudoRoster.createItem(contact, nickname, groups);
    }
    YahooUser yUser = new YahooUser(contact);
    for (String grp : groups) {
        yUser.addGroupId(grp);
    }
    yahooSession.getRoster().add(yUser);
    YahooBuddy yBuddy = new YahooBuddy(getBuddyManager(), yUser, nickname, groups, rosterItem);
    getBuddyManager().storeBuddy(yBuddy);
}
Also used : YahooUser(org.openymsg.network.YahooUser) PseudoRosterItem(net.sf.kraken.pseudoroster.PseudoRosterItem)

Aggregations

PseudoRosterItem (net.sf.kraken.pseudoroster.PseudoRosterItem)2 YahooUser (org.openymsg.network.YahooUser)2 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)1