net.java.sip.communicator.plugin.scphone
Class SCPhoneActivator

java.lang.Object
  extended by net.java.sip.communicator.plugin.scphone.SCPhoneActivator
All Implemented Interfaces:
java.util.EventListener, SCPhoneListener, net.java.sip.communicator.service.protocol.event.CallListener, net.java.sip.communicator.service.protocol.event.CallParticipantListener

public class SCPhoneActivator
extends java.lang.Object
implements SCPhoneListener, net.java.sip.communicator.service.protocol.event.CallListener, net.java.sip.communicator.service.protocol.event.CallParticipantListener

The responsability of the scphone plugin is to manage interactivity with an usb phone by linking it to sc. It gives to the user the ability to make and answer calls from a usb phone device, without using the sc GUI or headphones.


Field Summary
private  BundleContext bundleContext
           
private  net.java.sip.communicator.service.callhistory.CallHistoryService callHS
          used to retrive passsed and/or missed calls
private  java.util.Hashtable contactList
          Hastable mapping a user address to the Contact representing that user
private  net.java.sip.communicator.service.protocol.Call currentCall
          call currently runing on the phone
private  java.util.Hashtable histCall
          Hastable mapping a call ids to a CallParticipantRecord
private  int histCallCount
          number of callrecord to retrieve when needed
private  net.java.sip.communicator.util.Logger logger
           
private  SCPhone phone
          The SCPhone object that communicate with the phone device
private  java.util.Vector ppsVector
          A vector of ProtocolProviderServices which supports OperationSetBasicTelephony
private  net.java.sip.communicator.service.protocol.ProtocolProviderService primaryProtocolProvider
          We use this protocol provider for issue calls when there is not a default protocol provider.
private  java.lang.String usernameList
          A String containing, comma separated userfriendly username of contacts
 
Constructor Summary
SCPhoneActivator()
           
 
Method Summary
 void callEnded(net.java.sip.communicator.service.protocol.event.CallEvent event)
          CallListener implementation for callEnded
private  java.lang.StringBuffer getUsernamesList(net.java.sip.communicator.service.protocol.ContactGroup cg)
          compute a comma separated string list of contacts's usernames in a specified group.
private  void handleProviderAdded(net.java.sip.communicator.service.protocol.ProtocolProviderService provider)
          Used to attach the phone manager to existing or just registered protocol provider.
private  void handleProviderRemoved(net.java.sip.communicator.service.protocol.ProtocolProviderService provider)
          Removes the specified provider from the list of currently known providers and ignores all the calls made by it
private  void hangup()
          to terminate a call
 void incomingCallReceived(net.java.sip.communicator.service.protocol.event.CallEvent event)
          CallListener implementation for incomingCallReceived
private  void makeCall(java.lang.String user)
          make a call using appropriate protocol provider.
 void outgoingCallCreated(net.java.sip.communicator.service.protocol.event.CallEvent event)
          CallListener implementation for outgoingCallCreated
 void participantAddressChanged(net.java.sip.communicator.service.protocol.event.CallParticipantChangeEvent event)
          CallParticipantListener implementation for participantAddressChanged
 void participantDisplayNameChanged(net.java.sip.communicator.service.protocol.event.CallParticipantChangeEvent event)
          CallParticipantListener implementation for participantDisplayNameChanged
 void participantImageChanged(net.java.sip.communicator.service.protocol.event.CallParticipantChangeEvent event)
          CallParticipantListener implementation for participantAddressChanged
 void participantStateChanged(net.java.sip.communicator.service.protocol.event.CallParticipantChangeEvent event)
          CallParticipantListener implementation for participantStateChanged
 void participantTransportAddressChanged(net.java.sip.communicator.service.protocol.event.CallParticipantChangeEvent event)
          CallParticipantListener implementation for participantStateChanged
 void phoneCommandReceived(SCPhoneMessageEvent event)
          Implementation of SCPhoneListener's method, called when a message is recived from the phone.
 void phoneCommandSent(SCPhoneMessageEvent event)
          Implementation of SCPhoneListener's method, called when a message has been sent to the phone
 void serviceChanged(ServiceEvent serviceEvent)
          When new protocol provider is registered we check if it supports BasicTelephony and if so add a listener to it
 void start(BundleContext bc)
          Start the usb phone plugin
 void statusChanged(SCPhoneStatusEvent event)
          Implementation of SCPhoneListener's method, called when the phone become available
 void stop(BundleContext bc)
          Stop the usb phone plugin by "closing" the connexion with the phone device
private  void takeCall()
          Answer an incoming call.
private  void updateContactList()
          setup the contactlist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

phone

private SCPhone phone
The SCPhone object that communicate with the phone device


bundleContext

private BundleContext bundleContext

logger

private net.java.sip.communicator.util.Logger logger

ppsVector

private java.util.Vector ppsVector
A vector of ProtocolProviderServices which supports OperationSetBasicTelephony


currentCall

private net.java.sip.communicator.service.protocol.Call currentCall
call currently runing on the phone


contactList

private java.util.Hashtable contactList
Hastable mapping a user address to the Contact representing that user


usernameList

private java.lang.String usernameList
A String containing, comma separated userfriendly username of contacts


callHS

private net.java.sip.communicator.service.callhistory.CallHistoryService callHS
used to retrive passsed and/or missed calls


histCallCount

private int histCallCount
number of callrecord to retrieve when needed


histCall

private java.util.Hashtable histCall
Hastable mapping a call ids to a CallParticipantRecord


primaryProtocolProvider

