mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-21 05:38:12 +00:00
feat(ui/views/App/Settings/SettingsSipAccounts): in progress
This commit is contained in:
parent
ef73f050ae
commit
5689d88542
9 changed files with 210 additions and 15 deletions
|
|
@ -864,6 +864,14 @@ Server url not configured.</translation>
|
|||
<source>avpfEnabledLabel</source>
|
||||
<translation>Enable AVPF</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>cancel</source>
|
||||
<translation type="unfinished">CANCEL</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>confirm</source>
|
||||
<translation type="unfinished">CONFIRM</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsUi</name>
|
||||
|
|
|
|||
|
|
@ -864,6 +864,14 @@ Url du serveur non configurée.</translation>
|
|||
<source>avpfEnabledLabel</source>
|
||||
<translation>Activer AVPF</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>cancel</source>
|
||||
<translation type="unfinished">ANNULER</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>confirm</source>
|
||||
<translation type="unfinished">CONFIRMER</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsUi</name>
|
||||
|
|
|
|||
|
|
@ -34,7 +34,13 @@ QVariantMap AccountSettingsModel::getProxyConfigDescription (const std::shared_p
|
|||
|
||||
QVariantMap map;
|
||||
|
||||
map["sipAddress"] = ::Utils::linphoneStringToQString(proxy_config->getIdentityAddress()->asStringUriOnly());
|
||||
{
|
||||
const shared_ptr<const linphone::Address> address = proxy_config->getIdentityAddress();
|
||||
map["sipAddress"] = address
|
||||
? ::Utils::linphoneStringToQString(proxy_config->getIdentityAddress()->asStringUriOnly())
|
||||
: "";
|
||||
}
|
||||
|
||||
map["serverAddress"] = ::Utils::linphoneStringToQString(proxy_config->getServerAddr());
|
||||
map["registrationDuration"] = proxy_config->getPublishExpires();
|
||||
map["transport"] = ::Utils::linphoneStringToQString(proxy_config->getTransport());
|
||||
|
|
@ -58,6 +64,105 @@ void AccountSettingsModel::removeProxyConfig (const shared_ptr<linphone::ProxyCo
|
|||
emit accountSettingsUpdated();
|
||||
}
|
||||
|
||||
void AccountSettingsModel::addOrUpdateProxyConfig (
|
||||
const std::shared_ptr<linphone::ProxyConfig> &proxy_config,
|
||||
const QVariantMap &data
|
||||
) {
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
QString literal = data["sipAddress"].toString();
|
||||
|
||||
// Sip address.
|
||||
{
|
||||
shared_ptr<linphone::Address> address = linphone::Factory::get()->createAddress(
|
||||
::Utils::qStringToLinphoneString(literal)
|
||||
);
|
||||
if (!address) {
|
||||
qWarning() << QStringLiteral("Unable to create sip address object from: `%1`.").arg(literal);
|
||||
return;
|
||||
}
|
||||
|
||||
proxy_config->setIdentityAddress(address);
|
||||
}
|
||||
|
||||
// Server address.
|
||||
{
|
||||
QString q_server_address = data["serverAddress"].toString();
|
||||
string s_server_address = ::Utils::qStringToLinphoneString(q_server_address);
|
||||
|
||||
if (!proxy_config->setServerAddr(s_server_address)) {
|
||||
shared_ptr<linphone::Address> address = linphone::Factory::get()->createAddress(s_server_address);
|
||||
if (!address) {
|
||||
qWarning() << QStringLiteral("Unable to add server address: `%1`.").arg(q_server_address);
|
||||
return;
|
||||
}
|
||||
|
||||
QString transport = data["transport"].toString();
|
||||
if (transport == "TCP")
|
||||
address->setTransport(linphone::TransportType::TransportTypeTcp);
|
||||
else if (transport == "UDP")
|
||||
address->setTransport(linphone::TransportType::TransportTypeTcp);
|
||||
else
|
||||
address->setTransport(linphone::TransportType::TransportTypeTls);
|
||||
|
||||
if (!proxy_config->setServerAddr(address->asString())) {
|
||||
qWarning() << QStringLiteral("Unable to add server address: `%1`.").arg(q_server_address);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proxy_config->setPublishExpires(data["registrationDuration"].toInt());
|
||||
proxy_config->setRoute(::Utils::qStringToLinphoneString(data["route"].toString()));
|
||||
proxy_config->setContactParameters(::Utils::qStringToLinphoneString(data["contactParams"].toString()));
|
||||
proxy_config->setAvpfRrInterval(data["contactParams"].toInt());
|
||||
proxy_config->enableRegister(data["registerEnabled"].toBool());
|
||||
proxy_config->enablePublish(data["publishEnabled"].toBool());
|
||||
proxy_config->setAvpfMode(data["avpfEnabled"].toBool()
|
||||
? linphone::AVPFMode::AVPFModeEnabled
|
||||
: linphone::AVPFMode::AVPFModeDefault
|
||||
);
|
||||
|
||||
list<shared_ptr<linphone::ProxyConfig> > proxy_configs = core->getProxyConfigList();
|
||||
if (find(proxy_configs.cbegin(), proxy_configs.cend(), proxy_config) != proxy_configs.cend()) {
|
||||
if (proxy_config->done() == -1) {
|
||||
qWarning() << QStringLiteral("Unable to update proxy config: `%1`.").arg(literal);
|
||||
return;
|
||||
}
|
||||
} else if (core->addProxyConfig(proxy_config) == -1) {
|
||||
qWarning() << QStringLiteral("Unable to add proxy config: `%1`.").arg(literal);
|
||||
return;
|
||||
}
|
||||
|
||||
emit accountSettingsUpdated();
|
||||
}
|
||||
|
||||
std::shared_ptr<linphone::ProxyConfig> AccountSettingsModel::createProxyConfig () {
|
||||
return CoreManager::getInstance()->getCore()->createProxyConfig();
|
||||
}
|
||||
|
||||
QString AccountSettingsModel::getTransportFromServerAddress (const QString &server_address) {
|
||||
const shared_ptr<const linphone::Address> address = linphone::Factory::get()->createAddress(
|
||||
::Utils::qStringToLinphoneString(server_address)
|
||||
);
|
||||
|
||||
if (!address)
|
||||
return QStringLiteral("");
|
||||
|
||||
switch (address->getTransport()) {
|
||||
case linphone::TransportTypeUdp:
|
||||
return QStringLiteral("UDP");
|
||||
case linphone::TransportTypeTcp:
|
||||
return QStringLiteral("TCP");
|
||||
case linphone::TransportTypeTls:
|
||||
return QStringLiteral("TLS");
|
||||
|
||||
case linphone::TransportTypeDtls:
|
||||
break;
|
||||
}
|
||||
|
||||
return QStringLiteral("");
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AccountSettingsModel::getUsername () const {
|
||||
|
|
|
|||
|
|
@ -44,9 +44,16 @@ public:
|
|||
AccountSettingsModel (QObject *parent = Q_NULLPTR) : QObject(parent) {}
|
||||
|
||||
Q_INVOKABLE QVariantMap getProxyConfigDescription (const std::shared_ptr<linphone::ProxyConfig> &proxy_config);
|
||||
|
||||
Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config);
|
||||
|
||||
Q_INVOKABLE void addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config, const QVariantMap &data);
|
||||
Q_INVOKABLE void removeProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config);
|
||||
|
||||
Q_INVOKABLE std::shared_ptr<linphone::ProxyConfig> createProxyConfig ();
|
||||
|
||||
Q_INVOKABLE QString getTransportFromServerAddress (const QString &server_address);
|
||||
|
||||
signals:
|
||||
void accountSettingsUpdated ();
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ DialogPlus {
|
|||
|
||||
onClicked: exit(0)
|
||||
},
|
||||
TextButtonA {
|
||||
TextButtonB {
|
||||
text: qsTr('confirm')
|
||||
|
||||
onClicked: exit(1)
|
||||
|
|
|
|||
|
|
@ -121,6 +121,8 @@ TabContainer {
|
|||
|
||||
TextButtonB {
|
||||
text: qsTr('addAccount')
|
||||
|
||||
onClicked: Logic.editAccount()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,21 +8,27 @@
|
|||
|
||||
// =============================================================================
|
||||
|
||||
function initForm (account) {
|
||||
if (!account) {
|
||||
return
|
||||
}
|
||||
var proxyConfig
|
||||
|
||||
var config = Linphone.AccountSettingsModel.getProxyConfigDescription(account.proxyConfig)
|
||||
function initForm (account) {
|
||||
var AccountSettingsModel = Linphone.AccountSettingsModel
|
||||
|
||||
proxyConfig = account
|
||||
? account.proxyConfig
|
||||
: AccountSettingsModel.createProxyConfig()
|
||||
|
||||
var config = AccountSettingsModel.getProxyConfigDescription(proxyConfig)
|
||||
|
||||
sipAddress.text = config.sipAddress
|
||||
serverAddress.text = config.serverAddress
|
||||
registrationDuration.text = config.registrationDuration
|
||||
|
||||
var currentTransport = config.transport.toUpperCase()
|
||||
transport.currentIndex = Utils.findIndex(transport.model, function (value) {
|
||||
return value === currentTransport
|
||||
})
|
||||
transport.currentIndex = Number(
|
||||
Utils.findIndex(transport.model, function (value) {
|
||||
return value === currentTransport
|
||||
})
|
||||
)
|
||||
|
||||
route.text = config.route
|
||||
contactParams.text = config.contactParams
|
||||
|
|
@ -31,3 +37,28 @@ function initForm (account) {
|
|||
publishPresence.checked = config.publishPresence
|
||||
avpfEnabled.checked = config.avpfEnabled
|
||||
}
|
||||
|
||||
function handleServerAddressChanged (address) {
|
||||
var newTransport = Linphone.AccountSettingsModel.getTransportFromServerAddress(address)
|
||||
if (newTransport.length > 0) {
|
||||
transport.currentIndex = Utils.findIndex(transport.model, function (value) {
|
||||
return value === newTransport
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function validProxyConfig () {
|
||||
// TODO: Display errors on the form (if necessary).
|
||||
Linphone.AccountSettingsModel.addOrUpdateProxyConfig(proxyConfig, {
|
||||
sipAddress: sipAddress.text,
|
||||
serverAddress: serverAddress.text,
|
||||
registrationDuration: registrationDuration.text,
|
||||
transport: transport.currentText,
|
||||
route: route.text,
|
||||
contactParams: contactParams.text,
|
||||
avpfInterval: avpfInterval.text,
|
||||
registerEnabled: registerEnabled.checked,
|
||||
publishPresence: publishPresence.checked,
|
||||
avpfEnabled: avpfEnabled.checked
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,29 @@ import 'SettingsSipAccountsEdit.js' as Logic
|
|||
|
||||
// =============================================================================
|
||||
|
||||
ConfirmDialog {
|
||||
property var account
|
||||
DialogPlus {
|
||||
id: dialog
|
||||
|
||||
property var account // Optional.
|
||||
|
||||
buttons: [
|
||||
TextButtonA {
|
||||
text: qsTr('cancel')
|
||||
|
||||
onClicked: exit(0)
|
||||
},
|
||||
TextButtonB {
|
||||
enabled: sipAddress.length > 0 && serverAddress.length > 0
|
||||
text: qsTr('confirm')
|
||||
|
||||
onClicked: {
|
||||
Logic.validProxyConfig()
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
centeredButtons: true
|
||||
|
||||
height: SettingsSipAccountsEditStyle.height
|
||||
width: SettingsSipAccountsEditStyle.width
|
||||
|
|
@ -25,9 +46,9 @@ ConfirmDialog {
|
|||
Form {
|
||||
anchors {
|
||||
left: parent.left
|
||||
leftMargin: ManageAccountsStyle.leftMargin
|
||||
leftMargin: SettingsSipAccountsEditStyle.leftMargin
|
||||
right: parent.right
|
||||
rightMargin: ManageAccountsStyle.rightMargin
|
||||
rightMargin: SettingsSipAccountsEditStyle.rightMargin
|
||||
}
|
||||
|
||||
FormLine {
|
||||
|
|
@ -46,6 +67,8 @@ ConfirmDialog {
|
|||
|
||||
TextField {
|
||||
id: serverAddress
|
||||
|
||||
onTextChanged: Logic.handleServerAddressChanged(text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -67,7 +90,7 @@ ConfirmDialog {
|
|||
ComboBox {
|
||||
id: transport
|
||||
|
||||
model: [ 'TCP', 'UDP', 'TLS' ]
|
||||
model: [ 'UDP', 'TCP', 'TLS' ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -98,6 +121,9 @@ ConfirmDialog {
|
|||
|
||||
NumericField {
|
||||
id: avpfInterval
|
||||
|
||||
maxValue: 5
|
||||
minValue: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -108,6 +134,8 @@ ConfirmDialog {
|
|||
|
||||
Switch {
|
||||
id: registerEnabled
|
||||
|
||||
onClicked: checked = !checked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -118,6 +146,8 @@ ConfirmDialog {
|
|||
|
||||
Switch {
|
||||
id: publishPresence
|
||||
|
||||
onClicked: checked = !checked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -128,6 +158,8 @@ ConfirmDialog {
|
|||
|
||||
Switch {
|
||||
id: avpfEnabled
|
||||
|
||||
onClicked: checked = !checked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,5 +5,7 @@ import QtQuick 2.7
|
|||
|
||||
QtObject {
|
||||
property int height: 550
|
||||
property int leftMargin: 35
|
||||
property int rightMargin: 35
|
||||
property int width: 600
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue