I have made the following changes intended for :
  CE:MW:Shared / connman-qt

Please review and accept or decline.
BOSS has already run some checks on this request.
See the "Messages from BOSS" section below.

https://build.pub.meego.com//request/show/7583

Thank You,
rojkov

[This message was auto-generated]

---

Request # 7583:

Messages from BOSS:

State: review at 2012-12-28T11:54:48 by bossbot

Reviews:
       accepted by bossbot : Prechecks succeeded.
       new for CE-maintainers : Please replace this text with a review and 
approve/reject the review (not the SR). BOSS will take care of the rest

Changes:
  submit: home:rojkov:branches:CE:MW:Shared / connman-qt -> CE:MW:Shared / 
connman-qt
  
changes files:
--------------
--- connman-qt.changes
+++ connman-qt.changes
@@ -0,0 +1,5 @@
+* Fri Dec 28 2012 Dmitry Rozhkov <[email protected]> - 0.4.0
+- Added Counter API
+- Added Session API
+- networkservice: added error property
+

old:
----
  connman-qt-0.3.5.tar.bz2

new:
----
  connman-qt-0.4.0.tar.bz2

spec files:
-----------
--- connman-qt.spec
+++ connman-qt.spec
@@ -9,7 +9,7 @@
 # << macros
 
 Summary:    qt bindings for connman
-Version:    0.3.5
+Version:    0.4.0
 Release:    1
 Group:      System/GUI/Other
 License:    Apache License

other changes:
--------------

