src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java
/**
     * Update the resources for the contact for the received presence.
     * @param contact the contact which resources to update.
     * @param fullJid the full jid to use, if null will use those from the
     * presence packet
     * @param presence the presence packet to use to get info.
     * @return whether resource has been updated
     */
Update the resources for the contact for the received presence.
@param contact the contact which resources to update.
@param fullJid the full jid to use, if null will use those from the
presence packet
@param presence the presence packet to use to get info.
@return whether resource has been updated
Update the resources for the contact for the received presence . @param contact the contact which resources to update . @param fullJid the full jid to use if null will use those from the presence packet @param presence the presence packet to use to get info . @return whether resource has been updated
private boolean updateResource(ContactJabberImpl contact,
                                   FullJid fullJid,
                                   Presence presence)
    {
        if(fullJid == null)
            fullJid = presence.getFrom().asFullJidIfPossible();
        if (fullJid == null)
            return false;
        Resourcepart resource = fullJid.getResourceOrNull();
        if (resource != null && resource.length() > 0)
        {
            Map<FullJid, ContactResourceJabberImpl> resources =
                contact.getResourcesMap();
            ContactResourceJabberImpl contactResource
                = resources.get(fullJid);
            PresenceStatus newPresenceStatus
                = OperationSetPersistentPresenceJabberImpl
                    .jabberStatusToPresenceStatus(presence, parentProvider);
            if (contactResource == null)
            {
                contactResource = createResource(presence, fullJid, contact);
                resources.put(fullJid, contactResource);
                contact.fireContactResourceEvent(
                    new ContactResourceEvent(contact, contactResource,
                        ContactResourceEvent.RESOURCE_ADDED));
                return true;
            }
            else
            {
                boolean oldIndicator = contactResource.isMobile();
                boolean newIndicator =
                    mobileIndicator.isMobileResource(fullJid);
                int oldPriority = contactResource.getPriority();
                contactResource.setMobile(newIndicator);
                contactResource.setPriority(presence.getPriority());
                if(oldPriority != contactResource.getPriority())
                {
                    mobileIndicator.resourcesUpdated(contact);
                }
                if (contactResource.getPresenceStatus().getStatus()
                        != newPresenceStatus.getStatus()
                    || (oldIndicator != newIndicator)
                    || (oldPriority != contactResource.getPriority()))
                {
                    contactResource.setPresenceStatus(newPresenceStatus);
                    contact.fireContactResourceEvent(
                        new ContactResourceEvent(contact, contactResource,
                            ContactResourceEvent.RESOURCE_MODIFIED));
                    return true;
                }
            }
        }
        return false;
    }
private boolean updateResource ( ContactJabberImpl contact , FullJid fullJid , Presence presence ) { if ( fullJid == null ) fullJid = presence . getFrom ( ) . asFullJidIfPossible ( ) ; if ( fullJid == null ) return false ; Resourcepart resource = fullJid . getResourceOrNull ( ) ; if ( resource != null && resource . length ( ) > 0 ) { Map < FullJid , ContactResourceJabberImpl > resources = contact . getResourcesMap ( ) ; ContactResourceJabberImpl contactResource = resources . get ( fullJid ) ; PresenceStatus newPresenceStatus = OperationSetPersistentPresenceJabberImpl . jabberStatusToPresenceStatus ( presence , parentProvider ) ; if ( contactResource == null ) { contactResource = createResource ( presence , fullJid , contact ) ; resources . put ( fullJid , contactResource ) ; contact . fireContactResourceEvent ( new ContactResourceEvent ( contact , contactResource , ContactResourceEvent . RESOURCE_ADDED ) ) ; return true ; } else { boolean oldIndicator = contactResource . isMobile ( ) ; boolean newIndicator = mobileIndicator . isMobileResource ( fullJid ) ; int oldPriority = contactResource . getPriority ( ) ; contactResource . setMobile ( newIndicator ) ; contactResource . setPriority ( presence . getPriority ( ) ) ; if ( oldPriority != contactResource . getPriority ( ) ) { mobileIndicator . resourcesUpdated ( contact ) ; } if ( contactResource . getPresenceStatus ( ) . getStatus ( ) != newPresenceStatus . getStatus ( ) || ( oldIndicator != newIndicator ) || ( oldPriority != contactResource . getPriority ( ) ) ) { contactResource . setPresenceStatus ( newPresenceStatus ) ; contact . fireContactResourceEvent ( new ContactResourceEvent ( contact , contactResource , ContactResourceEvent . RESOURCE_MODIFIED ) ) ; return true ; } } } return false ; }
Update the resources for the contact for the received presence.
Update the resources for the contact for the received presence .
// update mobile indicator, as cabs maybe added after // creating the resource for the contact // priority has been updated so update and the // mobile indicator before firing an event