diff --git a/src/net/java/sip/communicator/impl/callhistory/CallPeerRecordImpl.java b/src/net/java/sip/communicator/impl/callhistory/CallPeerRecordImpl.java new file mode 100644 index 000000000..a69cf1b5a --- /dev/null +++ b/src/net/java/sip/communicator/impl/callhistory/CallPeerRecordImpl.java @@ -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; + } +} diff --git a/src/net/java/sip/communicator/impl/gui/main/call/GuiCallPeerRecord.java b/src/net/java/sip/communicator/impl/gui/main/call/GuiCallPeerRecord.java new file mode 100644 index 000000000..8599fce47 --- /dev/null +++ b/src/net/java/sip/communicator/impl/gui/main/call/GuiCallPeerRecord.java @@ -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 GuiCallPeerRecord is meant to be used in the call history + * to represent a history call peer record. It wraps a + * CallPeer or a CallPeerRecord 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; + } +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java new file mode 100644 index 000000000..143fe27ce --- /dev/null +++ b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java @@ -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 peerAddress. + * + * @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. + *
+ * @return the Contact 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()); + } +} diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java new file mode 100644 index 000000000..d3bce454a --- /dev/null +++ b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java @@ -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 peerAddress. + * + * @param peerAddress the JAIN SIP Address 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 SipProvider 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. + *
+ * @return the Contact 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 null 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 null 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 true if an audio stream is being sent to this
+ * peer and it is currently mute; false, 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);
+ }
+}
diff --git a/src/net/java/sip/communicator/service/callhistory/CallPeerRecord.java b/src/net/java/sip/communicator/service/callhistory/CallPeerRecord.java
new file mode 100644
index 000000000..c3eef6a8f
--- /dev/null
+++ b/src/net/java/sip/communicator/service/callhistory/CallPeerRecord.java
@@ -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;
+ }
+}
diff --git a/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java b/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java
new file mode 100644
index 000000000..a298eccb7
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java
@@ -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
+ *
+ * The default implementation returns false.
+ * 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
+ * @return the Contact 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 null if no such URL
+ * is available.
+ */
+ public URL getCallInfoURL();
+
+ /**
+ * Determines whether the audio stream (if any) being sent to this
+ * peer is mute.
+ *
+ * @return true if an audio stream is being sent to this
+ * peer and it is currently mute; false, otherwise
+ */
+ public boolean isMute();
+
+ /**
+ * Determines whether this peer is acting as a conference focus and
+ * thus may provide information about Though not mandatory CallPeerState would generally have one of the
+ * following life cycles
+ *
+ * In the case with your grand mother that we just described we have:
+ * If your granny was already on the phone we have:
+ * Whenever someone tries to reach you:
+ * A FAILED state is prone to appear at any place in the above diagram and is
+ * generally followed by a disconnected state.
+ *
+ * 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.
+ *
+ * This constant has the String value "Locally On Hold".
+ *
+ * This constant has the String value "Mutually On Hold".
+ *
+ * This constant has the String value "Remotely On Hold".
+ *
+ * Extend this class to create a CallPeerChangeEvent listener
+ * and override the methods for the events of interest. (If you implement the
+ * CallPeerListener 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.)
+ *
+ * CALL_PEER_STATUS_CHANGE - indicates a change in the status of the
+ * peer.
+ *
+ * CALL_PEER_DISPLAY_NAME_CHANGE - means that peer's displayName
+ * has changed
+ *
+ * CALL_PEER_ADDRESS_CHANGE - means that peer's address has
+ * changed.
+ *
+ * CALL_PEER_ADDRESS_CHANGE - means that the transport address of the
+ * peer (the one that we use to communicate with her) has changed.
+ *
+ * CALL_PEER_IMAGE_CHANGE - peer updated photo.
+ *
+ *
+ * @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 CallPeer that this event is about.
+ *
+ * @return a reference to the CallPeer 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;
+ }
+
+
+}
+
diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerConferenceEvent.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerConferenceEvent.java
new file mode 100644
index 000000000..e349721f3
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/event/CallPeerConferenceEvent.java
@@ -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 CallPeer 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
+ * ConferenceMembers (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 ListConferenceMember such as {@link #getConferenceMembers()} and
+ * {@link #getConferenceMemberCount()}.
+ */
+ private boolean conferenceFocus;
+
+ /**
+ * The list of ConferenceMembers currently known to and managed
+ * in a conference by this peer.
+ */
+ private final ListCallPeerConferenceListeners 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
+ * 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 null 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 null 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 CallPeer transitioned
+ * into a state (likely {@link CallPeerState#CONNECTED}) marking the
+ * start of the duration of the participation in a Call.
+ *
+ * @return the time at which this CallPeer transitioned
+ * into a state marking the start of the duration of the
+ * participation in a Call 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.
+ * ConferenceMember to the list of
+ * ConferenceMembers reported by this peer through
+ * {@link #getConferenceMembers()} and {@link #getConferenceMemberCount()}
+ * and fires
+ * CallPeerConferenceEvent#CONFERENCE_MEMBER_ADDED to
+ * the currently registered CallPeerConferenceListeners.
+ *
+ * @param conferenceMember
+ * a ConferenceMember to be added to the list of
+ * ConferenceMember reported by this peer. If
+ * the specified ConferenceMember 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 ConferenceMember from the list of
+ * ConferenceMembers reported by this peer through
+ * {@link #getConferenceMembers()} and {@link #getConferenceMemberCount()}
+ * if it is contained and fires
+ * CallPeerConferenceEvent#CONFERENCE_MEMBER_REMOVED to
+ * the currently registered CallPeerConferenceListeners.
+ *
+ * @param conferenceMember
+ * a ConferenceMember to be removed from the list of
+ * ConferenceMember reported by this peer. If
+ * the specified ConferenceMember 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 CallPeerConferenceEvent to the
+ * CallPeerConferenceListeners interested in changes in
+ * the conference-related information provided by this peer.
+ *
+ * @param conferenceEvent
+ * a CallPeerConferenceEvent 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;
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/service/protocol/CallPeer.java b/src/net/java/sip/communicator/service/protocol/CallPeer.java
new file mode 100644
index 000000000..cf662e2b1
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/CallPeer.java
@@ -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.
+ *
+ * CallPeer has not yet
+ * transitioned into a state marking the beginning of a participation in a
+ * Call 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 CallPeer transitioned
+ * into a state (likely {@link CallPeerState#CONNECTED}) marking the
+ * start of the duration of the participation in a Call.
+ *
+ * @return the time at which this CallPeer transitioned
+ * into a state marking the start of the duration of the
+ * participation in a Call 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
+ *
+ * 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.
+ * ConferenceMember such as
+ * {@link #getConferenceMembers()} and {@link #getConferenceMemberCount()}.
+ *
+ * @return true if this peer is acting as a conference
+ * focus; false, otherwise
+ */
+ public boolean isConferenceFocus();
+
+ /**
+ * Gets the ConferenceMembers currently known to this
+ * peer if it is acting as a conference focus.
+ *
+ * @return an array of ConferenceMembers 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 ConferenceMembers currently known to this
+ * peer if it is acting as a conference focus.
+ *
+ * @return the number of ConferenceMembers 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 CallPeerConferenceListener 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 CallPeerConferenceListener 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 CallPeerConferenceListener 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 CallPeerConferenceListener to no longer
+ * be notified about changes in conference-related information
+ */
+ public void removeCallPeerConferenceListener(
+ CallPeerConferenceListener listener);
+}
diff --git a/src/net/java/sip/communicator/service/protocol/CallPeerState.java b/src/net/java/sip/communicator/service/protocol/CallPeerState.java
new file mode 100644
index 000000000..b977d9f86
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/CallPeerState.java
@@ -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.
+ *
+ *
INITIATING_CALL -> CONNECTING -> ALERTING_REMOTE_USER -> CONNECTED -> DISCONNECTED
+ *
+ *
INITIATING_CALL -> CONNECTING -> BUSY -> DISCONNECTED
+ *
+ *
INCOMING_CALL -> CONNECTED -> DISCONNECTED
+ *
+ *
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.
+ *
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.
+ *
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.
+ *
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.
+ *
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.
+ *
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.
+ *
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.
+ *
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.
+ *
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.
+ *
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.
+ * CallPeer to notify
+ * interested CallPeerConferenceListeners 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 CallPeerConferenceEvent which notifies
+ * about a change in the characteristic of a specific
+ * CallPeer being a conference focus. The event does not
+ * carry information about a specific ConferenceMember i.e. the
+ * conferenceMember property is of value null.
+ */
+ public static final int CONFERENCE_FOCUS_CHANGED = 1;
+
+ /**
+ * The ID of CallPeerConferenceEvent which notifies
+ * about an addition to the list of ConferenceMembers managed
+ * by a specific CallPeer. The
+ * conferenceMember property specifies the
+ * ConferenceMember which was added and thus caused the event
+ * to be fired.
+ */
+ public static final int CONFERENCE_MEMBER_ADDED = 2;
+
+ /**
+ * The ID of CallPeerConferenceEvent which notifies
+ * about a removal from the list of ConferenceMembers managed
+ * by a specific CallPeer. The
+ * conferenceMember property specifies the
+ * ConferenceMember which was removed and thus caused the event
+ * to be fired.
+ */
+ public static final int CONFERENCE_MEMBER_REMOVED = 3;
+
+ /**
+ * The ConferenceMember 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, null.
+ */
+ 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 CallPeerConferenceEvent which is to
+ * be fired by a specific CallPeer and which notifies
+ * about a change in its conference-related information not including a
+ * change pertaining to a specific ConferenceMember.
+ *
+ * @param source
+ * the CallPeer 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 CallPeerConferenceEvent which is to
+ * be fired by a specific CallPeer and which notifies
+ * about a change in its conference-related information pertaining to a
+ * specific ConferenceMember.
+ *
+ * @param source
+ * the CallPeer 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 ConferenceMember 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 ConferenceMember 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 ConferenceMember which has been changed if this
+ * event has been fired because of such a change; otherwise,
+ * null
+ */
+ 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 CallPeer which is the source of/fired the
+ * event.
+ *
+ * @return the CallPeer which is the source of/fired the
+ * event
+ */
+ public CallPeer getSourceCallPeer()
+ {
+ return (CallPeer) getSource();
+ }
+}
diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerConferenceListener.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerConferenceListener.java
new file mode 100644
index 000000000..61fcb2ab0
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/event/CallPeerConferenceListener.java
@@ -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
+ * CallPeer delivered in the form of
+ * CallPeerConferenceEvents.
+ *
+ * @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 CallPeer.
+ *
+ * @param conferenceEvent
+ * a CallPeerConferenceEvent with ID
+ * CallPeerConferenceEvent#CONFERENCE_FOCUS_CHANGED
+ * and no associated ConferenceMember
+ */
+ public void conferenceFocusChanged(
+ CallPeerConferenceEvent conferenceEvent);
+
+ /**
+ * Notifies this listener about the addition of a specific
+ * ConferenceMember to the list of
+ * ConferenceMembers of a specific CallPeer
+ * acting as a conference focus.
+ *
+ * @param conferenceEvent
+ * a CallPeerConferenceEvent with ID
+ * CallPeerConferenceEvent#CONFERENCE_MEMBER_ADDED
+ * and conferenceMember property specifying the
+ * ConferenceMember which was added
+ */
+ public void conferenceMemberAdded(
+ CallPeerConferenceEvent conferenceEvent);
+
+ /**
+ * Notifies this listener about the removal of a specific
+ * ConferenceMember from the list of
+ * ConferenceMembers of a specific CallPeer
+ * acting as a conference focus.
+ *
+ * @param conferenceEvent
+ * a CallPeerConferenceEvent with ID
+ * CallPeerConferenceEvent#CONFERENCE_MEMBER_REMOVED
+ * and conferenceMember property specifying the
+ * ConferenceMember which was removed
+ */
+ public void conferenceMemberRemoved(
+ CallPeerConferenceEvent conferenceEvent);
+}
diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerControlEvent.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerControlEvent.java
new file mode 100644
index 000000000..824c6e3a1
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/event/CallPeerControlEvent.java
@@ -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;
+ }
+}
diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerEvent.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerEvent.java
new file mode 100644
index 000000000..614305181
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/event/CallPeerEvent.java
@@ -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 eventID has happened to sourceCallPeer in
+ * sourceCall
+ * @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 Call 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 CallPeer instance.
+ */
+ public CallPeer getSourceCallPeer()
+ {
+ return (CallPeer)getSource();
+ }
+
+ /**
+ * Returns a String representation of this CallPeerEvent.
+ *
+ * @return a String representation of this CallPeerEvent.
+ */
+ public String toString()
+ {
+
+ return "CallPeerEvent: ID=" + getEventID()
+ + " source peer=" + getSourceCallPeer()
+ + " source call=" + getSourceCall();
+ }
+
+}
diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerListener.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerListener.java
new file mode 100644
index 000000000..4f0bd3d4b
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/event/CallPeerListener.java
@@ -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
+ * CallPeer. 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 CallPeerChangeEvent 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 CallPeerChangeEvent 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 CallPeerChangeEvent 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 CallPeerChangeEvent 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 CallPeerChangeEvent instance containing
+ * the source event as well as its previous and its new image.
+ */
+ public void peerImageChanged(CallPeerChangeEvent evt);
+}
diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityListener.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityListener.java
new file mode 100755
index 000000000..2f445d0c3
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityListener.java
@@ -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);
+}
diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityMessageEvent.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityMessageEvent.java
new file mode 100644
index 000000000..34036e80f
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityMessageEvent.java
@@ -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 CallParticipantSecurityFailedEvent 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 CallPeerSecurityFailedEvent 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;
+ }
+}
diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityOffEvent.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityOffEvent.java
new file mode 100644
index 000000000..b9684af34
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityOffEvent.java
@@ -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 CallPeerSecurityAuthenticationEvent 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);
+ }
+}
diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityOnEvent.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityOnEvent.java
new file mode 100755
index 000000000..da22635bc
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityOnEvent.java
@@ -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 CallPeerSecurityOnEvent 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 CallPeer for which this event occurred.
+ *
+ * @return the CallPeer 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 true if the security string was already verified
+ * and false - otherwise.
+ *
+ * @return true if the security string was already verified
+ * and false - otherwise.
+ */
+ public boolean isSecurityVerified()
+ {
+ return isVerified;
+ }
+}
diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityStatusEvent.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityStatusEvent.java
new file mode 100644
index 000000000..0f30a6d0a
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityStatusEvent.java
@@ -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 AUDIO_SESSION or
+ * VIDEO_SESSION 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;
+ }
+}