<commit_before>/*
 * 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.awt.event.*;
import java.util.*;

import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.swing.*;

/**
 * Represents an UI means to mute the audio stream sent to an associated
 * <tt>CallPariticant</tt>.
 *
 * @author <NAME>
 */
public class MuteButton
    extends SIPCommToggleButton
{
    private static final long serialVersionUID = 0L;

    /**
     * Initializes a new <tt>MuteButton</tt> instance which is to mute the audio
     * stream to a specific <tt>CallParticipant</tt>.
     *
     * @param call the <tt>Call</tt> to be associated with
     *            the new instance and to have the audio stream sent to muted
     */
    public MuteButton(Call call)
    {
        this(call, false, false);
    }

    /**
     * Initializes a new <tt>MuteButton</tt> instance which is to mute the audio
     * stream to a specific <tt>CallParticipant</tt>.
     *
     * @param call  the <tt>Call</tt> to be associated with
     *              the new instance and to be put on/off hold upon performing
     *              its action.
     * @param isFullScreenMode indicates if this button will be used in a normal
     *              or full screen mode.
     * @param isSelected indicates the initial state of this toggle button -
     *              selected or not.
     */
    public MuteButton(Call call, boolean isFullScreenMode, boolean isSelected)
    {
        if (isFullScreenMode)
        {
            this.setBgImage(
                ImageLoader.getImage(ImageLoader.FULL_SCREEN_BUTTON_BG));
            this.setBgRolloverImage(
                ImageLoader.getImage(ImageLoader.FULL_SCREEN_BUTTON_BG));
            this.setIconImage(
                ImageLoader.getImage(ImageLoader.MUTE_BUTTON));
            this.setPressedImage(
                ImageLoader.getImage(ImageLoader.FULL_SCREEN_BUTTON_BG_PRESSED));
        }
        else
        {
            this.setBgImage(
                ImageLoader.getImage(ImageLoader.CALL_SETTING_BUTTON_BG));
            this.setBgRolloverImage(
                ImageLoader.getImage(ImageLoader.CALL_SETTING_BUTTON_BG));
            this.setIconImage(
                ImageLoader.getImage(ImageLoader.MUTE_BUTTON));
            this.setPressedImage(
                ImageLoader.getImage(ImageLoader.CALL_SETTING_BUTTON_PRESSED_BG));
        }

        setModel(new MuteButtonModel(call));
        setToolTipText(GuiActivator.getResources().getI18NString(
            "service.gui.MUTE_BUTTON_TOOL_TIP"));
        setSelected(isSelected);
    }
    /**
     * Represents the model of a toggle button that mutes the audio stream sent
     * to a specific <tt>CallParticipant</tt>.
     */
    private static class MuteButtonModel
        extends ToggleButtonModel
        implements ActionListener
    {

        /**
         * The <tt>CallParticipant</tt> whose state is being adapted for the
         * purposes of depicting as a toggle button.
         */
        private final Call call;

        /**
         * Initializes a new <tt>MuteButtonModel</tt> instance to represent the
         * state of a specific <tt>CallParticipant</tt> as a toggle button.
         *
         * @param call the <tt>Call</tt> whose state is to
         *            be represented as a toggle button
         */
        public MuteButtonModel(Call call)
        {
            this.call = call;

            addActionListener(this);
        }

        public void actionPerformed(ActionEvent evt)
        {
            if (call != null)
            {
                Iterator<CallPeer> participants
                    = call.getCallPeers();

                while (participants.hasNext())
                {
                    CallPeer callParticipant = participants.next();

                    OperationSetBasicTelephony telephony
                        = (OperationSetBasicTelephony) call.getProtocolProvider()
                            .getOperationSet(OperationSetBasicTelephony.class);

                    telephony.setMute(  callParticipant,
                                        !callParticipant.isMute());

                    fireItemStateChanged(
                        new ItemEvent(this,
                        ItemEvent.ITEM_STATE_CHANGED, this,
                        isSelected() ? ItemEvent.SELECTED : ItemEvent.DESELECTED));

                    fireStateChanged();
                }
            }
        }
    }
}<commit_msg>Renames occurrences of callParticipant to callPeer so that it would better reflect our new Call architecture that also includes conferencing and ConferenceMembers<commit_after>/*
 * 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.awt.event.*;
import java.util.*;

import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.swing.*;

/**
 * Represents an UI means to mute the audio stream sent to an associated
 * <tt>CallPariticant</tt>.
 *
 * @author <NAME>
 */
