SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

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

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.AbstractProtocolProviderService
      extended by net.java.sip.communicator.impl.protocol.sip.ProtocolProviderServiceSipImpl
All Implemented Interfaces:
EventListener, javax.sip.SipListener, RegistrationStateChangeListener, ProtocolProviderService

public class ProtocolProviderServiceSipImpl
extends AbstractProtocolProviderService
implements javax.sip.SipListener, RegistrationStateChangeListener

A SIP implementation of the Protocol Provider Service.

Author:
Emil Ivov, Lubomir Marinov, Alan Kelly, Grigorii Balutsel

Nested Class Summary
protected  class ProtocolProviderServiceSipImpl.ShutdownThread
          The thread that we use in order to send our unREGISTER request upon system shut down.
 
Field Summary
static String KEEP_ALIVE_INTERVAL
          The interval for keep-alive
static String KEEP_ALIVE_METHOD
          Keep-alive method can be - register,options or udp
static String PRES_CONTENT_IMAGE_NAME
          Presence content for image.
static String XCAP_ENABLE
          The name of the property under which the user may specify whether to use or not XCAP.
static String XCAP_PASSWORD
          The name of the property under which the user may specify the XCAP user password.
static String XCAP_SERVER_URI
          The name of the property under which the user may specify the XCAP server uri.
static String XCAP_USE_SIP_CREDETIALS
          The name of the property under which the user may specify whether to use original sip creadetials for the XCAP.
static String XCAP_USER
          The name of the property under which the user may specify the XCAP user.
 
Fields inherited from interface net.java.sip.communicator.service.protocol.ProtocolProviderService
BIND_RETRIES_DEFAULT_VALUE, BIND_RETRIES_PROPERTY_NAME
 
Constructor Summary
ProtocolProviderServiceSipImpl()
           
 
Method Summary
protected
<T extends OperationSet>
void
addSupportedOperationSet(Class<T> opsetClass, T opset)
          Adds a specific OperationSet implementation to the set of supported OperationSets of this instance.
 void fireRegistrationStateChanged(RegistrationState oldState, RegistrationState newState, int reasonCode, String reason)
          Creates a RegistrationStateChange event corresponding to the specified old and new states and notifies all currently registered listeners.
 AccountID getAccountID()
          Returns the AccountID that uniquely identifies the account represented by this instance of the ProtocolProviderService.
 javax.sip.address.AddressFactory getAddressFactory()
          Returns the AddressFactory used to create URLs ans Address objects.
static Set<ProtocolProviderServiceSipImpl> getAllInstances()
          Returns all running instances of ProtocolProviderServiceSipImpl
 String getContactAddressCustomParamValue()
          Returns null for a registraless account, a value for the contact address custom parameter otherwise.
 javax.sip.header.ContactHeader getContactHeader(javax.sip.address.Address intendedDestination)
          Returns a Contact header containing a sip URI based on a localhost address.
 javax.sip.header.ContactHeader getContactHeader(javax.sip.address.SipURI intendedDestination)
          Returns a Contact header containing a sip URI based on a localhost address and therefore usable in REGISTER requests only.
 javax.sip.SipProvider getDefaultJainSipProvider()
          Returns the provider that corresponds to the transport returned by getDefaultTransport().
 javax.sip.ListeningPoint getDefaultListeningPoint()
          Returns the listening point that corresponds to the transport returned by getDefaultTransport().
 String getDefaultTransport()
          Returns the transport that we should use if we have no clear idea of our destination's preferred transport.
 javax.sip.header.HeaderFactory getHeaderFactory()
          Returns the HeaderFactory used to create SIP message headers.
 InetSocketAddress getIntendedDestination(javax.sip.address.Address destination)
          Returns the InetAddress that is most likely to be to be used as a next hop when contacting the specified destination.
 InetSocketAddress getIntendedDestination(javax.sip.address.SipURI destination)
          Returns the InetAddress that is most likely to be to be used as a next hop when contacting the specified destination.
 InetSocketAddress getIntendedDestination(String host)
          Returns the InetAddress that is most likely to be to be used as a next hop when contacting the specified destination.
 javax.sip.SipProvider getJainSipProvider(String transport)
          Returns the default jain sip provider that we use for communication over transport.
 List<String> getKnownEventsList()
          Returns the list of all the registered events for this provider.
 javax.sip.ListeningPoint getListeningPoint(javax.sip.address.Address intendedDestination)
          Returns the default listening point that we should use to contact the intended destination.
 javax.sip.ListeningPoint getListeningPoint(javax.sip.address.SipURI intendedDestination)
          Returns the default listening point that we should use to contact the intended destination.
 javax.sip.ListeningPoint getListeningPoint(String transport)
          Returns the default listening point that we use for communication over transport.
 ArrayList<javax.sip.header.ViaHeader> getLocalViaHeaders(javax.sip.address.Address intendedDestination)
          Initializes and returns an ArrayList with a single ViaHeader containing a localhost address usable with the specified sdestination.
 ArrayList<javax.sip.header.ViaHeader> getLocalViaHeaders(javax.sip.address.SipURI intendedDestination)
          Initializes and returns an ArrayList with a single ViaHeader containing a localhost address usable with the specified sdestination.
 javax.sip.header.MaxForwardsHeader getMaxForwardsHeader()
          Initializes and returns this provider's default maxForwardsHeader field using the value specified by MAX_FORWARDS.
 SipMessageFactory getMessageFactory()
          Returns the Message Factory used to create SIP messages.
 String getOurDisplayName()
          Returns the display name string that the user has set as a display name for this account.
 javax.sip.address.Address getOurSipAddress(javax.sip.address.Address intendedDestination)
          Returns the SIP address of record (Display Name ) that this account is created for.
 javax.sip.address.Address getOurSipAddress(javax.sip.address.SipURI intendedDestination)
          Returns the SIP address of record (Display Name ) that this account is created for.
 InetSocketAddress getOutboundProxy()
          In case we are using an outbound proxy this method returns its address.
 String getOutboundProxyString()
          In case we are using an outbound proxy this method returns a suitable string for use with Router.
 String getOutboundProxyTransport()
          In case we are using an outbound proxy this method returns the transport we are using to connect to it.
 ProtocolIcon getProtocolIcon()
          Returns the sip protocol icon.
 String getProtocolName()
          Returns the short name of the protocol that the implementation of this provider is based upon (like SIP, Jabber, ICQ/AIM, or others for example).
(package private)  SipRegistrarConnection getRegistrarConnection()
          Returns the current instance of SipRegistrarConnection.
 RegistrationState getRegistrationState()
          Returns the state of the registration of this protocol provider with the corresponding registration service.
 javax.sip.header.UserAgentHeader getSipCommUserAgentHeader()
          Returns a User Agent header that could be used for signing our requests.
 SipSecurityManager getSipSecurityManager()
          Reurns the currently valid sip security manager that everyone should use to authenticate SIP Requests.
(package private)  SipStatusEnum getSipStatusEnum()
          Returns the current instance of SipStatusEnum.
 List<String> getSupportedMethods()
          Returns a List of Strings corresponding to all methods that we have a processor for.
 XCapClient getXCapClient()
          Gets the XCAP client.
protected  void initialize(String sipAddress, SipAccountID accountID)
          Initializes the service implementation, and puts it in a state where it could interoperate with other services.
 javax.sip.address.Address parseAddressString(String uriStr)
          Parses the the uriStr string and returns a JAIN SIP URI.
 void processDialogTerminated(javax.sip.DialogTerminatedEvent dialogTerminatedEvent)
          Process an asynchronously reported DialogTerminatedEvent.
 void processIOException(javax.sip.IOExceptionEvent exceptionEvent)
          Never called.
 void processRequest(javax.sip.RequestEvent requestEvent)
          Processes a Request received on a SipProvider upon which this SipListener is registered.
 void processResponse(javax.sip.ResponseEvent responseEvent)
          Processes a Response received on a SipProvider upon which this SipListener is registered.
 void processTimeout(javax.sip.TimeoutEvent timeoutEvent)
          Processes a retransmit or expiration Timeout of an underlying Transaction handled by this SipListener.
 void processTransactionTerminated(javax.sip.TransactionTerminatedEvent transactionTerminatedEvent)
          Process an asynchronously reported TransactionTerminatedEvent.
 void register(SecurityAuthority authority)
          Starts the registration process.
 void registerEvent(String event)
          Register a new event taken in account by this provider.
 void registerMethodProcessor(String method, MethodProcessor methodProcessor)
          Registers methodProcessor in the methorProcessors table so that it would receives all messages in a transaction initiated by a method request.
 void registrationStateChanged(RegistrationStateChangeEvent event)
          Stops dispatching SIP messages to a SIP protocol provider service once it's been unregistered.
protected
<T extends OperationSet>
void
removeSupportedOperationSet(Class<T> opsetClass)
          Removes an OperationSet implementation from the set of supported OperationSets for this instance.
 InetSocketAddress resolveSipAddress(String address)
          Tries to resolve address into a valid InetSocketAddress using an SRV query where it exists and A/AAAA where it doesn't.
 InetSocketAddress resolveSipAddress(String address, String transport)
          Tries to resolve address into a valid InetSocketAddress using an SRV query where it exists and A/AAAA where it doesn't.
 void sayError(javax.sip.ServerTransaction serverTransaction, int errorCode)
          Send an error response with the errorCode code using serverTransaction.
 void sayErrorSilently(javax.sip.ServerTransaction serverTransaction, int errorCode)
          Send an error response with the errorCode code using serverTransaction and do not surface exceptions.
 void sendAck(javax.sip.ClientTransaction clientTransaction)
          Sends an ACK request in the specified dialog.
 void sendInDialogRequest(javax.sip.SipProvider sipProvider, javax.sip.message.Request request, javax.sip.Dialog dialog)
          Sends a specific Request through a given SipProvider as part of the conversation associated with a specific Dialog.
 void shutdown()
          Makes the service implementation close all open sockets and release any resources that it might have taken and prepare for shutdown/garbage collection.
static void throwOperationFailedException(String message, int errorCode, Throwable cause, Logger logger)
          Logs a specific message and associated Throwable cause as an error using the current Logger and then throws a new OperationFailedException with the message, a specific error code and the cause.
 void unregister()
          Ends the registration of this protocol provider with the current registration service.
 void unregisterMethodProcessor(String method, MethodProcessor methodProcessor)
          Unregisters methodProcessor from the methorProcessors table so that it won't receive further messages in a transaction initiated by a method request.
 
Methods inherited from class net.java.sip.communicator.service.protocol.AbstractProtocolProviderService
addRegistrationStateChangeListener, getOperationSet, getProtocolDisplayName, getSupportedOperationSets, isRegistered, removeRegistrationStateChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.java.sip.communicator.service.protocol.ProtocolProviderService
hashCode
 

Field Detail

KEEP_ALIVE_METHOD

public static final String KEEP_ALIVE_METHOD
Keep-alive method can be - register,options or udp

See Also:
Constant Field Values

KEEP_ALIVE_INTERVAL

public static final String KEEP_ALIVE_INTERVAL
The interval for keep-alive

See Also:
Constant Field Values

XCAP_ENABLE

public static final String XCAP_ENABLE
The name of the property under which the user may specify whether to use or not XCAP.

See Also:
Constant Field Values

XCAP_USE_SIP_CREDETIALS

public static final String XCAP_USE_SIP_CREDETIALS
The name of the property under which the user may specify whether to use original sip creadetials for the XCAP.

See Also:
Constant Field Values

XCAP_SERVER_URI

public static final String XCAP_SERVER_URI
The name of the property under which the user may specify the XCAP server uri.

See Also:
Constant Field Values

XCAP_USER

public static final String XCAP_USER
The name of the property under which the user may specify the XCAP user.

See Also:
Constant Field Values

XCAP_PASSWORD

public static final String XCAP_PASSWORD
The name of the property under which the user may specify the XCAP user password.

See Also:
Constant Field Values

PRES_CONTENT_IMAGE_NAME

public static final String PRES_CONTENT_IMAGE_NAME
Presence content for image.

See Also:
Constant Field Values
Constructor Detail

ProtocolProviderServiceSipImpl

public ProtocolProviderServiceSipImpl()
Method Detail

getXCapClient

public XCapClient getXCapClient()
Gets the XCAP client.

Returns:
the XCAP client.

getAccountID

public AccountID getAccountID()
Returns the AccountID that uniquely identifies the account represented by this instance of the ProtocolProviderService.

Specified by:
getAccountID in interface ProtocolProviderService
Returns:
the id of the account represented by this provider.

getRegistrationState

public RegistrationState getRegistrationState()
Returns the state of the registration of this protocol provider with the corresponding registration service.

Specified by:
getRegistrationState in interface ProtocolProviderService
Returns:
ProviderRegistrationState

getProtocolName

public String getProtocolName()
Returns the short name of the protocol that the implementation of this provider is based upon (like SIP, Jabber, ICQ/AIM, or others for example). If the name of the protocol has been enumerated in ProtocolNames then the value returned by this method must be the same as the one in ProtocolNames.

Specified by:
getProtocolName in interface ProtocolProviderService
Returns:
a String containing the short name of the protocol this service is implementing (most often that would be a name in ProtocolNames).

registerEvent

public void registerEvent(String event)
Register a new event taken in account by this provider. This is usefull to generate the Allow-Events header of the OPTIONS responses and to generate 489 responses.

Parameters:
event - The event to register

getKnownEventsList

public List<String> getKnownEventsList()
Returns the list of all the registered events for this provider.

Returns:
The list of all the registered events

fireRegistrationStateChanged

public void fireRegistrationStateChanged(RegistrationState oldState,
                                         RegistrationState newState,
                                         int reasonCode,
                                         String reason)
Description copied from class: AbstractProtocolProviderService
Creates a RegistrationStateChange event corresponding to the specified old and new states and notifies all currently registered listeners.

Overrides:
fireRegistrationStateChanged in class AbstractProtocolProviderService
Parameters:
oldState - the state that the provider had before the change occurred
newState - the state that the provider is currently in.
reasonCode - a value corresponding to one of the REASON_XXX fields of the RegistrationStateChangeEvent class, indicating the reason for this state transition.
reason - a String further explaining the reason code or null if no such explanation is necessary.

register

public void register(SecurityAuthority authority)
              throws OperationFailedException
Starts the registration process. Connection details such as registration server, user name/number are provided through the configuration service through implementation specific properties.

Specified by:
register in interface ProtocolProviderService
Parameters:
authority - the security authority that will be used for resolving any security challenges that may be returned during the registration or at any moment while wer're registered.
Throws:
OperationFailedException - with the corresponding code it the registration fails for some reason (e.g. a networking error or an implementation problem).

unregister

public void unregister()
                throws OperationFailedException
Ends the registration of this protocol provider with the current registration service.

Specified by:
unregister in interface ProtocolProviderService
Throws:
OperationFailedException - with the corresponding code it the registration fails for some reason (e.g. a networking error or an implementation problem).

initialize

protected void initialize(String sipAddress,
                          SipAccountID accountID)
                   throws OperationFailedException,
                          IllegalArgumentException
Initializes the service implementation, and puts it in a state where it could interoperate with other services.

Parameters:
sipAddress - the account id/uin/screenname of the account that we're about to create
accountID - the identifier of the account that this protocol provider represents.
Throws:
OperationFailedException - with code INTERNAL_ERROR if we fail initializing the SIP Stack.
IllegalArgumentException - if one or more of the account properties have invalid values.
See Also:
AccountID

addSupportedOperationSet

protected <T extends OperationSet> void addSupportedOperationSet(Class<T> opsetClass,
                                                                 T opset)
Adds a specific OperationSet implementation to the set of supported OperationSets of this instance. Serves as a type-safe wrapper around AbstractProtocolProviderService.supportedOperationSets which works with class names instead of Class and also shortens the code which performs such additions.

Overrides:
addSupportedOperationSet in class AbstractProtocolProviderService
Type Parameters:
T - the exact type of the OperationSet implementation to be added
Parameters:
opsetClass - the Class of OperationSet under the name of which the specified implementation is to be added
opset - the OperationSet implementation to be added

removeSupportedOperationSet

protected <T extends OperationSet> void removeSupportedOperationSet(Class<T> opsetClass)
Removes an OperationSet implementation from the set of supported OperationSets for this instance.

Overrides:
removeSupportedOperationSet in class AbstractProtocolProviderService
Type Parameters:
T - the exact type of the OperationSet implementation to be added
Parameters:
opsetClass - the Class of OperationSet under the name of which the specified implementation is to be added

processIOException

public void processIOException(javax.sip.IOExceptionEvent exceptionEvent)
Never called.

Specified by:
processIOException in interface javax.sip.SipListener
Parameters:
exceptionEvent - the IOExceptionEvent containing the cause.

processResponse

public void processResponse(javax.sip.ResponseEvent responseEvent)
Processes a Response received on a SipProvider upon which this SipListener is registered.

Specified by:
processResponse in interface javax.sip.SipListener
Parameters:
responseEvent - the responseEvent fired from the SipProvider to the SipListener representing a Response received from the network.

processTimeout

public void processTimeout(javax.sip.TimeoutEvent timeoutEvent)
Processes a retransmit or expiration Timeout of an underlying Transaction handled by this SipListener. This Event notifies the application that a retransmission or transaction Timer expired in the SipProvider's transaction state machine. The TimeoutEvent encapsulates the specific timeout type and the transaction identifier either client or server upon which the timeout occurred. The type of Timeout can by determined by: timeoutType = timeoutEvent.getTimeout().getValue();

