Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.jabber
Class OperationSetBasicTelephonyJabberImpl

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.media.AbstractOperationSetBasicTelephony<ProtocolProviderServiceJabberImpl>
      extended by net.java.sip.communicator.impl.protocol.jabber.OperationSetBasicTelephonyJabberImpl
All Implemented Interfaces:
EventListener, RegistrationStateChangeListener, OperationSet, OperationSetAdvancedTelephony<ProtocolProviderServiceJabberImpl>, OperationSetBasicTelephony<ProtocolProviderServiceJabberImpl>, OperationSetSecureTelephony, OperationSetSecureZrtpTelephony, org.jivesoftware.smack.filter.PacketFilter, org.jivesoftware.smack.PacketListener

public class OperationSetBasicTelephonyJabberImpl
extends AbstractOperationSetBasicTelephony<ProtocolProviderServiceJabberImpl>
implements RegistrationStateChangeListener, org.jivesoftware.smack.PacketListener, org.jivesoftware.smack.filter.PacketFilter, OperationSetSecureZrtpTelephony, OperationSetAdvancedTelephony<ProtocolProviderServiceJabberImpl>

Implements all call management logic and exports basic telephony support by implementing OperationSetBasicTelephony.

Author:
Emil Ivov, Symphorien Wanko, Lyubomir Marinov, Sebastien Vincent

Field Summary
 
Fields inherited from interface net.java.sip.communicator.service.protocol.OperationSetBasicTelephony
MAX_MEDIA_PORT_NUMBER_PROPERTY_NAME, MIN_MEDIA_PORT_NUMBER_PROPERTY_NAME
 
Constructor Summary
OperationSetBasicTelephonyJabberImpl(ProtocolProviderServiceJabberImpl protocolProvider)
          Creates a new instance.
 
Method Summary
 boolean accept(org.jivesoftware.smack.packet.Packet packet)
          Tests whether or not the specified packet should be handled by this operation set.
 void answerCallPeer(CallPeer peer)
          Implements method answerCallPeer from OperationSetBasicTelephony.
 Call createCall(Contact callee)
          Creates a new Call and invites a specific CallPeer to it given by her Contact.
 Call createCall(Contact callee, CallGroup group)
          Creates a new Call and invites a specific CallPeer to it given by her Contact.
 Call createCall(String callee)
          Creates a new Call and invites a specific CallPeer to it given by her String URI.
 Call createCall(String callee, CallGroup group)
          Creates a new Call and invites a specific CallPeer to it given by her String URI.
(package private)  AbstractCallPeer<?,?> createOutgoingCall(CallJabberImpl call, String calleeAddress)
          Init and establish the specified call.
(package private)  AbstractCallPeer<?,?> createOutgoingCall(CallJabberImpl call, String calleeAddress, Iterable<org.jivesoftware.smack.packet.PacketExtension> sessionInitiateExtensions)
          Init and establish the specified call.
 Iterator<CallJabberImpl> getActiveCalls()
          Returns an iterator over all currently active calls.
protected  ActiveCallsRepositoryJabberImpl getActiveCallsRepository()
          Returns a reference to the ActiveCallsRepositoryJabberImpl that we are currently using.
(package private)  String getFullCalleeURI(String calleeAddress)
          Gets the full callee URI for a specific callee address.
 Iterator<CallGTalkImpl> getGTalkActiveCalls()
          Returns an iterator over all currently Google Talk active calls.
protected  ActiveCallsRepositoryGTalkImpl getGTalkActiveCallsRepository()
          Returns a reference to the ActiveCallsRepositoryGTalkImpl that we are currently using.
 ProtocolProviderServiceJabberImpl getProtocolProvider()
          Returns the protocol provider that this operation set belongs to.
 void hangupCallPeer(CallPeer peer)
          Ends the call with the specified peer.
 boolean isSecure(CallPeer peer)
          Gets the secure state of the call session in which a specific peer is involved
 void processPacket(org.jivesoftware.smack.packet.Packet packet)
          Handles incoming jingle packets and passes them to the corresponding method based on their action.
 void putOffHold(CallPeer peer)
          Resumes communication with a call peer previously put on hold.
 void putOnHold(CallPeer peer)
          Puts the specified CallPeer "on hold".
 void registrationStateChanged(RegistrationStateChangeEvent evt)
          Implementation of method registrationStateChange from interface RegistrationStateChangeListener for setting up (or down) our JingleManager when an XMPPConnection is available
 void setMute(Call call, boolean mute)
          Sets the mute state of the CallJabberImpl.
 void setTransferAuthority(TransferAuthority authority)
          Transfer authority used for interacting with user for unknown calls and the requests for transfer.
 void shutdown()
          Closes all active calls.
 void transfer(CallPeer peer, CallPeer target)
          Transfers (in the sense of call transfer) a specific CallPeer to a specific callee address which already participates in an active Call.
 void transfer(CallPeer peer, String target)
          Transfers (in the sense of call transfer) a specific CallPeer to a specific callee address which may or may not already be participating in an active Call.
 
Methods inherited from class net.java.sip.communicator.service.protocol.media.AbstractOperationSetBasicTelephony
addCallListener, createRecorder, fireCallEvent, fireCallEvent, removeCallListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.java.sip.communicator.service.protocol.OperationSetBasicTelephony
addCallListener, createRecorder, removeCallListener
 

Constructor Detail

OperationSetBasicTelephonyJabberImpl

public OperationSetBasicTelephonyJabberImpl(ProtocolProviderServiceJabberImpl protocolProvider)
Creates a new instance.

Parameters:
protocolProvider - a reference to the ProtocolProviderServiceJabberImpl instance that created us.
Method Detail

registrationStateChanged

public void registrationStateChanged(RegistrationStateChangeEvent evt)
Implementation of method registrationStateChange from interface RegistrationStateChangeListener for setting up (or down) our JingleManager when an XMPPConnection is available

Specified by:
registrationStateChanged in interface RegistrationStateChangeListener
Parameters:
evt - the event received

createCall

public Call createCall(String callee,
                       CallGroup group)
                throws OperationFailedException
Creates a new Call and invites a specific CallPeer to it given by her String URI.

Specified by:
createCall in interface OperationSetBasicTelephony<ProtocolProviderServiceJabberImpl>
Parameters:
callee - the address of the callee who we should invite to a new Call
group - CallGroup from which the Call will belong
Returns:
a newly created Call. The specified callee is available in the Call as a CallPeer
Throws:
OperationFailedException - with the corresponding code if we fail to create the call
See Also:
OperationSetBasicTelephony.createCall(String)

createCall

public Call createCall(Contact callee,
                       CallGroup group)
                throws OperationFailedException
Creates a new Call and invites a specific CallPeer to it given by her Contact.

Specified by:
createCall in interface OperationSetBasicTelephony<ProtocolProviderServiceJabberImpl>
Parameters:
callee - the address of the callee who we should invite to a new call
group - CallGroup from which the Call will belong
Returns:
a newly created Call. The specified callee is available in the Call as a CallPeer
Throws:
OperationFailedException - with the corresponding code if we fail to create the call
See Also:
OperationSetBasicTelephony.createCall(Contact)

createCall

public Call createCall(String callee)
                throws OperationFailedException
Creates a new Call and invites a specific CallPeer to it given by her String URI.

Specified by:
createCall in interface OperationSetBasicTelephony<ProtocolProviderServiceJabberImpl>
Parameters:
callee - the address of the callee who we should invite to a new Call
Returns:
a newly created Call. The specified callee is available in the Call as a CallPeer
Throws:
OperationFailedException - with the corresponding code if we fail to create the call
See Also:
OperationSetBasicTelephony.createCall(String)

createCall

public Call createCall(Contact callee)
                throws OperationFailedException
Creates a new Call and invites a specific CallPeer to it given by her Contact.

