Skip to content

Commit

Permalink
re-add counter API and fix up a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorn Potter committed Dec 28, 2012
1 parent b43af37 commit 3b5ab90
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
8 changes: 7 additions & 1 deletion libconnman-qt/counter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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);
}
Expand Down
11 changes: 9 additions & 2 deletions libconnman-qt/counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <quint32, quint32> 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 <QString,QVariantMap> latestCounts;

};


Expand Down
6 changes: 4 additions & 2 deletions libconnman-qt/libconnman-qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ HEADERS += manager.h \
useragent.h \
session.h \
sessionagent.h \
networksession.h
networksession.h \
counter.h

SOURCES += \
networkmanager.cpp \
Expand All @@ -47,7 +48,8 @@ SOURCES += \
useragent.cpp \
session.cpp \
sessionagent.cpp \
networksession.cpp
networksession.cpp \
counter.cpp


target.path = $$INSTALL_ROOT$$PREFIX/lib
Expand Down
1 change: 1 addition & 0 deletions libconnman-qt/useragent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down

0 comments on commit 3b5ab90

Please sign in to comment.