| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the plugins of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at qt-info@nokia.com.
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #include <QObject>
|
|---|
| 43 | #include <QList>
|
|---|
| 44 | #include <QtDBus/QtDBus>
|
|---|
| 45 | #include <QtDBus/QDBusConnection>
|
|---|
| 46 | #include <QtDBus/QDBusError>
|
|---|
| 47 | #include <QtDBus/QDBusInterface>
|
|---|
| 48 | #include <QtDBus/QDBusMessage>
|
|---|
| 49 | #include <QtDBus/QDBusReply>
|
|---|
| 50 | #include <QtDBus/QDBusPendingCallWatcher>
|
|---|
| 51 | #include <QtDBus/QDBusObjectPath>
|
|---|
| 52 | #include <QtDBus/QDBusPendingCall>
|
|---|
| 53 |
|
|---|
| 54 | #include "qconnmanservice_linux_p.h"
|
|---|
| 55 |
|
|---|
| 56 | #ifndef QT_NO_BEARERMANAGEMENT
|
|---|
| 57 | #ifndef QT_NO_DBUS
|
|---|
| 58 |
|
|---|
| 59 | QT_BEGIN_NAMESPACE
|
|---|
| 60 | static QDBusConnection dbusConnection = QDBusConnection::systemBus();
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 | QConnmanManagerInterface::QConnmanManagerInterface( QObject *parent)
|
|---|
| 64 | : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
|
|---|
| 65 | QLatin1String(CONNMAN_MANAGER_PATH),
|
|---|
| 66 | CONNMAN_MANAGER_INTERFACE,
|
|---|
| 67 | QDBusConnection::systemBus(), parent)
|
|---|
| 68 | {
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | QConnmanManagerInterface::~QConnmanManagerInterface()
|
|---|
| 72 | {
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | void QConnmanManagerInterface::connectNotify(const char *signal)
|
|---|
| 76 | {
|
|---|
| 77 | if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
|
|---|
| 78 | if(!connection().connect(QLatin1String(CONNMAN_SERVICE),
|
|---|
| 79 | QLatin1String(CONNMAN_MANAGER_PATH),
|
|---|
| 80 | QLatin1String(CONNMAN_MANAGER_INTERFACE),
|
|---|
| 81 | QLatin1String("PropertyChanged"),
|
|---|
| 82 | this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
|
|---|
| 83 | qWarning() << "PropertyCHanged not connected";
|
|---|
| 84 | }
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | if (QLatin1String(signal) == SIGNAL(stateChanged(QString))) {
|
|---|
| 88 | if (!connection().connect(QLatin1String(CONNMAN_SERVICE),
|
|---|
| 89 | QLatin1String(CONNMAN_MANAGER_PATH),
|
|---|
| 90 | QLatin1String(CONNMAN_MANAGER_INTERFACE),
|
|---|
| 91 | QLatin1String("StateChanged"),
|
|---|
| 92 | this,SIGNAL(stateChanged(const QString&)))) {
|
|---|
| 93 | qWarning() << "StateChanged not connected";
|
|---|
| 94 |
|
|---|
| 95 | }
|
|---|
| 96 | }
|
|---|
| 97 | if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
|
|---|
| 98 | QConnmanDBusHelper *helper;
|
|---|
| 99 | helper = new QConnmanDBusHelper(this);
|
|---|
| 100 |
|
|---|
| 101 | dbusConnection.connect(QLatin1String(CONNMAN_SERVICE),
|
|---|
| 102 | QLatin1String(CONNMAN_MANAGER_PATH),
|
|---|
| 103 | QLatin1String(CONNMAN_MANAGER_INTERFACE),
|
|---|
| 104 | QLatin1String("PropertyChanged"),
|
|---|
| 105 | helper,SLOT(propertyChanged(QString,QDBusVariant)));
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 | QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
|
|---|
| 109 | this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
|
|---|
| 110 | }
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | void QConnmanManagerInterface::disconnectNotify(const char *signal)
|
|---|
| 114 | {
|
|---|
| 115 | if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
|
|---|
| 116 |
|
|---|
| 117 | }
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | QVariant QConnmanManagerInterface::getProperty(const QString &property)
|
|---|
| 121 | {
|
|---|
| 122 | QVariant var;
|
|---|
| 123 | QVariantMap map = getProperties();
|
|---|
| 124 | if (map.contains(property)) {
|
|---|
| 125 | var = map.value(property);
|
|---|
| 126 | } else {
|
|---|
| 127 | qDebug() << "does not contain" << property;
|
|---|
| 128 | }
|
|---|
| 129 | return var;
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | QVariantMap QConnmanManagerInterface::getProperties()
|
|---|
| 133 | {
|
|---|
| 134 | if(this->isValid()) {
|
|---|
| 135 | QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
|
|---|
| 136 | return reply.value();
|
|---|
| 137 | } else return QVariantMap();
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | QString QConnmanManagerInterface::getState()
|
|---|
| 141 | {
|
|---|
| 142 | QDBusReply<QString > reply = this->call("GetState");
|
|---|
| 143 | return reply.value();
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | bool QConnmanManagerInterface::setProperty(const QString &name, const QDBusVariant &value)
|
|---|
| 147 | {
|
|---|
| 148 | Q_UNUSED(name);
|
|---|
| 149 | Q_UNUSED(value);
|
|---|
| 150 | return false;
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | QDBusObjectPath QConnmanManagerInterface::createProfile(const QString &/*name*/)
|
|---|
| 154 | {
|
|---|
| 155 | return QDBusObjectPath();
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | bool QConnmanManagerInterface::removeProfile(QDBusObjectPath /*path*/)
|
|---|
| 159 | {
|
|---|
| 160 | return false;
|
|---|
| 161 | }
|
|---|
| 162 |
|
|---|
| 163 | bool QConnmanManagerInterface::requestScan(const QString &type)
|
|---|
| 164 | {
|
|---|
| 165 | QDBusReply<QString> reply = this->call(QLatin1String("RequestScan"), QVariant::fromValue(type));
|
|---|
| 166 |
|
|---|
| 167 | bool ok = true;
|
|---|
| 168 | if(reply.error().type() == QDBusError::InvalidArgs) {
|
|---|
| 169 | qWarning() << reply.error().message();
|
|---|
| 170 | ok = false;
|
|---|
| 171 | }
|
|---|
| 172 | return ok;
|
|---|
| 173 | }
|
|---|
| 174 |
|
|---|
| 175 | bool QConnmanManagerInterface::enableTechnology(const QString &type)
|
|---|
| 176 | {
|
|---|
| 177 | QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("EnableTechnology"), QVariant::fromValue(type));
|
|---|
| 178 | bool ok = true;
|
|---|
| 179 | if(reply.error().type() == QDBusError::InvalidArgs) {
|
|---|
| 180 | qWarning() << reply.error().message();
|
|---|
| 181 | ok = false;
|
|---|
| 182 | }
|
|---|
| 183 | return ok;
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 | bool QConnmanManagerInterface::disableTechnology(const QString &type)
|
|---|
| 187 | {
|
|---|
| 188 | QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("DisableTechnology"), QVariant::fromValue(type));
|
|---|
| 189 | bool ok = true;
|
|---|
| 190 | if(reply.error().type() == QDBusError::InvalidArgs) {
|
|---|
| 191 | qWarning() << reply.error().message();
|
|---|
| 192 | ok = false;
|
|---|
| 193 | }
|
|---|
| 194 | return ok;
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | QDBusObjectPath QConnmanManagerInterface::connectService(QVariantMap &map)
|
|---|
| 198 | {
|
|---|
| 199 | QDBusReply<QDBusObjectPath > reply = this->call(QLatin1String("ConnectService"), QVariant::fromValue(map));
|
|---|
| 200 | if(!reply.isValid()) {
|
|---|
| 201 | qDebug() << reply.error().message();
|
|---|
| 202 |
|
|---|
| 203 | }
|
|---|
| 204 | return reply;
|
|---|
| 205 | }
|
|---|
| 206 |
|
|---|
| 207 | void QConnmanManagerInterface::registerAgent(QDBusObjectPath &/*path*/)
|
|---|
| 208 | {
|
|---|
| 209 | }
|
|---|
| 210 |
|
|---|
| 211 | void QConnmanManagerInterface::unregisterAgent(QDBusObjectPath /*path*/)
|
|---|
| 212 | {
|
|---|
| 213 | }
|
|---|
| 214 |
|
|---|
| 215 | void QConnmanManagerInterface::registerCounter(const QString &path, quint32 interval)
|
|---|
| 216 | { QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("RegisterCounter"),
|
|---|
| 217 | QVariant::fromValue(path),
|
|---|
| 218 | QVariant::fromValue(interval));
|
|---|
| 219 | if(reply.error().type() == QDBusError::InvalidArgs) {
|
|---|
| 220 | qWarning() << reply.error().message();
|
|---|
| 221 | }
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | void QConnmanManagerInterface::unregisterCounter(const QString &path)
|
|---|
| 225 | { QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("UnregisterCounter"),
|
|---|
| 226 | QVariant::fromValue(path));
|
|---|
| 227 | if(reply.error().type() == QDBusError::InvalidArgs) {
|
|---|
| 228 | qWarning() << reply.error().message();
|
|---|
| 229 | }
|
|---|
| 230 | }
|
|---|
| 231 |
|
|---|
| 232 | QString QConnmanManagerInterface::requestSession(const QString &bearerName)
|
|---|
| 233 | {
|
|---|
| 234 | QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("RequestSession"),
|
|---|
| 235 | QVariant::fromValue(bearerName));
|
|---|
| 236 | return QString();
|
|---|
| 237 | }
|
|---|
| 238 |
|
|---|
| 239 | void QConnmanManagerInterface::releaseSession()
|
|---|
| 240 | {
|
|---|
| 241 | QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("ReleaseSession"));
|
|---|
| 242 | }
|
|---|
| 243 |
|
|---|
| 244 |
|
|---|
| 245 | QDBusObjectPath QConnmanManagerInterface::lookupService(const QString &service)
|
|---|
| 246 | {
|
|---|
| 247 | QDBusReply<QDBusObjectPath > reply = this->call(QLatin1String("LookupService"), QVariant::fromValue(service));
|
|---|
| 248 | if(!reply.isValid()) {
|
|---|
| 249 | qDebug() << reply.error().message();
|
|---|
| 250 | }
|
|---|
| 251 | return reply;
|
|---|
| 252 | }
|
|---|
| 253 |
|
|---|
| 254 | // properties
|
|---|
| 255 |
|
|---|
| 256 | QStringList QConnmanManagerInterface::getAvailableTechnologies()
|
|---|
| 257 | {
|
|---|
| 258 | QVariant var = getProperty("AvailableTechnologies");
|
|---|
| 259 | return qdbus_cast<QStringList>(var);
|
|---|
| 260 | }
|
|---|
| 261 |
|
|---|
| 262 | QStringList QConnmanManagerInterface::getEnabledTechnologies()
|
|---|
| 263 | {
|
|---|
| 264 | QVariant var = getProperty("EnabledTechnologies");
|
|---|
| 265 | return qdbus_cast<QStringList>(var);
|
|---|
| 266 | }
|
|---|
| 267 |
|
|---|
| 268 | QStringList QConnmanManagerInterface::getConnectedTechnologies()
|
|---|
| 269 | {
|
|---|
| 270 | QVariant var = getProperty("ConnectedTechnologies");
|
|---|
| 271 | return qdbus_cast<QStringList>(var);
|
|---|
| 272 | }
|
|---|
| 273 |
|
|---|
| 274 | QString QConnmanManagerInterface::getDefaultTechnology()
|
|---|
| 275 | {
|
|---|
| 276 | QVariant var = getProperty("DefaultTechnology");
|
|---|
| 277 | return qdbus_cast<QString>(var);
|
|---|
| 278 | }
|
|---|
| 279 |
|
|---|
| 280 | bool QConnmanManagerInterface::getOfflineMode()
|
|---|
| 281 | {
|
|---|
| 282 | QVariant var = getProperty("OfflineMode");
|
|---|
| 283 | return qdbus_cast<bool>(var);
|
|---|
| 284 | }
|
|---|
| 285 |
|
|---|
| 286 | QString QConnmanManagerInterface::getActiveProfile()
|
|---|
| 287 | {
|
|---|
| 288 | QVariant var = getProperty("ActiveProfile");
|
|---|
| 289 | return qdbus_cast<QString>(var);
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | QStringList QConnmanManagerInterface::getProfiles()
|
|---|
| 293 | {
|
|---|
| 294 | QVariant var = getProperty("Profiles");
|
|---|
| 295 | return qdbus_cast<QStringList>(var);
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | QStringList QConnmanManagerInterface::getTechnologies()
|
|---|
| 299 | {
|
|---|
| 300 | QVariant var = getProperty("Technologies");
|
|---|
| 301 | return qdbus_cast<QStringList >(var);
|
|---|
| 302 | }
|
|---|
| 303 |
|
|---|
| 304 | QStringList QConnmanManagerInterface::getServices()
|
|---|
| 305 | {
|
|---|
| 306 | QVariant var = getProperty("Services");
|
|---|
| 307 | return qdbus_cast<QStringList >(var);
|
|---|
| 308 | }
|
|---|
| 309 |
|
|---|
| 310 | QString QConnmanManagerInterface::getPathForTechnology(const QString &name)
|
|---|
| 311 | {
|
|---|
| 312 | foreach(const QString path, getTechnologies()) {
|
|---|
| 313 | if(path.contains(name)) {
|
|---|
| 314 | return path;
|
|---|
| 315 | }
|
|---|
| 316 | }
|
|---|
| 317 | return "";
|
|---|
| 318 | }
|
|---|
| 319 |
|
|---|
| 320 |
|
|---|
| 321 | //////////////////////////
|
|---|
| 322 | QConnmanProfileInterface::QConnmanProfileInterface(const QString &dbusPathName,QObject *parent)
|
|---|
| 323 | : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
|
|---|
| 324 | dbusPathName,
|
|---|
| 325 | CONNMAN_PROFILE_INTERFACE,
|
|---|
| 326 | QDBusConnection::systemBus(), parent)
|
|---|
| 327 | {
|
|---|
| 328 | }
|
|---|
| 329 |
|
|---|
| 330 | QConnmanProfileInterface::~QConnmanProfileInterface()
|
|---|
| 331 | {
|
|---|
| 332 | }
|
|---|
| 333 |
|
|---|
| 334 | void QConnmanProfileInterface::connectNotify(const char *signal)
|
|---|
| 335 | {
|
|---|
| 336 | if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
|
|---|
| 337 | dbusConnection.connect(QLatin1String(CONNMAN_SERVICE),
|
|---|
| 338 | this->path(),
|
|---|
| 339 | QLatin1String(CONNMAN_PROFILE_INTERFACE),
|
|---|
| 340 | QLatin1String("PropertyChanged"),
|
|---|
| 341 | this,SIGNAL(propertyChanged(QString,QDBusVariant)));
|
|---|
| 342 | }
|
|---|
| 343 | }
|
|---|
| 344 |
|
|---|
| 345 | void QConnmanProfileInterface::disconnectNotify(const char *signal)
|
|---|
| 346 | {
|
|---|
| 347 | if (QLatin1String(signal) == SIGNAL(propertyChanged(QString, QVariant))) {
|
|---|
| 348 |
|
|---|
| 349 | }
|
|---|
| 350 | }
|
|---|
| 351 |
|
|---|
| 352 | QVariantMap QConnmanProfileInterface::getProperties()
|
|---|
| 353 | {
|
|---|
| 354 | QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
|
|---|
| 355 | return reply.value();
|
|---|
| 356 | }
|
|---|
| 357 |
|
|---|
| 358 | QVariant QConnmanProfileInterface::getProperty(const QString &property)
|
|---|
| 359 | {
|
|---|
| 360 | QVariant var;
|
|---|
| 361 | QVariantMap map = getProperties();
|
|---|
| 362 | if (map.contains(property)) {
|
|---|
| 363 | var = map.value(property);
|
|---|
| 364 | }
|
|---|
| 365 | return var;
|
|---|
| 366 | }
|
|---|
| 367 |
|
|---|
| 368 | // properties
|
|---|
| 369 | QString QConnmanProfileInterface::getName()
|
|---|
| 370 | {
|
|---|
| 371 |
|
|---|
| 372 | QVariant var = getProperty("Name");
|
|---|
| 373 | return qdbus_cast<QString>(var);
|
|---|
| 374 | }
|
|---|
| 375 |
|
|---|
| 376 | bool QConnmanProfileInterface::isOfflineMode()
|
|---|
| 377 | {
|
|---|
| 378 | QVariant var = getProperty("OfflineMode");
|
|---|
| 379 | return qdbus_cast<bool>(var);
|
|---|
| 380 | }
|
|---|
| 381 |
|
|---|
| 382 | QStringList QConnmanProfileInterface::getServices()
|
|---|
| 383 | {
|
|---|
| 384 | QVariant var = getProperty("Services");
|
|---|
| 385 | return qdbus_cast<QStringList>(var);
|
|---|
| 386 | }
|
|---|
| 387 |
|
|---|
| 388 |
|
|---|
| 389 | ///////////////////////////
|
|---|
| 390 | QConnmanServiceInterface::QConnmanServiceInterface(const QString &dbusPathName,QObject *parent)
|
|---|
| 391 | : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
|
|---|
| 392 | dbusPathName,
|
|---|
| 393 | CONNMAN_SERVICE_INTERFACE,
|
|---|
| 394 | QDBusConnection::systemBus(), parent)
|
|---|
| 395 | {
|
|---|
| 396 | }
|
|---|
| 397 |
|
|---|
| 398 | QConnmanServiceInterface::~QConnmanServiceInterface()
|
|---|
| 399 | {
|
|---|
| 400 | }
|
|---|
| 401 |
|
|---|
| 402 | void QConnmanServiceInterface::connectNotify(const char *signal)
|
|---|
| 403 | {
|
|---|
| 404 | if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
|
|---|
| 405 | dbusConnection.connect(QLatin1String(CONNMAN_SERVICE),
|
|---|
| 406 | this->path(),
|
|---|
| 407 | QLatin1String(CONNMAN_SERVICE_INTERFACE),
|
|---|
| 408 | QLatin1String("PropertyChanged"),
|
|---|
| 409 | this,SIGNAL(propertyChanged(QString,QDBusVariant)));
|
|---|
| 410 | }
|
|---|
| 411 | if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
|
|---|
| 412 | QConnmanDBusHelper *helper;
|
|---|
| 413 | helper = new QConnmanDBusHelper(this);
|
|---|
| 414 |
|
|---|
| 415 | dbusConnection.connect(QLatin1String(CONNMAN_SERVICE),
|
|---|
| 416 | this->path(),
|
|---|
| 417 | QLatin1String(CONNMAN_SERVICE_INTERFACE),
|
|---|
| 418 | QLatin1String("PropertyChanged"),
|
|---|
| 419 | helper,SLOT(propertyChanged(QString,QDBusVariant)));
|
|---|
| 420 |
|
|---|
| 421 | QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
|
|---|
| 422 | this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
|
|---|
| 423 | }
|
|---|
| 424 | }
|
|---|
| 425 |
|
|---|
| 426 | void QConnmanServiceInterface::disconnectNotify(const char *signal)
|
|---|
| 427 | {
|
|---|
| 428 | if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
|
|---|
| 429 |
|
|---|
| 430 | }
|
|---|
| 431 | }
|
|---|
| 432 |
|
|---|
| 433 | QVariantMap QConnmanServiceInterface::getProperties()
|
|---|
| 434 | {
|
|---|
| 435 | if(this->isValid()) {
|
|---|
| 436 | QDBusReply<QVariantMap> reply = this->call(QLatin1String("GetProperties"));
|
|---|
| 437 | return reply.value();
|
|---|
| 438 | }
|
|---|
| 439 | else
|
|---|
| 440 | return QVariantMap();
|
|---|
| 441 | }
|
|---|
| 442 |
|
|---|
| 443 | QVariant QConnmanServiceInterface::getProperty(const QString &property)
|
|---|
| 444 | {
|
|---|
| 445 | QVariant var;
|
|---|
| 446 | QVariantMap map = getProperties();
|
|---|
| 447 | if (map.contains(property)) {
|
|---|
| 448 | var = map.value(property);
|
|---|
| 449 | }
|
|---|
| 450 | return var;
|
|---|
| 451 | }
|
|---|
| 452 |
|
|---|
| 453 | void QConnmanServiceInterface::connect()
|
|---|
| 454 | {
|
|---|
| 455 | this->asyncCall(QLatin1String("Connect"));
|
|---|
| 456 | }
|
|---|
| 457 |
|
|---|
| 458 | void QConnmanServiceInterface::disconnect()
|
|---|
| 459 | {
|
|---|
| 460 | QDBusReply<QVariantMap> reply = this->call(QLatin1String("Disconnect"));
|
|---|
| 461 | }
|
|---|
| 462 |
|
|---|
| 463 | void QConnmanServiceInterface::remove()
|
|---|
| 464 | {
|
|---|
| 465 | QDBusReply<QVariantMap> reply = this->call(QLatin1String("Remove"));
|
|---|
| 466 | }
|
|---|
| 467 |
|
|---|
| 468 | // void moveBefore(QDBusObjectPath &service);
|
|---|
| 469 | // void moveAfter(QDBusObjectPath &service);
|
|---|
| 470 |
|
|---|
| 471 | // properties
|
|---|
| 472 | QString QConnmanServiceInterface::getState()
|
|---|
| 473 | {
|
|---|
| 474 | QVariant var = getProperty("State");
|
|---|
| 475 | return qdbus_cast<QString>(var);
|
|---|
| 476 | }
|
|---|
| 477 |
|
|---|
| 478 | QString QConnmanServiceInterface::getError()
|
|---|
| 479 | {
|
|---|
| 480 | QVariant var = getProperty("Error");
|
|---|
| 481 | return qdbus_cast<QString>(var);
|
|---|
| 482 | }
|
|---|
| 483 |
|
|---|
| 484 | QString QConnmanServiceInterface::getName()
|
|---|
| 485 | {
|
|---|
| 486 | QVariant var = getProperty("Name");
|
|---|
| 487 | return qdbus_cast<QString>(var);
|
|---|
| 488 | }
|
|---|
| 489 |
|
|---|
| 490 | QString QConnmanServiceInterface::getType()
|
|---|
| 491 | {
|
|---|
| 492 | QVariant var = getProperty("Type");
|
|---|
| 493 | return qdbus_cast<QString>(var);
|
|---|
| 494 | }
|
|---|
| 495 |
|
|---|
| 496 | QString QConnmanServiceInterface::getMode()
|
|---|
| 497 | {
|
|---|
| 498 | QVariant var = getProperty("Mode");
|
|---|
| 499 | return qdbus_cast<QString>(var);
|
|---|
| 500 | }
|
|---|
| 501 |
|
|---|
| 502 | QString QConnmanServiceInterface::getSecurity()
|
|---|
| 503 | {
|
|---|
| 504 | QVariant var = getProperty("Security");
|
|---|
| 505 | return qdbus_cast<QString>(var);
|
|---|
| 506 | }
|
|---|
| 507 |
|
|---|
| 508 | QString QConnmanServiceInterface::getPassphrase()
|
|---|
| 509 | {
|
|---|
| 510 | QVariant var = getProperty("Passphrase");
|
|---|
| 511 | return qdbus_cast<QString>(var);
|
|---|
| 512 | }
|
|---|
| 513 |
|
|---|
| 514 | bool QConnmanServiceInterface::isPassphraseRequired()
|
|---|
| 515 | {
|
|---|
| 516 | QVariant var = getProperty("PassphraseRequired");
|
|---|
| 517 | return qdbus_cast<bool>(var);
|
|---|
| 518 | }
|
|---|
| 519 |
|
|---|
| 520 | quint8 QConnmanServiceInterface::getSignalStrength()
|
|---|
| 521 | {
|
|---|
| 522 | QVariant var = getProperty("Strength");
|
|---|
| 523 | return qdbus_cast<quint8>(var);
|
|---|
| 524 | }
|
|---|
| 525 |
|
|---|
| 526 | bool QConnmanServiceInterface::isFavorite()
|
|---|
| 527 | {
|
|---|
| 528 | QVariant var = getProperty("Favorite");
|
|---|
| 529 | return qdbus_cast<bool>(var);
|
|---|
| 530 | }
|
|---|
| 531 |
|
|---|
| 532 | bool QConnmanServiceInterface::isImmutable()
|
|---|
| 533 | {
|
|---|
| 534 | QVariant var = getProperty("Immutable");
|
|---|
| 535 | return qdbus_cast<bool>(var);
|
|---|
| 536 | }
|
|---|
| 537 |
|
|---|
| 538 | bool QConnmanServiceInterface::isAutoConnect()
|
|---|
| 539 | {
|
|---|
| 540 | QVariant var = getProperty("AutoConnect");
|
|---|
| 541 | return qdbus_cast<bool>(var);
|
|---|
| 542 | }
|
|---|
| 543 |
|
|---|
| 544 | bool QConnmanServiceInterface::isSetupRequired()
|
|---|
| 545 | {
|
|---|
| 546 | QVariant var = getProperty("SetupRequired");
|
|---|
| 547 | return qdbus_cast<bool>(var);
|
|---|
| 548 | }
|
|---|
| 549 |
|
|---|
| 550 | QString QConnmanServiceInterface::getAPN()
|
|---|
| 551 | {
|
|---|
| 552 | QVariant var = getProperty("APN");
|
|---|
| 553 | return qdbus_cast<QString>(var);
|
|---|
| 554 | }
|
|---|
| 555 |
|
|---|
| 556 | QString QConnmanServiceInterface::getMCC()
|
|---|
| 557 | {
|
|---|
| 558 | QVariant var = getProperty("MCC");
|
|---|
| 559 | return qdbus_cast<QString>(var);
|
|---|
| 560 | }
|
|---|
| 561 |
|
|---|
| 562 | QString QConnmanServiceInterface::getMNC()
|
|---|
| 563 | {
|
|---|
| 564 | QVariant var = getProperty("MNC");
|
|---|
| 565 | return qdbus_cast<QString>(var);
|
|---|
| 566 | }
|
|---|
| 567 |
|
|---|
| 568 | bool QConnmanServiceInterface::isRoaming()
|
|---|
| 569 | {
|
|---|
| 570 | QVariant var = getProperty("Roaming");
|
|---|
| 571 | return qdbus_cast<bool>(var);
|
|---|
| 572 | }
|
|---|
| 573 |
|
|---|
| 574 | QStringList QConnmanServiceInterface::getNameservers()
|
|---|
| 575 | {
|
|---|
| 576 | QVariant var = getProperty("NameServers");
|
|---|
| 577 | return qdbus_cast<QStringList>(var);
|
|---|
| 578 | }
|
|---|
| 579 |
|
|---|
| 580 | QStringList QConnmanServiceInterface::getDomains()
|
|---|
| 581 | {
|
|---|
| 582 | QVariant var = getProperty("Domains");
|
|---|
| 583 | return qdbus_cast<QStringList>(var);
|
|---|
| 584 | }
|
|---|
| 585 |
|
|---|
| 586 | QVariantMap QConnmanServiceInterface::getIPv4()
|
|---|
| 587 | {
|
|---|
| 588 | QVariant var = getProperty("IPv4");
|
|---|
| 589 | return qdbus_cast<QVariantMap >(var);
|
|---|
| 590 | }
|
|---|
| 591 |
|
|---|
| 592 | QVariantMap QConnmanServiceInterface::getIPv4Configuration()
|
|---|
| 593 | {
|
|---|
| 594 | QVariant var = getProperty("IPv4.Configuration");
|
|---|
| 595 | return qdbus_cast<QVariantMap >(var);
|
|---|
| 596 | }
|
|---|
| 597 |
|
|---|
| 598 | QVariantMap QConnmanServiceInterface::getProxy()
|
|---|
| 599 | {
|
|---|
| 600 | QVariant var = getProperty("Proxy");
|
|---|
| 601 | return qdbus_cast<QVariantMap >(var);
|
|---|
| 602 | }
|
|---|
| 603 |
|
|---|
| 604 | QVariantMap QConnmanServiceInterface::getEthernet()
|
|---|
| 605 | {
|
|---|
| 606 | QVariant var = getProperty("Ethernet");
|
|---|
| 607 | return qdbus_cast<QVariantMap >(var);
|
|---|
| 608 | }
|
|---|
| 609 |
|
|---|
| 610 | QString QConnmanServiceInterface::getMethod()
|
|---|
| 611 | {
|
|---|
| 612 | QVariant var;
|
|---|
| 613 | QVariantMap map = getEthernet();
|
|---|
| 614 | QMapIterator<QString,QVariant> it(map);
|
|---|
| 615 | while(it.hasNext()) {
|
|---|
| 616 | it.next();
|
|---|
| 617 | if(it.key() == "Method") {
|
|---|
| 618 | return it.value().toString();
|
|---|
| 619 | }
|
|---|
| 620 | }
|
|---|
| 621 | return QString();
|
|---|
| 622 | }
|
|---|
| 623 |
|
|---|
| 624 | QString QConnmanServiceInterface::getInterface()
|
|---|
| 625 | {
|
|---|
| 626 | QVariant var;
|
|---|
| 627 | QVariantMap map = getEthernet();
|
|---|
| 628 |
|
|---|
| 629 | QMapIterator<QString,QVariant> it(map);
|
|---|
| 630 | while(it.hasNext()) {
|
|---|
| 631 | it.next();
|
|---|
| 632 | if(it.key() == "Interface") {
|
|---|
| 633 | return it.value().toString();
|
|---|
| 634 | }
|
|---|
| 635 | }
|
|---|
| 636 |
|
|---|
| 637 | return QString();
|
|---|
| 638 | }
|
|---|
| 639 |
|
|---|
| 640 | QString QConnmanServiceInterface::getMacAddress()
|
|---|
| 641 | {
|
|---|
| 642 | QVariant var;
|
|---|
| 643 | QVariantMap map = getEthernet();
|
|---|
| 644 |
|
|---|
| 645 | QMapIterator<QString,QVariant> it(map);
|
|---|
| 646 | while(it.hasNext()) {
|
|---|
| 647 | it.next();
|
|---|
| 648 | if(it.key() == "Address") {
|
|---|
| 649 | return it.value().toString();
|
|---|
| 650 | }
|
|---|
| 651 | }
|
|---|
| 652 | return QString();
|
|---|
| 653 | }
|
|---|
| 654 |
|
|---|
| 655 | quint16 QConnmanServiceInterface::getMtu()
|
|---|
| 656 | {
|
|---|
| 657 | quint16 mtu=0;
|
|---|
| 658 | QVariant var;
|
|---|
| 659 | QVariantMap map = getEthernet();
|
|---|
| 660 |
|
|---|
| 661 | QMapIterator<QString,QVariant> it(map);
|
|---|
| 662 | while(it.hasNext()) {
|
|---|
| 663 | it.next();
|
|---|
| 664 | if(it.key() == "MTU") {
|
|---|
| 665 | return it.value().toUInt();
|
|---|
| 666 | }
|
|---|
| 667 | }
|
|---|
| 668 | return mtu;
|
|---|
| 669 | }
|
|---|
| 670 |
|
|---|
| 671 | quint16 QConnmanServiceInterface::getSpeed()
|
|---|
| 672 | {
|
|---|
| 673 | quint16 speed=0;
|
|---|
| 674 | QVariant var;
|
|---|
| 675 | QVariantMap map = getEthernet();
|
|---|
| 676 |
|
|---|
| 677 | QMapIterator<QString,QVariant> it(map);
|
|---|
| 678 | while(it.hasNext()) {
|
|---|
| 679 | it.next();
|
|---|
| 680 | if(it.key() == "Speed") {
|
|---|
| 681 | return it.value().toUInt();
|
|---|
| 682 | }
|
|---|
| 683 | }
|
|---|
| 684 | return speed;
|
|---|
| 685 | }
|
|---|
| 686 |
|
|---|
| 687 | QString QConnmanServiceInterface::getDuplex()
|
|---|
| 688 | {
|
|---|
| 689 | QVariant var;
|
|---|
| 690 | QVariantMap map = getEthernet();
|
|---|
| 691 |
|
|---|
| 692 | QMapIterator<QString,QVariant> it(map);
|
|---|
| 693 | while(it.hasNext()) {
|
|---|
| 694 | it.next();
|
|---|
| 695 | if(it.key() == "Duplex") {
|
|---|
| 696 | return it.value().toString();
|
|---|
| 697 | }
|
|---|
| 698 | }
|
|---|
| 699 | return QString();
|
|---|
| 700 | }
|
|---|
| 701 |
|
|---|
| 702 |
|
|---|
| 703 | bool QConnmanServiceInterface::isOfflineMode()
|
|---|
| 704 | {
|
|---|
| 705 | QVariant var = getProperty("OfflineMode");
|
|---|
| 706 | return qdbus_cast<bool>(var);
|
|---|
| 707 | }
|
|---|
| 708 |
|
|---|
| 709 | QStringList QConnmanServiceInterface::getServices()
|
|---|
| 710 | {
|
|---|
| 711 | QVariant var = getProperty("Services");
|
|---|
| 712 | return qdbus_cast<QStringList>(var);
|
|---|
| 713 | }
|
|---|
| 714 |
|
|---|
| 715 |
|
|---|
| 716 | //////////////////////////
|
|---|
| 717 | QConnmanTechnologyInterface::QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent)
|
|---|
| 718 | : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
|
|---|
| 719 | dbusPathName,
|
|---|
| 720 | CONNMAN_TECHNOLOGY_INTERFACE,
|
|---|
| 721 | QDBusConnection::systemBus(), parent)
|
|---|
| 722 | {
|
|---|
| 723 | }
|
|---|
| 724 |
|
|---|
| 725 | QConnmanTechnologyInterface::~QConnmanTechnologyInterface()
|
|---|
| 726 | {
|
|---|
| 727 | }
|
|---|
| 728 |
|
|---|
| 729 | void QConnmanTechnologyInterface::connectNotify(const char *signal)
|
|---|
| 730 | {
|
|---|
| 731 | if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
|
|---|
| 732 | dbusConnection.connect(QLatin1String(CONNMAN_SERVICE),
|
|---|
| 733 | this->path(),
|
|---|
| 734 | QLatin1String(CONNMAN_TECHNOLOGY_INTERFACE),
|
|---|
| 735 | QLatin1String("PropertyChanged"),
|
|---|
| 736 | this,SIGNAL(propertyChanged(QString,QDBusVariant)));
|
|---|
| 737 | }
|
|---|
| 738 | if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
|
|---|
| 739 | QConnmanDBusHelper *helper;
|
|---|
| 740 | helper = new QConnmanDBusHelper(this);
|
|---|
| 741 |
|
|---|
| 742 | dbusConnection.connect(QLatin1String(CONNMAN_SERVICE),
|
|---|
| 743 | this->path(),
|
|---|
| 744 | QLatin1String(CONNMAN_TECHNOLOGY_INTERFACE),
|
|---|
| 745 | QLatin1String("PropertyChanged"),
|
|---|
| 746 | helper,SLOT(propertyChanged(QString,QDBusVariant)));
|
|---|
| 747 |
|
|---|
| 748 | QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
|
|---|
| 749 | this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
|
|---|
| 750 | }
|
|---|
| 751 | }
|
|---|
| 752 |
|
|---|
| 753 | void QConnmanTechnologyInterface::disconnectNotify(const char *signal)
|
|---|
| 754 | {
|
|---|
| 755 | if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
|
|---|
| 756 |
|
|---|
| 757 | }
|
|---|
| 758 | }
|
|---|
| 759 |
|
|---|
| 760 | QVariantMap QConnmanTechnologyInterface::getProperties()
|
|---|
| 761 | {
|
|---|
| 762 | QDBusReply<QVariantMap> reply = this->call(QLatin1String("GetProperties"));
|
|---|
| 763 | return reply.value();
|
|---|
| 764 | }
|
|---|
| 765 |
|
|---|
| 766 | QVariant QConnmanTechnologyInterface::getProperty(const QString &property)
|
|---|
| 767 | {
|
|---|
| 768 | QVariant var;
|
|---|
| 769 | QVariantMap map = getProperties();
|
|---|
| 770 | if (map.contains(property)) {
|
|---|
| 771 | var = map.value(property);
|
|---|
| 772 | }
|
|---|
| 773 | return var;
|
|---|
| 774 | }
|
|---|
| 775 |
|
|---|
| 776 | // properties
|
|---|
| 777 | QString QConnmanTechnologyInterface::getState()
|
|---|
| 778 | {
|
|---|
| 779 | QVariant var = getProperty("State");
|
|---|
| 780 | return qdbus_cast<QString>(var);
|
|---|
| 781 | }
|
|---|
| 782 |
|
|---|
| 783 | QString QConnmanTechnologyInterface::getName()
|
|---|
| 784 | {
|
|---|
| 785 | QVariant var = getProperty("Name");
|
|---|
| 786 | return qdbus_cast<QString>(var);
|
|---|
| 787 | }
|
|---|
| 788 |
|
|---|
| 789 | QString QConnmanTechnologyInterface::getType()
|
|---|
| 790 | {
|
|---|
| 791 | QVariant var = getProperty("Type");
|
|---|
| 792 | return qdbus_cast<QString>(var);
|
|---|
| 793 | }
|
|---|
| 794 |
|
|---|
| 795 |
|
|---|
| 796 | //////////////////////////////////
|
|---|
| 797 | QConnmanAgentInterface::QConnmanAgentInterface(const QString &dbusPathName, QObject *parent)
|
|---|
| 798 | : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
|
|---|
| 799 | dbusPathName,
|
|---|
| 800 | CONNMAN_AGENT_INTERFACE,
|
|---|
| 801 | QDBusConnection::systemBus(), parent)
|
|---|
| 802 | {
|
|---|
| 803 | }
|
|---|
| 804 |
|
|---|
| 805 | QConnmanAgentInterface::~QConnmanAgentInterface()
|
|---|
| 806 | {
|
|---|
| 807 | }
|
|---|
| 808 |
|
|---|
| 809 | void QConnmanAgentInterface::connectNotify(const char *signal)
|
|---|
| 810 | {
|
|---|
| 811 | if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
|
|---|
| 812 | // dbusConnection.connect(QLatin1String(CONNMAN_SERVICE),
|
|---|
| 813 | // this->path(),
|
|---|
| 814 | // QLatin1String(CONNMAN_NETWORK_INTERFACE),
|
|---|
| 815 | // QLatin1String("PropertyChanged"),
|
|---|
| 816 | // this,SIGNAL(propertyChanged(const QString &, QVariant &)));
|
|---|
| 817 | }
|
|---|
| 818 | }
|
|---|
| 819 |
|
|---|
| 820 | void QConnmanAgentInterface::disconnectNotify(const char *signal)
|
|---|
| 821 | {
|
|---|
| 822 | if (QLatin1String(signal) == SIGNAL(propertyChanged(QString, QDBusVariant))) {
|
|---|
| 823 |
|
|---|
| 824 | }
|
|---|
| 825 | }
|
|---|
| 826 |
|
|---|
| 827 |
|
|---|
| 828 | void QConnmanAgentInterface::release()
|
|---|
| 829 | {
|
|---|
| 830 | }
|
|---|
| 831 |
|
|---|
| 832 | void QConnmanAgentInterface::reportError(QDBusObjectPath &/*path*/, const QString &/*error*/)
|
|---|
| 833 | {
|
|---|
| 834 | }
|
|---|
| 835 |
|
|---|
| 836 | //dict QConnmanAgentInterface::requestInput(QDBusObjectPath &path, dict fields)
|
|---|
| 837 | //{
|
|---|
| 838 | //}
|
|---|
| 839 |
|
|---|
| 840 | void QConnmanAgentInterface::cancel()
|
|---|
| 841 | {
|
|---|
| 842 | }
|
|---|
| 843 |
|
|---|
| 844 |
|
|---|
| 845 | /////////////////////////////////////////
|
|---|
| 846 | QConnmanCounterInterface::QConnmanCounterInterface(const QString &dbusPathName,QObject *parent)
|
|---|
| 847 | : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
|
|---|
| 848 | dbusPathName,
|
|---|
| 849 | CONNMAN_COUNTER_INTERFACE,
|
|---|
| 850 | QDBusConnection::systemBus(), parent)
|
|---|
| 851 | {
|
|---|
| 852 | }
|
|---|
| 853 |
|
|---|
| 854 | QConnmanCounterInterface::~QConnmanCounterInterface()
|
|---|
| 855 | {
|
|---|
| 856 | }
|
|---|
| 857 |
|
|---|
| 858 | quint32 QConnmanCounterInterface::getReceivedByteCount()
|
|---|
| 859 | {
|
|---|
| 860 | return 0;
|
|---|
| 861 | }
|
|---|
| 862 |
|
|---|
| 863 | quint32 QConnmanCounterInterface::getTransmittedByteCount()
|
|---|
| 864 | {
|
|---|
| 865 | return 0;
|
|---|
| 866 | }
|
|---|
| 867 |
|
|---|
| 868 | quint64 QConnmanCounterInterface::getTimeOnline()
|
|---|
| 869 | {
|
|---|
| 870 | return 0;
|
|---|
| 871 | }
|
|---|
| 872 |
|
|---|
| 873 |
|
|---|
| 874 | /////////////////////////////////////////
|
|---|
| 875 | QConnmanDBusHelper::QConnmanDBusHelper(QObject * parent)
|
|---|
| 876 | : QObject(parent)
|
|---|
| 877 | {
|
|---|
| 878 | }
|
|---|
| 879 |
|
|---|
| 880 | QConnmanDBusHelper::~QConnmanDBusHelper()
|
|---|
| 881 | {
|
|---|
| 882 | }
|
|---|
| 883 |
|
|---|
| 884 | void QConnmanDBusHelper::propertyChanged(const QString &item, const QDBusVariant &var)
|
|---|
| 885 | {
|
|---|
| 886 | QDBusMessage msg = this->message();
|
|---|
| 887 | Q_EMIT propertyChangedContext(msg.path() ,item, var);
|
|---|
| 888 | }
|
|---|
| 889 |
|
|---|
| 890 | /////////////////
|
|---|
| 891 | QT_END_NAMESPACE
|
|---|
| 892 |
|
|---|
| 893 | #endif // QT_NO_DBUS
|
|---|
| 894 | #endif // QT_NO_BEARERMANAGEMENT
|
|---|
| 895 |
|
|---|