use of org.eclipse.ecf.presence.roster.RosterGroup in project ecf by eclipse.
the class XMPPContainerPresenceHelper method createRosterEntries.
private IRosterItem[] createRosterEntries(Iterator grps, IRosterItem parent, IUser user) {
final List result = new ArrayList();
if (grps.hasNext()) {
for (; grps.hasNext(); ) {
final Object o = grps.next();
// Get group name
final String groupName = (o instanceof String) ? (String) o : ((RosterGroup) o).getName();
if (groupName == null || groupName.equals("")) {
createRosterEntries(parent, user, result);
continue;
}
// See if group is already in roster
org.eclipse.ecf.presence.roster.RosterGroup rosterGroup = findRosterGroup(parent, groupName);
// Set flag if not
final boolean groupFound = rosterGroup != null;
if (!groupFound)
rosterGroup = new org.eclipse.ecf.presence.roster.RosterGroup(parent, groupName);
if (findRosterEntry(rosterGroup, user) == null) {
// Now create new roster entry
new org.eclipse.ecf.presence.roster.RosterEntry(rosterGroup, user, new org.eclipse.ecf.presence.Presence(IPresence.Type.UNAVAILABLE, IPresence.Type.UNAVAILABLE.toString(), IPresence.Mode.AWAY));
}
// Only add localGrp if not already in list
if (!groupFound)
result.add(rosterGroup);
}
} else
createRosterEntries(parent, user, result);
return (IRosterItem[]) result.toArray(new IRosterItem[] {});
}
use of org.eclipse.ecf.presence.roster.RosterGroup in project ecf by eclipse.
the class XMPPContainerPresenceHelper method createRosterEntry.
protected IRosterEntry createRosterEntry(ID userID, String name, Iterator grps) {
final List groups = new ArrayList();
for (; grps.hasNext(); ) {
final Object o = grps.next();
final String groupName = (o instanceof String) ? (String) o : ((RosterGroup) o).getName();
final IRosterGroup localGrp = new org.eclipse.ecf.presence.roster.RosterGroup(roster, groupName);
groups.add(localGrp);
}
final IUser user = new User(userID, name);
IRosterEntry newEntry = null;
if (groups.size() == 0)
return new org.eclipse.ecf.presence.roster.RosterEntry(roster, user, new org.eclipse.ecf.presence.Presence(IPresence.Type.UNAVAILABLE, IPresence.Type.UNAVAILABLE.toString(), IPresence.Mode.AWAY));
else
for (int i = 0; i < groups.size(); i++) {
final IRosterGroup grp = (IRosterGroup) groups.get(i);
if (i == 0)
newEntry = new org.eclipse.ecf.presence.roster.RosterEntry(grp, user, null);
else {
grp.getEntries().add(newEntry);
newEntry.getGroups().add(grp);
}
}
return newEntry;
}
Aggregations