Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.service.protocol
Class AbstractProtocolProviderService

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.AbstractProtocolProviderService
All Implemented Interfaces:
ProtocolProviderService
Direct Known Subclasses:
ProtocolProviderServiceDictImpl, ProtocolProviderServiceGibberishImpl, ProtocolProviderServiceIcqImpl, ProtocolProviderServiceIrcImpl, ProtocolProviderServiceJabberImpl, ProtocolProviderServiceMsnImpl, ProtocolProviderServiceRssImpl, ProtocolProviderServiceSipImpl, ProtocolProviderServiceSSHImpl, ProtocolProviderServiceYahooImpl, ProtocolProviderServiceZeroconfImpl

public abstract class AbstractProtocolProviderService
extends Object
implements ProtocolProviderService

Implements standard functionality of ProtocolProviderService in order to make it easier for implementers to provide complete solutions while focusing on protocol-specific details.

Author:
Lubomir Marinov

Field Summary
 
Fields inherited from interface net.java.sip.communicator.service.protocol.ProtocolProviderService
BIND_RETRIES_DEFAULT_VALUE, BIND_RETRIES_PROPERTY_NAME
 
Constructor Summary
AbstractProtocolProviderService()
           
 
Method Summary
 void addRegistrationStateChangeListener(RegistrationStateChangeListener listener)
          Registers the specified listener with this provider so that it would receive notifications on changes of its state or other properties such as its local address and display name.
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 clearRegistrationStateChangeListener()
          Clear all registration state change listeners.
 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.
<T extends OperationSet>
T
getOperationSet(Class<T> opsetClass)
          Returns the operation set corresponding to the specified class or null if this operation set is not supported by the provider implementation.
 String getProtocolDisplayName()
          Returns the protocol display name.
 Map<String,OperationSet> getSupportedOperationSets()
          Returns an array containing all operation sets supported by the current implementation.
 boolean isRegistered()
          Indicates whether or not this provider is registered
 void removeRegistrationStateChangeListener(RegistrationStateChangeListener listener)
          Removes the specified registration state change listener so that it does not receive any further notifications upon changes of the RegistrationState of this provider.
protected
<T extends OperationSet>
void
removeSupportedOperationSet(Class<T> opsetClass)
          Removes an OperationSet implementation from the set of supported OperationSets for this instance.
 String toString()
          A clear display for ProtocolProvider when its printed in logs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.java.sip.communicator.service.protocol.ProtocolProviderService
getAccountID, getProtocolIcon, getProtocolName, getRegistrationState, hashCode, isSignalingTransportSecure, register, shutdown, unregister
 

Constructor Detail

AbstractProtocolProviderService

public AbstractProtocolProviderService()
Method Detail

addRegistrationStateChangeListener

public void addRegistrationStateChangeListener(RegistrationStateChangeListener listener)
Registers the specified listener with this provider so that it would receive notifications on changes of its state or other properties such as its local address and display name.

Specified by:
addRegistrationStateChangeListener in interface ProtocolProviderService
Parameters:
listener - the listener to register.

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 supportedOperationSets which works with class names instead of Class and also shortens the code which performs such additions.

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.

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

fireRegistrationStateChanged

public 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.

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.

getOperationSet

public <T extends OperationSet> T getOperationSet(Class<T> opsetClass)
Returns the operation set corresponding to the specified class or null if this operation set is not supported by the provider implementation.

Specified by:
getOperationSet in interface ProtocolProviderService
Type Parameters:
T - the exact type of the OperationSet that we're looking for
Parameters:
opsetClass - the Class of the operation set that we're looking for.
Returns:
returns an OperationSet of the specified Class if the underlying implementation supports it; null, otherwise.

getProtocolDisplayName

public String getProtocolDisplayName()
Returns the protocol display name. This is the name that would be used by the GUI to display the protocol name.

Specified by:
getProtocolDisplayName in interface ProtocolProviderService
Returns:
a String containing the display name of the protocol this service is implementing

getSupportedOperationSets

public Map<String,OperationSet> getSupportedOperationSets()
Returns an array containing all operation sets supported by the current implementation. When querying this method users must be prepared to receive any subset of the OperationSet-s defined by this service. They MUST ignore any OperationSet-s that they are not aware of and that may be defined by future version of this service. Such "unknown" OperationSet-s though not encouraged, may also be defined by service implementors.

Specified by:
getSupportedOperationSets in interface ProtocolProviderService
Returns:
a java.util.Map containing instance of all supported operation sets mapped against their class names (e.g. OperationSetPresence.class.getName()) .

isRegistered

public boolean isRegistered()
Indicates whether or not this provider is registered

Specified by:
isRegistered in interface ProtocolProviderService
Returns:
true if the provider is currently registered and false otherwise.

removeRegistrationStateChangeListener

public void removeRegistrationStateChangeListener(RegistrationStateChangeListener listener)
Removes the specified registration state change listener so that it does not receive any further notifications upon changes of the RegistrationState of this provider.

Specified by:
removeRegistrationStateChangeListener in interface ProtocolProviderService
Parameters:
listener - the listener to register for RegistrationStateChangeEvents.

clearRegistrationStateChangeListener

public void clearRegistrationStateChangeListener()
Clear all registration state change listeners.


toString

public String toString()
A clear display for ProtocolProvider when its printed in logs.

Overrides:
toString in class Object
Returns:
the class name and the currently handled account.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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