Search in sources :

Example 6 with IRosterItem

use of org.eclipse.ecf.presence.roster.IRosterItem in project ecf by eclipse.

the class BrowseDialog method fillContentProvider.

/* (non-Javadoc)
	 * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#fillContentProvider(org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.AbstractContentProvider, org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter, org.eclipse.core.runtime.IProgressMonitor)
	 */
protected void fillContentProvider(AbstractContentProvider contentProvider, ItemsFilter itemsFilter, IProgressMonitor progressMonitor) {
    progressMonitor.beginTask(Messages.BrowseDialog_scanning, containers.length);
    // cycle through all the containers and grab entries
    for (int i = 0; i < containers.length; i++) {
        IContainer container = containers[i];
        IPresenceContainerAdapter presenceContainer = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
        if (presenceContainer != null) {
            IRosterManager manager = presenceContainer.getRosterManager();
            if (manager != null) {
                Collection items = manager.getRoster().getItems();
                for (Iterator it = items.iterator(); it.hasNext(); ) {
                    IRosterItem item = (IRosterItem) it.next();
                    addRosterItem(item, contentProvider, itemsFilter);
                }
            }
        }
        progressMonitor.worked(1);
    }
    progressMonitor.done();
}
Also used : IPresenceContainerAdapter(org.eclipse.ecf.presence.IPresenceContainerAdapter) IRosterManager(org.eclipse.ecf.presence.roster.IRosterManager) IRosterItem(org.eclipse.ecf.presence.roster.IRosterItem) Iterator(java.util.Iterator) Collection(java.util.Collection) IContainer(org.eclipse.ecf.core.IContainer)

Example 7 with IRosterItem

use of org.eclipse.ecf.presence.roster.IRosterItem in project ecf by eclipse.

the class XMPPContainerPresenceHelper method countClientsInRoster.

private int countClientsInRoster(XMPPID oldID) {
    Collection rosterItems = roster.getItems();
    int count = 0;
    synchronized (rosterItems) {
        for (final Iterator i = rosterItems.iterator(); i.hasNext(); ) {
            final IRosterItem item = (IRosterItem) i.next();
            if (item instanceof org.eclipse.ecf.presence.roster.RosterGroup) {
                final org.eclipse.ecf.presence.roster.RosterGroup group = (org.eclipse.ecf.presence.roster.RosterGroup) item;
                count += countClientsInRosterGroup(group, oldID);
            } else if (item instanceof org.eclipse.ecf.presence.roster.RosterEntry) {
                org.eclipse.ecf.presence.roster.RosterEntry entry = (org.eclipse.ecf.presence.roster.RosterEntry) item;
                XMPPID entryID = (XMPPID) entry.getUser().getID();
                if (entryID.getUsernameAtHost().equals(oldID.getUsernameAtHost())) {
                    count++;
                }
            }
        }
    }
    return count;
}
Also used : RosterGroup(org.eclipse.ecf.presence.roster.RosterGroup) IRosterItem(org.eclipse.ecf.presence.roster.IRosterItem) RosterGroup(org.eclipse.ecf.presence.roster.RosterGroup) IRosterGroup(org.eclipse.ecf.presence.roster.IRosterGroup) Iterator(java.util.Iterator) Collection(java.util.Collection) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) RosterEntry(org.jivesoftware.smack.RosterEntry) XMPPID(org.eclipse.ecf.provider.xmpp.identity.XMPPID)

Aggregations

IRosterItem (org.eclipse.ecf.presence.roster.IRosterItem)7 Iterator (java.util.Iterator)6 Collection (java.util.Collection)5 IRosterEntry (org.eclipse.ecf.presence.roster.IRosterEntry)5 IRosterGroup (org.eclipse.ecf.presence.roster.IRosterGroup)5 RosterEntry (org.jivesoftware.smack.RosterEntry)4 RosterGroup (org.eclipse.ecf.presence.roster.RosterGroup)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 XMPPID (org.eclipse.ecf.provider.xmpp.identity.XMPPID)2 IContainer (org.eclipse.ecf.core.IContainer)1 ISharedObject (org.eclipse.ecf.core.sharedobject.ISharedObject)1 IPresenceContainerAdapter (org.eclipse.ecf.presence.IPresenceContainerAdapter)1 IRoster (org.eclipse.ecf.presence.roster.IRoster)1 IRosterManager (org.eclipse.ecf.presence.roster.IRosterManager)1