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