Option to enable tone indications + update SDK

This commit is contained in:
Julien Wadel 2025-01-16 16:20:54 +01:00
parent fdbe13928a
commit f58a1a48e5
8 changed files with 45 additions and 16 deletions

View file

@ -113,6 +113,7 @@ SettingsCore::SettingsCore(QObject *parent) : QObject(parent) {
INIT_CORE_MEMBER(ShortcutCount, settingsModel)
INIT_CORE_MEMBER(Shortcuts, settingsModel)
INIT_CORE_MEMBER(CallToneIndicationsEnabled, settingsModel)
}
SettingsCore::SettingsCore(const SettingsCore &settingsCore) {
@ -183,6 +184,7 @@ SettingsCore::SettingsCore(const SettingsCore &settingsCore) {
mDownloadFolder = settingsCore.mDownloadFolder;
mShortcutCount = settingsCore.mShortcutCount;
mShortcuts = settingsCore.mShortcuts;
mCallToneIndicationsEnabled = settingsCore.mCallToneIndicationsEnabled;
}
SettingsCore::~SettingsCore() {
@ -386,6 +388,8 @@ void SettingsCore::setSelf(QSharedPointer<SettingsCore> me) {
ShortcutCount)
DEFINE_CORE_GET_CONNECT(mSettingsModelConnection, SettingsCore, SettingsModel, settingsModel, QVariantList,
shortcuts, Shortcuts)
DEFINE_CORE_GETSET_CONNECT(mSettingsModelConnection, SettingsCore, SettingsModel, settingsModel, bool,
callToneIndicationsEnabled, CallToneIndicationsEnabled)
auto coreModelConnection = SafeConnection<SettingsCore, CoreModel>::create(me, CoreModel::getInstance());

View file

@ -217,6 +217,7 @@ public:
// Read-only
DECLARE_CORE_MEMBER(int, shortcutCount, ShortcutCount)
DECLARE_CORE_MEMBER(QVariantList, shortcuts, Shortcuts)
DECLARE_CORE_GETSET_MEMBER(bool, callToneIndicationsEnabled, CallToneIndicationsEnabled)
signals:

View file

@ -321,7 +321,7 @@ void CoreModel::onCallStateChanged(const std::shared_ptr<linphone::Core> &core,
}
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);
SettingsModel::getInstance()->setCallToneIndicationsEnabled(false);
}
emit callStateChanged(core, call, state, message);
}

View file

@ -42,9 +42,8 @@ SettingsModel::SettingsModel() {
auto core = CoreModel::getInstance()->getCore();
mConfig = core->getConfig();
CoreModel::getInstance()->getLogger()->applyConfig(mConfig);
if (mConfig->hasEntry(UiSection, "do_not_disturb") == 1) {
enableDnd(dndEnabled());
}
// Only activate on enabled. If not, we should keep old configuration.
if (dndEnabled()) enableDnd(true);
QObject::connect(
CoreModel::getInstance().get(), &CoreModel::globalStateChanged, this,
[this](const std::shared_ptr<linphone::Core> &core, linphone::GlobalState gstate, const std::string &message) {
@ -426,6 +425,19 @@ void SettingsModel::setAutomaticallyRecordCallsEnabled(bool enabled) {
emit automaticallyRecordCallsEnabledChanged(enabled);
}
bool SettingsModel::getCallToneIndicationsEnabled() const {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
return CoreModel::getInstance()->getCore()->callToneIndicationsEnabled();
}
void SettingsModel::setCallToneIndicationsEnabled(bool enabled) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
if (enabled != getCallToneIndicationsEnabled()) {
CoreModel::getInstance()->getCore()->enableCallToneIndications(enabled);
emit callToneIndicationsEnabledChanged(enabled);
}
}
// =============================================================================
// VFS.
// =============================================================================
@ -539,12 +551,6 @@ bool SettingsModel::dndEnabled() const {
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
@ -552,7 +558,7 @@ void SettingsModel::enableRinging(bool enable) {
void SettingsModel::enableDnd(bool enableDnd) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
enableTones(mConfig, !enableDnd);
setCallToneIndicationsEnabled(!enableDnd);
enableRinging(!enableDnd);
mConfig->setInt(UiSection, "do_not_disturb", enableDnd);
emit dndChanged(enableDnd);

View file

@ -108,9 +108,16 @@ public:
QString getVideoDevice() const;
void setVideoDevice(QString device);
//------------------------------------------------------------------------------------------------------------
void startEchoCancellerCalibration();
int getEchoCancellationCalibration() const;
bool getCallToneIndicationsEnabled() const;
void setCallToneIndicationsEnabled(bool enabled);
//------------------------------------------------------------------------------------------------------------
bool getLogsEnabled() const;
void setLogsEnabled(bool status);
@ -133,7 +140,6 @@ public:
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;
@ -181,8 +187,6 @@ signals:
void videoEnabledChanged(bool enabled);
// Call. --------------------------------------------------------------------
void echoCancellationEnabledChanged(bool enabled);
void automaticallyRecordCallsEnabledChanged(bool enabled);
void captureGraphRunningChanged(bool running);
@ -198,10 +202,18 @@ signals:
void playbackDeviceChanged(QVariantMap device);
void ringerDeviceChanged(QVariantMap device);
void videoDeviceChanged(QString device);
void conferenceLayoutChanged();
void mediaEncryptionChanged();
void mediaEncryptionMandatoryChanged();
void echoCancellationEnabledChanged(bool enabled);
void automaticallyRecordCallsEnabledChanged(bool enabled);
void callToneIndicationsEnabledChanged(bool enabled);
void showAudioCodecsChanged(bool status);
void micVolumeChanged(float volume);
void logsEnabledChanged(bool status);

View file

@ -164,7 +164,7 @@ 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);
SettingsModel::getInstance()->setCallToneIndicationsEnabled(true);
}
std::shared_ptr<linphone::CallParams> params = core->createCallParams(nullptr);
if (localVideoEnabled) CallModel::activateLocalVideo(params, localVideoEnabled);

View file

@ -50,6 +50,12 @@ AbstractSettingsLayout {
propertyOwner: SettingsCpp
visible: !SettingsCpp.disableCallRecordings
}
SwitchSetting {
titleText: qsTr("Tonalités")
subTitleText: qsTr("Activer les tonalités")
propertyName: "callToneIndicationsEnabled"
propertyOwner: SettingsCpp
}
}
}

@ -1 +1 @@
Subproject commit ba6b6ff92790491e8344b9d1b6df4e2df45e3199
Subproject commit 5711bcc198fdc48665e36bd78fe987b33c281c81