@ -1,6 +1,6 @@
/ *
* 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 ;
@ -23,8 +23,8 @@
/ * *
* The < tt > CallPanel < / tt > is the panel containing call information . It ' s created
* and added to the main tabbed pane when user makes or receives calls . It shows
* information about call p articipant s, call duration , etc .
*
* information about call p eer s, call duration , etc .
*
* @author Yana Stamcheva
* @author Lubomir Marinov
* /
@ -38,19 +38,18 @@ public class CallPanel
private final TransparentPanel mainPanel = new TransparentPanel ( ) ;
private final Hashtable < CallPeer , CallPeerPanel >
participantsPanels =
new Hashtable < CallPeer , CallPeerPanel > ( ) ;
peersPanels = new Hashtable < CallPeer , CallPeerPanel > ( ) ;
private String title ;
private Call call ;
private final CallDialog callDialog ;
/ * *
* Creates a call panel for the corresponding call , by specifying the
* Creates a call panel for the corresponding call , by specifying the
* call type ( incoming or outgoing ) and the parent dialog .
*
*
* @param callDialog the dialog containing this panel
* @param call the call corresponding to this panel
* @param callType the type of the call
@ -70,40 +69,38 @@ public CallPanel(CallDialog callDialog, Call call, String callType)
if ( contactsCount > 0 )
{
CallPeer participant =
call . getCallPeers ( ) . next ( ) ;
CallPeer peer = call . getCallPeers ( ) . next ( ) ;
this . title = p articipant . getDisplayName ( ) ;
this . title = p eer . getDisplayName ( ) ;
}
this . setCall ( call , callType ) ;
}
/ * *
* Creates and adds a panel for a call p articipant .
*
* @param p articipant the call participant
* Creates and adds a panel for a call p eer .
*
* @param p eer the call peer
* @param callType the type of call - INCOMING of OUTGOING
* /
private CallPeerPanel addCallP articipant (
CallPeer p articipant , String callType )
private CallPeerPanel addCallP eer (
CallPeer p eer , String callType )
{
CallPeerPanel participantPanel =
getParticipantPanel ( participant ) ;
CallPeerPanel peerPanel = getPeerPanel ( peer ) ;
if ( p articipant Panel = = null )
if ( p eer Panel = = null )
{
p articipant Panel
= new CallPeerPanel ( callDialog , p articipant ) ;
p eer Panel
= new CallPeerPanel ( callDialog , p eer ) ;
this . mainPanel . add ( p articipant Panel) ;
this . mainPanel . add ( p eer Panel) ;
p articipant Panel. setCallType ( callType ) ;
p eer Panel. setCallType ( callType ) ;
this . p articipantsPanels. put ( participant , participant Panel) ;
this . p eersPanels. put ( peer , peer Panel) ;
}
if ( p articipant sPanels. size ( ) > 1 )
if ( p eer sPanels. size ( ) > 1 )
{
SCScrollPane scrollPane = new SCScrollPane ( ) ;
scrollPane . setViewportView ( mainPanel ) ;
@ -114,14 +111,14 @@ private CallPeerPanel addCallParticipant(
this . add ( mainPanel ) ;
}
return p articipant Panel;
return p eer Panel;
}
/ * *
* Returns the title of this call panel . The title is now the name of the
* first p articipant in the list of the call participant s. Should be
* first p eer in the list of the call peer s. Should be
* improved in the future .
*
*
* @return the title of this call panel
* /
public String getTitle ( )
@ -130,14 +127,14 @@ public String getTitle()
}
/ * *
* Implements the CallChangeListener . callP articipant Added method . When a new
* p articipant is added to our call add it to the call panel .
* Implements the CallChangeListener . callP eer Added method . When a new
* p eer is added to our call add it to the call panel .
* /
public void callPeerAdded ( CallPeerEvent evt )
{
if ( evt . getSourceCall ( ) = = call )
{
this . addCallP articipant ( evt . getSourceCallPeer ( ) , null ) ;
this . addCallP eer ( evt . getSourceCallPeer ( ) , null ) ;
this . revalidate ( ) ;
this . repaint ( ) ;
@ -145,31 +142,31 @@ public void callPeerAdded(CallPeerEvent evt)
}
/ * *
* Implements the CallChangeListener . callP articipant Removed method . When a
* call p articipant is removed from our call remove it from the call panel .
* Implements the CallChangeListener . callP eer Removed method . When a
* call p eer is removed from our call remove it from the call panel .
* /
public void callPeerRemoved ( CallPeerEvent evt )
{
if ( evt . getSourceCall ( ) = = call )
{
CallPeer p articipant = evt . getSourceCallPeer ( ) ;
CallPeer p eer = evt . getSourceCallPeer ( ) ;
CallPeerPanel p articipant Panel =
getP articipantPanel( participant ) ;
CallPeerPanel p eer Panel =
getP eerPanel( peer ) ;
if ( p articipant Panel ! = null )
if ( p eer Panel ! = null )
{
CallPeerState state = p articipant . getState ( ) ;
CallPeerState state = p eer . getState ( ) ;
p articipant Panel. setState ( state . getStateString ( ) , null ) ;
p eer Panel. setState ( state . getStateString ( ) , null ) ;
p articipant Panel. stopCallTimer ( ) ;
p eer Panel. stopCallTimer ( ) ;
if ( p articipant sPanels. size ( ) ! = 0 )
if ( p eer sPanels. size ( ) ! = 0 )
{
Timer timer =
new Timer ( 5000 , new RemoveP articipant PanelListener(
p articipant ) ) ;
new Timer ( 5000 , new RemoveP eer PanelListener(
p eer ) ) ;
timer . setRepeats ( false ) ;
timer . start ( ) ;
@ -186,22 +183,22 @@ public void callStateChanged(CallChangeEvent evt)
}
/ * *
* Implements the CallParicipantChangeListener . p articipant StateChanged
* Implements the CallParicipantChangeListener . p eer StateChanged
* method .
* /
public void peerStateChanged ( CallPeerChangeEvent evt )
{
CallPeer sourceP articipant = evt . getSourceCallPeer ( ) ;
CallPeer sourceP eer = evt . getSourceCallPeer ( ) ;
if ( sourceP articipant . getCall ( ) ! = call )
if ( sourceP eer . getCall ( ) ! = call )
return ;
CallPeerPanel p articipant Panel =
getP articipantPanel( sourceParticipant ) ;
CallPeerPanel p eer Panel =
getP eerPanel( sourcePeer ) ;
Object newState = evt . getNewValue ( ) ;
String newStateString = sourceP articipant . getState ( ) . getStateString ( ) ;
String newStateString = sourceP eer . getState ( ) . getStateString ( ) ;
Icon newStateIcon = null ;
if ( newState = = CallPeerState . ALERTING_REMOTE_SIDE )
@ -227,18 +224,18 @@ else if (newState == CallPeerState.CONNECTED)
NotificationManager
. stopSound ( NotificationManager . INCOMING_CALL ) ;
p articipant Panel. startCallTimer ( ) ;
p eer Panel. startCallTimer ( ) ;
}
}
else if ( newState = = CallPeerState . DISCONNECTED )
{
// The call p articipant should be already removed from the call
// see callP articipant Removed
// The call p eer should be already removed from the call
// see callP eer Removed
}
else if ( newState = = CallPeerState . FAILED )
{
// The call p articipant should be already removed from the call
// see callP articipant Removed
// The call p eer should be already removed from the call
// see callP eer Removed
}
else if ( CallPeerState . isOnHold ( ( CallPeerState ) newState ) )
{
@ -255,7 +252,7 @@ else if (CallPeerState.isOnHold((CallPeerState) newState))
}
}
p articipant Panel. setState ( newStateString , newStateIcon ) ;
p eer Panel. setState ( newStateString , newStateIcon ) ;
}
public void peerDisplayNameChanged ( CallPeerChangeEvent evt )
@ -272,25 +269,23 @@ public void peerImageChanged(CallPeerChangeEvent evt)
public void securityOn ( CallPeerSecurityOnEvent securityEvent )
{
CallPeer participant =
( CallPeer ) securityEvent . getSource ( ) ;
CallPeerPanel participantPanel =
getParticipantPanel ( participant ) ;
CallPeer peer = ( CallPeer ) securityEvent . getSource ( ) ;
CallPeerPanel peerPanel = getPeerPanel ( peer ) ;
p articipant Panel. setSecured ( true ) ;
peerPanel . setSecured ( true ) ;
p articipant Panel. setEncryptionCipher ( securityEvent . getCipher ( ) ) ;
p eer Panel. setEncryptionCipher ( securityEvent . getCipher ( ) ) ;
switch ( securityEvent . getSessionType ( ) ) {
case CallPeerSecurityOnEvent . AUDIO_SESSION :
p articipant Panel. setAudioSecurityOn ( true ) ;
p eer Panel. setAudioSecurityOn ( true ) ;
break ;
case CallPeerSecurityOnEvent . VIDEO_SESSION :
p articipant Panel. setVideoSecurityOn ( true ) ;
p eer Panel. setVideoSecurityOn ( true ) ;
break ;
}
p articipant Panel. createSecurityPanel ( securityEvent ) ;
p eer Panel. createSecurityPanel ( securityEvent ) ;
NotificationManager . fireNotification (
NotificationManager . CALL_SECURITY_ON ) ;
@ -298,27 +293,25 @@ public void securityOn(CallPeerSecurityOnEvent securityEvent)
public void securityOff ( CallPeerSecurityOffEvent securityEvent )
{
CallPeer participant =
( CallPeer ) securityEvent . getSource ( ) ;
CallPeerPanel participantPanel =
getParticipantPanel ( participant ) ;
CallPeer peer = ( CallPeer ) securityEvent . getSource ( ) ;
CallPeerPanel peerPanel = getPeerPanel ( peer ) ;
p articipant Panel. setSecured ( false ) ;
peerPanel . setSecured ( false ) ;
switch ( securityEvent . getSessionType ( ) )
{
case CallPeerSecurityOnEvent . AUDIO_SESSION :
p articipant Panel. setAudioSecurityOn ( false ) ;
p eer Panel. setAudioSecurityOn ( false ) ;
break ;
case CallPeerSecurityOnEvent . VIDEO_SESSION :
p articipant Panel. setVideoSecurityOn ( false ) ;
p eer Panel. setVideoSecurityOn ( false ) ;
break ;
}
}
/ * *
* Returns the call for this call panel .
*
*
* @return the call for this call panel
* /
public Call getCall ( )
@ -328,7 +321,7 @@ public Call getCall()
/ * *
* Sets the < tt > Call < / tt > corresponding to this < tt > CallPanel < / tt > .
*
*
* @param call the < tt > Call < / tt > corresponding to this < tt > CallPanel < / tt >
* @param callType the call type - INCOMING or OUTGOING
* /
@ -338,104 +331,104 @@ private void setCall(Call call, String callType)
this . call . addCallChangeListener ( this ) ;
// Remove all previously added p articipant panels, because they do not
// correspond to real p articipant s.
// Remove all previously added p eer panels, because they do not
// correspond to real p eer s.
this . mainPanel . removeAll ( ) ;
this . p articipant sPanels. clear ( ) ;
this . p eer sPanels. clear ( ) ;
Iterator < CallPeer > p articipant s = call . getCallPeers ( ) ;
Iterator < CallPeer > p eer s = call . getCallPeers ( ) ;
while ( p articipant s. hasNext ( ) )
while ( p eer s. hasNext ( ) )
{
CallPeer p articipant = participant s. next ( ) ;
CallPeer p eer = peer s. next ( ) ;
p articipant . addCallPeerListener ( this ) ;
p articipant . addCallPeerSecurityListener ( this ) ;
p articipant . addPropertyChangeListener ( this ) ;
p eer . addCallPeerListener ( this ) ;
p eer . addCallPeerSecurityListener ( this ) ;
p eer . addPropertyChangeListener ( this ) ;
this . addCallP articipant( participant , callType ) ;
this . addCallP eer( peer , callType ) ;
}
}
/ * *
* Indicates that a change has occurred in the transport address that we use
* to communicate with the p articipant .
*
* @param evt The < tt > CallP articipant ChangeEvent< / tt > instance containing
* to communicate with the p eer .
*
* @param evt The < tt > CallP eer ChangeEvent< / tt > instance containing
* the source event as well as its previous and its new transport
* address .
* /
public void peerTransportAddressChanged (
CallPeerChangeEvent evt )
{
/** @todo implement p articipant TransportAddressChanged() */
/** @todo implement p eer TransportAddressChanged() */
}
/ * *
* Removes the given CallP articipant panel from this CallPanel .
* Removes the given CallP eer panel from this CallPanel .
* /
private class RemoveP articipant PanelListener
private class RemoveP eer PanelListener
implements ActionListener
{
private CallPeer p articipant ;
private CallPeer p eer ;
public RemoveP articipantPanelListener( CallPeer participant )
public RemoveP eerPanelListener( CallPeer peer )
{
this . p articipant = participant ;
this . p eer = peer ;
}
public void actionPerformed ( ActionEvent e )
{
CallPeerPanel p articipant Panel =
p articipantsPanels. get ( participant ) ;
CallPeerPanel p eer Panel =
p eersPanels. get ( peer ) ;
mainPanel . remove ( p articipant Panel) ;
mainPanel . remove ( p eer Panel) ;
// remove the p articipant panel from the list of panels
p articipantsPanels. remove ( participant ) ;
// remove the p eer panel from the list of panels
p eersPanels. remove ( peer ) ;
}
}
/ * *
* Returns all p articipant panels contained in this call panel .
*
* @return an < tt > Iterator < / tt > over a list of all p articipant panels
* Returns all p eer panels contained in this call panel .
*
* @return an < tt > Iterator < / tt > over a list of all p eer panels
* contained in this call panel
* /
public Iterator < CallPeerPanel > getP articipant Panels( )
public Iterator < CallPeerPanel > getP eer Panels( )
{
return p articipant sPanels. values ( ) . iterator ( ) ;
return p eer sPanels. values ( ) . iterator ( ) ;
}
/ * *
* Returns the number of p articipant s for this call .
*
* @return the number of p articipant s for this call .
* Returns the number of p eer s for this call .
*
* @return the number of p eer s for this call .
* /
public int getP articipant Count( )
public int getP eer Count( )
{
return p articipant sPanels. size ( ) ;
return p eer sPanels. size ( ) ;
}
/ * *
* Returns the < tt > CallP articipant Panel< / tt > , which correspond to the given
* p articipant .
*
* @param p articipant the < tt > CallParticipant < / tt > we ' re looking for
* @return the < tt > CallP articipant Panel< / tt > , which correspond to the given
* p articipant
* Returns the < tt > CallP eer Panel< / tt > , which correspond to the given
* p eer .
*
* @param p eer the < tt > CallPeer < / tt > we ' re looking for
* @return the < tt > CallP eer Panel< / tt > , which correspond to the given
* p eer
* /
public CallPeerPanel getP articipantPanel( CallPeer participant )
public CallPeerPanel getP eerPanel( CallPeer peer )
{
for ( Map . Entry < CallPeer , CallPeerPanel > p articipant Entry :
p articipant sPanels. entrySet ( ) )
for ( Map . Entry < CallPeer , CallPeerPanel > p eer Entry :
p eer sPanels. entrySet ( ) )
{
CallPeer entryP articipant = participant Entry. getKey ( ) ;
CallPeer entryP eer = peer Entry. getKey ( ) ;
if ( ( entryP articipant ! = null )
& & entryP articipant. equals ( participant ) )
if ( ( entryP eer ! = null )
& & entryP eer. equals ( peer ) )
{
return p articipant Entry. getValue ( ) ;
return p eer Entry. getValue ( ) ;
}
}
return null ;
@ -488,14 +481,13 @@ public void propertyChange(PropertyChangeEvent evt)
{
boolean isMute = ( Boolean ) evt . getNewValue ( ) ;
CallPeer sourceP articipant
CallPeer sourceP eer
= ( CallPeer ) evt . getSource ( ) ;
if ( sourceP articipant . getCall ( ) ! = call )
if ( sourceP eer . getCall ( ) ! = call )
return ;
CallPeerPanel participantPanel =
getParticipantPanel ( sourceParticipant ) ;
CallPeerPanel peerPanel = getPeerPanel ( sourcePeer ) ;
if ( isMute )
{
@ -507,7 +499,7 @@ public void propertyChange(PropertyChangeEvent evt)
}
}
p articipant Panel. setMute ( isMute ) ;
p eer Panel. setMute ( isMute ) ;
}
}
}