mirror of https://github.com/sipwise/jitsi.git
Renames occurrences of callParticipant to callPeer so that it would better reflect our new Call architecture that also includes conferencing and ConferenceMembers
parent
ef884edaec
commit
51b357ed4b
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.callhistory;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.callhistory.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
* Added some setters to CallPeerRecord
|
||||
* @author Damian Minkov
|
||||
*/
|
||||
public class CallPeerRecordImpl
|
||||
extends CallPeerRecord
|
||||
{
|
||||
/**
|
||||
* Creates CallPeerRecord
|
||||
* @param peerAddress String
|
||||
* @param startTime Date
|
||||
* @param endTime Date
|
||||
*/
|
||||
public CallPeerRecordImpl(
|
||||
String peerAddress,
|
||||
Date startTime,
|
||||
Date endTime)
|
||||
{
|
||||
super(peerAddress, startTime, endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the time the peer joined the call
|
||||
* @param startTime Date
|
||||
*/
|
||||
public void setStartTime(Date startTime)
|
||||
{
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the particiapnts address
|
||||
* @param peerAddress String
|
||||
*/
|
||||
public void setPeerAddress(String peerAddress)
|
||||
{
|
||||
this.peerAddress = peerAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the time peer leaves the call
|
||||
* @param endTime Date
|
||||
*/
|
||||
public void setEndTime(Date endTime)
|
||||
{
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the peer state
|
||||
* @param state CallPeerState
|
||||
*/
|
||||
public void setState(CallPeerState state)
|
||||
{
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.call;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.callhistory.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* The <tt>GuiCallPeerRecord</tt> is meant to be used in the call history
|
||||
* to represent a history call peer record. It wraps a
|
||||
* <tt>CallPeer</tt> or a <tt>CallPeerRecord</tt> object.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class GuiCallPeerRecord
|
||||
{
|
||||
public static final String INCOMING_CALL = "IncomingCall";
|
||||
|
||||
public static final String OUTGOING_CALL = "OutgoingCall";
|
||||
|
||||
private String direction;
|
||||
|
||||
private String peerName;
|
||||
|
||||
private Date startTime;
|
||||
|
||||
private Date callDuration;
|
||||
|
||||
public GuiCallPeerRecord(String peerName,
|
||||
String direction,
|
||||
Date startTime,
|
||||
Date callDuration)
|
||||
{
|
||||
this.direction = direction;
|
||||
|
||||
this.peerName = peerName;
|
||||
|
||||
this.startTime = startTime;
|
||||
|
||||
this.callDuration = callDuration;
|
||||
}
|
||||
|
||||
public GuiCallPeerRecord(CallPeerRecord peerRecord,
|
||||
String direction)
|
||||
{
|
||||
this.direction = direction;
|
||||
|
||||
this.peerName = peerRecord.getPeerAddress();
|
||||
|
||||
this.startTime = peerRecord.getStartTime();
|
||||
|
||||
this.callDuration = GuiUtils.substractDates(
|
||||
peerRecord.getEndTime(), startTime);
|
||||
}
|
||||
|
||||
public String getDirection()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the duration of the contained peer call.
|
||||
*
|
||||
* @return the duration of the contained peer call
|
||||
*/
|
||||
public Date getDuration()
|
||||
{
|
||||
return callDuration;
|
||||
}
|
||||
|
||||
public String getPeerName()
|
||||
{
|
||||
return peerName;
|
||||
}
|
||||
|
||||
public Date getStartTime()
|
||||
{
|
||||
return startTime;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,250 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.protocol.jabber;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.service.protocol.event.*;
|
||||
import org.jivesoftware.smackx.jingle.*;
|
||||
|
||||
/**
|
||||
* Our Jabber implementation of the default CallPeer;
|
||||
*
|
||||
* @author Emil Ivov
|
||||
* @author Symphorien Wanko
|
||||
*/
|
||||
public class CallPeerJabberImpl
|
||||
extends AbstractCallPeer
|
||||
{
|
||||
|
||||
/**
|
||||
* The jabber address of this peer
|
||||
*/
|
||||
private String peerAddress = null;
|
||||
|
||||
/**
|
||||
* A byte array containing the image/photo representing the call peer.
|
||||
*/
|
||||
private byte[] image;
|
||||
|
||||
/**
|
||||
* A string uniquely identifying the peer.
|
||||
*/
|
||||
private String peerID;
|
||||
|
||||
/**
|
||||
* The call this peer belongs to.
|
||||
*/
|
||||
private CallJabberImpl call;
|
||||
|
||||
/**
|
||||
* The jingle session that has been created by the application for
|
||||
* communication with this call peer.
|
||||
*/
|
||||
private JingleSession jingleSession = null;
|
||||
|
||||
/**
|
||||
* Creates a new call peer with address <tt>peerAddress</tt>.
|
||||
*
|
||||
* @param peerAddress the Jabber address of the new call peer.
|
||||
* @param owningCall the call that contains this call peer.
|
||||
*/
|
||||
public CallPeerJabberImpl(String peerAddress,
|
||||
CallJabberImpl owningCall)
|
||||
{
|
||||
this.peerAddress = peerAddress;
|
||||
this.call = owningCall;
|
||||
call.addCallPeer(this);
|
||||
|
||||
//create the uid
|
||||
this.peerID = String.valueOf( System.currentTimeMillis())
|
||||
+ String.valueOf(hashCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String locator for that peer.
|
||||
*
|
||||
* @return the peer's address or phone number.
|
||||
*/
|
||||
public String getAddress()
|
||||
{
|
||||
return peerAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the address, phone number, or other protocol specific
|
||||
* identifier that represents this call peer. This method is to be
|
||||
* used by service users and MUST NOT be called by the implementation.
|
||||
*
|
||||
* @param address The address of this call peer.
|
||||
*/
|
||||
public void setAddress(String address)
|
||||
{
|
||||
String oldAddress = getAddress();
|
||||
|
||||
if(peerAddress.equals(address))
|
||||
return;
|
||||
|
||||
this.peerAddress = address;
|
||||
//Fire the Event
|
||||
fireCallPeerChangeEvent(
|
||||
CallPeerChangeEvent.CALL_PEER_ADDRESS_CHANGE,
|
||||
oldAddress,
|
||||
address.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a human readable name representing this peer.
|
||||
*
|
||||
* @return a String containing a name for that peer.
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
if (call != null)
|
||||
{
|
||||
ProtocolProviderService pps = call.getProtocolProvider();
|
||||
OperationSetPresence opSetPresence = (OperationSetPresence) pps
|
||||
.getOperationSet(OperationSetPresence.class);
|
||||
|
||||
Contact cont = opSetPresence.findContactByID(getAddress());
|
||||
if (cont != null)
|
||||
{
|
||||
return cont.getDisplayName();
|
||||
}
|
||||
}
|
||||
return peerAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* The method returns an image representation of the call peer
|
||||
* (e.g.
|
||||
*
|
||||
* @return byte[] a byte array containing the image or null if no image
|
||||
* is available.
|
||||
*/
|
||||
public byte[] getImage()
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the byte array containing an image representation (photo or picture)
|
||||
* of the call peer.
|
||||
*
|
||||
* @param image a byte array containing the image
|
||||
*/
|
||||
protected void setImage(byte[] image)
|
||||
{
|
||||
byte[] oldImage = getImage();
|
||||
this.image = image;
|
||||
|
||||
//Fire the Event
|
||||
fireCallPeerChangeEvent(
|
||||
CallPeerChangeEvent.CALL_PEER_IMAGE_CHANGE,
|
||||
oldImage,
|
||||
image);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique identifier representing this peer.
|
||||
*
|
||||
* @return an identifier representing this call peer.
|
||||
*/
|
||||
public String getPeerID()
|
||||
{
|
||||
return peerID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest sdp description that this peer sent us.
|
||||
* @return the latest sdp description that this peer sent us.
|
||||
*/
|
||||
/*public String getSdpDescription()
|
||||
{
|
||||
return sdpDescription;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Sets the String that serves as a unique identifier of this
|
||||
* CallPeer.
|
||||
* @param peerID the ID of this call peer.
|
||||
*/
|
||||
protected void setPeerID(String peerID)
|
||||
{
|
||||
this.peerID = peerID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the call that this peer belongs to. Calls
|
||||
* are created by underlying telephony protocol implementations.
|
||||
*
|
||||
* @return a reference to the call containing this peer.
|
||||
*/
|
||||
public Call getCall()
|
||||
{
|
||||
return call;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the call containing this peer.
|
||||
* @param call the call that this call peer is
|
||||
* partdicipating in.
|
||||
*/
|
||||
protected void setCall(CallJabberImpl call)
|
||||
{
|
||||
this.call = call;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the jingle session that has been created by the application for
|
||||
* communication with this call peer.
|
||||
* @param session the jingle session that has been created by the
|
||||
* application for this call.
|
||||
*/
|
||||
public void setJingleSession(JingleSession session)
|
||||
{
|
||||
this.jingleSession = session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the jingle session that has been created by the application for
|
||||
* communication with this call peer.
|
||||
*
|
||||
* @return the jingle session that has been created by the application for
|
||||
* communication with this call peer.
|
||||
*/
|
||||
|
||||
public JingleSession getJingleSession()
|
||||
{
|
||||
return jingleSession;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the protocol provider that this peer belongs to.
|
||||
* @return a reference to the ProtocolProviderService that this peer
|
||||
* belongs to.
|
||||
*/
|
||||
public ProtocolProviderService getProtocolProvider()
|
||||
{
|
||||
return this.getCall().getProtocolProvider();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contact corresponding to this peer or null if no
|
||||
* particular contact has been associated.
|
||||
* <p>
|
||||
* @return the <tt>Contact</tt> corresponding to this peer or null
|
||||
* if no particular contact has been associated.
|
||||
*/
|
||||
public Contact getContact()
|
||||
{
|
||||
ProtocolProviderService pps = call.getProtocolProvider();
|
||||
OperationSetPresence opSetPresence = (OperationSetPresence) pps
|
||||
.getOperationSet(OperationSetPresence.class);
|
||||
|
||||
return opSetPresence.findContactByID(getAddress());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,487 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.protocol.sip;
|
||||
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import javax.sip.*;
|
||||
import javax.sip.address.*;
|
||||
|
||||
import net.java.sip.communicator.service.media.*;
|
||||
import net.java.sip.communicator.service.media.event.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.service.protocol.event.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* Our SIP implementation of the default CallPeer;
|
||||
*
|
||||
* @author Emil Ivov
|
||||
*/
|
||||
public class CallPeerSipImpl
|
||||
extends AbstractCallPeer
|
||||
implements SessionCreatorCallback
|
||||
{
|
||||
private static final Logger logger
|
||||
= Logger.getLogger(CallPeerSipImpl.class);
|
||||
|
||||
/**
|
||||
* The sip address of this peer
|
||||
*/
|
||||
private Address peerAddress = null;
|
||||
|
||||
/**
|
||||
* A byte array containing the image/photo representing the call peer.
|
||||
*/
|
||||
private byte[] image;
|
||||
|
||||
/**
|
||||
* A string uniquely identifying the peer.
|
||||
*/
|
||||
private String peerID;
|
||||
|
||||
/**
|
||||
* The call this peer belongs to.
|
||||
*/
|
||||
private CallSipImpl call;
|
||||
|
||||
/**
|
||||
* The JAIN SIP dialog that has been created by the application for
|
||||
* communication with this call peer.
|
||||
*/
|
||||
private Dialog jainSipDialog = null;
|
||||
|
||||
/**
|
||||
* The SDP session description that we have received from this call
|
||||
* peer.
|
||||
*/
|
||||
private String sdpDescription = null;
|
||||
|
||||
/**
|
||||
* The SIP transaction that established this call. This was previously kept
|
||||
* in the jain-sip dialog but got deprected there so we're now keeping it
|
||||
* here.
|
||||
*/
|
||||
private Transaction firstTransaction = null;
|
||||
|
||||
/**
|
||||
* The jain sip provider instance that is responsible for sending and
|
||||
* receiving requests and responses related to this call peer.
|
||||
*/
|
||||
private SipProvider jainSipProvider = null;
|
||||
|
||||
/**
|
||||
* The transport address that we are using to address the peer or the
|
||||
* first one that we'll try when we next send them a message (could be the
|
||||
* address of our sip registrar).
|
||||
*/
|
||||
private InetSocketAddress transportAddress = null;
|
||||
|
||||
/**
|
||||
* A URL pointing to a location with call information or a call control
|
||||
* web interface related to this peer.
|
||||
*/
|
||||
private URL callControlURL = null;
|
||||
|
||||
/**
|
||||
* Creates a new call peer with address <tt>peerAddress</tt>.
|
||||
*
|
||||
* @param peerAddress the JAIN SIP <tt>Address</tt> of the new call peer.
|
||||
* @param owningCall the call that contains this call peer.
|
||||
*/
|
||||
public CallPeerSipImpl(Address peerAddress,
|
||||
CallSipImpl owningCall)
|
||||
{
|
||||
this.peerAddress = peerAddress;
|
||||
this.call = owningCall;
|
||||
call.addCallPeer(this);
|
||||
|
||||
//create the uid
|
||||
this.peerID = String.valueOf( System.currentTimeMillis())
|
||||
+ String.valueOf(hashCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String locator for that peer.
|
||||
*
|
||||
* @return the peer's address or phone number.
|
||||
*/
|
||||
public String getAddress()
|
||||
{
|
||||
return this.peerAddress.getURI().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the address, phone number, or other protocol specific
|
||||
* identifier that represents this call peer. This method is to be
|
||||
* used by service users and MUST NOT be called by the implementation.
|
||||
*
|
||||
* @param address The address of this call peer.
|
||||
*/
|
||||
public void setAddress(Address address)
|
||||
{
|
||||
String oldAddress = getAddress();
|
||||
|
||||
if(peerAddress.equals(address))
|
||||
return;
|
||||
|
||||
this.peerAddress = address;
|
||||
//Fire the Event
|
||||
fireCallPeerChangeEvent(
|
||||
CallPeerChangeEvent.CALL_PEER_ADDRESS_CHANGE,
|
||||
oldAddress,
|
||||
address.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a human readable name representing this peer.
|
||||
*
|
||||
* @return a String containing a name for that peer.
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
String displayName = peerAddress.getDisplayName();
|
||||
return (displayName == null)
|
||||
? peerAddress.getURI().toString()
|
||||
: displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a human readable name representing this peer.
|
||||
*
|
||||
* @param displayName the peer's display name
|
||||
*/
|
||||
protected void setDisplayName(String displayName)
|
||||
{
|
||||
String oldName = getDisplayName();
|
||||
try
|
||||
{
|
||||
this.peerAddress.setDisplayName(displayName);
|
||||
}
|
||||
catch (ParseException ex)
|
||||
{
|
||||
//couldn't happen
|
||||
logger.error(ex.getMessage(), ex);
|
||||
throw new IllegalArgumentException(ex.getMessage());
|
||||
}
|
||||
|
||||
//Fire the Event
|
||||
fireCallPeerChangeEvent(
|
||||
CallPeerChangeEvent.CALL_PEER_DISPLAY_NAME_CHANGE,
|
||||
oldName,
|
||||
displayName);
|
||||
}
|
||||
|
||||
/**
|
||||
* The method returns an image representation of the call peer
|
||||
* (e.g.
|
||||
*
|
||||
* @return byte[] a byte array containing the image or null if no image
|
||||
* is available.
|
||||
*/
|
||||
public byte[] getImage()
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the byte array containing an image representation (photo or picture)
|
||||
* of the call peer.
|
||||
*
|
||||
* @param image a byte array containing the image
|
||||
*/
|
||||
protected void setImage(byte[] image)
|
||||
{
|
||||
byte[] oldImage = getImage();
|
||||
this.image = image;
|
||||
|
||||
//Fire the Event
|
||||
fireCallPeerChangeEvent(
|
||||
CallPeerChangeEvent.CALL_PEER_IMAGE_CHANGE,
|
||||
oldImage,
|
||||
image);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique identifier representing this peer.
|
||||
*
|
||||
* @return an identifier representing this call peer.
|
||||
*/
|
||||
public String getPeerID()
|
||||
{
|
||||
return peerID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest sdp description that this peer sent us.
|
||||
* @return the latest sdp description that this peer sent us.
|
||||
*/
|
||||
public String getSdpDescription()
|
||||
{
|
||||
return sdpDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the String that serves as a unique identifier of this
|
||||
* CallPeer.
|
||||
* @param peerID the ID of this call peer.
|
||||
*/
|
||||
protected void setPeerID(String peerID)
|
||||
{
|
||||
this.peerID = peerID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the call that this peer belongs to. Calls
|
||||
* are created by underlying telephony protocol implementations.
|
||||
*
|
||||
* @return a reference to the call containing this peer.
|
||||
*/
|
||||
public Call getCall()
|
||||
{
|
||||
return call;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the call containing this peer.
|
||||
* @param call the call that this call peer is
|
||||
* partdicipating in.
|
||||
*/
|
||||
protected void setCall(CallSipImpl call)
|
||||
{
|
||||
this.call = call;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sdp description for this call peer.
|
||||
*
|
||||
* @param sdpDescription the sdp description for this call peer.
|
||||
*/
|
||||
public void setSdpDescription(String sdpDescription)
|
||||
{
|
||||
this.sdpDescription = sdpDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the javax.sip Address of this call peer.
|
||||
* @return the javax.sip Address of this call peer.
|
||||
*/
|
||||
public Address getJainSipAddress()
|
||||
{
|
||||
return peerAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the JAIN SIP dialog that has been created by the application for
|
||||
* communication with this call peer.
|
||||
* @param dialog the JAIN SIP dialog that has been created by the
|
||||
* application for this call.
|
||||
*/
|
||||
public void setDialog(Dialog dialog)
|
||||
{
|
||||
this.jainSipDialog = dialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JAIN SIP dialog that has been created by the application for
|
||||
* communication with this call peer.
|
||||
*
|
||||
* @return the JAIN SIP dialog that has been created by the application for
|
||||
* communication with this call peer.
|
||||
*/
|
||||
public Dialog getDialog()
|
||||
{
|
||||
return jainSipDialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the transaction instance that contains the INVITE which started
|
||||
* this call.
|
||||
*
|
||||
* @param transaction the Transaction that initiated this call.
|
||||
*/
|
||||
public void setFirstTransaction(Transaction transaction)
|
||||
{
|
||||
this.firstTransaction = transaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the transaction instance that contains the INVITE which started
|
||||
* this call.
|
||||
*
|
||||
* @return the Transaction that initiated this call.
|
||||
*/
|
||||
public Transaction getFirstTransaction()
|
||||
{
|
||||
return firstTransaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the jain sip provider instance that is responsible for sending and
|
||||
* receiving requests and responses related to this call peer.
|
||||
*
|
||||
* @param jainSipProvider the <tt>SipProvider</tt> that serves this call
|
||||
* peer.
|
||||
*/
|
||||
public void setJainSipProvider(SipProvider jainSipProvider)
|
||||
{
|
||||
this.jainSipProvider = jainSipProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the jain sip provider instance that is responsible for sending
|
||||
* and receiving requests and responses related to this call peer.
|
||||
*
|
||||
* @return the jain sip provider instance that is responsible for sending
|
||||
* and receiving requests and responses related to this call peer.
|
||||
*/
|
||||
public SipProvider getJainSipProvider()
|
||||
{
|
||||
return jainSipProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* The address that we have used to contact this peer. In cases
|
||||
* where no direct connection has been established with the peer,
|
||||
* this method will return the address that will be first tried when
|
||||
* connection is established (often the one used to connect with the
|
||||
* protocol server). The address may change during a session and
|
||||
*
|
||||
* @param transportAddress The address that we have used to contact this
|
||||
* peer.
|
||||
*/
|
||||
public void setTransportAddress(InetSocketAddress transportAddress)
|
||||
{
|
||||
InetSocketAddress oldTransportAddress = this.transportAddress;
|
||||
this.transportAddress = transportAddress;
|
||||
|
||||
this.fireCallPeerChangeEvent(
|
||||
CallPeerChangeEvent
|
||||
.CALL_PEER_TRANSPORT_ADDRESS_CHANGE,
|
||||
oldTransportAddress,
|
||||
transportAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the protocol provider that this peer belongs to.
|
||||
* @return a reference to the ProtocolProviderService that this peer
|
||||
* belongs to.
|
||||
*/
|
||||
public ProtocolProviderService getProtocolProvider()
|
||||
{
|
||||
return this.getCall().getProtocolProvider();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contact corresponding to this peer or null if no
|
||||
* particular contact has been associated.
|
||||
* <p>
|
||||
* @return the <tt>Contact</tt> corresponding to this peer or null
|
||||
* if no particular contact has been associated.
|
||||
*/
|
||||
public Contact getContact()
|
||||
{
|
||||
ProtocolProviderService pps = call.getProtocolProvider();
|
||||
OperationSetPresenceSipImpl opSetPresence
|
||||
= (OperationSetPresenceSipImpl) pps
|
||||
.getOperationSet(OperationSetPresence.class);
|
||||
|
||||
return opSetPresence.resolveContactID(getAddress());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a URL pointing ta a location with call control information for
|
||||
* this peer or <tt>null</tt> if no such URL is available for this
|
||||
* call peer.
|
||||
*
|
||||
* @return a URL link to a location with call information or a call control
|
||||
* web interface related to this peer or <tt>null</tt> if no such URL
|
||||
* is available.
|
||||
*/
|
||||
public URL getCallInfoURL()
|
||||
{
|
||||
return this.callControlURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a URL pointing ta a location with call control information for
|
||||
* this peer.
|
||||
*
|
||||
* @param callControlURL a URL link to a location with call information or
|
||||
* a call control web interface related to this peer.
|
||||
*/
|
||||
public void setCallInfoURL(URL callControlURL)
|
||||
{
|
||||
this.callControlURL = callControlURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the audio stream (if any) being sent to this
|
||||
* peer is mute.
|
||||
*
|
||||
* @return <tt>true</tt> if an audio stream is being sent to this
|
||||
* peer and it is currently mute; <tt>false</tt>, otherwise
|
||||
*/
|
||||
public boolean isMute()
|
||||
{
|
||||
CallSipImpl call = this.call;
|
||||
|
||||
if (call != null)
|
||||
{
|
||||
CallSession callSession = call.getMediaCallSession();
|
||||
|
||||
if (callSession != null)
|
||||
return callSession.isMute();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the security status to ON for this call peer.
|
||||
*
|
||||
* @param sessionType the type of the call session - audio or video.
|
||||
* @param cipher the cipher
|
||||
* @param securityString the SAS
|
||||
* @param isVerified indicates if the SAS has been verified
|
||||
*/
|
||||
public void securityOn( int sessionType,
|
||||
String cipher,
|
||||
String securityString,
|
||||
boolean isVerified)
|
||||
{
|
||||
fireCallPeerSecurityOnEvent( sessionType,
|
||||
cipher,
|
||||
securityString,
|
||||
isVerified);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the security status to OFF for this call peer.
|
||||
*
|
||||
* @param sessionType the type of the call session - audio or video.
|
||||
*/
|
||||
public void securityOff(int sessionType)
|
||||
{
|
||||
fireCallPeerSecurityOffEvent(sessionType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the security message associated with a failure/warning or
|
||||
* information coming from the encryption protocol.
|
||||
*
|
||||
* @param messageType the type of the message.
|
||||
* @param message the message
|
||||
*/
|
||||
public void securityMessage( String messageType,
|
||||
String i18nMessage,
|
||||
int severity)
|
||||
{
|
||||
fireCallPeerSecurityMessageEvent(messageType,
|
||||
i18nMessage,
|
||||
severity);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
package net.java.sip.communicator.service.callhistory;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
* Structure used for encapsulating data when writing or reading
|
||||
* Call History Data. Also These records are uesd for returning data
|
||||
* from the Call History Service
|
||||
*
|
||||
* @author Damian Minkov
|
||||
*/
|
||||
public class CallPeerRecord
|
||||
{
|
||||
protected String peerAddress = null;
|
||||
protected Date startTime = null;
|
||||
protected Date endTime = null;
|
||||
protected CallPeerState state = CallPeerState.UNKNOWN;
|
||||
|
||||
/**
|
||||
* Creates CallPeerRecord
|
||||
* @param peerAddress String
|
||||
* @param startTime Date
|
||||
* @param endTime Date
|
||||
*/
|
||||
public CallPeerRecord( String peerAddress,
|
||||
Date startTime,
|
||||
Date endTime)
|
||||
{
|
||||
this.peerAddress = peerAddress;
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* When peer diconnected from the call
|
||||
*
|
||||
* @return Date
|
||||
*/
|
||||
public Date getEndTime()
|
||||
{
|
||||
return endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* The peer address
|
||||
* @return String
|
||||
*/
|
||||
public String getPeerAddress()
|
||||
{
|
||||
return peerAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* When peer connected to the call
|
||||
* @return Date
|
||||
*/
|
||||
public Date getStartTime()
|
||||
{
|
||||
return startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the actual state of the peer
|
||||
* @return CallPeerState
|
||||
*/
|
||||
public CallPeerState getState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,646 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.protocol;
|
||||
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.event.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* Provides a default implementation for most of the
|
||||
* <code>CallPeer</code> methods with the purpose of only leaving custom
|
||||
* protocol development to clients using the PhoneUI service.
|
||||
*
|
||||
* @author Emil Ivov
|
||||
* @author Lubomir Marinov
|
||||
*/
|
||||
public abstract class AbstractCallPeer
|
||||
extends PropertyChangeNotifier
|
||||
implements CallPeer
|
||||
{
|
||||
private static final Logger logger
|
||||
= Logger.getLogger(AbstractCallPeer.class);
|
||||
|
||||
/**
|
||||
* The constant which describes an empty set of
|
||||
* <code>ConferenceMember</code>s (and which can be used to reduce
|
||||
* allocations).
|
||||
*/
|
||||
protected static final ConferenceMember[] NO_CONFERENCE_MEMBERS
|
||||
= new ConferenceMember[0];
|
||||
|
||||
/**
|
||||
* All the CallPeer listeners registered with this CallPeer.
|
||||
*/
|
||||
protected final List<CallPeerListener> callPeerListeners
|
||||
= new ArrayList<CallPeerListener>();
|
||||
|
||||
/**
|
||||
* All the CallPeerSecurityListener-s registered with this
|
||||
* CallPeer.
|
||||
*/
|
||||
protected final List<CallPeerSecurityListener>
|
||||
callPeerSecurityListeners
|
||||
= new ArrayList<CallPeerSecurityListener>();
|
||||
|
||||
/**
|
||||
* The indicator which determines whether this peer is acting as a
|
||||
* conference focus and thus may provide information about
|
||||
* <code>ConferenceMember</code> such as {@link #getConferenceMembers()} and
|
||||
* {@link #getConferenceMemberCount()}.
|
||||
*/
|
||||
private boolean conferenceFocus;
|
||||
|
||||
/**
|
||||
* The list of <code>ConferenceMember</code>s currently known to and managed
|
||||
* in a conference by this peer.
|
||||
*/
|
||||
private final List<ConferenceMember> conferenceMembers
|
||||
= new ArrayList<ConferenceMember>();
|
||||
|
||||
/**
|
||||
* The list of <code>CallPeerConferenceListener</code>s interested in
|
||||
* and to be notified about changes in conference-related information such
|
||||
* as this peer acting or not acting as a conference focus and
|
||||
* conference membership details.
|
||||
*/
|
||||
protected final List<CallPeerConferenceListener>
|
||||
callPeerConferenceListeners
|
||||
= new ArrayList<CallPeerConferenceListener>();
|
||||
|
||||
/**
|
||||
* The state of the call peer.
|
||||
*/
|
||||
private CallPeerState state = CallPeerState.UNKNOWN;
|
||||
|
||||
private long callDurationStartTime = CALL_DURATION_START_TIME_UNKNOWN;
|
||||
|
||||
private boolean isMute;
|
||||
|
||||
/**
|
||||
* Registers the <tt>listener</tt> to the list of listeners that would be
|
||||
* receiving CallPeerEvents
|
||||
* @param listener a listener instance to register with this peer.
|
||||
*/
|
||||
public void addCallPeerListener(CallPeerListener listener)
|
||||
{
|
||||
if (listener == null)
|
||||
return;
|
||||
synchronized(callPeerListeners)
|
||||
{
|
||||
if (!callPeerListeners.contains(listener))
|
||||
callPeerListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters the specified listener.
|
||||
* @param listener the listener to unregister.
|
||||
*/
|
||||
public void removeCallPeerListener(CallPeerListener listener)
|
||||
{
|
||||
if (listener == null)
|
||||
return;
|
||||
synchronized(callPeerListeners)
|
||||
{
|
||||
callPeerListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the <tt>listener</tt> to the list of listeners that would be
|
||||
* receiving CallPeerSecurityEvents
|
||||
*
|
||||
* @param listener a listener instance to register with this peer.
|
||||
*/
|
||||
public void addCallPeerSecurityListener(
|
||||
CallPeerSecurityListener listener)
|
||||
{
|
||||
if (listener == null)
|
||||
return;
|
||||
synchronized(callPeerSecurityListeners)
|
||||
{
|
||||
if (!callPeerSecurityListeners.contains(listener))
|
||||
callPeerSecurityListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters the specified listener.
|
||||
*
|
||||
* @param listener the listener to unregister.
|
||||
*/
|
||||
public void removeCallPeerSecurityListener(
|
||||
CallPeerSecurityListener listener)
|
||||
{
|
||||
if (listener == null)
|
||||
return;
|
||||
synchronized(callPeerSecurityListeners)
|
||||
{
|
||||
callPeerSecurityListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <tt>CallPeerChangeEvent</tt> using this call
|
||||
* peer as source, setting it to be of type <tt>eventType</tt> and
|
||||
* the corresponding <tt>oldValue</tt> and <tt>newValue</tt>,
|
||||
*
|
||||
* @param eventType the type of the event to create and dispatch.
|
||||
* @param oldValue the value of the source property before it changed.
|
||||
* @param newValue the current value of the source property.
|
||||
*/
|
||||
protected void fireCallPeerChangeEvent(String eventType,
|
||||
Object oldValue,
|
||||
Object newValue)
|
||||
{
|
||||
this.fireCallPeerChangeEvent( eventType, oldValue, newValue, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a <tt>CallPeerChangeEvent</tt> using this call
|
||||
* peer as source, setting it to be of type <tt>eventType</tt> and
|
||||
* the corresponding <tt>oldValue</tt> and <tt>newValue</tt>,
|
||||
*
|
||||
* @param eventType the type of the event to create and dispatch.
|
||||
* @param oldValue the value of the source property before it changed.
|
||||
* @param newValue the current value of the source property.
|
||||
* @param reason a string that could be set to contain a human readable
|
||||
* explanation for the transition (particularly handy when moving into a
|
||||
* FAILED state).
|
||||
*/
|
||||
protected void fireCallPeerChangeEvent(String eventType,
|
||||
Object oldValue,
|
||||
Object newValue,
|
||||
String reason)
|
||||
{
|
||||
CallPeerChangeEvent evt = new CallPeerChangeEvent(
|
||||
this, eventType, oldValue, newValue, reason);
|
||||
|
||||
logger.debug("Dispatching a CallPeerChangeEvent event to "
|
||||
+ callPeerListeners.size()
|
||||
+" listeners. event is: " + evt.toString());
|
||||
|
||||
Iterator<CallPeerListener> listeners = null;
|
||||
synchronized (callPeerListeners)
|
||||
{
|
||||
listeners = new ArrayList<CallPeerListener>(
|
||||
callPeerListeners).iterator();
|
||||
}
|
||||
|
||||
while (listeners.hasNext())
|
||||
{
|
||||
CallPeerListener listener
|
||||
= (CallPeerListener) listeners.next();
|
||||
|
||||
if(eventType.equals(CallPeerChangeEvent
|
||||
.CALL_PEER_ADDRESS_CHANGE))
|
||||
{
|
||||
listener.peerAddressChanged(evt);
|
||||
} else if(eventType.equals(CallPeerChangeEvent
|
||||
.CALL_PEER_DISPLAY_NAME_CHANGE))
|
||||
{
|
||||
listener.peerDisplayNameChanged(evt);
|
||||
} else if(eventType.equals(CallPeerChangeEvent
|
||||
.CALL_PEER_IMAGE_CHANGE))
|
||||
{
|
||||
listener.peerImageChanged(evt);
|
||||
} else if(eventType.equals(CallPeerChangeEvent
|
||||
.CALL_PEER_STATE_CHANGE))
|
||||
{
|
||||
listener.peerStateChanged(evt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <tt>CallPeerSecurityStatusEvent</tt> using this call
|
||||
* peer as source, setting it to be of type <tt>eventType</tt> and
|
||||
* the corresponding <tt>oldValue</tt> and <tt>newValue</tt>,
|
||||
*
|
||||
* @param sessionType the type of the session - audio or video
|
||||
* @param eventID the identifier of the event
|
||||
*/
|
||||
protected void fireCallPeerSecurityOnEvent(
|
||||
int sessionType,
|
||||
String cipher,
|
||||
String securityString,
|
||||
boolean isVerified)
|
||||
{
|
||||
CallPeerSecurityOnEvent evt
|
||||
= new CallPeerSecurityOnEvent( this,
|
||||
sessionType,
|
||||
cipher,
|
||||
securityString,
|
||||
isVerified);
|
||||
|
||||
logger.debug("Dispatching a CallPeerSecurityStatusEvent event to "
|
||||
+ callPeerSecurityListeners.size()
|
||||
+" listeners. event is: " + evt.toString());
|
||||
|
||||
Iterator<CallPeerSecurityListener> listeners = null;
|
||||
synchronized (callPeerSecurityListeners)
|
||||
{
|
||||
listeners = new ArrayList<CallPeerSecurityListener>(
|
||||
callPeerSecurityListeners).iterator();
|
||||
}
|
||||
|
||||
while (listeners.hasNext())
|
||||
{
|
||||
CallPeerSecurityListener listener
|
||||
= (CallPeerSecurityListener) listeners.next();
|
||||
|
||||
listener.securityOn(evt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <tt>CallPeerSecurityStatusEvent</tt> using this call
|
||||
* peer as source, setting it to be of type <tt>eventType</tt> and
|
||||
* the corresponding <tt>oldValue</tt> and <tt>newValue</tt>,
|
||||
*
|
||||
* @param sessionType the type of the session - audio or video
|
||||
* @param eventID the identifier of the event
|
||||
*/
|
||||
protected void fireCallPeerSecurityOffEvent(int sessionType)
|
||||
{
|
||||
CallPeerSecurityOffEvent event
|
||||
= new CallPeerSecurityOffEvent( this, sessionType);
|
||||
|
||||
logger.debug(
|
||||
"Dispatching a CallPeerSecurityAuthenticationEvent event to "
|
||||
+ callPeerSecurityListeners.size()
|
||||
+" listeners. event is: " + event.toString());
|
||||
|
||||
Iterator<CallPeerSecurityListener> listeners = null;
|
||||
synchronized (callPeerSecurityListeners)
|
||||
{
|
||||
listeners = new ArrayList<CallPeerSecurityListener>(
|
||||
callPeerSecurityListeners).iterator();
|
||||
}
|
||||
|
||||
while (listeners.hasNext())
|
||||
{
|
||||
CallPeerSecurityListener listener
|
||||
= (CallPeerSecurityListener) listeners.next();
|
||||
|
||||
listener.securityOff(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <tt>CallPeerSecurityStatusEvent</tt> using this call
|
||||
* peer as source, setting it to be of type <tt>eventType</tt> and
|
||||
* the corresponding <tt>oldValue</tt> and <tt>newValue</tt>,
|
||||
*
|
||||
* @param sessionType the type of the session - audio or video
|
||||
* @param eventID the identifier of the event
|
||||
*/
|
||||
protected void fireCallPeerSecurityMessageEvent(
|
||||
String messageType,
|
||||
String i18nMessage,
|
||||
int severity)
|
||||
{
|
||||
CallPeerSecurityMessageEvent evt
|
||||
= new CallPeerSecurityMessageEvent( this,
|
||||
messageType,
|
||||
i18nMessage,
|
||||
severity);
|
||||
|
||||
logger.debug("Dispatching a CallPeerSecurityFailedEvent event to "
|
||||
+ callPeerSecurityListeners.size()
|
||||
+" listeners. event is: " + evt.toString());
|
||||
|
||||
Iterator<CallPeerSecurityListener> listeners = null;
|
||||
synchronized (callPeerSecurityListeners)
|
||||
{
|
||||
listeners = new ArrayList<CallPeerSecurityListener>(
|
||||
callPeerSecurityListeners).iterator();
|
||||
}
|
||||
|
||||
while (listeners.hasNext())
|
||||
{
|
||||
CallPeerSecurityListener listener
|
||||
= (CallPeerSecurityListener) listeners.next();
|
||||
|
||||
listener.securityMessageRecieved(evt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the peer in the form of
|
||||
* <br/>
|
||||
* Display Name <address>;status=CallPeerStatus
|
||||
* @return a string representation of the peer and its state.
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return getDisplayName() + " <" + getAddress()
|
||||
+ ">;status=" + getState().getStateString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a URL pointing ta a location with call control information for
|
||||
* this peer or <tt>null</tt> if no such URL is available for this
|
||||
* call peer.
|
||||
*
|
||||
* @return a URL link to a location with call information or a call control
|
||||
* web interface related to this peer or <tt>null</tt> if no such URL
|
||||
* is available.
|
||||
*/
|
||||
public URL getCallInfoURL()
|
||||
{
|
||||
//if signaling protocols (such as SIP) know where to get this URL from
|
||||
//they should override this method
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object representing the current state of that peer.
|
||||
*
|
||||
* @return a CallPeerState instance representing the peer's state.
|
||||
*/
|
||||
public CallPeerState getState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes this CallPeer to enter the specified state. The method also
|
||||
* sets the currentStateStartDate field and fires a
|
||||
* CallPeerChangeEvent.
|
||||
*
|
||||
* @param newState the state this call peer should enter.
|
||||
* @param reason a string that could be set to contain a human readable
|
||||
* explanation for the transition (particularly handy when moving into a
|
||||
* FAILED state).
|
||||
*/
|
||||
public void setState(CallPeerState newState, String reason)
|
||||
{
|
||||
CallPeerState oldState = getState();
|
||||
|
||||
if(oldState == newState)
|
||||
return;
|
||||
|
||||
this.state = newState;
|
||||
|
||||
if (CallPeerState.CONNECTED.equals(newState)
|
||||
&& !CallPeerState.isOnHold(oldState))
|
||||
{
|
||||
callDurationStartTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
fireCallPeerChangeEvent(
|
||||
CallPeerChangeEvent.CALL_PEER_STATE_CHANGE,
|
||||
oldState,
|
||||
newState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes this CallPeer to enter the specified state. The method also
|
||||
* sets the currentStateStartDate field and fires a
|
||||
* CallPeerChangeEvent.
|
||||
*
|
||||
* @param newState the state this call peer should enter.
|
||||
*/
|
||||
public void setState(CallPeerState newState)
|
||||
{
|
||||
setState(newState, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the time at which this <code>CallPeer</code> transitioned
|
||||
* into a state (likely {@link CallPeerState#CONNECTED}) marking the
|
||||
* start of the duration of the participation in a <code>Call</code>.
|
||||
*
|
||||
* @return the time at which this <code>CallPeer</code> transitioned
|
||||
* into a state marking the start of the duration of the
|
||||
* participation in a <code>Call</code> or
|
||||
* {@link CallPeer#CALL_DURATION_START_TIME_UNKNOWN} if such
|
||||
* a transition has not been performed
|
||||
*/
|
||||
public long getCallDurationStartTime()
|
||||
{
|
||||
return callDurationStartTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the audio stream (if any) being sent to this
|
||||
* peer is mute.
|
||||
* <p>
|
||||
* The default implementation returns <tt>false</tt>.
|
||||
* </p>
|
||||
*
|
||||
* @return <tt>true</tt> if an audio stream is being sent to this
|
||||
* peer and it is currently mute; <tt>false</tt>, otherwise
|
||||
*/
|
||||
public boolean isMute()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mute property for this call peer.
|
||||
*
|
||||
* @param mute the new value of the mute property for this call peer
|
||||
*/
|
||||
public void setMute(boolean newMuteValue)
|
||||
{
|
||||
firePropertyChange(MUTE_PROPERTY_NAME, isMute, newMuteValue);
|
||||
|
||||
this.isMute = newMuteValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implements CallPeer#isConferenceFocus().
|
||||
*/
|
||||
public boolean isConferenceFocus()
|
||||
{
|
||||
return conferenceFocus;
|
||||
}
|
||||
|
||||
public void setConferenceFocus(boolean conferenceFocus)
|
||||
{
|
||||
if (this.conferenceFocus != conferenceFocus)
|
||||
{
|
||||
this.conferenceFocus = conferenceFocus;
|
||||
|
||||
fireCallPeerConferenceEvent(
|
||||
new CallPeerConferenceEvent(
|
||||
this,
|
||||
CallPeerConferenceEvent.CONFERENCE_FOCUS_CHANGED));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Implements CallPeer#getConferenceMembers(). In order to reduce
|
||||
* allocations, returns #NO_CONFERENCE_MEMBERS if #conferenceMembers
|
||||
* contains no ConferenceMember instances.
|
||||
*/
|
||||
public ConferenceMember[] getConferenceMembers()
|
||||
{
|
||||
ConferenceMember[] conferenceMembers;
|
||||
|
||||
synchronized (this.conferenceMembers)
|
||||
{
|
||||
int conferenceMemberCount = this.conferenceMembers.size();
|
||||
|
||||
if (conferenceMemberCount <= 0)
|
||||
conferenceMembers = NO_CONFERENCE_MEMBERS;
|
||||
else
|
||||
conferenceMembers
|
||||
= this.conferenceMembers
|
||||
.toArray(
|
||||
new ConferenceMember[conferenceMemberCount]);
|
||||
}
|
||||
return conferenceMembers;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implements CallPeer#getConferenceMemberCount().
|
||||
*/
|
||||
public int getConferenceMemberCount()
|
||||
{
|
||||
return conferenceMembers.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a specific <code>ConferenceMember</code> to the list of
|
||||
* <code>ConferenceMember</code>s reported by this peer through
|
||||
* {@link #getConferenceMembers()} and {@link #getConferenceMemberCount()}
|
||||
* and fires
|
||||
* <code>CallPeerConferenceEvent#CONFERENCE_MEMBER_ADDED</code> to
|
||||
* the currently registered <code>CallPeerConferenceListener</code>s.
|
||||
*
|
||||
* @param conferenceMember
|
||||
* a <code>ConferenceMember</code> to be added to the list of
|
||||
* <code>ConferenceMember</code> reported by this peer. If
|
||||
* the specified <code>ConferenceMember</code> is already
|
||||
* contained in the list, it is not added again and no event is
|
||||
* fired.
|
||||
*/
|
||||
public void addConferenceMember(ConferenceMember conferenceMember)
|
||||
{
|
||||
if (conferenceMember == null)
|
||||
throw new NullPointerException("conferenceMember");
|
||||
synchronized (conferenceMembers)
|
||||
{
|
||||
if (conferenceMembers.contains(conferenceMember))
|
||||
return;
|
||||
conferenceMembers.add(conferenceMember);
|
||||
}
|
||||
fireCallPeerConferenceEvent(
|
||||
new CallPeerConferenceEvent(
|
||||
this,
|
||||
CallPeerConferenceEvent.CONFERENCE_MEMBER_ADDED,
|
||||
conferenceMember));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a specific <code>ConferenceMember</code> from the list of
|
||||
* <code>ConferenceMember</code>s reported by this peer through
|
||||
* {@link #getConferenceMembers()} and {@link #getConferenceMemberCount()}
|
||||
* if it is contained and fires
|
||||
* <code>CallPeerConferenceEvent#CONFERENCE_MEMBER_REMOVED</code> to
|
||||
* the currently registered <code>CallPeerConferenceListener</code>s.
|
||||
*
|
||||
* @param conferenceMember
|
||||
* a <code>ConferenceMember</code> to be removed from the list of
|
||||
* <code>ConferenceMember</code> reported by this peer. If
|
||||
* the specified <code>ConferenceMember</code> is no contained in
|
||||
* the list, no event is fired.
|
||||
*/
|
||||
public void removeConferenceMember(ConferenceMember conferenceMember)
|
||||
{
|
||||
if (conferenceMember == null)
|
||||
throw new NullPointerException("conferenceMember");
|
||||
synchronized (conferenceMembers)
|
||||
{
|
||||
if (!conferenceMembers.remove(conferenceMember))
|
||||
return;
|
||||
}
|
||||
fireCallPeerConferenceEvent(
|
||||
new CallPeerConferenceEvent(
|
||||
this,
|
||||
CallPeerConferenceEvent.CONFERENCE_MEMBER_REMOVED,
|
||||
conferenceMember));
|
||||
}
|
||||
|
||||
/*
|
||||
* ImplementsCallPeer#addCallPeerConferenceListener(
|
||||
* CallPeerConferenceListener). In the fashion of the addition of the
|
||||
* other listeners, does not throw an exception on attempting to add a null
|
||||
* listeners and just ignores the call.
|
||||
*/
|
||||
public void addCallPeerConferenceListener(
|
||||
CallPeerConferenceListener listener)
|
||||
{
|
||||
if (listener != null)
|
||||
synchronized (callPeerConferenceListeners)
|
||||
{
|
||||
if (!callPeerConferenceListeners.contains(listener))
|
||||
callPeerConferenceListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Implements CallPeer#removeCallPeerConferenceListener(
|
||||
* CallPeerConferenceListener).
|
||||
*/
|
||||
public void removeCallPeerConferenceListener(
|
||||
CallPeerConferenceListener listener)
|
||||
{
|
||||
if (listener != null)
|
||||
synchronized (callPeerConferenceListeners)
|
||||
{
|
||||
callPeerConferenceListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires a specific <code>CallPeerConferenceEvent</code> to the
|
||||
* <code>CallPeerConferenceListener</code>s interested in changes in
|
||||
* the conference-related information provided by this peer.
|
||||
*
|
||||
* @param conferenceEvent
|
||||
* a <code>CallPeerConferenceEvent</code> to be fired and
|
||||
* carrying the event data
|
||||
*/
|
||||
protected void fireCallPeerConferenceEvent(
|
||||
CallPeerConferenceEvent conferenceEvent)
|
||||
{
|
||||
CallPeerConferenceListener[] listeners;
|
||||
|
||||
synchronized (callPeerConferenceListeners)
|
||||
{
|
||||
listeners
|
||||
= callPeerConferenceListeners
|
||||
.toArray(
|
||||
new CallPeerConferenceListener[
|
||||
callPeerConferenceListeners.size()]);
|
||||
}
|
||||
|
||||
int eventID = conferenceEvent.getEventID();
|
||||
|
||||
for (CallPeerConferenceListener listener : listeners)
|
||||
switch (eventID)
|
||||
{
|
||||
case CallPeerConferenceEvent.CONFERENCE_FOCUS_CHANGED:
|
||||
listener.conferenceFocusChanged(conferenceEvent);
|
||||
break;
|
||||
case CallPeerConferenceEvent.CONFERENCE_MEMBER_ADDED:
|
||||
listener.conferenceMemberAdded(conferenceEvent);
|
||||
break;
|
||||
case CallPeerConferenceEvent.CONFERENCE_MEMBER_REMOVED:
|
||||
listener.conferenceMemberRemoved(conferenceEvent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,257 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.protocol;
|
||||
|
||||
import java.net.*;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.event.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* The CallPeer is an interface that represents peers in a call.
|
||||
* Users of the UIService need to implement this interface (or one of its
|
||||
* default implementations such DefaultCallPeer) in order to be able to
|
||||
* register call peer in the user interface.
|
||||
*
|
||||
* <p>For SIP calls for example, it would be necessary to create a
|
||||
* CallPeerSipImpl class that would provide sip specific implementations of
|
||||
* various methods (getAddress() for example would return the peer's sip
|
||||
* URI).
|
||||
*
|
||||
* @author Emil Ivov
|
||||
* @author Lubomir Marinov
|
||||
*/
|
||||
public interface CallPeer
|
||||
{
|
||||
|
||||
/**
|
||||
* The constant indicating that a <code>CallPeer</code> has not yet
|
||||
* transitioned into a state marking the beginning of a participation in a
|
||||
* <code>Call</code> or that such a transition may have happened but the
|
||||
* time of its occurrence is unknown.
|
||||
*/
|
||||
public static final long CALL_DURATION_START_TIME_UNKNOWN = 0;
|
||||
|
||||
/**
|
||||
* The mute property name.
|
||||
*/
|
||||
public static final String MUTE_PROPERTY_NAME = "Mute";
|
||||
|
||||
/**
|
||||
* Returns a unique identifier representing this peer. Identifiers
|
||||
* returned by this method should remain unique across calls. In other
|
||||
* words, if it returned the value of "A" for a given peer it should
|
||||
* not return that same value for any other peer and return a
|
||||
* different value even if the same person (address) is participating in
|
||||
* another call. Values need not remain unique after restarting the program.
|
||||
*
|
||||
* @return an identifier representing this call peer.
|
||||
*/
|
||||
public String getPeerID();
|
||||
|
||||
/**
|
||||
* Returns a reference to the call that this peer belongs to.
|
||||
* @return a reference to the call containing this peer.
|
||||
*/
|
||||
public Call getCall();
|
||||
|
||||
/**
|
||||
* Returns a human readable name representing this peer.
|
||||
* @return a String containing a name for that peer.
|
||||
*/
|
||||
public String getDisplayName();
|
||||
|
||||
/**
|
||||
* Returns a String locator for that peer. A locator might be a SIP
|
||||
* URI, an IP address or a telephone number.
|
||||
* @return the peer's address or phone number.
|
||||
*/
|
||||
public String getAddress();
|
||||
|
||||
/**
|
||||
* Returns an object representing the current state of that peer.
|
||||
* CallPeerState may vary among CONNECTING, RINGING, CALLING, BUSY,
|
||||
* CONNECTED, and others, and it reflects the state of the connection between
|
||||
* us and that peer.
|
||||
* @return a CallPeerState instance representing the peer's
|
||||
* state.
|
||||
*/
|
||||
public CallPeerState getState();
|
||||
|
||||
/**
|
||||
* Allows the user interface to register a listener interested in changes
|
||||
* @param listener a listener instance to register with this peer.
|
||||
*/
|
||||
public void addCallPeerListener(CallPeerListener listener);
|
||||
|
||||
/**
|
||||
* Unregisters the specified listener.
|
||||
* @param listener the listener to unregister.
|
||||
*/
|
||||
public void removeCallPeerListener(CallPeerListener listener);
|
||||
|
||||
/**
|
||||
* Allows the user interface to register a listener interested in security
|
||||
* status changes.
|
||||
*
|
||||
* @param listener a listener instance to register with this peer
|
||||
*/
|
||||
public void addCallPeerSecurityListener(
|
||||
CallPeerSecurityListener listener);
|
||||
|
||||
/**
|
||||
* Unregisters the specified listener.
|
||||
*
|
||||
* @param listener the listener to unregister
|
||||
*/
|
||||
public void removeCallPeerSecurityListener(
|
||||
CallPeerSecurityListener listener);
|
||||
|
||||
/**
|
||||
* Allows the user interface to register a listener interested in property
|
||||
* changes.
|
||||
* @param listener a property change listener instance to register with this
|
||||
* peer.
|
||||
*/
|
||||
public void addPropertyChangeListener(PropertyChangeListener listener);
|
||||
|
||||
/**
|
||||
* Unregisters the specified property change listener.
|
||||
*
|
||||
* @param listener the property change listener to unregister.
|
||||
*/
|
||||
public void removePropertyChangeListener(PropertyChangeListener listener);
|
||||
|
||||
/**
|
||||
* Gets the time at which this <code>CallPeer</code> transitioned
|
||||
* into a state (likely {@link CallPeerState#CONNECTED}) marking the
|
||||
* start of the duration of the participation in a <code>Call</code>.
|
||||
*
|
||||
* @return the time at which this <code>CallPeer</code> transitioned
|
||||
* into a state marking the start of the duration of the
|
||||
* participation in a <code>Call</code> or
|
||||
* {@link #CALL_DURATION_START_TIME_UNKNOWN} if such a transition
|
||||
* has not been performed
|
||||
*/
|
||||
long getCallDurationStartTime();
|
||||
|
||||
/**
|
||||
* Returns a string representation of the peer in the form of
|
||||
* <br>
|
||||
* Display Name <address>;status=CallPeerStatus
|
||||
* @return a string representation of the peer and its state.
|
||||
*/
|
||||
public String toString();
|
||||
|
||||
/**
|
||||
* The method returns an image representation of the call peer (e.g.
|
||||
* a photo). Generally, the image representation is acquired from the
|
||||
* underlying telephony protocol and is transferred over the network during
|
||||
* call negotiation.
|
||||
* @return byte[] a byte array containing the image or null if no image is
|
||||
* available.
|
||||
*/
|
||||
public byte[] getImage();
|
||||
|
||||
/**
|
||||
* Returns the protocol provider that this peer belongs to.
|
||||
* @return a reference to the ProtocolProviderService that this peer
|
||||
* belongs to.
|
||||
*/
|
||||
public ProtocolProviderService getProtocolProvider();
|
||||
|
||||
/**
|
||||
* Returns the contact corresponding to this peer or null if no
|
||||
* particular contact has been associated.
|
||||
* <p>
|
||||
* @return the <tt>Contact</tt> corresponding to this peer or null
|
||||
* if no particular contact has been associated.
|
||||
*/
|
||||
public Contact getContact();
|
||||
|
||||
/**
|
||||
* Returns a URL pointing to a location with call control information or
|
||||
* null if such an URL is not available for the current call peer.
|
||||
*
|
||||
* @return a URL link to a location with call information or a call control
|
||||
* web interface related to this peer or <tt>null</tt> if no such URL
|
||||
* is available.
|
||||
*/
|
||||
public URL getCallInfoURL();
|
||||
|
||||
/**
|
||||
* Determines whether the audio stream (if any) being sent to this
|
||||
* peer is mute.
|
||||
*
|
||||
* @return <tt>true</tt> if an audio stream is being sent to this
|
||||
* peer and it is currently mute; <tt>false</tt>, otherwise
|
||||
*/
|
||||
public boolean isMute();
|
||||
|
||||
/**
|
||||
* Determines whether this peer is acting as a conference focus and
|
||||
* thus may provide information about <code>ConferenceMember</code> such as
|
||||
* {@link #getConferenceMembers()} and {@link #getConferenceMemberCount()}.
|
||||
*
|
||||
* @return <tt>true</tt> if this peer is acting as a conference
|
||||
* focus; <tt>false</tt>, otherwise
|
||||
*/
|
||||
public boolean isConferenceFocus();
|
||||
|
||||
/**
|
||||
* Gets the <code>ConferenceMember</code>s currently known to this
|
||||
* peer if it is acting as a conference focus.
|
||||
*
|
||||
* @return an array of <code>ConferenceMember</code>s describing the members
|
||||
* of a conference managed by this peer if it is acting as a
|
||||
* conference focus. If this peer is not acting as a
|
||||
* conference focus or it does but there are currently no members in
|
||||
* the conference it manages, an empty array is returned.
|
||||
*/
|
||||
public ConferenceMember[] getConferenceMembers();
|
||||
|
||||
/**
|
||||
* Gets the number of <code>ConferenceMember</code>s currently known to this
|
||||
* peer if it is acting as a conference focus.
|
||||
*
|
||||
* @return the number of <code>ConferenceMember</code>s currently known to
|
||||
* this peer if it is acting as a conference focus. If this
|
||||
* peer is not acting as a conference focus or it does but
|
||||
* there are currently no members in the conference it manages, a
|
||||
* value of zero is returned.
|
||||
*/
|
||||
public int getConferenceMemberCount();
|
||||
|
||||
/**
|
||||
* Adds a specific <code>CallPeerConferenceListener</code> to the
|
||||
* list of listeners interested in and notified about changes in
|
||||
* conference-related information such as this peer acting or not
|
||||
* acting as a conference focus and conference membership details.
|
||||
*
|
||||
* @param listener
|
||||
* a <code>CallPeerConferenceListener</code> to be
|
||||
* notified about changes in conference-related information. If
|
||||
* the specified listener is already in the list of interested
|
||||
* listeners (i.e. it has been previously added), it is not added
|
||||
* again.
|
||||
*/
|
||||
public void addCallPeerConferenceListener(
|
||||
CallPeerConferenceListener listener);
|
||||
|
||||
/**
|
||||
* Removes a specific <code>CallPeerConferenceListener</code> from
|
||||
* the list of listeners interested in and notified about changes in
|
||||
* conference-related information such as this peer acting or not
|
||||
* acting as a conference focus and conference membership details.
|
||||
*
|
||||
* @param listener
|
||||
* a <code>CallPeerConferenceListener</code> to no longer
|
||||
* be notified about changes in conference-related information
|
||||
*/
|
||||
public void removeCallPeerConferenceListener(
|
||||
CallPeerConferenceListener listener);
|
||||
}
|
||||
@ -0,0 +1,300 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.protocol;
|
||||
|
||||
/**
|
||||
* The CallPeerState class reflects the current state of a call
|
||||
* peer. In other words when you start calling your grand mother she will
|
||||
* be in a INITIATING_CALL state, when her phone rings her state will change to
|
||||
* ALERTING_REMOTE_SIDE, and when she replies she will enter a CONNCECTED state.
|
||||
*
|
||||
* <p>Though not mandatory CallPeerState would generally have one of the
|
||||
* following life cycles
|
||||
*
|
||||
* <p> In the case with your grand mother that we just described we have:
|
||||
* <br>INITIATING_CALL -> CONNECTING -> ALERTING_REMOTE_USER -> CONNECTED -> DISCONNECTED
|
||||
*
|
||||
* <p> If your granny was already on the phone we have:
|
||||
* <br>INITIATING_CALL -> CONNECTING -> BUSY -> DISCONNECTED
|
||||
*
|
||||
* <p>Whenever someone tries to reach you:
|
||||
* <br>INCOMING_CALL -> CONNECTED -> DISCONNECTED
|
||||
*
|
||||
* <p>A FAILED state is prone to appear at any place in the above diagram and is
|
||||
* generally followed by a disconnected state.
|
||||
*
|
||||
* <p>Information on call peer is shown in the phone user interface until
|
||||
* they enter the DISCONNECTED state. At that point call peer information
|
||||
* is automatically removed from the user interface and the call is considered
|
||||
* terminated.
|
||||
*
|
||||
* @author Emil Ivov
|
||||
* @author Lubomir Marinov
|
||||
*/
|
||||
public class CallPeerState
|
||||
{
|
||||
/**
|
||||
* This constant value indicates a String representation of the UNKNOWN
|
||||
* call state.
|
||||
* <br>This constant has the String value "Unknown".
|
||||
*/
|
||||
public static final String _UNKNOWN = "Unknown";
|
||||
|
||||
/**
|
||||
* This constant value indicates that the state of the call peer is
|
||||
* is UNKNOWN - which means that there is no information on the state for
|
||||
* the time being (this constant should be used as a default value for
|
||||
* newly created call peer that don't yet have an attributed call
|
||||
* state.
|
||||
*/
|
||||
public static final CallPeerState UNKNOWN =
|
||||
new CallPeerState(_UNKNOWN);
|
||||
|
||||
/**
|
||||
* This constant value indicates a String representation of the
|
||||
* INITIATING_CALL call state.
|
||||
* <br>This constant has the String value "Initiating Call".
|
||||
*/
|
||||
public static final String _INITIATING_CALL = "Initiating Call";
|
||||
|
||||
/**
|
||||
* This constant value indicates that the state of the call peer is
|
||||
* is INITIATING_CALL - which means that we're currently trying to open a
|
||||
* socket and send our request. In the case of SIP for example we will leave
|
||||
* this state the moment we receive a "100 Trying" request from a proxy or
|
||||
* the remote side.
|
||||
*/
|
||||
public static final CallPeerState INITIATING_CALL =
|
||||
new CallPeerState(_INITIATING_CALL);
|
||||
|
||||
/**
|
||||
* This constant value indicates a String representation of the CONNECTING
|
||||
* call state.
|
||||
* <br>This constant has the String value "Connecting".
|
||||
*/
|
||||
public static final String _CONNECTING = "Connecting";
|
||||
|
||||
/**
|
||||
* This constant value indicates that the state of the call peer is
|
||||
* CONNECTING - which means that a network connection to that peer
|
||||
* is currently being established.
|
||||
*/
|
||||
public static final CallPeerState CONNECTING =
|
||||
new CallPeerState(_CONNECTING);
|
||||
|
||||
/**
|
||||
* This constant value indicates a String representation of the CONNECTING
|
||||
* call state but in cases where early media is being exchanged.
|
||||
* <br>This constant has the String value "Connecting".
|
||||
*/
|
||||
public static final String _CONNECTING_WITH_EARLY_MEDIA = "Connecting*";
|
||||
|
||||
/**
|
||||
* This constant value indicates that the state of the call peer is
|
||||
* CONNECTING - which means that a network connection to that peer
|
||||
* is currently being established.
|
||||
*/
|
||||
public static final CallPeerState CONNECTING_WITH_EARLY_MEDIA =
|
||||
new CallPeerState( _CONNECTING_WITH_EARLY_MEDIA );
|
||||
|
||||
/**
|
||||
* This constant value indicates a String representation of the
|
||||
* ALERTING_REMOTE_SIDE call state.
|
||||
* <br>This constant has the String value "Alerting Remote User".
|
||||
*/
|
||||
public static final String _ALERTING_REMOTE_SIDE
|
||||
= "Alerting Remote User (Ringing)";
|
||||
|
||||
/**
|
||||
* This constant value indicates that the state of the call peer is
|
||||
* is ALERTING_REMOTE_SIDE - which means that a network connection to that
|
||||
* peer has been established and peer's phone is currently alerting the
|
||||
* remote user of the current call.
|
||||
*/
|
||||
public static final CallPeerState ALERTING_REMOTE_SIDE =
|
||||
new CallPeerState(_ALERTING_REMOTE_SIDE);
|
||||
|
||||
/**
|
||||
* This constant value indicates a String representation of the
|
||||
* INCOMING_CALL call state.
|
||||
* <br>This constant has the String value "Incoming Call".
|
||||
*/
|
||||
public static final String _INCOMING_CALL = "Incoming Call";
|
||||
|
||||
/**
|
||||
* This constant value indicates that the state of the call peer is
|
||||
* is INCOMING_CALL - which means that the peer is willing to start
|
||||
* a call with us. At that point local side should be playing a sound or a
|
||||
* graphical alert (the phone is ringing).
|
||||
*/
|
||||
public static final CallPeerState INCOMING_CALL
|
||||
= new CallPeerState(_INCOMING_CALL);
|
||||
|
||||
/**
|
||||
* This constant value indicates a String representation of the CONNECTED
|
||||
* call state.
|
||||
* <br>This constant has the String value "Connected".
|
||||
*/
|
||||
public static final String _CONNECTED = "Connected";
|
||||
|
||||
/**
|
||||
* This constant value indicates that the state of the call peer is
|
||||
* is CONNECTED - which means that there is an ongoing call with that
|
||||
* peer.
|
||||
*/
|
||||
public static final CallPeerState CONNECTED
|
||||
= new CallPeerState(_CONNECTED);
|
||||
|
||||
/**
|
||||
* This constant value indicates a String representation of the DISCONNECTED
|
||||
* call state.
|
||||
* <br>This constant has the String value "Disconnected".
|
||||
*/
|
||||
public static final String _DISCONNECTED = "Disconnected";
|
||||
|
||||
/**
|
||||
* This constant value indicates that the state of the call peer is
|
||||
* is DISCONNECTET - which means that this peer is not participating :)
|
||||
* in the call any more.
|
||||
*/
|
||||
public static final CallPeerState DISCONNECTED =
|
||||
new CallPeerState(_DISCONNECTED);
|
||||
|
||||
/**
|
||||
* This constant value indicates a String representation of the BUSY
|
||||
* call state.
|
||||
* <br>This constant has the String value "Busy".
|
||||
*/
|
||||
public static final String _BUSY = "Busy";
|
||||
|
||||
/**
|
||||
* This constant value indicates that the state of the call peer is
|
||||
* is BUSY - which means that an attempt to establish a call with that
|
||||
* peer has been made and that it has been turned down by them (e.g.
|
||||
* because they were already in a call).
|
||||
*/
|
||||
public static final CallPeerState BUSY
|
||||
= new CallPeerState(_BUSY);
|
||||
|
||||
/**
|
||||
* This constant value indicates a String representation of the FAILED
|
||||
* call state.
|
||||
* <br>This constant has the String value "Failed".
|
||||
*/
|
||||
public static final String _FAILED = "Failed";
|
||||
/**
|
||||
* This constant value indicates that the state of the call peer is
|
||||
* is ON_HOLD - which means that an attempt to establish a call with that
|
||||
* peer has failed for an unexpected reason.
|
||||
*/
|
||||
public static final CallPeerState FAILED
|
||||
= new CallPeerState(_FAILED);
|
||||
|
||||
/**
|
||||
* The constant value being a String representation of the ON_HOLD_LOCALLY
|
||||
* call peer state.
|
||||
* <p>
|
||||
* This constant has the String value "Locally On Hold".
|
||||
* </p>
|
||||
*/
|
||||
public static final String _ON_HOLD_LOCALLY = "Locally On Hold";
|
||||
/**
|
||||
* The constant value indicating that the state of a call peer is
|
||||
* locally put on hold.
|
||||
*/
|
||||
public static final CallPeerState ON_HOLD_LOCALLY
|
||||
= new CallPeerState(_ON_HOLD_LOCALLY);
|
||||
|
||||
/**
|
||||
* The constant value being a String representation of the ON_HOLD_MUTUALLY
|
||||
* call peer state.
|
||||
* <p>
|
||||
* This constant has the String value "Mutually On Hold".
|
||||
* </p>
|
||||
*/
|
||||
public static final String _ON_HOLD_MUTUALLY = "Mutually On Hold";
|
||||
/**
|
||||
* The constant value indicating that the state of a call peer is
|
||||
* mutually - locally and remotely - put on hold.
|
||||
*/
|
||||
public static final CallPeerState ON_HOLD_MUTUALLY
|
||||
= new CallPeerState(_ON_HOLD_MUTUALLY);
|
||||
|
||||
/**
|
||||
* The constant value being a String representation of the ON_HOLD_REMOTELY
|
||||
* call peer state.
|
||||
* <p>
|
||||
* This constant has the String value "Remotely On Hold".
|
||||
* </p>
|
||||
*/
|
||||
public static final String _ON_HOLD_REMOTELY = "Remotely On Hold";
|
||||
|
||||
/**
|
||||
* The constant value indicating that the state of a call peer is
|
||||
* remotely put on hold.
|
||||
*/
|
||||
public static final CallPeerState ON_HOLD_REMOTELY
|
||||
= new CallPeerState(_ON_HOLD_REMOTELY);
|
||||
|
||||
/**
|
||||
* Determines whether a specific <tt>CallPeerState</tt> value
|
||||
* signal a call hold regardless of the issuer (which may be local and/or
|
||||
* remote).
|
||||
*
|
||||
* @param state
|
||||
* the <tt>CallPeerState</tt> value to be checked
|
||||
* whether it signals a call hold
|
||||
* @return <tt>true</tt> if the specified <tt>state</tt> signals a call
|
||||
* hold; <tt>false</tt>, otherwise
|
||||
*/
|
||||
public static final boolean isOnHold(CallPeerState state)
|
||||
{
|
||||
return CallPeerState.ON_HOLD_LOCALLY.equals(state)
|
||||
|| CallPeerState.ON_HOLD_MUTUALLY.equals(state)
|
||||
|| CallPeerState.ON_HOLD_REMOTELY.equals(state);
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of this peer's Call State. Could be
|
||||
* _CONNECTED, _FAILED, _CALLING and etc.
|
||||
*/
|
||||
private String callStateStr;
|
||||
|
||||
/**
|
||||
* Create a peer call state object with a value corresponding to the
|
||||
* specified string.
|
||||
* @param callPeerState a string representation of the state.
|
||||
*/
|
||||
private CallPeerState(String callPeerState)
|
||||
{
|
||||
this.callStateStr = callPeerState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of tha CallPeerState.
|
||||
*
|
||||
* @return A string value (one of the _BUSY, _CALLING, _CONNECTED,
|
||||
* _CONNECTING, _DISCONNECTED, _FAILED, _RINGING constants) representing
|
||||
* this call peer state).
|
||||
*/
|
||||
public String getStateString()
|
||||
{
|
||||
return callStateStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this call state. Strings returned
|
||||
* by this method have the following format:
|
||||
* CallPeerState:<STATE_STRING>
|
||||
* and are meant to be used for logging/debugging purposes.
|
||||
* @return a string representation of this object.
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return getClass().getName()+":"+getStateString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.protocol.event;
|
||||
|
||||
/**
|
||||
* An abstract adapter class for receiving call peer (change) events.
|
||||
* This class exists only as a convenience for creating listener objects.
|
||||
* <p>
|
||||
* Extend this class to create a <tt>CallPeerChangeEvent</tt> listener
|
||||
* and override the methods for the events of interest. (If you implement the
|
||||
* <tt>CallPeerListener</tt> interface, you have to define all of the
|
||||
* methods in it. This abstract class defines null methods for them all, so you
|
||||
* only have to define methods for events you care about.)
|
||||
* </p>
|
||||
*
|
||||
* @see CallPeerChangeEvent
|
||||
* @see CallPeerListener
|
||||
*
|
||||
* @author Lubomir Marinov
|
||||
*/
|
||||
public abstract class CallPeerAdapter
|
||||
implements CallPeerListener
|
||||
{
|
||||
|
||||
/**
|
||||
* Indicates that a change has occurred in the address of the source
|
||||
* CallPeer.
|
||||
*
|
||||
* @param evt The <tt>CallPeerChangeEvent</tt> instance containing
|
||||
* the source event as well as its previous and its new address.
|
||||
*/
|
||||
public void peerAddressChanged(CallPeerChangeEvent evt)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that a change has occurred in the display name of the source
|
||||
* CallPeer.
|
||||
*
|
||||
* @param evt The <tt>CallPeerChangeEvent</tt> instance containing
|
||||
* the source event as well as its previous and its new display
|
||||
* names.
|
||||
*/
|
||||
public void peerDisplayNameChanged(CallPeerChangeEvent evt)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that a change has occurred in the image of the source
|
||||
* CallPeer.
|
||||
*
|
||||
* @param evt The <tt>CallPeerChangeEvent</tt> instance containing
|
||||
* the source event as well as its previous and its new image.
|
||||
*/
|
||||
public void peerImageChanged(CallPeerChangeEvent evt)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that a change has occurred in the status of the source
|
||||
* CallPeer.
|
||||
*
|
||||
* @param evt The <tt>CallPeerChangeEvent</tt> instance containing
|
||||
* the source event as well as its previous and its new status.
|
||||
*/
|
||||
public void peerStateChanged(CallPeerChangeEvent evt)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that a change has occurred in the transport address that we use
|
||||
* to communicate with the peer.
|
||||
*
|
||||
* @param evt The <tt>CallPeerChangeEvent</tt> instance containing
|
||||
* the source event as well as its previous and its new transport
|
||||
* address.
|
||||
*/
|
||||
public void peerTransportAddressChanged(
|
||||
CallPeerChangeEvent evt)
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,164 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.protocol.event;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
* CallPeerChangeEvent-s are triggerred whenever a change occurs in a
|
||||
* CallPeer. Dispatched events may be of one of the following types.
|
||||
* <p>
|
||||
* CALL_PEER_STATUS_CHANGE - indicates a change in the status of the
|
||||
* peer.
|
||||
* <p>
|
||||
* CALL_PEER_DISPLAY_NAME_CHANGE - means that peer's displayName
|
||||
* has changed
|
||||
* <p>
|
||||
* CALL_PEER_ADDRESS_CHANGE - means that peer's address has
|
||||
* changed.
|
||||
* <p>
|
||||
* CALL_PEER_ADDRESS_CHANGE - means that the transport address of the
|
||||
* peer (the one that we use to communicate with her) has changed.
|
||||
* <p>
|
||||
* CALL_PEER_IMAGE_CHANGE - peer updated photo.
|
||||
* <p>
|
||||
*
|
||||
* @author Emil Ivov
|
||||
*/
|
||||
public class CallPeerChangeEvent
|
||||
extends java.beans.PropertyChangeEvent
|
||||
{
|
||||
/**
|
||||
* An event type indicating that the corresponding event is caused by a
|
||||
* change of the CallPeer's status.
|
||||
*/
|
||||
public static final String CALL_PEER_STATE_CHANGE =
|
||||
"CallPeerStatusChange";
|
||||
|
||||
/**
|
||||
* An event type indicating that the corresponding event is caused by a
|
||||
* change of the peer's display name.
|
||||
*/
|
||||
public static final String CALL_PEER_DISPLAY_NAME_CHANGE =
|
||||
"CallPeerDisplayNameChange";
|
||||
|
||||
/**
|
||||
* An event type indicating that the corresponding event is caused by a
|
||||
* change of the peer's address.
|
||||
*/
|
||||
public static final String CALL_PEER_ADDRESS_CHANGE =
|
||||
"CallPeerAddressChange";
|
||||
|
||||
/**
|
||||
* An event type indicating that the corresponding event is caused by a
|
||||
* change of the peer's address.
|
||||
*/
|
||||
public static final String CALL_PEER_TRANSPORT_ADDRESS_CHANGE =
|
||||
"CallPeerAddressChange";
|
||||
|
||||
/**
|
||||
* An event type indicating that the corresponding event is caused by a
|
||||
* change of the peer's photo/picture.
|
||||
*/
|
||||
public static final String CALL_PEER_IMAGE_CHANGE =
|
||||
"CallPeerImageChange";
|
||||
|
||||
/**
|
||||
* A reason string further explaining the event (may be null). The string
|
||||
* would be mostly used for events issued upon a CallPeerState
|
||||
* transition that has led to a FAILED state.
|
||||
*/
|
||||
private final String reason;
|
||||
|
||||
/**
|
||||
* Creates a CallPeerChangeEvent with the specified source, type,
|
||||
* oldValue and newValue.
|
||||
* @param source the peer that produced the event.
|
||||
* @param type the type of the event (i.e. address change, state change etc.).
|
||||
* @param oldValue the value of the changed property before the event occurred
|
||||
* @param newValue current value of the changed property.
|
||||
*/
|
||||
public CallPeerChangeEvent(CallPeer source,
|
||||
String type,
|
||||
Object oldValue,
|
||||
Object newValue)
|
||||
{
|
||||
this(source, type, oldValue, newValue, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a CallPeerChangeEvent with the specified source, type,
|
||||
* oldValue and newValue.
|
||||
* @param source the peer that produced the event.
|
||||
* @param type the type of the event (i.e. address change, state change etc.).
|
||||
* @param oldValue the value of the changed property before the event occurred
|
||||
* @param newValue current value of the changed property.
|
||||
* @param reason a string containing a human readable explanation for the
|
||||
* reason that triggerred this event (may be null).
|
||||
*/
|
||||
public CallPeerChangeEvent(CallPeer source,
|
||||
String type,
|
||||
Object oldValue,
|
||||
Object newValue,
|
||||
String reason)
|
||||
{
|
||||
super(source, type, oldValue, newValue);
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of this event.
|
||||
* @return a string containing one of the following values:
|
||||
* CALL_PEER_STATUS_CHANGE, CALL_PEER_DISPLAY_NAME_CHANGE,
|
||||
* CALL_PEER_ADDRESS_CHANGE, CALL_PEER_IMAGE_CHANGE
|
||||
*/
|
||||
public String getEventType()
|
||||
{
|
||||
return getPropertyName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this CallPeerChangeEvent.
|
||||
*
|
||||
* @return A a String representation of this CallPeerChangeEvent.
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
|
||||
return "CallPeerChangeEvent: type="+getEventType()
|
||||
+ " oldV="+getOldValue()
|
||||
+ " newV="+getNewValue()
|
||||
+ " for peer=" + getSourceCallPeer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>CallPeer</tt> that this event is about.
|
||||
*
|
||||
* @return a reference to the <tt>CallPeer</tt> that is the source
|
||||
* of this event.
|
||||
*/
|
||||
public CallPeer getSourceCallPeer()
|
||||
{
|
||||
return (CallPeer)getSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reason string further explaining the event (may be null). The
|
||||
* string would be mostly used for events issued upon a CallPeerState
|
||||
* transition that has led to a FAILED state.
|
||||
*
|
||||
* @return a reason string further explaining the event or null if no reason
|
||||
* was set.
|
||||
*/
|
||||
public String getReasonString()
|
||||
{
|
||||
return reason;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,164 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.protocol.event;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
* Represents an event fired by a <code>CallPeer</code> to notify
|
||||
* interested <code>CallPeerConferenceListener</code>s about changes in
|
||||
* its conference-related information such as it acting or not acting as a
|
||||
* conference focus and conference membership details.
|
||||
*
|
||||
* @author Lubomir Marinov
|
||||
*/
|
||||
public class CallPeerConferenceEvent
|
||||
extends EventObject
|
||||
{
|
||||
|
||||
/**
|
||||
* The ID of <code>CallPeerConferenceEvent</code> which notifies
|
||||
* about a change in the characteristic of a specific
|
||||
* <code>CallPeer</code> being a conference focus. The event does not
|
||||
* carry information about a specific <code>ConferenceMember</code> i.e. the
|
||||
* <code>conferenceMember</code> property is of value <tt>null</tt>.
|
||||
*/
|
||||
public static final int CONFERENCE_FOCUS_CHANGED = 1;
|
||||
|
||||
/**
|
||||
* The ID of <code>CallPeerConferenceEvent</code> which notifies
|
||||
* about an addition to the list of <code>ConferenceMember</code>s managed
|
||||
* by a specific <code>CallPeer</code>. The
|
||||
* <code>conferenceMember</code> property specifies the
|
||||
* <code>ConferenceMember</code> which was added and thus caused the event
|
||||
* to be fired.
|
||||
*/
|
||||
public static final int CONFERENCE_MEMBER_ADDED = 2;
|
||||
|
||||
/**
|
||||
* The ID of <code>CallPeerConferenceEvent</code> which notifies
|
||||
* about a removal from the list of <code>ConferenceMember</code>s managed
|
||||
* by a specific <code>CallPeer</code>. The
|
||||
* <code>conferenceMember</code> property specifies the
|
||||
* <code>ConferenceMember</code> which was removed and thus caused the event
|
||||
* to be fired.
|
||||
*/
|
||||
public static final int CONFERENCE_MEMBER_REMOVED = 3;
|
||||
|
||||
/**
|
||||
* The <code>ConferenceMember</code> which has been changed (e.g. added to
|
||||
* or removed from the conference) if this event has been fired because of
|
||||
* such a change; otherwise, <tt>null</tt>.
|
||||
*/
|
||||
private final ConferenceMember conferenceMember;
|
||||
|
||||
/**
|
||||
* The ID of this event which may be one of
|
||||
* {@link #CONFERENCE_FOCUS_CHANGED}, {@link #CONFERENCE_MEMBER_ADDED} and
|
||||
* {@link #CONFERENCE_MEMBER_REMOVED} and indicates the specifics of the
|
||||
* change in the conference-related information and the details this event
|
||||
* carries.
|
||||
*/
|
||||
private final int eventID;
|
||||
|
||||
/**
|
||||
* Initializes a new <code>CallPeerConferenceEvent</code> which is to
|
||||
* be fired by a specific <code>CallPeer</code> and which notifies
|
||||
* about a change in its conference-related information not including a
|
||||
* change pertaining to a specific <code>ConferenceMember</code>.
|
||||
*
|
||||
* @param source
|
||||
* the <code>CallPeer</code> which is to fire the new
|
||||
* event
|
||||
* @param eventID
|
||||
* the ID of this event which may be
|
||||
* {@link #CONFERENCE_FOCUS_CHANGED} and indicates the specifics
|
||||
* of the change in the conference-related information and the
|
||||
* details this event carries
|
||||
*/
|
||||
public CallPeerConferenceEvent(CallPeer source, int eventID)
|
||||
{
|
||||
this(source, eventID, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new <code>CallPeerConferenceEvent</code> which is to
|
||||
* be fired by a specific <code>CallPeer</code> and which notifies
|
||||
* about a change in its conference-related information pertaining to a
|
||||
* specific <code>ConferenceMember</code>.
|
||||
*
|
||||
* @param source
|
||||
* the <code>CallPeer</code> which is to fire the new
|
||||
* event
|
||||
* @param eventID
|
||||
* the ID of this event which may be
|
||||
* {@link #CONFERENCE_MEMBER_ADDED} and
|
||||
* {@link #CONFERENCE_MEMBER_REMOVED} and indicates the specifics
|
||||
* of the change in the conference-related information and the
|
||||
* details this event carries
|
||||
* @param conferenceMember
|
||||
* the <code>ConferenceMember</code> which caused the new event
|
||||
* to be fired
|
||||
*/
|
||||
public CallPeerConferenceEvent(
|
||||
CallPeer source,
|
||||
int eventID,
|
||||
ConferenceMember conferenceMember)
|
||||
{
|
||||
super(source);
|
||||
|
||||
this.eventID = eventID;
|
||||
this.conferenceMember = conferenceMember;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <code>ConferenceMember</code> which has been changed (e.g. added
|
||||
* to or removed from the conference) if this event has been fired because
|
||||
* of such a change.
|
||||
*
|
||||
* @return the <code>ConferenceMember</code> which has been changed if this
|
||||
* event has been fired because of such a change; otherwise,
|
||||
* <tt>null</tt>
|
||||
*/
|
||||
public ConferenceMember getConferenceMember()
|
||||
{
|
||||
return conferenceMember;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ID of this event which may be one of
|
||||
* {@link #CONFERENCE_FOCUS_CHANGED}, {@link #CONFERENCE_MEMBER_ADDED} and
|
||||
* {@link #CONFERENCE_MEMBER_REMOVED} and indicates the specifics of the
|
||||
* change in the conference-related information and the details this event
|
||||
* carries.
|
||||
*
|
||||
* @return the ID of this event which may be one of
|
||||
* {@link #CONFERENCE_FOCUS_CHANGED},
|
||||
* {@link #CONFERENCE_MEMBER_ADDED} and
|
||||
* {@link #CONFERENCE_MEMBER_REMOVED} and indicates the specifics of
|
||||
* the change in the conference-related information and the details
|
||||
* this event carries
|
||||
*/
|
||||
public int getEventID()
|
||||
{
|
||||
return eventID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <code>CallPeer</code> which is the source of/fired the
|
||||
* event.
|
||||
*
|
||||
* @return the <code>CallPeer</code> which is the source of/fired the
|
||||
* event
|
||||
*/
|
||||
public CallPeer getSourceCallPeer()
|
||||
{
|
||||
return (CallPeer) getSource();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.protocol.event;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Represents a listener of changes in the conference-related information of
|
||||
* <code>CallPeer</code> delivered in the form of
|
||||
* <code>CallPeerConferenceEvent</code>s.
|
||||
*
|
||||
* @author Lubomir Marinov
|
||||
*/
|
||||
public interface CallPeerConferenceListener
|
||||
extends EventListener
|
||||
{
|
||||
|
||||
/**
|
||||
* Notifies this listener about a change in the characteristic of being a
|
||||
* conference focus of a specific <code>CallPeer</code>.
|
||||
*
|
||||
* @param conferenceEvent
|
||||
* a <code>CallPeerConferenceEvent</code> with ID
|
||||
* <code>CallPeerConferenceEvent#CONFERENCE_FOCUS_CHANGED</code>
|
||||
* and no associated <code>ConferenceMember</code>
|
||||
*/
|
||||
public void conferenceFocusChanged(
|
||||
CallPeerConferenceEvent conferenceEvent);
|
||||
|
||||
/**
|
||||
* Notifies this listener about the addition of a specific
|
||||
* <code>ConferenceMember</code> to the list of
|
||||
* <code>ConferenceMember</code>s of a specific <code>CallPeer</code>
|
||||
* acting as a conference focus.
|
||||
*
|
||||
* @param conferenceEvent
|
||||
* a <code>CallPeerConferenceEvent</code> with ID
|
||||
* <code>CallPeerConferenceEvent#CONFERENCE_MEMBER_ADDED</code>
|
||||
* and <code>conferenceMember</code> property specifying the
|
||||
* <code>ConferenceMember</code> which was added
|
||||
*/
|
||||
public void conferenceMemberAdded(
|
||||
CallPeerConferenceEvent conferenceEvent);
|
||||
|
||||
/**
|
||||
* Notifies this listener about the removal of a specific
|
||||
* <code>ConferenceMember</code> from the list of
|
||||
* <code>ConferenceMember</code>s of a specific <code>CallPeer</code>
|
||||
* acting as a conference focus.
|
||||
*
|
||||
* @param conferenceEvent
|
||||
* a <code>CallPeerConferenceEvent</code> with ID
|
||||
* <code>CallPeerConferenceEvent#CONFERENCE_MEMBER_REMOVED</code>
|
||||
* and <code>conferenceMember</code> property specifying the
|
||||
* <code>ConferenceMember</code> which was removed
|
||||
*/
|
||||
public void conferenceMemberRemoved(
|
||||
CallPeerConferenceEvent conferenceEvent);
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
package net.java.sip.communicator.service.protocol.event;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
* The CallPeerControlEvent is issued by the PhoneUIService as a result
|
||||
* of a user request to modify the way a CallPeer is associated with a
|
||||
* call, or in other words "Answer" the incoming call of a CallPeer or
|
||||
* "Hangup" and thus and the participation of a CallPeer in a call. The
|
||||
* source of the event is considered to be the CallPeer that is being
|
||||
* controlled. As the event might also be used to indicate a user request to
|
||||
* transfer a given call peer to a different number, the class also contains
|
||||
* a targetURI field, containing the address that a client is being redirected to
|
||||
* (the target uri might also have slightly different meanings depending on the
|
||||
* method dispatching the event).
|
||||
*
|
||||
* @author Emil Ivov
|
||||
*/
|
||||
public class CallPeerControlEvent
|
||||
extends java.util.EventObject
|
||||
{
|
||||
private final String targetURI;
|
||||
|
||||
/**
|
||||
* Creates a new event instance with the specified source CallPeer
|
||||
* and targetURI, if any.
|
||||
* @param source the CallPeer that this event is pertaining to.
|
||||
* @param targetURI the URI to transfer to if this is a "Transfer" event
|
||||
* or null otherwise.
|
||||
*/
|
||||
public CallPeerControlEvent(CallPeer source, String targetURI)
|
||||
{
|
||||
super(source);
|
||||
this.targetURI = targetURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the CallPeer that this event is pertaining to.
|
||||
* @return the CallPeer that this event is pertaining to.
|
||||
*/
|
||||
public CallPeer getAssociatedCallPeer()
|
||||
{
|
||||
return (CallPeer) source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the target URI if this is event is triggered by a transfer
|
||||
* request or null if not.
|
||||
* @return null or a tranfer URI.
|
||||
*/
|
||||
public String getTargetURI()
|
||||
{
|
||||
return targetURI;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.protocol.event;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Emil Ivov
|
||||
*/
|
||||
public class CallPeerEvent
|
||||
extends EventObject
|
||||
{
|
||||
/**
|
||||
* The call that the source call peer is associated with.
|
||||
*/
|
||||
private final Call sourceCall;
|
||||
|
||||
/**
|
||||
* An event id value indicating that this event is about the fact that
|
||||
* the source call peer has joined the source call.
|
||||
*/
|
||||
public static final int CALL_PEER_ADDED = 1;
|
||||
|
||||
/**
|
||||
* An event id value indicating that this event is about the fact that
|
||||
* the source call peer has left the source call.
|
||||
*/
|
||||
public static final int CALL_PEER_REMVOVED = 2;
|
||||
|
||||
/**
|
||||
* The id indicating the type of this event.
|
||||
*/
|
||||
private final int eventID;
|
||||
|
||||
/**
|
||||
* Creates a call peer event instance indicating that an event with
|
||||
* id <tt>eventID</tt> has happened to <tt>sourceCallPeer</tt> in
|
||||
* <tt>sourceCall</tt>
|
||||
* @param sourceCallPeer the call peer that this event is
|
||||
* about.
|
||||
* @param sourceCall the call that the source call peer is associated
|
||||
* with.
|
||||
* @param eventID one of the CALL_PEER_XXX member ints indicating
|
||||
* the type of this event.
|
||||
*/
|
||||
public CallPeerEvent(CallPeer sourceCallPeer,
|
||||
Call sourceCall,
|
||||
int eventID)
|
||||
{
|
||||
super(sourceCallPeer);
|
||||
this.sourceCall = sourceCall;
|
||||
this.eventID = eventID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returnst one of the CALL_PEER_XXX member ints indicating
|
||||
* the type of this event.
|
||||
* @return one of the CALL_PEER_XXX member ints indicating
|
||||
* the type of this event.
|
||||
*/
|
||||
public int getEventID()
|
||||
{
|
||||
return this.eventID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the call that the source call peer is associated with.
|
||||
*
|
||||
* @return a reference to the <tt>Call</tt> that the source call peer
|
||||
* is associated with.
|
||||
*/
|
||||
public Call getSourceCall()
|
||||
{
|
||||
return sourceCall;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the source call peer (the one that this event is about).
|
||||
*
|
||||
* @return a reference to the source <tt>CallPeer</tt> instance.
|
||||
*/
|
||||
public CallPeer getSourceCallPeer()
|
||||
{
|
||||
return (CallPeer)getSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this <tt>CallPeerEvent</tt>.
|
||||
*
|
||||
* @return a String representation of this <tt>CallPeerEvent</tt>.
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
|
||||
return "CallPeerEvent: ID=" + getEventID()
|
||||
+ " source peer=" + getSourceCallPeer()
|
||||
+ " source call=" + getSourceCall();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.protocol.event;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* Receives events notifying of changes that have occurred within a
|
||||
* <tt>CallPeer</tt>. Such changes may pertain to current call
|
||||
* peer state, their display name, address, image and (possibly in the
|
||||
* future) others.
|
||||
*
|
||||
* @author Emil Ivov
|
||||
*/
|
||||
public interface CallPeerListener
|
||||
extends EventListener
|
||||
{
|
||||
|
||||
/**
|
||||
* Indicates that a change has occurred in the status of the source
|
||||
* CallPeer.
|
||||
*
|
||||
* @param evt The <tt>CallPeerChangeEvent</tt> instance containing
|
||||
* the source event as well as its previous and its new status.
|
||||
*/
|
||||
public void peerStateChanged(CallPeerChangeEvent evt);
|
||||
|
||||
/**
|
||||
* Indicates that a change has occurred in the display name of the source
|
||||
* CallPeer.
|
||||
*
|
||||
* @param evt The <tt>CallPeerChangeEvent</tt> instance containing
|
||||
* the source event as well as its previous and its new display names.
|
||||
*/
|
||||
public void peerDisplayNameChanged(CallPeerChangeEvent evt);
|
||||
|
||||
/**
|
||||
* Indicates that a change has occurred in the address of the source
|
||||
* CallPeer.
|
||||
*
|
||||
* @param evt The <tt>CallPeerChangeEvent</tt> instance containing
|
||||
* the source event as well as its previous and its new address.
|
||||
*/
|
||||
public void peerAddressChanged(CallPeerChangeEvent evt);
|
||||
|
||||
/**
|
||||
* Indicates that a change has occurred in the transport address that we
|
||||
* use to communicate with the peer.
|
||||
*
|
||||
* @param evt The <tt>CallPeerChangeEvent</tt> instance containing
|
||||
* the source event as well as its previous and its new transport address.
|
||||
*/
|
||||
public void peerTransportAddressChanged(
|
||||
CallPeerChangeEvent evt);
|
||||
|
||||
/**
|
||||
* Indicates that a change has occurred in the image of the source
|
||||
* CallPeer.
|
||||
*
|
||||
* @param evt The <tt>CallPeerChangeEvent</tt> instance containing
|
||||
* the source event as well as its previous and its new image.
|
||||
*/
|
||||
public void peerImageChanged(CallPeerChangeEvent evt);
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.protocol.event;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* CallPeerSecurityListener interface extends EventListener. This is the
|
||||
* listener interface used to handle an event related with a change in security
|
||||
* status.
|
||||
*
|
||||
* The change in security status is triggered at the protocol level, which
|
||||
* signal security state changes to the GUI. This modifies the current security
|
||||
* status indicator for the call sessions.
|
||||
*
|
||||
* @author Werner Dittmann
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public interface CallPeerSecurityListener
|
||||
extends EventListener
|
||||
{
|
||||
/**
|
||||
* The handler for the security event received. The security event
|
||||
* represents an indication of change in the security status.
|
||||
*
|
||||
* @param securityEvent
|
||||
* the security event received
|
||||
*/
|
||||
public void securityOn(
|
||||
CallPeerSecurityOnEvent securityEvent);
|
||||
|
||||
/**
|
||||
* The handler for the security event received. The security event
|
||||
* represents an indication of change in the security status.
|
||||
*
|
||||
* @param securityEvent
|
||||
* the security event received
|
||||
*/
|
||||
public void securityOff(
|
||||
CallPeerSecurityOffEvent securityEvent);
|
||||
|
||||
/**
|
||||
* The handler of the security message event.
|
||||
*
|
||||
* @param event the security message event.
|
||||
*/
|
||||
public void securityMessageRecieved(
|
||||
CallPeerSecurityMessageEvent event);
|
||||
}
|
||||
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.protocol.event;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
* The <tt>CallParticipantSecurityFailedEvent</tt> is triggered whenever
|
||||
* a problem has occurred during call security process.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
* @author Werner Dittmann
|
||||
*/
|
||||
public class CallPeerSecurityMessageEvent
|
||||
extends EventObject
|
||||
{
|
||||
/**
|
||||
* This is a information message. Security will be established.
|
||||
*/
|
||||
public static final int INFORMATION = 0;
|
||||
|
||||
/**
|
||||
* This is a warning message. Security will not be established.
|
||||
*/
|
||||
public static final int WARNING = 1;
|
||||
|
||||
/**
|
||||
* This is a severe error. Security will not be established.
|
||||
*/
|
||||
public static final int SEVERE = 2;
|
||||
|
||||
/**
|
||||
* This is a ZRTP error message. Security will not be established.
|
||||
*/
|
||||
public static final int ERROR = 3;
|
||||
|
||||
/**
|
||||
* The internationalized message associated with this event.
|
||||
*/
|
||||
private final String eventI18nMessage;
|
||||
|
||||
/**
|
||||
* The message associated with this event.
|
||||
*/
|
||||
private final String eventMessage;
|
||||
|
||||
/**
|
||||
* The severity of the security message event.
|
||||
*/
|
||||
private final int eventSeverity;
|
||||
|
||||
/**
|
||||
* Creates a <tt>CallPeerSecurityFailedEvent</tt> by specifying the
|
||||
* call peer, event type and message associated with this event.
|
||||
*
|
||||
* @param callPeer the call peer implied in this event.
|
||||
* @param eventType the type of the event. One of the constants defined in
|
||||
* this class.
|
||||
* @param eventMessage the message associated with this event.
|
||||
* @param i18nMessage the internationalized message associated with this
|
||||
* event that could be shown to the user.
|
||||
*/
|
||||
public CallPeerSecurityMessageEvent( CallPeer callPeer,
|
||||
String eventMessage,
|
||||
String i18nMessage,
|
||||
int eventSeverity)
|
||||
{
|
||||
super(callPeer);
|
||||
|
||||
this.eventMessage = eventMessage;
|
||||
this.eventI18nMessage = i18nMessage;
|
||||
this.eventSeverity = eventSeverity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the message associated with this event.
|
||||
*
|
||||
* @return the message associated with this event.
|
||||
*/
|
||||
public String getMessage()
|
||||
{
|
||||
return eventMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the internationalized message associated with this event.
|
||||
*
|
||||
* @return the internationalized message associated with this event.
|
||||
*/
|
||||
public String getI18nMessage()
|
||||
{
|
||||
return eventI18nMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event severity.
|
||||
*
|
||||
* @return the eventSeverity
|
||||
*/
|
||||
public int getEventSeverity() {
|
||||
return eventSeverity;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.protocol.event;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
* The <tt>CallPeerSecurityAuthenticationEvent</tt> is triggered whenever
|
||||
* a the security strings are received in a secure call.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class CallPeerSecurityOffEvent
|
||||
extends CallPeerSecurityStatusEvent
|
||||
{
|
||||
|
||||
/**
|
||||
* The event constructor.
|
||||
*
|
||||
* @param callPeer the call peer associated with this event
|
||||
* @param sessionType the type of the session: audio or video
|
||||
*/
|
||||
public CallPeerSecurityOffEvent( CallPeer callPeer,
|
||||
int sessionType)
|
||||
{
|
||||
super(callPeer, sessionType);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.protocol.event;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
* The <tt>CallPeerSecurityOnEvent</tt> is triggered whenever a
|
||||
* communication with a given peer is going secure.
|
||||
*
|
||||
* @author Werner Dittmann
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class CallPeerSecurityOnEvent
|
||||
extends CallPeerSecurityStatusEvent
|
||||
{
|
||||
private final String securityString;
|
||||
|
||||
private final boolean isVerified;
|
||||
|
||||
private final String cipher;
|
||||
|
||||
/**
|
||||
* The event constructor
|
||||
*
|
||||
* @param callPeer the call peer associated with this event
|
||||
* @param sessionType the type of the session, either AUDIO_SESSION or
|
||||
* VIDEO_SESSION
|
||||
* @param cipher the cipher used for the encryption
|
||||
* @param securityString the security string (SAS)
|
||||
* @param isVerified indicates if the security string has already been
|
||||
* verified
|
||||
*/
|
||||
public CallPeerSecurityOnEvent( CallPeer callPeer,
|
||||
int sessionType,
|
||||
String cipher,
|
||||
String securityString,
|
||||
boolean isVerified)
|
||||
{
|
||||
super(callPeer, sessionType);
|
||||
|
||||
this.cipher = cipher;
|
||||
this.securityString = securityString;
|
||||
this.isVerified = isVerified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>CallPeer</tt> for which this event occurred.
|
||||
*
|
||||
* @return the <tt>CallPeer</tt> for which this event occurred.
|
||||
*/
|
||||
public CallPeer getCallPeer()
|
||||
{
|
||||
return (CallPeer) getSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cipher used for the encryption.
|
||||
*
|
||||
* @return the cipher used for the encryption.
|
||||
*/
|
||||
public String getCipher()
|
||||
{
|
||||
return cipher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the security string.
|
||||
*
|
||||
* @return the security string.
|
||||
*/
|
||||
public String getSecurityString()
|
||||
{
|
||||
return securityString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the security string was already verified
|
||||
* and <code>false</code> - otherwise.
|
||||
*
|
||||
* @return <code>true</code> if the security string was already verified
|
||||
* and <code>false</code> - otherwise.
|
||||
*/
|
||||
public boolean isSecurityVerified()
|
||||
{
|
||||
return isVerified;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.protocol.event;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Parent class for SecurityOn and SecurityOff events.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public abstract class CallPeerSecurityStatusEvent
|
||||
extends EventObject
|
||||
{
|
||||
/**
|
||||
* Constant value defining that security is enabled.
|
||||
*/
|
||||
public static final int AUDIO_SESSION = 1;
|
||||
|
||||
/**
|
||||
* Constant value defining that security is disabled.
|
||||
*/
|
||||
public static final int VIDEO_SESSION = 2;
|
||||
|
||||
private final int sessionType;
|
||||
|
||||
/**
|
||||
* Constructor required by the EventObject.
|
||||
*
|
||||
* @param source the source object for this event.
|
||||
* @param sessionType either <code>AUDIO_SESSION</code> or
|
||||
* <code>VIDEO_SESSION</code> to indicate the type of the
|
||||
* session
|
||||
*/
|
||||
public CallPeerSecurityStatusEvent(Object source, int sessionType)
|
||||
{
|
||||
super(source);
|
||||
|
||||
this.sessionType = sessionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the session, either AUDIO_SESSION or VIDEO_SESSION.
|
||||
*
|
||||
* @return the type of the session, either AUDIO_SESSION or VIDEO_SESSION.
|
||||
*/
|
||||
public int getSessionType()
|
||||
{
|
||||
return sessionType;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue