Commit def265ad authored by Adrian Georgescu's avatar Adrian Georgescu

Added per account auto answer settings

parent 9b2f4358
......@@ -19,6 +19,7 @@ class BonjourMSRPSettingsExtension(BonjourMSRPSettings):
class BonjourSIPSettings(SettingsGroup):
transport_order = Setting(type=SIPTransportList, default=SIPTransportList(['tcp', 'udp', 'tls']))
tls_name = Setting(type=str, default='Blink')
auto_answer = Setting(type=bool, default=False)
class MessageSummarySettingsExtension(MessageSummarySettings):
......@@ -52,6 +53,7 @@ class SIPSettingsExtension(SIPSettings):
subscribe_interval = Setting(type=NonNegativeInteger, default=600)
publish_interval = Setting(type=NonNegativeInteger, default=600)
tls_name = Setting(type=str, default=None, nillable=True)
auto_answer = Setting(type=bool, default=True)
class ServerSettings(SettingsGroup):
......
......@@ -8,7 +8,7 @@ import sys
from sipsimple.configuration import Setting, SettingsGroup, SettingsObject, SettingsObjectExtension
from sipsimple.configuration.datatypes import AudioCodecList, NonNegativeInteger, PositiveInteger, Path, SampleRate, VideoCodecList
from sipsimple.configuration.settings import AudioSettings, ChatSettings, EchoCancellerSettings, LogsSettings, RTPSettings, TLSSettings
from sipsimple.configuration.settings import AudioSettings, ChatSettings, EchoCancellerSettings, LogsSettings, RTPSettings, SIPSettings, TLSSettings
from blink import __version__
from blink.configuration.datatypes import ApplicationDataPath, GraphTimeScale, HTTPURL, IconDescriptor, SoundFile, PresenceState, PresenceStateList
......@@ -31,8 +31,10 @@ class AudioSettingsExtension(AudioSettings):
recordings_directory = Setting(type=ApplicationDataPath, default=ApplicationDataPath('recordings'))
sample_rate = Setting(type=SampleRate, default=32000)
echo_canceller = EchoCancellerSettingsExtension
class SIPSettingsExtension(SIPSettings):
auto_answer_interval = Setting(type=int, default=15)
auto_answer = Setting(type=bool, default=False)
auto_answer = Setting(type=bool, default=True)
class ChatSettingsExtension(ChatSettings):
......@@ -86,6 +88,7 @@ class SIPSimpleSettingsExtension(SettingsObjectExtension):
server = ServerSettings
sounds = SoundSettings
tls = TLSSettingsExtension
sip = SIPSettingsExtension
user_agent = Setting(type=str, default='Blink %s (%s)' % (__version__, platform.system() if sys.platform != 'darwin' else 'MacOSX Qt'))
......
......@@ -744,7 +744,7 @@ class MainWindow(base_class, ui_class):
def _SH_AutoAnswerButtonClicked(self, answer):
settings = SIPSimpleSettings()
settings.audio.auto_answer = not settings.audio.auto_answer
settings.sip.auto_answer = not settings.sip.auto_answer
settings.save()
def _SH_SilentButtonClicked(self, silent):
......@@ -774,7 +774,7 @@ class MainWindow(base_class, ui_class):
settings = SIPSimpleSettings()
self.silent_action.setChecked(settings.audio.silent)
self.silent_button.setChecked(settings.audio.silent)
self.auto_answer_action.setChecked(settings.audio.auto_answer)
self.auto_answer_action.setChecked(settings.sip.auto_answer)
self.answering_machine_action.setChecked(settings.answering_machine.enabled)
self.auto_accept_chat_action.setChecked(settings.chat.auto_accept)
self.received_messages_sound_action.setChecked(settings.sounds.play_message_alerts)
......
......@@ -282,7 +282,7 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
self.video_codec_bitrate_button.activated[int].connect(self._SH_VideoCodecBitrateButtonActivated)
self.h264_profile_button.activated[int].connect(self._SH_H264ProfileButtonActivated)
# Chat and SMS
# Chat
self.style_view.sizeChanged.connect(self._SH_StyleViewSizeChanged)
self.style_view.page().mainFrame().contentsSizeChanged.connect(self._SH_StyleViewFrameContentsSizeChanged)
......@@ -334,6 +334,10 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
self.tls_cert_file_browse_button.clicked.connect(self._SH_TLSCertFileBrowseButtonClicked)
self.tls_verify_server_button.clicked.connect(self._SH_TLSVerifyServerButtonClicked)
# Auto answer
self.auto_answer_interval.valueChanged[int].connect(self._SH_AutoAnswerIntervalChanged)
self.account_auto_answer.clicked.connect(self._SH_AccountAutoAnswerChanged)
# Setup initial state (show the accounts page right after start)
self.accounts_action.trigger()
self.account_tab_widget.setCurrentIndex(0)
......@@ -680,7 +684,7 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
self.h264_profile_button.setCurrentIndex(self.h264_profile_button.findData(str(settings.video.h264.profile)))
self.video_codec_bitrate_button.setCurrentIndex(self.video_codec_bitrate_button.findData(settings.video.max_bitrate))
# Chat and SMS settings
# Chat
style_index = self.style_button.findText(blink_settings.chat_window.style)
if style_index == -1:
style_index = 0
......@@ -747,6 +751,8 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
self.media_ports_start.setValue(settings.rtp.port_range.start)
with blocked_qt_signals(self.media_ports):
self.media_ports.setValue(settings.rtp.port_range.end - settings.rtp.port_range.start)
with blocked_qt_signals(self.auto_answer_interval):
self.auto_answer_interval.setValue(settings.sip.auto_answer_interval)
self.screenshots_directory_editor.setText(blink_settings.screenshots_directory or '')
self.transfers_directory_editor.setText(blink_settings.transfers_directory or '')
......@@ -805,8 +811,11 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
self.rtp_encryption_button.setChecked(account.rtp.encryption.enabled)
self.key_negotiation_button.setEnabled(account.rtp.encryption.enabled)
self.key_negotiation_button.setCurrentIndex(self.key_negotiation_button.findData(account.rtp.encryption.key_negotiation))
self.account_auto_answer.setChecked(account.sip.auto_answer)
if account is not bonjour_account:
self.account_auto_answer.setText('Auto answer from allowed contacts')
# Server settings tab
self.always_use_my_proxy_button.setChecked(account.sip.always_use_my_proxy)
outbound_proxy = account.sip.outbound_proxy or UnspecifiedOutboundProxy
......@@ -855,7 +864,8 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
self.prefix_button.addItem(item_text)
self.prefix_button.setCurrentIndex(self.prefix_button.findText(item_text))
self._update_pstn_example_label()
else:
self.account_auto_answer.setText('Auto answer from all neighbours')
def update_chat_preview(self):
......@@ -1154,6 +1164,16 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
account = self.selected_account
account.rtp.encryption.enabled = checked
account.save()
def _SH_AutoAnswerIntervalChanged(self, interval):
settings = SIPSimpleSettings()
settings.sip.auto_answer_interval = interval
settings.save()
def _SH_AccountAutoAnswerChanged(self, auto_answer):
account = self.selected_account
account.sip.auto_answer = not account.sip.auto_answer
account.save()
def _SH_KeyNegotiationButtonActivated(self, index):
account = self.selected_account
......@@ -1730,10 +1750,14 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
self.auto_accept_chat_button.setChecked(settings.chat.auto_accept)
if 'sounds.play_message_alerts' in notification.data.modified:
self.chat_message_alert_button.setChecked(settings.sounds.play_message_alerts)
if 'sip.auto_answer_interval' in notification.data.modified:
self.auto_answer_interval.setValue(settings.sip.auto_answer_interval)
if 'video.device' in notification.data.modified:
self.video_camera_button.setCurrentIndex(self.video_camera_button.findData(settings.video.device))
elif notification.sender is self.selected_account is not None:
account = notification.sender
if 'sip.auto_answer' in notification.data.modified:
self.account_auto_answer.setChecked(account.sip.auto_answer)
if 'enabled' in notification.data.modified:
self.account_enabled_button.setChecked(account.enabled)
if not account.enabled:
......
......@@ -5242,20 +5242,24 @@ class IncomingRequest(QObject):
self.dialog.uri_label.setText(address)
self.dialog.username_label.setText(contact.name or session.remote_identity.display_name or address)
settings = SIPSimpleSettings()
try:
if settings.audio.auto_answer and contact.settings.auto_answer and settings.audio.auto_answer_interval:
auto_answer_interval = settings.audio.auto_answer_interval
except AttributeError:
pass
else:
if auto_answer_interval > 0:
self.dialog.setAutoAnswer(settings.audio.auto_answer_interval)
self._auto_answer_timer = QTimer()
self._auto_answer_timer.setInterval(settings.audio.auto_answer_interval * 1000)
self._auto_answer_timer.setSingleShot(True)
self._auto_answer_timer.timeout.connect(self._auto_answer)
self._auto_answer_timer.start()
auto_answer_interval = 0
if settings.sip.auto_answer and settings.sip.auto_answer_interval and session.account.sip.auto_answer:
if session.account is BonjourAccount():
auto_answer_interval = settings.sip.auto_answer_interval
else:
if hasattr(contact.settings, 'auto_answer'):
if contact.settings.auto_answer:
auto_answer_interval = settings.sip.auto_answer_interval
if auto_answer_interval > 0:
self.dialog.setAutoAnswer(auto_answer_interval)
self._auto_answer_timer = QTimer()
self._auto_answer_timer.setInterval(auto_answer_interval * 1000)
self._auto_answer_timer.setSingleShot(True)
self._auto_answer_timer.timeout.connect(self._auto_answer)
self._auto_answer_timer.start()
self.dialog.user_icon.setPixmap(contact.icon.pixmap(48))
self.dialog.audio_stream.setVisible(self.audio_stream is not None)
......
......@@ -158,7 +158,7 @@
<item row="0" column="1">
<widget class="QTabWidget" name="account_tab_widget">
<property name="currentIndex">
<number>4</number>
<number>1</number>
</property>
<widget class="QWidget" name="account_information_tab">
<attribute name="title">
......@@ -300,7 +300,7 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QComboBox" name="key_negotiation_button">
<item>
<property name="text">
......@@ -324,7 +324,7 @@
</item>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="key_negotiation_label">
<property name="text">
<string>Encryption:</string>
......@@ -343,7 +343,7 @@
</font>
</property>
<property name="text">
<string>RTP Options</string>
<string>Options</string>
</property>
</widget>
</item>
......@@ -354,7 +354,7 @@
</property>
</widget>
</item>
<item row="4" column="2">
<item row="5" column="2">
<spacer name="key_negotiation_spacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -374,6 +374,13 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="account_auto_answer">
<property name="text">
<string>Auto answer from allowed contacts</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......@@ -1663,16 +1670,6 @@
</property>
</spacer>
</item>
<item row="5" column="0">
<widget class="QLabel" name="tail_length_label">
<property name="text">
<string>Tail Length:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSlider" name="tail_length_slider">
<property name="maximum">
......@@ -1703,6 +1700,16 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="tail_length_label">
<property name="text">
<string>Tail Length:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......@@ -1920,6 +1927,19 @@
</item>
</widget>
</item>
<item row="4" column="0" colspan="4">
<spacer name="answering_machine_spacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>100</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="2">
<widget class="QWidget" name="unavailable_message_buttons_widget" native="true">
<layout class="QHBoxLayout" name="am_buttons_layout">
......@@ -2002,19 +2022,6 @@
</layout>
</widget>
</item>
<item row="4" column="0" colspan="4">
<spacer name="answering_machine_spacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>100</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
......@@ -2844,8 +2851,8 @@
<widget class="QLabel" name="tcp_port_label">
<property name="geometry">
<rect>
<x>313</x>
<y>91</y>
<x>314</x>
<y>97</y>
<width>64</width>
<height>17</height>
</rect>
......@@ -2866,8 +2873,8 @@
<widget class="QLabel" name="tls_port_label">
<property name="geometry">
<rect>
<x>313</x>
<y>124</y>
<x>316</x>
<y>130</y>
<width>62</width>
<height>17</height>
</rect>
......@@ -2902,7 +2909,7 @@
<property name="geometry">
<rect>
<x>386</x>
<y>157</y>
<y>159</y>
<width>74</width>
<height>27</height>
</rect>
......@@ -2924,7 +2931,7 @@
<property name="geometry">
<rect>
<x>313</x>
<y>58</y>
<y>65</y>
<width>67</width>
<height>17</height>
</rect>
......@@ -2939,8 +2946,8 @@
<widget class="QLabel" name="starting_at_label">
<property name="geometry">
<rect>
<x>287</x>
<y>157</y>
<x>303</x>
<y>162</y>
<width>75</width>
<height>17</height>
</rect>
......@@ -3049,7 +3056,7 @@
<property name="geometry">
<rect>
<x>386</x>
<y>124</y>
<y>126</y>
<width>74</width>
<height>27</height>
</rect>
......@@ -3078,7 +3085,7 @@
<property name="geometry">
<rect>
<x>386</x>
<y>91</y>
<y>93</y>
<width>74</width>
<height>27</height>
</rect>
......@@ -3122,8 +3129,8 @@
<widget class="QLabel" name="media_ports_label">
<property name="geometry">
<rect>
<x>18</x>
<y>157</y>
<x>90</x>
<y>160</y>
<width>71</width>
<height>17</height>
</rect>
......@@ -3234,7 +3241,7 @@
<property name="geometry">
<rect>
<x>386</x>
<y>58</y>
<y>60</y>
<width>74</width>
<height>27</height>
</rect>
......@@ -3278,8 +3285,8 @@
<widget class="QLabel" name="port_note_label">
<property name="geometry">
<rect>
<x>466</x>
<y>58</y>
<x>170</x>
<y>200</y>
<width>288</width>
<height>17</height>
</rect>
......@@ -3291,7 +3298,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Set SIP ports to 0 for automatic allocation</string>
<string>Set ports to 0 for automatic allocation</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
......@@ -3367,6 +3374,45 @@
<string>Browse</string>
</property>
</widget>
<widget class="QSpinBox" name="auto_answer_interval">
<property name="geometry">
<rect>
<x>680</x>
<y>60</y>
<width>48</width>
<height>27</height>
</rect>
</property>
<property name="value">
<number>15</number>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>530</x>
<y>65</y>
<width>151</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Auto answer interval:</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>738</x>
<y>65</y>
<width>71</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>seconds</string>
</property>
</widget>
</widget>
</item>
</layout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment