Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.sip.MethodProcessorAdapter
      extended by net.java.sip.communicator.impl.protocol.sip.EventPackageSupport
All Implemented Interfaces:
MethodProcessor
Direct Known Subclasses:
EventPackageNotifier, EventPackageSubscriber

public class EventPackageSupport
extends MethodProcessorAdapter

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

Author:
Lyubomir Marinov

Nested Class Summary
protected static class EventPackageSupport.Subscription
          Represents a general event package subscription in the sense of RFC 3265 "Session Initiation Protocol (SIP)-Specific Event Notification" and its signaling characteristics such as Request URI, id tag value of its Event header.
 
Field Summary
protected  String contentSubType
          The sub-type of the content type of the response bodies announced, expected and supported by the subscriptions/notifications managed by this instance.
protected  String eventPackage
          The name of the event package this instance implements and carried in the Event and Allow-Events headers.
protected  ProtocolProviderServiceSipImpl protocolProvider
          The SIP ProtocolProviderService implementation for which this instance provides support for a specific event package.
protected  int subscriptionDuration
          The duration of each subscription managed by this instance and carried in the Expires header.
protected  TimerScheduler timer
          The Timer support which executes the time-based tasks of this instance.
 
Constructor Summary
protected EventPackageSupport(ProtocolProviderServiceSipImpl protocolProvider, String eventPackage, int subscriptionDuration, String contentSubType, TimerScheduler timer)
          Initializes a new EventPackageSupport instance which is to provide support according to RFC 3265 to a specific SIP ProtocolProviderService implementation for a specific event package.
 
Method Summary
protected  void addSubscription(String callId, EventPackageSupport.Subscription subscription)
          Adds a specific Subscription associated with a specific CallId to the list of subscriptions managed by this instance.
 String getEventPackage()
          Gets the name of the event package this instance implements and carried in the Event and Allow-Events headers.
(package private) static javax.sip.ServerTransaction getOrCreateServerTransaction(javax.sip.RequestEvent requestEvent)
          Safely returns the ServerTransaction associated with a specific RequestEvent or creates a new one if the specified RequestEvent is not associated with one.
protected  EventPackageSupport.Subscription getSubscription(javax.sip.address.Address toAddress, 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  EventPackageSupport.Subscription getSubscription(String callId)
          Gets the Subscription from the list of subscriptions managed by this instance which is associated with a specific CallId.
protected  EventPackageSupport.Subscription[] getSubscriptions()
          Gets a new copy of the list of Subscriptions managed by this instance.
protected  void processAuthenticationChallenge(javax.sip.ClientTransaction clientTransaction, javax.sip.message.Response response, javax.sip.SipProvider jainSipProvider)
          Attempts to re-generate a Request within a specific ClientTransaction with the proper authorization headers.
(package private) static void processAuthenticationChallenge(ProtocolProviderServiceSipImpl protocolProvider, javax.sip.ClientTransaction clientTransaction, javax.sip.message.Response response, javax.sip.SipProvider jainSipProvider)
          Attempts to re-generate a Request within a specific ClientTransaction with the proper authorization headers.
 void removeSubscription(javax.sip.address.Address toAddress)
          Removes a Subscription from the list of subscriptions managed by this instance which is associated with a specific subscription Address/Request URI and has an id tag in its Event header of null.
 boolean removeSubscription(javax.sip.address.Address toAddress, String eventId)
          Removes a 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  boolean removeSubscription(String callId, EventPackageSupport.Subscription subscription)
          Removes a specific Subscription from the list of subscriptions managed by this instance if it is associated with a specific CallId.
static boolean sendNotImplementedResponse(ProtocolProviderServiceSipImpl provider, javax.sip.RequestEvent requestEvent)
          Sends a Response.NOT_IMPLEMENTED Response to a specific Request.
 
Methods inherited from class net.java.sip.communicator.impl.protocol.sip.MethodProcessorAdapter
processDialogTerminated, processIOException, processRequest, processResponse, processTimeout, processTransactionTerminated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

contentSubType

protected final String contentSubType
The sub-type of the content type of the response bodies announced, expected and supported by the subscriptions/notifications managed by this instance.


eventPackage

protected final String eventPackage
The name of the event package this instance implements and carried in the Event and Allow-Events headers.


protocolProvider

protected final ProtocolProviderServiceSipImpl protocolProvider
The SIP ProtocolProviderService implementation for which this instance provides support for a specific event package.


subscriptionDuration

protected final int subscriptionDuration
The duration of each subscription managed by this instance and carried in the Expires header. Subscribers will interpret it as the value to be announced in the SIP signaling related to SUBSCRIBE requests originating from them, notifiers will use it as the default value for SUBSCRIBE requests coming to them which do not specify an explicit value in the Expires headers.


timer

protected final TimerScheduler timer
The Timer support which executes the time-based tasks of this instance.

Constructor Detail

EventPackageSupport

protected EventPackageSupport(ProtocolProviderServiceSipImpl protocolProvider,
                              String eventPackage,
                              int subscriptionDuration,
                              String contentSubType,
                              TimerScheduler timer)
Initializes a new EventPackageSupport instance which is to provide 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 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. Subscribers will interpret it as the value to be announced in the SIP signaling related to SUBSCRIBE requests originating from them, notifiers will use it as the default value for SUBSCRIBE requests coming to them which do not specify an explicit value in the Expires headers.
contentSubType - the sub-type of the content type of the response bodies to be announced, expected and supported by the subscriptions/notifications to be managed by the new instance
timer - the Timer support which is to execute the time-based tasks of the new instance
Method Detail

addSubscription

protected void addSubscription(String callId,
                               EventPackageSupport.Subscription subscription)
Adds a specific Subscription associated with a specific CallId to the list of subscriptions managed by this instance.

Parameters:
callId - the CallId associated with the Subscription to be added
subscription - the Subscription to be added to the list of subscriptions managed by this instance

getEventPackage

public final String getEventPackage()
Gets the name of the event package this instance implements and carried in the Event and Allow-Events headers.

Returns:
the name of the event package this instance implements and carried in the Event and Allow-Events headers

getOrCreateServerTransaction

static javax.sip.ServerTransaction getOrCreateServerTransaction(javax.sip.RequestEvent requestEvent)
Safely returns the ServerTransaction associated with a specific RequestEvent or creates a new one if the specified RequestEvent is not associated with one. Does not throw TransactionAlreadyExistsException and TransactionUnavailableException but rather logs these exceptions if they occur and returns null.

Parameters:
requestEvent - the RequestEvent to get the associated ServerTransaction of
Returns:
the ServerTransaction carried by the specified RequestEvent if the carried value in question is not null; a new ServerTransaction initializes with the Request carried by the specified RequestEvent if the event in question carries a null ServerTransaction; null in case of an exception

getSubscription

protected EventPackageSupport.Subscription getSubscription(javax.sip.address.Address toAddress,
                                                           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.

Parameters:
toAddress - 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 EventPackageSupport.Subscription getSubscription(String callId)
Gets the Subscription from the list of subscriptions managed by this instance which is associated with a specific CallId.

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

getSubscriptions

protected EventPackageSupport.Subscription[] getSubscriptions()
Gets a new copy of the list of Subscriptions managed by this instance.

Returns:
a new copy of the list of Subscriptions managed by this instance; if this instance currently manages no Subscriptions, an empty array of Subscription element type

processAuthenticationChallenge

protected void processAuthenticationChallenge(javax.sip.ClientTransaction clientTransaction,
                                              javax.sip.message.Response response,
                                              javax.sip.SipProvider jainSipProvider)
                                       throws OperationFailedException
Attempts to re-generate a Request within a specific ClientTransaction with the proper authorization headers.

Parameters:
clientTransaction - the ClientTransaction which was challenged to authenticate
response - the challenging Response
jainSipProvider - the provider which received the authentication challenge
Throws:
OperationFailedException - if processing the authentication challenge failed

processAuthenticationChallenge

static void processAuthenticationChallenge(ProtocolProviderServiceSipImpl protocolProvider,
                                           javax.sip.ClientTransaction clientTransaction,
                                           javax.sip.message.Response response,
                                           javax.sip.SipProvider jainSipProvider)
                                    throws OperationFailedException
Attempts to re-generate a Request within a specific ClientTransaction with the proper authorization headers.

Parameters:
protocolProvider - the SIP ProtocolProviderService implementation which received the authentication challenge and which is to re-generate and send the respective Request
clientTransaction - the ClientTransaction which was challenged to authenticate
response - the challenging Response
jainSipProvider - the provider which received the authentication challenge
Throws:
OperationFailedException - if processing the authentication challenge failed

removeSubscription

public void removeSubscription(javax.sip.address.Address toAddress)
Removes a Subscription from the list of subscriptions managed by this instance which is associated with a specific subscription Address/Request URI and has an id tag in its Event header of null. If such an instance is not found, does nothing.

Parameters:
toAddress - the subscription Address/Request URI of the Subscription to be removed

removeSubscription

public boolean removeSubscription(javax.sip.address.Address toAddress,
                                  String eventId)
Removes a 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. If such an instance is not found, does nothing.

Parameters:
toAddress - the subscription Address/Request URI of the Subscription to be removed
eventId - the id tag in the Event header of the Subscription to be removed; null if the Subscription should have no id tag in its Event header
Returns:
true if a Subscription was indeed removed by the call; otherwise, false

removeSubscription

protected boolean removeSubscription(String callId,
                                     EventPackageSupport.Subscription subscription)
Removes a specific Subscription from the list of subscriptions managed by this instance if it is associated with a specific CallId. If the specified Subscription is not associated with the specified CallId (including the case of no known association for the specified CallId), does nothing.

Parameters:
callId - the CallId which is expected to be associated with the specified Subscription
subscription - the Subscription to be removed from the list of subscriptions managed by this instance if it is associated with the specified CallId
Returns:
true if a Subscription was indeed removed by the call; otherwise, false

sendNotImplementedResponse

public static boolean sendNotImplementedResponse(ProtocolProviderServiceSipImpl provider,
                                                 javax.sip.RequestEvent requestEvent)
Sends a Response.NOT_IMPLEMENTED Response to a specific Request.

Parameters:
provider - the ProtocolProviderServiceSipImpl through which the Response is to be sent
requestEvent - the Request to which the Response to be sent is to respond
Returns:
true if the Response has been successfully sent; otherwise, false

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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