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> ...@@ -1386,6 +1386,34 @@ your friend&apos;s SIP address or username.</translation>
<source>invalidRoute</source> <source>invalidRoute</source>
<translation>Invalid route.</translation> <translation>Invalid route.</translation>
</message> </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>
<context> <context>
<name>SettingsUi</name> <name>SettingsUi</name>
......
...@@ -1384,6 +1384,34 @@ Cliquez ici : &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt; ...@@ -1384,6 +1384,34 @@ Cliquez ici : &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<source>invalidRoute</source> <source>invalidRoute</source>
<translation>Route invalide.</translation> <translation>Route invalide.</translation>
</message> </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>
<context> <context>
<name>SettingsUi</name> <name>SettingsUi</name>
......
...@@ -1384,6 +1384,34 @@ ...@@ -1384,6 +1384,34 @@
<source>invalidRoute</source> <source>invalidRoute</source>
<translation>Неверный маршрут.</translation> <translation>Неверный маршрут.</translation>
</message> </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>
<context> <context>
<name>SettingsUi</name> <name>SettingsUi</name>
......
...@@ -1386,6 +1386,34 @@ arkadaşınızın SIP adresini veya kullanıcı adını girin.</translation> ...@@ -1386,6 +1386,34 @@ arkadaşınızın SIP adresini veya kullanıcı adını girin.</translation>
<source>invalidRoute</source> <source>invalidRoute</source>
<translation>Geçersiz rota.</translation> <translation>Geçersiz rota.</translation>
</message> </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>
<context> <context>
<name>SettingsUi</name> <name>SettingsUi</name>
......
...@@ -96,7 +96,6 @@ QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<li ...@@ -96,7 +96,6 @@ QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<li
? ::Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString()) ? ::Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString())
: QString(""); : QString("");
} }
map["serverAddress"] = ::Utils::coreStringToAppString(proxyConfig->getServerAddr()); map["serverAddress"] = ::Utils::coreStringToAppString(proxyConfig->getServerAddr());
map["registrationDuration"] = proxyConfig->getPublishExpires(); map["registrationDuration"] = proxyConfig->getPublishExpires();
map["transport"] = ::Utils::coreStringToAppString(proxyConfig->getTransport()); map["transport"] = ::Utils::coreStringToAppString(proxyConfig->getTransport());
...@@ -108,6 +107,14 @@ QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<li ...@@ -108,6 +107,14 @@ QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<li
map["avpfEnabled"] = proxyConfig->getAvpfMode() == linphone::AVPFMode::AVPFModeEnabled; map["avpfEnabled"] = proxyConfig->getAvpfMode() == linphone::AVPFMode::AVPFModeEnabled;
map["registrationState"] = ::mapLinphoneRegistrationStateToUi(proxyConfig->getState()); 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; return map;
} }
...@@ -172,6 +179,33 @@ bool AccountSettingsModel::addOrUpdateProxyConfig ( ...@@ -172,6 +179,33 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
: linphone::AVPFMode::AVPFModeDefault : 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); return addOrUpdateProxyConfig(proxyConfig);
} }
......
...@@ -36,6 +36,11 @@ function initForm (account) { ...@@ -36,6 +36,11 @@ function initForm (account) {
registerEnabled.checked = config.registerEnabled registerEnabled.checked = config.registerEnabled
publishPresence.checked = config.publishPresence publishPresence.checked = config.publishPresence
avpfEnabled.checked = config.avpfEnabled 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) { if (account) {
dialog._sipAddressOk = true dialog._sipAddressOk = true
...@@ -62,7 +67,12 @@ function validProxyConfig () { ...@@ -62,7 +67,12 @@ function validProxyConfig () {
avpfInterval: avpfInterval.text, avpfInterval: avpfInterval.text,
registerEnabled: registerEnabled.checked, registerEnabled: registerEnabled.checked,
publishPresence: publishPresence.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) dialog.exit(1)
} else { } else {
...@@ -108,3 +118,5 @@ function handleTransportChanged (transport) { ...@@ -108,3 +118,5 @@ function handleTransportChanged (transport) {
dialog._serverAddressOk = false dialog._serverAddressOk = false
} }
} }
// -----------------------------------------------------------------------------
...@@ -42,131 +42,206 @@ DialogPlus { ...@@ -42,131 +42,206 @@ DialogPlus {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
Form { TabContainer {
anchors.fill: parent Column {
width: parent.width
FormLine { Form {
FormGroup { title: qsTr('mainSipAccountSettingsTitle')
label: qsTr('sipAddressLabel') + '*' width: parent.width
TextField { FormLine {
id: sipAddress 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 { FormLine {
FormGroup { FormGroup {
label: qsTr('serverAddressLabel') + '*' label: qsTr('serverAddressLabel') + '*'
TextField { TextField {
id: serverAddress id: serverAddress
error: dialog._serverAddressOk ? '' : qsTr('invalidServerAddress') error: dialog._serverAddressOk ? '' : qsTr('invalidServerAddress')
onTextChanged: Logic.handleServerAddressChanged(text) onTextChanged: Logic.handleServerAddressChanged(text)
}
}
} }
}
}
FormLine { FormLine {
FormGroup { FormGroup {
label: qsTr('registrationDurationLabel') label: qsTr('registrationDurationLabel')
NumericField { NumericField {
id: registrationDuration id: registrationDuration
}
}
} }
}
}
FormLine { FormLine {
FormGroup { FormGroup {
label: qsTr('transportLabel') label: qsTr('transportLabel')
ComboBox { ComboBox {
id: transport id: transport
enabled: dialog._serverAddressOk enabled: dialog._serverAddressOk
model: [ 'UDP', 'TCP', 'TLS', 'DTLS' ] model: [ 'UDP', 'TCP', 'TLS', 'DTLS' ]
onActivated: Logic.handleTransportChanged(model[index]) onActivated: Logic.handleTransportChanged(model[index])
}
}
} }
}
}
FormLine { FormLine {
FormGroup { FormGroup {
label: qsTr('routeLabel') label: qsTr('routeLabel')
TextField { TextField {
id: route id: route
error: dialog._routeOk ? '' : qsTr('invalidRoute') error: dialog._routeOk ? '' : qsTr('invalidRoute')
onTextChanged: Logic.handleRouteChanged(text) onTextChanged: Logic.handleRouteChanged(text)
}
}
} }
}
}
FormLine { FormLine {
FormGroup { FormGroup {
label: qsTr('contactParamsLabel') label: qsTr('contactParamsLabel')
TextField { TextField {
id: contactParams id: contactParams
}
}
} }
}
}
FormLine { FormLine {
FormGroup { FormGroup {
label: qsTr('avpfIntervalLabel') label: qsTr('avpfIntervalLabel')
NumericField { NumericField {
id: avpfInterval id: avpfInterval
maxValue: 5 maxValue: 5
minValue: 1 minValue: 1
}
}
} }
}
}
FormLine { FormLine {
FormGroup { FormGroup {
label: qsTr('registerEnabledLabel') label: qsTr('registerEnabledLabel')
Switch { Switch {
id: registerEnabled id: registerEnabled
onClicked: checked = !checked onClicked: checked = !checked
}
}
} }
}
}
FormLine { FormLine {
FormGroup { FormGroup {
label: qsTr('publishPresenceLabel') label: qsTr('publishPresenceLabel')
Switch { Switch {
id: publishPresence id: publishPresence
onClicked: checked = !checked onClicked: checked = !checked
}
}
}
FormLine {
FormGroup {
label: qsTr('avpfEnabledLabel')
Switch {
id: avpfEnabled
onClicked: checked = !checked
}
}
} }
} }
}
FormLine { // -----------------------------------------------------------------------
FormGroup { // NAT and Firewall.
label: qsTr('avpfEnabledLabel') // -----------------------------------------------------------------------
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 { FormGroup {
id: avpfEnabled 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 ...@@ -5,5 +5,5 @@ import QtQml 2.2
QtObject { QtObject {
property int height: 550 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