diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index ab31c4d076..cf67520284 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -328,6 +328,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_settings_events_title" = "Events"; "lng_settings_events_joined" = "Contact joined Telegram"; "lng_settings_events_pinned" = "Pinned messages"; +"lng_settings_notifications_calls_title" = "Calls"; "lng_notification_preview" = "You have a new message"; "lng_notification_reply" = "Reply"; @@ -395,6 +396,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_settings_call_stop_mic_test" = "Stop test"; "lng_settings_call_section_other" = "Other settings"; "lng_settings_call_open_system_prefs" = "Open system sound preferences"; +"lng_settings_call_accept_calls" = "Accept calls from this device"; "lng_settings_call_device_default" = "Same as the System"; "lng_settings_call_audio_ducking" = "Mute other sounds during calls"; diff --git a/Telegram/SourceFiles/calls/calls_instance.cpp b/Telegram/SourceFiles/calls/calls_instance.cpp index 79ad8a91bd..e6c78e82da 100644 --- a/Telegram/SourceFiles/calls/calls_instance.cpp +++ b/Telegram/SourceFiles/calls/calls_instance.cpp @@ -377,6 +377,8 @@ void Instance::handleCallUpdate( } else if (phoneCall.vdate().v + (config.callRingTimeoutMs / 1000) < base::unixtime::now()) { LOG(("Ignoring too old call.")); + } else if (Core::App().settings().disableCalls()) { + LOG(("Ignoring call because of 'accept calls' settings.")); } else { createCall(user, Call::Type::Incoming, phoneCall.is_video()); _currentCall->handleUpdate(call); diff --git a/Telegram/SourceFiles/core/core_settings.cpp b/Telegram/SourceFiles/core/core_settings.cpp index 8940fdf6e1..aa6bded0d3 100644 --- a/Telegram/SourceFiles/core/core_settings.cpp +++ b/Telegram/SourceFiles/core/core_settings.cpp @@ -19,8 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Core { Settings::Settings() -: _callAudioBackend(Webrtc::Backend::OpenAL) -, _sendSubmitWay(Ui::InputSubmitSettings::Enter) +: _sendSubmitWay(Ui::InputSubmitSettings::Enter) , _floatPlayerColumn(Window::Column::Second) , _floatPlayerCorner(RectPart::TopRight) , _dialogsWidthRatio(DefaultDialogsWidthRatio()) { @@ -115,7 +114,8 @@ QByteArray Settings::serialize() const { << qint32(_groupCallPushToTalk ? 1 : 0) << _groupCallPushToTalkShortcut << qint64(_groupCallPushToTalkDelay) - << qint32(_callAudioBackend); + << qint32(0) // Call audio backend + << qint32(_disableCalls ? 1 : 0); } return result; } @@ -186,7 +186,8 @@ void Settings::addFromSerialized(const QByteArray &serialized) { qint32 groupCallPushToTalk = _groupCallPushToTalk ? 1 : 0; QByteArray groupCallPushToTalkShortcut = _groupCallPushToTalkShortcut; qint64 groupCallPushToTalkDelay = _groupCallPushToTalkDelay; - qint32 callAudioBackend = static_cast(_callAudioBackend); + qint32 callAudioBackend = 0; + qint32 disableCalls = _disableCalls ? 1 : 0; stream >> themesAccentColors; if (!stream.atEnd()) { @@ -285,6 +286,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) { if (!stream.atEnd()) { stream >> callAudioBackend; } + if (!stream.atEnd()) { + stream >> disableCalls; + } if (stream.status() != QDataStream::Ok) { LOG(("App Error: " "Bad data for Core::Settings::constructFromSerialized()")); @@ -379,12 +383,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) { _groupCallPushToTalk = (groupCallPushToTalk == 1); _groupCallPushToTalkShortcut = groupCallPushToTalkShortcut; _groupCallPushToTalkDelay = groupCallPushToTalkDelay; - auto uncheckedBackend = static_cast(callAudioBackend); - switch (uncheckedBackend) { - case Webrtc::Backend::OpenAL: - case Webrtc::Backend::ADM: - case Webrtc::Backend::ADM2: _callAudioBackend = uncheckedBackend; break; - } + _disableCalls = (disableCalls == 1); } bool Settings::chatWide() const { @@ -495,6 +494,8 @@ void Settings::resetOnLastLogout() { //_callInputVolume = 100; //_callAudioDuckingEnabled = true; + _disableCalls = false; + _groupCallPushToTalk = false; _groupCallPushToTalkShortcut = QByteArray(); _groupCallPushToTalkDelay = 20; diff --git a/Telegram/SourceFiles/core/core_settings.h b/Telegram/SourceFiles/core/core_settings.h index 33a0927706..64b201ee83 100644 --- a/Telegram/SourceFiles/core/core_settings.h +++ b/Telegram/SourceFiles/core/core_settings.h @@ -222,8 +222,11 @@ public: _callAudioDuckingEnabled = value; } [[nodiscard]] Webrtc::Backend callAudioBackend() const; - void setCallAudioBackend(Webrtc::Backend backend) { - _callAudioBackend = backend; + void setDisableCalls(bool value) { + _disableCalls = value; + } + [[nodiscard]] bool disableCalls() const { + return _disableCalls; } [[nodiscard]] bool groupCallPushToTalk() const { return _groupCallPushToTalk; @@ -539,7 +542,7 @@ private: int _callOutputVolume = 100; int _callInputVolume = 100; bool _callAudioDuckingEnabled = true; - Webrtc::Backend _callAudioBackend = Webrtc::Backend(); + bool _disableCalls = false; bool _groupCallPushToTalk = false; QByteArray _groupCallPushToTalkShortcut; crl::time _groupCallPushToTalkDelay = 20; diff --git a/Telegram/SourceFiles/settings/settings_calls.cpp b/Telegram/SourceFiles/settings/settings_calls.cpp index abcb8b49b1..94d981359d 100644 --- a/Telegram/SourceFiles/settings/settings_calls.cpp +++ b/Telegram/SourceFiles/settings/settings_calls.cpp @@ -275,6 +275,19 @@ void Calls::setupContent() { //)->addClickHandler([] { // Ui::show(ChooseAudioBackendBox()); //}); + AddButton( + content, + tr::lng_settings_call_accept_calls(), + st::settingsButton + )->toggleOn(rpl::single( + !settings.disableCalls() + ))->toggledChanges( + ) | rpl::filter([&settings](bool value) { + return (settings.disableCalls() == value); + }) | rpl::start_with_next([=](bool value) { + Core::App().settings().setDisableCalls(!value); + Core::App().saveSettingsDelayed(); + }, content->lifetime()); AddButton( content, tr::lng_settings_call_open_system_prefs(), @@ -286,6 +299,7 @@ void Calls::setupContent() { Ui::show(Box(tr::lng_linux_no_audio_prefs(tr::now))); } }); + AddSkip(content); Ui::ResizeFitChild(this, content); diff --git a/Telegram/SourceFiles/settings/settings_notifications.cpp b/Telegram/SourceFiles/settings/settings_notifications.cpp index f6ce983b0b..71dce89b98 100644 --- a/Telegram/SourceFiles/settings/settings_notifications.cpp +++ b/Telegram/SourceFiles/settings/settings_notifications.cpp @@ -676,6 +676,23 @@ void SetupNotificationsContent( Core::App().saveSettingsDelayed(); }, joined->lifetime()); + AddSkip(container, st::settingsCheckboxesSkip); + AddDivider(container); + AddSkip(container, st::settingsCheckboxesSkip); + AddSubsectionTitle( + container, + tr::lng_settings_notifications_calls_title()); + addCheckbox( + tr::lng_settings_call_accept_calls(tr::now), + !settings.disableCalls() + )->checkedChanges( + ) | rpl::filter([&settings](bool value) { + return (settings.disableCalls() == value); + }) | rpl::start_with_next([=](bool value) { + Core::App().settings().setDisableCalls(!value); + Core::App().saveSettingsDelayed(); + }, container->lifetime()); + const auto nativeText = [&] { if (!Platform::Notifications::Supported() || Platform::Notifications::Enforced()) {