Commit d18c57c5 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/Settings/SettingsNetwork): supports video port

parent 16ae7c20
......@@ -187,6 +187,7 @@
<file>ui/modules/Common/Form/ComboBox.qml</file>
<file>ui/modules/Common/Form/DroppableTextArea.qml</file>
<file>ui/modules/Common/Form/Fields/NumericField.qml</file>
<file>ui/modules/Common/Form/Fields/PortField.qml</file>
<file>ui/modules/Common/Form/Fields/TextAreaField.qml</file>
<file>ui/modules/Common/Form/Fields/TextField.qml</file>
<file>ui/modules/Common/Form/+linux/SearchBox.qml</file>
......@@ -301,6 +302,7 @@
<file>ui/modules/Linphone/Timeline.qml</file>
<file>ui/scripts/LinphoneUtils/linphone-utils.js</file>
<file>ui/scripts/LinphoneUtils/qmldir</file>
<file>ui/scripts/Utils/port-tools.js</file>
<file>ui/scripts/Utils/qmldir</file>
<file>ui/scripts/Utils/uri-tools.js</file>
<file>ui/scripts/Utils/utils.js</file>
......
......@@ -42,22 +42,23 @@ SettingsModel::SettingsModel (QObject *parent) : QObject(parent) {
// Network.
// =============================================================================
bool SettingsModel::getUseRfc2833ForDtmfs () const {
return CoreManager::getInstance()->getCore()->getUseRfc2833ForDtmf();
QList<int> SettingsModel::getVideoPortRange () const {
int a, b;
CoreManager::getInstance()->getCore()->getVideoPortRange(a, b);
return QList<int>() << a << b;
}
void SettingsModel::setUseRfc2833ForDtmfs (bool status) {
void SettingsModel::setVideoPortRange (const QList<int> &range) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
int a = range[0];
int b = range[1];
if (status) {
core->setUseInfoForDtmf(false);
core->setUseRfc2833ForDtmf(true);
} else {
core->setUseRfc2833ForDtmf(false);
core->setUseInfoForDtmf(true);
}
if (b == -1)
core->setVideoPort(a);
else
core->setVideoPortRange(a, b);
emit dtmfsProtocolChanged();
emit videoPortRangeChanged(a, b);
}
// -----------------------------------------------------------------------------
......@@ -82,6 +83,26 @@ void SettingsModel::setUseSipInfoForDtmfs (bool status) {
// -----------------------------------------------------------------------------
bool SettingsModel::getUseRfc2833ForDtmfs () const {
return CoreManager::getInstance()->getCore()->getUseRfc2833ForDtmf();
}
void SettingsModel::setUseRfc2833ForDtmfs (bool status) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
if (status) {
core->setUseInfoForDtmf(false);
core->setUseRfc2833ForDtmf(true);
} else {
core->setUseRfc2833ForDtmf(false);
core->setUseInfoForDtmf(true);
}
emit dtmfsProtocolChanged();
}
// -----------------------------------------------------------------------------
bool SettingsModel::getIpv6Enabled () const {
return CoreManager::getInstance()->getCore()->ipv6Enabled();
}
......
......@@ -31,6 +31,8 @@
class SettingsModel : public QObject {
Q_OBJECT;
Q_PROPERTY(QList<int> videoPortRange READ getVideoPortRange WRITE setVideoPortRange NOTIFY videoPortRangeChanged);
Q_PROPERTY(bool useSipInfoForDtmfs READ getUseSipInfoForDtmfs WRITE setUseSipInfoForDtmfs NOTIFY dtmfsProtocolChanged);
Q_PROPERTY(bool useRfc2833ForDtmfs READ getUseRfc2833ForDtmfs WRITE setUseRfc2833ForDtmfs NOTIFY dtmfsProtocolChanged);
......@@ -47,6 +49,9 @@ public:
// Network. ------------------------------------------------------------------
QList<int> getVideoPortRange () const;
void setVideoPortRange (const QList<int> &range);
bool getUseSipInfoForDtmfs () const;
void setUseSipInfoForDtmfs (bool status);
......@@ -75,6 +80,8 @@ public:
static const std::string UI_SECTION;
signals:
void videoPortRangeChanged (int a, int b);
void dtmfsProtocolChanged ();
void ipv6EnabledChanged (bool status);
......
import QtQuick 2.7
import Utils 1.0
// =============================================================================
Item {
id: wrapper
// ---------------------------------------------------------------------------
property string text
property bool supportsRange: false
// ---------------------------------------------------------------------------
signal editingFinished (int portA, int portB)
// ---------------------------------------------------------------------------
function _extractPorts (text) {
var portA = +text.split(':')[0]
var portB = (function () {
var port = text.split(':')[1]
return port && port.length > 0 ? +port : -1
})()
if (portB < 0 || portA === portB) {
return [ portA, -1 ]
}
if (portA < portB) {
return [ portA, portB ]
}
return [ portB, portA ]
}
function _computeText (range) {
return range[1] < 0
? range[0]
: range[0] + ':' + range[1]
}
// ---------------------------------------------------------------------------
implicitWidth: textField.width
implicitHeight: textField.height
onTextChanged: textField.text = _computeText(_extractPorts(text))
// ---------------------------------------------------------------------------
TextField {
id: textField
property bool locked: false
validator: RegExpValidator {
regExp: wrapper.supportsRange
? Utils.PORT_RANGE_REGEX
: Utils.PORT_REGEX
}
// Workaround to supports empty string.
Keys.onReturnPressed: editingFinished()
onActiveFocusChanged: !activeFocus && !text.length && editingFinished()
onEditingFinished: {
var range = _extractPorts(textField.text)
wrapper.text = textField.text = _computeText(range)
wrapper.editingFinished(range[0], range[1])
}
}
}
......@@ -34,6 +34,7 @@ TextButtonA 1.0 Form/Buttons/TextButtonA.qml
TextButtonB 1.0 Form/Buttons/TextButtonB.qml
NumericField 1.0 Form/Fields/NumericField.qml
PortField 1.0 Form/Fields/PortField.qml
TextAreaField 1.0 Form/Fields/TextAreaField.qml
TextField 1.0 Form/Fields/TextField.qml
......
// =============================================================================
// Library to deal with Ports.
// =============================================================================
.pragma library
// -----------------------------------------------------------------------------
var PORT = '([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])'
var PORT_RANGE = PORT + '(?::' + PORT + ')?'
// -----------------------------------------------------------------------------
var PORT_REGEX = new RegExp('^' + PORT + '$')
var PORT_RANGE_REGEX = new RegExp('^' + PORT_RANGE + '$')
......@@ -6,8 +6,16 @@
.import QtQuick 2.0 as QtQuick
.import 'port-tools.js' as PortTools
.import 'uri-tools.js' as UriTools
// =============================================================================
// Constants.
// =============================================================================
var PORT_REGEX = PortTools.PORT_REGEX
var PORT_RANGE_REGEX = PortTools.PORT_RANGE_REGEX
// =============================================================================
// QML helpers.
// =============================================================================
......
......@@ -12,41 +12,6 @@ TabContainer {
spacing: SettingsWindowStyle.forms.spacing
width: parent.width
// -------------------------------------------------------------------------
// Transport.
// -------------------------------------------------------------------------
Form {
title: qsTr('transportTitle')
width: parent.width
FormLine {
FormGroup {
label: qsTr('sendDtmfsLabel')
ExclusiveButtons {
selectedButton: Number(!SettingsModel.useSipInfoForDtmfs)
texts: [
'SIP INFO',
'RFC 2833'
]
onClicked: SettingsModel.useSipInfoForDtmfs = !button
}
}
FormGroup {
label: qsTr('allowIpV6Label')
Switch {
checked: SettingsModel.ipv6Enabled
onClicked: SettingsModel.ipv6Enabled = !checked
}
}
}
}
// -------------------------------------------------------------------------
// Network protocol and ports.
// -------------------------------------------------------------------------
......@@ -73,10 +38,12 @@ TabContainer {
FormGroup {
label: qsTr('sipUdpPortLabel')
NumericField {
minValue: 0
maxValue: 65535
readOnly: randomSipUdpPort.checked || !enableSipUdpPort.checked
PortField {
//readOnly: randomSipUdpPort.checked || !enableSipUdpPort.checked
supportsRange: true
text: SettingsModel.videoPortRange.join(':')
onEditingFinished: SettingsModel.videoPortRange = [ portA, portB ]
}
}
......@@ -184,6 +151,41 @@ TabContainer {
}
}
// -------------------------------------------------------------------------
// Transport.
// -------------------------------------------------------------------------
Form {
title: qsTr('transportTitle')
width: parent.width
FormLine {
FormGroup {
label: qsTr('sendDtmfsLabel')
ExclusiveButtons {
selectedButton: Number(!SettingsModel.useSipInfoForDtmfs)
texts: [
'SIP INFO',
'RFC 2833'
]
onClicked: SettingsModel.useSipInfoForDtmfs = !button
}
}
FormGroup {
label: qsTr('allowIpV6Label')
Switch {
checked: SettingsModel.ipv6Enabled
onClicked: SettingsModel.ipv6Enabled = !checked
}
}
}
}
// -------------------------------------------------------------------------
// DSCP fields.
// -------------------------------------------------------------------------
......
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