From ab5e37350b19d39fa38b408dc6782b66561ac4fe Mon Sep 17 00:00:00 2001 From: David Cooper Date: Sat, 26 Oct 2024 12:32:28 -0400 Subject: [PATCH] Configuration setting to silence all call alerts --- blink/configuration/settings.py | 1 + blink/preferences.py | 7 +++++++ blink/sessions.py | 18 +++++++++++------- resources/preferences.ui | 9 ++++++++- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/blink/configuration/settings.py b/blink/configuration/settings.py index 64d2c8e0..cd1c2eec 100644 --- a/blink/configuration/settings.py +++ b/blink/configuration/settings.py @@ -38,6 +38,7 @@ class AudioSettingsExtension(AudioSettings): recordings_directory = Setting(type=ApplicationDataPath, default=ApplicationDataPath('recordings')) sample_rate = Setting(type=SampleRate, default=41000 if sys.platform != 'darwin' else 32000) echo_canceller = EchoCancellerSettingsExtension + play_call_alerts = Setting(type=bool, default=False) class SIPSettingsExtension(SIPSettings): diff --git a/blink/preferences.py b/blink/preferences.py index 978cb14f..9c434512 100644 --- a/blink/preferences.py +++ b/blink/preferences.py @@ -304,6 +304,7 @@ def __init__(self, account_model, parent=None): self.audio_output_device_button.activated[int].connect(self._SH_AudioOutputDeviceButtonActivated) self.audio_sample_rate_button.activated[int].connect(self._SH_AudioSampleRateButtonActivated) self.enable_echo_cancelling_button.clicked.connect(self._SH_EnableEchoCancellingButtonClicked) + self.enable_play_call_alerts_button.clicked.connect(self._SH_EnablePlayCallAlertsButtonClicked) self.tail_length_slider.valueChanged.connect(self._SH_TailLengthSliderValueChanged) # Audio codecs @@ -712,6 +713,7 @@ def load_settings(self): # Audio devices self.load_audio_devices() self.enable_echo_cancelling_button.setChecked(settings.audio.echo_canceller.enabled) + self.enable_play_call_alerts_button.setChecked(settings.audio.play_call_alerts) with blocked_qt_signals(self.tail_length_slider): self.tail_length_slider.setValue(settings.audio.echo_canceller.tail_length) self.audio_sample_rate_button.clear() @@ -1613,6 +1615,11 @@ def _SH_TailLengthSliderValueChanged(self, value): settings.audio.echo_canceller.tail_length = value settings.save() + def _SH_EnablePlayCallAlertsButtonClicked(self, checked): + settings = SIPSimpleSettings() + settings.audio.play_call_alerts = checked + settings.save() + # Audio codecs signal handlers def _SH_AudioCodecsListItemChanged(self, item): settings = SIPSimpleSettings() diff --git a/blink/sessions.py b/blink/sessions.py index ff8a4242..7752b730 100644 --- a/blink/sessions.py +++ b/blink/sessions.py @@ -6867,8 +6867,8 @@ def update_ringtone(self): # Outgoing ringtone outgoing_sessions_or_proposals = [session for session in self.sessions if session.state == 'connecting/ringing' and session.direction == 'outgoing' or session.state == 'connected/sent_proposal'] outgoing_file_transfers = [transfer for transfer in self.file_transfers if transfer.state == 'connecting/ringing' and transfer.direction == 'outgoing'] - if any(not session.on_hold for session in outgoing_sessions_or_proposals) or outgoing_file_transfers: - settings = SIPSimpleSettings() + settings = SIPSimpleSettings() + if settings.audio.play_call_alerts and any(not session.on_hold for session in outgoing_sessions_or_proposals) or outgoing_file_transfers: outbound_ringtone = settings.sounds.outbound_ringtone if outbound_ringtone: if any('audio' in session.streams.proposed and not session.on_hold for session in outgoing_sessions_or_proposals): @@ -6921,7 +6921,7 @@ def update_ringtone(self): # Hold tone connected_sessions = [session for session in self.sessions if session.state == 'connected/*'] connected_on_hold_sessions = [session for session in connected_sessions if session.on_hold] - if outbound_ringtone is Null and inbound_ringtone is Null and connected_sessions: + if settings.audio.play_call_alerts and outbound_ringtone is Null and inbound_ringtone is Null and connected_sessions: if len(connected_sessions) == len(connected_on_hold_sessions): hold_tone = WavePlayer(SIPApplication.alert_audio_mixer, Resources.get('sounds/hold_tone.wav'), loop_count=0, volume=30, initial_delay=45, pause_time=45) hold_tone.bridge = SIPApplication.alert_audio_bridge @@ -7121,21 +7121,24 @@ def _NH_BlinkSessionDidChangeState(self, notification): notification.sender._play_hangup_tone = notification.data.old_state in ('connecting/*', 'connected/*') and notification.sender.streams.types.intersection({'audio', 'video'}) def _NH_BlinkSessionDidChangeHoldState(self, notification): - if notification.sender is self.active_session and notification.data.originator == 'remote' and notification.data.remote_hold and not notification.data.local_hold: + settings = SIPSimpleSettings() + if settings.sounds.play_message_alerts and notification.sender is self.active_session and notification.data.originator == 'remote' and notification.data.remote_hold and not notification.data.local_hold: player = WavePlayer(SIPApplication.voice_audio_bridge.mixer, Resources.get('sounds/hold_tone.wav'), loop_count=1, volume=30) SIPApplication.voice_audio_bridge.add(player) player.start() self.update_ringtone() def _NH_BlinkSessionDidRemoveStream(self, notification): - if notification.data.stream.type in ('audio', 'video') and not self._hangup_tone_timer.isActive(): + settings = SIPSimpleSettings() + if settings.audio.play_call_alerts and notification.data.stream.type in ('audio', 'video') and not self._hangup_tone_timer.isActive(): self._hangup_tone_timer.start() player = WavePlayer(SIPApplication.voice_audio_bridge.mixer, Resources.get('sounds/hangup_tone.wav'), volume=30) SIPApplication.voice_audio_bridge.add(player) player.start() def _NH_BlinkSessionDidEnd(self, notification): - if notification.sender._play_hangup_tone and not self._hangup_tone_timer.isActive(): + settings = SIPSimpleSettings() + if settings.audio.play_call_alerts and notification.sender._play_hangup_tone and not self._hangup_tone_timer.isActive(): self._hangup_tone_timer.start() player = WavePlayer(SIPApplication.voice_audio_bridge.mixer, Resources.get('sounds/hangup_tone.wav'), volume=30) SIPApplication.voice_audio_bridge.add(player) @@ -7187,7 +7190,8 @@ def _NH_BlinkFileTransferDidEnd(self, notification): pass else: notification.center.remove_observer(self, sender=notification.sender) - if not notification.data.error and not self._filetransfer_tone_timer.isActive(): + settings = SIPSimpleSettings() + if settings.play_call_alerts and not notification.data.error and not self._filetransfer_tone_timer.isActive(): self._filetransfer_tone_timer.start() player = WavePlayer(SIPApplication.voice_audio_bridge.mixer, Resources.get('sounds/file_transfer.wav'), volume=30) SIPApplication.voice_audio_bridge.add(player) diff --git a/resources/preferences.ui b/resources/preferences.ui index 58454dd2..c4469d05 100644 --- a/resources/preferences.ui +++ b/resources/preferences.ui @@ -2041,7 +2041,14 @@ - + + + + Play call alerts + + + + Tail Length: