From 3e8998a7d712275891905f9e75a8cd150de86877 Mon Sep 17 00:00:00 2001 From: Teemu Holappa Date: Thu, 28 Jan 2016 10:22:43 +0200 Subject: Wifi support to the Network Settings Plugin. All the network management is done now through the Connman backend. Removed separate wifi settings plugin. Change-Id: I7b6b7231f1c44727ce0591e11182d25bc43718ed Reviewed-by: Risto Avila --- .../bluetoothsettingsplugin.pro | 1 + src/qtdevicesettings/devicesettings.pro | 1 - .../networksettingsplugin/icons.qrc | 2 + .../imports/NetworkSettings/EditWiredSettings.qml | 35 +- .../imports/NetworkSettings/NetworkDetails.qml | 2 +- .../imports/NetworkSettings/NetworkSettings.qml | 12 +- .../NetworkSettings/WifiSelectorDelegate.qml | 90 ++++ .../imports/NetworkSettings/WifiSettings.qml | 158 ++++-- .../imports/NetworkSettings/WifiSignalMonitor.qml | 83 +++ .../imports/NetworkSettings/WiredSettings.qml | 26 +- .../networksettings/connman/connmancommon.cpp | 97 ++++ .../networksettings/connman/connmancommon.h | 77 +++ .../connman/networksettingsmanager_linux.cpp | 583 --------------------- .../connman/networksettingsmanager_linux_p.h | 148 ------ .../connman/qnetworksettingsinterface_p.cpp | 105 ++++ .../connman/qnetworksettingsinterface_p.h | 92 ++++ .../connman/qnetworksettingsmanager_p.cpp | 163 ++++++ .../connman/qnetworksettingsmanager_p.h | 70 +++ .../connman/qnetworksettingsservice_p.cpp | 405 ++++++++++++++ .../connman/qnetworksettingsservice_p.h | 84 +++ .../connman/qnetworksettingsuseragent_p.cpp | 99 ++++ .../connman/qnetworksettingsuseragent_p.h | 75 +++ .../networksettings/networkaddressmodel.cpp | 83 --- .../networksettings/networkaddressmodel.h | 60 --- .../networksettings/networkconfig.h | 394 -------------- .../networksettings/networksettings.pri | 42 +- .../networksettings/networksettingsmanager.cpp | 167 ------ .../networksettings/networksettingsmanager.h | 127 ----- .../networksettings/networksmodel.cpp | 111 ---- .../networksettings/networksmodel.h | 131 ----- .../networksettings/qnetworksettings.h | 399 ++++++++++++++ .../qnetworksettingsaddressmodel.cpp | 83 +++ .../networksettings/qnetworksettingsaddressmodel.h | 60 +++ .../networksettings/qnetworksettingsinterface.cpp | 81 +++ .../networksettings/qnetworksettingsinterface.h | 75 +++ .../qnetworksettingsinterfacemodel.cpp | 112 ++++ .../qnetworksettingsinterfacemodel.h | 71 +++ .../networksettings/qnetworksettingsmanager.cpp | 71 +++ .../networksettings/qnetworksettingsmanager.h | 72 +++ .../networksettings/qnetworksettingsservice.cpp | 147 ++++++ .../networksettings/qnetworksettingsservice.h | 99 ++++ .../qnetworksettingsservicemodel.cpp | 164 ++++++ .../networksettings/qnetworksettingsservicemodel.h | 88 ++++ .../networksettings/qnetworksettingsuseragent.cpp | 55 ++ .../networksettings/qnetworksettingsuseragent.h | 59 +++ .../networksettingsplugin.pro | 7 +- .../networksettingsplugin_plugin.cpp | 23 +- .../imports/Settings/CustomCombobox.qml | 5 +- .../Settings/FlatStyledDropdownDelegate.qml | 2 +- .../imports/Settings/TextLabel.qml | 1 + src/qtdevicesettings/timedateplugin/plugin.cpp | 1 - .../wifisettingsplugin/WifiManagerView.qml | 180 ------- .../wifisettingsplugin/WifiSelectorDelegate.qml | 87 --- .../wifisettingsplugin/WifiSignalMonitor.qml | 83 --- src/qtdevicesettings/wifisettingsplugin/icons.qrc | 7 - src/qtdevicesettings/wifisettingsplugin/plugin.cpp | 58 -- src/qtdevicesettings/wifisettingsplugin/qml.qrc | 7 - src/qtdevicesettings/wifisettingsplugin/qmldir | 2 - .../wifisettingsplugin/wifisettingsplugin.pro | 26 - 59 files changed, 3296 insertions(+), 2352 deletions(-) create mode 100644 src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSelectorDelegate.qml create mode 100644 src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSignalMonitor.qml create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/connman/connmancommon.cpp create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/connman/connmancommon.h delete mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/connman/networksettingsmanager_linux.cpp delete mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/connman/networksettingsmanager_linux_p.h create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsinterface_p.cpp create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsinterface_p.h create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsmanager_p.cpp create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsmanager_p.h create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsservice_p.cpp create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsservice_p.h create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsuseragent_p.cpp create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsuseragent_p.h delete mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/networkaddressmodel.cpp delete mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/networkaddressmodel.h delete mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/networkconfig.h delete mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/networksettingsmanager.cpp delete mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/networksettingsmanager.h delete mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/networksmodel.cpp delete mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/networksmodel.h create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettings.h create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsaddressmodel.cpp create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsaddressmodel.h create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsinterface.cpp create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsinterface.h create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsinterfacemodel.cpp create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsinterfacemodel.h create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsmanager.cpp create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsmanager.h create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsservice.cpp create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsservice.h create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsservicemodel.cpp create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsservicemodel.h create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsuseragent.cpp create mode 100644 src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsuseragent.h delete mode 100644 src/qtdevicesettings/wifisettingsplugin/WifiManagerView.qml delete mode 100644 src/qtdevicesettings/wifisettingsplugin/WifiSelectorDelegate.qml delete mode 100644 src/qtdevicesettings/wifisettingsplugin/WifiSignalMonitor.qml delete mode 100644 src/qtdevicesettings/wifisettingsplugin/icons.qrc delete mode 100644 src/qtdevicesettings/wifisettingsplugin/plugin.cpp delete mode 100644 src/qtdevicesettings/wifisettingsplugin/qml.qrc delete mode 100644 src/qtdevicesettings/wifisettingsplugin/qmldir delete mode 100644 src/qtdevicesettings/wifisettingsplugin/wifisettingsplugin.pro (limited to 'src/qtdevicesettings') diff --git a/src/qtdevicesettings/bluetoothsettingsplugin/bluetoothsettingsplugin.pro b/src/qtdevicesettings/bluetoothsettingsplugin/bluetoothsettingsplugin.pro index 5ca0add..1ffc6c5 100644 --- a/src/qtdevicesettings/bluetoothsettingsplugin/bluetoothsettingsplugin.pro +++ b/src/qtdevicesettings/bluetoothsettingsplugin/bluetoothsettingsplugin.pro @@ -19,6 +19,7 @@ SOURCES += plugin.cpp \ pluginfiles.files += \ qmldir \ + installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) target.path = $$installPath diff --git a/src/qtdevicesettings/devicesettings.pro b/src/qtdevicesettings/devicesettings.pro index 54758aa..c49e6fb 100644 --- a/src/qtdevicesettings/devicesettings.pro +++ b/src/qtdevicesettings/devicesettings.pro @@ -5,7 +5,6 @@ SUBDIRS += \ generalsettingsplugin \ timedateplugin \ settingsui \ - wifisettingsplugin \ localesettingsplugin \ bluetoothsettingsplugin \ diff --git a/src/qtdevicesettings/networksettingsplugin/icons.qrc b/src/qtdevicesettings/networksettingsplugin/icons.qrc index af8a564..4b07cca 100644 --- a/src/qtdevicesettings/networksettingsplugin/icons.qrc +++ b/src/qtdevicesettings/networksettingsplugin/icons.qrc @@ -1,4 +1,6 @@ + ../icons/Wifi_lightgray_2x.png + ../icons/WifiAnim_black_2x.png diff --git a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/EditWiredSettings.qml b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/EditWiredSettings.qml index a09bdf8..c678c67 100644 --- a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/EditWiredSettings.qml +++ b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/EditWiredSettings.qml @@ -90,15 +90,15 @@ Item { ListElement { text: "DHCP" - method: IPv4Config.Dhcp + method: NetworkSettingsIPv4.Dhcp } ListElement { text: "Manual" - method: IPv4Config.Manual + method: NetworkSettingsIPv4.Manual } ListElement { text: "Off" - method: IPv4Config.Off + method: NetworkSettingsIPv4.Off } } @@ -125,7 +125,7 @@ Item { Column { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - visible: service.ipv4.method === IPv4Config.Dhcp + visible: service.ipv4.method === NetworkSettingsIPv4.Dhcp Row { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) @@ -166,7 +166,7 @@ Item { Column { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - visible: service.ipv4.method === IPv4Config.Manual + visible: service.ipv4.method === NetworkSettingsIPv4.Manual Row { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) @@ -234,15 +234,15 @@ Item { ListElement { text: qsTr("Auto") - method: IPv6Config.Auto + method: NetworkSettingsIPv6.Auto } ListElement { text: qsTr("Manual") - method: IPv6Config.Manual + method: NetworkSettingsIPv6.Manual } ListElement { text: qsTr("Off") - method: IPv6Config.Off + method: NetworkSettingsIPv6.Off } } @@ -268,7 +268,7 @@ Item { Column { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - visible: service.ipv6.method === IPv6Config.Auto + visible: service.ipv6.method === NetworkSettingsIPv6.Auto Row { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) TextLabel { @@ -308,7 +308,7 @@ Item { Column { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - visible: service.ipv6.method === IPv6Config.Manual + visible: service.ipv6.method === NetworkSettingsIPv6.Manual Row { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) TextLabel { @@ -497,15 +497,15 @@ Item { ListElement { text: qsTr("Direct") - method: ProxyConfig.Direct + method: NetworkSettingsProxy.Direct } ListElement { text: qsTr("Auto") - method: ProxyConfig.Auto + method: NetworkSettingsProxy.Auto } ListElement { text: qsTr("Manual") - method: ProxyConfig.Manual + method: NetworkSettingsProxy.Manual } } @@ -531,9 +531,10 @@ Item { Row { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - visible: service.proxy.method !== ProxyConfig.Direct + visible: service.proxy.method !== NetworkSettingsProxy.Direct TextLabel { - text: service.proxy.method === ProxyConfig.Manual ? qsTr("Proxy address") : qsTr("Automatic configuration URL") + text: service.proxy.method === NetworkSettingsProxy.Manual ? qsTr("Proxy address") : qsTr("Automatic configuration URL") + width: content.titleWidth horizontalAlignment: Text.AlignRight } @@ -546,7 +547,7 @@ Item { } Row { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - visible: service.proxy.method === ProxyConfig.Manual + visible: service.proxy.method === NetworkSettingsProxy.Manual TextLabel { text: qsTr("No proxy for") @@ -632,7 +633,7 @@ Item { } if (proxyChanged) { proxyUrl.accepted(); - service.setupProxyConfig(); + service.setupNetworkSettingsProxy(); } stackView.pop(); } diff --git a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/NetworkDetails.qml b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/NetworkDetails.qml index 1540e03..3e71be0 100644 --- a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/NetworkDetails.qml +++ b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/NetworkDetails.qml @@ -37,6 +37,6 @@ import QtQuick 2.5 Loader { id: root - property var service: undefined + property var selectedInterface:undefined anchors.fill: parent } diff --git a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/NetworkSettings.qml b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/NetworkSettings.qml index daf3d1d..dcda5e0 100644 --- a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/NetworkSettings.qml +++ b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/NetworkSettings.qml @@ -78,7 +78,7 @@ Item { } Repeater { - model: NetworkSettingsManager.networks + model: NetworkSettingsManager.interfaces Button { implicitWidth: networkSelect.width - Math.round(20 * Flat.FlatStyle.scaleFactor) @@ -105,19 +105,21 @@ Item { } TextLabel { - text: networkSelect.stateToStr(status) + text: networkSelect.stateToStr(modelData.state) font.pixelSize: Math.round(12 * Flat.FlatStyle.scaleFactor) } + } } onCheckedChanged: { if (checked) { - networkDetails.service = NetworkSettingsManager.getService(name, type); - if (type === NetworkType.Wired) { + networkDetails.selectedInterface = modelData + networkDetails.selectedInterface.scanServices() + if (type === NetworkSettingsType.Wired) { networkDetails.source = "WiredSettings.qml"; } - else if (type === NetworkType.Wifi) { + else if (type === NetworkSettingsType.Wifi) { networkDetails.source = "WifiSettings.qml"; } } diff --git a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSelectorDelegate.qml b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSelectorDelegate.qml new file mode 100644 index 0000000..bc39ebd --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSelectorDelegate.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.5 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 1.4 +import com.theqtcompany.settings.common 1.0 +import com.theqtcompany.settings.network 1.0 +import QtQuick.Controls.Styles.Flat 1.0 as Flat + +Item { + id: root + property bool checkable: true + property bool checked: false + property bool pressed: false + property bool connect: modelData["connected"] + signal clicked() + + MouseArea { + id: delegateButton + anchors.fill: parent + hoverEnabled: true + onPressed: root.pressed = true + onClicked: root.clicked() + onEntered: checked = !checked + + Rectangle { + anchors.fill: parent + color: root.checked ? Flat.FlatStyle.disabledColor : "transparent" + opacity: root.checked ? 0.15 : 1.0 + } + Rectangle { + color: Flat.FlatStyle.darkFrameColor + width: parent.width + height: Flat.FlatStyle.onePixel + anchors.bottom: parent.bottom + } + TextLabel { + id: text + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.margins: Math.round(10 * Flat.FlatStyle.scaleFactor) + horizontalAlignment: Text.AlignLeft + text: modelData["name"] + } + WifiSignalMonitor { + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.margins: Math.round(10 * Flat.FlatStyle.scaleFactor) + height: Math.round(parent.height * .8) + width: height + signalStrength: modelData["signalStrength"] + connected: modelData["connected"] + } + } +} diff --git a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSettings.qml b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSettings.qml index 3221e88..e7c2bda 100644 --- a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSettings.qml +++ b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSettings.qml @@ -39,56 +39,152 @@ import QtQuick.Controls 1.4 import QtQuick.Controls.Styles.Flat 1.0 as Flat import com.theqtcompany.settings.common 1.0 import com.theqtcompany.settings.network 1.0 -import com.theqtcompany.settings.wifi 1.0 Item { id: root anchors.fill: parent anchors.margins: Math.round(20 * Flat.FlatStyle.scaleFactor) + + Component.onCompleted: { + NetworkSettingsManager.services.type = NetworkSettingsType.Wifi; + } GroupBox { id: content title: qsTr("Wireless Settings") anchors.fill: parent Layout.fillWidth: true flat: true - width: parent.width - Row { - id: enableSwitch + ColumnLayout { + spacing: Math.round(20 * Flat.FlatStyle.scaleFactor) width: parent.width - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - TextLabel { - width: root.width*0.382 - horizontalAlignment: Text.AlignRight - text: NetworkSettingsManager.wifiPowered ? qsTr("Disable Wifi") : qsTr("Enable Wifi") + Row { + id: enableSwitch + width: parent.width + spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) + TextLabel { + width: root.width*0.382 + horizontalAlignment: Text.AlignRight + text: selectedInterface.powered ? qsTr("Disable Wifi") : qsTr("Enable Wifi") + } + Switch { + checked: selectedInterface.powered + onCheckedChanged: selectedInterface.powered = checked + } } - Switch { - checked: NetworkSettingsManager.wifiPowered - onCheckedChanged: NetworkSettingsManager.wifiPowered = checked + + Row { + spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) + width: parent.width + + TextLabel { + id: labelText + text: qsTr("Selected network ") + width: content.width*0.382 + horizontalAlignment: Text.AlignRight + } + + CustomCombobox { + id: networkSelection + model: NetworkSettingsManager.services + visible: selectedInterface.powered + width: Math.round(200 * Flat.FlatStyle.scaleFactor) + textRole: "name" + onSelectedIndexChanged : if (selectedIndex >= 0) model.itemFromRow(selectedIndex).connectService(); + + delegate: WifiSelectorDelegate { + id: delegate + onConnectChanged: if (connect) networkSelection.setSelectIndexToVal(modelData.name, "name"); + } + } } - } - Item { - id: wifiManagerContainer - anchors.left: parent.left - anchors.right: parent.right - anchors.top: enableSwitch.bottom - anchors.topMargin: Math.round(10 * Flat.FlatStyle.scaleFactor) - anchors.bottom: parent.bottom - Loader { - id: wifiManagerLoader - asynchronous: true - sourceComponent: NetworkSettingsManager.wifiPowered ? wifiManager : undefined + GroupBox { + id: connectView + title: qsTr("Enter a password") + flat: false + visible: false + ColumnLayout { + Row { + id: errorView + property alias text: text.text + visible: text.text !== "" + + spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) + Image { + source: "../icons/Alert_yellow_1x.png" + } + Text { + id: text + color: "#face20" + text: "" + } + } + Row { + spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) + visible: false + TextLabel { + text: qsTr("User name") + width: root.width*0.382 + horizontalAlignment: Text.AlignRight + } + TextField { + text: "" + inputMethodHints: Qt.ImhNoPredictiveText + } + } + Row { + spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) + TextLabel { + text: qsTr("Password") + horizontalAlignment: Text.AlignRight + } + TextField { + id: password + text: "" + echoMode: TextInput.Password + inputMethodHints: Qt.ImhNoPredictiveText + } + } + Row { + spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) + Button { + text: qsTr("Connect") + onClicked: { + connectView.visible = false + NetworkSettingsUserAgent.setUserCredentials("", password.text) + } + } + Button { + text: qsTr("Cancel") + onClicked:connectView.visible = false + } + } + } + } + + Button { + id: disconnect + text: qsTr("Disconnect") + visible: selectedInterface.state === NetworkSettingsState.Online || + selectedInterface.state === NetworkSettingsState.Ready + onClicked: { + console.log("disconnect"); + NetworkSettingsManager.services.itemFromRow(networkSelection.selectedIndex).disconnectService(); + networkSelection.selectedIndex = -1; + } } } - } - Component { - id: wifiManager - WifiManagerView { - id: wifiSettings - width: root.width - visible: true + Connections { + target: NetworkSettingsUserAgent + onShowUserCredentialsInput : { + connectView.visible = true + } + onError: { + errorView.visible = true + connectView.visible = true + } } } } diff --git a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSignalMonitor.qml b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSignalMonitor.qml new file mode 100644 index 0000000..35d9e53 --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSignalMonitor.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.5 + +Item { + id: root + + property bool scanning: false + property int signalStrength: 100 + property bool connected: false + + onSignalStrengthChanged: { + sprite.visible = true; + + if (signalStrength < 10) { + sprite.visible = false; + } + else if (signalStrength < 30) { + sprite.currentFrame = 0; + } + else if (signalStrength < 60) { + sprite.currentFrame = 1; + } + else if (signalStrength < 80) { + sprite.currentFrame = 2; + } + else if (signalStrength <= 100) { + sprite.currentFrame = 3; + } + } + + Image { + anchors.fill: parent + source: "Wifi_lightgray_2x.png" + } + + AnimatedSprite { + id: sprite + anchors.fill: parent + source: connected ? "WifiAnim_qt_2x.png" : "WifiAnim_black_2x.png" + frameDuration: 500 + frameCount: 4 + currentFrame: 3 + frameSync: false + frameWidth: 32 + frameHeight: 32 + loops: 40 + running: scanning + } +} diff --git a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WiredSettings.qml b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WiredSettings.qml index 5a7e860..4c07baa 100644 --- a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WiredSettings.qml +++ b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WiredSettings.qml @@ -45,10 +45,12 @@ Item { anchors.fill: parent anchors.margins: Math.round(20 * Flat.FlatStyle.scaleFactor) property bool editMode: false + property var service: null + property string title: qsTr("Network"); - onVisibleChanged: { - if (visible) - titlebar.title = qsTr("Network"); + Component.onCompleted: { + NetworkSettingsManager.services.type = NetworkSettingsType.Wired; + root.service = NetworkSettingsManager.services.itemFromRow(0); } ListModel { @@ -56,15 +58,15 @@ Item { ListElement { text: "DHCP" - method: IPv4Config.Dhcp + method: NetworkSettingsIPv4.Dhcp } ListElement { text: "Manual" - method: IPv4Config.Manual + method: NetworkSettingsIPv4.Manual } ListElement { text: "Off" - method: IPv4Config.Off + method: NetworkSettingsIPv4.Off } } @@ -85,7 +87,7 @@ Item { model: methodsModel Component.onCompleted: selectedIndex = service.ipv4.method onSelectedIndexChanged : { - if (model.get(selectedIndex).method !== IPv4Config.Dhcp) { + if (model.get(selectedIndex).method !== NetworkSettingsIPv4.Dhcp) { service.ipv4.method = model.get(selectedIndex).method; editMode = true; } @@ -104,7 +106,7 @@ Item { } Row { - visible: service.ipv4.method !== IPv4Config.Off + visible: service.ipv4.method !== NetworkSettingsIPv4.Off TextLabel { text: qsTr("IP Address: ") } @@ -121,7 +123,7 @@ Item { } Row { - visible: service.ipv4.method !== IPv4Config.Off + visible: service.ipv4.method !== NetworkSettingsIPv4.Off TextLabel { text: qsTr("Mask: ") } @@ -138,7 +140,7 @@ Item { } Row { - visible: service.ipv4.method !== IPv4Config.Off + visible: service.ipv4.method !== NetworkSettingsIPv4.Off TextLabel { text: qsTr("Router: ") } @@ -155,7 +157,7 @@ Item { } Row { - visible: service.ipv4.method !== IPv4Config.Off + visible: service.ipv4.method !== NetworkSettingsIPv4.Off TextLabel { text: qsTr("DNS server: ") } @@ -197,7 +199,7 @@ Item { text: qsTr("Edit") visible: !editMode - onClicked: stackView.push( { item : Qt.resolvedUrl("EditWiredSettings.qml"), properties : { service: service } } ) + onClicked: stackView.push({item: Qt.resolvedUrl("EditWiredSettings.qml"), properties: {service: root.service}}); } } } diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/connman/connmancommon.cpp b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/connmancommon.cpp new file mode 100644 index 0000000..94a1fa1 --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/connmancommon.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "connmancommon.h" + +//Conversion operations for datatypes +const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMap &obj) +{ + argument.beginStructure(); + argument >> obj.objectPath >> obj.propertyMap; + argument.endStructure(); + return argument; +} + +QDBusArgument &operator<<(QDBusArgument &argument, const ConnmanMap &obj) +{ + argument.beginStructure(); + argument << obj.objectPath << obj.propertyMap; + argument.endStructure(); + return argument; +} + +const QString &operator>>(const QString &argument, QNetworkSettingsType &obj) +{ + if (argument == AttributeEthernet) { + obj.setType(QNetworkSettingsType::Wired); + } + else if (argument == AttributeWifi) { + obj.setType(QNetworkSettingsType::Wifi); + } + else { + obj.setType(QNetworkSettingsType::Unknown); + } + + return argument; +} + +const QString &operator>>(const QString &argument, QNetworkSettingsState &obj) +{ + if (argument == AttributeIdle) { + obj.setState(QNetworkSettingsState::Idle); + } + else if (argument == AttributeFailure) { + obj.setState(QNetworkSettingsState::Failure); + } + else if (argument == AttributeAssociation) { + obj.setState(QNetworkSettingsState::Association); + } + else if (argument == AttributeConfiguration) { + obj.setState(QNetworkSettingsState::Configuration); + } + else if (argument == AttributeReady) { + obj.setState(QNetworkSettingsState::Ready); + } + else if (argument == AttributeDisconnect) { + obj.setState(QNetworkSettingsState::Disconnect); + } + else if (argument == AttributeOneline) { + obj.setState(QNetworkSettingsState::Online); + } + else { + obj.setState(QNetworkSettingsState::Undefined); + } + return argument; +} diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/connman/connmancommon.h b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/connmancommon.h new file mode 100644 index 0000000..dd3e7af --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/connmancommon.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef CONNMANCOMMON_H +#define CONNMANCOMMON_H + +#include +#include +#include + +#define AgentPath "/ConnmanAgent" +#define PropertyState "State" +#define PropertyName "Name" +#define PropertyType "Type" +#define PropertyConnected "Connected" +#define PropertyPowered "Powered" + +#define AttributeWifi "wifi" +#define AttributeEthernet "ethernet" +#define AttributeIdle "idle" +#define AttributeFailure "failure" +#define AttributeAssociation "association" +#define AttributeConfiguration "configuration" +#define AttributeReady "ready" +#define AttributeDisconnect "disconnect" +#define AttributeOneline "online" + +struct ConnmanMap { + QDBusObjectPath objectPath; + QVariantMap propertyMap; +}; + +QDBusArgument &operator<<(QDBusArgument &argument, const ConnmanMap &obj); +const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMap &obj); + +const QString &operator>>(const QString &argument, QNetworkSettingsType &obj); +const QString &operator>>(const QString &argument, QNetworkSettingsState &obj); + +typedef QList ConnmanMapList; + +Q_DECLARE_METATYPE( ConnmanMap ) +Q_DECLARE_METATYPE( ConnmanMapList ) + + +#endif // CONNMANCOMMON_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/connman/networksettingsmanager_linux.cpp b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/networksettingsmanager_linux.cpp deleted file mode 100644 index c4973ea..0000000 --- a/src/qtdevicesettings/networksettingsplugin/networksettings/connman/networksettingsmanager_linux.cpp +++ /dev/null @@ -1,583 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include - -#include "networkconfig.h" -#include "networksettingsmanager_linux_p.h" -#include "connman_manager_interface.cpp" -#include "moc_connman_manager_interface.cpp" -#include "connman_service_interface.h" -#include "connman_technology_interface.h" - -const QString PropertyIPv4("IPv4"); -const QString PropertyIPv4Config("IPv4.Configuration"); -const QString PropertyIPv6("IPv6"); -const QString PropertyIPv6Config("IPv6.Configuration"); -const QString PropertyNameservers("Nameservers"); -const QString PropertyNameserversConfig("Nameservers.Configuration"); -const QString PropertyDomains("Domains"); -const QString PropertyDomainsConfig("Domains.Configuration"); -const QString PropertyProxy("Proxy"); -const QString PropertyProxyConfig("Proxy.Configuration"); -const QString PropertyState("State"); -const QString PropertyName("Name"); -const QString PropertyType("Type"); -const QString PropertyConnected("Connected"); -const QString PropertyPowered("Powered"); -const QString PropertyAddress("Address"); -const QString PropertyNetMask("Netmask"); -const QString PropertyGateway("Gateway"); -const QString PropertyPrefixLength("PrefixLength"); -const QString PropertyMethod("Method"); -const QString PropertyPrivacy("Privacy"); -const QString PropertyUrl("Url"); -const QString PropertyServers("Servers"); -const QString PropertyExcludes("Excludes"); -const QString AttributeAuto("auto"); -const QString AttributeDhcp("dhcp"); -const QString AttributeManual("manual"); -const QString AttributeOff("off"); -const QString AttributeDisabled("disabled"); -const QString AttributeEnabled("enabled"); -const QString AttributePreferred("preferred"); -const QString AttributeDirect("direct"); -const QString AttributeWifi("wifi"); -const QString AttributeEthernet("ethernet"); -const QString AttributeIdle("idle"); -const QString AttributeFailure("failure"); -const QString AttributeAssociation("association"); -const QString AttributeConfiguration("configuration"); -const QString AttributeReady("ready"); -const QString AttributeDisconnect("disconnect"); -const QString AttributeOneline("online"); - -//Conversion operations for datatypes -const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMap &obj) -{ - argument.beginStructure(); - argument >> obj.objectPath >> obj.propertyMap; - argument.endStructure(); - return argument; -} - -QDBusArgument &operator<<(QDBusArgument &argument, const ConnmanMap &obj) -{ - argument.beginStructure(); - argument << obj.objectPath << obj.propertyMap; - argument.endStructure(); - return argument; -} - -const QVariantMap &operator>>(const QVariantMap &argument, IPv4Config &obj) -{ - obj.setAddress(argument[PropertyAddress].toString()); - obj.setMask(argument[PropertyNetMask].toString()); - obj.setGateway(argument[PropertyGateway].toString()); - - QString method = argument[PropertyMethod].toString(); - - if (method == AttributeDhcp) { - obj.setMethod(IPv4Config::Dhcp); - } - else if (method == AttributeManual) { - obj.setMethod(IPv4Config::Manual); - } - else if (method == AttributeOff) { - obj.setMethod(IPv4Config::Off); - } - else { - obj.setMethod(IPv4Config::Off); - } - return argument; -} - -const QVariantMap &operator<<(QVariantMap &argument, const IPv4Config &obj) -{ - argument.insert(PropertyAddress, QVariant::fromValue(obj.address())); - - argument.insert(PropertyNetMask, QVariant::fromValue(obj.mask())); - - argument.insert(PropertyGateway, QVariant::fromValue(obj.gateway())); - - QString method; - switch (obj.method()) { - case IPv4Config::Dhcp: - method = AttributeDhcp; - break; - case IPv4Config::Manual: - method = AttributeManual; - break; - case IPv4Config::Off: - method = AttributeOff; - break; - default: - break; - } - argument.insert(PropertyMethod, QVariant::fromValue(method)); - return argument; -} - -const QVariantMap &operator>>(const QVariantMap &argument, IPv6Config &obj) -{ - obj.setAddress(argument[PropertyAddress].toString()); - obj.setGateway(argument[PropertyGateway].toString()); - obj.setPrefixLength(argument[PropertyPrefixLength].toInt()); - QString method = argument[PropertyMethod].toString(); - if (method == AttributeAuto) { - obj.setMethod(IPv6Config::Auto); - } - else if (method == AttributeManual) { - obj.setMethod(IPv6Config::Manual); - } - else if (method == AttributeOff) { - obj.setMethod(IPv6Config::Off); - } - QString privacy = argument[PropertyPrivacy].toString(); - - if (privacy == AttributeDisabled) { - obj.setPrivacy(IPv6Config::Disabled); - } - else if (privacy == AttributeEnabled) { - obj.setPrivacy(IPv6Config::Enabled); - } - else if (privacy == AttributePreferred) { - obj.setPrivacy(IPv6Config::Preferred); - } - return argument; -} - -const QVariantMap &operator<<(QVariantMap &argument, const IPv6Config &obj) -{ - argument.insert(PropertyAddress, QVariant::fromValue(obj.address())); - argument.insert(PropertyGateway, QVariant::fromValue(obj.address())); - argument.insert(PropertyPrefixLength, QVariant::fromValue(obj.prefixLength())); - - QString method; - switch (obj.method()) { - case IPv6Config::Auto: - method = AttributeAuto; - break; - case IPv6Config::Manual: - method = AttributeManual; - break; - case IPv6Config::Off: - method = AttributeOff; - break; - default: - break; - } - argument.insert(PropertyMethod, QVariant::fromValue(method)); - - QString privacy; - switch (obj.privacy()) { - case IPv6Config::Disabled: - method = AttributeDisabled; - break; - case IPv6Config::Enabled: - method = AttributeEnabled; - break; - case IPv6Config::Preferred: - method = AttributePreferred; - break; - default: - break; - } - argument.insert(PropertyPrivacy, QVariant::fromValue(privacy)); - - return argument; -} - - -const QVariantMap &operator>>(const QVariantMap &argument, ProxyConfig &obj) -{ - QString method = argument[PropertyMethod].toString(); - if (method == AttributeDirect) { - obj.setMethod(ProxyConfig::Direct); - } - else if (method == AttributeAuto) { - obj.setMethod(ProxyConfig::Auto); - } - else if (method == AttributeManual) { - obj.setMethod(ProxyConfig::Manual); - } - - QString urlStr = argument[PropertyUrl].toString(); - obj.setUrl(QUrl(urlStr)); - - obj.setServers(argument[PropertyServers].toStringList()); - obj.setExcludes(argument[PropertyExcludes].toStringList()); - - return argument; -} - -const QVariantMap &operator<<(QVariantMap &argument, const ProxyConfig &obj) -{ - QString method; - switch (obj.method()) { - case ProxyConfig::Direct: - method = AttributeDirect; - break; - case ProxyConfig::Auto: - method = AttributeAuto; - break; - case ProxyConfig::Manual: - method = AttributeManual; - break; - default: - break; - } - argument.insert(PropertyMethod, QVariant::fromValue(method)); - argument.insert(PropertyUrl, QVariant::fromValue(obj.url().toString())); - argument.insert(PropertyServers, QVariant::fromValue(obj.servers())); - argument.insert(PropertyServers, QVariant::fromValue(obj.excludes())); - - return argument; -} - -const QString &operator>>(const QString &argument, NetworkType &obj) -{ - if (argument == AttributeEthernet) { - obj.setType(NetworkType::Wired); - } - else if (argument == AttributeWifi) { - obj.setType(NetworkType::Wifi); - } - else { - obj.setType(NetworkType::Unknown); - } - - return argument; -} - -const QString &operator>>(const QString &argument, NetworkState &obj) -{ - if (argument == AttributeIdle) { - obj.setState(NetworkState::Idle); - } - else if (argument == AttributeFailure) { - obj.setState(NetworkState::Failure); - } - else if (argument == AttributeAssociation) { - obj.setState(NetworkState::Association); - } - else if (argument == AttributeConfiguration) { - obj.setState(NetworkState::Configuration); - } - else if (argument == AttributeReady) { - obj.setState(NetworkState::Ready); - } - else if (argument == AttributeDisconnect) { - obj.setState(NetworkState::Disconnect); - } - else if (argument == AttributeOneline) { - obj.setState(NetworkState::Online); - } - else { - obj.setState(NetworkState::Undefined); - } - return argument; -} - -NetworkServicePrivate::NetworkServicePrivate(const QString& aPath, NetworkService *parent) : - QObject(parent) - ,q_ptr(parent) - ,m_path(aPath) -{ - qDBusRegisterMetaType(); - qDBusRegisterMetaType(); - - m_service = new NetConnmanServiceInterface("net.connman", m_path, - QDBusConnection::systemBus(), this); - - connect(m_service, SIGNAL(PropertyChanged(QString,QDBusVariant)), - this, SLOT(updateProperty(QString,QDBusVariant))); - - QDBusPendingReply reply = m_service->GetProperties(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - this, SLOT(propertiesUpdated(QDBusPendingCallWatcher*))); -} - -void NetworkServicePrivate::setupIpv6Config() -{ - QVariantMap param; - param << m_ipv6config; - if (m_service) - m_service->SetProperty(PropertyIPv6Config, QDBusVariant(QVariant(param))); -} - -void NetworkServicePrivate::setupNameserversConfig() -{ - QVariant param = QVariant::fromValue(m_nameserverConfig.stringList()); - if (m_service) - m_service->SetProperty(PropertyNameserversConfig, QDBusVariant(QVariant(param))); -} - -void NetworkServicePrivate::setupDomainsConfig() -{ - QVariant param = QVariant::fromValue(m_domainsConfig.stringList()); - if (m_service) - m_service->SetProperty(PropertyDomainsConfig, QDBusVariant(QVariant(param))); -} - -void NetworkServicePrivate::setupProxyConfig() -{ - QVariantMap param; - param << m_proxyConfig; - if (m_service) - m_service->SetProperty(PropertyProxyConfig, QDBusVariant(QVariant(param))); -} - -void NetworkServicePrivate::setupIpv4Config() -{ - QVariantMap param; - param << m_ipv4config; - if (m_service) - m_service->SetProperty(PropertyIPv4Config, QDBusVariant(QVariant(param))); -} - - -void NetworkServicePrivate::propertiesUpdated(QDBusPendingCallWatcher *call) -{ - QDBusPendingReply reply = *call; - call->deleteLater(); - - if (!reply.isError()) - setupConfiguration(reply.value()); -} - -void NetworkServicePrivate::updateProperty(const QString &name, const QDBusVariant &value) -{ - updateProperty(name, value.variant()); -} - -void NetworkServicePrivate::updateProperty(const QString& key, const QVariant& val) -{ - Q_Q(NetworkService); - - if (key == PropertyIPv4) { - QVariantMap value = qdbus_cast(val); - value >> m_ipv4config; - emit q->ipv4Changed(); - } - else if (key == PropertyIPv6) { - QVariantMap value = qdbus_cast(val); - value >> m_ipv6config; - emit q->ipv6Changed(); - } - else if (key == PropertyNameservers) { - QStringList value = qdbus_cast(val); - m_nameserverConfig.setStringList(value); - emit q->nameserversChanged(); - } - else if (key == PropertyDomains) { - QStringList value = qdbus_cast(val); - m_domainsConfig.setStringList(value); - emit q->domainsChanged(); - } - else if (key == PropertyProxy) { - QVariantMap value = qdbus_cast(val); - value >> m_proxyConfig; - emit q->proxyChanged(); - } - else if (key == PropertyState) { - QString value = qdbus_cast(val); - value >> m_state; - emit q->stateChanged(); - } - else if (key == PropertyName) { - m_name = qdbus_cast(val); - emit q->nameChanged(); - } - else if (key == PropertyType) { - QString value = qdbus_cast(val); - value >> m_type; - } -} - -void NetworkServicePrivate::setupConfiguration(const QVariantMap &properties) -{ - QVariantMap::const_iterator it = properties.constBegin(), end = properties.constEnd(); - for ( ; it != end; ++it) { - updateProperty(it.key(), it.value()); - } -} - -NetworkTechnology::NetworkTechnology(const QString& path, const QVariantMap& properties, QObject* parent) - : NetworkItem(parent) - { - m_technology = new NetConnmanTechnologyInterface("net.connman", path, - QDBusConnection::systemBus(), this); - connect(m_technology, SIGNAL(PropertyChanged(QString,QDBusVariant)), - this, SLOT(updateProperty(QString,QDBusVariant))); - - updateProperty(PropertyName, properties[PropertyName]); - updateProperty(PropertyType, properties[PropertyType]); - updateProperty(PropertyConnected, properties[PropertyConnected]); - updateProperty(PropertyPowered, properties[PropertyPowered]); - } - -void NetworkTechnology::updateProperty(const QString &name, const QDBusVariant &value) -{ - updateProperty(name, value.variant()); -} - -void NetworkTechnology::updateProperty(const QString &name, const QVariant &value) -{ - if (name == PropertyName) { - m_name = qdbus_cast(value); - } - else if (name == PropertyType) { - qdbus_cast(value) >> m_type; - emit typeChanged(); - } - else if (name == PropertyConnected) { - bool connected = qdbus_cast(value); - if (connected) - m_state.setState(NetworkState::Online); - else - m_state.setState(NetworkState::Disconnect); - emit stateChanged(); - } - else if (name == PropertyPowered) { - m_powered = qdbus_cast(value); - emit poweredChanged(); - } -} - - -NetworkSettingsManagerPrivate::NetworkSettingsManagerPrivate(NetworkSettingsManager *parent) - :QObject(parent) - ,q_ptr(parent) -{ - m_manager = new NetConnmanManagerInterface("net.connman", "/", - QDBusConnection::systemBus(), this); - - if (m_manager->isValid()) { - //List technologies - QDBusPendingReply reply = m_manager->GetTechnologies(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - this, SLOT(getTechnologiesFinished(QDBusPendingCallWatcher*))); - - reply = m_manager->GetServices(); - watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - this, SLOT(getServicesFinished(QDBusPendingCallWatcher*))); - } - else { - delete m_manager; - m_manager = NULL; - } -} - -void NetworkSettingsManagerPrivate::getServicesFinished(QDBusPendingCallWatcher *watcher) -{ - Q_Q(NetworkSettingsManager); - QDBusPendingReply reply = *watcher; - watcher->deleteLater(); - if (reply.isError()) - return; - - foreach (const ConnmanMap &object, reply.value()) { - const QString servicePath = object.objectPath.path(); - NetworkService *service = new NetworkService(servicePath, this); - m_services.append(service); - - //Update status property - QString n = qdbus_cast(object.propertyMap[PropertyName]); - QString t = qdbus_cast(object.propertyMap[PropertyType]); - QString s = qdbus_cast(object.propertyMap[PropertyState]); - - NetworkType type; - t >> type; - NetworkState state; - s >> state; - - foreach (NetworkItem* item, m_networksModel.getModel()) { - if (item->name() == n && item->type() == type.type()) { - item->setState(state.state()); - } - } - } - emit q->servicesChanged(); -} - -void NetworkSettingsManagerPrivate::getTechnologiesFinished(QDBusPendingCallWatcher *watcher) -{ - Q_Q(NetworkSettingsManager); - QDBusPendingReply reply = *watcher; - watcher->deleteLater(); - if (reply.isError()) - return; - - foreach (const ConnmanMap &object, reply.value()) { - NetworkTechnology *item = new NetworkTechnology(object.objectPath.path(), object.propertyMap, this); - - //Wired to the top - if (item->type() == NetworkType::Wired) - m_networksModel.insert(0, item); - else if (item->type() == NetworkType::Wifi) { - connect(item, &NetworkItem::poweredChanged, q, &NetworkSettingsManager::wifiPoweredChanged); - m_networksModel.append(item); - } - emit q->networksChanged(); - } -} - -bool NetworkSettingsManagerPrivate::wifiPowered() -{ - foreach (NetworkItem* item, m_networksModel.getModel()) { - if (item->type() == NetworkType::Wifi) { - return item->powered(); - } - } - return false; -} - -void NetworkSettingsManagerPrivate::setWifiPowered(const bool powered) -{ - foreach (NetworkItem* item, m_networksModel.getModel()) { - if (item->type() == NetworkType::Wifi) { - NetworkTechnology* technology = qobject_cast(item); - if (technology) { - NetConnmanTechnologyInterface *connmantech = technology->getTechnology(); - connmantech->SetProperty(PropertyPowered, QDBusVariant(QVariant(powered))); - } - } - } -} diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/connman/networksettingsmanager_linux_p.h b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/networksettingsmanager_linux_p.h deleted file mode 100644 index bccbed8..0000000 --- a/src/qtdevicesettings/networksettingsplugin/networksettings/connman/networksettingsmanager_linux_p.h +++ /dev/null @@ -1,148 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef NETWORKSETTINGSMANAGERPRIVATE_H -#define NETWORKSETTINGSMANAGERPRIVATE_H - -#include -#include -#include -#include -#include -#include "networkaddressmodel.h" -#include "networksettingsmanager.h" -#include "networksmodel.h" - -class NetConnmanManagerInterface; -class NetConnmanServiceInterface; -class NetworkService; -class NetConnmanTechnologyInterface; - -struct ConnmanMap { - QDBusObjectPath objectPath; - QVariantMap propertyMap; -}; - -QDBusArgument &operator<<(QDBusArgument &argument, const ConnmanMap &obj); - -const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMap &obj); - -typedef QList ConnmanMapList; - -Q_DECLARE_METATYPE( ConnmanMap ) -Q_DECLARE_METATYPE( ConnmanMapList ) - -class NetworkServicePrivate : public QObject -{ - Q_OBJECT - Q_DECLARE_PUBLIC(NetworkService) -public: - NetworkServicePrivate(const QString& aPath, NetworkService *parent=0); - - NetworkService *q_ptr; -private slots: - void propertiesUpdated(QDBusPendingCallWatcher *call); - void updateProperty(const QString &name, const QDBusVariant &value); - -private: - void setupConfiguration(const QVariantMap &properties); - void updateProperty(const QString& key, const QVariant& value); - -protected: - void setAutoConnect(const bool autoconnect); - void setupIpv4Config(); - void setupIpv6Config(); - void setupNameserversConfig(); - void setupDomainsConfig(); - void setupProxyConfig(); - - QString m_path; - QString m_name; - NetworkState m_state; - IPv4Config m_ipv4config; - IPv6Config m_ipv6config; - NetworkAddressModel m_domainsConfig; - NetworkAddressModel m_nameserverConfig; - ProxyConfig m_proxyConfig; - WifiConfig m_wifiConfig; - NetworkType m_type; - NetConnmanServiceInterface *m_service; -}; - -class NetworkTechnology : public NetworkItem -{ - Q_OBJECT -public: - explicit NetworkTechnology(const QString& path, const QVariantMap& properties, QObject* parent=0); - virtual ~NetworkTechnology() { - - } - - NetConnmanTechnologyInterface *getTechnology() { - return m_technology; - } - -public slots: - void updateProperty(const QString &name, const QDBusVariant &value); -protected: - void updateProperty(const QString &name, const QVariant &value); - -private: - NetConnmanTechnologyInterface *m_technology; -}; - - -class NetworkSettingsManagerPrivate : public QObject -{ - Q_OBJECT - Q_DECLARE_PUBLIC(NetworkSettingsManager) -public: - explicit NetworkSettingsManagerPrivate(NetworkSettingsManager *parent); - NetworkSettingsManager *q_ptr; - void setWifiPowered(const bool powered); - bool wifiPowered(); - -public slots: - void getServicesFinished(QDBusPendingCallWatcher *watcher); - void getTechnologiesFinished(QDBusPendingCallWatcher *watcher); - -protected: - QList m_services; - NetworksModel m_networksModel; -private: - NetConnmanManagerInterface *m_manager; -}; - -#endif // NETWORKSETTINGSMANAGERPRIVATE_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsinterface_p.cpp b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsinterface_p.cpp new file mode 100644 index 0000000..9a034d0 --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsinterface_p.cpp @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qnetworksettingsinterface_p.h" +#include "qnetworksettingsinterface.h" +#include "connman_technology_interface.h" +#include "connmancommon.h" + +QNetworkSettingsInterfacePrivate::QNetworkSettingsInterfacePrivate(QNetworkSettingsInterface* parent) + : QObject(parent) + ,q_ptr(parent) +{ + +} + +void QNetworkSettingsInterfacePrivate::initialize(const QString& path, const QVariantMap& properties) +{ + m_technology = new NetConnmanTechnologyInterface("net.connman", path, + QDBusConnection::systemBus(), this); + connect(m_technology, SIGNAL(PropertyChanged(QString,QDBusVariant)), + this, SLOT(updateProperty(QString,QDBusVariant))); + + updateProperty(PropertyName, properties[PropertyName]); + updateProperty(PropertyType, properties[PropertyType]); + updateProperty(PropertyConnected, properties[PropertyConnected]); + updateProperty(PropertyPowered, properties[PropertyPowered]); +} + +void QNetworkSettingsInterfacePrivate::updateProperty(const QString &name, const QDBusVariant &value) +{ + updateProperty(name, value.variant()); +} + +void QNetworkSettingsInterfacePrivate::updateProperty(const QString &name, const QVariant &value) +{ + Q_Q(QNetworkSettingsInterface); + if (name == PropertyName) { + m_name = qdbus_cast(value); + } + else if (name == PropertyType) { + qdbus_cast(value) >> m_type; + emit q->typeChanged(); + } + else if (name == PropertyConnected) { + bool connected = qdbus_cast(value); + if (connected) + m_state.setState(QNetworkSettingsState::Online); + else + m_state.setState(QNetworkSettingsState::Disconnect); + emit q->stateChanged(); + } + else if (name == PropertyPowered) { + m_powered = qdbus_cast(value); + emit q->poweredChanged(); + } +} + +void QNetworkSettingsInterfacePrivate::setState(QNetworkSettingsState::States aState) +{ + Q_Q(QNetworkSettingsInterface); + m_state.setState(aState); + emit q->stateChanged(); +} + +void QNetworkSettingsInterfacePrivate::setPowered(const bool aPowered) +{ + m_technology->SetProperty(PropertyPowered, QDBusVariant(QVariant(aPowered))); +} + +void QNetworkSettingsInterfacePrivate::scan() +{ + m_technology->Scan(); +} diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsinterface_p.h b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsinterface_p.h new file mode 100644 index 0000000..6e1d5ca --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsinterface_p.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QNETWORKSETTINGSINTERFACEPRIVATE_H +#define QNETWORKSETTINGSINTERFACEPRIVATE_H + +#include +#include +#include "qnetworksettings.h" +#include "qnetworksettingsinterface.h" + +class NetConnmanTechnologyInterface; + +class QNetworkSettingsInterfacePrivate : public QObject +{ + Q_OBJECT + Q_DECLARE_PUBLIC(QNetworkSettingsInterface) +public: + explicit QNetworkSettingsInterfacePrivate(QNetworkSettingsInterface* parent); + void initialize(const QString& path, const QVariantMap& properties); + void setPowered(const bool power); + void setState(QNetworkSettingsState::States aState); + void scan(); + +public slots: + void updateProperty(const QString &name, const QDBusVariant &value); +protected: + void updateProperty(const QString &name, const QVariant &value); + +protected: + NetConnmanTechnologyInterface *m_technology; + QString m_name; + QNetworkSettingsType m_type; + QNetworkSettingsState m_state; + bool m_powered; + QNetworkSettingsInterface *q_ptr; +}; + + +class ConnmanSettingsInterface : public QNetworkSettingsInterface +{ + Q_OBJECT +public: + ConnmanSettingsInterface(const QString& path, const QVariantMap& properties, QObject *parent=0) + :QNetworkSettingsInterface(parent) + { + if (d_ptr) + d_ptr->initialize(path, properties); + } + + void setState(QNetworkSettingsState::States aState) { + Q_D(QNetworkSettingsInterface); + d->setState(aState); + } + + virtual ~ConnmanSettingsInterface() { + + } +}; +#endif // QNETWORKSETTINGSINTERFACEPRIVATE_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsmanager_p.cpp b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsmanager_p.cpp new file mode 100644 index 0000000..2d4a0d3 --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsmanager_p.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qnetworksettingsmanager_p.h" +#include "connman_manager_interface.cpp" +#include "moc_connman_manager_interface.cpp" +#include "qnetworksettingsinterface.h" +#include "qnetworksettingsinterface_p.h" + +QNetworkSettingsManagerPrivate::QNetworkSettingsManagerPrivate(QNetworkSettingsManager *parent) + :QObject(parent) + ,q_ptr(parent) +{ + m_serviceFilter.setSourceModel(&m_serviceModel); + m_manager = new NetConnmanManagerInterface("net.connman", "/", + QDBusConnection::systemBus(), this); + + if (m_manager->isValid()) { + //List technologies + QDBusPendingReply reply = m_manager->GetTechnologies(); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); + connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), + this, SLOT(getTechnologiesFinished(QDBusPendingCallWatcher*))); + + reply = m_manager->GetServices(); + watcher = new QDBusPendingCallWatcher(reply, this); + connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), + this, SLOT(getServicesFinished(QDBusPendingCallWatcher*))); + + connect(m_manager, &NetConnmanManagerInterface::ServicesChanged, this, &QNetworkSettingsManagerPrivate::servicesChanged); + + m_manager->RegisterAgent(QDBusObjectPath(AgentPath)); + } + else { + delete m_manager; + m_manager = NULL; + } +} + +void QNetworkSettingsManagerPrivate::requestInput(const QString& service, const QString& type) +{ + Q_UNUSED(type); + foreach (QNetworkSettingsService* servicePtr, m_serviceModel.getModel()) { + if (servicePtr->id() == service) + emit servicePtr->showCrendentialInput(); + } +} + +void QNetworkSettingsManagerPrivate::getServicesFinished(QDBusPendingCallWatcher *watcher) +{ + Q_Q(QNetworkSettingsManager); + QDBusPendingReply reply = *watcher; + watcher->deleteLater(); + if (reply.isError()) + return; + + foreach (const ConnmanMap &object, reply.value()) { + const QString servicePath = object.objectPath.path(); + QNetworkSettingsService *service = new QNetworkSettingsService(servicePath, this); + m_serviceModel.append(service); + + //Update status property + QString n = qdbus_cast(object.propertyMap[PropertyName]); + QString t = qdbus_cast(object.propertyMap[PropertyType]); + QString s = qdbus_cast(object.propertyMap[PropertyState]); + + QNetworkSettingsType type; + t >> type; + QNetworkSettingsState state; + s >> state; + + foreach (QNetworkSettingsInterface* item, m_interfaceModel.getModel()) { + ConnmanSettingsInterface* technology = qobject_cast(item); + if (technology->name() == n && technology->type() == type.type()) { + technology->setState(state.state()); + } + } + } + emit q->servicesChanged(); +} + +void QNetworkSettingsManagerPrivate::getTechnologiesFinished(QDBusPendingCallWatcher *watcher) +{ + Q_Q(QNetworkSettingsManager); + + QDBusPendingReply reply = *watcher; + watcher->deleteLater(); + if (reply.isError()) + return; + + foreach (const ConnmanMap &object, reply.value()) { + ConnmanSettingsInterface *item = new ConnmanSettingsInterface(object.objectPath.path(), object.propertyMap, this); + + if (item->type() == QNetworkSettingsType::Wired) { + m_interfaceModel.insert(0, item); + } + else if (item->type() == QNetworkSettingsType::Wifi) { + m_interfaceModel.append(item); + } + emit q->interfacesChanged(); + } +} + +void QNetworkSettingsManagerPrivate::servicesChanged(ConnmanMapList changed, const QList &removed) +{ + foreach (QDBusObjectPath path, removed) { + QList serviceList = m_serviceModel.getModel(); + QMutableListIterator i(serviceList); + while (i.hasNext()) { + if (i.next()->id() == path.path()) + i.remove(); + } + } + + QStringList newServices; + foreach (ConnmanMap map, changed) { + bool found = false; + foreach (QNetworkSettingsService* service, m_serviceModel.getModel()) { + if (service->id() == map.objectPath.path()) { + found =true; + break; + } + } + if (!found) + newServices.append(map.objectPath.path()); + } + foreach (QString newService, newServices) { + QNetworkSettingsService *service = new QNetworkSettingsService(newService, this); + m_serviceModel.append(service); + } +} diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsmanager_p.h b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsmanager_p.h new file mode 100644 index 0000000..6883d74 --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsmanager_p.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QNETWORKSETTINGSMANAGERPRIVATE_H +#define QNETWORKSETTINGSMANAGERPRIVATE_H + +#include +#include +#include "connmancommon.h" +#include "qnetworksettingsmanager.h" +#include "qnetworksettingsinterfacemodel.h" +#include "qnetworksettingsservicemodel.h" + +class NetConnmanManagerInterface; + +class QNetworkSettingsManagerPrivate : public QObject +{ + Q_OBJECT + Q_DECLARE_PUBLIC(QNetworkSettingsManager) +public: + explicit QNetworkSettingsManagerPrivate(QNetworkSettingsManager *parent); + QNetworkSettingsManager *q_ptr; + +public slots: + void getServicesFinished(QDBusPendingCallWatcher *watcher); + void getTechnologiesFinished(QDBusPendingCallWatcher *watcher); + void requestInput(const QString& service, const QString& type); + void servicesChanged(ConnmanMapList changed, const QList &removed); + +protected: + QNetworkSettingsInterfaceModel m_interfaceModel; + QNetworkSettingsServiceModel m_serviceModel; + QNetworkSettingsServiceFilter m_serviceFilter; +private: + NetConnmanManagerInterface *m_manager; +}; + +#endif // QNETWORKSETTINGSMANAGERPRIVATE_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsservice_p.cpp b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsservice_p.cpp new file mode 100644 index 0000000..95181ed --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsservice_p.cpp @@ -0,0 +1,405 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qnetworksettingsservice_p.h" +#include "connman_service_interface.h" +#include "connmancommon.h" + +const QString PropertyIPv4("IPv4"); +const QString PropertyQNetworkSettingsIPv4("IPv4.Configuration"); +const QString PropertyIPv6("IPv6"); +const QString PropertyQNetworkSettingsIPv6("IPv6.Configuration"); +const QString PropertyNameservers("Nameservers"); +const QString PropertyNameserversConfig("Nameservers.Configuration"); +const QString PropertyDomains("Domains"); +const QString PropertyDomainsConfig("Domains.Configuration"); +const QString PropertyProxy("Proxy"); +const QString PropertyQNetworkSettingsProxy("Proxy.Configuration"); +const QString PropertyAddress("Address"); +const QString PropertyNetMask("Netmask"); +const QString PropertyGateway("Gateway"); +const QString PropertyPrefixLength("PrefixLength"); +const QString PropertyMethod("Method"); +const QString PropertyPrivacy("Privacy"); +const QString PropertyUrl("Url"); +const QString PropertyServers("Servers"); +const QString PropertyExcludes("Excludes"); +const QString PropertyStrength("Strength"); +const QString PropertySecurity("Security"); + +const QString AttributeAuto("auto"); +const QString AttributeDhcp("dhcp"); +const QString AttributeManual("manual"); +const QString AttributeOff("off"); +const QString AttributeDisabled("disabled"); +const QString AttributeEnabled("enabled"); +const QString AttributePreferred("preferred"); +const QString AttributeDirect("direct"); +const QString AttributeNone("none"); +const QString AttributeWep("wep"); +const QString AttributePsk("psk"); +const QString AttributeIeee("ieee8021x"); +const QString AttributeWps("wps"); +const QString AttributeInvalidKey("invalid-key"); + +const QVariantMap &operator>>(const QVariantMap &argument, QNetworkSettingsIPv4 &obj) +{ + obj.setAddress(argument[PropertyAddress].toString()); + obj.setMask(argument[PropertyNetMask].toString()); + obj.setGateway(argument[PropertyGateway].toString()); + + QString method = argument[PropertyMethod].toString(); + + if (method == AttributeDhcp) { + obj.setMethod(QNetworkSettingsIPv4::Dhcp); + } + else if (method == AttributeManual) { + obj.setMethod(QNetworkSettingsIPv4::Manual); + } + else if (method == AttributeOff) { + obj.setMethod(QNetworkSettingsIPv4::Off); + } + else { + obj.setMethod(QNetworkSettingsIPv4::Off); + } + return argument; +} + +const QVariantMap &operator<<(QVariantMap &argument, const QNetworkSettingsIPv4 &obj) +{ + argument.insert(PropertyAddress, QVariant::fromValue(obj.address())); + + argument.insert(PropertyNetMask, QVariant::fromValue(obj.mask())); + + argument.insert(PropertyGateway, QVariant::fromValue(obj.gateway())); + + QString method; + switch (obj.method()) { + case QNetworkSettingsIPv4::Dhcp: + method = AttributeDhcp; + break; + case QNetworkSettingsIPv4::Manual: + method = AttributeManual; + break; + case QNetworkSettingsIPv4::Off: + method = AttributeOff; + break; + default: + break; + } + argument.insert(PropertyMethod, QVariant::fromValue(method)); + return argument; +} + +const QVariantMap &operator>>(const QVariantMap &argument, QNetworkSettingsIPv6 &obj) +{ + obj.setAddress(argument[PropertyAddress].toString()); + obj.setGateway(argument[PropertyGateway].toString()); + obj.setPrefixLength(argument[PropertyPrefixLength].toInt()); + QString method = argument[PropertyMethod].toString(); + if (method == AttributeAuto) { + obj.setMethod(QNetworkSettingsIPv6::Auto); + } + else if (method == AttributeManual) { + obj.setMethod(QNetworkSettingsIPv6::Manual); + } + else if (method == AttributeOff) { + obj.setMethod(QNetworkSettingsIPv6::Off); + } + QString privacy = argument[PropertyPrivacy].toString(); + + if (privacy == AttributeDisabled) { + obj.setPrivacy(QNetworkSettingsIPv6::Disabled); + } + else if (privacy == AttributeEnabled) { + obj.setPrivacy(QNetworkSettingsIPv6::Enabled); + } + else if (privacy == AttributePreferred) { + obj.setPrivacy(QNetworkSettingsIPv6::Preferred); + } + return argument; +} + + +const QVariantMap &operator<<(QVariantMap &argument, const QNetworkSettingsIPv6 &obj) +{ + argument.insert(PropertyAddress, QVariant::fromValue(obj.address())); + argument.insert(PropertyGateway, QVariant::fromValue(obj.address())); + argument.insert(PropertyPrefixLength, QVariant::fromValue(obj.prefixLength())); + + QString method; + switch (obj.method()) { + case QNetworkSettingsIPv6::Auto: + method = AttributeAuto; + break; + case QNetworkSettingsIPv6::Manual: + method = AttributeManual; + break; + case QNetworkSettingsIPv6::Off: + method = AttributeOff; + break; + default: + break; + } + argument.insert(PropertyMethod, QVariant::fromValue(method)); + + QString privacy; + switch (obj.privacy()) { + case QNetworkSettingsIPv6::Disabled: + method = AttributeDisabled; + break; + case QNetworkSettingsIPv6::Enabled: + method = AttributeEnabled; + break; + case QNetworkSettingsIPv6::Preferred: + method = AttributePreferred; + break; + default: + break; + } + argument.insert(PropertyPrivacy, QVariant::fromValue(privacy)); + + return argument; +} + + +const QVariantMap &operator>>(const QVariantMap &argument, QNetworkSettingsProxy &obj) +{ + QString method = argument[PropertyMethod].toString(); + if (method == AttributeDirect) { + obj.setMethod(QNetworkSettingsProxy::Direct); + } + else if (method == AttributeAuto) { + obj.setMethod(QNetworkSettingsProxy::Auto); + } + else if (method == AttributeManual) { + obj.setMethod(QNetworkSettingsProxy::Manual); + } + + QString urlStr = argument[PropertyUrl].toString(); + obj.setUrl(QUrl(urlStr)); + + obj.setServers(argument[PropertyServers].toStringList()); + obj.setExcludes(argument[PropertyExcludes].toStringList()); + + return argument; +} + +const QVariantMap &operator<<(QVariantMap &argument, const QNetworkSettingsProxy &obj) +{ + QString method; + switch (obj.method()) { + case QNetworkSettingsProxy::Direct: + method = AttributeDirect; + break; + case QNetworkSettingsProxy::Auto: + method = AttributeAuto; + break; + case QNetworkSettingsProxy::Manual: + method = AttributeManual; + break; + default: + break; + } + argument.insert(PropertyMethod, QVariant::fromValue(method)); + argument.insert(PropertyUrl, QVariant::fromValue(obj.url().toString())); + argument.insert(PropertyServers, QVariant::fromValue(obj.servers())); + argument.insert(PropertyServers, QVariant::fromValue(obj.excludes())); + + return argument; +} + +QNetworkSettingsServicePrivate::QNetworkSettingsServicePrivate(const QString& id, QNetworkSettingsService *parent) : + QObject(parent) + ,q_ptr(parent) + ,m_id(id) +{ + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + + m_service = new NetConnmanServiceInterface("net.connman", m_id, + QDBusConnection::systemBus(), this); + + connect(m_service, SIGNAL(PropertyChanged(QString,QDBusVariant)), + this, SLOT(updateProperty(QString,QDBusVariant))); + + QDBusPendingReply reply = m_service->GetProperties(); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); + + connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), + this, SLOT(propertiesUpdated(QDBusPendingCallWatcher*))); +} + +void QNetworkSettingsServicePrivate::setupIpv6Config() +{ + QVariantMap param; + param << m_ipv6config; + if (m_service) + m_service->SetProperty(PropertyQNetworkSettingsIPv6, QDBusVariant(QVariant(param))); +} + +void QNetworkSettingsServicePrivate::setupNameserversConfig() +{ + QVariant param = QVariant::fromValue(m_nameserverConfig.stringList()); + if (m_service) + m_service->SetProperty(PropertyNameserversConfig, QDBusVariant(QVariant(param))); +} + +void QNetworkSettingsServicePrivate::setupDomainsConfig() +{ + QVariant param = QVariant::fromValue(m_domainsConfig.stringList()); + if (m_service) + m_service->SetProperty(PropertyDomainsConfig, QDBusVariant(QVariant(param))); +} + +void QNetworkSettingsServicePrivate::setupQNetworkSettingsProxy() +{ + QVariantMap param; + param << m_proxyConfig; + if (m_service) + m_service->SetProperty(PropertyQNetworkSettingsProxy, QDBusVariant(QVariant(param))); +} + +void QNetworkSettingsServicePrivate::setupIpv4Config() +{ + QVariantMap param; + param << m_ipv4config; + if (m_service) + m_service->SetProperty(PropertyQNetworkSettingsIPv4, QDBusVariant(QVariant(param))); +} + +void QNetworkSettingsServicePrivate::connectService() +{ + if (m_service) { + m_service->Connect(); + } +} + +void QNetworkSettingsServicePrivate::disconnectService() +{ + if (m_service) + m_service->Disconnect(); + +} + +void QNetworkSettingsServicePrivate::propertiesUpdated(QDBusPendingCallWatcher *call) +{ + QDBusPendingReply reply = *call; + call->deleteLater(); + + if (!reply.isError()) + setupConfiguration(reply.value()); +} + +void QNetworkSettingsServicePrivate::updateProperty(const QString &name, const QDBusVariant &value) +{ + updateProperty(name, value.variant()); +} + +void QNetworkSettingsServicePrivate::updateProperty(const QString& key, const QVariant& val) +{ + Q_Q(QNetworkSettingsService); + + if (key == PropertyIPv4) { + QVariantMap value = qdbus_cast(val); + value >> m_ipv4config; + emit q->ipv4Changed(); + } + else if (key == PropertyIPv6) { + QVariantMap value = qdbus_cast(val); + value >> m_ipv6config; + emit q->ipv6Changed(); + } + else if (key == PropertyNameservers) { + QStringList value = qdbus_cast(val); + m_nameserverConfig.setStringList(value); + emit q->nameserversChanged(); + } + else if (key == PropertyDomains) { + QStringList value = qdbus_cast(val); + m_domainsConfig.setStringList(value); + emit q->domainsChanged(); + } + else if (key == PropertyProxy) { + QVariantMap value = qdbus_cast(val); + value >> m_proxyConfig; + emit q->proxyChanged(); + } + else if (key == PropertyState) { + QString value = qdbus_cast(val); + value >> m_state; + emit q->stateChanged(); + } + else if (key == PropertyName) { + m_name = qdbus_cast(val); + emit q->nameChanged(); + } + else if (key == PropertyType) { + QString value = qdbus_cast(val); + value >> m_type; + } + else if (key == PropertyStrength) { + m_wifiConfig.setSignalStrength(val.toInt()); + } + else if (key == PropertySecurity) { + QStringList value = qdbus_cast(val); + foreach (const QString str, value) { + if (str == AttributeNone) { + m_wifiConfig.setSecurity(QNetworkSettingsWireless::None); + } + else if (str == AttributeWep) { + m_wifiConfig.setSecurity(QNetworkSettingsWireless::WEP); + } + else if (str == AttributePsk) { + m_wifiConfig.setSecurity(QNetworkSettingsWireless::WPA); + } + else if (str == AttributeIeee) { + m_wifiConfig.setSecurity(QNetworkSettingsWireless::WPA2); + } + else if (str == AttributeWps) { + m_wifiConfig.setSecurity(QNetworkSettingsWireless::WPS); + } + } + } +} + +void QNetworkSettingsServicePrivate::setupConfiguration(const QVariantMap &properties) +{ + QVariantMap::const_iterator it = properties.constBegin(), end = properties.constEnd(); + for ( ; it != end; ++it) { + updateProperty(it.key(), it.value()); + } +} + diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsservice_p.h b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsservice_p.h new file mode 100644 index 0000000..39a04bd --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsservice_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QNETWORKSETTINGSSERVICEPRIVATE_H +#define QNETWORKSETTINGSSERVICEPRIVATE_H + +#include +#include "qnetworksettingsservice.h" +#include "qnetworksettings.h" + +class NetConnmanServiceInterface; + +class QNetworkSettingsServicePrivate : public QObject +{ + Q_OBJECT + Q_DECLARE_PUBLIC(QNetworkSettingsService) +public: + QNetworkSettingsServicePrivate(const QString& aPath, QNetworkSettingsService *parent=0); + + QNetworkSettingsService *q_ptr; +private slots: + void propertiesUpdated(QDBusPendingCallWatcher *call); + void updateProperty(const QString &name, const QDBusVariant &value); + +private: + void setupConfiguration(const QVariantMap &properties); + void updateProperty(const QString& key, const QVariant& value); + +protected: + void setAutoConnect(const bool autoconnect); + void setupIpv4Config(); + void setupIpv6Config(); + void setupNameserversConfig(); + void setupDomainsConfig(); + void setupQNetworkSettingsProxy(); + void connectService(); + void disconnectService(); + + QString m_id; + QString m_name; + QNetworkSettingsState m_state; + QNetworkSettingsIPv4 m_ipv4config; + QNetworkSettingsIPv6 m_ipv6config; + QNetworkSettingsAddressModel m_domainsConfig; + QNetworkSettingsAddressModel m_nameserverConfig; + QNetworkSettingsProxy m_proxyConfig; + QNetworkSettingsWireless m_wifiConfig; + QNetworkSettingsType m_type; + NetConnmanServiceInterface *m_service; +}; + +#endif // QNETWORKSETTINGSSERVICEPRIVATE_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsuseragent_p.cpp b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsuseragent_p.cpp new file mode 100644 index 0000000..918c8b8 --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsuseragent_p.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qnetworksettingsuseragent_p.h" +#include "connmancommon.h" + +const QString PropertyPassphrase("Passphrase"); + +QNetworkSettingsUserAgentPrivate::QNetworkSettingsUserAgentPrivate(QNetworkSettingsUserAgent *parent) + :QDBusAbstractAdaptor(parent) + ,q_ptr(parent) + ,m_pendingReply(false) +{ + + setAutoRelaySignals(true); + QMetaObject::invokeMethod(this, "registerAgent", Qt::QueuedConnection); +} + +void QNetworkSettingsUserAgentPrivate::cancel() +{ + // handle method call net.connman.Agent.Cancel + m_pendingReply = false; + QMetaObject::invokeMethod(parent(), "Cancel"); +} + +void QNetworkSettingsUserAgentPrivate::release() +{ + // handle method call net.connman.Agent.Release + QMetaObject::invokeMethod(parent(), "Release"); +} + +void QNetworkSettingsUserAgentPrivate::ReportError(const QDBusObjectPath &path, const QString ¶m) +{ + Q_Q(QNetworkSettingsUserAgent); + Q_UNUSED(path); + Q_UNUSED(param); + emit q->error(); +} + +void QNetworkSettingsUserAgentPrivate::registerAgent() +{ + Q_Q(QNetworkSettingsUserAgent); + QDBusConnection::systemBus().registerObject(AgentPath, q_ptr); +} + +QVariantMap QNetworkSettingsUserAgentPrivate::RequestInput(const QDBusObjectPath &path, const QVariantMap ¶ms, const QDBusMessage &msg) +{ + Q_Q(QNetworkSettingsUserAgent); + Q_UNUSED(path); + Q_UNUSED(params); + msg.setDelayedReply(true); + m_reply = msg.createReply(); + m_pendingReply = true; + emit q->showUserCredentialsInput(); + return QVariantMap(); +} + +void QNetworkSettingsUserAgentPrivate::setUserCredentials(const QString& username, + const QString& password) +{ + QVariantMap response; + response[PropertyName] = username; + response[PropertyPassphrase] = password; + m_reply << response; + m_pendingReply = false; + QDBusConnection::systemBus().send(m_reply); +} diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsuseragent_p.h b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsuseragent_p.h new file mode 100644 index 0000000..8c480a5 --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/connman/qnetworksettingsuseragent_p.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QNETWORKSETTINGSUSERAGENTPRIVATE_H +#define QNETWORKSETTINGSUSERAGENTPRIVATE_H + +#include +#include +#include "qnetworksettingsuseragent.h" + +QT_BEGIN_NAMESPACE +class QByteArray; +template class QList; +template class QMap; +class QString; +class QStringList; +class QVariant; +QT_END_NAMESPACE + +const QString AgentPath("/ConnmanAgent"); + +class QNetworkSettingsUserAgentPrivate : public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "net.connman.Agent") + Q_DECLARE_PUBLIC(QNetworkSettingsUserAgent) +public: + QNetworkSettingsUserAgentPrivate(QNetworkSettingsUserAgent *parent=0); + void setUserCredentials(const QString& aUsername, const QString& aPassword); + void cancel(); + void release(); +public Q_SLOTS: // Dbus methods + void ReportError(const QDBusObjectPath &path, const QString ¶m); + QVariantMap RequestInput(const QDBusObjectPath &path, const QVariantMap ¶ms, + const QDBusMessage &message); + void registerAgent(); +private: + QNetworkSettingsUserAgent *q_ptr; + QDBusMessage m_reply; + bool m_pendingReply; +}; + +#endif // QNETWORKSETTINGSUSERAGENTPRIVATE_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/networkaddressmodel.cpp b/src/qtdevicesettings/networksettingsplugin/networksettings/networkaddressmodel.cpp deleted file mode 100644 index 3df67ab..0000000 --- a/src/qtdevicesettings/networksettingsplugin/networksettings/networkaddressmodel.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "networkaddressmodel.h" - -NetworkAddressModel::NetworkAddressModel(QObject *parent) - :QStringListModel(parent) -{ -} - -NetworkAddressModel::NetworkAddressModel(const QStringList &strings, QObject *parent) - :QStringListModel(parent) -{ - setStringList(strings); -} - -void NetworkAddressModel::setStringList(const QStringList &addresses) -{ - m_addresses = addresses; - QStringListModel::setStringList(m_addresses); - emit countChanged(); -} - -void NetworkAddressModel::append(const QString& address) -{ - int row = rowCount(); - - bool succeed = insertRows(row, 1); - if (succeed) - succeed = setData(index(row), QVariant::fromValue(address)); - - Q_ASSERT(succeed == true); - - emit countChanged(); -} - -void NetworkAddressModel::remove(int index) -{ - removeRows(index, 1); - emit countChanged(); -} - -int NetworkAddressModel::count() const -{ - return rowCount(); -} - -void NetworkAddressModel::resetChanges() -{ - QStringListModel::setStringList(m_addresses); -} diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/networkaddressmodel.h b/src/qtdevicesettings/networksettingsplugin/networksettings/networkaddressmodel.h deleted file mode 100644 index b90958f..0000000 --- a/src/qtdevicesettings/networksettingsplugin/networksettings/networkaddressmodel.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef NETWORKADDRESSMODEL_H -#define NETWORKADDRESSMODEL_H - -#include - -class NetworkAddressModel : public QStringListModel -{ - Q_OBJECT - Q_PROPERTY(int count READ count NOTIFY countChanged) -public: - explicit NetworkAddressModel(QObject *parent = 0); - explicit NetworkAddressModel(const QStringList &strings, QObject *parent = 0); - Q_INVOKABLE void append(const QString& address); - Q_INVOKABLE void remove(int index); - Q_INVOKABLE void resetChanges(); - void setStringList(const QStringList &addresses); - int count() const; - -signals: - void countChanged(); -private: - QStringList m_addresses; -}; - -#endif // NETWORKADDRESSMODEL_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/networkconfig.h b/src/qtdevicesettings/networksettingsplugin/networksettings/networkconfig.h deleted file mode 100644 index cdff473..0000000 --- a/src/qtdevicesettings/networksettingsplugin/networksettings/networkconfig.h +++ /dev/null @@ -1,394 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef NETWORKCONFIG_H -#define NETWORKCONFIG_H - -#include -#include -#include -#include "networkaddressmodel.h" - -class NetworkState : public QObject -{ - Q_OBJECT - Q_ENUMS(States) - Q_PROPERTY(States state READ state WRITE setState NOTIFY stateChanged) - -public: - enum States {Idle, Failure, Association, Configuration, Ready, Disconnect, Online, Undefined}; - - explicit NetworkState(States aState, QObject *parent = 0) - : QObject(parent) - { - m_state = aState; - } - - explicit NetworkState(QObject *parent = 0) - : QObject(parent) - { - m_state = Undefined; - } - - States state() const { - return m_state; - } - - void setState(const States aState) { - m_state = aState; - emit stateChanged(); - } - -signals: - void stateChanged(); - -private: - States m_state; -}; - -class NetworkType : public QObject -{ - Q_OBJECT - Q_ENUMS(Types) - Q_PROPERTY(Types type READ type WRITE setType NOTIFY typeChanged) - -public: - enum Types { - Wired, - Wifi, - Bluetooth, - Unknown - }; - - explicit NetworkType(Types aType, QObject *parent = 0) - : QObject(parent) - { - m_type = aType; - } - - explicit NetworkType(QObject *parent = 0) - : QObject(parent) - { - m_type = Unknown; - } - - - Types type() const { - return m_type; - } - - void setType(const Types aType) { - m_type = aType; - emit typeChanged(); - } - -signals: - void typeChanged(); - -private: - Types m_type; -}; - -class IPv4Config : public QObject -{ - Q_OBJECT - Q_ENUMS(MethodType) - Q_PROPERTY(QString address READ address WRITE setAddress NOTIFY addressChanged) - Q_PROPERTY(QString gateway READ gateway WRITE setGateway NOTIFY gatewayChanged) - Q_PROPERTY(MethodType method READ method WRITE setMethod NOTIFY methodChanged) - Q_PROPERTY(QString mask READ mask WRITE setMask NOTIFY maskChanged) - -public: - explicit IPv4Config(QObject *parent = 0) - : QObject(parent) - { - - } - - enum MethodType {Dhcp, Manual, Off}; - - QString address() const { - return m_address; - } - void setAddress(const QString& aAdderess) { - m_address = aAdderess; - emit addressChanged(); - } - - QString gateway() const { - return m_gateway; - } - - void setGateway(const QString& aGateway) { - m_gateway = aGateway; - emit gatewayChanged(); - } - - MethodType method() const { - return m_method; - } - - void setMethod(const MethodType aMethod) { - m_method = aMethod; - emit methodChanged(); - } - - QString mask() const { - return m_mask; - } - - void setMask(const QString& aMask) { - m_mask = aMask; - emit maskChanged(); - } - -signals: - void addressChanged(); - void gatewayChanged(); - void methodChanged(); - void maskChanged(); - -private: - QString m_address; - QString m_gateway; - MethodType m_method; - QString m_mask; -}; - - -class IPv6Config : public QObject -{ - Q_OBJECT - Q_ENUMS(MethodType PrivacyType) - Q_PROPERTY(QString address READ address WRITE setAddress NOTIFY addressChanged) - Q_PROPERTY(QString gateway READ gateway WRITE setGateway NOTIFY gatewayChanged) - Q_PROPERTY(MethodType method READ method WRITE setMethod NOTIFY methodChanged) - Q_PROPERTY(PrivacyType privacy READ privacy WRITE setPrivacy NOTIFY privacyChanged) - Q_PROPERTY(int prefixLength READ prefixLength WRITE setPrefixLength NOTIFY prefixLengthChanged) - -public: - explicit IPv6Config(QObject *parent = 0) - : QObject(parent) - { - - } - - enum MethodType {Auto, Manual, Off}; - enum PrivacyType {Disabled, Enabled, Preferred}; - - QString address() const { - return m_address; - } - void setAddress(const QString& aAdderess) { - m_address = aAdderess; - emit addressChanged(); - } - - QString gateway() const { - return m_gateway; - } - - void setGateway(const QString& aGateway) { - m_gateway = aGateway; - emit gatewayChanged(); - } - - MethodType method() const { - return m_method; - } - - void setMethod(const MethodType aMethod) { - m_method = aMethod; - emit methodChanged(); - } - - PrivacyType privacy() const { - return m_privacy; - } - - void setPrivacy(const PrivacyType aPrivacy) { - m_privacy = aPrivacy; - emit privacyChanged(); - } - - int prefixLength() const { - return m_prefixLength; - } - - void setPrefixLength(const int& aPrefixLength) { - m_prefixLength = aPrefixLength; - emit prefixLengthChanged(); - } - -signals: - void addressChanged(); - void gatewayChanged(); - void methodChanged(); - void privacyChanged(); - void prefixLengthChanged(); - -private: - QString m_address; - QString m_gateway; - MethodType m_method; - PrivacyType m_privacy; - int m_prefixLength; -}; - -class ProxyConfig : public QObject -{ - Q_OBJECT - Q_ENUMS(MethodType) -public: - Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) - Q_PROPERTY(QAbstractItemModel* servers READ servers NOTIFY serversChanged) - Q_PROPERTY(QAbstractItemModel* excludes READ excludes NOTIFY excludesChanged) - Q_PROPERTY(MethodType method READ method WRITE setMethod NOTIFY methodChanged) - - explicit ProxyConfig(QObject *parent=NULL) - : QObject(parent) - { - - } - - enum MethodType {Direct, Auto, Manual}; - - QUrl url() const { - return m_url; - } - - void setUrl(const QUrl& aUrl) { - m_url = aUrl; - emit urlChanged(); - } - - QAbstractItemModel* servers(void) { - return &m_servers; - } - - void setServers(const QStringList& aServers) { - m_servers.setStringList(aServers); - emit serversChanged(); - } - - QStringList servers() const { - return m_servers.stringList(); - } - - QAbstractItemModel* excludes(void) { - return &m_excludes; - } - - QStringList excludes() const { - return m_excludes.stringList(); - } - - void setExcludes(const QStringList& aExcludes) { - m_excludes.setStringList(aExcludes); - emit excludesChanged(); - } - - MethodType method(void) const { - return m_method; - } - - void setMethod(const MethodType& aMethod) { - m_method = aMethod; - emit methodChanged(); - } - -signals: - void urlChanged(); - void serversChanged(); - void excludesChanged(); - void methodChanged(); -private: - QUrl m_url; - NetworkAddressModel m_servers; - NetworkAddressModel m_excludes; - MethodType m_method; -}; - -class WifiConfig : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString bssid READ bssid NOTIFY bssidChanged) - Q_PROPERTY(int maxRate READ maxRate NOTIFY maxRateChanged) - Q_PROPERTY(int frequency READ frequency NOTIFY frequencyChanged) - Q_PROPERTY(QString encryptionMode READ encryptionMode NOTIFY encryptionModeChanged) - Q_PROPERTY(bool hidden READ hidden NOTIFY hiddenChanged) -public: - explicit WifiConfig(QObject* parent = 0) : - QObject(parent) { - - } - - const QString bssid() { - return m_bssid; - } - - int maxRate() { - return m_maxRate; - } - - int frequency() { - return m_frequency; - } - - const QString encryptionMode() { - return m_encryptionMode; - } - - bool hidden() const { - return m_hidden; - } - -signals: - void bssidChanged(const QString &bssid); - void maxRateChanged(quint32 rate); - void frequencyChanged(quint16 frequency); - void encryptionModeChanged(const QString &mode); - void hiddenChanged(bool); - -private: - QString m_bssid; - quint32 m_maxRate; - quint16 m_frequency; - QString m_encryptionMode; - bool m_hidden; -}; - - -#endif diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/networksettings.pri b/src/qtdevicesettings/networksettingsplugin/networksettings/networksettings.pri index 7a81571..d067eb7 100644 --- a/src/qtdevicesettings/networksettingsplugin/networksettings/networksettings.pri +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/networksettings.pri @@ -1,9 +1,3 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2015-11-03T13:52:45 -# -#------------------------------------------------- - QT += core network dbus INCLUDEPATH += $${PWD}/connman @@ -14,15 +8,31 @@ DBUS_INTERFACES = \ networksettings/connman/connman_service.xml \ networksettings/connman/connman_technology.xml - -SOURCES += networksettings/networksettingsmanager.cpp \ - networksettings/connman/networksettingsmanager_linux.cpp \ - networksettings/networkaddressmodel.cpp \ - networksettings/networksmodel.cpp +SOURCES += \ + $$PWD/qnetworksettingsinterfacemodel.cpp \ + $$PWD/qnetworksettingsmanager.cpp \ + $$PWD/qnetworksettingsaddressmodel.cpp \ + $$PWD/qnetworksettingsservicemodel.cpp \ + $$PWD/qnetworksettingsservice.cpp \ + $$PWD/qnetworksettingsuseragent.cpp \ + $$PWD/qnetworksettingsinterface.cpp \ + $$PWD/connman/qnetworksettingsinterface_p.cpp \ + $$PWD/connman/qnetworksettingsservice_p.cpp \ + $$PWD/connman/qnetworksettingsuseragent_p.cpp \ + $$PWD/connman/qnetworksettingsmanager_p.cpp \ + $$PWD/connman/connmancommon.cpp HEADERS += \ - networksettings/networkconfig.h \ - networksettings/connman/networksettingsmanager_linux_p.h \ - networksettings/networkaddressmodel.h \ - networksettings/networksettingsmanager.h \ - networksettings/networksmodel.h + $$PWD/qnetworksettingsinterfacemodel.h \ + $$PWD/qnetworksettings.h \ + $$PWD/qnetworksettingsmanager.h \ + $$PWD/qnetworksettingsaddressmodel.h \ + $$PWD/qnetworksettingsservicemodel.h \ + $$PWD/qnetworksettingsservice.h \ + $$PWD/qnetworksettingsuseragent.h \ + $$PWD/qnetworksettingsinterface.h \ + $$PWD/connman/qnetworksettingsinterface_p.h \ + $$PWD/connman/qnetworksettingsservice_p.h \ + $$PWD/connman/qnetworksettingsuseragent_p.h \ + $$PWD/connman/qnetworksettingsmanager_p.h \ + $$PWD/connman/connmancommon.h diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/networksettingsmanager.cpp b/src/qtdevicesettings/networksettingsplugin/networksettings/networksettingsmanager.cpp deleted file mode 100644 index 6df0f22..0000000 --- a/src/qtdevicesettings/networksettingsplugin/networksettings/networksettingsmanager.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "networksettingsmanager.h" -#include "connman/networksettingsmanager_linux_p.h" -#include - -NetworkService::NetworkService(const QString& aServiceId, QObject* parent) : - QObject(parent) - ,d_ptr(new NetworkServicePrivate(aServiceId, this)) -{ - -} - -QString NetworkService::name() const -{ - Q_D(const NetworkService); - return d->m_name; -} - -NetworkState::States NetworkService::state() -{ - Q_D(NetworkService); - return d->m_state.state(); -} - -NetworkType::Types NetworkService::type() -{ - Q_D(NetworkService); - return d->m_type.type(); -} - -IPv4Config* NetworkService::ipv4() -{ - Q_D(NetworkService); - return &d->m_ipv4config; -} - -IPv6Config* NetworkService::ipv6() -{ - Q_D(NetworkService); - return &d->m_ipv6config; -} - -ProxyConfig* NetworkService::proxy() -{ - Q_D(NetworkService); - return &d->m_proxyConfig; -} - -QAbstractItemModel* NetworkService::domains() -{ - Q_D(NetworkService); - return &d->m_domainsConfig; -} - -QAbstractItemModel* NetworkService::nameservers() -{ - Q_D(NetworkService); - return &d->m_nameserverConfig; -} - -void NetworkService::setupIpv4Config() -{ - Q_D(NetworkService); - d->setupIpv4Config(); -} - -void NetworkService::setupIpv6Config() -{ - Q_D(NetworkService); - d->setupIpv6Config(); -} - -void NetworkService::setupNameserversConfig() -{ - Q_D(NetworkService); - d->setupNameserversConfig(); -} - -void NetworkService::setupDomainsConfig() -{ - Q_D(NetworkService); - d->setupDomainsConfig(); -} - -void NetworkService::setupProxyConfig() -{ - Q_D(NetworkService); - d->setupProxyConfig(); -} - -NetworkSettingsManager::NetworkSettingsManager(QObject *parent) : - QObject(parent) - ,d_ptr(new NetworkSettingsManagerPrivate(this)) -{ - -} - -QQmlListProperty NetworkSettingsManager::services() -{ - Q_D(NetworkSettingsManager); - return QQmlListProperty(this, d->m_services); -} - -QAbstractItemModel* NetworkSettingsManager::networks() -{ - Q_D(NetworkSettingsManager); - return &d->m_networksModel; -} - -NetworkService* NetworkSettingsManager::getService(const QString& aName, const int aType) -{ - Q_D(NetworkSettingsManager); - - foreach (NetworkService* service, d->m_services) { - if (service->name() == aName && service->type() == aType) { - return service; - } - } - return NULL; -} - - -bool NetworkSettingsManager::wifiPowered() -{ - Q_D(NetworkSettingsManager); - return d->wifiPowered(); -} - -void NetworkSettingsManager::setWifiPowered(const bool power) -{ - Q_D(NetworkSettingsManager); - d->setWifiPowered(power); -} diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/networksettingsmanager.h b/src/qtdevicesettings/networksettingsplugin/networksettings/networksettingsmanager.h deleted file mode 100644 index 8e51258..0000000 --- a/src/qtdevicesettings/networksettingsplugin/networksettings/networksettingsmanager.h +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef NETWORKSETTINGSMANAGER_H -#define NETWORKSETTINGSMANAGER_H - -#include "networkconfig.h" -#include -#include -#include - -QT_FORWARD_DECLARE_CLASS(NetworkSettingsManagerPrivate) -QT_FORWARD_DECLARE_CLASS(NetworkServicePrivate) -QT_FORWARD_DECLARE_CLASS(NetworkNetworkTypePrivate) - -class NetworkService : public QObject -{ - Q_OBJECT - Q_ENUMS(StateTypes) - Q_PROPERTY(QString name READ name NOTIFY nameChanged) - Q_PROPERTY(NetworkState::States state READ state NOTIFY stateChanged) - Q_PROPERTY(NetworkType::Types type READ type NOTIFY typeChanged) - Q_PROPERTY(IPv4Config* ipv4 READ ipv4 NOTIFY ipv4Changed) - Q_PROPERTY(IPv6Config* ipv6 READ ipv6 NOTIFY ipv6Changed) - Q_PROPERTY(ProxyConfig* proxy READ proxy NOTIFY proxyChanged) - Q_PROPERTY(QAbstractItemModel* domains READ domains NOTIFY domainsChanged) - Q_PROPERTY(QAbstractItemModel* nameservers READ nameservers NOTIFY nameserversChanged) -public: - explicit NetworkService(const QString& aServiceId, QObject* parent = 0); - - QString name() const; - NetworkState::States state(); - NetworkType::Types type(); - IPv4Config* ipv4(); - IPv6Config* ipv6(); - ProxyConfig* proxy(); - QAbstractItemModel* domains(); - QAbstractItemModel* nameservers(); - - Q_INVOKABLE void setAutoConnect(const bool autoconnect); - Q_INVOKABLE void setupIpv4Config(); - Q_INVOKABLE void setupIpv6Config(); - Q_INVOKABLE void setupNameserversConfig(); - Q_INVOKABLE void setupDomainsConfig(); - Q_INVOKABLE void setupProxyConfig(); - -Q_SIGNALS: - void nameChanged(); - void stateChanged(); - void typeChanged(); - void proxyChanged(); - void ipv4Changed(); - void ipv6Changed(); - void domainsChanged(); - void nameserversChanged(); - -protected: - NetworkServicePrivate *d_ptr; - - Q_DISABLE_COPY(NetworkService) - Q_DECLARE_PRIVATE(NetworkService) -}; - -class NetworkSettingsManager : public QObject -{ - Q_OBJECT - Q_ENUMS(StateTypes NetworkTypeTypes) - Q_PROPERTY(QQmlListProperty services READ services NOTIFY servicesChanged) - Q_PROPERTY(QAbstractItemModel* networks READ networks NOTIFY networksChanged) - Q_PROPERTY(bool wifiPowered READ wifiPowered WRITE setWifiPowered NOTIFY wifiPoweredChanged) -public: - explicit NetworkSettingsManager(QObject* parent = 0); - QQmlListProperty services(); - - QAbstractItemModel* networks(); - - Q_INVOKABLE NetworkService* getService(const QString& aName, const int aType); - - bool wifiPowered(); - void setWifiPowered(const bool power); - -Q_SIGNALS: - void servicesChanged(); - void wifiPoweredChanged(); - void networksChanged(); - -protected: - NetworkSettingsManagerPrivate *d_ptr; - -private: - Q_DISABLE_COPY(NetworkSettingsManager) - Q_DECLARE_PRIVATE(NetworkSettingsManager) -}; - -#endif // NETWORKSETTINGSMANAGER_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/networksmodel.cpp b/src/qtdevicesettings/networksettingsplugin/networksettings/networksmodel.cpp deleted file mode 100644 index 8524417..0000000 --- a/src/qtdevicesettings/networksettingsplugin/networksettings/networksmodel.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include "networksmodel.h" - -NetworksModel::NetworksModel(QObject *parent) - : QAbstractListModel(parent) -{ - m_roleNames.insert(Qt::UserRole, "modelData"); - m_roleNames.insert(Type, "type"); - m_roleNames.insert(Status, "status"); - m_roleNames.insert(Name, "name"); -} - -NetworksModel::~NetworksModel() -{ - -} - -QHash NetworksModel::roleNames() const -{ - return m_roleNames; -} - - -int NetworksModel::rowCount(const QModelIndex & parent) const -{ - Q_UNUSED(parent); - return m_items.count(); -} - -QVariant NetworksModel::data(const QModelIndex & index, int role) const -{ - if (!index.isValid()) return QVariant(); - - NetworkItem *item = m_items[index.row()]; - if (role == Qt::UserRole) { - return QVariant::fromValue(static_cast(item)); - } - - switch (role) { - case Type: - return item->type(); - break; - case Name: - return item->name(); - break; - case Status: - return item->state(); - break; - default: - return ""; - } - -} - -void NetworksModel::append(NetworkItem* item) -{ - item->setParent(this); - - beginInsertRows(QModelIndex(), rowCount(), rowCount()); - m_items.append(item); - endInsertRows(); -} - -void NetworksModel::insert(int row, NetworkItem* item) -{ - item->setParent(this); - - beginInsertRows(QModelIndex(), row, row); - m_items.insert(row, item); - endInsertRows(); -} - -QList NetworksModel::getModel() -{ - return m_items; -} diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/networksmodel.h b/src/qtdevicesettings/networksettingsplugin/networksettings/networksmodel.h deleted file mode 100644 index d4c389c..0000000 --- a/src/qtdevicesettings/networksettingsplugin/networksettings/networksmodel.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef NETWORKSMODEL_H -#define NETWORKSMODEL_H - -#include -#include "networkconfig.h" - -QT_FORWARD_DECLARE_CLASS(NetworksModelPrivate) -QT_FORWARD_DECLARE_CLASS(QQmlPropertyMap) - -class NetworkItem : public QObject { - Q_OBJECT - Q_PROPERTY(QString name READ name NOTIFY nameChanged) - Q_PROPERTY(NetworkState::States state READ state NOTIFY stateChanged) - Q_PROPERTY(NetworkType::Types type READ type NOTIFY typeChanged) - Q_PROPERTY(bool powered READ powered NOTIFY poweredChanged) - -public: - explicit NetworkItem(QObject* parent=0) : - QObject(parent) { - - } - - QString name() const { - return m_name; - } - - void setName(const QString& aName) { - m_name = aName; - } - - NetworkState::States state() const { - return m_state.state(); - } - - NetworkType::Types type() const { - return m_type.type(); - } - - void setState(const NetworkState::States aState) { - m_state.setState(aState); - } - - void setType(const NetworkType::Types aType) { - m_type.setType(aType); - } - - bool powered() const { - return m_powered; - } - - void setPowered(const bool aPowered) { - m_powered = aPowered; - } - -signals: - void nameChanged(); - void stateChanged(); - void typeChanged(); - void poweredChanged(); - -protected: - QString m_name; - NetworkState m_state; - NetworkType m_type; - bool m_powered; - friend class NetworksModel; -}; - -class NetworksModel : public QAbstractListModel -{ - Q_OBJECT - -public: - explicit NetworksModel(QObject *parent=0); - virtual ~NetworksModel(); - // from QAbstractItemModel - int rowCount(const QModelIndex & parent = QModelIndex()) const; - QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; - QHash roleNames() const; - - void append(NetworkItem* networkItem); - void insert(int row, NetworkItem* networkItem); - QList getModel(); - - enum Roles { - Type = Qt::UserRole + 1, - Status, - Name - }; - -private: - QList m_items; - QHash m_roleNames; -}; - -#endif // NETWORKSMODEL_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettings.h b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettings.h new file mode 100644 index 0000000..6a0604b --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettings.h @@ -0,0 +1,399 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QNETWORKSETTINGS_H +#define QNETWORKSETTINGS_H + +#include +#include +#include +#include "qnetworksettingsaddressmodel.h" + +class QNetworkSettingsState : public QObject +{ + Q_OBJECT + Q_ENUMS(States) + Q_PROPERTY(States state READ state WRITE setState NOTIFY stateChanged) + +public: + enum States {Idle, Failure, Association, Configuration, Ready, Disconnect, Online, Undefined}; + + explicit QNetworkSettingsState(States state, QObject *parent = 0) + : QObject(parent) + { + m_state = state; + } + + explicit QNetworkSettingsState(QObject *parent = 0) + : QObject(parent) + { + m_state = Undefined; + } + + States state() const { + return m_state; + } + + void setState(const States state) { + m_state = state; + emit stateChanged(); + } + +signals: + void stateChanged(); + +private: + States m_state; +}; + +class QNetworkSettingsType : public QObject +{ + Q_OBJECT + Q_ENUMS(Types) + Q_PROPERTY(Types type READ type WRITE setType NOTIFY typeChanged) + +public: + enum Types { + Wired, + Wifi, + Bluetooth, + Unknown + }; + + explicit QNetworkSettingsType(Types type, QObject *parent = 0) + : QObject(parent) + { + m_type = type; + } + + explicit QNetworkSettingsType(QObject *parent = 0) + : QObject(parent) + { + m_type = Unknown; + } + + + Types type() const { + return m_type; + } + + void setType(const Types type) { + m_type = type; + emit typeChanged(); + } + +signals: + void typeChanged(); + +private: + Types m_type; +}; + +class QNetworkSettingsIPv4 : public QObject +{ + Q_OBJECT + Q_ENUMS(MethodType) + Q_PROPERTY(QString address READ address WRITE setAddress NOTIFY addressChanged) + Q_PROPERTY(QString gateway READ gateway WRITE setGateway NOTIFY gatewayChanged) + Q_PROPERTY(MethodType method READ method WRITE setMethod NOTIFY methodChanged) + Q_PROPERTY(QString mask READ mask WRITE setMask NOTIFY maskChanged) + +public: + explicit QNetworkSettingsIPv4(QObject *parent = 0) + : QObject(parent) + { + + } + + enum MethodType {Dhcp, Manual, Off}; + + QString address() const { + return m_address; + } + void setAddress(const QString& adderess) { + m_address = adderess; + emit addressChanged(); + } + + QString gateway() const { + return m_gateway; + } + + void setGateway(const QString& gateway) { + m_gateway = gateway; + emit gatewayChanged(); + } + + MethodType method() const { + return m_method; + } + + void setMethod(const MethodType method) { + m_method = method; + emit methodChanged(); + } + + QString mask() const { + return m_mask; + } + + void setMask(const QString& mask) { + m_mask = mask; + emit maskChanged(); + } + +signals: + void addressChanged(); + void gatewayChanged(); + void methodChanged(); + void maskChanged(); + +private: + QString m_address; + QString m_gateway; + MethodType m_method; + QString m_mask; +}; + + +class QNetworkSettingsIPv6 : public QObject +{ + Q_OBJECT + Q_ENUMS(MethodType PrivacyType) + Q_PROPERTY(QString address READ address WRITE setAddress NOTIFY addressChanged) + Q_PROPERTY(QString gateway READ gateway WRITE setGateway NOTIFY gatewayChanged) + Q_PROPERTY(MethodType method READ method WRITE setMethod NOTIFY methodChanged) + Q_PROPERTY(PrivacyType privacy READ privacy WRITE setPrivacy NOTIFY privacyChanged) + Q_PROPERTY(int prefixLength READ prefixLength WRITE setPrefixLength NOTIFY prefixLengthChanged) + +public: + explicit QNetworkSettingsIPv6(QObject *parent = 0) + : QObject(parent) + { + + } + + enum MethodType {Auto, Manual, Off}; + enum PrivacyType {Disabled, Enabled, Preferred}; + + QString address() const { + return m_address; + } + void setAddress(const QString& adderess) { + m_address = adderess; + emit addressChanged(); + } + + QString gateway() const { + return m_gateway; + } + + void setGateway(const QString& gateway) { + m_gateway = gateway; + emit gatewayChanged(); + } + + MethodType method() const { + return m_method; + } + + void setMethod(const MethodType method) { + m_method = method; + emit methodChanged(); + } + + PrivacyType privacy() const { + return m_privacy; + } + + void setPrivacy(const PrivacyType privacy) { + m_privacy = privacy; + emit privacyChanged(); + } + + int prefixLength() const { + return m_prefixLength; + } + + void setPrefixLength(const int& prefixLength) { + m_prefixLength = prefixLength; + emit prefixLengthChanged(); + } + +signals: + void addressChanged(); + void gatewayChanged(); + void methodChanged(); + void privacyChanged(); + void prefixLengthChanged(); + +private: + QString m_address; + QString m_gateway; + MethodType m_method; + PrivacyType m_privacy; + int m_prefixLength; +}; + +class QNetworkSettingsProxy : public QObject +{ + Q_OBJECT + Q_ENUMS(MethodType) +public: + Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) + Q_PROPERTY(QAbstractItemModel* servers READ servers NOTIFY serversChanged) + Q_PROPERTY(QAbstractItemModel* excludes READ excludes NOTIFY excludesChanged) + Q_PROPERTY(MethodType method READ method WRITE setMethod NOTIFY methodChanged) + + explicit QNetworkSettingsProxy(QObject *parent=NULL) + : QObject(parent) + { + + } + + enum MethodType {Direct, Auto, Manual}; + + QUrl url() const { + return m_url; + } + + void setUrl(const QUrl& url) { + m_url = url; + emit urlChanged(); + } + + QAbstractItemModel* servers(void) { + return &m_servers; + } + + void setServers(const QStringList& servers) { + m_servers.setStringList(servers); + emit serversChanged(); + } + + QStringList servers() const { + return m_servers.stringList(); + } + + QAbstractItemModel* excludes(void) { + return &m_excludes; + } + + QStringList excludes() const { + return m_excludes.stringList(); + } + + void setExcludes(const QStringList& excludes) { + m_excludes.setStringList(excludes); + emit excludesChanged(); + } + + MethodType method(void) const { + return m_method; + } + + void setMethod(const MethodType& method) { + m_method = method; + emit methodChanged(); + } + +signals: + void urlChanged(); + void serversChanged(); + void excludesChanged(); + void methodChanged(); +private: + QUrl m_url; + QNetworkSettingsAddressModel m_servers; + QNetworkSettingsAddressModel m_excludes; + MethodType m_method; +}; + +class QNetworkSettingsWireless : public QObject +{ + Q_OBJECT + Q_PROPERTY(int signalStrength READ signalStrength WRITE setSignalStrength NOTIFY signalStrengthChanged) + Q_PROPERTY(bool hidden READ hidden NOTIFY hiddenChanged) +public: + explicit QNetworkSettingsWireless(QObject* parent = 0) : + QObject(parent) { + } + + enum SecurityFlags {None=1, WEP=2, WPA=4, WPA2=8, WPS=16}; + + Q_INVOKABLE bool supportsSecurity(SecurityFlags security) { + if (m_securityFlags & security) { + return true; + } + return false; + } + + bool hidden() const { + return m_hidden; + } + + void setHidden(const bool hidden) { + m_hidden = hidden; + emit hiddenChanged(); + } + + int signalStrength() const { + return m_signalStrength; + } + + void setSignalStrength(const int signalStrength) { + m_signalStrength = signalStrength; + emit signalStrengthChanged(); + } + + void setSecurity(const SecurityFlags security) { + if (security == None) { + m_securityFlags = None; + } + else { + m_securityFlags |= security; + } + } + +signals: + void hiddenChanged(); + void signalStrengthChanged(); + void passwordChanged(); +private: + quint16 m_securityFlags; + bool m_hidden; + int m_signalStrength; +}; +#endif //QNETWORKSETTINGS_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsaddressmodel.cpp b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsaddressmodel.cpp new file mode 100644 index 0000000..b70278b --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsaddressmodel.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qnetworksettingsaddressmodel.h" + +QNetworkSettingsAddressModel::QNetworkSettingsAddressModel(QObject *parent) + :QStringListModel(parent) +{ +} + +QNetworkSettingsAddressModel::QNetworkSettingsAddressModel(const QStringList &strings, QObject *parent) + :QStringListModel(parent) +{ + setStringList(strings); +} + +void QNetworkSettingsAddressModel::setStringList(const QStringList &addresses) +{ + m_addresses = addresses; + QStringListModel::setStringList(m_addresses); + emit countChanged(); +} + +void QNetworkSettingsAddressModel::append(const QString& address) +{ + int row = rowCount(); + + bool succeed = insertRows(row, 1); + if (succeed) + succeed = setData(index(row), QVariant::fromValue(address)); + + Q_ASSERT(succeed == true); + + emit countChanged(); +} + +void QNetworkSettingsAddressModel::remove(int index) +{ + removeRows(index, 1); + emit countChanged(); +} + +int QNetworkSettingsAddressModel::count() const +{ + return rowCount(); +} + +void QNetworkSettingsAddressModel::resetChanges() +{ + QStringListModel::setStringList(m_addresses); +} diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsaddressmodel.h b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsaddressmodel.h new file mode 100644 index 0000000..b7a1c2e --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsaddressmodel.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QNETWORKSETTINGSADDRESSMODEL_H +#define QNETWORKSETTINGSADDRESSMODEL_H + +#include + +class QNetworkSettingsAddressModel : public QStringListModel +{ + Q_OBJECT + Q_PROPERTY(int count READ count NOTIFY countChanged) +public: + explicit QNetworkSettingsAddressModel(QObject *parent = 0); + explicit QNetworkSettingsAddressModel(const QStringList &strings, QObject *parent = 0); + Q_INVOKABLE void append(const QString& address); + Q_INVOKABLE void remove(int index); + Q_INVOKABLE void resetChanges(); + void setStringList(const QStringList &addresses); + int count() const; + +signals: + void countChanged(); +private: + QStringList m_addresses; +}; + +#endif // QNETWORKSETTINGSADDRESSMODEL_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsinterface.cpp b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsinterface.cpp new file mode 100644 index 0000000..893311a --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsinterface.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qnetworksettingsinterface.h" +#include "qnetworksettingsinterface_p.h" +#include "qnetworksettings.h" + +QNetworkSettingsInterface::QNetworkSettingsInterface(QObject *parent) : + QObject(parent) + ,d_ptr(new QNetworkSettingsInterfacePrivate(this)) +{ + +} + +QString QNetworkSettingsInterface::name() const +{ + Q_D(const QNetworkSettingsInterface); + return d->m_name; +} + +QNetworkSettingsState::States QNetworkSettingsInterface::state() +{ + Q_D(QNetworkSettingsInterface); + return d->m_state.state(); +} + +QNetworkSettingsType::Types QNetworkSettingsInterface::type() +{ + Q_D(QNetworkSettingsInterface); + return d->m_type.type(); +} + +bool QNetworkSettingsInterface::powered() const +{ + Q_D(const QNetworkSettingsInterface); + return d->m_powered; +} + +void QNetworkSettingsInterface::setPowered(const bool powered) +{ + Q_D(QNetworkSettingsInterface); + d->setPowered(powered); +} + +void QNetworkSettingsInterface::scanServices() +{ + Q_D(QNetworkSettingsInterface); + d->scan(); +} diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsinterface.h b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsinterface.h new file mode 100644 index 0000000..bce4848 --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsinterface.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QNETWORKSETTINGSINTERFACE_H +#define QNETWORKSETTINGSINTERFACE_H + +#include +#include "qnetworksettings.h" + +QT_FORWARD_DECLARE_CLASS(QNetworkSettingsInterfacePrivate) + +class QNetworkSettingsInterface : public QObject { + Q_OBJECT + Q_PROPERTY(QString name READ name NOTIFY nameChanged) + Q_PROPERTY(QNetworkSettingsState::States state READ state NOTIFY stateChanged) + Q_PROPERTY(QNetworkSettingsType::Types type READ type NOTIFY typeChanged) + Q_PROPERTY(bool powered READ powered WRITE setPowered NOTIFY poweredChanged) + +public: + explicit QNetworkSettingsInterface(QObject* parent=0); + QString name() const; + QNetworkSettingsState::States state(); + QNetworkSettingsType::Types type(); + bool powered() const; + void setPowered(const bool powered); + Q_INVOKABLE void scanServices(); + +signals: + void nameChanged(); + void stateChanged(); + void typeChanged(); + void poweredChanged(); + +protected: + friend class NetworksInterfaceModel; + QNetworkSettingsInterfacePrivate *d_ptr; + + Q_DISABLE_COPY(QNetworkSettingsInterface) + Q_DECLARE_PRIVATE(QNetworkSettingsInterface) +}; + +#endif // QNETWORKSETTINGSINTERFACE_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsinterfacemodel.cpp b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsinterfacemodel.cpp new file mode 100644 index 0000000..a4ea477 --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsinterfacemodel.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include "qnetworksettingsinterfacemodel.h" +#include "qnetworksettingsinterface.h" + +QNetworkSettingsInterfaceModel::QNetworkSettingsInterfaceModel(QObject *parent) + : QAbstractListModel(parent) +{ + m_roleNames.insert(Qt::UserRole, "modelData"); + m_roleNames.insert(Type, "type"); + m_roleNames.insert(Status, "status"); + m_roleNames.insert(Name, "name"); +} + +QNetworkSettingsInterfaceModel::~QNetworkSettingsInterfaceModel() +{ + +} + +QHash QNetworkSettingsInterfaceModel::roleNames() const +{ + return m_roleNames; +} + + +int QNetworkSettingsInterfaceModel::rowCount(const QModelIndex & parent) const +{ + Q_UNUSED(parent); + return m_items.count(); +} + +QVariant QNetworkSettingsInterfaceModel::data(const QModelIndex & index, int role) const +{ + if (!index.isValid()) return QVariant(); + + QNetworkSettingsInterface *item = m_items[index.row()]; + if (role == Qt::UserRole) { + return QVariant::fromValue(static_cast(item)); + } + + switch (role) { + case Type: + return item->type(); + break; + case Name: + return item->name(); + break; + case Status: + return item->state(); + break; + default: + return ""; + } + +} + +void QNetworkSettingsInterfaceModel::append(QNetworkSettingsInterface* item) +{ + item->setParent(this); + + beginInsertRows(QModelIndex(), rowCount(), rowCount()); + m_items.append(item); + endInsertRows(); +} + +void QNetworkSettingsInterfaceModel::insert(int row, QNetworkSettingsInterface* item) +{ + item->setParent(this); + + beginInsertRows(QModelIndex(), row, row); + m_items.insert(row, item); + endInsertRows(); +} + +QList QNetworkSettingsInterfaceModel::getModel() +{ + return m_items; +} diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsinterfacemodel.h b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsinterfacemodel.h new file mode 100644 index 0000000..c44733a --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsinterfacemodel.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QNETWORKSETTINGSINTERFACEMODEL_H +#define QNETWORKSETTINGSINTERFACEMODEL_H + +#include +#include "qnetworksettings.h" + +class QNetworkSettingsInterface; + +class QNetworkSettingsInterfaceModel : public QAbstractListModel +{ + Q_OBJECT + +public: + explicit QNetworkSettingsInterfaceModel(QObject *parent=0); + virtual ~QNetworkSettingsInterfaceModel(); + // from QAbstractItemModel + int rowCount(const QModelIndex & parent = QModelIndex()) const; + QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; + QHash roleNames() const; + + void append(QNetworkSettingsInterface* networkInterface); + void insert(int row, QNetworkSettingsInterface* networkInterface); + QList getModel(); + + enum Roles { + Type = Qt::UserRole + 1, + Status, + Name + }; + +private: + QList m_items; + QHash m_roleNames; +}; + +#endif // QNETWORKSETTINGSINTERFACEMODEL_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsmanager.cpp b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsmanager.cpp new file mode 100644 index 0000000..f4a8918 --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsmanager.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qnetworksettingsmanager.h" +#include "qnetworksettingsservice.h" +#include "qnetworksettingsservicemodel.h" +#include "qnetworksettingsinterfacemodel.h" +#include "qnetworksettingsmanager_p.h" +#include + +QNetworkSettingsManager::QNetworkSettingsManager(QObject *parent) : + QObject(parent) + ,d_ptr(new QNetworkSettingsManagerPrivate(this)) +{ +} + +QAbstractItemModel* QNetworkSettingsManager::services() +{ + Q_D(QNetworkSettingsManager); + return &d->m_serviceFilter; +} + +QAbstractItemModel* QNetworkSettingsManager::interfaces() +{ + Q_D(QNetworkSettingsManager); + return &d->m_interfaceModel; +} + +QNetworkSettingsService* QNetworkSettingsManager::getService(const QString& name, const int type) +{ + Q_D(QNetworkSettingsManager); + + foreach (QNetworkSettingsService* service, d->m_serviceModel.getModel()) { + if (service->name() == name && service->type() == type) { + return service; + } + } + return NULL; +} diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsmanager.h b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsmanager.h new file mode 100644 index 0000000..03921b2 --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsmanager.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QNETWORKSETTINGSMANAGER_H +#define QNETWORKSETTINGSMANAGER_H + +#include "qnetworksettings.h" +#include +#include +#include + +QT_FORWARD_DECLARE_CLASS(QNetworkSettingsManagerPrivate) +QT_FORWARD_DECLARE_CLASS(QNetworkSettingsService) + +class QNetworkSettingsManager : public QObject +{ + Q_OBJECT + Q_ENUMS(StateTypes NetworkTypeTypes) + Q_PROPERTY(QAbstractItemModel* services READ services NOTIFY servicesChanged) + Q_PROPERTY(QAbstractItemModel* interfaces READ interfaces NOTIFY interfacesChanged) +public: + explicit QNetworkSettingsManager(QObject* parent = 0); + QAbstractItemModel* services(); + QAbstractItemModel* interfaces(); + + Q_INVOKABLE QNetworkSettingsService* getService(const QString& name, const int type); + +Q_SIGNALS: + void servicesChanged(); + void interfacesChanged(); + +protected: + QNetworkSettingsManagerPrivate *d_ptr; + +private: + Q_DISABLE_COPY(QNetworkSettingsManager) + Q_DECLARE_PRIVATE(QNetworkSettingsManager) +}; + +#endif // QNETWORKSETTINGSMANAGER_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsservice.cpp b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsservice.cpp new file mode 100644 index 0000000..8ade875 --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsservice.cpp @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qnetworksettingsservice.h" +#include "qnetworksettingsservice_p.h" + +QNetworkSettingsService::QNetworkSettingsService(const QString& aServiceId, QObject* parent) : + QObject(parent) + ,d_ptr(new QNetworkSettingsServicePrivate(aServiceId, this)) +{ + +} + +QString QNetworkSettingsService::id() const +{ + Q_D(const QNetworkSettingsService); + return d->m_id; +} + +QString QNetworkSettingsService::name() const +{ + Q_D(const QNetworkSettingsService); + return d->m_name; +} + +QNetworkSettingsState::States QNetworkSettingsService::state() +{ + Q_D(QNetworkSettingsService); + return d->m_state.state(); +} + +QNetworkSettingsType::Types QNetworkSettingsService::type() +{ + Q_D(QNetworkSettingsService); + return d->m_type.type(); +} + +QNetworkSettingsIPv4* QNetworkSettingsService::ipv4() +{ + Q_D(QNetworkSettingsService); + return &d->m_ipv4config; +} + +QNetworkSettingsIPv6* QNetworkSettingsService::ipv6() +{ + Q_D(QNetworkSettingsService); + return &d->m_ipv6config; +} + +QNetworkSettingsProxy* QNetworkSettingsService::proxy() +{ + Q_D(QNetworkSettingsService); + return &d->m_proxyConfig; +} + +QNetworkSettingsWireless* QNetworkSettingsService::wirelessConfig() +{ + Q_D(QNetworkSettingsService); + return &d->m_wifiConfig; +} + +QAbstractItemModel* QNetworkSettingsService::domains() +{ + Q_D(QNetworkSettingsService); + return &d->m_domainsConfig; +} + +QAbstractItemModel* QNetworkSettingsService::nameservers() +{ + Q_D(QNetworkSettingsService); + return &d->m_nameserverConfig; +} + +void QNetworkSettingsService::setupIpv4Config() +{ + Q_D(QNetworkSettingsService); + d->setupIpv4Config(); +} + +void QNetworkSettingsService::setupIpv6Config() +{ + Q_D(QNetworkSettingsService); + d->setupIpv6Config(); +} + +void QNetworkSettingsService::setupNameserversConfig() +{ + Q_D(QNetworkSettingsService); + d->setupNameserversConfig(); +} + +void QNetworkSettingsService::setupDomainsConfig() +{ + Q_D(QNetworkSettingsService); + d->setupDomainsConfig(); +} + +void QNetworkSettingsService::setupNetworkSettingsProxy() +{ + Q_D(QNetworkSettingsService); + d->setupQNetworkSettingsProxy(); +} + +void QNetworkSettingsService::connectService() +{ + Q_D(QNetworkSettingsService); + d->connectService(); +} + +void QNetworkSettingsService::disconnectService() +{ + Q_D(QNetworkSettingsService); + d->disconnectService(); +} diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsservice.h b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsservice.h new file mode 100644 index 0000000..96d4244 --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsservice.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QNETWORKSETTINGSSERVICE_H +#define QNETWORKSETTINGSSERVICE_H + +#include +#include "qnetworksettings.h" + +QT_FORWARD_DECLARE_CLASS(QNetworkSettingsServicePrivate) + +class QNetworkSettingsService : public QObject +{ + Q_OBJECT + Q_ENUMS(StateTypes) + Q_PROPERTY(QString id READ id CONSTANT) + Q_PROPERTY(QString name READ name NOTIFY nameChanged) + Q_PROPERTY(QNetworkSettingsState::States state READ state NOTIFY stateChanged) + Q_PROPERTY(QNetworkSettingsType::Types type READ type NOTIFY typeChanged) + Q_PROPERTY(QNetworkSettingsIPv4* ipv4 READ ipv4 NOTIFY ipv4Changed) + Q_PROPERTY(QNetworkSettingsIPv6* ipv6 READ ipv6 NOTIFY ipv6Changed) + Q_PROPERTY(QNetworkSettingsProxy* proxy READ proxy NOTIFY proxyChanged) + Q_PROPERTY(QNetworkSettingsWireless* wirelessConfig READ wirelessConfig NOTIFY wirelessChanged) + Q_PROPERTY(QAbstractItemModel* domains READ domains NOTIFY domainsChanged) + Q_PROPERTY(QAbstractItemModel* nameservers READ nameservers NOTIFY nameserversChanged) +public: + explicit QNetworkSettingsService(const QString& aServiceId, QObject* parent = 0); + + QString id() const; + QString name() const; + QNetworkSettingsState::States state(); + QNetworkSettingsType::Types type(); + QNetworkSettingsIPv4* ipv4(); + QNetworkSettingsIPv6* ipv6(); + QNetworkSettingsProxy* proxy(); + QAbstractItemModel* domains(); + QAbstractItemModel* nameservers(); + QNetworkSettingsWireless* wirelessConfig(); + + Q_INVOKABLE void setAutoConnect(const bool autoconnect); + Q_INVOKABLE void setupIpv4Config(); + Q_INVOKABLE void setupIpv6Config(); + Q_INVOKABLE void setupNameserversConfig(); + Q_INVOKABLE void setupDomainsConfig(); + Q_INVOKABLE void setupNetworkSettingsProxy(); + //Wireless config + Q_INVOKABLE void connectService(); + Q_INVOKABLE void disconnectService(); +Q_SIGNALS: + void nameChanged(); + void stateChanged(); + void typeChanged(); + void proxyChanged(); + void ipv4Changed(); + void ipv6Changed(); + void domainsChanged(); + void nameserversChanged(); + void wirelessChanged(); + void showCrendentialInput(); +protected: + QNetworkSettingsServicePrivate *d_ptr; + + Q_DISABLE_COPY(QNetworkSettingsService) + Q_DECLARE_PRIVATE(QNetworkSettingsService) +}; + +#endif // QNETWORKSETTINGSSERVICE_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsservicemodel.cpp b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsservicemodel.cpp new file mode 100644 index 0000000..ff5406d --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsservicemodel.cpp @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qnetworksettingsservicemodel.h" +#include "qnetworksettings.h" + +QNetworkSettingsServiceModel::QNetworkSettingsServiceModel(QObject *parent) + : QAbstractListModel(parent) +{ + m_roleNames.insert(Qt::UserRole, "modelData"); + m_roleNames.insert(Name, "name"); + m_roleNames.insert(SignalStrength, "signalStrength"); + m_roleNames.insert(Connected, "connected"); +} + +QNetworkSettingsServiceModel::~QNetworkSettingsServiceModel() +{ + +} + +QHash QNetworkSettingsServiceModel::roleNames() const +{ + return m_roleNames; +} + + +int QNetworkSettingsServiceModel::rowCount(const QModelIndex & parent) const +{ + Q_UNUSED(parent); + return m_items.count(); +} + +QVariant QNetworkSettingsServiceModel::data(const QModelIndex & index, int role) const +{ + if (!index.isValid()) return QVariant(); + + QNetworkSettingsService *item = m_items[index.row()]; + if (role == Qt::UserRole) { + return QVariant::fromValue(static_cast(item)); + } + else if (role == Name) { + return item->name(); + } + else if (role == SignalStrength) { + return item->wirelessConfig()->signalStrength(); + } + else if (role == Connected) { + return item->state() == QNetworkSettingsState::Online || item->state() == QNetworkSettingsState::Ready; + } + return QVariant(); +} + +void QNetworkSettingsServiceModel::append(QNetworkSettingsService* item) +{ + item->setParent(this); + + beginInsertRows(QModelIndex(), rowCount(), rowCount()); + m_items.append(item); + endInsertRows(); +} + +void QNetworkSettingsServiceModel::insert(int row, QNetworkSettingsService* item) +{ + item->setParent(this); + + beginInsertRows(QModelIndex(), row, row); + m_items.insert(row, item); + endInsertRows(); +} + +QList QNetworkSettingsServiceModel::getModel() +{ + return m_items; +} + +//Filter model + +QNetworkSettingsServiceFilter::QNetworkSettingsServiceFilter(QObject* parent) + :QSortFilterProxyModel(parent) +{ + connect(this, &QNetworkSettingsServiceFilter::typeChanged, this, &QNetworkSettingsServiceFilter::invalidate); +} + +QNetworkSettingsServiceFilter::~QNetworkSettingsServiceFilter() +{ + +} + +QNetworkSettingsType::Types QNetworkSettingsServiceFilter::type() const +{ + return m_type; +} + +void QNetworkSettingsServiceFilter::setType(const QNetworkSettingsType::Types type) +{ + m_type = type; + emit typeChanged(); +} + +bool QNetworkSettingsServiceFilter::filterAcceptsRow( int source_row, const QModelIndex& source_parent ) const +{ + if (this->sourceModel()) + { + QModelIndex index = this->sourceModel()->index( source_row, 0, source_parent ); + if (index.isValid()) + { + if (index.isValid()) + { + QObject * obj = qvariant_cast(index.data(Qt::UserRole)); + QNetworkSettingsService * service = qobject_cast(obj); + if (service->type() == m_type) + return true; + } + } + } + return false; +} + +QVariant QNetworkSettingsServiceFilter::itemFromRow(const int row) const +{ + QModelIndex idx = index(row, 0); + QModelIndex mapped = mapToSource(idx); + if (mapped.isValid()) + { + QVariant serviceItem = mapped.data(Qt::UserRole); + if (serviceItem.isValid()) + { + return serviceItem; + } + } + return QVariant::fromValue(QString("")); +} diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsservicemodel.h b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsservicemodel.h new file mode 100644 index 0000000..0b520ef --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsservicemodel.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QNETWORKSETTINGSSERVICEMODEL_H +#define QNETWORKSETTINGSSERVICEMODEL_H + +#include +#include "qnetworksettings.h" +#include "qnetworksettingsservice.h" + +class QNetworkSettingsServiceModel : public QAbstractListModel +{ + Q_OBJECT +public: + explicit QNetworkSettingsServiceModel(QObject *parent=0); + virtual ~QNetworkSettingsServiceModel(); + // from QAbstractItemModel + int rowCount(const QModelIndex & parent = QModelIndex()) const; + QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; + QHash roleNames() const; + + void append(QNetworkSettingsService* networkService); + void insert(int row, QNetworkSettingsService* networkInterface); + QList getModel(); + + enum Roles { + Type = Qt::UserRole + 1, + Name, + SignalStrength, + Connected + }; + +private: + QList m_items; + QHash m_roleNames; +}; + +class QNetworkSettingsServiceFilter : public QSortFilterProxyModel +{ + Q_OBJECT + Q_PROPERTY(QNetworkSettingsType::Types type READ type WRITE setType NOTIFY typeChanged) +public: + explicit QNetworkSettingsServiceFilter(QObject* parent=0); + virtual ~QNetworkSettingsServiceFilter(); + bool filterAcceptsRow( int source_row, const QModelIndex& source_parent ) const override; + QNetworkSettingsType::Types type() const; + void setType(QNetworkSettingsType::Types type); + Q_INVOKABLE QVariant itemFromRow(const int row) const; +signals: + void typeChanged(); +private: + QNetworkSettingsType::Types m_type; + +}; + +#endif // QNETWORKSETTINGSSERVICEMODEL_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsuseragent.cpp b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsuseragent.cpp new file mode 100644 index 0000000..0e7b637 --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsuseragent.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qnetworksettingsuseragent.h" +#include "qnetworksettingsuseragent_p.h" + +QNetworkSettingsUserAgent::QNetworkSettingsUserAgent(QObject *parent) + :QObject(parent) + ,d_ptr(new QNetworkSettingsUserAgentPrivate(this)) +{ +} + +void QNetworkSettingsUserAgent::setUserCredentials(const QString& username, const QString& passphrase) +{ + Q_D(QNetworkSettingsUserAgent); + d->setUserCredentials(username, passphrase); +} + +void QNetworkSettingsUserAgent::cancelInput() +{ + Q_D(QNetworkSettingsUserAgent); + d->cancel(); +} diff --git a/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsuseragent.h b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsuseragent.h new file mode 100644 index 0000000..6f4dc22 --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/networksettings/qnetworksettingsuseragent.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QNETWORKSETTINGSUSERAGENT_H +#define QNETWORKSETTINGSUSERAGENT_H + +#include + +QT_FORWARD_DECLARE_CLASS(QNetworkSettingsUserAgentPrivate) + +class QNetworkSettingsUserAgent : public QObject +{ + Q_OBJECT +public: + explicit QNetworkSettingsUserAgent(QObject *parent = 0); + Q_INVOKABLE void setUserCredentials(const QString& username, const QString& passphrase); + Q_INVOKABLE void cancelInput(); +signals: + void showUserCredentialsInput(); + void error(); +private: + QNetworkSettingsUserAgentPrivate *d_ptr; + + Q_DISABLE_COPY(QNetworkSettingsUserAgent) + Q_DECLARE_PRIVATE(QNetworkSettingsUserAgent) +}; +#endif // QNETWORKSETTINGSUSERAGENT_H diff --git a/src/qtdevicesettings/networksettingsplugin/networksettingsplugin.pro b/src/qtdevicesettings/networksettingsplugin/networksettingsplugin.pro index c514393..1024f91 100644 --- a/src/qtdevicesettings/networksettingsplugin/networksettingsplugin.pro +++ b/src/qtdevicesettings/networksettingsplugin/networksettingsplugin.pro @@ -31,7 +31,12 @@ pluginfiles.files += \ imports/NetworkSettings/WifiSettings.qml \ imports/NetworkSettings/IpAddressTextField.qml \ imports/NetworkSettings/NetworkSettings.qml \ - imports/NetworkSettings/WiredSettings.qml + imports/NetworkSettings/WiredSettings.qml \ + imports/NetworkSettings/WifiSelectorDelegate.qml \ + imports/NetworkSettings/WifiSignalMonitor.qml \ + ../icons/WifiAnim_black_2x.png \ + ../icons/WifiAnim_qt_2x.png \ + ../icons/Wifi_lightgray_2x.png \ installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) diff --git a/src/qtdevicesettings/networksettingsplugin/networksettingsplugin_plugin.cpp b/src/qtdevicesettings/networksettingsplugin/networksettingsplugin_plugin.cpp index 684cef0..3480b56 100644 --- a/src/qtdevicesettings/networksettingsplugin/networksettingsplugin_plugin.cpp +++ b/src/qtdevicesettings/networksettingsplugin/networksettingsplugin_plugin.cpp @@ -34,11 +34,14 @@ ** ****************************************************************************/ #include "networksettingsplugin_plugin.h" -#include "networkconfig.h" -#include "networksettingsmanager.h" +#include "qnetworksettings.h" +#include "qnetworksettingsmanager.h" +#include "qnetworksettingsservice.h" +#include "qnetworksettingsuseragent.h" #include #include +#include template QObject *instance(QQmlEngine *engine, QJSEngine *) { @@ -50,12 +53,12 @@ QObject *instance(QQmlEngine *engine, QJSEngine *) { void NetworksettingspluginPlugin::registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("com.theqtcompany.settings.network")); - qmlRegisterUncreatableType(uri, 1, 0, "NetworkService", "Cannot be instantiated directly."); - qmlRegisterUncreatableType(uri, 1, 0, "IPv4Config", "Cannot be instantiated directly."); - qmlRegisterUncreatableType(uri, 1, 0, "IPv6Config", "Cannot be instantiated directly."); - qmlRegisterUncreatableType(uri, 1, 0, "ProxyConfig", "Cannot be instantiated directly."); - qmlRegisterUncreatableType(uri, 1, 0, "NetworkType", "Cannot be instantiated directly."); - qmlRegisterSingletonType(uri, 1, 0, "NetworkSettingsManager", &instance); + qmlRegisterUncreatableType(uri, 1, 0, "NetworkService", "Cannot be instantiated directly."); + qmlRegisterUncreatableType(uri, 1, 0, "NetworkSettingsIPv4", "Cannot be instantiated directly."); + qmlRegisterUncreatableType(uri, 1, 0, "NetworkSettingsIPv6", "Cannot be instantiated directly."); + qmlRegisterUncreatableType(uri, 1, 0, "NetworkSettingsProxy", "Cannot be instantiated directly."); + qmlRegisterUncreatableType(uri, 1, 0, "NetworkSettingsType", "Cannot be instantiated directly."); + qmlRegisterUncreatableType(uri, 1, 0, "NetworkSettingsState", "Cannot be instantiated directly."); + qmlRegisterSingletonType(uri, 1, 0, "NetworkSettingsManager", &instance); + qmlRegisterSingletonType(uri, 1, 0, "NetworkSettingsUserAgent", &instance); } - - diff --git a/src/qtdevicesettings/settingscomponents/imports/Settings/CustomCombobox.qml b/src/qtdevicesettings/settingscomponents/imports/Settings/CustomCombobox.qml index 72342e1..37c7871 100644 --- a/src/qtdevicesettings/settingscomponents/imports/Settings/CustomCombobox.qml +++ b/src/qtdevicesettings/settingscomponents/imports/Settings/CustomCombobox.qml @@ -144,7 +144,7 @@ Item { DelegateModel { id: comboboxModel - delegate: comboboxDelete + delegate: comboboxDelegate } Repeater { @@ -156,7 +156,7 @@ Item { } Component { - id: comboboxDelete + id: comboboxDelegate Item { id: comboboxViewDelegate property bool checked @@ -168,6 +168,7 @@ Item { sourceComponent: delegate anchors.fill: parent property var modelData: model + property string textRole: textRole onLoaded : exgroup.bindCheckable(item) } diff --git a/src/qtdevicesettings/settingscomponents/imports/Settings/FlatStyledDropdownDelegate.qml b/src/qtdevicesettings/settingscomponents/imports/Settings/FlatStyledDropdownDelegate.qml index ca68e16..c1bd24c 100644 --- a/src/qtdevicesettings/settingscomponents/imports/Settings/FlatStyledDropdownDelegate.qml +++ b/src/qtdevicesettings/settingscomponents/imports/Settings/FlatStyledDropdownDelegate.qml @@ -72,7 +72,7 @@ Item { anchors.bottom: parent.bottom anchors.margins: Math.round(10 * Flat.FlatStyle.scaleFactor) horizontalAlignment: Text.AlignLeft - text: modelData.text + text: modelData.name } } } diff --git a/src/qtdevicesettings/settingscomponents/imports/Settings/TextLabel.qml b/src/qtdevicesettings/settingscomponents/imports/Settings/TextLabel.qml index 176f848..e9f5d12 100644 --- a/src/qtdevicesettings/settingscomponents/imports/Settings/TextLabel.qml +++ b/src/qtdevicesettings/settingscomponents/imports/Settings/TextLabel.qml @@ -36,6 +36,7 @@ import QtQuick 2.5 import QtQuick.Layouts 1.1 import QtQuick.Controls 1.4 +import QtQuick.Controls.Styles.Flat 1.0 as Flat Text { color: systemPalette.text diff --git a/src/qtdevicesettings/timedateplugin/plugin.cpp b/src/qtdevicesettings/timedateplugin/plugin.cpp index 3fa4939..b092c2c 100644 --- a/src/qtdevicesettings/timedateplugin/plugin.cpp +++ b/src/qtdevicesettings/timedateplugin/plugin.cpp @@ -59,7 +59,6 @@ class TimeDateSettingsQmlPlugin : public QQmlExtensionPlugin public: void registerTypes(const char *uri) { - const QString prefix = "qrc:"; qmlRegisterSingletonType(uri, 1, 0, "TimeManager", &instance); } diff --git a/src/qtdevicesettings/wifisettingsplugin/WifiManagerView.qml b/src/qtdevicesettings/wifisettingsplugin/WifiManagerView.qml deleted file mode 100644 index 71115d5..0000000 --- a/src/qtdevicesettings/wifisettingsplugin/WifiManagerView.qml +++ /dev/null @@ -1,180 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Layouts 1.1 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles.Flat 1.0 as Flat -import com.theqtcompany.settings.common 1.0 -import com.theqtcompany.settings.wifi 1.0 -import B2Qt.Wifi 1.0 - -Item { - id: root - Component.onCompleted: { - if (WifiManager.backendState === WifiManager.NotRunning) { - WifiManager.start(); - } - else if (WifiManager.backendState == WifiManager.Running) { - WifiManager.scanning = true; - } - } - - WifiConfiguration { - id: config - property bool connected: WifiManager.networkState === WifiManager.Connected - } - - ColumnLayout { - id: content - anchors.fill: parent - - Row { - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - - TextLabel { - text: qsTr("Selected network ") - width: root.width*0.382 - horizontalAlignment: Text.AlignRight - } - - CustomCombobox { - id: networkSelection - model: WifiManager.networks - width: Math.round(200 * Flat.FlatStyle.scaleFactor) - textRole: "ssid" - Component.onCompleted: { - setSelectIndexToVal(WifiManager.currentSSID, "ssid"); - } - onSelectedIndexChanged : { - var ssid = networkSelection.textValue; - config.ssid = ssid; - if (WifiManager.currentSSID !== ssid || !config.connected) { - connectView.visible = true; - } - } - delegate: WifiSelectorDelegate { } - } - - Image { - id: warning - anchors.verticalCenter: parent.verticalCenter - source: "../icons/Alert_yellow_1x.png" - visible: WifiManager.state === WifiManager.HandshakeFailed || - WifiManager.state === WifiManager.DhcpRequestFailed - } - } - - Button { - id: disconnect - text: qsTr("Disconnect") - visible: config.connected - onClicked: { - WifiManager.disconnect(); - networkSelection.currentIndex = -1; - } - } - - GroupBox { - id: connectView - title: qsTr("Enter a password") - flat: false - visible: false - ColumnLayout { - Row { - id: errorView - property alias text: text.text - visible: text.text !== "" - - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - Image { - source: "../icons/Alert_yellow_1x.png" - } - Text { - id: text - color: "#face20" - text: "" - } - } - Row { - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - visible: false - TextLabel { - text: qsTr("User name") - width: root.width*0.382 - horizontalAlignment: Text.AlignRight - } - TextField { - text: "" - inputMethodHints: Qt.ImhNoPredictiveText - } - } - Row { - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - TextLabel { - text: qsTr("Password") - horizontalAlignment: Text.AlignRight - } - TextField { - id: password - text: "" - echoMode: TextInput.Password - inputMethodHints: Qt.ImhNoPredictiveText - } - } - Row { - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - Button { - text: qsTr("Connect") - onClicked: { - config.passphrase = password.text - if (!WifiManager.connect(config)) { - print("failed to connect: " + WifiManager.lastError) - errorView.text = qsTr("Invalid password"); - } - else { - connectView.visible = false - } - } - } - Button { - text: qsTr("Cancel") - onClicked:connectView.visible = false - } - } - } - } - } -} diff --git a/src/qtdevicesettings/wifisettingsplugin/WifiSelectorDelegate.qml b/src/qtdevicesettings/wifisettingsplugin/WifiSelectorDelegate.qml deleted file mode 100644 index cea3750..0000000 --- a/src/qtdevicesettings/wifisettingsplugin/WifiSelectorDelegate.qml +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Layouts 1.1 -import QtQuick.Controls 1.4 -import com.theqtcompany.settings.common 1.0 -import com.theqtcompany.settings.wifi 1.0 - -Item { - id: root - property bool checkable: true - property bool checked: false - property bool pressed: false - signal clicked() - - MouseArea { - id: delegateButton - anchors.fill: parent - hoverEnabled: true - onPressed: root.pressed = true - onClicked: root.clicked() - onEntered: checked = !checked - - Rectangle { - anchors.fill: parent - color: root.checked ? Flat.FlatStyle.disabledColor : "transparent" - opacity: root.checked ? 0.15 : 1.0 - } - Rectangle { - color: Flat.FlatStyle.darkFrameColor - width: parent.width - height: Flat.FlatStyle.onePixel - anchors.bottom: parent.bottom - } - TextLabel { - id: text - anchors.left: parent.left - anchors.right: parent.right - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.margins: Math.round(10 * Flat.FlatStyle.scaleFactor) - horizontalAlignment: Text.AlignLeft - text: modelData["ssid"] - } - WifiSignalMonitor { - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.margins: Math.round(10 * Flat.FlatStyle.scaleFactor) - height: Math.round(parent.height * .8) - width: height - signalStrength: modelData["signalStrength"] - } - } -} diff --git a/src/qtdevicesettings/wifisettingsplugin/WifiSignalMonitor.qml b/src/qtdevicesettings/wifisettingsplugin/WifiSignalMonitor.qml deleted file mode 100644 index e3ab0c8..0000000 --- a/src/qtdevicesettings/wifisettingsplugin/WifiSignalMonitor.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.5 - -Item { - id: root - - property bool scanning: false - property int signalStrength: 100 - property bool connected: false - - onSignalStrengthChanged: { - sprite.visible = true; - - if (signalStrength < 10) { - sprite.visible = false; - } - else if (signalStrength < 30) { - sprite.currentFrame = 0; - } - else if (signalStrength < 60) { - sprite.currentFrame = 1; - } - else if (signalStrength < 80) { - sprite.currentFrame = 2; - } - else if (signalStrength <= 100) { - sprite.currentFrame = 3; - } - } - - Image { - anchors.fill: parent - source: "../icons/Wifi_lightgray_2x.png" - } - - AnimatedSprite { - id: sprite - anchors.fill: parent - source: connected ? "../icons/WifiAnim_qt_2x.png" : "../icons/WifiAnim_black_2x.png" - frameDuration: 500 - frameCount: 4 - currentFrame: 3 - frameSync: false - frameWidth: 32 - frameHeight: 32 - loops: 40 - running: scanning - } -} diff --git a/src/qtdevicesettings/wifisettingsplugin/icons.qrc b/src/qtdevicesettings/wifisettingsplugin/icons.qrc deleted file mode 100644 index ac67804..0000000 --- a/src/qtdevicesettings/wifisettingsplugin/icons.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - ../icons/Wifi_lightgray_2x.png - ../icons/WifiAnim_black_2x.png - ../icons/Alert_yellow_1x.png - - diff --git a/src/qtdevicesettings/wifisettingsplugin/plugin.cpp b/src/qtdevicesettings/wifisettingsplugin/plugin.cpp deleted file mode 100644 index c87f68a..0000000 --- a/src/qtdevicesettings/wifisettingsplugin/plugin.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - -class WifiSettingsQmlPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") - -public: - void registerTypes(const char *uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("com.theqtcompany.settings.wifi")); - const QString prefix = "qrc:"; - qmlRegisterType(QUrl(prefix + "WifiManagerView.qml"), uri, 1, 0, "WifiManagerView"); - qmlRegisterType(QUrl(prefix + "WifiSignalMonitor.qml"), uri, 1, 0, "WifiSignalMonitor"); - qmlRegisterType(QUrl(prefix + "WifiSelectorDelegate.qml"), uri, 1, 0, "WifiSelectorDelegate"); - - } -}; - -#include "plugin.moc" diff --git a/src/qtdevicesettings/wifisettingsplugin/qml.qrc b/src/qtdevicesettings/wifisettingsplugin/qml.qrc deleted file mode 100644 index b43e801..0000000 --- a/src/qtdevicesettings/wifisettingsplugin/qml.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - WifiManagerView.qml - WifiSignalMonitor.qml - WifiSelectorDelegate.qml - - diff --git a/src/qtdevicesettings/wifisettingsplugin/qmldir b/src/qtdevicesettings/wifisettingsplugin/qmldir deleted file mode 100644 index d5c237e..0000000 --- a/src/qtdevicesettings/wifisettingsplugin/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -module com.theqtcompany.settings.wifi -plugin qmlwifiplugin diff --git a/src/qtdevicesettings/wifisettingsplugin/wifisettingsplugin.pro b/src/qtdevicesettings/wifisettingsplugin/wifisettingsplugin.pro deleted file mode 100644 index aa50429..0000000 --- a/src/qtdevicesettings/wifisettingsplugin/wifisettingsplugin.pro +++ /dev/null @@ -1,26 +0,0 @@ -TEMPLATE = lib -CONFIG += plugin -QT += qml - -uri = com.theqtcompany.settings.wifi - -DESTDIR = imports/Wifi -TARGET = qmlwifiplugin - -SOURCES += plugin.cpp - -pluginfiles.files += \ - qmldir \ - -installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) - -target.path = $$installPath -pluginfiles.path += $$installPath -INSTALLS += target pluginfiles - - -RESOURCES += \ - icons.qrc \ - qml.qrc - -HEADERS += -- cgit v1.2.3