Search in sources :

Example 1 with LocalUser

use of pl.mn.communicator.LocalUser 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 2 with LocalUser

use of pl.mn.communicator.LocalUser in project Openfire by igniterealtime.

the class GaduGaduSession method removeContact.

/**
     * @see net.sf.kraken.session.TransportSession#removeContact(net.sf.kraken.roster.TransportBuddy)
     */
@Override
public void removeContact(GaduGaduBuddy contact) {
    String ggContact = getTransport().convertJIDToID(contact.getJID());
    pseudoRoster.removeItem(ggContact);
    for (GaduGaduBuddy buddy : getBuddyManager().getBuddies()) {
        if (buddy.getJID().equals(contact.getJID())) {
            LocalUser byeUser = buddy.toLocalUser();
            try {
                iSession.getPresenceService().removeMonitoredUser(new User(byeUser.getUin()));
            } catch (GGException e) {
                Log.debug("GaduGadu: Error while removing user from being monitored during delete:", e);
            }
            break;
        }
    }
}
Also used : GGException(pl.mn.communicator.GGException) User(pl.mn.communicator.User) LocalUser(pl.mn.communicator.LocalUser) LocalUser(pl.mn.communicator.LocalUser)

Example 3 with LocalUser

use of pl.mn.communicator.LocalUser in project Openfire by igniterealtime.

the class GaduGaduBuddy method toLocalUser.

public LocalUser toLocalUser() {
    LocalUser localUser = new LocalUser();
    localUser.setUin(Integer.parseInt(this.getName()));
    localUser.setDisplayName(this.getNickname() != null ? this.getNickname() : this.getName());
    Collection<String> groups = this.getGroups();
    if (groups.size() > 0) {
        localUser.setGroup((String) groups.toArray()[0]);
    }
    localUser.setEmailAddress(this.getGaduEmailAddress());
    localUser.setFirstName(this.getGaduFirstName() != null ? this.getGaduFirstName() : this.getName());
    localUser.setLastName(this.getGaduLastName());
    localUser.setNickName(this.getNickname());
    localUser.setTelephone(this.getGaduTelephone());
    return localUser;
}
Also used : LocalUser(pl.mn.communicator.LocalUser)

Example 4 with LocalUser

use of pl.mn.communicator.LocalUser in project Openfire by igniterealtime.

the class GaduGaduSession 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) {
    String contact = getTransport().convertJIDToID(jid);
    if (nickname == null || nickname.length() < 1) {
        nickname = jid.toBareJID();
    }
    LocalUser newUser = new LocalUser();
    newUser.setUin(Integer.parseInt(contact));
    newUser.setDisplayName(nickname);
    if (groups.size() > 0) {
        newUser.setGroup(groups.get(0));
    }
    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 GaduGaduBuddy(getBuddyManager(), newUser, rosterItem));
    try {
        iSession.getPresenceService().addMonitoredUser(new User(newUser.getUin()));
    } catch (GGException e) {
        Log.debug("GaduGadu: Error while setting up user to be monitored during add:", e);
    }
}
Also used : GGException(pl.mn.communicator.GGException) User(pl.mn.communicator.User) LocalUser(pl.mn.communicator.LocalUser) PseudoRosterItem(net.sf.kraken.pseudoroster.PseudoRosterItem) LocalUser(pl.mn.communicator.LocalUser)

Aggregations

LocalUser (pl.mn.communicator.LocalUser)4 GGException (pl.mn.communicator.GGException)3 User (pl.mn.communicator.User)3 PseudoRosterItem (net.sf.kraken.pseudoroster.PseudoRosterItem)2 ArrayList (java.util.ArrayList)1 IUser (pl.mn.communicator.IUser)1