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);
}
}
}
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;
}
}
}
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;
}
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);
}
}
Aggregations