Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.sip
Class EventPackageNotifier

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.sip.MethodProcessorAdapter
      extended by net.java.sip.communicator.impl.protocol.sip.EventPackageSupport
          extended by net.java.sip.communicator.impl.protocol.sip.EventPackageNotifier
All Implemented Interfaces:
MethodProcessor

public abstract class EventPackageNotifier
extends EventPackageSupport

Implements the notifier part of RFC 3265 "Session Initiation Protocol (SIP)-Specific Event Notification" and thus eases the creation of event package-specific implementations.

Author:
Lubomir Marinov, Benoit Pradelle, Emil Ivov

Nested Class Summary
static class EventPackageNotifier.Subscription
          Represents a general event package subscription in the sense of RFC 3265 "Session Initiation Protocol (SIP)-Specific Event Notification" from the point of view of the notifier and its signaling characteristics such as Request URI, id tag value of its Event header, the Dialog which has been created by the associated SUBSCRIBE request or through which NOTIFY requests are to be sent.
static interface EventPackageNotifier.SubscriptionFilter
          Represents a filter for Subscriptions i.e.
 
Field Summary
 
Fields inherited from class net.java.sip.communicator.impl.protocol.sip.EventPackageSupport
contentSubType, eventPackage, protocolProvider, subscriptionDuration, timer
 
Constructor Summary
EventPackageNotifier(ProtocolProviderServiceSipImpl protocolProvider, String eventPackage, int subscriptionDuration, String contentSubType, TimerScheduler timer)
          Initializes a new EventPackageNotifier instance which is to provide notifier support according to RFC 3265 to a specific SIP ProtocolProviderService implementation for a specific event package.
 
Method Summary
protected abstract  EventPackageNotifier.Subscription createSubscription(javax.sip.address.Address fromAddress, String eventId)
          Creates a new Subscription instance which is to represent the subscription signaling from and to a specific target identified by its Address/Request URI and a specific EventId tag.
protected  EventPackageNotifier.Subscription getSubscription(javax.sip.address.Address fromAddress, String eventId)
          Gets the Subscription from the list of subscriptions managed by this instance which is associated with a specific subscription Address/Request URI and has a specific id tag in its Event header.
protected  EventPackageNotifier.Subscription getSubscription(String callId)
          Gets the Subscription from the list of subscriptions managed by this instance which is associated with a specific CallId.
 void notify(EventPackageNotifier.Subscription subscription, String subscriptionState, String reason)
          Notifies a specific target identified by its Subscription about a specific subscription state and a specific reason for that subscription state via a NOTIFY request.
 void notifyAll(String subscriptionState, String reason)
          Notifies all targets represented by the Subscriptions managed by this instance about a specific subscription state and a specific reason for that subscription state via NOTIFY requests.
 void notifyAll(String subscriptionState, String reason, EventPackageNotifier.SubscriptionFilter filter)
          Notifies all targets represented by the Subscriptions managed by this instance which are accepted by a specific SubscriptionFilter about a specific subscription state and a specific reason for that subscription state via NOTIFY requests.
 boolean processRequest(javax.sip.RequestEvent requestEvent)
          Processes incoming subscribe requests.
 boolean processResponse(javax.sip.ResponseEvent responseEvent)
          Handles an incoming response to a request we'vre previously sent.
protected  void removeSubscription(javax.sip.message.Response response, String eventId, javax.sip.ClientTransaction clientTransaction)
          Removes a Subscription from the list of subscriptions managed by this instance identified by the Response to our NOTIFY request.
 
Methods inherited from class net.java.sip.communicator.impl.protocol.sip.EventPackageSupport
addSubscription, getEventPackage, getOrCreateServerTransaction, getSubscriptions, processAuthenticationChallenge, processAuthenticationChallenge, removeSubscription, removeSubscription, removeSubscription, sendNotImplementedResponse
 
Methods inherited from class net.java.sip.communicator.impl.protocol.sip.MethodProcessorAdapter
processDialogTerminated, processIOException, processTimeout, processTransactionTerminated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventPackageNotifier

public EventPackageNotifier(ProtocolProviderServiceSipImpl protocolProvider,
                            String eventPackage,
                            int subscriptionDuration,
                            String contentSubType,
                            TimerScheduler timer)
Initializes a new EventPackageNotifier instance which is to provide notifier support according to RFC 3265 to a specific SIP ProtocolProviderService implementation for a specific event package.

Parameters:
protocolProvider - the SIP ProtocolProviderService implementation for which the new instance is to provide notifier support for a specific event package
eventPackage - the name of the event package the new instance is to implement and carry in the Event and Allow-Events headers
subscriptionDuration - the duration of each subscription to be managed by the new instance and to be carried in the Expires headers
contentSubType - the sub-type of the content type of the NOTIFY bodies to be announced, expected and supported by the subscriptions to be managed by the new instance
timer - the Timer support which is to time out the subscriptions to be managed by the new instance
Method Detail

createSubscription

protected abstract EventPackageNotifier.Subscription createSubscription(javax.sip.address.Address fromAddress,
                                                                        String eventId)
Creates a new Subscription instance which is to represent the subscription signaling from and to a specific target identified by its Address/Request URI and a specific EventId tag.

Parameters:
fromAddress - the Address/Request URI of the subscription target
eventId - the EventId tag of the subscription signaling associated with the specified target
Returns:
a new Subscription instance which represents the specified subscription target

getSubscription

protected EventPackageNotifier.Subscription getSubscription(javax.sip.address.Address fromAddress,
                                                            String eventId)
Gets the Subscription from the list of subscriptions managed by this instance which is associated with a specific subscription Address/Request URI and has a specific id tag in its Event header.

Overrides:
getSubscription in class EventPackageSupport
Parameters:
fromAddress - the subscription Address/Request URI of the Subscription to be retrieved
eventId - the id tag placed in the Event header of the Subscription to be retrieved if there is one or null if the Subscription should have no id tag in its Event header
Returns:
an existing Subscription from the list of subscriptions managed by this instance with the specified subscription Address /Request URI and the specified id tag in its Event header; null if no such Subscription exists in the list of subscriptions managed by this instance

getSubscription

protected EventPackageNotifier.Subscription getSubscription(String callId)
Gets the Subscription from the list of subscriptions managed by this instance which is associated with a specific CallId.

Overrides:
getSubscription in class EventPackageSupport
Parameters:
callId - the CallId associated with the Subscription to be retrieved
Returns:
an existing Subscription from the list of subscriptions managed by this instance which is associated with the specified CallId; null if no such Subscription exists in the list of subscriptions managed by this instance

notify

public void notify(EventPackageNotifier.Subscription subscription,
                   String subscriptionState,
                   String reason)
            throws OperationFailedException
Notifies a specific target identified by its Subscription about a specific subscription state and a specific reason for that subscription state via a NOTIFY request.

Parameters:
subscription - the target identified by its Subscription to be notified about the specified subscription state and the specified reason for that subscription state via a NOTIFY request
subscriptionState - the subscription state to notify the target represented by its Subscription about
reason - the reason for that subscription state
Throws:
OperationFailedException - if sending the NOTIFY request failed

notifyAll

public void notifyAll(String subscriptionState,
                      String reason)
               throws OperationFailedException
Notifies all targets represented by the Subscriptions managed by this instance about a specific subscription state and a specific reason for that subscription state via NOTIFY requests.

Parameters:
subscriptionState - the subscription state to be sent to all targets represented by the Subscriptions managed by this instance via NOTIFY requests
reason - the reason for the specified subscription state
Throws:
OperationFailedException - if anything goes wrong while sending out the notifications.

notifyAll

public void notifyAll(String subscriptionState,
                      String reason,
                      EventPackageNotifier.SubscriptionFilter filter)
               throws OperationFailedException
Notifies all targets represented by the Subscriptions managed by this instance which are accepted by a specific SubscriptionFilter about a specific subscription state and a specific reason for that subscription state via NOTIFY requests.

Parameters:
subscriptionState - the subscription state to be sent to all targets represented by the Subscriptions managed by this instance which are accepted by filter via NOTIFY requests
reason - the reason for the specified subscription state
filter - the SubscriptionFilter to pick up the Subscriptions managed by this instance to be notified about subscriptionState
Throws:
OperationFailedException - if anything goes wrong while sending out the notifications

processRequest

public boolean processRequest(javax.sip.RequestEvent requestEvent)
Processes incoming subscribe requests.

Specified by:
processRequest in interface MethodProcessor
Overrides:
processRequest in class MethodProcessorAdapter
Parameters:
requestEvent - the event containing the request we need to handle
Returns:
true if we have handled and thus consumed the request; false, otherwise
See Also:
MethodProcessor.processRequest(RequestEvent)

processResponse

public boolean processResponse(javax.sip.ResponseEvent responseEvent)
Handles an incoming response to a request we'vre previously sent.

Specified by:
processResponse in interface MethodProcessor
Overrides:
processResponse in class MethodProcessorAdapter
Parameters:
responseEvent - the event we need to handle
Returns:
true in case we've handles and thus consumed the event; false, otherwise
See Also:
MethodProcessor.processResponse(ResponseEvent)

removeSubscription

protected void removeSubscription(javax.sip.message.Response response,
                                  String eventId,
                                  javax.sip.ClientTransaction clientTransaction)
Removes a Subscription from the list of subscriptions managed by this instance identified by the Response to our NOTIFY request. If the specified Response cannot identify such a Subscription, does nothing.

Parameters:
response - a Response identifying the Subscription to be removed from the list of subscriptions managed by this instance
eventId - the value of the id tag
clientTransaction - the ClientTransaction through which the specified Response came

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.