Search in sources :

Example 1 with PseudoRosterItem

use of net.sf.kraken.pseudoroster.PseudoRosterItem in project Openfire by igniterealtime.

the class IRCSession method addContact.

@Override
public void addContact(JID jid, String nickname, ArrayList<String> groups) {
    String contact = getTransport().convertJIDToID(jid);
    PseudoRosterItem rosterItem;
    if (pseudoRoster.hasItem(contact)) {
        rosterItem = pseudoRoster.getItem(contact);
        rosterItem.setNickname(nickname);
        rosterItem.setGroups(groups);
    } else {
        rosterItem = pseudoRoster.createItem(contact, nickname, groups);
    }
    getBuddyManager().storeBuddy(new IRCBuddy(getBuddyManager(), contact, rosterItem));
//        connection.sendCommand(new IsonCommand(contact));
}
Also used : PseudoRosterItem(net.sf.kraken.pseudoroster.PseudoRosterItem)

Example 2 with PseudoRosterItem

use of net.sf.kraken.pseudoroster.PseudoRosterItem in project Openfire by igniterealtime.

the class IRCSession method updateContact.

@Override
public void updateContact(IRCBuddy contact) {
    String ircContact = getTransport().convertJIDToID(contact.getJID());
    if (pseudoRoster.hasItem(ircContact)) {
        PseudoRosterItem rosterItem = pseudoRoster.getItem(ircContact);
        rosterItem.setNickname(contact.getNickname());
        rosterItem.setGroups((List<String>) contact.getGroups());
    //            connection.sendCommand(new IsonCommand(ircContact));
    } else {
        PseudoRosterItem rosterItem = pseudoRoster.createItem(ircContact, contact.getNickname(), (List<String>) contact.getGroups());
        getBuddyManager().storeBuddy(new IRCBuddy(getBuddyManager(), ircContact, rosterItem));
    //            connection.sendCommand(new IsonCommand(ircContact));
    }
}
Also used : PseudoRosterItem(net.sf.kraken.pseudoroster.PseudoRosterItem)

Example 3 with PseudoRosterItem

use of net.sf.kraken.pseudoroster.PseudoRosterItem in project Openfire by igniterealtime.

the class SimpleSession 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) {
    Log.debug("SimpleSession(" + jid.getNode() + ").addContact:  Roster of " + jid.toString() + " locked!");
    String destId = getTransport().convertJIDToID(jid);
    PseudoRosterItem rosterItem;
    if (pseudoRoster.hasItem(destId)) {
        rosterItem = pseudoRoster.getItem(destId);
        rosterItem.setNickname(nickname);
    } else {
        rosterItem = pseudoRoster.createItem(destId, nickname, null);
    }
    getBuddyManager().storeBuddy(new SimpleBuddy(getBuddyManager(), destId, rosterItem));
    Log.debug("SimpleSession(" + jid.getNode() + ").addContact:  Starting addContact function for " + destId);
    Request subscribeRequest;
    try {
        subscribeRequest = prepareSubscribeRequest(destId);
        subscribeRequest.addHeader(headerFactory.createExpiresHeader(365 * 24 * 60 * 60));
    } catch (Exception e) {
        Log.debug("SimpleSession(" + jid.getNode() + ").addContact:  Unable to prepare SUBSCRIBE request.", e);
        Log.debug("SimpleSession(" + jid.getNode() + ").addContact:  Roster of " + jid.toString() + " unlocked!");
        return;
    }
    try {
        subscribeRequest.addHeader(headerFactory.createAllowHeader(Request.ACK));
        subscribeRequest.addHeader(headerFactory.createAllowHeader(Request.BYE));
        subscribeRequest.addHeader(headerFactory.createAllowHeader(Request.CANCEL));
        subscribeRequest.addHeader(headerFactory.createAllowHeader(Request.INFO));
        subscribeRequest.addHeader(headerFactory.createAllowHeader(Request.INVITE));
        subscribeRequest.addHeader(headerFactory.createAllowHeader(Request.MESSAGE));
        subscribeRequest.addHeader(headerFactory.createAllowHeader(Request.NOTIFY));
        subscribeRequest.addHeader(headerFactory.createAllowHeader(Request.OPTIONS));
        subscribeRequest.addHeader(headerFactory.createAllowHeader(Request.REFER));
        subscribeRequest.addHeader(headerFactory.createAllowHeader(Request.SUBSCRIBE));
        subscribeRequest.addHeader(headerFactory.createEventHeader("presence"));
        subscribeRequest.addHeader(headerFactory.createAcceptHeader("application", "pidf+xml"));
    } catch (Exception e) {
        Log.debug("SimpleSession(" + jid.getNode() + ").addContact:  Unable to add a header", e);
    }
    try {
        sendRequest(subscribeRequest, ListeningPoint.UDP);
    } catch (Exception e) {
        Log.debug("SimpleSession(" + jid.getNode() + ").addContact:  Unable to send request.", e);
        Log.debug("SimpleSession(" + jid.getNode() + ").addContact:  Roster of " + jid.toString() + " unlocked!");
        return;
    }
    Log.debug("SimpleSession(" + jid.getNode() + ").addContact:  Roster of " + jid.toString() + " unlocked!");
}
Also used : Request(javax.sip.message.Request) PseudoRosterItem(net.sf.kraken.pseudoroster.PseudoRosterItem) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException) NotFoundException(org.jivesoftware.util.NotFoundException) TooManyListenersException(java.util.TooManyListenersException) SipException(javax.sip.SipException) UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException)

Example 4 with PseudoRosterItem

use of net.sf.kraken.pseudoroster.PseudoRosterItem in project Openfire by igniterealtime.

the class GaduGaduListener method contactListReceived.

@SuppressWarnings("unchecked")
public void contactListReceived(Collection collection) {
    Log.debug("GaduGadu: Contact list received: " + collection);
    for (Object localUserObj : collection) {
        LocalUser localUser = (LocalUser) localUserObj;
        if (localUser.getUin() > 0) {
            String ggContact = Integer.toString(localUser.getUin());
            String nickname = localUser.getDisplayName();
            List<String> groups = new ArrayList<String>();
            groups.add(localUser.getGroup());
            if (getSession().getPseudoRoster().hasItem(ggContact)) {
                PseudoRosterItem rosterItem = getSession().getPseudoRoster().getItem(ggContact);
                rosterItem.setNickname(nickname);
                rosterItem.setGroups(groups);
            } else {
                PseudoRosterItem rosterItem = getSession().getPseudoRoster().createItem(ggContact, nickname, groups);
                getSession().getBuddyManager().storeBuddy(new GaduGaduBuddy(getSession().getBuddyManager(), localUser, rosterItem));
            }
            try {
                getSession().iSession.getPresenceService().addMonitoredUser(new User(localUser.getUin()));
            } catch (GGException e) {
                Log.debug("GaduGadu: Error while setting up user to be monitored:", e);
            }
        } else {
            Log.debug("GaduGadu: Ignoring user with UIN less than -1: " + localUser);
        }
    }
}
Also used : GGException(pl.mn.communicator.GGException) LocalUser(pl.mn.communicator.LocalUser) User(pl.mn.communicator.User) IUser(pl.mn.communicator.IUser) ArrayList(java.util.ArrayList) PseudoRosterItem(net.sf.kraken.pseudoroster.PseudoRosterItem) LocalUser(pl.mn.communicator.LocalUser)

Example 5 with PseudoRosterItem

use of net.sf.kraken.pseudoroster.PseudoRosterItem 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)

Aggregations

PseudoRosterItem (net.sf.kraken.pseudoroster.PseudoRosterItem)10 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)4 NotFoundException (org.jivesoftware.util.NotFoundException)3 ArrayList (java.util.ArrayList)2 YahooUser (org.openymsg.network.YahooUser)2 GGException (pl.mn.communicator.GGException)2 LocalUser (pl.mn.communicator.LocalUser)2 User (pl.mn.communicator.User)2 ParseException (java.text.ParseException)1 TooManyListenersException (java.util.TooManyListenersException)1 InvalidArgumentException (javax.sip.InvalidArgumentException)1 SipException (javax.sip.SipException)1 Request (javax.sip.message.Request)1 JID (org.xmpp.packet.JID)1 IUser (pl.mn.communicator.IUser)1