aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferencePeerPanel.java
blob: f29cd0522b1554cf9d951de880de819b72aa1585 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
/*
 * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Copyright @ 2015 Atlassian Pty Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.java.sip.communicator.impl.gui.main.call.conference;

import java.awt.*;
import java.awt.event.*;
import java.util.*;

import javax.swing.*;

import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.main.call.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.plugin.desktoputil.*;
import net.java.sip.communicator.service.globaldisplaydetails.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.skin.*;

import net.java.sip.communicator.util.call.CallPeerAdapter;

import org.jitsi.service.neomedia.*;
import org.jitsi.service.protocol.event.*;
import org.jitsi.service.resources.*;

/**
 * Depicts a single <tt>CallPeer</tt> who participates in a telephony conference
 * and is not a focus or the local user/peer (identified by a specific
 * <tt>Call</tt> instance).
 *
 * @author Yana Stamcheva
 * @author Lyubomir Marinov
 * @author Adam Netocny
 */
public class ConferencePeerPanel
    extends BasicConferenceParticipantPanel<Object>
    implements ConferenceCallPeerRenderer,
               Skinnable
{
    /**
     * Serial version UID.
     */
    private static final long serialVersionUID = 0L;

    /**
     * The <tt>Call</tt> which represents the local peer depicted by this
     * instance. If <tt>null</tt>, then this instance does not depict the local
     * peer and depicts {@link #callPeer}.
     */
    private final Call call;

    /**
     * The <tt>CallPeer</tt> depicted by this instance. If <tt>null</tt>, then
     * this instance depicts the local peer represented by {@link #call}.
     */
    private final CallPeer callPeer;

    /**
     * The <tt>CallPeerAdapter</tt> which implements common
     * <tt>CallPeer</tt>-related listeners on behalf of this instance.
     */
    private final CallPeerAdapter callPeerAdapter;

    /**
     * The tools menu available for each peer.
     */
    private CallPeerMenu callPeerMenu;

    /**
     * The DTMF label.
     */
    private final JLabel dtmfLabel = new JLabel();

    /**
     * The label showing whether the voice has been set to mute.
     */
    private final JLabel holdStatusLabel = new JLabel();

    /**
     * The label showing whether the voice has been set to mute.
     */
    private final JLabel muteStatusLabel = new JLabel();

    /**
     * The component showing the security details.
     */
    private SecurityPanel<?> securityPanel;

    /**
     * The <tt>SoundLevelListener</tt> which listens to the changes in the
     * audio/sound level of the model of this instance. If {@link #callPeer} is
     * non-<tt>null</tt>, <tt>callPeer</tt> is the model of this instance i.e.
     * <tt>soundLevelListener</tt> will be added to the audio stream of
     * <tt>callPeer</tt> and will listen to local calculations of the audio
     * levels of the remote peer; otherwise, {@link #call} is the model of this
     * instance i.e. <tt>soundLevelListener</tt> will be added to <tt>call</tt>
     * and will listen to local calculations of the audio levels of the local
     * peer.
     */
    private final SoundLevelListenerImpl soundLevelListener
        = new SoundLevelListenerImpl();

    /**
     * Initializes a new <tt>ConferencePeerPanel</tt> which is to depict the
     * local peer represented by a specific <tt>Call</tt> on behalf of a
     * specific <tt>BasicConferenceCallPanel</tt> i.e. <tt>CallRenderer</tt>.
     *
     * @param callRenderer the <tt>BasicConferenceCallPanel</tt> which requests
     * the initialization of the new instance and which will use the new
     * instance to depict the local peer represented by the specified
     * <tt>Call</tt>
     * @param call the <tt>Call</tt> which represents the local peer to be
     * depicted by the new instance
     * @param video <tt>true</tt> if the new instance will be associated with a
     * display of video (e.g. which will be streaming to the <tt>CallPeer</tt>s
     * associated with the specified <tt>call</tt>); otherwise, <tt>false</tt>
     * @throws NullPointerException if <tt>call</tt> is <tt>null</tt>
     */
    public ConferencePeerPanel(
            BasicConferenceCallPanel callRenderer,
            Call call,
            boolean video)
    {
        super(callRenderer, call, video);

        if (call == null)
            throw new NullPointerException("call");

        this.call = call;
        this.callPeer = null;

        callPeerAdapter = null;

        String globalDisplayName = null;
        // Try to set the same image as the one in the main window. This way
        // we improve our chances to have an image, instead of looking only at
        // the protocol provider avatar, which could be null, we look for any
        // image coming from one of our accounts.
        GlobalDisplayDetailsService displayDetailsService
            = GuiActivator.getGlobalDisplayDetailsService();

        if(displayDetailsService != null)
        {
            byte[] globalAccountImage
                = displayDetailsService.getGlobalDisplayAvatar();

            if((globalAccountImage != null) && (globalAccountImage.length > 0))
                setPeerImage(globalAccountImage);

            globalDisplayName = displayDetailsService.getGlobalDisplayName();
        }

        ResourceManagementService resources = GuiActivator.getResources();

        setPeerName(
                (globalDisplayName != null && globalDisplayName.length() > 0)
                ? globalDisplayName
                    + " ("
                    + call.getProtocolProvider().getAccountID().getDisplayName()
                    + ")"
                : call.getProtocolProvider().getAccountID().getDisplayName());

        setTitleBackground(
                video
                    ? Color.DARK_GRAY
                    : new Color(
                            resources.getColor(
                                    "service.gui.CALL_LOCAL_USER_BACKGROUND")));

        if(isSoundLevelIndicatorEnabled())
            call.addLocalUserSoundLevelListener(soundLevelListener);
    }

    /**
     * Initializes a new <tt>ConferencePeerPanel</tt> which is to depict a
     * specific <tt>CallPeer</tt> on behalf of a specific
     * <tt>BasicConferenceCallPanel</tt> i.e. <tt>CallRenderer</tt>.
     *
     * @param callRenderer the <tt>BasicConferenceCallPanel</tt> which requests
     * the initialization of the new instance and which will use the new
     * instance to depict the specified <tt>CallPeer</tt>
     * @param callPeer the <tt>CallPeer</tt> to be depicted by the new instance
     */
    public ConferencePeerPanel(
            BasicConferenceCallPanel callRenderer,
            CallPeer callPeer)
    {
        this(callRenderer, callPeer, false);
    }

    /**
     * Initializes a new <tt>ConferencePeerPanel</tt> which is to depict a
     * specific <tt>CallPeer</tt> on behalf of a specific
     * <tt>BasicConferenceCallPanel</tt> i.e. <tt>CallRenderer</tt>.
     *
     * @param callRenderer the <tt>BasicConferenceCallPanel</tt> which requests
     * the initialization of the new instance and which will use the new
     * instance to depict the specified <tt>CallPeer</tt>
     * @param callPeer the <tt>CallPeer</tt> to be depicted by the new instance
     * @param video <tt>true</tt> if the new instance will be associated with a
     * display of video (e.g. which will be streaming from the specified
     * <tt>callPeer</tt>); otherwise, <tt>false</tt>
     * @throws NullPointerException if <tt>callPeer</tt> is <tt>null</tt>
     */
    public ConferencePeerPanel(
            BasicConferenceCallPanel callRenderer,
            CallPeer callPeer,
            boolean video)
    {
        super(callRenderer, callPeer, video);

        if (callPeer == null)
            throw new NullPointerException("callPeer");

        this.call = null;
        this.callPeer = callPeer;

        securityPanel = SecurityPanel.create(this, callPeer, null);

        setMute(callPeer.isMute());

        setPeerImage(CallManager.getPeerImage(callPeer));
        setPeerName(callPeer.getDisplayName());

        // We initialize the status bar for call peers only.
        initStatusBar(callPeer);

        callPeerMenu = new CallPeerMenu(callPeer, callRenderer);

        SIPCommMenuBar menuBar = new SIPCommMenuBar();

        menuBar.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
        menuBar.add(callPeerMenu);
        addToNameBar(menuBar);

        setTitleBackground(
                video
                    ? Color.DARK_GRAY
                    : new Color(
                            GuiActivator.getResources().getColor(
                                    "service.gui.CALL_PEER_NAME_BACKGROUND")));

        initSecuritySettings();

        callPeerAdapter = new CallPeerAdapter(this.callPeer, this);

        if(isSoundLevelIndicatorEnabled())
            this.callPeer.addStreamSoundLevelListener(soundLevelListener);
    }

    /**
     * {@inheritDoc}
     */
    public void dispose()
    {
        if (callPeerAdapter != null)
            callPeerAdapter.dispose();
        if (callPeer != null)
        {
            callPeer.removeConferenceMembersSoundLevelListener(
                    soundLevelListener);
            callPeer.removeStreamSoundLevelListener(soundLevelListener);
        }
        if (call != null)
            call.removeLocalUserSoundLevelListener(soundLevelListener);
    }

    /**
     * Gets the <tt>Call</tt> associated with this instance. If this instance
     * depicts the local peer, it was initialized with a specific <tt>Call</tt>
     * which represents the local peer. If this instance depicts an actual
     * <tt>CallPeer</tt>, its associated <tt>Call</tt> is returned.
     *
     * @return the <tt>Call</tt> associated with this instance
     */
    public Call getCall()
    {
        return (callPeer == null) ? call : callPeer.getCall();
    }

    /**
     * Returns <tt>CallPeer</tt> contact address.
     *
     * @return <tt>CallPeer</tt> contact address
     */
    public String getCallPeerContactAddress()
    {
        return callPeer.getURI();
    }

    /**
     * {@inheritDoc}
     *
     * Returns this instance.
     */
    public Component getComponent()
    {
        return this;
    }

    /**
     * Initializes the security settings for this call peer.
     */
    private void initSecuritySettings()
    {
        securityStatusLabel.setSecurityOff();

        CallPeerSecurityStatusEvent securityEvent
            = callPeer.getCurrentSecuritySettings();

        if (securityEvent != null
            && securityEvent instanceof CallPeerSecurityOnEvent)
        {
            CallPeerSecurityOnEvent securityOnEvt
                = (CallPeerSecurityOnEvent) securityEvent;

            securityOn(securityOnEvt);
        }

        securityStatusLabel.setBorder(
            BorderFactory.createEmptyBorder(2, 5, 2, 5));

        securityStatusLabel.addMouseListener(new MouseAdapter()
        {
            /**
             * Invoked when a mouse button has been pressed on a component.
             */
            @Override
            public void mousePressed(MouseEvent e)
            {
                setSecurityPanelVisible(
                        !getCallPanel().getCallWindow().getFrame()
                                .getGlassPane().isVisible());
            }
        });
    }

    /**
     * Initializes the status bar component for the given <tt>callPeer</tt>.
     *
     * @param callPeer the underlying peer, which status would be displayed
     */
    private void initStatusBar(CallPeer callPeer)
    {
        initSecurityStatusLabel();
        this.setParticipantState(callPeer.getState().getLocalizedStateString());

        this.addToStatusBar(holdStatusLabel);
        this.addToStatusBar(muteStatusLabel);
        this.addToStatusBar(dtmfLabel);
    }

    /**
     * Indicates if the local video component is currently visible.
     *
     * @return <tt>true</tt> if the local video component is currently visible,
     * <tt>false</tt> - otherwise
     */
    public boolean isLocalVideoVisible()
    {
        return false;
    }

    /**
     * Determines whether the indicator which depicts the sound/audio levels (of
     * the local or remote peer in a call) is to be enabled. For example, the
     * indicator may be disabled for performance-related reasons.
     *
     * @return <tt>true</tt> if the indicator which depicts the sound/audio
     * levels (of the local or remote peer in a call) is to be enabled;
     * otherwise, <tt>false</tt>
     */
    static boolean isSoundLevelIndicatorEnabled()
    {
        return
            !GuiActivator.getConfigurationService().getBoolean(
                    "net.java.sip.communicator.impl.gui.main.call"
                        + ".DISABLE_SOUND_LEVEL_INDICATORS",
                    false);
    }

    /**
     * Reloads style information.
     */
    @Override
    public void loadSkin()
    {
        setTitleBackground(
                new Color(
                        GuiActivator.getResources().getColor(
                                "service.gui.CALL_LOCAL_USER_BACKGROUND")));

        if(muteStatusLabel.getIcon() != null)
        {
            muteStatusLabel.setIcon(
                    new ImageIcon(
                            ImageLoader.getImage(
                                    ImageLoader.MUTE_STATUS_ICON)));
        }
        if(holdStatusLabel.getIcon() != null)
        {
            holdStatusLabel.setIcon(
                    new ImageIcon(
                            ImageLoader.getImage(
                                    ImageLoader.HOLD_STATUS_ICON)));
        }
        if(callPeerMenu != null)
            callPeerMenu.loadSkin();
    }

    /**
     * Prints the given DTMG character through this <tt>CallPeerRenderer</tt>.
     * @param dtmfChar the DTMF char to print
     */
    public void printDTMFTone(char dtmfChar)
    {
        dtmfLabel.setText(dtmfLabel.getText() + dtmfChar);
    }

    /**
     * Re-dispatches glass pane mouse events only in case they occur on the
     * security panel.
     *
     * @param glassPane the glass pane
     * @param e the mouse event in question
     */
    private void redispatchMouseEvent(Component glassPane, MouseEvent e)
    {
        Point glassPanePoint = e.getPoint();
        Point securityPanelPoint
            = SwingUtilities.convertPoint(
                    glassPane,
                    glassPanePoint,
                    securityPanel);

        Component component;
        Point componentPoint;

        if (securityPanelPoint.y > 0)
        {
            component = securityPanel;
            componentPoint = securityPanelPoint;
        }
        else
        {
            Container contentPane
                = getCallPanel().getCallWindow().getFrame().getContentPane();
            Point containerPoint
                = SwingUtilities.convertPoint(
                        glassPane,
                        glassPanePoint,
                        contentPane);

            component
                = SwingUtilities.getDeepestComponentAt(
                        contentPane,
                        containerPoint.x,
                        containerPoint.y);
            componentPoint
                = SwingUtilities.convertPoint(
                        contentPane,
                        glassPanePoint,
                        component);
        }

        if (component != null)
        {
            component.dispatchEvent(
                    new MouseEvent(
                            component,
                            e.getID(),
                            e.getWhen(),
                            e.getModifiers(),
                            componentPoint.x,
                            componentPoint.y,
                            e.getClickCount(),
                            e.isPopupTrigger()));
        }

        e.consume();
    }

    /**
     * The handler for the security event received. The security event
     * for starting establish a secure connection.
     *
     * @param securityNegotiationStartedEvent
     *            the security started event received
     */
    public void securityNegotiationStarted(
        CallPeerSecurityNegotiationStartedEvent securityNegotiationStartedEvent)
    {

    }

    /**
     * Indicates that the security has gone off.
     *
     * @param evt Details about the event that caused this message.
     */
    @Override
    public void securityOff(CallPeerSecurityOffEvent evt)
    {
        super.securityOff(evt);

        if(securityPanel != null)
        {
            securityPanel.securityOff(evt);
        }
    }

    /**
     * Indicates that the security is turned on.
     * <p>
     * Sets the secured status icon to the status panel and initializes/updates
     * the corresponding security details.
     *
     * @param evt Details about the event that caused this message.
     */
    @Override
    public void securityOn(CallPeerSecurityOnEvent evt)
    {
        super.securityOn(evt);

        // If the securityOn is called without a specific event, we'll just call
        // the super and we'll return.
        if (evt == null)
            return;

        SrtpControl srtpControl = evt.getSecurityController();

        // In case this is the local peer.
        if (securityPanel == null)
            return;

        // if we have some other panel, using other control
        if (securityPanel.getSecurityControl() == null
            || !srtpControl.getClass().isInstance(
                securityPanel.getSecurityControl()))
        {
            setSecurityPanelVisible(false);

            securityPanel
                = SecurityPanel.create(this, callPeer, srtpControl);
        }

        securityPanel.securityOn(evt);

        boolean isSecurityLowPriority = Boolean.parseBoolean(
            GuiActivator.getResources().getSettingsString(
                "impl.gui.I_DONT_CARE_THAT_MUCH_ABOUT_SECURITY"));

        if (srtpControl instanceof ZrtpControl
            && !((ZrtpControl) srtpControl).isSecurityVerified()
            && !isSecurityLowPriority)
        {
            setSecurityPanelVisible(true);
        }
    }

    /**
     * Indicates that the security status is pending confirmation.
     */
    @Override
    public void securityPending()
    {
        super.securityPending();
    }

    /**
     * Indicates that the security is timeouted, is not supported by the
     * other end.
     * @param evt Details about the event that caused this message.
     */
    public void securityTimeout(CallPeerSecurityTimeoutEvent evt)
    {
        if(Boolean.parseBoolean(GuiActivator.getResources()
                .getSettingsString("impl.gui.PARANOIA_UI")))
        {
            try
            {
                CallPeer peer = (CallPeer) evt.getSource();
                OperationSetBasicTelephony<?> telephony
                    = peer.getProtocolProvider().getOperationSet(
                            OperationSetBasicTelephony.class);

                telephony.hangupCallPeer(
                    peer,
                    OperationSetBasicTelephony.HANGUP_REASON_ENCRYPTION_REQUIRED,
                    "Encryption Required!");
            }
            catch(OperationFailedException ex)
            {
                Logger.getLogger(getClass())
                    .error("Failed to hangup peer", ex);
            }
        }
    }

    /**
     * Sets the reason of a call failure if one occurs. The renderer should
     * display this reason to the user.
     * @param reason the reason to display
     */
    @Override
    public void setErrorReason(String reason)
    {
        super.setErrorReason(reason);
    }

    /**
     * Shows/hides the local video component.
     *
     * @param isVisible <tt>true</tt> to show the local video, <tt>false</tt> -
     * otherwise
     */
    public void setLocalVideoVisible(boolean isVisible) {}


    /**
     * Sets the mute status icon to the status panel.
     *
     * @param isMute indicates if the call with this peer is
     * muted
     */
    public void setMute(boolean isMute)
    {
        if(isMute)
            muteStatusLabel.setIcon(new ImageIcon(
                ImageLoader.getImage(ImageLoader.MUTE_STATUS_ICON)));
        else
            muteStatusLabel.setIcon(null);

        this.revalidate();
        this.repaint();
    }

    /**
     * Sets the "on hold" property value.
     * @param isOnHold indicates if the call with this peer is put on hold
     */
    public void setOnHold(boolean isOnHold)
    {
        if(isOnHold)
            holdStatusLabel.setIcon(new ImageIcon(
                ImageLoader.getImage(ImageLoader.HOLD_STATUS_ICON)));
        else
            holdStatusLabel.setIcon(null);

        this.revalidate();
        this.repaint();
    }

    /**
     * Sets the <tt>icon</tt> of the peer.
     * @param icon the icon to set
     */
    public void setPeerImage(byte[] icon)
    {
        // If this is the local peer (i.e. us) or any peer, but the focus peer.
        if (callPeer == null || !callPeer.isConferenceFocus())
            setParticipantImage(icon);
    }

    /**
     * Sets the name of the peer.
     * @param name the name of the peer
     */
    public void setPeerName(String name)
    {
        setParticipantName(name);
    }

    /**
     * Sets the state of the contained call peer by specifying the
     * state name.
     *
     * @param oldState the previous state of the peer
     * @param newState the new state of the peer
     * @param stateString the state of the contained call peer
     */
    public void setPeerState(   CallPeerState oldState,
                                CallPeerState newState,
                                String stateString)
    {
        this.setParticipantState(stateString);
    }

    /**
     * Shows/hides the security panel.
     *
     * @param isVisible <tt>true</tt> to show the security panel, <tt>false</tt>
     * to hide it
     */
    public void setSecurityPanelVisible(boolean isVisible)
    {
        final JFrame callFrame = getCallPanel().getCallWindow().getFrame();
        final JPanel glassPane = (JPanel) callFrame.getGlassPane();

        if (!isVisible)
        {
            // Need to hide the security panel explicitly in order to keep the
            // fade effect.
            securityPanel.setVisible(false);
            glassPane.setVisible(false);
            glassPane.removeAll();
        }
        else
        {
            glassPane.setLayout(null);
            glassPane.addMouseListener(
                new MouseListener()
                {
                    public void mouseClicked(MouseEvent e)
                    {
                        redispatchMouseEvent(glassPane, e);
                    }

                    public void mouseEntered(MouseEvent e)
                    {
                        redispatchMouseEvent(glassPane, e);
                    }

                    public void mouseExited(MouseEvent e)
                    {
                        redispatchMouseEvent(glassPane, e);
                    }

                    public void mousePressed(MouseEvent e)
                    {
                        redispatchMouseEvent(glassPane, e);
                    }

                    public void mouseReleased(MouseEvent e)
                    {
                        redispatchMouseEvent(glassPane, e);
                    }
                });

            Point securityLabelPoint = securityStatusLabel.getLocation();
            Point newPoint
                = SwingUtilities.convertPoint(
                        securityStatusLabel.getParent(),
                        securityLabelPoint.x, securityLabelPoint.y,
                        callFrame);

            securityPanel.setBeginPoint(
                new Point((int) newPoint.getX() + 15, 0));
            securityPanel.setBounds(
                0, (int) newPoint.getY() - 5, callFrame.getWidth(), 110);

            glassPane.add(securityPanel);
            // Need to show the security panel explicitly in order to keep the
            // fade effect.
            securityPanel.setVisible(true);
            glassPane.setVisible(true);

            glassPane.addComponentListener(
                new ComponentAdapter()
                {
                    /**
                     * Invoked when the component's size changes.
                     */
                    @Override
                    public void componentResized(ComponentEvent e)
                    {
                        if (glassPane.isVisible())
                        {
                            glassPane.setVisible(false);
                            callFrame.removeComponentListener(this);
                        }
                    }
                });
        }
    }

    /**
     * Implements the various types of listeners which get notified about
     * changes in the sound/audio levels of the model of this
     * <tt>ConferencePeerPanel</tt> and updates its sound level indicator.
     */
    private class SoundLevelListenerImpl
        implements ConferenceMembersSoundLevelListener,
                   SoundLevelListener
    {
        /**
         * {@inheritDoc}
         */
        public void soundLevelChanged(ConferenceMembersSoundLevelEvent ev)
        {
            /*
             * If the callPeer depicted by this ConferencePeerPanel instance is
             * represented as a ConferenceMember, update the sound level
             * indicator of this ConferencePeerPanel instance with the specified
             * sound level (value).
             */
            for (Map.Entry<ConferenceMember,Integer> e
                    : ev.getLevels().entrySet())
            {
                if (CallManager.addressesAreEqual(
                        e.getKey().getAddress(),
                        callPeer.getAddress()))
                {
                    updateSoundBar(e.getValue());
                    break;
                }
            }
        }

        /**
         * {@inheritDoc}
         */
        public void soundLevelChanged(Object source, int level)
        {
            if (source.equals(participant))
            {
                /*
                 * If the remote peer is a conference focus and there is at
                 * least one other member (i.e. different than the remote peer
                 * and the local peer/user), we expect the remote peer to send
                 * us CSRC-based audio levels. Otherwise, the stream-based audio
                 * levels may conflict with the CSRC-based audio levels.
                 */
                if (callPeer != null)
                {
                    int conferenceMemberCount
                        = callPeer.getConferenceMemberCount();

                    if (conferenceMemberCount > 2)
                        return;
                }

                updateSoundBar(level);
            }
        }
    }
}