src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java
/**
     * Updates the resources for the contact.
     * @param contact the contact which resources to update.
     * @param removeUnavailable whether to remove unavailable resources.
     * @return whether resource has been updated
     */
Updates the resources for the contact.
@param contact the contact which resources to update.
@param removeUnavailable whether to remove unavailable resources.
@return whether resource has been updated
Updates the resources for the contact . @param contact the contact which resources to update . @param removeUnavailable whether to remove unavailable resources . @return whether resource has been updated
private boolean updateResources(ContactJabberImpl contact,
                                 boolean removeUnavailable)
    {
        if (!contact.isResolved()
            || (contact instanceof VolatileContactJabberImpl
                && ((VolatileContactJabberImpl)contact)
                        .isPrivateMessagingContact()))
            return false;
        boolean eventFired = false;
        Map<FullJid, ContactResourceJabberImpl> resources =
            contact.getResourcesMap();
        if( parentProvider.getConnection() == null
            || !parentProvider.getConnection().isConnected())
        {
            if(removeUnavailable)
            {
                Iterator<Map.Entry<FullJid, ContactResourceJabberImpl>>
                    iter = resources.entrySet().iterator();
                while(iter.hasNext())
                {
                    Map.Entry<FullJid, ContactResourceJabberImpl> entry
                        = iter.next();
                    iter.remove();
                    contact.fireContactResourceEvent(
                        new ContactResourceEvent(contact, entry.getValue(),
                            ContactResourceEvent.RESOURCE_REMOVED));
                    eventFired = true;
                }
            }
            return eventFired;
        }
        Roster r = Roster.getInstanceFor(parentProvider.getConnection());
        BareJid bareJid = contact.getAddressAsJid().asBareJid();
        for (Presence presence : r.getPresences(bareJid))
        {
            eventFired = updateResource(contact, null, presence) || eventFired;
        }
        if(!removeUnavailable)
            return eventFired;
        for (FullJid fullJid : resources.keySet())
        {
            if(!r.getPresenceResource(fullJid).isAvailable())
            {
                eventFired = removeResource(contact, fullJid) || eventFired;
            }
        }
        return eventFired;
    }
private boolean updateResources ( ContactJabberImpl contact , boolean removeUnavailable ) { if ( ! contact . isResolved ( ) || ( contact instanceof VolatileContactJabberImpl && ( ( VolatileContactJabberImpl ) contact ) . isPrivateMessagingContact ( ) ) ) return false ; boolean eventFired = false ; Map < FullJid , ContactResourceJabberImpl > resources = contact . getResourcesMap ( ) ; if ( parentProvider . getConnection ( ) == null || ! parentProvider . getConnection ( ) . isConnected ( ) ) { if ( removeUnavailable ) { Iterator < Map . Entry < FullJid , ContactResourceJabberImpl > > iter = resources . entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { Map . Entry < FullJid , ContactResourceJabberImpl > entry = iter . next ( ) ; iter . remove ( ) ; contact . fireContactResourceEvent ( new ContactResourceEvent ( contact , entry . getValue ( ) , ContactResourceEvent . RESOURCE_REMOVED ) ) ; eventFired = true ; } } return eventFired ; } Roster r = Roster . getInstanceFor ( parentProvider . getConnection ( ) ) ; BareJid bareJid = contact . getAddressAsJid ( ) . asBareJid ( ) ; for ( Presence presence : r . getPresences ( bareJid ) ) { eventFired = updateResource ( contact , null , presence ) || eventFired ; } if ( ! removeUnavailable ) return eventFired ; for ( FullJid fullJid : resources . keySet ( ) ) { if ( ! r . getPresenceResource ( fullJid ) . isAvailable ( ) ) { eventFired = removeResource ( contact , fullJid ) || eventFired ; } } return eventFired ; }
Updates the resources for the contact.
Updates the resources for the contact .
// Do not obtain getRoster if we are not connected, or new Roster // will be created, all the resources that will be returned will be // unavailable. As we are not connected if set remove all resources // Choose the resource which has the highest priority AND supports // Jingle, if we have two resources with same priority take // the most available.