Commit 5cd97cb5 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(Settings): provide an option to disable the RLS URI

parent 3c455990
......@@ -1240,6 +1240,22 @@ your friend&apos;s SIP address or username.</translation>
<source>enableAdaptiveRateControlLabel</source>
<translation>Enable adaptive rate control</translation>
</message>
<message>
<source>presenceTitle</source>
<translation>Presence</translation>
</message>
<message>
<source>rlsUriLabel</source>
<translation>Use RLS URI</translation>
</message>
<message>
<source>rlsUriAuto</source>
<translation>AUTO</translation>
</message>
<message>
<source>rlsUriDisabled</source>
<translation>NEVER</translation>
</message>
</context>
<context>
<name>SettingsSipAccounts</name>
......
......@@ -1238,6 +1238,22 @@ Cliquez ici : &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<source>enableAdaptiveRateControlLabel</source>
<translation>Activer le contrôle de débit adaptif</translation>
</message>
<message>
<source>presenceTitle</source>
<translation>Présence</translation>
</message>
<message>
<source>rlsUriLabel</source>
<translation>Utiliser l&apos;URI RLS</translation>
</message>
<message>
<source>rlsUriAuto</source>
<translation>AUTO</translation>
</message>
<message>
<source>rlsUriDisabled</source>
<translation>JAMAIS</translation>
</message>
</context>
<context>
<name>SettingsSipAccounts</name>
......
......@@ -48,10 +48,6 @@
#define PATH_MESSAGE_HISTORY_LIST "/message-history.db"
#define PATH_ZRTP_SECRETS "/zidcache"
#ifndef RLS_URI
#define RLS_URI "sips:rls@sip.linphone.org"
#endif // ifndef RLS_URI
using namespace std;
// =============================================================================
......@@ -271,14 +267,6 @@ static void migrateConfigurationFile (const QString &oldPath, const QString &new
}
}
inline void setRlsUri (const QString &configPath) {
shared_ptr<linphone::Config> config = linphone::Config::newWithFactory(::Utils::appStringToCoreString(configPath), "");
if (config->getString("sip", "rls_uri", "").empty()) {
config->setString("sip", "rls_uri", RLS_URI);
config->sync();
}
}
void Paths::migrate () {
QString newPath = ::getAppConfigFilePath();
QString oldBaseDir = QSysInfo::productType() == "windows"
......@@ -286,11 +274,8 @@ void Paths::migrate () {
: QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
QString oldPath = oldBaseDir + "/.linphonerc";
if (!::filePathExists(newPath) && ::filePathExists(oldPath)) {
if (!::filePathExists(newPath) && ::filePathExists(oldPath))
::migrateConfigurationFile(oldPath, newPath);
/* Define RLS uri so that presence switches from peer-to-peer mode to list mode. */
::setRlsUri(newPath);
}
newPath = ::getAppCallHistoryFilePath();
oldPath = oldBaseDir + "/.linphone-call-history.db";
......
......@@ -40,6 +40,12 @@ public:
}
private:
void createProxyConfig (const shared_ptr<linphone::AccountCreator> &creator) {
shared_ptr<linphone::ProxyConfig> proxyConfig = creator->createProxyConfig();
Q_CHECK_PTR(proxyConfig);
CoreManager::getInstance()->getSettingsModel()->configureRlsUri(proxyConfig);
}
void onCreateAccount (
const shared_ptr<linphone::AccountCreator> &,
linphone::AccountCreatorStatus status,
......@@ -63,9 +69,7 @@ private:
const string &
) override {
if (status == linphone::AccountCreatorStatusAccountExist || status == linphone::AccountCreatorStatusAccountExistWithAlias) {
shared_ptr<linphone::ProxyConfig> proxyConfig = creator->createProxyConfig();
Q_CHECK_PTR(proxyConfig);
createProxyConfig(creator);
emit mAssistant->loginStatusChanged(QString(""));
} else {
if (status == linphone::AccountCreatorStatusRequestFailed)
......@@ -84,10 +88,8 @@ private:
status == linphone::AccountCreatorStatusAccountActivated ||
status == linphone::AccountCreatorStatusAccountAlreadyActivated
) {
if (creator->getEmail().empty()) {
shared_ptr<linphone::ProxyConfig> proxyConfig = creator->createProxyConfig();
Q_CHECK_PTR(proxyConfig);
}
if (creator->getEmail().empty())
createProxyConfig(creator);
emit mAssistant->activateStatusChanged(QString(""));
} else {
......@@ -104,9 +106,7 @@ private:
const string &
) override {
if (status == linphone::AccountCreatorStatusAccountActivated) {
shared_ptr<linphone::ProxyConfig> proxyConfig = creator->createProxyConfig();
Q_CHECK_PTR(proxyConfig);
createProxyConfig(creator);
emit mAssistant->activateStatusChanged(QString(""));
} else {
if (status == linphone::AccountCreatorStatusRequestFailed)
......
......@@ -61,7 +61,8 @@ AccountSettingsModel::AccountSettingsModel (QObject *parent) : QObject(parent) {
bool AccountSettingsModel::addOrUpdateProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {
Q_CHECK_PTR(proxyConfig);
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
CoreManager *coreManager = CoreManager::getInstance();
shared_ptr<linphone::Core> core = coreManager->getCore();
list<shared_ptr<linphone::ProxyConfig> > proxyConfigs = core->getProxyConfigList();
if (find(proxyConfigs.cbegin(), proxyConfigs.cend(), proxyConfig) != proxyConfigs.cend()) {
......@@ -70,12 +71,15 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (const shared_ptr<linphone::Pr
.arg(::Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString()));
return false;
}
} else if (core->addProxyConfig(proxyConfig) == -1) {
qWarning() << QStringLiteral("Unable to add proxy config: `%1`.")
.arg(::Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString()));
return false;
coreManager->getSettingsModel()->configureRlsUri();
} else {
if (core->addProxyConfig(proxyConfig) == -1) {
qWarning() << QStringLiteral("Unable to add proxy config: `%1`.")
.arg(::Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString()));
return false;
}
coreManager->getSettingsModel()->configureRlsUri(proxyConfig);
}
emit accountSettingsUpdated();
return true;
......@@ -115,7 +119,10 @@ void AccountSettingsModel::setDefaultProxyConfig (const shared_ptr<linphone::Pro
void AccountSettingsModel::removeProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {
Q_CHECK_PTR(proxyConfig);
CoreManager::getInstance()->getCore()->removeProxyConfig(proxyConfig);
CoreManager *coreManager = CoreManager::getInstance();
coreManager->getCore()->removeProxyConfig(proxyConfig);
coreManager->getSettingsModel()->configureRlsUri();
emit accountSettingsUpdated();
}
......
......@@ -29,6 +29,10 @@
#include "SettingsModel.hpp"
#ifndef DEFAULT_RLS_URI
#define DEFAULT_RLS_URI "sips:rls@sip.linphone.org"
#endif // ifndef RLS_URI
using namespace std;
// =============================================================================
......@@ -37,6 +41,7 @@ const string SettingsModel::UI_SECTION("ui");
SettingsModel::SettingsModel (QObject *parent) : QObject(parent) {
mConfig = CoreManager::getInstance()->getCore()->getConfig();
configureRlsUri();
}
// =============================================================================
......@@ -647,6 +652,62 @@ void SettingsModel::setDscpVideo (int dscp) {
emit dscpVideoChanged(dscp);
}
// -----------------------------------------------------------------------------
bool SettingsModel::getRlsUriEnabled () const {
return !!mConfig->getInt(UI_SECTION, "rls_uri_enabled", true);
}
void SettingsModel::setRlsUriEnabled (bool status) {
mConfig->setInt(UI_SECTION, "rls_uri_enabled", status);
mConfig->setString("sip", "rls_uri", status ? DEFAULT_RLS_URI : "");
emit rlsUriEnabledChanged(status);
}
static string getRlsUriDomain () {
static string domain;
if (!domain.empty())
return domain;
shared_ptr<linphone::Address> linphoneAddress = CoreManager::getInstance()->getCore()->createAddress(DEFAULT_RLS_URI);
Q_CHECK_PTR(linphoneAddress);
domain = linphoneAddress->getDomain();
return domain;
}
void SettingsModel::configureRlsUri () {
// Ensure rls uri is empty.
if (!getRlsUriEnabled()) {
mConfig->setString("sip", "rls_uri", "");
return;
}
// Set rls uri if necessary.
const string domain = getRlsUriDomain();
for (const auto &proxyConfig : CoreManager::getInstance()->getCore()->getProxyConfigList())
if (proxyConfig->getDomain() == domain) {
mConfig->setString("sip", "rls_uri", DEFAULT_RLS_URI);
return;
}
mConfig->setString("sip", "rls_uri", "");
}
void SettingsModel::configureRlsUri (const shared_ptr<const linphone::ProxyConfig> &proxyConfig) {
if (!getRlsUriEnabled()) {
mConfig->setString("sip", "rls_uri", "");
return;
}
const string domain = getRlsUriDomain();
if (proxyConfig->getDomain() == domain) {
mConfig->setString("sip", "rls_uri", DEFAULT_RLS_URI);
return;
}
mConfig->setString("sip", "rls_uri", "");
}
// =============================================================================
// UI.
// =============================================================================
......
......@@ -111,6 +111,8 @@ class SettingsModel : public QObject {
Q_PROPERTY(int dscpAudio READ getDscpAudio WRITE setDscpAudio NOTIFY dscpAudioChanged);
Q_PROPERTY(int dscpVideo READ getDscpVideo WRITE setDscpVideo NOTIFY dscpVideoChanged);
Q_PROPERTY(bool rlsUriEnabled READ getRlsUriEnabled WRITE setRlsUriEnabled NOTIFY rlsUriEnabledChanged);
// UI. -----------------------------------------------------------------------
Q_PROPERTY(QString remoteProvisioning READ getRemoteProvisioning WRITE setRemoteProvisioning NOTIFY remoteProvisioningChanged);
......@@ -272,6 +274,12 @@ public:
int getDscpVideo () const;
void setDscpVideo (int dscp);
bool getRlsUriEnabled () const;
void setRlsUriEnabled (bool status);
void configureRlsUri ();
void configureRlsUri (const std::shared_ptr<const linphone::ProxyConfig> &proxyConfig);
// UI. -----------------------------------------------------------------------
QString getSavedScreenshotsFolder () const;
......@@ -375,6 +383,8 @@ signals:
void dscpAudioChanged (int dscp);
void dscpVideoChanged (int dscp);
void rlsUriEnabledChanged (bool status);
// UI. -----------------------------------------------------------------------
void savedScreenshotsFolderChanged (const QString &folder);
......
......@@ -96,6 +96,31 @@ TabContainer {
}
}
// -------------------------------------------------------------------------
// Presence.
// -------------------------------------------------------------------------
Form {
title: qsTr('presenceTitle')
width: parent.width
FormLine {
FormGroup {
label: qsTr('rlsUriLabel')
ExclusiveButtons {
selectedButton: Number(!SettingsModel.rlsUriEnabled)
texts: [
qsTr('rlsUriAuto'),
qsTr('rlsUriDisabled')
]
onClicked: SettingsModel.rlsUriEnabled = !button
}
}
}
}
// -------------------------------------------------------------------------
// Network protocol and ports.
// -------------------------------------------------------------------------
......
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