Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.AbstractOperationSetServerStoredAccountInfo
      extended by net.java.sip.communicator.impl.protocol.sip.OperationSetServerStoredAccountInfoSipImpl
All Implemented Interfaces:
EventListener, RegistrationStateChangeListener, OperationSet, OperationSetServerStoredAccountInfo

public class OperationSetServerStoredAccountInfoSipImpl
extends AbstractOperationSetServerStoredAccountInfo
implements RegistrationStateChangeListener

SIP server stored account information. Supports the user avatar during pres-content specification.

Author:
Grigorii Balutsel

Constructor Summary
OperationSetServerStoredAccountInfoSipImpl(ProtocolProviderServiceSipImpl provider)
          Creates this op.set.
 
Method Summary
 void addDetail(ServerStoredDetails.GenericDetail detail)
          Adds the specified detail to the list of details registered on-line for this account.
 void addDetail(ServerStoredDetails.GenericDetail detail, boolean fireChangeEvents)
          Adds the specified detail to the list of details registered on-line for this account.
 Iterator<ServerStoredDetails.GenericDetail> getAllAvailableDetails()
          Returns all details currently available and set for our account.
 Iterator<ServerStoredDetails.GenericDetail> getDetails(Class<? extends ServerStoredDetails.GenericDetail> detailClass)
          Returns an iterator over all details that are instances of exactly the same class as the one specified.
 Iterator<ServerStoredDetails.GenericDetail> getDetailsAndDescendants(Class<? extends ServerStoredDetails.GenericDetail> detailClass)
          Returns an iterator over all details of the specified class.
 int getMaxDetailInstances(Class<? extends ServerStoredDetails.GenericDetail> detailClass)
          The method returns the number of instances supported for a particular detail type.
 Iterator<Class<? extends ServerStoredDetails.GenericDetail>> getSupportedDetailTypes()
          Returns all detail Class-es that the underlying implementation supports setting.
 boolean isDetailClassSupported(Class<? extends ServerStoredDetails.GenericDetail> detailClass)
          Determines whether a detail class represents a detail supported by the underlying implementation or not.
 void registrationStateChanged(RegistrationStateChangeEvent evt)
          Lister method for protocol provider registration event.
 boolean removeDetail(ServerStoredDetails.GenericDetail detail)
          Removes the specified detail from the list of details stored online for this account.
 boolean replaceDetail(ServerStoredDetails.GenericDetail currentDetailValue, ServerStoredDetails.GenericDetail newDetailValue)
          Replaces the currentDetailValue detail with newDetailValue and returns true if the operation was a success or false if currentDetailValue did not previously exist (in this case an additional call to addDetail is required).
(package private)  void setOurDisplayName(String newDisplayName)
          Changes the display name string.
 
Methods inherited from class net.java.sip.communicator.service.protocol.AbstractOperationSetServerStoredAccountInfo
addServerStoredDetailsChangeListener, fireServerStoredDetailsChangeEvent, removeServerStoredDetailsChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperationSetServerStoredAccountInfoSipImpl

public OperationSetServerStoredAccountInfoSipImpl(ProtocolProviderServiceSipImpl provider)
Creates this op.set.

Parameters:
provider - the parent provider.
Method Detail

getDetailsAndDescendants

public Iterator<ServerStoredDetails.GenericDetail> getDetailsAndDescendants(Class<? extends ServerStoredDetails.GenericDetail> detailClass)
Returns an iterator over all details of the specified class.

Specified by:
getDetailsAndDescendants in interface OperationSetServerStoredAccountInfo
Parameters:
detailClass - one of the detail classes defined in the ServerStoredDetails class, indicating the kind of details we're interested in.
Returns:
a java.util.Iterator over all details that are instances or descendants of the specified class.

getDetails

public Iterator<ServerStoredDetails.GenericDetail> getDetails(Class<? extends ServerStoredDetails.GenericDetail> detailClass)
Returns an iterator over all details that are instances of exactly the same class as the one specified.

Specified by:
getDetails in interface OperationSetServerStoredAccountInfo
Parameters:
detailClass - one of the detail classes defined in the ServerStoredDetails class, indicating the kind of details we're interested in.
Returns:
a java.util.Iterator over all details of specified class.

getAllAvailableDetails

public Iterator<ServerStoredDetails.GenericDetail> getAllAvailableDetails()
Returns all details currently available and set for our account.

Specified by:
getAllAvailableDetails in interface OperationSetServerStoredAccountInfo
Returns:
a java.util.Iterator over all details currently set our account.

getSupportedDetailTypes

public Iterator<Class<? extends ServerStoredDetails.GenericDetail>> getSupportedDetailTypes()
Returns all detail Class-es that the underlying implementation supports setting.

Specified by:
getSupportedDetailTypes in interface OperationSetServerStoredAccountInfo
Returns:
a java.util.Iterator over all detail classes supported by the implementation.

isDetailClassSupported

public boolean isDetailClassSupported(Class<? extends ServerStoredDetails.GenericDetail> detailClass)
Determines whether a detail class represents a detail supported by the underlying implementation or not.

Specified by:
isDetailClassSupported in interface OperationSetServerStoredAccountInfo
Parameters:
detailClass - the class the support for which we'd like to determine.
Returns:
true if the underlying implementation supports setting details of this type and false otherwise.

getMaxDetailInstances

public int getMaxDetailInstances(Class<? extends ServerStoredDetails.GenericDetail> detailClass)
The method returns the number of instances supported for a particular detail type.

Specified by:
getMaxDetailInstances in interface OperationSetServerStoredAccountInfo
Parameters:
detailClass - GenericDetail subclass
Returns:
int the maximum number of detail instances.

addDetail

public void addDetail(ServerStoredDetails.GenericDetail detail)
               throws IllegalArgumentException,
                      OperationFailedException,
                      ArrayIndexOutOfBoundsException
Adds the specified detail to the list of details registered on-line for this account.

Specified by:
addDetail in interface OperationSetServerStoredAccountInfo
Parameters:
detail - the detail that we'd like registered on the server.
Throws:
IllegalArgumentException - if such a detail already exists and its max instances number has been atteined or if the underlying implementation does not support setting details of the corresponding class.
OperationFailedException - with code Network Failure if putting the new value online has failed.
ArrayIndexOutOfBoundsException - if the number of instances currently registered by the application is already equal to the maximum number of supported instances.

addDetail

public void addDetail(ServerStoredDetails.GenericDetail detail,
                      boolean fireChangeEvents)
               throws IllegalArgumentException,
                      OperationFailedException,
                      ArrayIndexOutOfBoundsException
Adds the specified detail to the list of details registered on-line for this account.

Parameters:
detail - the detail that we'd like registered on the server.
fireChangeEvents - whether to fire change events.
Throws:
IllegalArgumentException - if such a detail already exists and its max instances number has been atteined or if the underlying implementation does not support setting details of the corresponding class.
OperationFailedException - with code Network Failure if putting the new value online has failed.
ArrayIndexOutOfBoundsException - if the number of instances currently registered by the application is already equal to the maximum number of supported instances.

removeDetail

public boolean removeDetail(ServerStoredDetails.GenericDetail detail)
                     throws OperationFailedException
Removes the specified detail from the list of details stored online for this account.

Specified by:
removeDetail in interface OperationSetServerStoredAccountInfo
Parameters:
detail - the detail to remove
Returns:
true if the specified detail existed and was successfully removed and false otherwise.
Throws:
OperationFailedException - with code Network Failure if removing the detail from the server has failed

replaceDetail

public boolean replaceDetail(ServerStoredDetails.GenericDetail currentDetailValue,
                             ServerStoredDetails.GenericDetail newDetailValue)
                      throws ClassCastException,
                             OperationFailedException
Replaces the currentDetailValue detail with newDetailValue and returns true if the operation was a success or false if currentDetailValue did not previously exist (in this case an additional call to addDetail is required).

Specified by:
replaceDetail in interface OperationSetServerStoredAccountInfo
Parameters:
currentDetailValue - the detail value we'd like to replace.
newDetailValue - the value of the detail that we'd like to replace currentDetailValue with.
Returns:
true if the operation was a success or false if currentDetailValue did not previously exist (in this case an additional call to addDetail is required)
Throws:
ClassCastException - if newDetailValue is not an instance of the same class as currentDetailValue.
OperationFailedException - with code Network Failure if putting the new value back online has failed

registrationStateChanged

public void registrationStateChanged(RegistrationStateChangeEvent evt)
Lister method for protocol provider registration event. If state is UNREGISTERED or CONNECTION_FAILED it will clear the cache.

Specified by:
registrationStateChanged in interface RegistrationStateChangeListener
Parameters:
evt - the event describing the status change.

setOurDisplayName

void setOurDisplayName(String newDisplayName)
Changes the display name string.


Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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