public class MuteButton
    extends SIPCommToggleButton
{
    private static final long serialVersionUID = 0L;

    /**
     * Initializes a new <tt>MuteButton</tt> instance which is to mute the audio
     * stream to a specific <tt>CallPeer</tt>.
     *
     * @param call the <tt>Call</tt> to be associated with
     *            the new instance and to have the audio stream sent to muted
     */
    public MuteButton(Call call)
    {
        this(call, false, false);
    }

    /**
     * Initializes a new <tt>MuteButton</tt> instance which is to mute the audio
     * stream to a specific <tt>CallPeer</tt>.
     *
     * @param call  the <tt>Call</tt> to be associated with
     *              the new instance and to be put on/off hold upon performing
     *              its action.
     * @param isFullScreenMode indicates if this button will be used in a normal
     *              or full screen mode.
     * @param isSelected indicates the initial state of this toggle button -
     *              selected or not.
     */
    public MuteButton(Call call, boolean isFullScreenMode, boolean isSelected)
    {
        if (isFullScreenMode)
        {
            this.setBgImage(
                ImageLoader.getImage(ImageLoader.FULL_SCREEN_BUTTON_BG));
            this.setBgRolloverImage(
                ImageLoader.getImage(ImageLoader.FULL_SCREEN_BUTTON_BG));
            this.setIconImage(
                ImageLoader.getImage(ImageLoader.MUTE_BUTTON));
            this.setPressedImage(
                ImageLoader.getImage(ImageLoader.FULL_SCREEN_BUTTON_BG_PRESSED));
        }
        else
        {
            this.setBgImage(
                ImageLoader.getImage(ImageLoader.CALL_SETTING_BUTTON_BG));
            this.setBgRolloverImage(
                ImageLoader.getImage(ImageLoader.CALL_SETTING_BUTTON_BG));
            this.setIconImage(
                ImageLoader.getImage(ImageLoader.MUTE_BUTTON));
            this.setPressedImage(
                ImageLoader.getImage(ImageLoader.CALL_SETTING_BUTTON_PRESSED_BG));
        }

        setModel(new MuteButtonModel(call));
        setToolTipText(GuiActivator.getResources().getI18NString(
            "service.gui.MUTE_BUTTON_TOOL_TIP"));
        setSelected(isSelected);
    }
    /**
     * Represents the model of a toggle button that mutes the audio stream sent
     * to a specific <tt>CallPeer</tt>.
     */
    private static class MuteButtonModel
        extends ToggleButtonModel
        implements ActionListener
    {

        /**
         * The <tt>CallPeer</tt> whose state is being adapted for the
         * purposes of depicting as a toggle button.
         */
        private final Call call;

        /**
         * Initializes a new <tt>MuteButtonModel</tt> instance to represent the
         * state of a specific <tt>CallPeer</tt> as a toggle button.
         *
         * @param call the <tt>Call</tt> whose state is to
         *            be represented as a toggle button
         */
        public MuteButtonModel(Call call)
        {
            this.call = call;

            addActionListener(this);
        }

        public void actionPerformed(ActionEvent evt)
        {
            if (call != null)
            {
                Iterator<CallPeer> peers
                    = call.getCallPeers();

                while (peers.hasNext())
                {
                    CallPeer callPeer = peers.next();

                    OperationSetBasicTelephony telephony
                        = (OperationSetBasicTelephony) call.getProtocolProvider()
                            .getOperationSet(OperationSetBasicTelephony.class);

                    telephony.setMute(  callPeer,
                                        !callPeer.isMute());

                    fireItemStateChanged(
                        new ItemEvent(this,
                        ItemEvent.ITEM_STATE_CHANGED, this,
                        isSelected() ? ItemEvent.SELECTED : ItemEvent.DESELECTED));

                    fireStateChanged();
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.08175577283128771, 'fraction_numerical': 0.0006240898689411275, 'mean_word_length': 1.8839232153569285, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '981131', 'n_tokens_mistral': 2621, 'n_tokens_neox': 2526, 'n_words': 651}