++++++ connman-qt-0.3.5.tar.bz2 -> connman-qt-0.4.0.tar.bz2
--- libconnman-qt/counter.cpp
+++ libconnman-qt/counter.cpp
@@ -0,0 +1,70 @@
+/*
+ * 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)
+{
+    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),
+    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 if (home.isEmpty()) {
+        //roaming
+        m_counter->serviceUsage(service_path.path(), roaming, true);
+    }
+}
+
--- libconnman-qt/counter.h
+++ libconnman-qt/counter.h
@@ -0,0 +1,67 @@
+/*
+ * 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(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:
+   //  "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;
+
+};
+
+
+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
--- libconnman-qt/libconnman-qt.pro
+++ libconnman-qt/libconnman-qt.pro
@@ -16,6 +16,7 @@
 #system(qdbusxml2cpp -c Manager -p manager -N connman-manager.xml)
 system(qdbusxml2cpp -c Service -p service -N connman-service.xml)
 system(qdbusxml2cpp -c Technology -p technology -N connman-technology.xml)
+#system(qdbusxml2cpp -c Session -p session -N connman-session.xml)
 
 HEADERS += manager.h \
     service.h \
@@ -27,7 +28,11 @@
     clockproxy.h \
     clockmodel.h \
     debug.h \
-    useragent.h
+    useragent.h \
+    session.h \
+    sessionagent.h \
+    networksession.h \
+    counter.h
 
 SOURCES += \
     networkmanager.cpp \
@@ -40,7 +45,12 @@
     clockmodel.cpp \
     commondbustypes.cpp \
     debug.cpp \
-    useragent.cpp
+    useragent.cpp \
+    session.cpp \
+    sessionagent.cpp \
+    networksession.cpp \
+    counter.cpp
+
 
 target.path = $$INSTALL_ROOT$$PREFIX/lib
 
--- libconnman-qt/networkmanager.cpp
+++ libconnman-qt/networkmanager.cpp
@@ -27,6 +27,7 @@
 
 const QString NetworkManager::State("State");
 const QString NetworkManager::OfflineMode("OfflineMode");
+const QString NetworkManager::SessionMode("SessionMode");
 
 NetworkManager::NetworkManager(QObject* parent)
   : QObject(parent),
@@ -319,7 +320,9 @@
         emit stateChanged(tmp.toString());
     } else if (name == OfflineMode) {
         emit offlineModeChanged(tmp.toBool());
-    }
+    } else if (name == SessionMode) {
+       emit sessionModeChanged(tmp.toBool());
+   }
 }
 
 void NetworkManager::technologyAdded(const QDBusObjectPath &technology,
@@ -441,3 +444,42 @@
     if(m_manager)
         m_manager->UnregisterAgent(QDBusObjectPath(path));
 }
+
+void NetworkManager::registerCounter(const QString &path, quint32 
accuracy,quint32 period)
+{
+    if(m_manager)
+        m_manager->RegisterCounter(QDBusObjectPath(path),accuracy, period);
+}
+
+void NetworkManager::unregisterCounter(const QString &path)
+{
+    if(m_manager)
+        m_manager->UnregisterCounter(QDBusObjectPath(path));
+}
+
+QDBusObjectPath NetworkManager::createSession(const QVariantMap &settings, 
const QString &sessionNotifierPath)
+{
+    qDebug() << Q_FUNC_INFO << sessionNotifierPath << m_manager;
+
+    QDBusPendingReply<QDBusObjectPath> reply;
+    if(m_manager)
+       reply = 
m_manager->CreateSession(settings,QDBusObjectPath(sessionNotifierPath));
+    return reply;
+}
+
+void NetworkManager::destroySession(const QString &sessionAgentPath)
+{
+    if(m_manager)
+        m_manager->DestroySession(QDBusObjectPath(sessionAgentPath));
+}
+
+void NetworkManager::setSessionMode(const bool &sessionMode)
+{
+    if(m_manager)
+        m_manager->SetProperty(SessionMode, 
QDBusVariant(QVariant(sessionMode)));
+}
+
+bool NetworkManager::sessionMode() const
+{
+    return m_propertiesCache[SessionMode].toBool();
+}
--- libconnman-qt/networkmanager.h
+++ libconnman-qt/networkmanager.h
@@ -37,6 +37,8 @@
     Q_PROPERTY(bool offlineMode READ offlineMode WRITE setOfflineMode NOTIFY 
offlineModeChanged);
     Q_PROPERTY(NetworkService* defaultRoute READ defaultRoute NOTIFY 
defaultRouteChanged);
 
+    Q_PROPERTY(bool sessionMode READ sessionMode WRITE setSessionMode NOTIFY 
sessionModeChanged);
+
 public:
     NetworkManager(QObject* parent=0);
     virtual ~NetworkManager();
@@ -51,10 +53,18 @@
     bool offlineMode() const;
     NetworkService* defaultRoute() const;
 
+    bool sessionMode() const;
+
 public slots:
     void setOfflineMode(const bool &offlineMode);
     void registerAgent(const QString &path);
     void unregisterAgent(const QString &path);
+    void registerCounter(const QString &path, quint32 accuracy,quint32 period);
+    void unregisterCounter(const QString &path);
+    QDBusObjectPath createSession(const QVariantMap &settings, const QString 
&sessionNotifierPath);
+    void destroySession(const QString &sessionAgentPath);
+
+    void setSessionMode(const bool &sessionMode);
 
 signals:
     void availabilityChanged(bool available);
@@ -64,6 +74,7 @@
     void technologiesChanged();
     void servicesChanged();
     void defaultRouteChanged(NetworkService* defaultRoute);
+    void sessionModeChanged(bool);
 
 private:
     Manager *m_manager;
@@ -89,6 +100,7 @@
 
     static const QString State;
     static const QString OfflineMode;
+    static const QString SessionMode;
 
     bool m_available;
 
--- libconnman-qt/networkservice.cpp
+++ libconnman-qt/networkservice.cpp
@@ -72,7 +72,7 @@
     connect(m_service,
             SIGNAL(PropertyChanged(const QString&, const QDBusVariant&)),
             this,
-            SLOT(propertyChanged(const QString&, const QDBusVariant&)));
+            SLOT(updateProperty(const QString&, const QDBusVariant&)));
 }
 
 NetworkService::~NetworkService() {}
@@ -85,6 +85,10 @@
     return m_propertiesCache.value(State).toString();
 }
 
+const QString NetworkService::error() const {
+    return m_propertiesCache.value(Error).toString();
+}
+
 const QString NetworkService::type() const {
     return m_propertiesCache.value(Type).toString();
 }
@@ -165,11 +169,11 @@
     QDBusPendingReply<> conn_reply = m_service->Connect();
     m_service->setTimeout(old_timeout);
 
-    dbg_connectWatcher = new QDBusPendingCallWatcher(conn_reply, m_service);
-    connect(dbg_connectWatcher,
+    m_connectReqWatcher = new QDBusPendingCallWatcher(conn_reply, m_service);
+    connect(m_connectReqWatcher,
             SIGNAL(finished(QDBusPendingCallWatcher*)),
             this,
-            SLOT(dbg_connectReply(QDBusPendingCallWatcher*)));
+            SLOT(handleConnectReply(QDBusPendingCallWatcher*)));
 }
 
 void NetworkService::requestDisconnect()
@@ -218,20 +222,21 @@
     m_service->SetProperty(ProxyConfig, 
QDBusVariant(QVariant(adaptToConnmanProperties(proxy))));
 }
 
-/* this slot is used for debugging */
-void NetworkService::dbg_connectReply(QDBusPendingCallWatcher *call){
-    pr_dbg() << "Got something from service.connect()";
+void NetworkService::handleConnectReply(QDBusPendingCallWatcher *call)
+{
     Q_ASSERT(call);
     QDBusPendingReply<> reply = *call;
+
     if (!reply.isFinished()) {
        pr_dbg() << "connect() not finished yet";
     }
     if (reply.isError()) {
         pr_dbg() << "Reply from service.connect(): " << 
reply.error().message();
+        emit connectRequestFailed(reply.error().message());
     }
 }
 
-void NetworkService::propertyChanged(const QString &name, const QDBusVariant 
&value)
+void NetworkService::updateProperty(const QString &name, const QDBusVariant 
&value)
 {
     QVariant tmp = value.variant();
 
@@ -244,6 +249,8 @@
 
     if (name == Name) {
         emit nameChanged(tmp.toString());
+    } else if (name == Error) {
+        emit errorChanged(tmp.toString());
     } else if (name == State) {
         emit stateChanged(tmp.toString());
     } else if (name == Security) {
--- libconnman-qt/networkservice.h
+++ libconnman-qt/networkservice.h
@@ -24,6 +24,7 @@
 
     Q_PROPERTY(QString name READ name NOTIFY nameChanged);
     Q_PROPERTY(QString state READ state NOTIFY stateChanged);
+    Q_PROPERTY(QString error READ error NOTIFY errorChanged);
     Q_PROPERTY(QString type READ type);
     Q_PROPERTY(QStringList security READ security NOTIFY securityChanged);
     Q_PROPERTY(uint strength READ strength NOTIFY strengthChanged);
@@ -50,6 +51,7 @@
     const QString name() const;
     const QString type() const;
     const QString state() const;
+    const QString error() const;
     const QStringList security() const;
     bool autoConnect() const;
     uint strength() const;
@@ -70,6 +72,7 @@
 signals:
     void nameChanged(const QString &name);
     void stateChanged(const QString &state);
+    void errorChanged(const QString &error);
     void securityChanged(const QStringList &security);
     void strengthChanged(const uint strength);
     void favoriteChanged(const bool &favorite);
@@ -86,6 +89,7 @@
     void proxyChanged(const QVariantMap &proxy);
     void proxyConfigChanged(const QVariantMap &proxy);
     void ethernetChanged(const QVariantMap &ethernet);
+    void connectRequestFailed(const QString &error);
 
 public slots:
     void requestConnect();
@@ -104,7 +108,7 @@
     QString m_path;
     QVariantMap m_propertiesCache;
 
-    QDBusPendingCallWatcher *dbg_connectWatcher;
+    QDBusPendingCallWatcher *m_connectReqWatcher;
 
     static const QString Name;
     static const QString State;
@@ -127,8 +131,8 @@
     static const QString Ethernet;
 
 private slots:
-    void propertyChanged(const QString &name, const QDBusVariant &value);
-    void dbg_connectReply(QDBusPendingCallWatcher *call);
+    void updateProperty(const QString &name, const QDBusVariant &value);
+    void handleConnectReply(QDBusPendingCallWatcher *call);
 
 private:
     Q_DISABLE_COPY(NetworkService);
--- libconnman-qt/networksession.cpp
+++ libconnman-qt/networksession.cpp
@@ -0,0 +1,118 @@
+/*
+ * Copyright © 2012, Jolla Ltd
+ *
+ * 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 "networksession.h"
+#include "sessionagent.h"
+
+NetworkSession::NetworkSession(QObject *parent) :
+    QObject(parent),
+    m_sessionAgent(0),
+    m_path("/ConnmanQmlSessionAgent")
+{
+}
+
+NetworkSession::~NetworkSession()
+{
+}
+
+void NetworkSession::registerSession()
+{
+    if (m_path.isEmpty())
+        return;
+    m_sessionAgent = new SessionAgent(m_path ,this);
+    connect(m_sessionAgent,SIGNAL(settingsUpdated(QVariantMap)),
+            this,SLOT(sessionSettingsUpdated(QVariantMap)));
+
+    m_sessionAgent->registerSession();
+}
+
+QString NetworkSession::state() const
+{
+    return settingsMap.value("State").toString();
+}
+
+QString NetworkSession::name() const
+{
+    return settingsMap.value("Name").toString();
+}
+
+QString NetworkSession::bearer() const
+{
+    return settingsMap.value("Bearer").toString();
+}
+
+QString NetworkSession::sessionInterface() const
+{
+    return settingsMap.value("Interface").toString();
+}
+
+QVariantMap NetworkSession::ipv4() const
+{
+    return settingsMap.value("IPv4").toMap();
+}
+
+QVariantMap NetworkSession::ipv6() const
+{
+    return settingsMap.value("IPv6").toMap();
+}
+
+QStringList NetworkSession::allowedBearers() const
+{
+    return settingsMap.value("AllowedBearers").toStringList();
+}
+
+QString NetworkSession::connectionType() const
+{
+    return settingsMap.value("ConnectionType").toString();
+}
+
+void NetworkSession::setAllowedBearers(const QStringList &bearers)
+{
+    settingsMap.insert("AllowedBearers",  qVariantFromValue(bearers));
+    m_sessionAgent->setAllowedBearers(bearers);
+}
+
+void NetworkSession::setConnectionType(const QString &type)
+{
+    settingsMap.insert("ConnectionType",  qVariantFromValue(type));
+    m_sessionAgent->setConnectionType(type);
+}
+
+void NetworkSession::requestDestroy()
+{
+    m_sessionAgent->requestDestroy();
+}
+
+void NetworkSession::requestConnect()
+{
+    m_sessionAgent->requestConnect();
+}
+
+void NetworkSession::requestDisconnect()
+{
+    m_sessionAgent->requestDisconnect();
+}
+
+void NetworkSession::sessionSettingsUpdated(const QVariantMap &settings)
+{
+    Q_FOREACH(const QString &name, settings.keys()) {
+        settingsMap.insert(name,settings[name]);
+    }
+    Q_EMIT settingsChanged(settings);
+}
+
+QString NetworkSession::path() const
+{
+    return m_path;
+}
+
+void NetworkSession::setPath(const QString &path)
+{
+    m_path = path;
+}
--- libconnman-qt/networksession.h
+++ libconnman-qt/networksession.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright © 2012, Jolla Ltd
+ *
+ * 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 SESSIONSERVICE_H
+#define SESSIONSERVICE_H
+
+#include <QObject>
+#include <QtDBus>
+
+class SessionAgent;
+
+class NetworkSession : public QObject
+{
+    Q_OBJECT
+    Q_PROPERTY(QString state READ state)
+    Q_PROPERTY(QString name READ name)
+    Q_PROPERTY(QString bearer READ bearer)
+    Q_PROPERTY(QString sessionInterface READ sessionInterface)
+    Q_PROPERTY(QVariantMap ipv4 READ ipv4)
+    Q_PROPERTY(QVariantMap ipv6 READ ipv6)
+
+    Q_PROPERTY(QString path READ path WRITE setPath)
+
+    Q_PROPERTY(QStringList allowedBearers READ allowedBearers WRITE 
setAllowedBearers NOTIFY allowedBearersChanged)
+    Q_PROPERTY(QString connectionType READ connectionType WRITE 
setConnectionType NOTIFY connectionTypeChanged)
+
+public:
+    NetworkSession(QObject *parent = 0);
+    virtual ~NetworkSession();
+
+    //Settings
+     QString state() const;
+     QString name() const;
+     QString bearer() const;
+     QString sessionInterface() const;
+     QVariantMap ipv4() const;
+     QVariantMap ipv6() const;
+     QStringList allowedBearers() const;
+     QString connectionType() const;
+
+     QString path() const;
+
+    void setAllowedBearers(const QStringList &bearers);
+    void setConnectionType(const QString &type);
+
+signals:
+
+    void allowedBearersChanged(const QStringList &bearers);
+    void connectionTypeChanged(const QString &type);
+    void settingsChanged(const QVariantMap &settings);
+
+public slots:
+    void requestDestroy();
+    void requestConnect();
+    void requestDisconnect();
+    void sessionSettingsUpdated(const QVariantMap &settings);
+    void setPath(const QString &path);
+    void registerSession();
+
+private:
+    SessionAgent *m_sessionAgent;
+    QVariantMap settingsMap;
+    QString m_path;
+};
+
+#endif // SESSIONSERVICE_H
--- libconnman-qt/session.cpp
+++ libconnman-qt/session.cpp
@@ -0,0 +1,25 @@
+/*
+ * 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 "session.h"
+
+/*
+ * Implementation of interface class Session
+ */
+
+Session::Session(const QString &path, QObject *parent)
+    : QDBusAbstractInterface(staticConnmanService(), path, 
staticInterfaceName(), QDBusConnection::systemBus(), parent)
+{
+    qDebug() << Q_FUNC_INFO;
+}
+
+Session::~Session()
+{
+}
+
--- libconnman-qt/session.h
+++ libconnman-qt/session.h
@@ -0,0 +1,63 @@
+/*
+ * 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 SESSION_H_1356566832
+#define SESSION_H_1356566832
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+/*
+ * Proxy class for interface net.connman.Session
+ */
+class Session: public QDBusAbstractInterface
+{
+    Q_OBJECT
+public:
+    static inline const char *staticConnmanService()
+    { return "net.connman"; }
+    static inline const char *staticInterfaceName()
+    { return "net.connman.Session"; }
+
+public:
+    Session(const QString &path, QObject *parent = 0);
+
+    ~Session();
+
+public Q_SLOTS: // METHODS
+    inline QDBusPendingReply<> Change(const QString &name, const QDBusVariant 
&value)
+    {
+        QList<QVariant> argumentList;
+        argumentList << QVariant::fromValue(name) << 
QVariant::fromValue(value);
+        return asyncCallWithArgumentList(QLatin1String("Change"), 
argumentList);
+    }
+
+    inline QDBusPendingReply<> Connect()
+    {
+         return asyncCall(QLatin1String("Connect"));
+    }
+
+    inline QDBusPendingReply<> Destroy()
+    {
+        return asyncCall(QLatin1String("Destroy"));
+    }
+
+    inline QDBusPendingReply<> Disconnect()
+    {
+        return asyncCall(QLatin1String("Disconnect"));
+    }
+
+};
+
+#endif
--- libconnman-qt/sessionagent.cpp
+++ libconnman-qt/sessionagent.cpp
@@ -0,0 +1,117 @@
+/*
+ * Copyright © 2012, Jolla Ltd.
+ *
+ * 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 <debug.h>
+#include "sessionagent.h"
+#include "session.h"
+
+/*
+This class is used to run a connman session.
+Example:
+    SessionAgent *sessionAgent = new SessionAgent("/ConnmanSessionAgent",this);
+    connect(sessionAgent,SIGNAL(settingsUpdated(QVariantMap)),
+            this,SLOT(sessionSettingsUpdated(QVariantMap)));
+
+    sessionAgent->registerSession(); // you MUST call this!
+
+    sessionAgent->setAllowedBearers(QStringList() << "wifi" << "ethernet" << 
"cellular");
+    sessionAgent->requestConnect();
+
+    There can be multiple sessions.
+
+  */
+
+SessionAgent::SessionAgent(const QString &path, QObject* parent) :
+    QObject(parent),
+    agentPath(path),
+    m_session(0)
+{
+    m_manager = new Manager("net.connman", "/", QDBusConnection::systemBus(), 
this);
+    const QString sessionmode = "SessionMode";
+    m_manager->SetProperty(sessionmode, QDBusVariant(true));
+}
+
+SessionAgent::~SessionAgent()
+{
+    m_manager->DestroySession(QDBusObjectPath(agentPath));
+}
+
+void SessionAgent::setAllowedBearers(const QStringList &bearers)
+{
+    if (!m_session)
+        return;
+    QVariantMap map;
+    map.insert("AllowedBearers",  qVariantFromValue(bearers));
+    m_session->Change("AllowedBearers",QDBusVariant(bearers));
+}
+
+void SessionAgent::setConnectionType(const QString &type)
+{
+    if (!m_session)
+        return;
+    QVariantMap map;
+    map.insert("ConnectionType",  qVariantFromValue(type));
+    m_session->Change("ConnectionType",QDBusVariant(type));
+}
+
+void SessionAgent::registerSession()
+{
+    if (m_manager->isValid()) {
+        QDBusPendingReply<QDBusObjectPath> obpath = 
m_manager->CreateSession(QVariantMap(),QDBusObjectPath(agentPath));
+        m_session = new Session(obpath.value().path(), this);
+        new SessionNotificationAdaptor(this);
+        QDBusConnection::systemBus().registerObject(agentPath, this);
+    }
+}
+
+void SessionAgent::requestConnect()
+{
+    if (m_session)
+        m_session->Connect();
+}
+
+void SessionAgent::requestDisconnect()
+{
+    if (m_session)
+        m_session->Disconnect();
+}
+
+void SessionAgent::requestDestroy()
+{
+    if (m_session)
+        m_session->Destroy();
+}
+
+void SessionAgent::release()
+{
+    Q_EMIT released();
+}
+
+void SessionAgent::update(const QVariantMap &settings)
+{
+    Q_EMIT settingsUpdated(settings);
+}
+
+SessionNotificationAdaptor::SessionNotificationAdaptor(SessionAgent* parent)
+  : QDBusAbstractAdaptor(parent),
+    m_sessionAgent(parent)
+{
+}
+
+SessionNotificationAdaptor::~SessionNotificationAdaptor() {}
+
+void SessionNotificationAdaptor::Release()
+{
+    m_sessionAgent->release();
+}
+
+void SessionNotificationAdaptor::Update(const QVariantMap &settings)
+{
+    m_sessionAgent->update(settings);
+}
--- libconnman-qt/sessionagent.h
+++ libconnman-qt/sessionagent.h
@@ -0,0 +1,65 @@
+/*
+ * 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 SESSIONAGENT_H
+#define SESSIONAGENT_H
+
+#include "manager.h"
+
+class Session;
+
+class SessionAgent : public QObject
+{
+    Q_OBJECT
+
+public:
+    explicit SessionAgent(const QString &path,QObject* parent = 0);
+    virtual ~SessionAgent();
+
+    void setAllowedBearers(const QStringList &bearers);
+    void setConnectionType(const QString &type);
+    void registerSession();
+    void requestConnect();
+    void requestDisconnect();
+    void requestDestroy();
+
+public slots:
+    void release();
+    void update(const QVariantMap &settings);
+
+Q_SIGNALS:
+    void settingsUpdated(const QVariantMap &settings);
+    void released();
+
+private:
+    QString agentPath;
+    QVariantMap sessionSettings;
+    Manager* m_manager;
+    Session *m_session;
+
+    friend class SessionNotificationAdaptor;
+};
+
+class SessionNotificationAdaptor : public QDBusAbstractAdaptor
+{
+    Q_OBJECT
+    Q_CLASSINFO("D-Bus Interface", "net.connman.Notification")
+
+public:
+    explicit SessionNotificationAdaptor(SessionAgent* parent);
+    virtual ~SessionNotificationAdaptor();
+
+public slots:
+    void Release();
+    void Update(const QVariantMap &settings);
+private:
+    SessionAgent* m_sessionAgent;
+};
+
+#endif // USERAGENT_H
--- libconnman-qt/useragent.cpp
+++ libconnman-qt/useragent.cpp
@@ -21,6 +21,7 @@
     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)),
--- plugin/components.cpp
+++ plugin/components.cpp
@@ -14,6 +14,7 @@
 #include "networkingmodel.h"
 #include "technologymodel.h"
 #include "useragent.h"
+#include "networksession.h"
 
 void Components::registerTypes(const char *uri)
 {
@@ -23,6 +24,7 @@
     qmlRegisterType<TechnologyModel>(uri,0,2,"TechnologyModel");
     qmlRegisterType<UserAgent>(uri,0,2,"UserAgent");
     qmlRegisterType<ClockModel>(uri,0,2,"ClockModel");
+    qmlRegisterType<NetworkSession>(uri,0,2,"NetworkSession");
 }
 
 void Components::initializeEngine(QDeclarativeEngine *engine, const char *uri)
@@ -31,4 +33,4 @@
     Q_UNUSED(engine);
 }
 
-Q_EXPORT_PLUGIN(Components);
+Q_EXPORT_PLUGIN(Components)

++++++ connman-qt.yaml
--- connman-qt.yaml
+++ connman-qt.yaml
@@ -1,6 +1,6 @@
 Name: connman-qt
 Summary: qt bindings for connman
-Version: 0.3.5
+Version: 0.4.0
 Release: 1
 Group: System/GUI/Other
 License: Apache License



Reply via email to