Skip to content

Configuration setting to silence all call alerts #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions blink/configuration/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 7 additions & 0 deletions blink/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
18 changes: 11 additions & 7 deletions blink/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion resources/preferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2041,7 +2041,14 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="5" column="1" colspan="2">
<widget class="QCheckBox" name="enable_play_call_alerts_button">
<property name="text">
<string>Play call alerts</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="tail_length_label">
<property name="text">
<string>Tail Length:</string>
Expand Down