Specified by:
processTimeout in interface javax.sip.SipListener
Parameters:
timeoutEvent - - the timeoutEvent received indicating either the message retransmit or transaction timed out.

processTransactionTerminated

public void processTransactionTerminated(javax.sip.TransactionTerminatedEvent transactionTerminatedEvent)
Process an asynchronously reported TransactionTerminatedEvent. When a transaction transitions to the Terminated state, the stack keeps no further records of the transaction. This notification can be used by applications to clean up any auxiliary data that is being maintained for the given transaction.

Specified by:
processTransactionTerminated in interface javax.sip.SipListener
Parameters:
transactionTerminatedEvent - -- an event that indicates that the transaction has transitioned into the terminated state.
Since:
v1.2

processDialogTerminated

public void processDialogTerminated(javax.sip.DialogTerminatedEvent dialogTerminatedEvent)
Process an asynchronously reported DialogTerminatedEvent. When a dialog transitions to the Terminated state, the stack keeps no further records of the dialog. This notification can be used by applications to clean up any auxiliary data that is being maintained for the given dialog.

Specified by:
processDialogTerminated in interface javax.sip.SipListener
Parameters:
dialogTerminatedEvent - -- an event that indicates that the dialog has transitioned into the terminated state.
Since:
v1.2

processRequest

public void processRequest(javax.sip.RequestEvent requestEvent)
Processes a Request received on a SipProvider upon which this SipListener is registered.

Specified by:
processRequest in interface javax.sip.SipListener
Parameters:
requestEvent - requestEvent fired from the SipProvider to the SipListener representing a Request received from the network.

shutdown

public void shutdown()
Makes the service implementation close all open sockets and release any resources that it might have taken and prepare for shutdown/garbage collection.

Specified by:
shutdown in interface ProtocolProviderService

getLocalViaHeaders

public ArrayList<javax.sip.header.ViaHeader> getLocalViaHeaders(javax.sip.address.Address intendedDestination)
                                                         throws OperationFailedException
Initializes and returns an ArrayList with a single ViaHeader containing a localhost address usable with the specified sdestination. This ArrayList may be used when sending requests to that destination.

Parameters:
intendedDestination - The address of the destination that the request using the via headers will be sent to.
Returns:
ViaHeader-s list to be used when sending requests.
Throws:
OperationFailedException - code INTERNAL_ERROR if a ParseException occurs while initializing the array list.

getLocalViaHeaders

public ArrayList<javax.sip.header.ViaHeader> getLocalViaHeaders(javax.sip.address.SipURI intendedDestination)
                                                         throws OperationFailedException
Initializes and returns an ArrayList with a single ViaHeader containing a localhost address usable with the specified sdestination. This ArrayList may be used when sending requests to that destination.

Parameters:
intendedDestination - The address of the destination that the request using the via headers will be sent to.
Returns:
ViaHeader-s list to be used when sending requests.
Throws:
OperationFailedException - code INTERNAL_ERROR if a ParseException occurs while initializing the array list.

getMaxForwardsHeader

public javax.sip.header.MaxForwardsHeader getMaxForwardsHeader()
                                                        throws OperationFailedException
Initializes and returns this provider's default maxForwardsHeader field using the value specified by MAX_FORWARDS.

Returns:
an instance of a MaxForwardsHeader that can be used when sending requests
Throws:
OperationFailedException - with code INTERNAL_ERROR if MAX_FORWARDS has an invalid value.

getContactHeader

public javax.sip.header.ContactHeader getContactHeader(javax.sip.address.Address intendedDestination)
Returns a Contact header containing a sip URI based on a localhost address.

Parameters:
intendedDestination - the destination that we plan to be sending this contact header to.
Returns:
a Contact header based upon a local inet address.

getContactHeader

public javax.sip.header.ContactHeader getContactHeader(javax.sip.address.SipURI intendedDestination)
Returns a Contact header containing a sip URI based on a localhost address and therefore usable in REGISTER requests only.

Parameters:
intendedDestination - the destination that we plan to be sending this contact header to.
Returns:
a Contact header based upon a local inet address.

getContactAddressCustomParamValue

public String getContactAddressCustomParamValue()
Returns null for a registraless account, a value for the contact address custom parameter otherwise. This will help the dispatching of incoming requests between accounts with the same username. For address-of-record user@example.com, the returned value woud be example_com.

