mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-28 01:09:19 +00:00
Do not disturb
This commit is contained in:
parent
30aff646a3
commit
16e1b7b7c2
14 changed files with 140 additions and 13 deletions
|
|
@ -267,7 +267,7 @@ void App::initCore() {
|
|||
mEngine->addImageProvider(WindowIconProvider::ProviderId, new WindowIconProvider());
|
||||
|
||||
// Enable notifications.
|
||||
mNotifier = new Notifier(mEngine);
|
||||
mNotifier = new Notifier(mEngine, settings);
|
||||
mSettings = settings;
|
||||
settings.reset();
|
||||
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@
|
|||
|
||||
#include "core/App.hpp"
|
||||
#include "core/call/CallGui.hpp"
|
||||
#include "model/tool/ToolModel.hpp"
|
||||
#include "tool/LinphoneEnums.hpp"
|
||||
#include "tool/providers/AvatarProvider.hpp"
|
||||
#include "tool/providers/ImageProvider.hpp"
|
||||
#include "model/tool/ToolModel.hpp"
|
||||
|
||||
DEFINE_ABSTRACT_OBJECT(Notifier)
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ const QHash<int, Notifier::Notification> Notifier::Notifications = {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
Notifier::Notifier(QObject *parent) : QObject(parent) {
|
||||
Notifier::Notifier(QObject *parent, QSharedPointer<Settings> settings) : QObject(parent) {
|
||||
mustBeInMainThread(getClassName());
|
||||
const int nComponents = Notifications.size();
|
||||
mComponents = new QQmlComponent *[nComponents];
|
||||
|
|
@ -113,6 +113,7 @@ Notifier::Notifier(QObject *parent) : QObject(parent) {
|
|||
}
|
||||
|
||||
mMutex = new QMutex();
|
||||
mSettings = settings;
|
||||
}
|
||||
|
||||
Notifier::~Notifier() {
|
||||
|
|
@ -267,6 +268,7 @@ void Notifier::deleteNotification(QVariant notification) {
|
|||
// =============================================================================
|
||||
|
||||
#define CREATE_NOTIFICATION(TYPE, DATA) \
|
||||
if (mSettings->dndEnabled()) return; \
|
||||
QObject *notification = createNotification(TYPE, DATA); \
|
||||
if (!notification) return; \
|
||||
const int timeout = Notifications[TYPE].getTimeout() * 1000; \
|
||||
|
|
@ -283,11 +285,12 @@ void Notifier::notifyReceivedCall(const shared_ptr<linphone::Call> &call) {
|
|||
auto accountModel = Utils::makeQObject_ptr<AccountModel>(account);
|
||||
accountModel->setSelf(accountModel);
|
||||
if (!accountModel->getNotificationsAllowed()) {
|
||||
qInfo() << "Notifications have been disabled for this account - not creating a notification for incoming call";
|
||||
qInfo()
|
||||
<< "Notifications have been disabled for this account - not creating a notification for incoming call";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
auto model = CallCore::create(call);
|
||||
auto gui = new CallGui(model);
|
||||
gui->moveToThread(App::getInstance()->thread());
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include "core/setting/SettingsCore.hpp"
|
||||
#include "tool/AbstractObject.hpp"
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
|
|
@ -36,7 +37,7 @@ class Notifier : public QObject, public AbstractObject {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Notifier(QObject *parent = Q_NULLPTR);
|
||||
Notifier(QObject *parent = Q_NULLPTR, QSharedPointer<Settings> settings = Q_NULLPTR);
|
||||
~Notifier();
|
||||
|
||||
enum NotificationType {
|
||||
|
|
@ -97,6 +98,7 @@ private:
|
|||
QQmlComponent **mComponents = nullptr;
|
||||
|
||||
static const QHash<int, Notification> Notifications;
|
||||
QSharedPointer<Settings> mSettings;
|
||||
|
||||
DECLARE_ABSTRACT_OBJECT
|
||||
};
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@ Settings::Settings(QObject *parent) : QObject(parent) {
|
|||
mLogsFolder = mSettingsModel->getLogsFolder();
|
||||
mLogsEmail = mSettingsModel->getLogsEmail();
|
||||
|
||||
// DND
|
||||
mDndEnabled = mSettingsModel->dndEnabled();
|
||||
|
||||
// Ui
|
||||
INIT_CORE_MEMBER(DisableChatFeature, mSettingsModel)
|
||||
INIT_CORE_MEMBER(DisableMeetingsFeature, mSettingsModel)
|
||||
|
|
@ -254,6 +257,17 @@ void Settings::setSelf(QSharedPointer<Settings> me) {
|
|||
});
|
||||
});
|
||||
|
||||
// DND
|
||||
mSettingsModelConnection->makeConnectToCore(&Settings::lEnableDnd, [this](const bool value) {
|
||||
mSettingsModelConnection->invokeToModel([this, value]() { mSettingsModel->enableDnd(value); });
|
||||
});
|
||||
mSettingsModelConnection->makeConnectToModel(&SettingsModel::dndChanged, [this](const bool value) {
|
||||
mSettingsModelConnection->invokeToCore([this, value]() {
|
||||
mDndEnabled = value;
|
||||
emit dndChanged();
|
||||
});
|
||||
});
|
||||
|
||||
DEFINE_CORE_GETSET_CONNECT(mSettingsModelConnection, Settings, SettingsModel, mSettingsModel, bool,
|
||||
disableChatFeature, DisableChatFeature)
|
||||
DEFINE_CORE_GETSET_CONNECT(mSettingsModelConnection, Settings, SettingsModel, mSettingsModel, bool,
|
||||
|
|
@ -426,3 +440,7 @@ QString Settings::getLogsEmail() const {
|
|||
QString Settings::getLogsFolder() const {
|
||||
return mLogsFolder;
|
||||
}
|
||||
|
||||
bool Settings::dndEnabled() const {
|
||||
return mDndEnabled;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ class Settings : public QObject, public AbstractObject {
|
|||
Q_PROPERTY(bool fullLogsEnabled READ getFullLogsEnabled WRITE setFullLogsEnabled NOTIFY fullLogsEnabledChanged)
|
||||
Q_PROPERTY(QString logsEmail READ getLogsEmail)
|
||||
Q_PROPERTY(QString logsFolder READ getLogsFolder)
|
||||
Q_PROPERTY(bool dnd READ dndEnabled WRITE lEnableDnd NOTIFY dndChanged)
|
||||
|
||||
public:
|
||||
static QSharedPointer<Settings> create();
|
||||
|
|
@ -136,6 +137,8 @@ public:
|
|||
QString getLogsEmail() const;
|
||||
QString getLogsFolder() const;
|
||||
|
||||
bool dndEnabled() const;
|
||||
|
||||
DECLARE_CORE_GETSET(bool, disableChatFeature, DisableChatFeature)
|
||||
DECLARE_CORE_GETSET(bool, disableMeetingsFeature, DisableMeetingsFeature)
|
||||
DECLARE_CORE_GETSET(bool, disableBroadcastFeature, DisableBroadcastFeature)
|
||||
|
|
@ -204,6 +207,9 @@ signals:
|
|||
|
||||
void lastActiveTabIndexChanged();
|
||||
|
||||
void dndChanged();
|
||||
void lEnableDnd(bool value);
|
||||
|
||||
private:
|
||||
std::shared_ptr<SettingsModel> mSettingsModel;
|
||||
|
||||
|
|
@ -239,6 +245,9 @@ private:
|
|||
QString mLogsFolder;
|
||||
QString mLogsEmail;
|
||||
|
||||
// DND
|
||||
bool mDndEnabled;
|
||||
|
||||
QSettings mAppSettings;
|
||||
QSharedPointer<SafeConnection<Settings, SettingsModel>> mSettingsModelConnection;
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ use_cpim=1
|
|||
zrtp_key_agreements_suites=MS_ZRTP_KEY_AGREEMENT_K255_KYB512
|
||||
|
||||
[sound]
|
||||
disable_ringing=1
|
||||
#remove this property for any application that is not Linphone public version itself
|
||||
ec_calibrator_cool_tones=1
|
||||
ec_filter=MSWebRTCAEC
|
||||
|
|
|
|||
3
Linphone/data/image/bell-dnd.svg
Normal file
3
Linphone/data/image/bell-dnd.svg
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M21 28C21 28.2652 20.8946 28.5196 20.7071 28.7071C20.5196 28.8946 20.2652 29 20 29H12C11.7348 29 11.4804 28.8946 11.2929 28.7071C11.1053 28.5196 11 28.2652 11 28C11 27.7348 11.1053 27.4804 11.2929 27.2929C11.4804 27.1054 11.7348 27 12 27H20C20.2652 27 20.5196 27.1054 20.7071 27.2929C20.8946 27.4804 21 27.7348 21 28ZM18 17H15.875L18.8375 12.555C18.9382 12.404 18.996 12.2284 19.0045 12.0471C19.0131 11.8658 18.9721 11.6856 18.8861 11.5258C18.8 11.366 18.6721 11.2326 18.516 11.14C18.3599 11.0474 18.1815 10.999 18 11H14C13.7348 11 13.4804 11.1054 13.2929 11.2929C13.1053 11.4804 13 11.7348 13 12C13 12.2652 13.1053 12.5196 13.2929 12.7071C13.4804 12.8946 13.7348 13 14 13H16.1312L13.1687 17.445C13.0683 17.5955 13.0106 17.7705 13.0018 17.9513C12.993 18.1321 13.0334 18.3118 13.1187 18.4714C13.204 18.631 13.331 18.7645 13.4862 18.8576C13.6415 18.9507 13.819 18.9999 14 19H18C18.2652 19 18.5196 18.8946 18.7071 18.7071C18.8946 18.5196 19 18.2652 19 18C19 17.7348 18.8946 17.4804 18.7071 17.2929C18.5196 17.1054 18.2652 17 18 17ZM27.73 24C27.5566 24.3055 27.3049 24.5592 27.0008 24.7349C26.6967 24.9107 26.3512 25.0022 26 25H5.99999C5.64841 24.9995 5.30317 24.9064 4.99906 24.73C4.69495 24.5535 4.44272 24.3 4.2678 23.9951C4.09288 23.6901 4.00144 23.3444 4.0027 22.9928C4.00396 22.6412 4.09788 22.2962 4.27499 21.9925C4.96874 20.7975 5.99999 17.4175 5.99999 13C5.99999 10.3478 7.05356 7.8043 8.92892 5.92893C10.8043 4.05357 13.3478 3 16 3C18.6522 3 21.1957 4.05357 23.0711 5.92893C24.9464 7.8043 26 10.3478 26 13C26 17.4163 27.0325 20.7975 27.7262 21.9925C27.9051 22.2966 27.9997 22.6429 28.0004 22.9957C28.0011 23.3486 27.9077 23.6952 27.73 24ZM26 23C25.0337 21.3412 24 17.5063 24 13C24 10.8783 23.1571 8.84344 21.6568 7.34315C20.1566 5.84285 18.1217 5 16 5C13.8783 5 11.8434 5.84285 10.3431 7.34315C8.84284 8.84344 7.99999 10.8783 7.99999 13C7.99999 17.5075 6.96499 21.3425 5.99999 23H26Z" fill="#6C7A87"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2 KiB |
|
|
@ -207,7 +207,6 @@ void AccountModel::setStunServer(QString value) {
|
|||
params->setNatPolicy(policy);
|
||||
mMonitor->setParams(params);
|
||||
emit stunServerChanged(value);
|
||||
qWarning() << "cdes stun server set to" << value;
|
||||
}
|
||||
|
||||
void AccountModel::setIceEnabled(bool value) {
|
||||
|
|
|
|||
|
|
@ -268,6 +268,10 @@ void CoreModel::onCallStateChanged(const std::shared_ptr<linphone::Core> &core,
|
|||
if (state == linphone::Call::State::IncomingReceived) {
|
||||
App::getInstance()->getNotifier()->notifyReceivedCall(call);
|
||||
}
|
||||
if (state == linphone::Call::State::End && SettingsModel::dndEnabled(core->getConfig()) &&
|
||||
core->getCallsNb() == 0) { // Disable tones in DND mode if no more calls are running.
|
||||
SettingsModel::enableTones(core->getConfig(), false);
|
||||
}
|
||||
emit callStateChanged(core, call, state, message);
|
||||
}
|
||||
void CoreModel::onCallStatsUpdated(const std::shared_ptr<linphone::Core> &core,
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ SettingsModel::SettingsModel(QObject *parent) : QObject(parent) {
|
|||
auto core = CoreModel::getInstance()->getCore();
|
||||
mConfig = core->getConfig();
|
||||
CoreModel::getInstance()->getLogger()->applyConfig(mConfig);
|
||||
if (mConfig->hasEntry(UiSection, "do_not_disturb") == 1) {
|
||||
enableDnd(dndEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
SettingsModel::~SettingsModel() {
|
||||
|
|
@ -416,6 +419,39 @@ QString SettingsModel::getLogsEmail() const {
|
|||
return Utils::coreStringToAppString(mConfig->getString(UiSection, "logs_email", Constants::DefaultLogsEmail));
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Do not disturb
|
||||
// =============================================================================
|
||||
|
||||
bool SettingsModel::dndEnabled(const shared_ptr<linphone::Config> &config) {
|
||||
mustBeInLinphoneThread(sLog().arg(Q_FUNC_INFO));
|
||||
return config ? config->getInt(UiSection, "do_not_disturb", false) : false;
|
||||
}
|
||||
|
||||
bool SettingsModel::dndEnabled() const {
|
||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||
return dndEnabled(mConfig);
|
||||
}
|
||||
|
||||
void SettingsModel::enableTones(const shared_ptr<linphone::Config> &config, bool enable) {
|
||||
mustBeInLinphoneThread(sLog().arg(Q_FUNC_INFO));
|
||||
config->setInt("sound", "tone_indications", enable); // General tones
|
||||
config->setInt("misc", "tone_indications", enable); // Call tones
|
||||
}
|
||||
|
||||
void SettingsModel::enableRinging(bool enable) {
|
||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||
mConfig->setInt("sound", "disable_ringing", !enable); // Ringing
|
||||
}
|
||||
|
||||
void SettingsModel::enableDnd(bool enableDnd) {
|
||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||
enableTones(mConfig, !enableDnd);
|
||||
enableRinging(!enableDnd);
|
||||
mConfig->setInt(UiSection, "do_not_disturb", enableDnd);
|
||||
emit dndChanged(enableDnd);
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Ui.
|
||||
// =============================================================================
|
||||
|
|
|
|||
|
|
@ -88,9 +88,6 @@ public:
|
|||
QString getPlaybackDevice() const;
|
||||
void setPlaybackDevice(const QString &device);
|
||||
|
||||
QString getRingPath() const;
|
||||
void setRingPath(const QString &path);
|
||||
|
||||
void startEchoCancellerCalibration();
|
||||
int getEchoCancellationCalibration() const;
|
||||
|
||||
|
|
@ -118,6 +115,12 @@ public:
|
|||
void cleanLogs() const;
|
||||
void sendLogs() const;
|
||||
|
||||
bool dndEnabled() const;
|
||||
static bool dndEnabled(const std::shared_ptr<linphone::Config> &config);
|
||||
void enableDnd(bool value);
|
||||
static void enableTones(const std::shared_ptr<linphone::Config> &config, bool enable);
|
||||
void enableRinging(bool enable);
|
||||
|
||||
QString getLogsEmail() const;
|
||||
|
||||
// UI
|
||||
|
|
@ -155,8 +158,6 @@ signals:
|
|||
void captureDeviceChanged(const QString &device);
|
||||
void playbackDeviceChanged(const QString &device);
|
||||
|
||||
void ringPathChanged(const QString &path);
|
||||
|
||||
void showAudioCodecsChanged(bool status);
|
||||
|
||||
void videoDevicesChanged(const QStringList &devices);
|
||||
|
|
@ -167,6 +168,8 @@ signals:
|
|||
void logsEnabledChanged(bool status);
|
||||
void fullLogsEnabledChanged(bool status);
|
||||
|
||||
void dndChanged(bool value);
|
||||
|
||||
private:
|
||||
MediastreamerUtils::SimpleCaptureGraph *mSimpleCaptureGraph = nullptr;
|
||||
int mCaptureGraphListenerCount = 0;
|
||||
|
|
|
|||
|
|
@ -136,6 +136,11 @@ bool ToolModel::createCall(const QString &sipAddress,
|
|||
}
|
||||
}
|
||||
|
||||
if (SettingsModel::dndEnabled(
|
||||
core->getConfig())) { // Force tones for outgoing calls when in DND mode (ringback, dtmf, etc ... ) disabled
|
||||
// again when no more calls are running.
|
||||
SettingsModel::enableTones(core->getConfig(), true);
|
||||
}
|
||||
std::shared_ptr<linphone::CallParams> params = core->createCallParams(nullptr);
|
||||
CallModel::activateLocalVideo(params, nullptr, localVideoEnabled);
|
||||
|
||||
|
|
|
|||
|
|
@ -349,6 +349,36 @@ Item {
|
|||
}
|
||||
RowLayout {
|
||||
spacing: 10 * DefaultStyle.dp
|
||||
PopupButton {
|
||||
id: deactivateDndButton
|
||||
Layout.preferredWidth: 32 * DefaultStyle.dp
|
||||
Layout.preferredHeight: 32 * DefaultStyle.dp
|
||||
popup.padding: 14 * DefaultStyle.dp
|
||||
visible: SettingsCpp.dnd
|
||||
contentItem: EffectImage {
|
||||
imageSource: AppIcons.bellDnd
|
||||
width: 32 * DefaultStyle.dp
|
||||
height: 32 * DefaultStyle.dp
|
||||
Layout.preferredWidth: 32 * DefaultStyle.dp
|
||||
Layout.preferredHeight: 32 * DefaultStyle.dp
|
||||
fillMode: Image.PreserveAspectFit
|
||||
colorizationColor: DefaultStyle.main1_500_main
|
||||
}
|
||||
popup.contentItem: ColumnLayout {
|
||||
IconLabelButton {
|
||||
Layout.preferredHeight: 32 * DefaultStyle.dp
|
||||
Layout.fillWidth: true
|
||||
focus: visible
|
||||
iconSize: 32 * DefaultStyle.dp
|
||||
text: qsTr("Désactiver ne pas déranger")
|
||||
iconSource: AppIcons.bellDnd
|
||||
onClicked: {
|
||||
deactivateDndButton.popup.close()
|
||||
SettingsCpp.dnd = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PopupButton {
|
||||
id: avatarButton
|
||||
Layout.preferredWidth: 54 * DefaultStyle.dp
|
||||
|
|
@ -419,6 +449,21 @@ Item {
|
|||
KeyNavigation.up: visibleChildren.length != 0 ? settingsButtons.getPreviousItem(0) : null
|
||||
KeyNavigation.down: visibleChildren.length != 0 ? settingsButtons.getNextItem(0) : null
|
||||
}
|
||||
IconLabelButton {
|
||||
id: dndButton
|
||||
Layout.preferredHeight: 32 * DefaultStyle.dp
|
||||
Layout.fillWidth: true
|
||||
focus: visible
|
||||
iconSize: 32 * DefaultStyle.dp
|
||||
text: SettingsCpp.dnd ? qsTr("Désactiver ne pas déranger") : qsTr("Activer ne pas déranger")
|
||||
iconSource: AppIcons.bellDnd
|
||||
onClicked: {
|
||||
settingsMenuButton.popup.close()
|
||||
SettingsCpp.dnd = !SettingsCpp.dnd
|
||||
}
|
||||
KeyNavigation.up: visibleChildren.length != 0 ? settingsButtons.getPreviousItem(0) : null
|
||||
KeyNavigation.down: visibleChildren.length != 0 ? settingsButtons.getNextItem(0) : null
|
||||
}
|
||||
IconLabelButton {
|
||||
id: settingsButton
|
||||
Layout.preferredHeight: 32 * DefaultStyle.dp
|
||||
|
|
|
|||
|
|
@ -112,4 +112,5 @@ QtObject {
|
|||
property string mobile: "image://internal/mobile.svg"
|
||||
property string desktop: "image://internal/desktop.svg"
|
||||
property string calendar: "image://internal/calendar.svg"
|
||||
property string bellDnd: "image://internal/bell-dnd.svg"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue