use of org.eclipse.ecf.presence.roster.IRosterGroup in project ecf by eclipse.
the class XMPPContainerPresenceHelper method updatePresence.
private void updatePresence(XMPPID fromID, IPresence newPresence) {
final Collection rosterItems = roster.getItems();
List newEntrys = new ArrayList();
synchronized (rosterItems) {
for (final Iterator i = roster.getItems().iterator(); i.hasNext(); ) {
final IRosterItem item = (IRosterItem) i.next();
if (item instanceof IRosterGroup) {
AdditionalClientRosterEntry[] es = updatePresenceInGroup((IRosterGroup) item, fromID, newPresence);
for (int j = 0; j < es.length; j++) {
newEntrys.add(es[j]);
}
} else if (item instanceof org.eclipse.ecf.presence.roster.RosterEntry) {
AdditionalClientRosterEntry entry = updatePresenceForMatchingEntry((org.eclipse.ecf.presence.roster.RosterEntry) item, fromID, newPresence);
if (entry != null)
newEntrys.add(entry);
}
}
}
AdditionalClientRosterEntry[] entrys = (AdditionalClientRosterEntry[]) newEntrys.toArray(new AdditionalClientRosterEntry[] {});
if (entrys.length > 0) {
for (int i = 0; i < entrys.length; i++) {
if (entrys[i].add) {
IRosterEntry entry = new org.eclipse.ecf.presence.roster.RosterEntry(entrys[i].parent, entrys[i].user, entrys[i].presence);
addUniqueToRoster(new IRosterItem[] { entry });
fireSetRosterEntry(false, entry);
} else {
removeItemFromRoster(rosterItems, fromID);
}
}
}
}
use of org.eclipse.ecf.presence.roster.IRosterGroup in project ecf by eclipse.
the class RosterWriterHelper method showRosterItems.
private void showRosterItems(IRosterItem rosterItem) {
if (rosterItem == null)
return;
Collection children = null;
if (rosterItem instanceof IRoster) {
System.out.println("Roster: " + rosterItem.getName());
children = ((IRoster) rosterItem).getItems();
} else if (rosterItem instanceof IRosterGroup) {
System.out.println(" Group: " + rosterItem.getName());
children = ((IRosterGroup) rosterItem).getEntries();
} else if (rosterItem instanceof IRosterEntry) {
System.out.println(" Entry: " + rosterItem.getName());
System.out.println(" Type: " + ((IRosterEntry) rosterItem).getPresence().getType());
children = null;
}
if (children != null) {
for (Iterator i = children.iterator(); i.hasNext(); ) showRosterItems((IRosterItem) i.next());
}
}
use of org.eclipse.ecf.presence.roster.IRosterGroup 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