Commit c245d7a8 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/Settings/SettingsNetwork): supports bandwith

parent 70071507
......@@ -42,56 +42,6 @@ SettingsModel::SettingsModel (QObject *parent) : QObject(parent) {
// Network.
// =============================================================================
// bool SettingsModel::getTcpPortEnabled () const {}
// void SettingsModel::setTcpPortEnabled (bool status) {
// emit tcpPortEnabledChanged(status);
// }
// -----------------------------------------------------------------------------
QList<int> SettingsModel::getAudioPortRange () const {
int a, b;
CoreManager::getInstance()->getCore()->getAudioPortRange(a, b);
return QList<int>() << a << b;
}
void SettingsModel::setAudioPortRange (const QList<int> &range) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
int a = range[0];
int b = range[1];
if (b == -1)
core->setAudioPort(a);
else
core->setAudioPortRange(a, b);
emit audioPortRangeChanged(a, b);
}
// -----------------------------------------------------------------------------
QList<int> SettingsModel::getVideoPortRange () const {
int a, b;
CoreManager::getInstance()->getCore()->getVideoPortRange(a, b);
return QList<int>() << a << b;
}
void SettingsModel::setVideoPortRange (const QList<int> &range) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
int a = range[0];
int b = range[1];
if (b == -1)
core->setVideoPort(a);
else
core->setVideoPortRange(a, b);
emit videoPortRangeChanged(a, b);
}
// -----------------------------------------------------------------------------
bool SettingsModel::getUseSipInfoForDtmfs () const {
return CoreManager::getInstance()->getCore()->getUseInfoForDtmf();
}
......@@ -143,6 +93,89 @@ void SettingsModel::setIpv6Enabled (bool status) {
// -----------------------------------------------------------------------------
int SettingsModel::getDownloadBandwidth () const {
return CoreManager::getInstance()->getCore()->getDownloadBandwidth();
}
void SettingsModel::setDownloadBandwidth (int bandwidth) {
CoreManager::getInstance()->getCore()->setDownloadBandwidth(bandwidth);
emit downloadBandWidthChanged(getDownloadBandwidth());
}
// -----------------------------------------------------------------------------
int SettingsModel::getUploadBandwidth () const {
return CoreManager::getInstance()->getCore()->getUploadBandwidth();
}
void SettingsModel::setUploadBandwidth (int bandwidth) {
CoreManager::getInstance()->getCore()->setUploadBandwidth(bandwidth);
emit uploadBandWidthChanged(getUploadBandwidth());
}
// -----------------------------------------------------------------------------
bool SettingsModel::getAdaptiveRateControlEnabled () const {
return CoreManager::getInstance()->getCore()->adaptiveRateControlEnabled();
}
void SettingsModel::setAdaptiveRateControlEnabled (bool status) {
CoreManager::getInstance()->getCore()->enableAdaptiveRateControl(status);
emit adaptiveRateControlEnabledChanged(status);
}
// -----------------------------------------------------------------------------
// bool SettingsModel::getTcpPortEnabled () const {}
// void SettingsModel::setTcpPortEnabled (bool status) {
// emit tcpPortEnabledChanged(status);
// }
// -----------------------------------------------------------------------------
QList<int> SettingsModel::getAudioPortRange () const {
int a, b;
CoreManager::getInstance()->getCore()->getAudioPortRange(a, b);
return QList<int>() << a << b;
}
void SettingsModel::setAudioPortRange (const QList<int> &range) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
int a = range[0];
int b = range[1];
if (b == -1)
core->setAudioPort(a);
else
core->setAudioPortRange(a, b);
emit audioPortRangeChanged(a, b);
}
// -----------------------------------------------------------------------------
QList<int> SettingsModel::getVideoPortRange () const {
int a, b;
CoreManager::getInstance()->getCore()->getVideoPortRange(a, b);
return QList<int>() << a << b;
}
void SettingsModel::setVideoPortRange (const QList<int> &range) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
int a = range[0];
int b = range[1];
if (b == -1)
core->setVideoPort(a);
else
core->setVideoPortRange(a, b);
emit videoPortRangeChanged(a, b);
}
// -----------------------------------------------------------------------------
bool SettingsModel::getIceEnabled () const {
return CoreManager::getInstance()->getCore()->getNatPolicy()->iceEnabled();
}
......
......@@ -31,16 +31,32 @@
class SettingsModel : public QObject {
Q_OBJECT;
// Q_PROPERTY(bool tcpPortEnabled READ getTcpPortEnabled WRITE setTcpPortEnabled NOTIFY tcpPortEnabledChanged);
// ===========================================================================
// PROPERTIES.
// ===========================================================================
Q_PROPERTY(QList<int> audioPortRange READ getAudioPortRange WRITE setAudioPortRange NOTIFY audioPortRangeChanged);
Q_PROPERTY(QList<int> videoPortRange READ getVideoPortRange WRITE setVideoPortRange NOTIFY videoPortRangeChanged);
// Network. ------------------------------------------------------------------
Q_PROPERTY(bool useSipInfoForDtmfs READ getUseSipInfoForDtmfs WRITE setUseSipInfoForDtmfs NOTIFY dtmfsProtocolChanged);
Q_PROPERTY(bool useRfc2833ForDtmfs READ getUseRfc2833ForDtmfs WRITE setUseRfc2833ForDtmfs NOTIFY dtmfsProtocolChanged);
Q_PROPERTY(bool ipv6Enabled READ getIpv6Enabled WRITE setIpv6Enabled NOTIFY ipv6EnabledChanged);
Q_PROPERTY(int downloadBandwidth READ getDownloadBandwidth WRITE setDownloadBandwidth NOTIFY downloadBandWidthChanged);
Q_PROPERTY(int uploadBandwidth READ getUploadBandwidth WRITE setUploadBandwidth NOTIFY uploadBandWidthChanged);
Q_PROPERTY(
bool adaptiveRateControlEnabled
READ getAdaptiveRateControlEnabled
WRITE setAdaptiveRateControlEnabled
NOTIFY adaptiveRateControlEnabledChanged
);
// Q_PROPERTY(bool tcpPortEnabled READ getTcpPortEnabled WRITE setTcpPortEnabled NOTIFY tcpPortEnabledChanged);
Q_PROPERTY(QList<int> audioPortRange READ getAudioPortRange WRITE setAudioPortRange NOTIFY audioPortRangeChanged);
Q_PROPERTY(QList<int> videoPortRange READ getVideoPortRange WRITE setVideoPortRange NOTIFY videoPortRangeChanged);
Q_PROPERTY(bool iceEnabled READ getIceEnabled WRITE setIceEnabled NOTIFY iceEnabledChanged);
Q_PROPERTY(bool turnEnabled READ getTurnEnabled WRITE setTurnEnabled NOTIFY turnEnabledChanged);
......@@ -53,6 +69,8 @@ class SettingsModel : public QObject {
Q_PROPERTY(int dscpAudio READ getDscpAudio WRITE setDscpAudio NOTIFY dscpAudioChanged);
Q_PROPERTY(int dscpVideo READ getDscpVideo WRITE setDscpVideo NOTIFY dscpVideoChanged);
// Misc. ---------------------------------------------------------------------
Q_PROPERTY(bool autoAnswerStatus READ getAutoAnswerStatus WRITE setAutoAnswerStatus NOTIFY autoAnswerStatusChanged);
Q_PROPERTY(QString fileTransferUrl READ getFileTransferUrl WRITE setFileTransferUrl NOTIFY fileTransferUrlChanged);
......@@ -62,16 +80,11 @@ class SettingsModel : public QObject {
public:
SettingsModel (QObject *parent = Q_NULLPTR);
// Network. ------------------------------------------------------------------
// bool getTcpPortEnabled () const;
// void setTcpPortEnabled (bool status);
QList<int> getAudioPortRange () const;
void setAudioPortRange (const QList<int> &range);
// ===========================================================================
// METHODS.
// ===========================================================================
QList<int> getVideoPortRange () const;
void setVideoPortRange (const QList<int> &range);
// Network. ------------------------------------------------------------------
bool getUseSipInfoForDtmfs () const;
void setUseSipInfoForDtmfs (bool status);
......@@ -82,6 +95,24 @@ public:
bool getIpv6Enabled () const;
void setIpv6Enabled (bool status);
int getDownloadBandwidth () const;
void setDownloadBandwidth (int bandwidth);
int getUploadBandwidth () const;
void setUploadBandwidth (int bandwidth);
bool getAdaptiveRateControlEnabled () const;
void setAdaptiveRateControlEnabled (bool status);
// bool getTcpPortEnabled () const;
// void setTcpPortEnabled (bool status);
QList<int> getAudioPortRange () const;
void setAudioPortRange (const QList<int> &range);
QList<int> getVideoPortRange () const;
void setVideoPortRange (const QList<int> &range);
bool getIceEnabled () const;
void setIceEnabled (bool status);
......@@ -124,16 +155,27 @@ public:
static const std::string UI_SECTION;
signals:
// void tcpPortEnabledChanged (bool status);
// ===========================================================================
// SIGNALS.
// ===========================================================================
void audioPortRangeChanged (int a, int b);
void videoPortRangeChanged (int a, int b);
signals:
// Network. ------------------------------------------------------------------
void dtmfsProtocolChanged ();
void ipv6EnabledChanged (bool status);
void downloadBandWidthChanged (int bandwidth);
void uploadBandWidthChanged (int bandwidth);
bool adaptiveRateControlEnabledChanged (bool status);
// void tcpPortEnabledChanged (bool status);
void audioPortRangeChanged (int a, int b);
void videoPortRangeChanged (int a, int b);
void iceEnabledChanged (bool status);
void turnEnabledChanged (bool status);
......@@ -146,6 +188,8 @@ signals:
void dscpAudioChanged (int dscp);
void dscpVideoChanged (int dscp);
// Misc. ---------------------------------------------------------------------
void autoAnswerStatusChanged (bool status);
void fileTransferUrlChanged (const QString &url);
......
......@@ -17,18 +17,26 @@ TextField {
function _decrease () {
var value = +numericField.text
if (value - step >= minValue) {
numericField.text = value - step
if (value === minValue) {
return
}
numericField.text = value - step >= minValue
? value - step
: minValue
numericField.editingFinished()
}
function _increase () {
var value = +numericField.text
if (value + step <= maxValue) {
numericField.text = value + step
if (value === maxValue) {
return
}
numericField.text = value + step <= maxValue
? value + step
: maxValue
numericField.editingFinished()
}
// ---------------------------------------------------------------------------
......
......@@ -12,6 +12,90 @@ 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
}
}
}
}
// -------------------------------------------------------------------------
// Bandwidth control.
// -------------------------------------------------------------------------
Form {
title: qsTr('bandwidthControlTitle')
width: parent.width
FormLine {
FormGroup {
label: qsTr('downloadSpeedLimitLabel')
NumericField {
minValue: 0
maxValue: 100000
step: 100
text: SettingsModel.downloadBandwidth
onEditingFinished: SettingsModel.downloadBandwidth = text
}
}
FormGroup {
label: qsTr('uploadSpeedLimitLabel')
NumericField {
minValue: 0
maxValue: 100000
step: 100
text: SettingsModel.uploadBandwidth
onEditingFinished: SettingsModel.uploadBandwidth = text
}
}
}
FormLine {
FormGroup {
label: qsTr('enableAdaptiveRateControlLabel')
Switch {
checked: SettingsModel.adaptiveRateControlEnabled
onClicked: SettingsModel.adaptiveRateControlEnabled = !checked
}
}
}
}
// -------------------------------------------------------------------------
// Network protocol and ports.
// -------------------------------------------------------------------------
......@@ -157,78 +241,6 @@ 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
}
}
}
}
// -------------------------------------------------------------------------
// Bandwidth control.
// -------------------------------------------------------------------------
Form {
title: qsTr('bandwidthControlTitle')
width: parent.width
FormLine {
FormGroup {
label: qsTr('downloadSpeedLimitLabel')
NumericField {
minValue: 0
maxValue: 100000
}
}
FormGroup {
label: qsTr('uploadSpeedLimitLabel')
NumericField {
minValue: 0
maxValue: 100000
}
}
}
FormLine {
FormGroup {
label: qsTr('enableAdaptiveRateControlLabel')
Switch {}
}
}
}
// -------------------------------------------------------------------------
// NAT and Firewall.
// -------------------------------------------------------------------------
......
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