Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.callhistory
Class CallHistoryServiceImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.callhistory.CallHistoryServiceImpl
All Implemented Interfaces:
EventListener, CallHistoryService, CallListener, org.osgi.framework.ServiceListener

public class CallHistoryServiceImpl
extends Object
implements CallHistoryService, CallListener, org.osgi.framework.ServiceListener

The Call History Service stores info about the calls made. Logs calls info for all protocol providers that support basic telephony (i.e. those that implement OperationSetBasicTelephony).

Author:
Damian Minkov, Lubomir Marinov

Constructor Summary
CallHistoryServiceImpl()
           
 
Method Summary
 void addSearchProgressListener(CallHistorySearchProgressListener listener)
          Adding progress listener for monitoring progress of search process
 void callEnded(CallEvent event)
          CallListener implementation for call endings
(package private) static CallRecord convertHistoryRecordToCallRecord(HistoryRecord hr)
          Used to convert HistoryRecord in CallReord and CallPeerRecord which are returned by the finder methods
 Collection<CallRecord> findByEndDate(Date endDate)
          Returns all the calls made before the given date
 Collection<CallRecord> findByEndDate(MetaContact contact, Date endDate)
          Returns all the calls made by all the contacts in the supplied metacontact before the given date
 CallHistoryQuery findByPeer(String address, int recordCount)
          Find the calls made by the supplied peer address
 Collection<CallRecord> findByPeriod(Date startDate, Date endDate)
          Returns all the calls made between the given dates
 Collection<CallRecord> findByPeriod(MetaContact contact, Date startDate, Date endDate)
          Returns all the calls made by all the contacts in the supplied metacontact between the given dates
 Collection<CallRecord> findByStartDate(Date startDate)
          Returns all the calls made after the given date
 Collection<CallRecord> findByStartDate(MetaContact contact, Date startDate)
          Returns all the calls made by all the contacts in the supplied contact after the given date.
 Collection<CallRecord> findLast(int count)
          Returns the supplied number of calls made
 Collection<CallRecord> findLast(MetaContact contact, int count)
          Returns the supplied number of calls by all the contacts in the supplied metacontact
 HistoryService getHistoryService()
          Returns the underlying history service.
 void incomingCallReceived(CallEvent event)
          CallListener implementation for incoming calls
 void outgoingCallCreated(CallEvent event)
          CallListener implementation for outgoing calls
 void removeSearchProgressListener(CallHistorySearchProgressListener listener)
          Removing progress listener
 void serviceChanged(org.osgi.framework.ServiceEvent serviceEvent)
          When new protocol provider is registered we check does it supports BasicTelephony and if so add a listener to it
 void setHistoryService(HistoryService historyService)
          Set the configuration service.
 void start(org.osgi.framework.BundleContext bc)
          starts the service.
 void stop(org.osgi.framework.BundleContext bc)
          stops the service.
 void unsetHistoryService(HistoryService hService)
          Remove a configuration service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CallHistoryServiceImpl

public CallHistoryServiceImpl()
Method Detail

getHistoryService

public HistoryService getHistoryService()
Returns the underlying history service.

Returns:
the underlying history service

findByStartDate

public Collection<CallRecord> findByStartDate(MetaContact contact,
                                              Date startDate)
                                       throws RuntimeException
Returns all the calls made by all the contacts in the supplied contact after the given date.

Specified by:
findByStartDate in interface CallHistoryService
Parameters:
contact - MetaContact which contacts participate in the returned calls
startDate - Date the start date of the calls
Returns:
the CallHistoryQuery, corresponding to this find
Throws:
RuntimeException

findByStartDate

public Collection<CallRecord> findByStartDate(Date startDate)
Returns all the calls made after the given date

Specified by:
findByStartDate in interface CallHistoryService
Parameters:
startDate - Date the start date of the calls
Returns:
the CallHistoryQuery, corresponding to this find
Throws:
RuntimeException

findByEndDate

public Collection<CallRecord> findByEndDate(MetaContact contact,
                                            Date endDate)
                                     throws RuntimeException
Returns all the calls made by all the contacts in the supplied metacontact before the given date

Specified by:
findByEndDate in interface CallHistoryService
Parameters:
contact - MetaContact which contacts participate in the returned calls
endDate - Date the end date of the calls
Returns:
Collection of CallRecords with CallPeerRecord
Throws:
RuntimeException

findByEndDate

public Collection<CallRecord> findByEndDate(Date endDate)
                                     throws RuntimeException
Returns all the calls made before the given date