Specified by:
createCall in interface OperationSetBasicTelephony<ProtocolProviderServiceJabberImpl>
Parameters:
callee - the address of the callee who we should invite to a new call
Returns:
a newly created Call. The specified callee is available in the Call as a CallPeer
Throws:
OperationFailedException - with the corresponding code if we fail to create the call
See Also:
OperationSetBasicTelephony.createCall(Contact)

createOutgoingCall

AbstractCallPeer<?,?> createOutgoingCall(CallJabberImpl call,
                                         String calleeAddress)
                                   throws OperationFailedException
Init and establish the specified call.

Parameters:
call - the CallJabberImpl that will be used to initiate the call
calleeAddress - the address of the callee that we'd like to connect with.
Returns:
the CallPeer that represented by the specified uri. All following state change events will be delivered through that call peer. The Call that this peer is a member of could be retrieved from the CallPeer instance with the use of the corresponding method.
Throws:
OperationFailedException - with the corresponding code if we fail to create the call.

createOutgoingCall

AbstractCallPeer<?,?> createOutgoingCall(CallJabberImpl call,
                                         String calleeAddress,
                                         Iterable<org.jivesoftware.smack.packet.PacketExtension> sessionInitiateExtensions)
                                   throws OperationFailedException
Init and establish the specified call.

Parameters:
call - the CallJabberImpl that will be used to initiate the call
calleeAddress - the address of the callee that we'd like to connect with.
sessionInitiateExtensions - a collection of additional and optional PacketExtensions to be added to the session-initiate JingleIQ which is to init the specified call
Returns:
the CallPeer that represented by the specified uri. All following state change events will be delivered through that call peer. The Call that this peer is a member of could be retrieved from the CallPeer instance with the use of the corresponding method.
Throws:
OperationFailedException - with the corresponding code if we fail to create the call.

getFullCalleeURI

String getFullCalleeURI(String calleeAddress)
Gets the full callee URI for a specific callee address.

Parameters:
calleeAddress - the callee address to get the full callee URI for
Returns:
the full callee URI for the specified calleeAddress

getActiveCalls

public Iterator<CallJabberImpl> getActiveCalls()
Returns an iterator over all currently active calls.

Specified by:
getActiveCalls in interface OperationSetBasicTelephony<ProtocolProviderServiceJabberImpl>
Returns:
an iterator over all currently active calls.

getGTalkActiveCalls

public Iterator<CallGTalkImpl> getGTalkActiveCalls()
Returns an iterator over all currently Google Talk active calls.

Returns:
an iterator over all currently Google Talk active calls.

putOffHold

public void putOffHold(CallPeer peer)
                throws OperationFailedException
Resumes communication with a call peer previously put on hold.

Specified by:
putOffHold in interface OperationSetBasicTelephony<ProtocolProviderServiceJabberImpl>
Parameters:
peer - the call peer to put on hold.
Throws:
OperationFailedException - if we fail to send the "hold" message.

putOnHold

public void putOnHold(CallPeer peer)
               throws OperationFailedException
Puts the specified CallPeer "on hold".

Specified by:
putOnHold in interface OperationSetBasicTelephony<ProtocolProviderServiceJabberImpl>
Parameters:
peer - the peer that we'd like to put on hold.
Throws:
OperationFailedException - if we fail to send the "hold" message.

setMute

public void setMute(Call call,
                    boolean mute)
Sets the mute state of the CallJabberImpl.

Specified by:
setMute in interface OperationSetBasicTelephony<ProtocolProviderServiceJabberImpl>
Overrides:
setMute in class AbstractOperationSetBasicTelephony<ProtocolProviderServiceJabberImpl>
Parameters:
call - the CallJabberImpl whose mute state is set
mute - true to mute the call streams being sent to peers; otherwise, false

hangupCallPeer

public void hangupCallPeer(CallPeer peer)
                    throws ClassCastException,
                           OperationFailedException
Ends the call with the specified peer.

Specified by:
hangupCallPeer in interface OperationSetBasicTelephony<ProtocolProviderServiceJabberImpl>
Parameters:
peer - the peer that we'd like to hang up on.
Throws:
ClassCastException - if peer is not an instance of this CallPeerSipImpl.
OperationFailedException - if we fail to terminate the call.