Returns:
null for a registraless account, a value for the "registering_acc" contact address parameter otherwise

getAddressFactory

public javax.sip.address.AddressFactory getAddressFactory()
Returns the AddressFactory used to create URLs ans Address objects.

Returns:
the AddressFactory used to create URLs ans Address objects.

getHeaderFactory

public javax.sip.header.HeaderFactory getHeaderFactory()
Returns the HeaderFactory used to create SIP message headers.

Returns:
the HeaderFactory used to create SIP message headers.

getMessageFactory

public SipMessageFactory getMessageFactory()
Returns the Message Factory used to create SIP messages.

Returns:
the Message Factory used to create SIP messages.

getAllInstances

public static Set<ProtocolProviderServiceSipImpl> getAllInstances()
Returns all running instances of ProtocolProviderServiceSipImpl

Returns:
all running instances of ProtocolProviderServiceSipImpl

getListeningPoint

public javax.sip.ListeningPoint getListeningPoint(String transport)
Returns the default listening point that we use for communication over transport.

Parameters:
transport - the transport that the returned listening point needs to support.
Returns:
the default listening point that we use for communication over transport or null if no such transport is supported.

getListeningPoint

public javax.sip.ListeningPoint getListeningPoint(javax.sip.address.Address intendedDestination)
Returns the default listening point that we should use to contact the intended destination.

Parameters:
intendedDestination - the address that we will be trying to contact through the listening point we are trying to obtain.
Returns:
the listening point that we should use to contact the intended destination.

getListeningPoint

public javax.sip.ListeningPoint getListeningPoint(javax.sip.address.SipURI intendedDestination)
Returns the default listening point that we should use to contact the intended destination.

Parameters:
intendedDestination - the address that we will be trying to contact through the listening point we are trying to obtain.
Returns:
the listening point that we should use to contact the intended destination.

getJainSipProvider

public javax.sip.SipProvider getJainSipProvider(String transport)
Returns the default jain sip provider that we use for communication over transport.

Parameters:
transport - the transport that the returned provider needs to support.
Returns:
the default jain sip provider that we use for communication over transport or null if no such transport is supported.

getSipSecurityManager

public SipSecurityManager getSipSecurityManager()
Reurns the currently valid sip security manager that everyone should use to authenticate SIP Requests.

Returns:
the currently valid instace of a SipSecurityManager that everyone sould use to authenticate SIP Requests.

getOurSipAddress

public javax.sip.address.Address getOurSipAddress(javax.sip.address.Address intendedDestination)
Returns the SIP address of record (Display Name ) that this account is created for. The method takes into account whether or not we are running in Registar or "No Registar" mode and either returns the AOR we are using to register or an address constructed using the local address.

Parameters:
intendedDestination - the destination that we would be using the local address to communicate with.
Returns:
our Address Of Record that we should use in From headers.

getOurSipAddress

public javax.sip.address.Address getOurSipAddress(javax.sip.address.SipURI intendedDestination)
Returns the SIP address of record (Display Name ) that this account is created for. The method takes into account whether or not we are running in Registar or "No Registar" mode and either returns the AOR we are using to register or an address constructed using the local address

Parameters:
intendedDestination - the destination that we would be using the local address to communicate with. .
Returns:
our Address Of Record that we should use in From headers.

getOutboundProxyString

public String getOutboundProxyString()
In case we are using an outbound proxy this method returns a suitable string for use with Router. The method returns null otherwise.

Returns:
the string of our outbound proxy if we are using one and null otherwise.

getOutboundProxy

public InetSocketAddress getOutboundProxy()
In case we are using an outbound proxy this method returns its address. The method returns null otherwise.

Returns:
the address of our outbound proxy if we are using one and null otherwise.

getOutboundProxyTransport

public String getOutboundProxyTransport()
In case we are using an outbound proxy this method returns the transport we are using to connect to it. The method returns null otherwise.

Returns:
the transport used to connect to our outbound proxy if we are using one and null otherwise.

registerMethodProcessor

public void registerMethodProcessor(String method,
                                    MethodProcessor methodProcessor)
Registers methodProcessor in the methorProcessors table so that it would receives all messages in a transaction initiated by a method request. If any previous processors exist for the same method, they will be replaced by this one.

Parameters:
method - a String representing the SIP method that we're registering the processor for (e.g. INVITE, REGISTER, or SUBSCRIBE).
methodProcessor - a MethodProcessor implementation that would handle all messages received within a method transaction.

unregisterMethodProcessor

public void unregisterMethodProcessor(String method,
                                      MethodProcessor methodProcessor)
Unregisters methodProcessor from the methorProcessors table so that it won't receive further messages in a transaction initiated by a method request.

Parameters:
method - the name of the method whose processor we'd like to unregister.
methodProcessor - the MethodProcessor that we'd like to unregister.

getDefaultTransport

public String getDefaultTransport()
Returns the transport that we should use if we have no clear idea of our destination's preferred transport. The method would first check if we are running behind an outbound proxy and if so return its transport. If no outbound proxy is set, the method would check the contents of the DEFAULT_TRANSPORT property and return it if not null. Otherwise the method would return UDP;

Returns:
The first non null password of the following: a) the transport we use to communicate with our registrar b) the transport of our outbound proxy, c) the transport specified by the DEFAULT_TRANSPORT property, UDP.

getDefaultJainSipProvider

public javax.sip.SipProvider getDefaultJainSipProvider()
Returns the provider that corresponds to the transport returned by getDefaultTransport(). Equivalent to calling getJainSipProvider(getDefaultTransport())

Returns:
the Jain SipProvider that corresponds to the transport returned by getDefaultTransport().

getDefaultListeningPoint

public javax.sip.ListeningPoint getDefaultListeningPoint()
Returns the listening point that corresponds to the transport returned by getDefaultTransport(). Equivalent to calling getListeningPoint(getDefaultTransport())

Returns:
the Jain SipProvider that corresponds to the transport returned by getDefaultTransport().

getOurDisplayName

public String getOurDisplayName()
Returns the display name string that the user has set as a display name for this account.

Returns:
the display name string that the user has set as a display name for this account.

getSipCommUserAgentHeader

public javax.sip.header.UserAgentHeader getSipCommUserAgentHeader()
Returns a User Agent header that could be used for signing our requests.

Returns:
a UserAgentHeader that could be used for signing our requests.

sayErrorSilently

public void sayErrorSilently(javax.sip.ServerTransaction serverTransaction,
                             int errorCode)
Send an error response with the errorCode code using serverTransaction and do not surface exceptions. The method is useful when we are sending the error response in a stack initiated operation and don't have the possibility to escalate potential exceptions, so we can only log them.

Parameters:
serverTransaction - the transaction that we'd like to send an error response in.
errorCode - the code that the response should have.

sendAck

public void sendAck(javax.sip.ClientTransaction clientTransaction)
             throws javax.sip.SipException,
                    javax.sip.InvalidArgumentException
Sends an ACK request in the specified dialog.

Parameters:
clientTransaction - the transaction that resulted in the ACK we are about to send (MUST be an INVITE transaction).
Throws:
javax.sip.InvalidArgumentException - if there is a problem with the supplied CSeq ( for example <= 0 ).
javax.sip.SipException - if the CSeq does not relate to a previously sent INVITE or if the Method that created the Dialog is not an INVITE ( for example SUBSCRIBE) or if we fail to send the INVITE for whatever reason.

sayError

public void sayError(javax.sip.ServerTransaction serverTransaction,
                     int errorCode)
              throws OperationFailedException
Send an error response with the errorCode code using serverTransaction.

Parameters:
serverTransaction - the transaction that we'd like to send an error response in.
errorCode - the code that the response should have.
Throws:
OperationFailedException - if we failed constructing or sending a SIP Message.

sendInDialogRequest

public void sendInDialogRequest(javax.sip.SipProvider sipProvider,
                                javax.sip.message.Request request,
                                javax.sip.Dialog dialog)
                         throws OperationFailedException
Sends a specific Request through a given SipProvider as part of the conversation associated with a specific Dialog.

Parameters:
sipProvider - the SipProvider to send the specified request through
request - the Request to send through sipProvider
dialog - the Dialog as part of which the specified request is to be sent
Throws:
OperationFailedException - if creating a transaction or sending the request fails.

getSupportedMethods

public List<String> getSupportedMethods()
Returns a List of Strings corresponding to all methods that we have a processor for.

Returns:
a List of methods that we support.

getProtocolIcon

public ProtocolIcon getProtocolIcon()
Returns the sip protocol icon.

Specified by:
getProtocolIcon in interface ProtocolProviderService
Returns:
the sip protocol icon

getSipStatusEnum

SipStatusEnum getSipStatusEnum()
Returns the current instance of SipStatusEnum.

Returns:
the current instance of SipStatusEnum.

getRegistrarConnection

SipRegistrarConnection getRegistrarConnection()
Returns the current instance of SipRegistrarConnection.

