summaryrefslogtreecommitdiffstats
path: root/src/plugins/bearer/networkmanager
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-02-08 00:45:09 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-02-08 07:49:05 (GMT)
commit5096692696b18df82914fc1f63597e00c24fa5d2 (patch)
tree69ee5d57422e17f83a2aeb573c5b24ff62eca0f8 /src/plugins/bearer/networkmanager
parent10628947d5ab1cfcd571ada10c0eab4b7f1f02ac (diff)
downloadQt-5096692696b18df82914fc1f63597e00c24fa5d2.zip
Qt-5096692696b18df82914fc1f63597e00c24fa5d2.tar.gz
Qt-5096692696b18df82914fc1f63597e00c24fa5d2.tar.bz2
Remove remaining Network Manager ifdef'ed code from common code.
Diffstat (limited to 'src/plugins/bearer/networkmanager')
-rw-r--r--src/plugins/bearer/networkmanager/networkmanager.pro2
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp61
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.h4
3 files changed, 65 insertions, 2 deletions
diff --git a/src/plugins/bearer/networkmanager/networkmanager.pro b/src/plugins/bearer/networkmanager/networkmanager.pro
index 5bac121..bf0d29a 100644
--- a/src/plugins/bearer/networkmanager/networkmanager.pro
+++ b/src/plugins/bearer/networkmanager/networkmanager.pro
@@ -3,8 +3,6 @@ include(../../qpluginbase.pri)
QT += network dbus
-DEFINES += BACKEND_NM
-
HEADERS += qnmdbushelper.h \
qnetworkmanagerservice.h \
qnetworkmanagerengine.h \
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
index 2c550f0..9a9bdad 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
@@ -680,6 +680,67 @@ QNetworkSession::State QNetworkManagerEngine::sessionStateForId(const QString &i
return QNetworkSession::Invalid;
}
+quint64 QNetworkManagerEngine::bytesWritten(const QString &id)
+{
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+ if (ptr && (ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
+ const QString networkInterface = getInterfaceFromId(id);
+ if (!networkInterface.isEmpty()) {
+ const QString devFile = QLatin1String("/sys/class/net/") +
+ networkInterface +
+ QLatin1String("/statistics/tx_bytes");
+
+ quint64 result = Q_UINT64_C(0);
+
+ QFile tx(devFile);
+ if (tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QTextStream in(&tx);
+ in >> result;
+ tx.close();
+ }
+
+ return result;
+ }
+ }
+
+ return Q_UINT64_C(0);
+}
+
+quint64 QNetworkManagerEngine::bytesReceived(const QString &id)
+{
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+ if (ptr && (ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
+ const QString networkInterface = getInterfaceFromId(id);
+ if (!networkInterface.isEmpty()) {
+ const QString devFile = QLatin1String("/sys/class/net/") +
+ networkInterface +
+ QLatin1String("/statistics/rx_bytes");
+
+ quint64 result = Q_UINT64_C(0);
+
+ QFile tx(devFile);
+ if (tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QTextStream in(&tx);
+ in >> result;
+ tx.close();
+ }
+
+ return result;
+ }
+ }
+
+ return Q_UINT64_C(0);
+}
+
+quint64 QNetworkManagerEngine::startTime(const QString &id)
+{
+ QNetworkManagerSettingsConnection *connection = connectionFromId(id);
+ if (connection)
+ return connection->getTimestamp();
+ else
+ return Q_UINT64_C(0);
+}
+
QNetworkConfigurationManager::Capabilities QNetworkManagerEngine::capabilities() const
{
return QNetworkConfigurationManager::ForcedRoaming |
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
index 848f166..70efc05 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
@@ -82,6 +82,10 @@ public:
QNetworkSession::State sessionStateForId(const QString &id);
+ quint64 bytesWritten(const QString &id);
+ quint64 bytesReceived(const QString &id);
+ quint64 startTime(const QString &id);
+
QNetworkConfigurationManager::Capabilities capabilities() const;
QNetworkSessionPrivate *createSessionBackend();