From 3b5ab907e49e6d186a7a89dfb9b016ba3bd1301b Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Fri, 28 Dec 2012 15:03:04 +1000 Subject: [PATCH] re-add counter API and fix up a bit --- libconnman-qt/counter.cpp | 8 +++++++- libconnman-qt/counter.h | 11 +++++++++-- libconnman-qt/libconnman-qt.pro | 6 ++++-- libconnman-qt/useragent.cpp | 1 + 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/libconnman-qt/counter.cpp b/libconnman-qt/counter.cpp index 0dce613..f19d3a9 100644 --- a/libconnman-qt/counter.cpp +++ b/libconnman-qt/counter.cpp @@ -31,9 +31,15 @@ Counter::~Counter() void Counter::serviceUsage(const QString &servicePath, const QVariantMap &counters, bool roaming) { + latestCounts.insert(servicePath, counters); Q_EMIT counterChanged(servicePath, counters, roaming); } +QVariantMap Counter::latestStats(const QString &servicePath) +{ + return latestCounts[servicePath]; +} + CounterAdaptor::CounterAdaptor(Counter* parent) : QDBusAbstractAdaptor(parent), @@ -56,7 +62,7 @@ void CounterAdaptor::Usage(const QDBusObjectPath &service_path, if (roaming.isEmpty()) { // home m_counter->serviceUsage(service_path.path(), home, false); - } else { + } else if (home.isEmpty()) { //roaming m_counter->serviceUsage(service_path.path(), roaming, true); } diff --git a/libconnman-qt/counter.h b/libconnman-qt/counter.h index 313b6b8..28bc16d 100644 --- a/libconnman-qt/counter.h +++ b/libconnman-qt/counter.h @@ -22,19 +22,26 @@ class Counter : public QObject Q_OBJECT Q_DISABLE_COPY(Counter) public: - explicit Counter(/*const QString &serviceName, */QObject *parent = 0); + explicit Counter(QObject *parent = 0); virtual ~Counter(); void serviceUsage(const QString &servicePath, const QVariantMap &counters, bool roaming); + void secondsOnline(const QString &servicePath); + QVariantMap latestStats(const QString &servicePath); + QPair latestBytes(const QString &servicePath); signals: - // void usage + // "RX.Bytes", "RX.Packets" + // "TX.Bytes", "TX.Packets" + // "Time" void counterChanged(const QString servicePath, const QVariantMap &counters, bool roaming); public slots: private: NetworkManager* m_manager; + QMap latestCounts; + }; diff --git a/libconnman-qt/libconnman-qt.pro b/libconnman-qt/libconnman-qt.pro index 650bcff..2ae254f 100644 --- a/libconnman-qt/libconnman-qt.pro +++ b/libconnman-qt/libconnman-qt.pro @@ -31,7 +31,8 @@ HEADERS += manager.h \ useragent.h \ session.h \ sessionagent.h \ - networksession.h + networksession.h \ + counter.h SOURCES += \ networkmanager.cpp \ @@ -47,7 +48,8 @@ SOURCES += \ useragent.cpp \ session.cpp \ sessionagent.cpp \ - networksession.cpp + networksession.cpp \ + counter.cpp target.path = $$INSTALL_ROOT$$PREFIX/lib diff --git a/libconnman-qt/useragent.cpp b/libconnman-qt/useragent.cpp index 2dfb3b7..f70ad3c 100644 --- a/libconnman-qt/useragent.cpp +++ b/libconnman-qt/useragent.cpp @@ -21,6 +21,7 @@ UserAgent::UserAgent(QObject* parent) : QDBusConnection::systemBus().registerObject(AGENT_PATH, this); if (m_manager->isAvailable()) { + m_manager->unregisterAgent(QString(AGENT_PATH)); m_manager->registerAgent(QString(AGENT_PATH)); } connect(m_manager, SIGNAL(availabilityChanged(bool)),