Commit cb4626fa authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/Settings/SettingsSipAccounts): supports default identity config

parent 2d8cf788
......@@ -791,6 +791,25 @@ Server url not configured.</translation>
<translation>Enable adaptive rate control</translation>
</message>
</context>
<context>
<name>SettingsSipAccounts</name>
<message>
<source>defaultIdentityTitle</source>
<translation>Default identity</translation>
</message>
<message>
<source>defaultDisplaynameLabel</source>
<translation>Display name</translation>
</message>
<message>
<source>defaultUsernameLabel</source>
<translation>Username</translation>
</message>
<message>
<source>defaultSipAddressLabel</source>
<translation>SIP address</translation>
</message>
</context>
<context>
<name>SettingsUi</name>
<message>
......
......@@ -791,6 +791,25 @@ Url du serveur non configurée.</translation>
<translation>Activer le contrôle de débit adaptif</translation>
</message>
</context>
<context>
<name>SettingsSipAccounts</name>
<message>
<source>defaultIdentityTitle</source>
<translation>Identité par défaut</translation>
</message>
<message>
<source>defaultDisplaynameLabel</source>
<translation>Nom d&apos;affichage</translation>
</message>
<message>
<source>defaultUsernameLabel</source>
<translation>Nom d&apos;utilisateur</translation>
</message>
<message>
<source>defaultSipAddressLabel</source>
<translation>Adresse SIP</translation>
</message>
</context>
<context>
<name>SettingsUi</name>
<message>
......
......@@ -31,13 +31,13 @@
void AccountSettingsModel::setDefaultProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxy_config) {
CoreManager::getInstance()->getCore()->setDefaultProxyConfig(proxy_config);
emit accountUpdated();
emit accountSettingsUpdated();
}
// -----------------------------------------------------------------------------
QString AccountSettingsModel::getUsername () const {
shared_ptr<linphone::Address> address = getDefaultSipAddress();
shared_ptr<linphone::Address> address = getUsedSipAddress();
const string &display_name = address->getDisplayName();
return ::Utils::linphoneStringToQString(
......@@ -46,21 +46,63 @@ QString AccountSettingsModel::getUsername () const {
}
void AccountSettingsModel::setUsername (const QString &username) {
shared_ptr<linphone::Address> address = getDefaultSipAddress();
shared_ptr<linphone::Address> address = getUsedSipAddress();
if (address->setDisplayName(::Utils::qStringToLinphoneString(username)))
qWarning() << QStringLiteral("Unable to set displayName on sip address: `%1`.")
.arg(::Utils::linphoneStringToQString(address->asStringUriOnly()));
emit accountUpdated();
emit accountSettingsUpdated();
}
QString AccountSettingsModel::getSipAddress () const {
return ::Utils::linphoneStringToQString(getUsedSipAddress()->asStringUriOnly());
}
// -----------------------------------------------------------------------------
QString AccountSettingsModel::getSipAddress () const {
return ::Utils::linphoneStringToQString(getDefaultSipAddress()->asStringUriOnly());
QString AccountSettingsModel::getPrimaryUsername () const {
return ::Utils::linphoneStringToQString(
CoreManager::getInstance()->getCore()->getPrimaryContactParsed()->getUsername()
);
}
void AccountSettingsModel::setPrimaryUsername (const QString &username) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::Address> primary = core->getPrimaryContactParsed();
primary->setUsername(
username.isEmpty() ? "linphone" : ::Utils::qStringToLinphoneString(username)
);
core->setPrimaryContact(primary->asString());
emit accountSettingsUpdated();
}
QString AccountSettingsModel::getPrimaryDisplayname () const {
return ::Utils::linphoneStringToQString(
CoreManager::getInstance()->getCore()->getPrimaryContactParsed()->getDisplayName()
);
}
void AccountSettingsModel::setPrimaryDisplayname (const QString &displayname) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::Address> primary = core->getPrimaryContactParsed();
primary->setDisplayName(::Utils::qStringToLinphoneString(displayname));
core->setPrimaryContact(primary->asString());
emit accountSettingsUpdated();
}
QString AccountSettingsModel::getPrimarySipAddress () const {
return ::Utils::linphoneStringToQString(
CoreManager::getInstance()->getCore()->getPrimaryContactParsed()->asString()
);
}
// -----------------------------------------------------------------------------
QVariantList AccountSettingsModel::getAccounts () const {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
QVariantList accounts;
......@@ -84,7 +126,7 @@ QVariantList AccountSettingsModel::getAccounts () const {
// -----------------------------------------------------------------------------
shared_ptr<linphone::Address> AccountSettingsModel::getDefaultSipAddress () const {
shared_ptr<linphone::Address> AccountSettingsModel::getUsedSipAddress () const {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::ProxyConfig> proxy_config = core->getDefaultProxyConfig();
......
......@@ -31,9 +31,14 @@
class AccountSettingsModel : public QObject {
Q_OBJECT;
Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY accountUpdated);
Q_PROPERTY(QString sipAddress READ getSipAddress NOTIFY accountUpdated);
Q_PROPERTY(QVariantList accounts READ getAccounts NOTIFY accountUpdated);
Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY accountSettingsUpdated);
Q_PROPERTY(QString sipAddress READ getSipAddress NOTIFY accountSettingsUpdated);
Q_PROPERTY(QString primaryDisplayname READ getPrimaryDisplayname WRITE setPrimaryDisplayname NOTIFY accountSettingsUpdated);
Q_PROPERTY(QString primaryUsername READ getPrimaryUsername WRITE setPrimaryUsername NOTIFY accountSettingsUpdated);
Q_PROPERTY(QString primarySipAddress READ getPrimarySipAddress NOTIFY accountSettingsUpdated);
Q_PROPERTY(QVariantList accounts READ getAccounts NOTIFY accountSettingsUpdated);
public:
AccountSettingsModel (QObject *parent = Q_NULLPTR) : QObject(parent) {}
......@@ -41,16 +46,25 @@ public:
Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config);
signals:
void accountUpdated ();
void accountSettingsUpdated ();
private:
QString getUsername () const;
void setUsername (const QString &username);
QString getSipAddress () const;
QString getPrimaryUsername () const;
void setPrimaryUsername (const QString &username);
QString getPrimaryDisplayname () const;
void setPrimaryDisplayname (const QString &displayname);
QString getPrimarySipAddress () const;
QVariantList getAccounts () const;
std::shared_ptr<linphone::Address> getDefaultSipAddress () const;
std::shared_ptr<linphone::Address> getUsedSipAddress () const;
};
Q_DECLARE_METATYPE(std::shared_ptr<linphone::ProxyConfig> );
......
import QtQuick 2.7
import Common 1.0
import Linphone 1.0
import App.Styles 1.0
// =============================================================================
TabContainer {
Column {
spacing: SettingsWindowStyle.forms.spacing
width: parent.width
// -------------------------------------------------------------------------
// Default identity.
// -------------------------------------------------------------------------
Form {
title: qsTr('defaultIdentityTitle')
width: parent.width
FormLine {
FormGroup {
label: qsTr('defaultDisplaynameLabel')
TextField {
text: AccountSettingsModel.primaryDisplayname
onEditingFinished: AccountSettingsModel.primaryDisplayname = text
}
}
}
FormLine {
FormGroup {
label: qsTr('defaultUsernameLabel')
TextField {
text: AccountSettingsModel.primaryUsername
onEditingFinished: AccountSettingsModel.primaryUsername = text
}
}
}
FormLine {
FormGroup {
label: qsTr('defaultSipAddressLabel')
TextField {
readOnly: true
text: AccountSettingsModel.primarySipAddress
}
}
}
}
}
}
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