Specified by:
findByEndDate in interface CallHistoryService
Parameters:
endDate - Date the end date of the calls
Returns:
Collection of CallRecords with CallPeerRecord
Throws:
RuntimeException

findByPeriod

public Collection<CallRecord> findByPeriod(MetaContact contact,
                                           Date startDate,
                                           Date endDate)
                                    throws RuntimeException
Returns all the calls made by all the contacts in the supplied metacontact between the given dates

Specified by:
findByPeriod in interface CallHistoryService
Parameters:
contact - MetaContact
startDate - Date the start date of the calls
endDate - Date the end date of the conversations
Returns:
Collection of CallRecords with CallPeerRecord
Throws:
RuntimeException

findByPeriod

public Collection<CallRecord> findByPeriod(Date startDate,
                                           Date endDate)
                                    throws RuntimeException
Returns all the calls made between the given dates

Specified by:
findByPeriod in interface CallHistoryService
Parameters:
startDate - Date the start date of the calls
endDate - Date the end date of the conversations
Returns:
Collection of CallRecords with CallPeerRecord
Throws:
RuntimeException

findLast

public Collection<CallRecord> findLast(MetaContact contact,
                                       int count)
                                throws RuntimeException
Returns the supplied number of calls by all the contacts in the supplied metacontact

Specified by:
findLast in interface CallHistoryService
Parameters:
contact - MetaContact which contacts participate in the returned calls
count - calls count
Returns:
Collection of CallRecords with CallPeerRecord
Throws:
RuntimeException

findLast

public Collection<CallRecord> findLast(int count)
                                throws RuntimeException
Returns the supplied number of calls made

Specified by:
findLast in interface CallHistoryService
Parameters:
count - calls count
Returns:
Collection of CallRecords with CallPeerRecord
Throws:
RuntimeException

findByPeer

public CallHistoryQuery findByPeer(String address,
                                   int recordCount)
                            throws RuntimeException
Find the calls made by the supplied peer address

Specified by:
findByPeer in interface CallHistoryService
Parameters:
address - String the address of the peer
recordCount - the number of records to return
Returns:
Collection of CallRecords with CallPeerRecord
Throws:
RuntimeException

convertHistoryRecordToCallRecord

static CallRecord convertHistoryRecordToCallRecord(HistoryRecord hr)
Used to convert HistoryRecord in CallReord and CallPeerRecord which are returned by the finder methods

Parameters:
hr - HistoryRecord
Returns:
Object CallRecord

start

public void start(org.osgi.framework.BundleContext bc)
starts the service. Check the current registerd protocol providers which supports BasicTelephony and adds calls listener to them

Parameters:
bc - BundleContext

stop

public void stop(org.osgi.framework.BundleContext bc)
stops the service.

Parameters:
bc - BundleContext

setHistoryService

public void setHistoryService(HistoryService historyService)
                       throws IllegalArgumentException,
                              IOException
Set the configuration service.

Parameters:
historyService - HistoryService
Throws:
IOException
IllegalArgumentException

unsetHistoryService

public void unsetHistoryService(HistoryService hService)
Remove a configuration service.

Parameters:
hService - HistoryService

serviceChanged

public void serviceChanged(org.osgi.framework.ServiceEvent serviceEvent)
When new protocol provider is registered we check does it supports BasicTelephony and if so add a listener to it

Specified by:
serviceChanged in interface org.osgi.framework.ServiceListener
Parameters:
serviceEvent - ServiceEvent

addSearchProgressListener

public void addSearchProgressListener(CallHistorySearchProgressListener listener)
Adding progress listener for monitoring progress of search process

Specified by:
addSearchProgressListener in interface CallHistoryService
Parameters:
listener - HistorySearchProgressListener

removeSearchProgressListener

public void removeSearchProgressListener(CallHistorySearchProgressListener listener)
Removing progress listener

Specified by:
removeSearchProgressListener in interface CallHistoryService
Parameters:
listener - HistorySearchProgressListener

incomingCallReceived

public void incomingCallReceived(CallEvent event)
CallListener implementation for incoming calls

Specified by:
incomingCallReceived in interface CallListener
Parameters:
event - CallEvent

outgoingCallCreated

public void outgoingCallCreated(CallEvent event)
CallListener implementation for outgoing calls

Specified by:
outgoingCallCreated in interface CallListener
Parameters:
event - CallEvent

callEnded

public void callEnded(CallEvent event)
CallListener implementation for call endings

Specified by:
callEnded in interface CallListener
Parameters:
event - CallEvent

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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