Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.service.protocol
Class ActiveCallsRepository<T extends Call,U extends OperationSetBasicTelephony<? extends ProtocolProviderService>>

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.event.CallChangeAdapter
      extended by net.java.sip.communicator.service.protocol.ActiveCallsRepository<T,U>
Type Parameters:
T - Call
U - OperationSetBasicTelephony
All Implemented Interfaces:
EventListener, CallChangeListener
Direct Known Subclasses:
ActiveCallsRepositoryGTalkImpl, ActiveCallsRepositoryJabberImpl, ActiveCallsRepositorySipImpl

public abstract class ActiveCallsRepository<T extends Call,U extends OperationSetBasicTelephony<? extends ProtocolProviderService>>
extends CallChangeAdapter

Keeps a list of all calls currently active and maintained by this protocol provider. Offers methods for finding a call by its ID, peer session and others. This class is meant for use by protocol implementations and cannot be accessed from other bundles.

Author:
Emil Ivov

Field Summary
protected  U parentOperationSet
          The operation set that created us.
 
Constructor Summary
ActiveCallsRepository(U opSet)
          Creates a new instance of this repository.
 
Method Summary
 void addCall(T call)
          Adds the specified call to the list of calls tracked by this repository.
 void callStateChanged(CallChangeEvent evt)
          If evt indicates that the call has been ended we remove it from the repository.
protected abstract  void fireCallEvent(int eventID, Call sourceCall)
          Creates and dispatches a CallEvent notifying registered listeners that an event with id eventID has occurred on sourceCall.
 int getActiveCallCount()
          Returns the number of calls currently tracked by this repository.
 Iterator<T> getActiveCalls()
          Returns an iterator over all currently active (non-ended) calls.
 
Methods inherited from class net.java.sip.communicator.service.protocol.event.CallChangeAdapter
callPeerAdded, callPeerRemoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parentOperationSet

protected final U extends OperationSetBasicTelephony<? extends ProtocolProviderService> parentOperationSet
The operation set that created us. Instance is mainly used for firing events when necessary.

Constructor Detail

ActiveCallsRepository

public ActiveCallsRepository(U opSet)
Creates a new instance of this repository.

Parameters:
opSet - a reference to the AbstractOperationSetBasicTelephony extension that created us.
Method Detail

addCall

public void addCall(T call)
Adds the specified call to the list of calls tracked by this repository.

Parameters:
call - CallSipImpl

callStateChanged

public void callStateChanged(CallChangeEvent evt)
If evt indicates that the call has been ended we remove it from the repository.

Specified by:
callStateChanged in interface CallChangeListener
Overrides:
callStateChanged in class CallChangeAdapter
Parameters:
evt - the CallChangeEvent instance containing the source calls and its old and new state.

getActiveCalls

public Iterator<T> getActiveCalls()
Returns an iterator over all currently active (non-ended) calls.

Returns:
an iterator over all currently active (non-ended) calls.

getActiveCallCount

public int getActiveCallCount()
Returns the number of calls currently tracked by this repository.

Returns:
the number of calls currently tracked by this repository.

fireCallEvent

protected abstract void fireCallEvent(int eventID,
                                      Call sourceCall)
Creates and dispatches a CallEvent notifying registered listeners that an event with id eventID has occurred on sourceCall.

TODO The method is ugly because it can be implemented if parentOperationSet is an AbstractOperationSetBasicTelephony. But after the move of the latter in the .service.protocol.media package, it is not visible here.

Parameters:
eventID - the ID of the event to dispatch
sourceCall - the call on which the event has occurred.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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