use of net.sf.kraken.pseudoroster.PseudoRosterItem 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);
}
use of net.sf.kraken.pseudoroster.PseudoRosterItem in project Openfire by igniterealtime.
the class YahooSession method updateContact.
/**
* @see net.sf.kraken.session.TransportSession#updateContact(net.sf.kraken.roster.TransportBuddy)
*/
@Override
public void updateContact(YahooBuddy contact) {
// Yahoo requires each user to be in at least one group.
if (contact.getGroups() == null || contact.getGroups().isEmpty()) {
List<String> defaultGroup = new ArrayList<String>();
defaultGroup.add(DEFAULT_GROUPNAME);
contact.setGroups(defaultGroup);
}
String yahooContact = getTransport().convertJIDToID(contact.getJID());
PseudoRosterItem rosterItem;
if (pseudoRoster.hasItem(yahooContact)) {
rosterItem = pseudoRoster.getItem(yahooContact);
rosterItem.setNickname(contact.getNickname());
} else {
rosterItem = pseudoRoster.createItem(yahooContact, contact.getNickname(), null);
}
try {
YahooBuddy yBuddy = getBuddyManager().getBuddy(contact.getJID());
yBuddy.pseudoRosterItem = rosterItem;
for (String newGroup : yBuddy.getGroups()) {
if (!yBuddy.yahooUser.getGroupIds().contains(newGroup)) {
// Add new group to user
yBuddy.yahooUser.addGroupId(newGroup);
}
}
for (String oldGroup : yBuddy.yahooUser.getGroupIds()) {
if (!yBuddy.getGroups().contains(oldGroup)) {
// Remove group from user
// TODO: This needs to be implemented...
//yBuddy.yahooUser.removeGroupId(oldGroup);
}
}
} catch (NotFoundException e) {
Log.debug("Yahoo: Updated buddy not found in buddy manager: " + yahooContact);
}
}
use of net.sf.kraken.pseudoroster.PseudoRosterItem in project Openfire by igniterealtime.
the class SimpleSession method updateContact.
/**
* @see net.sf.kraken.session.TransportSession#updateContact(net.sf.kraken.roster.TransportBuddy)
*/
@Override
public void updateContact(SimpleBuddy contact) {
Log.debug("SimpleSession(" + jid.getNode() + ").updateContact: I was called!");
JID destJid = contact.getJID();
String destId = getTransport().convertJIDToID(destJid);
PseudoRosterItem rosterItem;
if (pseudoRoster.hasItem(destId)) {
rosterItem = pseudoRoster.getItem(destId);
rosterItem.setNickname(contact.getNickname());
} else {
rosterItem = pseudoRoster.createItem(destId, contact.getNickname(), null);
}
try {
SimpleBuddy simpleBuddy = getBuddyManager().getBuddy(destJid);
simpleBuddy.pseudoRosterItem = rosterItem;
} catch (NotFoundException e) {
Log.debug("SIMPLE: Newly added buddy not found in buddy manager: " + destId);
}
}
use of net.sf.kraken.pseudoroster.PseudoRosterItem 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);
}
}
use of net.sf.kraken.pseudoroster.PseudoRosterItem in project Openfire by igniterealtime.
the class GaduGaduSession method updateContact.
/**
* @see net.sf.kraken.session.TransportSession#updateContact(net.sf.kraken.roster.TransportBuddy)
*/
@Override
public void updateContact(GaduGaduBuddy contact) {
String ggContact = getTransport().convertJIDToID(contact.getJID());
if (pseudoRoster.hasItem(ggContact)) {
PseudoRosterItem rosterItem = pseudoRoster.getItem(ggContact);
rosterItem.setNickname(contact.getNickname());
rosterItem.setGroups((List<String>) contact.getGroups());
} else {
PseudoRosterItem rosterItem = pseudoRoster.createItem(ggContact, contact.getNickname(), (List<String>) contact.getGroups());
getBuddyManager().storeBuddy(new GaduGaduBuddy(getBuddyManager(), rosterItem));
}
}
Aggregations