Commit 986f5d99 authored by Danmei Chen's avatar Danmei Chen Committed by Ronan Abhamon

feat(SettingsSipAccountsEdit): give access to nat policy settings for one proxy config

parent c2cde508
......@@ -1386,6 +1386,34 @@ your friend&apos;s SIP address or username.</translation>
<source>invalidRoute</source>
<translation>Invalid route.</translation>
</message>
<message>
<source>enableIceLabel</source>
<translation>Enable ICE</translation>
</message>
<message>
<source>stunServerLabel</source>
<translation>STUN/TURN server</translation>
</message>
<message>
<source>enableTurnLabel</source>
<translation>Enable TURN</translation>
</message>
<message>
<source>turnUserLabel</source>
<translation>TURN user</translation>
</message>
<message>
<source>turnPasswordLabel</source>
<translation>TURN password</translation>
</message>
<message>
<source>natAndFirewallTitle</source>
<translation>NAT and Firewall</translation>
</message>
<message>
<source>mainSipAccountSettingsTitle</source>
<translation>Main SIP account settings</translation>
</message>
</context>
<context>
<name>SettingsUi</name>
......
......@@ -1384,6 +1384,34 @@ Cliquez ici : &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<source>invalidRoute</source>
<translation>Route invalide.</translation>
</message>
<message>
<source>enableIceLabel</source>
<translation>Activer ICE</translation>
</message>
<message>
<source>stunServerLabel</source>
<translation>Serveur STUN/TURN</translation>
</message>
<message>
<source>enableTurnLabel</source>
<translation>Activer TURN</translation>
</message>
<message>
<source>turnUserLabel</source>
<translation>Utilisateur TURN</translation>
</message>
<message>
<source>turnPasswordLabel</source>
<translation>Mot de passe TURN</translation>
</message>
<message>
<source>natAndFirewallTitle</source>
<translation>NAT et Pare-feu</translation>
</message>
<message>
<source>mainSipAccountSettingsTitle</source>
<translation>Paramètres principaux du compte SIP</translation>
</message>
</context>
<context>
<name>SettingsUi</name>
......
......@@ -1384,6 +1384,34 @@
<source>invalidRoute</source>
<translation>Неверный маршрут.</translation>
</message>
<message>
<source>enableIceLabel</source>
<translation>Включить ICE</translation>
</message>
<message>
<source>stunServerLabel</source>
<translation>Сервер STUN/TURN</translation>
</message>
<message>
<source>enableTurnLabel</source>
<translation>Включить TURN</translation>
</message>
<message>
<source>turnUserLabel</source>
<translation>Пользователь TURN</translation>
</message>
<message>
<source>turnPasswordLabel</source>
<translation>Пароль TURN</translation>
</message>
<message>
<source>natAndFirewallTitle</source>
<translation>NAT и межсетевой экран</translation>
</message>
<message>
<source>mainSipAccountSettingsTitle</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsUi</name>
......
......@@ -1386,6 +1386,34 @@ arkadaşınızın SIP adresini veya kullanıcı adını girin.</translation>
<source>invalidRoute</source>
<translation>Geçersiz rota.</translation>
</message>
<message>
<source>enableIceLabel</source>
<translation>ICE&apos;yi etkinleştir</translation>
</message>
<message>
<source>stunServerLabel</source>
<translation>STUN/TURN sunucusu</translation>
</message>
<message>
<source>enableTurnLabel</source>
<translation>TURN&apos;u etkinleştir</translation>
</message>
<message>
<source>turnUserLabel</source>
<translation>TURN kullanıcısı</translation>
</message>
<message>
<source>turnPasswordLabel</source>
<translation>TURN parolası</translation>
</message>
<message>
<source>natAndFirewallTitle</source>
<translation>NAT ve Güvenlik Duvarı</translation>
</message>
<message>
<source>mainSipAccountSettingsTitle</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsUi</name>
......
......@@ -96,7 +96,6 @@ QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<li
? ::Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString())
: QString("");
}
map["serverAddress"] = ::Utils::coreStringToAppString(proxyConfig->getServerAddr());
map["registrationDuration"] = proxyConfig->getPublishExpires();
map["transport"] = ::Utils::coreStringToAppString(proxyConfig->getTransport());
......@@ -108,6 +107,14 @@ QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<li
map["avpfEnabled"] = proxyConfig->getAvpfMode() == linphone::AVPFMode::AVPFModeEnabled;
map["registrationState"] = ::mapLinphoneRegistrationStateToUi(proxyConfig->getState());
shared_ptr<linphone::NatPolicy> natPolicy = proxyConfig->getNatPolicy();
map["iceEnabled"] = natPolicy->iceEnabled();
map["turnEnabled"] = natPolicy->turnEnabled();
map["stunServer"] = ::Utils::coreStringToAppString(natPolicy->getStunServer());
map["turnUser"] = ::Utils::coreStringToAppString(natPolicy->getStunServerUsername());
shared_ptr<const linphone::AuthInfo> authInfo = proxyConfig->findAuthInfo();
map["turnPassword"] = authInfo ? ::Utils::coreStringToAppString(authInfo->getPasswd()) : QString("");
return map;
}
......@@ -172,6 +179,33 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
: linphone::AVPFMode::AVPFModeDefault
);
shared_ptr<linphone::NatPolicy> natPolicy = proxyConfig->getNatPolicy();
natPolicy->enableIce(data["iceEnabled"].toBool());
natPolicy->enableStun(data["iceEnabled"].toBool());
natPolicy->enableTurn(data["turnEnabled"].toBool());
natPolicy->setStunServer(::Utils::appStringToCoreString(data["stunServer"].toString()));
natPolicy->setStunServerUsername(::Utils::appStringToCoreString(data["turnUser"].toString()));
shared_ptr<const linphone::AuthInfo> authInfo = proxyConfig->findAuthInfo();
shared_ptr<linphone::Core> core = proxyConfig->getCore();
if (authInfo) {
shared_ptr<linphone::AuthInfo> clonedAuthInfo = authInfo->clone();
clonedAuthInfo->setPasswd(::Utils::appStringToCoreString(data["turnPassword"].toString()));
core->removeAuthInfo(authInfo);
core->addAuthInfo(clonedAuthInfo);
} else {
authInfo = linphone::Factory::get()->createAuthInfo(
::Utils::appStringToCoreString(data["turnUser"].toString()),
::Utils::appStringToCoreString(data["turnUser"].toString()),
::Utils::appStringToCoreString(data["turnPassword"].toString()),
"",
"",
""
);
core->addAuthInfo(authInfo);
}
return addOrUpdateProxyConfig(proxyConfig);
}
......
......@@ -36,6 +36,11 @@ function initForm (account) {
registerEnabled.checked = config.registerEnabled
publishPresence.checked = config.publishPresence
avpfEnabled.checked = config.avpfEnabled
iceEnabled.checked = config.iceEnabled
turnEnabled.checked = config.turnEnabled
stunServer.text = config.stunServer
turnPassword.text = config.turnPassword
turnUser.text = config.turnUser
if (account) {
dialog._sipAddressOk = true
......@@ -62,7 +67,12 @@ function validProxyConfig () {
avpfInterval: avpfInterval.text,
registerEnabled: registerEnabled.checked,
publishPresence: publishPresence.checked,
avpfEnabled: avpfEnabled.checked
avpfEnabled: avpfEnabled.checked,
iceEnabled: iceEnabled.checked,
turnEnabled: turnEnabled.checked,
stunServer: stunServer.text,
turnUser: turnUser.text,
turnPassword: turnPassword.text
})) {
dialog.exit(1)
} else {
......@@ -108,3 +118,5 @@ function handleTransportChanged (transport) {
dialog._serverAddressOk = false
}
}
// -----------------------------------------------------------------------------
......@@ -42,131 +42,206 @@ DialogPlus {
// ---------------------------------------------------------------------------
Form {
anchors.fill: parent
TabContainer {
Column {
width: parent.width
FormLine {
FormGroup {
label: qsTr('sipAddressLabel') + '*'
Form {
title: qsTr('mainSipAccountSettingsTitle')
width: parent.width
TextField {
id: sipAddress
FormLine {
FormGroup {
label: qsTr('sipAddressLabel') + '*'
error: dialog._sipAddressOk ? '' : qsTr('invalidSipAddress')
TextField {
id: sipAddress
onTextChanged: Logic.handleSipAddressChanged(text)
error: dialog._sipAddressOk ? '' : qsTr('invalidSipAddress')
onTextChanged: Logic.handleSipAddressChanged(text)
}
}
}
}
}
FormLine {
FormGroup {
label: qsTr('serverAddressLabel') + '*'
FormLine {
FormGroup {
label: qsTr('serverAddressLabel') + '*'
TextField {
id: serverAddress
TextField {
id: serverAddress
error: dialog._serverAddressOk ? '' : qsTr('invalidServerAddress')
error: dialog._serverAddressOk ? '' : qsTr('invalidServerAddress')
onTextChanged: Logic.handleServerAddressChanged(text)
onTextChanged: Logic.handleServerAddressChanged(text)
}
}
}
}
}
FormLine {
FormGroup {
label: qsTr('registrationDurationLabel')
FormLine {
FormGroup {
label: qsTr('registrationDurationLabel')
NumericField {
id: registrationDuration
NumericField {
id: registrationDuration
}
}
}
}
}
FormLine {
FormGroup {
label: qsTr('transportLabel')
FormLine {
FormGroup {
label: qsTr('transportLabel')
ComboBox {
id: transport
ComboBox {
id: transport
enabled: dialog._serverAddressOk
model: [ 'UDP', 'TCP', 'TLS', 'DTLS' ]
enabled: dialog._serverAddressOk
model: [ 'UDP', 'TCP', 'TLS', 'DTLS' ]
onActivated: Logic.handleTransportChanged(model[index])
onActivated: Logic.handleTransportChanged(model[index])
}
}
}
}
}
FormLine {
FormGroup {
label: qsTr('routeLabel')
FormLine {
FormGroup {
label: qsTr('routeLabel')
TextField {
id: route
TextField {
id: route
error: dialog._routeOk ? '' : qsTr('invalidRoute')
error: dialog._routeOk ? '' : qsTr('invalidRoute')
onTextChanged: Logic.handleRouteChanged(text)
onTextChanged: Logic.handleRouteChanged(text)
}
}
}
}
}
FormLine {
FormGroup {
label: qsTr('contactParamsLabel')
FormLine {
FormGroup {
label: qsTr('contactParamsLabel')
TextField {
id: contactParams
TextField {
id: contactParams
}
}
}
}
}
FormLine {
FormGroup {
label: qsTr('avpfIntervalLabel')
FormLine {
FormGroup {
label: qsTr('avpfIntervalLabel')
NumericField {
id: avpfInterval
NumericField {
id: avpfInterval
maxValue: 5
minValue: 1
maxValue: 5
minValue: 1
}
}
}
}
}
FormLine {
FormGroup {
label: qsTr('registerEnabledLabel')
FormLine {
FormGroup {
label: qsTr('registerEnabledLabel')
Switch {
id: registerEnabled
Switch {
id: registerEnabled
onClicked: checked = !checked
onClicked: checked = !checked
}
}
}
}
}
FormLine {
FormGroup {
label: qsTr('publishPresenceLabel')
FormLine {
FormGroup {
label: qsTr('publishPresenceLabel')
Switch {
id: publishPresence
Switch {
id: publishPresence
onClicked: checked = !checked
onClicked: checked = !checked
}
}
}
FormLine {
FormGroup {
label: qsTr('avpfEnabledLabel')
Switch {
id: avpfEnabled
onClicked: checked = !checked
}
}
}
}
}
FormLine {
FormGroup {
label: qsTr('avpfEnabledLabel')
// -----------------------------------------------------------------------
// NAT and Firewall.
// -----------------------------------------------------------------------
Form {
title: qsTr('natAndFirewallTitle')
width: parent.width
FormLine {
FormGroup {
label: qsTr('enableIceLabel')
Switch {
id: iceEnabled
onClicked: checked = !checked
}
}
FormGroup {
label: qsTr('stunServerLabel')
TextField {
id: stunServer
readOnly: !iceEnabled.checked
}
}
}
FormLine {
FormGroup {
label: qsTr('enableTurnLabel')
Switch {
id: turnEnabled
enabled: iceEnabled.checked
onClicked: checked = !checked
}
}
FormGroup {
label: qsTr('turnUserLabel')
TextField {
id: turnUser
readOnly: !turnEnabled.checked || !turnEnabled.enabled
}
}
}
FormLine {
FormGroup {}
Switch {
id: avpfEnabled
FormGroup {
label: qsTr('turnPasswordLabel')
onClicked: checked = !checked
TextField {
id: turnPassword
readOnly: !turnEnabled.checked || !turnEnabled.enabled || !turnUser.text.length
}
}
}
}
}
......
......@@ -5,5 +5,5 @@ import QtQml 2.2
QtObject {
property int height: 550
property int width: 600
property int width: 934
}
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