Returns:
SipRegistrarConnection

parseAddressString

public javax.sip.address.Address parseAddressString(String uriStr)
                                             throws ParseException
Parses the the uriStr string and returns a JAIN SIP URI.

Parameters:
uriStr - a String containing the uri to parse.
Returns:
a URI object corresponding to the uriStr string.
Throws:
ParseException - if uriStr is not properly formatted.

resolveSipAddress

public InetSocketAddress resolveSipAddress(String address,
                                           String transport)
                                    throws UnknownHostException
Tries to resolve address into a valid InetSocketAddress using an SRV query where it exists and A/AAAA where it doesn't.

Parameters:
address - the address we'd like to resolve.
transport - the protocol that we'd like to use when accessing address.
Returns:
an InetSocketAddress instance containing the SRV record for address if one has been defined and the A/AAAA record where it hasn't.
Throws:
UnknownHostException - if address is not a valid host address.

resolveSipAddress

public InetSocketAddress resolveSipAddress(String address)
                                    throws UnknownHostException
Tries to resolve address into a valid InetSocketAddress using an SRV query where it exists and A/AAAA where it doesn't. The method assumes that the transport that we'll be using when connecting to address is the one that has been defined as default for this provider.

Parameters:
address - the address we'd like to resolve.
Returns:
an InetSocketAddress instance containing the SRV record for address if one has been defined and the A/AAAA record where it hasn't.
Throws:
UnknownHostException - if address is not a valid host address.

getIntendedDestination

public InetSocketAddress getIntendedDestination(javax.sip.address.Address destination)
                                         throws IllegalArgumentException
Returns the InetAddress that is most likely to be to be used as a next hop when contacting the specified destination. This is an utility method that is used whenever we have to choose one of our local addresses to put in the Via, Contact or (in the case of no registrar accounts) From headers. The method also takes into account the existence of an outbound proxy and in that case returns its address as the next hop.

Parameters:
destination - the destination that we would contact.
Returns:
the InetSocketAddress that is most likely to be to be used as a next hop when contacting the specified destination.
Throws:
IllegalArgumentException - if destination is not a valid host/ip/fqdn

getIntendedDestination

public InetSocketAddress getIntendedDestination(javax.sip.address.SipURI destination)
                                         throws IllegalArgumentException
Returns the InetAddress that is most likely to be to be used as a next hop when contacting the specified destination. This is an utility method that is used whenever we have to choose one of our local addresses to put in the Via, Contact or (in the case of no registrar accounts) From headers. The method also takes into account the existence of an outbound proxy and in that case returns its address as the next hop.

Parameters:
destination - the destination that we would contact.
Returns:
the InetSocketAddress that is most likely to be to be used as a next hop when contacting the specified destination.
Throws:
IllegalArgumentException - if destination is not a valid host/ip/fqdn

getIntendedDestination

public InetSocketAddress getIntendedDestination(String host)
                                         throws IllegalArgumentException
Returns the InetAddress that is most likely to be to be used as a next hop when contacting the specified destination. This is an utility method that is used whenever we have to choose one of our local addresses to put in the Via, Contact or (in the case of no registrar accounts) From headers. The method also takes into account the existence of an outbound proxy and in that case returns its address as the next hop.

Parameters:
host - the destination that we would contact.
Returns:
the InetSocketAddress that is most likely to be to be used as a next hop when contacting the specified destination.
Throws:
IllegalArgumentException - if destination is not a valid host/ip/fqdn.

registrationStateChanged

public void registrationStateChanged(RegistrationStateChangeEvent event)
Stops dispatching SIP messages to a SIP protocol provider service once it's been unregistered.

Specified by:
registrationStateChanged in interface RegistrationStateChangeListener
Parameters:
event - the change event in the registration state of a provider.

throwOperationFailedException

public static void throwOperationFailedException(String message,
                                                 int errorCode,
                                                 Throwable cause,
                                                 Logger logger)
                                          throws OperationFailedException
Logs a specific message and associated Throwable cause as an error using the current Logger and then throws a new OperationFailedException with the message, a specific error code and the cause.

Parameters:
message - the message to be logged and then wrapped in a new OperationFailedException
errorCode - the error code to be assigned to the new OperationFailedException
cause - the Throwable that has caused the necessity to log an error and have a new OperationFailedException thrown
logger - the logger that we'd like to log the error message and cause.
Throws:
OperationFailedException - the exception that we wanted this method to throw.

SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

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