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