forked from nemomobile/libconnman-qt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lorn Potter
committed
Dec 21, 2012
1 parent
8e08ecc
commit 8127255
Showing
5 changed files
with
142 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright © 2012, Jolla. | ||
* | ||
* This program is licensed under the terms and conditions of the | ||
* Apache License, version 2.0. The full text of the Apache License is at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
*/ | ||
|
||
#include <QtDBus/QDBusConnection> | ||
|
||
#include "counter.h" | ||
|
||
static const char COUNTER_PATH[] = "/ConnectivityCounter"; | ||
|
||
Counter::Counter(QObject *parent) : | ||
QObject(parent), | ||
m_manager(NetworkManagerFactory::createInstance()) | ||
{ | ||
new CounterAdaptor(this); | ||
QDBusConnection::systemBus().registerObject(COUNTER_PATH, this); | ||
|
||
if (m_manager->isAvailable()) { | ||
m_manager->registerCounter(QString(COUNTER_PATH),1024,5); | ||
} | ||
} | ||
|
||
Counter::~Counter() | ||
{ | ||
} | ||
|
||
void Counter::serviceUsage(const QString &servicePath, const QVariantMap &counters, bool roaming) | ||
{ | ||
Q_EMIT counterChanged(servicePath, counters, roaming); | ||
} | ||
|
||
|
||
CounterAdaptor::CounterAdaptor(Counter* parent) | ||
: QDBusAbstractAdaptor(parent), | ||
m_counter(parent) | ||
{ | ||
} | ||
|
||
CounterAdaptor::~CounterAdaptor() | ||
{ | ||
} | ||
|
||
void CounterAdaptor::Release() | ||
{ | ||
} | ||
|
||
void CounterAdaptor::Usage(const QDBusObjectPath &service_path, | ||
const QVariantMap &home, | ||
const QVariantMap &roaming) | ||
{ | ||
if (roaming.isEmpty()) { | ||
// home | ||
m_counter->serviceUsage(service_path.path(), home, false); | ||
} else { | ||
//roaming | ||
m_counter->serviceUsage(service_path.path(), roaming, true); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright © 2012, Jolla. | ||
* | ||
* This program is licensed under the terms and conditions of the | ||
* Apache License, version 2.0. The full text of the Apache License is at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
*/ | ||
|
||
#ifndef COUNTER_H | ||
#define COUNTER_H | ||
|
||
#include <QObject> | ||
#include <QVariantMap> | ||
#include <QtDBus/QDBusAbstractAdaptor> | ||
#include <QtDBus/QDBusObjectPath> | ||
|
||
#include <networkmanager.h> | ||
|
||
class Counter : public QObject | ||
{ | ||
Q_OBJECT | ||
Q_DISABLE_COPY(Counter) | ||
public: | ||
explicit Counter(/*const QString &serviceName, */QObject *parent = 0); | ||
virtual ~Counter(); | ||
|
||
void serviceUsage(const QString &servicePath, const QVariantMap &counters, bool roaming); | ||
|
||
signals: | ||
// void usage | ||
void counterChanged(const QString servicePath, const QVariantMap &counters, bool roaming); | ||
|
||
public slots: | ||
|
||
private: | ||
NetworkManager* m_manager; | ||
}; | ||
|
||
|
||
class CounterAdaptor : public QDBusAbstractAdaptor | ||
{ | ||
Q_OBJECT; | ||
Q_CLASSINFO("D-Bus Interface", "net.connman.Counter"); | ||
|
||
public: | ||
explicit CounterAdaptor(Counter* parent); | ||
virtual ~CounterAdaptor(); | ||
|
||
public slots: | ||
void Release(); | ||
void Usage(const QDBusObjectPath &service_path, | ||
const QVariantMap &home, | ||
const QVariantMap &roaming); | ||
|
||
private: | ||
Counter* m_counter; | ||
friend class CounterAdaptor; | ||
}; | ||
#endif // COUNTER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters