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/7566 Thank You, rojkov [This message was auto-generated] --- Request # 7566: Messages from BOSS: State: review at 2012-12-19T10:47:04 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,6 @@ +* Wed Dec 19 2012 Dmitry Rozhkov <[email protected]> - 0.3.4 +- technologymodel: Untie TechnologyModel from WiFi +- add session, notification and counter API +- technologymodel: move user agent to dedicated class +- useragent: iterate over credentials fields on C++ side, not JS + old: ---- connman-qt-0.3.3.tar.bz2 new: ---- connman-qt-0.3.4.tar.bz2 spec files: ----------- --- connman-qt.spec +++ connman-qt.spec @@ -9,7 +9,7 @@ # << macros Summary: qt bindings for connman -Version: 0.3.3 +Version: 0.3.4 Release: 1 Group: System/GUI/Other License: Apache License other changes: -------------- ++++++ connman-qt-0.3.3.tar.bz2 -> connman-qt-0.3.4.tar.bz2 --- README.rst +++ README.rst @@ -6,5 +6,12 @@ `NetworkTechnology` represents `net.connman.Technology` and `NetworkService` represents `net.connman.Service`. +`TechnologyModel` is a QML component representing a list of network +services of a given technology. + +`UserAgent` is a QML component providing `net.connman.Agent` D-Bus interface. + The class `NetworkingModel` is a QML component adapting a static instance of `NetworkManager`. Also it provides the D-Bus interface `net.connman.Agent`. + +.. warning:: `NetworkingModel` is going to be deprecated. --- libconnman-qt/connman-manager.xml +++ libconnman-qt/connman-manager.xml @@ -30,6 +30,36 @@ <arg name="path" type="o"/> </method> + <method name="RegisterCounter" tp:name-for-bindings="Register_Counter"> + <arg name="path" type="o"/> + <arg name="accuracy" type="u"/> + <arg name="period" type="u"/> + </method> + + <method name="UnregisterCounter" tp:name-for-bindings="Unregister_Counter"> + <arg name="path" type="o"/> + </method> + + <method name="CreateSession" tp:name-for-bindings="Create_Session"> + <arg name="settings" type="a{sv}"> + <arg name="notifier" type="o"/> + </method> + + <method name="DestroySession" tp:name-for-bindings="Destroy_Session"> + <arg name="session" type="o"/> + </method> + + <method name="RequestPrivateNetwork" tp:name-for-bindings="Request_Privete_Network"> + <arg name="options" type="a{sv}"> + <arg name="path" type="o" direction="out"/> + <arg name="dict" type="a{sv}" direction="out"/> + <arg name="fd" type="i" direction="out"/> + </method> + + <method name="ReleasePrivateNetwork" tp:name-for-bindings="Release_Private_Network"> + <arg name="path" type="o"/> + </method> + <signal name="TechnologyAdded" tp:name-for-bindings="Technology_Added"> <arg name="technology" type="o"/> <arg name="properties" type="a{sv}"/> --- libconnman-qt/connman-notification.xml +++ libconnman-qt/connman-notification.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<node xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <interface name="net.connman.Notification"> + + <method name="Release" tp:name-for-bindings="Release" /> + + <method name="Update" tp:name-for-bindings="Update"/> + <arg name="settings" type="a{sv}"> + </method> + + </interface> +</node> --- libconnman-qt/connman-service.xml +++ libconnman-qt/connman-service.xml @@ -30,6 +30,8 @@ <arg name="service" type="o"/> </method> + <method name="ResetCounters" tp:name-for-bindings="Reset_Counters" /> + <signal name="PropertyChanged" tp:name-for-bindings="Property_Changed"> <arg name="name" type="s"/> <arg name="value" type="v"/> --- libconnman-qt/connman-session.xml +++ libconnman-qt/connman-session.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<node name="/Session" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <interface name="net.connman.Session"> + + <method name="Destroy" tp:name-for-bindings="Destroy" /> + + <method name="Connect" tp:name-for-bindings="Connect" /> + + <method name="Disconnect" tp:name-for-bindings="Disconnect" /> + + <method name="Change" tp:name-for-bindings="Change"> + <arg name="name" type="s"> + <arg name="value" type="v"> + </method> + + <method name="Update" tp:name-for-bindings="Update"/> + <arg name="settings" type="a{sv}"> + </method> + + </interface> +</node> --- libconnman-qt/libconnman-qt.pro +++ libconnman-qt/libconnman-qt.pro @@ -51,3 +51,10 @@ pkgconfig.files = connman-qt4.pc INSTALLS += target headers pkgconfig + +OTHER_FILES = connman-service.xml \ + connman-technology.xml \ + connman-clock.xml \ + connman-manager.xml \ + connman-session.xml \ + connman-notification.xml --- libconnman-qt/manager.h +++ libconnman-qt/manager.h @@ -76,6 +76,54 @@ return asyncCallWithArgumentList(QLatin1String("UnregisterAgent"), argumentList); } + inline QDBusPendingReply<> RegisterCounter(const QDBusObjectPath &path, const uint accuracy, const uint period) + { + QList<QVariant> argumentList; + argumentList << QVariant::fromValue(path); + argumentList << QVariant::fromValue(accuracy); + argumentList << QVariant::fromValue(period); + return asyncCallWithArgumentList(QLatin1String("RegisterCounter"), argumentList); + } + + inline QDBusPendingReply<> UnregisterCounter(const QDBusObjectPath &path) + { + QList<QVariant> argumentList; + argumentList << QVariant::fromValue(path); + return asyncCallWithArgumentList(QLatin1String("UnregisterCounter"), argumentList); + } + + inline QDBusPendingReply<> CreateSession(const QVariantMap &settings, const QDBusObjectPath ¬ifier) + { + QList<QVariant> argumentList; + argumentList << QVariant::fromValue(settings); + argumentList << QVariant::fromValue(notifier); + return asyncCallWithArgumentList(QLatin1String("CreateSession"), argumentList); + } + + + inline QDBusPendingReply<> DestroySession(const QDBusObjectPath &path) + { + QList<QVariant> argumentList; + argumentList << QVariant::fromValue(path); + return asyncCallWithArgumentList(QLatin1String("DestroySession"), argumentList); + } + + + inline QDBusPendingReply<> RequestPrivateNetwork(const QVariantMap &options) + { + QList<QVariant> argumentList; + argumentList << QVariant::fromValue(options); + return asyncCallWithArgumentList(QLatin1String("RequestPrivateNetwork"), argumentList); + } + + + inline QDBusPendingReply<> ReleasePrivateNetwork(const QDBusObjectPath &path) + { + QList<QVariant> argumentList; + argumentList << QVariant::fromValue(path); + return asyncCallWithArgumentList(QLatin1String("ReleasePrivateNetwork"), argumentList); + } + Q_SIGNALS: // SIGNALS void PropertyChanged(const QString &name, const QDBusVariant &value); void ServicesChanged(ConnmanObjectList changed, const QList<QDBusObjectPath> &removed); --- plugin/components.cpp +++ plugin/components.cpp @@ -13,6 +13,7 @@ #include <clockmodel.h> #include "networkingmodel.h" #include "technologymodel.h" +#include "useragent.h" void Components::registerTypes(const char *uri) { @@ -20,6 +21,7 @@ "Please don't create \"NetworkService\" objects manually."); qmlRegisterType<NetworkingModel>(uri,0,2,"NetworkingModel"); qmlRegisterType<TechnologyModel>(uri,0,2,"TechnologyModel"); + qmlRegisterType<UserAgent>(uri,0,2,"UserAgent"); qmlRegisterType<ClockModel>(uri,0,2,"ClockModel"); } --- plugin/networkingmodel.h +++ plugin/networkingmodel.h @@ -23,6 +23,10 @@ QDBusMessage msg; }; +/* + * WARNING: this class is going to be deprecated. Use TechnologyModel and + * UserAgent classes instead. + */ class NetworkingModel : public QObject { Q_OBJECT; --- plugin/technologymodel.cpp +++ plugin/technologymodel.cpp @@ -10,9 +10,6 @@ #include <QDebug> #include "technologymodel.h" -#include "useragent.h" - -static const char AGENT_PATH[] = "/ConnectivitySettings"; #define CONNECT_TECHNOLOGY_SIGNALS(tech) \ connect(tech, \ @@ -38,8 +35,6 @@ roles[ServiceRole] = "networkService"; setRoleNames(roles); - new UserAgent(this); // this object will be freed when TechnologyModel is freed - m_tech = m_manager->getTechnology(m_techname); if (m_tech) { CONNECT_TECHNOLOGY_SIGNALS(m_tech); @@ -57,14 +52,10 @@ SIGNAL(servicesChanged()), this, SLOT(updateServiceList())); - - QDBusConnection::systemBus().registerObject(AGENT_PATH, this); - m_manager->registerAgent(QString(AGENT_PATH)); } TechnologyModel::~TechnologyModel() { - m_manager->unregisterAgent(QString(AGENT_PATH)); } QVariant TechnologyModel::data(const QModelIndex &index, int role) const @@ -113,6 +104,40 @@ } } +void TechnologyModel::setName(const QString &name) +{ + if (m_techname == name) { + return; + } + + bool oldPowered(false); + + if (m_tech) { + oldPowered = m_tech->powered(); + disconnect(m_tech, SIGNAL(poweredChanged(bool)), + this, SIGNAL(poweredChanged(bool))); + disconnect(m_tech, SIGNAL(scanFinished()), + this, SIGNAL(scanRequestFinished())); + } + + m_techname = name; + m_tech = m_manager->getTechnology(m_techname); + emit nameChanged(m_techname); + + if (!m_tech) { + if (oldPowered) { + emit poweredChanged(false); + } + return; + } + + if (oldPowered != m_tech->powered()) { + emit poweredChanged(!oldPowered); + } + + CONNECT_TECHNOLOGY_SIGNALS(m_tech); +} + void TechnologyModel::requestScan() const { qDebug() << "scan requested for technology"; @@ -145,36 +170,9 @@ void TechnologyModel::managerAvailabilityChanged(bool available) { - if(available) - m_manager->registerAgent(QString(AGENT_PATH)); - emit availabilityChanged(available); } -void TechnologyModel::requestUserInput(ServiceRequestData* data) -{ - m_req_data = data; - emit userInputRequested(data->objectPath, data->fields); -} - -void TechnologyModel::reportError(const QString &error) { - emit errorReported(error); -} - -void TechnologyModel::sendUserReply(const QVariantMap &input) { - if (!input.isEmpty()) { - QDBusMessage &reply = m_req_data->reply; - reply << input; - QDBusConnection::systemBus().send(reply); - } else { - QDBusMessage error = m_req_data->msg.createErrorReply( - QString("net.connman.Agent.Error.Canceled"), - QString("canceled by user")); - QDBusConnection::systemBus().send(error); - } - delete m_req_data; -} - int TechnologyModel::indexOf(const QString &dbusObjectPath) const { int idx(-1); --- plugin/technologymodel.h +++ plugin/technologymodel.h @@ -18,28 +18,15 @@ #include <networktechnology.h> #include <networkservice.h> -struct ServiceRequestData -{ - QString objectPath; - QVariantMap fields; - QDBusMessage reply; - QDBusMessage msg; -}; - /* * TechnologyModel is a list model specific to a certain technology (wifi by default). - * TODO: 1. consider refactoring this class to NetworkServiceModel with - * "technologyName" as a filtering property; - * 2. drop properties NetworkServiceModel.available, NetworkServiceModel.powered; - * 2. expose NetworkTechnology as QtQuick component. */ class TechnologyModel : public QAbstractListModel { Q_OBJECT; Q_DISABLE_COPY(TechnologyModel); - // TODO: consider "name" as writeable property of TechnologyModel QtQuck component - Q_PROPERTY(QString name READ name NOTIFY nameChanged); + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged); Q_PROPERTY(bool available READ isAvailable NOTIFY availabilityChanged); Q_PROPERTY(bool powered READ isPowered WRITE setPowered NOTIFY poweredChanged); @@ -58,10 +45,8 @@ bool isAvailable() const; bool isPowered() const; - void requestUserInput(ServiceRequestData* data); - void reportError(const QString &error); + void setName(const QString &name); - Q_INVOKABLE void sendUserReply(const QVariantMap &input); Q_INVOKABLE int indexOf(const QString &dbusObjectPath) const; public slots: @@ -74,15 +59,12 @@ void poweredChanged(const bool &powered); void technologiesChanged(); - void userInputRequested(const QString &servicePath, const QVariantMap &fields); - void errorReported(const QString &error); void scanRequestFinished(); private: QString m_techname; NetworkManager* m_manager; NetworkTechnology* m_tech; - ServiceRequestData* m_req_data; QVector<NetworkService *> m_services; private slots: --- plugin/useragent.cpp +++ plugin/useragent.cpp @@ -7,38 +7,111 @@ * */ +#include <debug.h> #include "useragent.h" -UserAgent::UserAgent(TechnologyModel* parent) - : QDBusAbstractAdaptor(parent), - m_model(parent) +static const char AGENT_PATH[] = "/ConnectivityUserAgent"; + +UserAgent::UserAgent(QObject* parent) : + QObject(parent), + m_req_data(NULL), + m_manager(NetworkManagerFactory::createInstance()) +{ + new AgentAdaptor(this); // this object will be freed when UserAgent is freed + QDBusConnection::systemBus().registerObject(AGENT_PATH, this); + + if (m_manager->isAvailable()) { + m_manager->registerAgent(QString(AGENT_PATH)); + } + connect(m_manager, SIGNAL(availabilityChanged(bool)), + this, SLOT(updateMgrAvailability(bool))); +} + +UserAgent::~UserAgent() +{ + m_manager->unregisterAgent(QString(AGENT_PATH)); +} + +void UserAgent::requestUserInput(ServiceRequestData* data) +{ + m_req_data = data; + QVariantList fields; + + foreach (const QString &key, data->fields.keys()) { + QVariantMap field; + + field.insert("name", key); + field.insert("type", data->fields.value(key).toMap().value("Type")); + fields.append(QVariant(field)); + } + + emit userInputRequested(data->objectPath, fields); +} + +void UserAgent::cancelUserInput() { - // TODO + delete m_req_data; + m_req_data = NULL; + emit userInputCanceled(); +} + +void UserAgent::reportError(const QString &error) { + emit errorReported(error); } -UserAgent::~UserAgent() {} +void UserAgent::sendUserReply(const QVariantMap &input) { + if (m_req_data == NULL) { + qWarning("Got reply for non-existing request"); + return; + } + + if (!input.isEmpty()) { + QDBusMessage &reply = m_req_data->reply; + reply << input; + QDBusConnection::systemBus().send(reply); + } else { + QDBusMessage error = m_req_data->msg.createErrorReply( + QString("net.connman.Agent.Error.Canceled"), + QString("canceled by user")); + QDBusConnection::systemBus().send(error); + } + delete m_req_data; + m_req_data = NULL; +} -void UserAgent::Release() +void UserAgent::updateMgrAvailability(bool &available) { - // here do clean up + if (available) { + m_manager->registerAgent(QString(AGENT_PATH)); + } } -void UserAgent::ReportError(const QDBusObjectPath &service_path, const QString &error) +AgentAdaptor::AgentAdaptor(UserAgent* parent) + : QDBusAbstractAdaptor(parent), + m_userAgent(parent) +{ +} + +AgentAdaptor::~AgentAdaptor() {} + +void AgentAdaptor::Release() {} + +void AgentAdaptor::ReportError(const QDBusObjectPath &service_path, const QString &error) { - qDebug() << "From " << service_path.path() << " got this error:\n" << error; - m_model->reportError(error); + pr_dbg() << "From " << service_path.path() << " got this error:\n" << error; + m_userAgent->reportError(error); } -void UserAgent::RequestBrowser(const QDBusObjectPath &service_path, const QString &url) +void AgentAdaptor::RequestBrowser(const QDBusObjectPath &service_path, const QString &url) { - qDebug() << "Service " << service_path.path() << " wants browser to open hotspot's url " << url; + pr_dbg() << "Service " << service_path.path() << " wants browser to open hotspot's url " << url; } -void UserAgent::RequestInput(const QDBusObjectPath &service_path, +void AgentAdaptor::RequestInput(const QDBusObjectPath &service_path, const QVariantMap &fields, const QDBusMessage &message) { - qDebug() << "Service " << service_path.path() << " wants user input"; + pr_dbg() << "Service " << service_path.path() << " wants user input"; QVariantMap json; foreach (const QString &key, fields.keys()){ @@ -54,10 +127,11 @@ reqdata->reply = message.createReply(); reqdata->msg = message; - m_model->requestUserInput(reqdata); + m_userAgent->requestUserInput(reqdata); } -void UserAgent::Cancel() +void AgentAdaptor::Cancel() { - qDebug() << "WARNING: request to agent got canceled"; + pr_dbg() << "WARNING: request to agent got canceled"; + m_userAgent->cancelUserInput(); } --- plugin/useragent.h +++ plugin/useragent.h @@ -10,17 +10,54 @@ #ifndef USERAGENT_H #define USERAGENT_H -#include <QDBusAbstractAdaptor> -#include "technologymodel.h" +#include <networkmanager.h> -class UserAgent : public QDBusAbstractAdaptor +struct ServiceRequestData +{ + QString objectPath; + QVariantMap fields; + QDBusMessage reply; + QDBusMessage msg; +}; + +class UserAgent : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(UserAgent) + +public: + explicit UserAgent(QObject* parent = 0); + virtual ~UserAgent(); + + Q_INVOKABLE void sendUserReply(const QVariantMap &input); + +signals: + void userInputRequested(const QString &servicePath, const QVariantList &fields); + void userInputCanceled(); + void errorReported(const QString &error); + +private slots: + void updateMgrAvailability(bool &available); + +private: + void requestUserInput(ServiceRequestData* data); + void cancelUserInput(); + void reportError(const QString &error); + + ServiceRequestData* m_req_data; + NetworkManager* m_manager; + + friend class AgentAdaptor; +}; + +class AgentAdaptor : public QDBusAbstractAdaptor { Q_OBJECT; Q_CLASSINFO("D-Bus Interface", "net.connman.Agent"); public: - UserAgent(TechnologyModel* parent); - virtual ~UserAgent(); + explicit AgentAdaptor(UserAgent* parent); + virtual ~AgentAdaptor(); public slots: void Release(); @@ -32,7 +69,7 @@ void Cancel(); private: - TechnologyModel* m_model; + UserAgent* m_userAgent; }; #endif // USERAGENT_H ++++++ connman-qt.yaml --- connman-qt.yaml +++ connman-qt.yaml @@ -1,6 +1,6 @@ Name: connman-qt Summary: qt bindings for connman -Version: 0.3.3 +Version: 0.3.4 Release: 1 Group: System/GUI/Other License: Apache License
