src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java
/**
         * Handles receiving a presence subscribe
         * @param fromID sender
         */
Handles receiving a presence subscribe
@param fromID sender
Handles receiving a presence subscribe @param fromID sender
private void handleSubscribeReceived(final Jid fromID,
            final String displayName)
        {
            new Thread(new Runnable() {
            public void run()
            {
                if (logger.isTraceEnabled())
                {
                    logger.trace(
                            fromID
                                + " wants to add you to its contact list");
                }
                ContactJabberImpl srcContact
                    = ssContactList.findContactById(fromID);
                Presence.Type responsePresenceType = null;
                if(srcContact == null)
                {
                    srcContact = createVolatileContact(fromID, displayName);
                }
                else
                {
                    if(srcContact.isPersistent())
                        responsePresenceType = Presence.Type.subscribed;
                }
                if(responsePresenceType == null)
                {
                    AuthorizationRequest req = new AuthorizationRequest();
                    AuthorizationResponse response
                        = handler.processAuthorisationRequest(
                                        req, srcContact);
                    if(response != null)
                    {
                        if(response.getResponseCode()
                               .equals(AuthorizationResponse.ACCEPT))
                        {
                            responsePresenceType
                                = Presence.Type.subscribed;
                            if (logger.isInfoEnabled())
                                logger.info(
                                    "Sending Accepted Subscription");
                        }
                        else if(response.getResponseCode()
                                .equals(AuthorizationResponse.REJECT))
                        {
                            responsePresenceType
                                = Presence.Type.unsubscribed;
                            if (logger.isInfoEnabled())
                                logger.info(
                                    "Sending Rejected Subscription");
                        }
                    }
                }
                if(responsePresenceType == null)
                    return;
                Presence responsePacket = new Presence(
                        responsePresenceType);
                responsePacket.setTo(fromID);
                try
                {
                    parentProvider.getConnection().sendStanza(responsePacket);
                }
                catch (NotConnectedException | InterruptedException e)
                {
                    logger.error("Could not send presence repsonse", e);
                }
            }}).start();
        }
private void handleSubscribeReceived ( final Jid fromID , final String displayName ) { new Thread ( new Runnable ( ) { public void run ( ) { if ( logger . isTraceEnabled ( ) ) { logger . trace ( fromID + " wants to add you to its contact list" ) ; } ContactJabberImpl srcContact = ssContactList . findContactById ( fromID ) ; Presence . Type responsePresenceType = null ; if ( srcContact == null ) { srcContact = createVolatileContact ( fromID , displayName ) ; } else { if ( srcContact . isPersistent ( ) ) responsePresenceType = Presence . Type . subscribed ; } if ( responsePresenceType == null ) { AuthorizationRequest req = new AuthorizationRequest ( ) ; AuthorizationResponse response = handler . processAuthorisationRequest ( req , srcContact ) ; if ( response != null ) { if ( response . getResponseCode ( ) . equals ( AuthorizationResponse . ACCEPT ) ) { responsePresenceType = Presence . Type . subscribed ; if ( logger . isInfoEnabled ( ) ) logger . info ( "Sending Accepted Subscription" ) ; } else if ( response . getResponseCode ( ) . equals ( AuthorizationResponse . REJECT ) ) { responsePresenceType = Presence . Type . unsubscribed ; if ( logger . isInfoEnabled ( ) ) logger . info ( "Sending Rejected Subscription" ) ; } } } if ( responsePresenceType == null ) return ; Presence responsePacket = new Presence ( responsePresenceType ) ; responsePacket . setTo ( fromID ) ; try { parentProvider . getConnection ( ) . sendStanza ( responsePacket ) ; } catch ( NotConnectedException | InterruptedException e ) { logger . error ( "Could not send presence repsonse" , e ) ; } } } ) . start ( ) ; }
Handles receiving a presence subscribe
 @param fromID sender
Handles receiving a presence subscribe @param fromID sender
// run waiting for user response in different thread // as this seems to block the packet dispatch thread // and we don't receive anything till we unblock it // buddy want to add you to its roster // subscription ignored