Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.2
plasma-nm5
0001-Revert-Use-NetworkManager-DeviceStatistics...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Revert-Use-NetworkManager-DeviceStatistics-instead-o.patch of Package plasma-nm5
From 32794c88fb625e896458764a121b4c1f9e5117ee Mon Sep 17 00:00:00 2001 From: Wolfgang Bauer <wbauer@tmo.at> Date: Sun, 16 Sep 2018 09:23:22 +0200 Subject: [PATCH] Revert "Use NetworkManager::DeviceStatistics instead of Plasma data engine" This reverts commit 36dd019c98107cf1f1155988915841048b607c1b to make the speed graph work again with NetworkManager 1.0 on Leap 42. The new code depends on NM 1.4.0 or higher, and would not show any traffic with earlier NM versions. --- applet/contents/ui/ConnectionItem.qml | 33 ++++++++++++++++++------------- applet/contents/ui/TrafficMonitor.qml | 37 ++++++++++++++++------------------- libs/models/networkmodel.cpp | 29 --------------------------- libs/models/networkmodel.h | 5 +---- libs/models/networkmodelitem.cpp | 24 ----------------------- libs/models/networkmodelitem.h | 8 -------- 6 files changed, 37 insertions(+), 99 deletions(-) diff --git a/applet/contents/ui/ConnectionItem.qml b/applet/contents/ui/ConnectionItem.qml index 3e5af365..e661338b 100644 --- a/applet/contents/ui/ConnectionItem.qml +++ b/applet/contents/ui/ConnectionItem.qml @@ -34,8 +34,7 @@ PlasmaComponents.ListItem { property bool predictableWirelessPassword: !Uuid && Type == PlasmaNM.Enums.Wireless && (SecurityType == PlasmaNM.Enums.StaticWep || SecurityType == PlasmaNM.Enums.WpaPsk || SecurityType == PlasmaNM.Enums.Wpa2Psk) - property bool showSpeed: plasmoid.expanded && - ConnectionState == PlasmaNM.Enums.Activated && + property bool showSpeed: ConnectionState == PlasmaNM.Enums.Activated && (Type == PlasmaNM.Enums.Wired || Type == PlasmaNM.Enums.Wireless || Type == PlasmaNM.Enums.Gsm || @@ -47,6 +46,17 @@ PlasmaComponents.ListItem { enabled: true height: expanded ? baseHeight + separator.height + expandableComponentLoader.height + (2 * Math.round(units.gridUnit / 3)) : baseHeight + PlasmaCore.DataSource { + id: dataSource + + property string downloadSource: "network/interfaces/" + DeviceName + "/receiver/data" + property string uploadSource: "network/interfaces/" + DeviceName + "/transmitter/data" + + connectedSources: showSpeed && plasmoid.expanded ? [downloadSource, uploadSource] : [] + engine: "systemmonitor" + interval: 2000 + } + ColumnLayout { anchors.fill: parent @@ -149,7 +159,7 @@ PlasmaComponents.ListItem { top: parent.top } height: visible ? implicitHeight : 0 - visible: showSpeed + visible: showSpeed && dataSource.data && dataSource.data[dataSource.downloadSource] && dataSource.data[dataSource.uploadSource] PlasmaComponents.TabButton { id: speedTabButton @@ -187,9 +197,8 @@ PlasmaComponents.ListItem { top: detailsTabBar.visible ? detailsTabBar.bottom : parent.top topMargin: Math.round(units.gridUnit / 3) } - rxBytes: RxBytes - txBytes: TxBytes - interval: 2000 + dataEngine: dataSource + deviceName: DeviceName visible: detailsTabBar.currentTab == speedTabButton } } @@ -304,26 +313,22 @@ PlasmaComponents.ListItem { result += ", " + SecurityTypeString return result } else if (ConnectionState == PlasmaNM.Enums.Activated) { - if (showSpeed) { + if (showSpeed && dataSource.data && dataSource.data[dataSource.downloadSource] && dataSource.data[dataSource.uploadSource]) { var downloadColor = theme.highlightColor // cycle upload color by 180 degrees var uploadColor = Qt.hsva((downloadColor.hsvHue + 0.5) % 1, downloadColor.hsvSaturation, downloadColor.hsvValue, downloadColor.a) return i18n("Connected, <font color='%1'>⬇</font> %2/s, <font color='%3'>⬆</font> %4/s", downloadColor, - KCoreAddons.Format.formatByteSize(RxBytes), + KCoreAddons.Format.formatByteSize(dataSource.data[dataSource.downloadSource].value * 1024 || 0), uploadColor, - KCoreAddons.Format.formatByteSize(TxBytes)) + KCoreAddons.Format.formatByteSize(dataSource.data[dataSource.uploadSource].value * 1024 || 0)) } else { return i18n("Connected") } } } - onShowSpeedChanged: { - connectionModel.setDeviceStatisticsRefreshRateMs(DevicePath, showSpeed ? 2000 : 0) - } - onActivatingChanged: { if (ConnectionState == PlasmaNM.Enums.Activating) { ListView.view.positionViewAtBeginning() diff --git a/applet/contents/ui/TrafficMonitor.qml b/applet/contents/ui/TrafficMonitor.qml index 636b9bce..e9ee4207 100644 --- a/applet/contents/ui/TrafficMonitor.qml +++ b/applet/contents/ui/TrafficMonitor.qml @@ -24,9 +24,8 @@ import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons import org.kde.plasma.components 2.0 as PlasmaComponents Item { - property real rxBytes: 0 - property real txBytes: 0 - property alias interval: timer.interval + property QtObject dataEngine: null + property string deviceName height: visible ? plotter.height + units.gridUnit : 0 @@ -42,7 +41,7 @@ Item { height: paintedHeight font.pointSize: theme.smallestFont.pointSize lineHeight: 1.75 - text: KCoreAddons.Format.formatByteSize(plotter.maxValue * (1 - index / 5)) + i18n("/s") + text: KCoreAddons.Format.formatByteSize((plotter.maxValue * 1024) * (1 - index / 5)) } } @@ -76,22 +75,20 @@ Item { } ] - Timer { - id: timer - repeat: true - running: parent.visible - property real prevRxBytes - property real prevTxBytes - Component.onCompleted: { - prevRxBytes = rxBytes - prevTxBytes = txBytes - } - onTriggered: { - var rxSpeed = (rxBytes - prevRxBytes) * 1000 / interval - var txSpeed = (txBytes - prevTxBytes) * 1000 / interval - prevRxBytes = rxBytes - prevTxBytes = txBytes - plotter.addSample([rxSpeed, txSpeed]); + Connections { + target: dataEngine; + onNewData: { + if (sourceName.indexOf("network/interfaces/" + deviceName) != 0) { + return; + } + var rx = dataEngine.data[dataEngine.downloadSource]; + var tx = dataEngine.data[dataEngine.uploadSource]; + if (rx === undefined || rx.value === undefined || + tx === undefined || tx.value === undefined) { + return; + } + + plotter.addSample([rx.value, tx.value]); } } } diff --git a/libs/models/networkmodel.cpp b/libs/models/networkmodel.cpp index e4b0f73e..d494081e 100644 --- a/libs/models/networkmodel.cpp +++ b/libs/models/networkmodel.cpp @@ -106,10 +106,6 @@ QVariant NetworkModel::data(const QModelIndex &index, int role) const return item->vpnState(); case VpnType: return item->vpnType(); - case RxBytesRole: - return item->rxBytes(); - case TxBytesRole: - return item->txBytes(); default: break; } @@ -153,8 +149,6 @@ QHash<int, QByteArray> NetworkModel::roleNames() const roles[UuidRole] = "Uuid"; roles[VpnState] = "VpnState"; roles[VpnType] = "VpnType"; - roles[RxBytesRole] = "RxBytes"; - roles[TxBytesRole] = "TxBytes"; return roles; } @@ -216,20 +210,6 @@ void NetworkModel::initializeSignals(const NetworkManager::Device::Ptr &device) connect(device.data(), &NetworkManager::Device::ipInterfaceChanged, this, &NetworkModel::ipInterfaceChanged); connect(device.data(), &NetworkManager::Device::stateChanged, this, &NetworkModel::deviceStateChanged, Qt::UniqueConnection); - auto deviceStatistics = device->deviceStatistics(); - connect(deviceStatistics.data(), &NetworkManager::DeviceStatistics::rxBytesChanged, this, [this, device](qulonglong rxBytes) { - for (auto *item : m_list.returnItems(NetworkItemsList::Device, device->uni())) { - item->setRxBytes(rxBytes); - updateItem(item); - } - }); - connect(deviceStatistics.data(), &NetworkManager::DeviceStatistics::txBytesChanged, this, [this, device](qulonglong txBytes) { - for (auto *item : m_list.returnItems(NetworkItemsList::Device, device->uni())) { - item->setTxBytes(txBytes); - updateItem(item); - } - }); - if (device->type() == NetworkManager::Device::Wifi) { NetworkManager::WirelessDevice::Ptr wifiDev = device.objectCast<NetworkManager::WirelessDevice>(); connect(wifiDev.data(), &NetworkManager::WirelessDevice::networkAppeared, this, &NetworkModel::wirelessNetworkAppeared, Qt::UniqueConnection); @@ -533,15 +513,6 @@ void NetworkModel::onItemUpdated() } } -void NetworkModel::setDeviceStatisticsRefreshRateMs(const QString &devicePath, uint refreshRate) -{ - NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(devicePath); - - if (device) { - device->deviceStatistics()->setRefreshRateMs(refreshRate); - } -} - void NetworkModel::updateItem(NetworkModelItem*item) { const int row = m_list.indexOf(item); diff --git a/libs/models/networkmodel.h b/libs/models/networkmodel.h index b8598547..6f980383 100644 --- a/libs/models/networkmodel.h +++ b/libs/models/networkmodel.h @@ -67,9 +67,7 @@ public: UniRole, UuidRole, VpnState, - VpnType, - RxBytesRole, - TxBytesRole + VpnType }; int rowCount(const QModelIndex &parent) const override; @@ -78,7 +76,6 @@ public: public Q_SLOTS: void onItemUpdated(); - void setDeviceStatisticsRefreshRateMs(const QString &devicePath, uint refreshRate); private Q_SLOTS: void accessPointSignalStrengthChanged(int signal); diff --git a/libs/models/networkmodelitem.cpp b/libs/models/networkmodelitem.cpp index 17c84108..8106644c 100644 --- a/libs/models/networkmodelitem.cpp +++ b/libs/models/networkmodelitem.cpp @@ -62,8 +62,6 @@ NetworkModelItem::NetworkModelItem(QObject *parent) , m_slave(false) , m_type(NetworkManager::ConnectionSettings::Unknown) , m_vpnState(NetworkManager::VpnConnection::Unknown) - , m_rxBytes(0) - , m_txBytes(0) { } @@ -82,8 +80,6 @@ NetworkModelItem::NetworkModelItem(const NetworkModelItem *item, QObject *parent , m_type(item->type()) , m_uuid(item->uuid()) , m_vpnState(NetworkManager::VpnConnection::Unknown) - , m_rxBytes(0) - , m_txBytes(0) { } @@ -412,26 +408,6 @@ void NetworkModelItem::setVpnType(const QString &type) m_vpnType = type; } -qulonglong NetworkModelItem::rxBytes() const -{ - return m_rxBytes; -} - -void NetworkModelItem::setRxBytes(qulonglong bytes) -{ - m_rxBytes = bytes; -} - -qulonglong NetworkModelItem::txBytes() const -{ - return m_txBytes; -} - -void NetworkModelItem::setTxBytes(qulonglong bytes) -{ - m_txBytes = bytes; -} - bool NetworkModelItem::operator==(const NetworkModelItem *item) const { if (!item->uuid().isEmpty() && !uuid().isEmpty()) { diff --git a/libs/models/networkmodelitem.h b/libs/models/networkmodelitem.h index 0f4f4209..ff1496f9 100644 --- a/libs/models/networkmodelitem.h +++ b/libs/models/networkmodelitem.h @@ -108,12 +108,6 @@ public: QString vpnType() const; void setVpnType(const QString &type); - qulonglong rxBytes() const; - void setRxBytes(qulonglong bytes); - - qulonglong txBytes() const; - void setTxBytes(qulonglong bytes); - bool operator==(const NetworkModelItem *item) const; public Q_SLOTS: @@ -143,8 +137,6 @@ private: QString m_uuid; QString m_vpnType; NetworkManager::VpnConnection::State m_vpnState; - qulonglong m_rxBytes; - qulonglong m_txBytes; }; #endif // PLASMA_NM_MODEL_NETWORK_MODEL_ITEM_H -- 2.13.7
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor