public class ProtocolProviderServiceSipImpl extends AbstractProtocolProviderService implements javax.sip.SipListener, RegistrationStateChangeListener
Modifier and Type | Class and Description |
---|---|
protected class |
ProtocolProviderServiceSipImpl.ShutdownThread
The thread that we use in order to send our unREGISTER request upon
system shut down.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
USE_SESSION_LEVEL_DIRECTION_IN_SDP
The name of the property which, if enabled, will cause a session-level
attribute for the session direction (e.g.
|
BIND_RETRIES_DEFAULT_VALUE, BIND_RETRIES_PROPERTY_NAME
Constructor and Description |
---|
ProtocolProviderServiceSipImpl() |
Modifier and Type | Method and Description |
---|---|
(package private) void |
addEarlyMessageProcessor(SipMessageProcessor processor)
Registers early message processor.
|
protected <T extends OperationSet> |
addSupportedOperationSet(java.lang.Class<T> opsetClass,
T opset)
Adds a specific OperationSet implementation to the set of
supported OperationSets of this instance.
|
(package private) void |
earlyProcessMessage(java.util.EventObject message)
Early process an incoming message from interested listeners.
|
AccountID |
getAccountID()
Returns the AccountID that uniquely identifies the account represented by
this instance of the ProtocolProviderService.
|
gov.nist.javax.sip.address.AddressFactoryEx |
getAddressFactory()
Returns the AddressFactory used to create URLs ans Address objects.
|
static java.util.Set<ProtocolProviderServiceSipImpl> |
getAllInstances()
Returns all running instances of ProtocolProviderServiceSipImpl
|
ProxyConnection |
getConnection()
Returns the ProxyConnection.
|
java.lang.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().
|
java.lang.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.
|
java.net.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.
|
java.net.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.
|
javax.sip.SipProvider |
getJainSipProvider(java.lang.String transport)
Returns the default jain sip provider that we use for communication over
transport.
|
java.util.List<java.lang.String> |
getKnownEventsList()
Returns the list of all the registered events for this provider.
|
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(java.lang.String transport)
Returns the default listening point that we use for communication over
transport.
|
java.util.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.
|
java.util.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.
|
java.lang.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
|
javax.sip.address.Address |
getOurSipAddress(javax.sip.address.SipURI intendedDestination)
Returns the SIP address of record (Display Name
|
ProtocolIcon |
getProtocolIcon()
Returns the sip protocol icon.
|
java.lang.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).
|
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.
|
java.util.List<java.lang.String> |
getSupportedMethods()
Returns a List of Strings corresponding to all methods that we have a
processor for.
|
TransportProtocol |
getTransportProtocol()
Returns the "transport" protocol of this instance used to carry the
control channel for the current protocol service.
|
protected void |
initialize(java.lang.String sipAddress,
SipAccountIDImpl accountID)
Initializes the service implementation, and puts it in a state where it
could interoperate with other services.
|
boolean |
isRegistrationRequiredForCalling()
Indicates whether or not this provider must registered
when placing outgoing calls.
|
boolean |
isSignalingTransportSecure()
Indicates if the SIP transport channel is using a TLS secured socket.
|
static boolean |
isValidTransport(java.lang.String transport)
Determines whether the supplied transport is a known SIP transport method
|
protected void |
notifyConnectionFailed()
If somewhere we got for example timeout of receiving answer to our
requests we consider problem with network and notify the provider.
|
javax.sip.address.Address |
parseAddressString(java.lang.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(java.lang.String event)
Register a new event taken in account by this provider.
|
void |
registerMethodProcessor(java.lang.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.
|
(package private) boolean |
registerUsingNextAddress()
Finds the next address to retry registering.
|
void |
registrationStateChanged(RegistrationStateChangeEvent event)
Stops dispatching SIP messages to a SIP protocol provider service
once it's been unregistered.
|
(package private) void |
removeEarlyMessageProcessor(SipMessageProcessor processor)
Removes the early message processor.
|
protected <T extends OperationSet> |
removeSupportedOperationSet(java.lang.Class<T> opsetClass)
Removes an OperationSet implementation from the set of
supported OperationSets for this instance.
|
void |
sayError(javax.sip.ServerTransaction serverTransaction,
int errorCode)
Send an error response with the errorCode code using
serverTransaction.
|
void |
sayError(javax.sip.ServerTransaction serverTransaction,
int errorCode,
javax.sip.header.Header header)
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.
|
(package private) boolean |
setOurDisplayName(java.lang.String newDisplayName)
Changes the display name string.
|
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(java.lang.String message,
int errorCode,
java.lang.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 |
unregister(boolean userRequest)
Ends the registration of this protocol provider with the current
registration service.
|
void |
unregisterMethodProcessor(java.lang.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.
|
boolean |
validateContactAddress(java.lang.String contactId,
java.util.List<java.lang.String> result)
Validates the contact identifier and returns an error message if
applicable and a suggested correction
|
addRegistrationStateChangeListener, clearRegistrationStateChangeListener, clearSupportedOperationSet, fireRegistrationStateChanged, fireRegistrationStateChanged, getOperationSet, getProtocolDisplayName, getSupportedOperationSetClasses, getSupportedOperationSets, isRegistered, removeRegistrationStateChangeListener, toString
public static final java.lang.String USE_SESSION_LEVEL_DIRECTION_IN_SDP
public AccountID getAccountID()
getAccountID
in interface ProtocolProviderService
public boolean validateContactAddress(java.lang.String contactId, java.util.List<java.lang.String> result)
validateContactAddress
in interface ProtocolProviderService
validateContactAddress
in class AbstractProtocolProviderService
contactId
- the contact identifier to validateresult
- Must be supplied as an empty a list. Implementors add
items:
public boolean isRegistrationRequiredForCalling()
isRegistrationRequiredForCalling
in interface ProtocolProviderService
isRegistrationRequiredForCalling
in class AbstractProtocolProviderService
public RegistrationState getRegistrationState()
getRegistrationState
in interface ProtocolProviderService
public java.lang.String getProtocolName()
getProtocolName
in interface ProtocolProviderService
public void registerEvent(java.lang.String event)
event
- The event to registerpublic java.util.List<java.lang.String> getKnownEventsList()
public void register(SecurityAuthority authority) throws OperationFailedException
register
in interface ProtocolProviderService
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.OperationFailedException
- with the corresponding code it the
registration fails for some reason (e.g. a networking error or an
implementation problem).public void unregister() throws OperationFailedException
unregister
in interface ProtocolProviderService
OperationFailedException
- with the corresponding code it the
registration fails for some reason (e.g. a networking error or an
implementation problem).public void unregister(boolean userRequest) throws OperationFailedException
unregister
in interface ProtocolProviderService
unregister
in class AbstractProtocolProviderService
userRequest
- is the unregister by user request.OperationFailedException
- with the corresponding code it the
registration fails for some reason (e.g. a networking error or an
implementation problem).protected void initialize(java.lang.String sipAddress, SipAccountIDImpl accountID) throws OperationFailedException, java.lang.IllegalArgumentException
sipAddress
- the account id/uin/screenname of the account that we're
about to createaccountID
- the identifier of the account that this protocol
provider represents.OperationFailedException
- with code INTERNAL_ERROR if we fail
initializing the SIP Stack.java.lang.IllegalArgumentException
- if one or more of the account
properties have invalid values.AccountID
protected <T extends OperationSet> void addSupportedOperationSet(java.lang.Class<T> opsetClass, T opset)
AbstractProtocolProviderService.supportedOperationSets
which works with class
names instead of Class and also shortens the code which performs
such additions.addSupportedOperationSet
in class AbstractProtocolProviderService
T
- the exact type of the OperationSet implementation to
be addedopsetClass
- the Class of OperationSet under the
name of which the specified implementation is to be addedopset
- the OperationSet implementation to be addedprotected <T extends OperationSet> void removeSupportedOperationSet(java.lang.Class<T> opsetClass)
removeSupportedOperationSet
in class AbstractProtocolProviderService
T
- the exact type of the OperationSet implementation to
be addedopsetClass
- the Class of OperationSet under the
name of which the specified implementation is to be addedpublic void processIOException(javax.sip.IOExceptionEvent exceptionEvent)
processIOException
in interface javax.sip.SipListener
exceptionEvent
- the IOExceptionEvent containing the cause.public void processResponse(javax.sip.ResponseEvent responseEvent)
processResponse
in interface javax.sip.SipListener
responseEvent
- the responseEvent fired from the SipProvider to the
SipListener representing a Response received from the network.public void processTimeout(javax.sip.TimeoutEvent timeoutEvent)
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();
processTimeout
in interface javax.sip.SipListener
timeoutEvent
- -
the timeoutEvent received indicating either the message
retransmit or transaction timed out.public void processTransactionTerminated(javax.sip.TransactionTerminatedEvent transactionTerminatedEvent)
processTransactionTerminated
in interface javax.sip.SipListener
transactionTerminatedEvent
- -- an event that indicates that the
transaction has transitioned into the terminated state.public void processDialogTerminated(javax.sip.DialogTerminatedEvent dialogTerminatedEvent)
processDialogTerminated
in interface javax.sip.SipListener
dialogTerminatedEvent
- -- an event that indicates that the
dialog has transitioned into the terminated state.public void processRequest(javax.sip.RequestEvent requestEvent)
processRequest
in interface javax.sip.SipListener
requestEvent
- requestEvent fired from the SipProvider to the
SipListener representing a Request received from the network.public void shutdown()
shutdown
in interface ProtocolProviderService
public java.util.ArrayList<javax.sip.header.ViaHeader> getLocalViaHeaders(javax.sip.address.Address intendedDestination) throws OperationFailedException
intendedDestination
- The address of the destination that the
request using the via headers will be sent to.OperationFailedException
- code INTERNAL_ERROR if a ParseException
occurs while initializing the array list.public java.util.ArrayList<javax.sip.header.ViaHeader> getLocalViaHeaders(javax.sip.address.SipURI intendedDestination) throws OperationFailedException
intendedDestination
- The address of the destination that the
request using the via headers will be sent to.OperationFailedException
- code INTERNAL_ERROR if a ParseException
occurs while initializing the array list.public javax.sip.header.MaxForwardsHeader getMaxForwardsHeader() throws OperationFailedException
OperationFailedException
- with code INTERNAL_ERROR if MAX_FORWARDS
has an invalid value.public javax.sip.header.ContactHeader getContactHeader(javax.sip.address.Address intendedDestination)
intendedDestination
- the destination that we plan to be sending
this contact header to.public javax.sip.header.ContactHeader getContactHeader(javax.sip.address.SipURI intendedDestination)
intendedDestination
- the destination that we plan to be sending
this contact header to.public java.lang.String getContactAddressCustomParamValue()
public gov.nist.javax.sip.address.AddressFactoryEx getAddressFactory()
public javax.sip.header.HeaderFactory getHeaderFactory()
public SipMessageFactory getMessageFactory()
public static java.util.Set<ProtocolProviderServiceSipImpl> getAllInstances()
public javax.sip.ListeningPoint getListeningPoint(java.lang.String transport)
transport
- the transport that the returned listening point needs
to support.public javax.sip.ListeningPoint getListeningPoint(javax.sip.address.SipURI intendedDestination)
intendedDestination
- the address that we will be trying to contact
through the listening point we are trying to obtain.public javax.sip.SipProvider getJainSipProvider(java.lang.String transport)
transport
- the transport that the returned provider needs
to support.public SipSecurityManager getSipSecurityManager()
public javax.sip.address.Address getOurSipAddress(javax.sip.address.Address intendedDestination)
intendedDestination
- the destination that we would be using the
local address to communicate with.public javax.sip.address.Address getOurSipAddress(javax.sip.address.SipURI intendedDestination)
intendedDestination
- the destination that we would be using the
local address to communicate with.
.public ProxyConnection getConnection()
public boolean isSignalingTransportSecure()
isSignalingTransportSecure
in interface ProtocolProviderService
public TransportProtocol getTransportProtocol()
getTransportProtocol
in interface ProtocolProviderService
public void registerMethodProcessor(java.lang.String method, MethodProcessor methodProcessor)
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.public void unregisterMethodProcessor(java.lang.String method, MethodProcessor methodProcessor)
method
- the name of the method whose processor we'd like to
unregister.methodProcessor
- the MethodProcessor that we'd like to
unregister.public java.lang.String getDefaultTransport()
public javax.sip.SipProvider getDefaultJainSipProvider()
public java.lang.String getOurDisplayName()
boolean setOurDisplayName(java.lang.String newDisplayName)
public javax.sip.header.UserAgentHeader getSipCommUserAgentHeader()
public void sayErrorSilently(javax.sip.ServerTransaction serverTransaction, int errorCode)
serverTransaction
- the transaction that we'd like to send an error
response in.errorCode
- the code that the response should have.public void sendAck(javax.sip.ClientTransaction clientTransaction) throws javax.sip.SipException, javax.sip.InvalidArgumentException
clientTransaction
- the transaction that resulted in the ACK we are
about to send (MUST be an INVITE transaction).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.public void sayError(javax.sip.ServerTransaction serverTransaction, int errorCode) throws OperationFailedException
serverTransaction
- the transaction that we'd like to send an error
response in.errorCode
- the code that the response should have.OperationFailedException
- if we failed constructing or sending a
SIP Message.public void sayError(javax.sip.ServerTransaction serverTransaction, int errorCode, javax.sip.header.Header header) throws OperationFailedException
serverTransaction
- the transaction that we'd like to send an error
response in.errorCode
- the code that the response should have.header
- SIP headerOperationFailedException
- if we failed constructing or sending a
SIP Message.public void sendInDialogRequest(javax.sip.SipProvider sipProvider, javax.sip.message.Request request, javax.sip.Dialog dialog) throws OperationFailedException
sipProvider
- the SipProvider to send the specified
request throughrequest
- the Request to send through
sipProviderdialog
- the Dialog as part of which the specified
request is to be sentOperationFailedException
- if creating a transaction or sending
the request fails.public java.util.List<java.lang.String> getSupportedMethods()
public ProtocolIcon getProtocolIcon()
getProtocolIcon
in interface ProtocolProviderService
SipStatusEnum getSipStatusEnum()
public SipRegistrarConnection getRegistrarConnection()
public javax.sip.address.Address parseAddressString(java.lang.String uriStr) throws java.text.ParseException
uriStr
- a String containing the uri to parse.java.text.ParseException
- if uriStr is not properly formatted.public java.net.InetSocketAddress getIntendedDestination(javax.sip.address.Address destination) throws java.lang.IllegalArgumentException
destination
- the destination that we would contact.java.lang.IllegalArgumentException
- if destination is not a valid
host/ip/fqdnpublic java.net.InetSocketAddress getIntendedDestination(javax.sip.address.SipURI destination) throws java.lang.IllegalArgumentException
destination
- the destination that we would contact.java.lang.IllegalArgumentException
- if destination is not a valid
host/ip/fqdnpublic void registrationStateChanged(RegistrationStateChangeEvent event)
registrationStateChanged
in interface RegistrationStateChangeListener
event
- the change event in the registration state of a provider.public static void throwOperationFailedException(java.lang.String message, int errorCode, java.lang.Throwable cause, Logger logger) throws OperationFailedException
message
- the message to be logged and then wrapped in a new
OperationFailedExceptionerrorCode
- the error code to be assigned to the new
OperationFailedExceptioncause
- the Throwable that has caused the necessity to log
an error and have a new OperationFailedException thrownlogger
- the logger that we'd like to log the error message
and cause.OperationFailedException
- the exception that we wanted this method
to throw.void addEarlyMessageProcessor(SipMessageProcessor processor)
processor
- early message processor.void removeEarlyMessageProcessor(SipMessageProcessor processor)
processor
- early message processor.void earlyProcessMessage(java.util.EventObject message)
message
- the message to process.boolean registerUsingNextAddress()
protected void notifyConnectionFailed()
public static boolean isValidTransport(java.lang.String transport)
transport
- the SIP transport to check
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.