answerCallPeer

public void answerCallPeer(CallPeer peer)
                    throws OperationFailedException
Implements method answerCallPeer from OperationSetBasicTelephony.

Specified by:
answerCallPeer in interface OperationSetBasicTelephony<ProtocolProviderServiceJabberImpl>
Parameters:
peer - the call peer that we want to answer
Throws:
OperationFailedException - if we fails to answer

shutdown

public void shutdown()
Closes all active calls. And releases resources.


accept

public boolean accept(org.jivesoftware.smack.packet.Packet packet)
Tests whether or not the specified packet should be handled by this operation set. This method is called by smack prior to packet delivery and it would only accept JingleIQs that are either session initiations with RTP content or belong to sessions that are already handled by this operation set.

Specified by:
accept in interface org.jivesoftware.smack.filter.PacketFilter
Parameters:
packet - the packet to test.
Returns:
true if and only if packet passes the filter.

processPacket

public void processPacket(org.jivesoftware.smack.packet.Packet packet)
Handles incoming jingle packets and passes them to the corresponding method based on their action.

Specified by:
processPacket in interface org.jivesoftware.smack.PacketListener
Parameters:
packet - the packet to process.

getActiveCallsRepository

protected ActiveCallsRepositoryJabberImpl getActiveCallsRepository()
Returns a reference to the ActiveCallsRepositoryJabberImpl that we are currently using.

Returns:
a reference to the ActiveCallsRepositoryJabberImpl that we are currently using.

getGTalkActiveCallsRepository

protected ActiveCallsRepositoryGTalkImpl getGTalkActiveCallsRepository()
Returns a reference to the ActiveCallsRepositoryGTalkImpl that we are currently using.

Returns:
a reference to the ActiveCallsRepositoryGTalkImpl that we are currently using.

getProtocolProvider

public ProtocolProviderServiceJabberImpl getProtocolProvider()
Returns the protocol provider that this operation set belongs to.

Specified by:
getProtocolProvider in interface OperationSetBasicTelephony<ProtocolProviderServiceJabberImpl>
Returns:
a reference to the ProtocolProviderService that created this operation set.

isSecure

public boolean isSecure(CallPeer peer)
Gets the secure state of the call session in which a specific peer is involved

Specified by:
isSecure in interface OperationSetSecureTelephony
Parameters:
peer - the peer for who the call state is required
Returns:
the call state

transfer

public void transfer(CallPeer peer,
                     CallPeer target)
              throws OperationFailedException
Transfers (in the sense of call transfer) a specific CallPeer to a specific callee address which already participates in an active Call.

The method is suitable for providing the implementation of attended call transfer (though no such requirement is imposed).

Specified by:
transfer in interface OperationSetAdvancedTelephony<ProtocolProviderServiceJabberImpl>
Parameters:
peer - the CallPeer to be transfered to the specified callee address
target - the address in the form of CallPeer of the callee to transfer peer to
Throws:
OperationFailedException - if something goes wrong
See Also:
OperationSetAdvancedTelephony.transfer(CallPeer, CallPeer)

transfer

public void transfer(CallPeer peer,
                     String target)
              throws OperationFailedException
Transfers (in the sense of call transfer) a specific CallPeer to a specific callee address which may or may not already be participating in an active Call.

The method is suitable for providing the implementation of unattended call transfer (though no such requirement is imposed).

Specified by:
transfer in interface OperationSetAdvancedTelephony<ProtocolProviderServiceJabberImpl>
Parameters:
peer - the CallPeer to be transfered to the specified callee address
target - the address of the callee to transfer peer to
Throws:
OperationFailedException - if something goes wrong
See Also:
OperationSetAdvancedTelephony.transfer(CallPeer, String)

setTransferAuthority

public void setTransferAuthority(TransferAuthority authority)
Transfer authority used for interacting with user for unknown calls and the requests for transfer.

Specified by:
setTransferAuthority in interface OperationSetAdvancedTelephony<ProtocolProviderServiceJabberImpl>
Parameters:
authority - transfer authority.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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