private net.java.sip.communicator.service.protocol.ProtocolProviderService primaryProtocolProvider
We use this protocol provider for issue calls when there is not a default protocol provider. The reason is that each contact belong to a protocol provider. But, when the destination that we currently try to join do not match a known protocol provider, (user typed phone number for example) we will choose this one to process the call. the primaryProtocolProvider is arbitrarily choosed among available protocol provider.

Constructor Detail

SCPhoneActivator

public SCPhoneActivator()
Method Detail

start

public void start(BundleContext bc)
           throws java.lang.Exception
Start the usb phone plugin

Parameters:
bc - BundleContext
Throws:
java.lang.Exception

stop

public void stop(BundleContext bc)
          throws java.lang.Exception
Stop the usb phone plugin by "closing" the connexion with the phone device

Parameters:
bc - BundleContext
Throws:
java.lang.Exception

getUsernamesList

private java.lang.StringBuffer getUsernamesList(net.java.sip.communicator.service.protocol.ContactGroup cg)
compute a comma separated string list of contacts's usernames in a specified group. retrieve also contact in subgroups.

Parameters:
group - the group from which we want to retrieve contacts
Returns:
a string containing usenames of contacts in this group,

updateContactList

private void updateContactList()
setup the contactlist


callEnded

public void callEnded(net.java.sip.communicator.service.protocol.event.CallEvent event)
CallListener implementation for callEnded

Specified by:
callEnded in interface net.java.sip.communicator.service.protocol.event.CallListener
Parameters:
event - CallEvent

incomingCallReceived

public void incomingCallReceived(net.java.sip.communicator.service.protocol.event.CallEvent event)
CallListener implementation for incomingCallReceived

Specified by:
incomingCallReceived in interface net.java.sip.communicator.service.protocol.event.CallListener
Parameters:
event - CallEvent

outgoingCallCreated

public void outgoingCallCreated(net.java.sip.communicator.service.protocol.event.CallEvent event)
CallListener implementation for outgoingCallCreated

Specified by:
outgoingCallCreated in interface net.java.sip.communicator.service.protocol.event.CallListener
Parameters:
event - CallEvent

participantAddressChanged

public void participantAddressChanged(net.java.sip.communicator.service.protocol.event.CallParticipantChangeEvent event)
CallParticipantListener implementation for participantAddressChanged

Specified by:
participantAddressChanged in interface net.java.sip.communicator.service.protocol.event.CallParticipantListener
Parameters:
event - CallParticipantChangeEvent

participantDisplayNameChanged

public void participantDisplayNameChanged(net.java.sip.communicator.service.protocol.event.CallParticipantChangeEvent event)
CallParticipantListener implementation for participantDisplayNameChanged

Specified by:
participantDisplayNameChanged in interface net.java.sip.communicator.service.protocol.event.CallParticipantListener
Parameters:
event - CallParticipantChangeEvent

participantImageChanged

public void participantImageChanged(net.java.sip.communicator.service.protocol.event.CallParticipantChangeEvent event)
CallParticipantListener implementation for participantAddressChanged

Specified by:
participantImageChanged in interface net.java.sip.communicator.service.protocol.event.CallParticipantListener
Parameters:
event - CallParticipantChangeEvent

participantStateChanged

public void participantStateChanged(net.java.sip.communicator.service.protocol.event.CallParticipantChangeEvent event)
CallParticipantListener implementation for participantStateChanged

Specified by:
participantStateChanged in interface net.java.sip.communicator.service.protocol.event.CallParticipantListener
Parameters:
event - CallParticipantChangeEvent

participantTransportAddressChanged

public void participantTransportAddressChanged(net.java.sip.communicator.service.protocol.event.CallParticipantChangeEvent event)
CallParticipantListener implementation for participantStateChanged

Specified by:
participantTransportAddressChanged in interface net.java.sip.communicator.service.protocol.event.CallParticipantListener
Parameters:
event - CallParticipantChangeEvent

makeCall

private void makeCall(java.lang.String user)
make a call using appropriate protocol provider.

Parameters:
user - to call
See Also:
primaryProtocolProvider

takeCall

private void takeCall()
Answer an incoming call.


hangup

private void hangup()
to terminate a call

Parameters:
c - call to end

handleProviderAdded

private void handleProviderAdded(net.java.sip.communicator.service.protocol.ProtocolProviderService provider)
Used to attach the phone manager to existing or just registered protocol provider. Checks if the provider has implementation of OperationSetBasicTelephony

Parameters:
provider - ProtocolProviderService

handleProviderRemoved

private void handleProviderRemoved(net.java.sip.communicator.service.protocol.ProtocolProviderService provider)
Removes the specified provider from the list of currently known providers and ignores all the calls made by it

Parameters:
provider - the ProtocolProviderService that has been unregistered.

serviceChanged

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

Parameters:
serviceEvent - ServiceEvent

phoneCommandReceived

public void phoneCommandReceived(SCPhoneMessageEvent event)
Implementation of SCPhoneListener's method, called when a message is recived from the phone. When we receive a message, we proccess it and send, if needed, a reply to the phone device.

Specified by:
phoneCommandReceived in interface SCPhoneListener
Parameters:
event - SCPhoneMessageEvent.

phoneCommandSent

public void phoneCommandSent(SCPhoneMessageEvent event)
Implementation of SCPhoneListener's method, called when a message has been sent to the phone

Specified by:
phoneCommandSent in interface SCPhoneListener
Parameters:
event - SCPhoneMessageEvent.

statusChanged

public void statusChanged(SCPhoneStatusEvent event)
Implementation of SCPhoneListener's method, called when the phone become available

Specified by:
statusChanged in interface SCPhoneListener
Parameters:
event - SCPhoneStatusEvent.