Update connman bearer plugin for changed connman API.

This should also remain working for previous connman

Change-Id: I5f0a1947f11948b202391ba0c256067faa01ce6d
Reviewed-by: Lorn Potter <lorn.potter@jollamobile.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Lorn Potter 2012-12-07 07:41:44 +10:00 committed by The Qt Project
parent 12b68e817f
commit 2efccfeeef
2 changed files with 57 additions and 6 deletions

View File

@ -57,9 +57,24 @@
#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
QDBusArgument &operator<<(QDBusArgument &argument, const ConnmanMap &map)
{
argument.beginStructure();
argument << map.objectPath << map.propertyMap;
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMap &map)
{
argument.beginStructure();
argument >> map.objectPath >> map.propertyMap;
argument.endStructure();
return argument;
}
static QDBusConnection dbusConnection = QDBusConnection::systemBus();
QConnmanManagerInterface::QConnmanManagerInterface( QObject *parent)
: QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
QLatin1String(CONNMAN_MANAGER_PATH),
@ -301,14 +316,37 @@ QStringList QConnmanManagerInterface::getProfiles()
QStringList QConnmanManagerInterface::getTechnologies()
{
QVariant var = getProperty("Technologies");
return qdbus_cast<QStringList >(var);
QStringList list;
QDBusReply<ConnmanMapList> replyList = this->call(QLatin1String("GetTechnologies"));
if (replyList.isValid()) {
Q_FOREACH (ConnmanMap map, replyList.value()) {
list << map.objectPath.path();
}
} else {
// try for older version
QVariant var = getProperty("Technologies");
if (!var.isNull()) {
list = qdbus_cast<QStringList>(var);
}
}
return list;
}
QStringList QConnmanManagerInterface::getServices()
{
QVariant var = getProperty("Services");
return qdbus_cast<QStringList >(var);
QStringList list;
QDBusReply<ConnmanMapList> replyList = this->call(QLatin1String("GetServices"));
if (replyList.isValid()) {
Q_FOREACH (ConnmanMap map, replyList.value()) {
list << map.objectPath.path();
}
} else {
QVariant var = getProperty("Services");
if (!var.isNull()) {
list = qdbus_cast<QStringList>(var);
}
}
return list;
}
QString QConnmanManagerInterface::getPathForTechnology(const QString &name)

View File

@ -59,6 +59,7 @@
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusMessage>
#include <QtDBus/QDBusReply>
#include <QtDBus/QDBusArgument>
#include <QtDBus/QDBusPendingCallWatcher>
#include <QtDBus/QDBusObjectPath>
@ -90,11 +91,23 @@
QT_BEGIN_NAMESPACE
struct ConnmanMap {
QDBusObjectPath objectPath;
QVariantMap propertyMap;
};
typedef QList< ConnmanMap > ConnmanMapList;
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(ConnmanMap))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(ConnmanMapList))
QT_BEGIN_NAMESPACE
QDBusArgument &operator<<(QDBusArgument &argument, const ConnmanMap &obj);
const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMap &obj);
class QConnmanManagerInterface : public QDBusAbstractInterface
{
Q_OBJECT