src/plugins/bearer/connman/qofonoservice_linux.cpp
changeset 37 758a864f9613
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 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 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    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 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    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 "qofonoservice_linux_p.h"
       
    55 
       
    56 
       
    57 QT_BEGIN_NAMESPACE
       
    58 static QDBusConnection dbusConnection = QDBusConnection::systemBus();
       
    59 
       
    60 
       
    61 QOfonoManagerInterface::QOfonoManagerInterface( QObject *parent)
       
    62         : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
       
    63                                  QLatin1String(OFONO_MANAGER_PATH),
       
    64                                  OFONO_MANAGER_INTERFACE,
       
    65                                  QDBusConnection::systemBus(), parent)
       
    66 {
       
    67 }
       
    68 
       
    69 QOfonoManagerInterface::~QOfonoManagerInterface()
       
    70 {
       
    71 }
       
    72 
       
    73 QList <QDBusObjectPath> QOfonoManagerInterface::getModems()
       
    74 {
       
    75     QVariant var = getProperty("Modems");
       
    76     return qdbus_cast<QList<QDBusObjectPath> >(var);
       
    77 }
       
    78 
       
    79 QDBusObjectPath QOfonoManagerInterface::currentModem()
       
    80 {
       
    81     QList<QDBusObjectPath> modems = getModems();
       
    82     foreach(const QDBusObjectPath modem, modems) {
       
    83         QOfonoModemInterface device(modem.path());
       
    84         if(device.isPowered() && device.isOnline())
       
    85         return modem;;
       
    86     }
       
    87     return QDBusObjectPath();
       
    88 }
       
    89 
       
    90 
       
    91 void QOfonoManagerInterface::connectNotify(const char *signal)
       
    92 {
       
    93 if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
       
    94         if(!connection().connect(QLatin1String(OFONO_SERVICE),
       
    95                                QLatin1String(OFONO_MANAGER_PATH),
       
    96                                QLatin1String(OFONO_MANAGER_INTERFACE),
       
    97                                QLatin1String("PropertyChanged"),
       
    98                                this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
       
    99             qWarning() << "PropertyCHanged not connected";
       
   100         }
       
   101     }
       
   102 
       
   103     if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
       
   104         QOfonoDBusHelper *helper;
       
   105         helper = new QOfonoDBusHelper(this);
       
   106 
       
   107         dbusConnection.connect(QLatin1String(OFONO_SERVICE),
       
   108                                QLatin1String(OFONO_MANAGER_PATH),
       
   109                                QLatin1String(OFONO_MANAGER_INTERFACE),
       
   110                                QLatin1String("PropertyChanged"),
       
   111                                helper,SLOT(propertyChanged(QString,QDBusVariant)));
       
   112 
       
   113 
       
   114         QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
       
   115                 this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
       
   116     }
       
   117 }
       
   118 
       
   119 void QOfonoManagerInterface::disconnectNotify(const char *signal)
       
   120 {
       
   121     if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
       
   122 
       
   123     }
       
   124 }
       
   125 
       
   126 QVariant QOfonoManagerInterface::getProperty(const QString &property)
       
   127 {
       
   128     QVariantMap map = getProperties();
       
   129     if (map.contains(property)) {
       
   130         return map.value(property);
       
   131     } else {
       
   132         qDebug() << Q_FUNC_INFO << "does not contain" << property;
       
   133     }
       
   134     return QVariant();
       
   135 }
       
   136 
       
   137 QVariantMap QOfonoManagerInterface::getProperties()
       
   138 {
       
   139     QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
       
   140     if(reply.isValid())
       
   141         return reply.value();
       
   142     else
       
   143         return QVariantMap();
       
   144 }
       
   145 
       
   146 QOfonoDBusHelper::QOfonoDBusHelper(QObject * parent)
       
   147         : QObject(parent)
       
   148 {
       
   149 }
       
   150 
       
   151 QOfonoDBusHelper::~QOfonoDBusHelper()
       
   152 {
       
   153 }
       
   154 
       
   155 void QOfonoDBusHelper::propertyChanged(const QString &item, const QDBusVariant &var)
       
   156 {
       
   157     QDBusMessage msg = this->message();
       
   158     Q_EMIT propertyChangedContext(msg.path() ,item, var);
       
   159 }
       
   160 
       
   161 
       
   162 QOfonoModemInterface::QOfonoModemInterface(const QString &dbusPathName, QObject *parent)
       
   163     : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
       
   164                              dbusPathName,
       
   165                              OFONO_MODEM_INTERFACE,
       
   166                              QDBusConnection::systemBus(), parent)
       
   167 {
       
   168 }
       
   169 
       
   170 QOfonoModemInterface::~QOfonoModemInterface()
       
   171 {
       
   172 }
       
   173 
       
   174 bool QOfonoModemInterface::isPowered()
       
   175 {
       
   176     QVariant var = getProperty("Powered");
       
   177     return qdbus_cast<bool>(var);
       
   178 }
       
   179 
       
   180 bool QOfonoModemInterface::isOnline()
       
   181 {
       
   182     QVariant var = getProperty("Online");
       
   183     return qdbus_cast<bool>(var);
       
   184 }
       
   185 
       
   186 QString QOfonoModemInterface::getName()
       
   187 {
       
   188     QVariant var = getProperty("Name");
       
   189     return qdbus_cast<QString>(var);
       
   190 }
       
   191 
       
   192 QString QOfonoModemInterface::getManufacturer()
       
   193 {
       
   194     QVariant var = getProperty("Manufacturer");
       
   195     return qdbus_cast<QString>(var);
       
   196 
       
   197 }
       
   198 
       
   199 QString QOfonoModemInterface::getModel()
       
   200 {
       
   201 
       
   202     QVariant var = getProperty("Model");
       
   203     return qdbus_cast<QString>(var);
       
   204 }
       
   205 
       
   206 QString QOfonoModemInterface::getRevision()
       
   207 {
       
   208     QVariant var = getProperty("Revision");
       
   209     return qdbus_cast<QString>(var);
       
   210 
       
   211 }
       
   212 QString QOfonoModemInterface::getSerial()
       
   213 {
       
   214     QVariant var = getProperty("Serial");
       
   215     return qdbus_cast<QString>(var);
       
   216 
       
   217 }
       
   218 
       
   219 QStringList QOfonoModemInterface::getFeatures()
       
   220 {
       
   221     //sms, sim
       
   222     QVariant var = getProperty("Features");
       
   223     return qdbus_cast<QStringList>(var);
       
   224 }
       
   225 
       
   226 QStringList QOfonoModemInterface::getInterfaces()
       
   227 {
       
   228     QVariant var = getProperty("Interfaces");
       
   229     return qdbus_cast<QStringList>(var);
       
   230 }
       
   231 
       
   232 QString QOfonoModemInterface::defaultInterface()
       
   233 {
       
   234     foreach(const QString &modem,getInterfaces()) {
       
   235      return modem;
       
   236     }
       
   237     return QString();
       
   238 }
       
   239 
       
   240 
       
   241 void QOfonoModemInterface::connectNotify(const char *signal)
       
   242 {
       
   243     if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
       
   244             if(!connection().connect(QLatin1String(OFONO_SERVICE),
       
   245                                    this->path(),
       
   246                                    QLatin1String(OFONO_MODEM_INTERFACE),
       
   247                                    QLatin1String("PropertyChanged"),
       
   248                                    this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
       
   249                 qWarning() << "PropertyCHanged not connected";
       
   250             }
       
   251         }
       
   252 
       
   253         if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
       
   254             QOfonoDBusHelper *helper;
       
   255             helper = new QOfonoDBusHelper(this);
       
   256 
       
   257             dbusConnection.connect(QLatin1String(OFONO_SERVICE),
       
   258                                    this->path(),
       
   259                                    QLatin1String(OFONO_MODEM_INTERFACE),
       
   260                                    QLatin1String("PropertyChanged"),
       
   261                                    helper,SLOT(propertyChanged(QString,QDBusVariant)));
       
   262 
       
   263 
       
   264             QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
       
   265                     this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
       
   266         }}
       
   267 
       
   268 void QOfonoModemInterface::disconnectNotify(const char *signal)
       
   269 {
       
   270     if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
       
   271 
       
   272     }
       
   273 }
       
   274 
       
   275 QVariantMap QOfonoModemInterface::getProperties()
       
   276 {
       
   277     QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
       
   278     return reply.value();
       
   279 }
       
   280 
       
   281 QVariant QOfonoModemInterface::getProperty(const QString &property)
       
   282 {
       
   283     QVariant var;
       
   284     QVariantMap map = getProperties();
       
   285     if (map.contains(property)) {
       
   286         var = map.value(property);
       
   287     } else {
       
   288         qDebug() << Q_FUNC_INFO << "does not contain" << property;
       
   289     }
       
   290     return var;
       
   291 }
       
   292 
       
   293 
       
   294 QOfonoNetworkRegistrationInterface::QOfonoNetworkRegistrationInterface(const QString &dbusPathName, QObject *parent)
       
   295     : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
       
   296                              dbusPathName,
       
   297                              OFONO_NETWORK_REGISTRATION_INTERFACE,
       
   298                              QDBusConnection::systemBus(), parent)
       
   299 {
       
   300 }
       
   301 
       
   302 QOfonoNetworkRegistrationInterface::~QOfonoNetworkRegistrationInterface()
       
   303 {
       
   304 }
       
   305 
       
   306 QString QOfonoNetworkRegistrationInterface::getStatus()
       
   307 {
       
   308     /*
       
   309                 "unregistered"  Not registered to any network
       
   310                 "registered"    Registered to home network
       
   311                 "searching"     Not registered, but searching
       
   312                 "denied"        Registration has been denied
       
   313                 "unknown"       Status is unknown
       
   314                 "roaming"       Registered, but roaming*/
       
   315     QVariant var = getProperty("Status");
       
   316     return qdbus_cast<QString>(var);
       
   317 }
       
   318 
       
   319 quint16 QOfonoNetworkRegistrationInterface::getLac()
       
   320 {
       
   321     QVariant var = getProperty("LocationAreaCode");
       
   322     return var.value<quint16>();
       
   323 }
       
   324 
       
   325 
       
   326 quint32 QOfonoNetworkRegistrationInterface::getCellId()
       
   327 {
       
   328     QVariant var = getProperty("CellId");
       
   329     return var.value<quint32>();
       
   330 }
       
   331 
       
   332 QString QOfonoNetworkRegistrationInterface::getTechnology()
       
   333 {
       
   334     // "gsm", "edge", "umts", "hspa","lte"
       
   335     QVariant var = getProperty("Technology");
       
   336     return qdbus_cast<QString>(var);
       
   337 }
       
   338 
       
   339 QString QOfonoNetworkRegistrationInterface::getOperatorName()
       
   340 {
       
   341     QVariant var = getProperty("Name");
       
   342     return qdbus_cast<QString>(var);
       
   343 }
       
   344 
       
   345 int QOfonoNetworkRegistrationInterface::getSignalStrength()
       
   346 {
       
   347     QVariant var = getProperty("Strength");
       
   348     return qdbus_cast<int>(var);
       
   349 
       
   350 }
       
   351 
       
   352 QString QOfonoNetworkRegistrationInterface::getBaseStation()
       
   353 {
       
   354     QVariant var = getProperty("BaseStation");
       
   355     return qdbus_cast<QString>(var);
       
   356 }
       
   357 
       
   358 QList <QDBusObjectPath> QOfonoNetworkRegistrationInterface::getOperators()
       
   359 {
       
   360     QVariant var = getProperty("Operators");
       
   361     return qdbus_cast<QList <QDBusObjectPath> >(var);
       
   362 }
       
   363 
       
   364 void QOfonoNetworkRegistrationInterface::connectNotify(const char *signal)
       
   365 {
       
   366 if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
       
   367         if(!connection().connect(QLatin1String(OFONO_SERVICE),
       
   368                                this->path(),
       
   369                                QLatin1String(OFONO_NETWORK_REGISTRATION_INTERFACE),
       
   370                                QLatin1String("PropertyChanged"),
       
   371                                this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
       
   372             qWarning() << "PropertyCHanged not connected";
       
   373         }
       
   374     }
       
   375 
       
   376     if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
       
   377         QOfonoDBusHelper *helper;
       
   378         helper = new QOfonoDBusHelper(this);
       
   379 
       
   380         dbusConnection.connect(QLatin1String(OFONO_SERVICE),
       
   381                                this->path(),
       
   382                                QLatin1String(OFONO_NETWORK_REGISTRATION_INTERFACE),
       
   383                                QLatin1String("PropertyChanged"),
       
   384                                helper,SLOT(propertyChanged(QString,QDBusVariant)));
       
   385 
       
   386 
       
   387         QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
       
   388                 this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
       
   389     }
       
   390 }
       
   391 
       
   392 void QOfonoNetworkRegistrationInterface::disconnectNotify(const char *signal)
       
   393 {
       
   394     if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
       
   395 
       
   396     }
       
   397 }
       
   398 
       
   399 QVariant QOfonoNetworkRegistrationInterface::getProperty(const QString &property)
       
   400 {
       
   401     QVariant var;
       
   402     QVariantMap map = getProperties();
       
   403     if (map.contains(property)) {
       
   404         var = map.value(property);
       
   405     } else {
       
   406         qDebug() << Q_FUNC_INFO << "does not contain" << property;
       
   407     }
       
   408     return var;
       
   409 }
       
   410 
       
   411 QVariantMap QOfonoNetworkRegistrationInterface::getProperties()
       
   412 {
       
   413     QDBusReply<QVariantMap > reply =  this->call(QLatin1String("GetProperties"));
       
   414     return reply.value();
       
   415 }
       
   416 
       
   417 
       
   418 
       
   419 QOfonoNetworkOperatorInterface::QOfonoNetworkOperatorInterface(const QString &dbusPathName, QObject *parent)
       
   420     : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
       
   421                              dbusPathName,
       
   422                              OFONO_NETWORK_OPERATOR_INTERFACE,
       
   423                              QDBusConnection::systemBus(), parent)
       
   424 {
       
   425 }
       
   426 
       
   427 QOfonoNetworkOperatorInterface::~QOfonoNetworkOperatorInterface()
       
   428 {
       
   429 }
       
   430 
       
   431 QString QOfonoNetworkOperatorInterface::getName()
       
   432 {
       
   433     QVariant var = getProperty("Name");
       
   434     return qdbus_cast<QString>(var);
       
   435 }
       
   436 
       
   437 QString QOfonoNetworkOperatorInterface::getStatus()
       
   438 {
       
   439     // "unknown", "available", "current" and "forbidden"
       
   440     QVariant var = getProperty("Status");
       
   441     return qdbus_cast<QString>(var);
       
   442 }
       
   443 
       
   444 QString QOfonoNetworkOperatorInterface::getMcc()
       
   445 {
       
   446     QVariant var = getProperty("MobileCountryCode");
       
   447     return qdbus_cast<QString>(var);
       
   448 }
       
   449 
       
   450 QString QOfonoNetworkOperatorInterface::getMnc()
       
   451 {
       
   452     QVariant var = getProperty("MobileNetworkCode");
       
   453     return qdbus_cast<QString>(var);
       
   454 }
       
   455 
       
   456 QStringList QOfonoNetworkOperatorInterface::getTechnologies()
       
   457 {
       
   458     QVariant var = getProperty("Technologies");
       
   459     return qdbus_cast<QStringList>(var);
       
   460 }
       
   461 
       
   462 void QOfonoNetworkOperatorInterface::connectNotify(const char *signal)
       
   463 {
       
   464 if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
       
   465         if(!connection().connect(QLatin1String(OFONO_SERVICE),
       
   466                                this->path(),
       
   467                                QLatin1String(OFONO_NETWORK_OPERATOR_INTERFACE),
       
   468                                QLatin1String("PropertyChanged"),
       
   469                                this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
       
   470             qWarning() << "PropertyCHanged not connected";
       
   471         }
       
   472     }
       
   473 
       
   474     if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
       
   475         QOfonoDBusHelper *helper;
       
   476         helper = new QOfonoDBusHelper(this);
       
   477 
       
   478         dbusConnection.connect(QLatin1String(OFONO_SERVICE),
       
   479                                this->path(),
       
   480                                QLatin1String(OFONO_NETWORK_OPERATOR_INTERFACE),
       
   481                                QLatin1String("PropertyChanged"),
       
   482                                helper,SLOT(propertyChanged(QString,QDBusVariant)));
       
   483 
       
   484 
       
   485         QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
       
   486                 this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
       
   487     }
       
   488 }
       
   489 
       
   490 void QOfonoNetworkOperatorInterface::disconnectNotify(const char *signal)
       
   491 {
       
   492     if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
       
   493 
       
   494     }
       
   495 }
       
   496 
       
   497 QVariant QOfonoNetworkOperatorInterface::getProperty(const QString &property)
       
   498 {
       
   499     QVariant var;
       
   500     QVariantMap map = getProperties();
       
   501     if (map.contains(property)) {
       
   502         var = map.value(property);
       
   503     } else {
       
   504         qDebug() << Q_FUNC_INFO << "does not contain" << property;
       
   505     }
       
   506     return var;
       
   507 }
       
   508 
       
   509 QVariantMap QOfonoNetworkOperatorInterface::getProperties()
       
   510 {
       
   511     QDBusReply<QVariantMap > reply =  this->call(QLatin1String("GetProperties"));
       
   512     return reply.value();
       
   513 }
       
   514 
       
   515 QOfonoSimInterface::QOfonoSimInterface(const QString &dbusPathName, QObject *parent)
       
   516     : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
       
   517                              dbusPathName,
       
   518                              OFONO_SIM_MANAGER_INTERFACE,
       
   519                              QDBusConnection::systemBus(), parent)
       
   520 {
       
   521 }
       
   522 
       
   523 QOfonoSimInterface::~QOfonoSimInterface()
       
   524 {
       
   525 }
       
   526 
       
   527 bool QOfonoSimInterface::isPresent()
       
   528 {
       
   529     QVariant var = getProperty("Present");
       
   530     return qdbus_cast<bool>(var);
       
   531 }
       
   532 
       
   533 QString QOfonoSimInterface::getHomeMcc()
       
   534 {
       
   535     QVariant var = getProperty("MobileCountryCode");
       
   536     return qdbus_cast<QString>(var);
       
   537 }
       
   538 
       
   539 QString QOfonoSimInterface::getHomeMnc()
       
   540 {
       
   541     QVariant var = getProperty("MobileNetworkCode");
       
   542     return qdbus_cast<QString>(var);
       
   543 }
       
   544 
       
   545 //    QStringList subscriberNumbers();
       
   546 //    QMap<QString,QString> serviceNumbers();
       
   547 QString QOfonoSimInterface::pinRequired()
       
   548 {
       
   549     QVariant var = getProperty("PinRequired");
       
   550     return qdbus_cast<QString>(var);
       
   551 }
       
   552 
       
   553 QString QOfonoSimInterface::lockedPins()
       
   554 {
       
   555     QVariant var = getProperty("LockedPins");
       
   556     return qdbus_cast<QString>(var);
       
   557 }
       
   558 
       
   559 QString QOfonoSimInterface::cardIdentifier()
       
   560 {
       
   561     QVariant var = getProperty("CardIdentifier");
       
   562     return qdbus_cast<QString>(var);
       
   563 }
       
   564 
       
   565 void QOfonoSimInterface::connectNotify(const char *signal)
       
   566 {
       
   567 if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
       
   568         if(!connection().connect(QLatin1String(OFONO_SERVICE),
       
   569                                this->path(),
       
   570                                QLatin1String(OFONO_SIM_MANAGER_INTERFACE),
       
   571                                QLatin1String("PropertyChanged"),
       
   572                                this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
       
   573             qWarning() << "PropertyCHanged not connected";
       
   574         }
       
   575     }
       
   576 
       
   577     if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
       
   578         QOfonoDBusHelper *helper;
       
   579         helper = new QOfonoDBusHelper(this);
       
   580 
       
   581         dbusConnection.connect(QLatin1String(OFONO_SERVICE),
       
   582                                this->path(),
       
   583                                QLatin1String(OFONO_SIM_MANAGER_INTERFACE),
       
   584                                QLatin1String("PropertyChanged"),
       
   585                                helper,SLOT(propertyChanged(QString,QDBusVariant)));
       
   586 
       
   587 
       
   588         QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
       
   589                 this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
       
   590     }
       
   591 }
       
   592 
       
   593 void QOfonoSimInterface::disconnectNotify(const char *signal)
       
   594 {
       
   595     if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
       
   596 
       
   597     }
       
   598 }
       
   599 
       
   600 QVariant QOfonoSimInterface::getProperty(const QString &property)
       
   601 {
       
   602     QVariant var;
       
   603     QVariantMap map = getProperties();
       
   604     if (map.contains(property)) {
       
   605         var = map.value(property);
       
   606     } else {
       
   607         qDebug() << Q_FUNC_INFO << "does not contain" << property;
       
   608     }
       
   609     return var;
       
   610 }
       
   611 
       
   612 QVariantMap QOfonoSimInterface::getProperties()
       
   613 {
       
   614     QDBusReply<QVariantMap > reply =  this->call(QLatin1String("GetProperties"));
       
   615     return reply.value();
       
   616 }
       
   617 
       
   618 QOfonoDataConnectionManagerInterface::QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent)
       
   619     : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
       
   620                              dbusPathName,
       
   621                              OFONO_DATA_CONNECTION_MANAGER_INTERFACE,
       
   622                              QDBusConnection::systemBus(), parent)
       
   623 {
       
   624 }
       
   625 
       
   626 QOfonoDataConnectionManagerInterface::~QOfonoDataConnectionManagerInterface()
       
   627 {
       
   628 }
       
   629 
       
   630 QList<QDBusObjectPath> QOfonoDataConnectionManagerInterface::getPrimaryContexts()
       
   631 {
       
   632     QVariant var = getProperty("PrimaryContexts");
       
   633     return qdbus_cast<QList<QDBusObjectPath> >(var);
       
   634 }
       
   635 
       
   636 bool QOfonoDataConnectionManagerInterface::isAttached()
       
   637 {
       
   638     QVariant var = getProperty("Attached");
       
   639     return qdbus_cast<bool>(var);
       
   640 }
       
   641 
       
   642 bool QOfonoDataConnectionManagerInterface::isRoamingAllowed()
       
   643 {
       
   644     QVariant var = getProperty("RoamingAllowed");
       
   645     return qdbus_cast<bool>(var);
       
   646 }
       
   647 
       
   648 bool QOfonoDataConnectionManagerInterface::isPowered()
       
   649 {
       
   650     QVariant var = getProperty("Powered");
       
   651     return qdbus_cast<bool>(var);
       
   652 }
       
   653 
       
   654 void QOfonoDataConnectionManagerInterface::connectNotify(const char *signal)
       
   655 {
       
   656 if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
       
   657         if(!connection().connect(QLatin1String(OFONO_SERVICE),
       
   658                                this->path(),
       
   659                                QLatin1String(OFONO_DATA_CONNECTION_MANAGER_INTERFACE),
       
   660                                QLatin1String("PropertyChanged"),
       
   661                                this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
       
   662             qWarning() << "PropertyCHanged not connected";
       
   663         }
       
   664     }
       
   665 
       
   666     if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
       
   667         QOfonoDBusHelper *helper;
       
   668         helper = new QOfonoDBusHelper(this);
       
   669 
       
   670         dbusConnection.connect(QLatin1String(OFONO_SERVICE),
       
   671                                this->path(),
       
   672                                QLatin1String(OFONO_DATA_CONNECTION_MANAGER_INTERFACE),
       
   673                                QLatin1String("PropertyChanged"),
       
   674                                helper,SLOT(propertyChanged(QString,QDBusVariant)));
       
   675 
       
   676 
       
   677         QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
       
   678                 this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
       
   679     }
       
   680 }
       
   681 
       
   682 void QOfonoDataConnectionManagerInterface::disconnectNotify(const char *signal)
       
   683 {
       
   684     if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
       
   685 
       
   686     }
       
   687 }
       
   688 
       
   689 QVariant QOfonoDataConnectionManagerInterface::getProperty(const QString &property)
       
   690 {
       
   691     QVariant var;
       
   692     QVariantMap map = getProperties();
       
   693     if (map.contains(property)) {
       
   694         var = map.value(property);
       
   695     } else {
       
   696         qDebug() << Q_FUNC_INFO << "does not contain" << property;
       
   697     }
       
   698     return var;
       
   699 }
       
   700 
       
   701 QVariantMap QOfonoDataConnectionManagerInterface::getProperties()
       
   702 {
       
   703     QDBusReply<QVariantMap > reply =  this->call(QLatin1String("GetProperties"));
       
   704     return reply.value();
       
   705 }
       
   706 
       
   707 QOfonoPrimaryDataContextInterface::QOfonoPrimaryDataContextInterface(const QString &dbusPathName, QObject *parent)
       
   708     : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
       
   709                              dbusPathName,
       
   710                              OFONO_DATA_CONTEXT_INTERFACE,
       
   711                              QDBusConnection::systemBus(), parent)
       
   712 {
       
   713 }
       
   714 
       
   715 QOfonoPrimaryDataContextInterface::~QOfonoPrimaryDataContextInterface()
       
   716 {
       
   717 }
       
   718 
       
   719 bool QOfonoPrimaryDataContextInterface::isActive()
       
   720 {
       
   721     QVariant var = getProperty("Active");
       
   722     return qdbus_cast<bool>(var);
       
   723 }
       
   724 
       
   725 QString QOfonoPrimaryDataContextInterface::getApName()
       
   726 {
       
   727     QVariant var = getProperty("AccessPointName");
       
   728     return qdbus_cast<QString>(var);
       
   729 }
       
   730 
       
   731 QString QOfonoPrimaryDataContextInterface::getType()
       
   732 {
       
   733     QVariant var = getProperty("Type");
       
   734     return qdbus_cast<QString>(var);
       
   735 }
       
   736 
       
   737 QString QOfonoPrimaryDataContextInterface::getName()
       
   738 {
       
   739     QVariant var = getProperty("Name");
       
   740     return qdbus_cast<QString>(var);
       
   741 }
       
   742 
       
   743 QVariantMap QOfonoPrimaryDataContextInterface::getSettings()
       
   744 {
       
   745     QVariant var = getProperty("Settings");
       
   746     return qdbus_cast<QVariantMap>(var);
       
   747 }
       
   748 
       
   749 QString QOfonoPrimaryDataContextInterface::getInterface()
       
   750 {
       
   751     QVariant var = getProperty("Interface");
       
   752     return qdbus_cast<QString>(var);
       
   753 }
       
   754 
       
   755 QString QOfonoPrimaryDataContextInterface::getAddress()
       
   756 {
       
   757     QVariant var = getProperty("Address");
       
   758     return qdbus_cast<QString>(var);
       
   759 }
       
   760 
       
   761 bool QOfonoPrimaryDataContextInterface::setActive(bool on)
       
   762 {
       
   763 //    this->setProperty("Active", QVariant(on));
       
   764 
       
   765     return setProp("Active", qVariantFromValue(on));
       
   766 }
       
   767 
       
   768 bool QOfonoPrimaryDataContextInterface::setApn(const QString &name)
       
   769 {
       
   770     return setProp("AccessPointName", QVariant::fromValue(name));
       
   771 }
       
   772 
       
   773 void QOfonoPrimaryDataContextInterface::connectNotify(const char *signal)
       
   774 {
       
   775 if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
       
   776         if(!connection().connect(QLatin1String(OFONO_SERVICE),
       
   777                                this->path(),
       
   778                                QLatin1String(OFONO_DATA_CONTEXT_INTERFACE),
       
   779                                QLatin1String("PropertyChanged"),
       
   780                                this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
       
   781             qWarning() << "PropertyCHanged not connected";
       
   782         }
       
   783     }
       
   784 
       
   785     if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
       
   786         QOfonoDBusHelper *helper;
       
   787         helper = new QOfonoDBusHelper(this);
       
   788 
       
   789         dbusConnection.connect(QLatin1String(OFONO_SERVICE),
       
   790                                this->path(),
       
   791                                QLatin1String(OFONO_DATA_CONTEXT_INTERFACE),
       
   792                                QLatin1String("PropertyChanged"),
       
   793                                helper,SLOT(propertyChanged(QString,QDBusVariant)));
       
   794 
       
   795 
       
   796         QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
       
   797                 this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
       
   798     }
       
   799 }
       
   800 
       
   801 void QOfonoPrimaryDataContextInterface::disconnectNotify(const char *signal)
       
   802 {
       
   803     if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
       
   804 
       
   805     }
       
   806 }
       
   807 
       
   808 QVariant QOfonoPrimaryDataContextInterface::getProperty(const QString &property)
       
   809 {
       
   810     QVariant var;
       
   811     QVariantMap map = getProperties();
       
   812     if (map.contains(property)) {
       
   813         var = map.value(property);
       
   814     } else {
       
   815         qDebug() << Q_FUNC_INFO << "does not contain" << property;
       
   816     }
       
   817     return var;
       
   818 }
       
   819 
       
   820 QVariantMap QOfonoPrimaryDataContextInterface::getProperties()
       
   821 {
       
   822     QDBusReply<QVariantMap > reply =  this->call(QLatin1String("GetProperties"));
       
   823     return reply.value();
       
   824 }
       
   825 
       
   826 bool QOfonoPrimaryDataContextInterface::setProp(const QString &property, const QVariant &var)
       
   827 {
       
   828     QList<QVariant> args;
       
   829     args << qVariantFromValue(property) << qVariantFromValue(QDBusVariant(var));
       
   830 
       
   831     QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect,
       
   832                                                     QLatin1String("SetProperty"),
       
   833                                                     args);
       
   834     bool ok = true;
       
   835     if(reply.type() != QDBusMessage::ReplyMessage) {
       
   836         qWarning() << reply.errorMessage();
       
   837         ok = false;
       
   838     }
       
   839     qWarning() << reply.errorMessage();
       
   840     return ok;
       
   841 }
       
   842 
       
   843 QOfonoSmsInterface::QOfonoSmsInterface(const QString &dbusPathName, QObject *parent)
       
   844     : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
       
   845                              dbusPathName,
       
   846                              OFONO_SMS_MANAGER_INTERFACE,
       
   847                              QDBusConnection::systemBus(), parent)
       
   848 {
       
   849 }
       
   850 
       
   851 QOfonoSmsInterface::~QOfonoSmsInterface()
       
   852 {
       
   853 }
       
   854 
       
   855 void QOfonoSmsInterface::connectNotify(const char *signal)
       
   856 {
       
   857     if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
       
   858         if(!connection().connect(QLatin1String(OFONO_SERVICE),
       
   859                                  this->path(),
       
   860                                  QLatin1String(OFONO_SMS_MANAGER_INTERFACE),
       
   861                                  QLatin1String("PropertyChanged"),
       
   862                                  this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
       
   863             qWarning() << "PropertyCHanged not connected";
       
   864         }
       
   865     }
       
   866 
       
   867     if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
       
   868         QOfonoDBusHelper *helper;
       
   869         helper = new QOfonoDBusHelper(this);
       
   870 
       
   871         dbusConnection.connect(QLatin1String(OFONO_SERVICE),
       
   872                                this->path(),
       
   873                                QLatin1String(OFONO_SMS_MANAGER_INTERFACE),
       
   874                                QLatin1String("PropertyChanged"),
       
   875                                helper,SLOT(propertyChanged(QString,QDBusVariant)));
       
   876 
       
   877 
       
   878         QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
       
   879                          this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
       
   880     }
       
   881 
       
   882     if (QLatin1String(signal) == SIGNAL(immediateMessage(QString,QVariantMap))) {
       
   883         if(!connection().connect(QLatin1String(OFONO_SERVICE),
       
   884                                  this->path(),
       
   885                                  QLatin1String(OFONO_SMS_MANAGER_INTERFACE),
       
   886                                  QLatin1String("ImmediateMessage"),
       
   887                                  this,SIGNAL(immediateMessage(QString,QVariantMap )))) {
       
   888             qWarning() << "PropertyCHanged not connected";
       
   889         }
       
   890     }
       
   891 
       
   892     if (QLatin1String(signal) == SIGNAL(incomingMessage(QString,QVariantMap))) {
       
   893         if(!connection().connect(QLatin1String(OFONO_SERVICE),
       
   894                                  this->path(),
       
   895                                  QLatin1String(OFONO_SMS_MANAGER_INTERFACE),
       
   896                                  QLatin1String("IncomingMessage"),
       
   897                                  this,SIGNAL(incomingMessage(QString,QVariantMap)))) {
       
   898             qWarning() << "PropertyCHanged not connected";
       
   899         }
       
   900     }
       
   901 }
       
   902 
       
   903 void QOfonoSmsInterface::disconnectNotify(const char *signal)
       
   904 {
       
   905     if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
       
   906 
       
   907     }
       
   908 }
       
   909 
       
   910 QVariant QOfonoSmsInterface::getProperty(const QString &property)
       
   911 {
       
   912     QVariant var;
       
   913     QVariantMap map = getProperties();
       
   914     if (map.contains(property)) {
       
   915         var = map.value(property);
       
   916     } else {
       
   917         qDebug() << Q_FUNC_INFO << "does not contain" << property;
       
   918     }
       
   919     return var;
       
   920 }
       
   921 
       
   922 QVariantMap QOfonoSmsInterface::getProperties()
       
   923 {
       
   924     QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
       
   925     return reply.value();
       
   926 }
       
   927 
       
   928 void QOfonoSmsInterface::sendMessage(const QString &to, const QString &message)
       
   929 {
       
   930     QDBusReply<QString> reply =  this->call(QLatin1String("SendMessage"),
       
   931                                             QVariant::fromValue(to),
       
   932                                             QVariant::fromValue(message));
       
   933     bool ok = true;
       
   934     if(reply.error().type() == QDBusError::InvalidArgs) {
       
   935         qWarning() << reply.error().message();
       
   936         ok = false;
       
   937     }
       
   938 }
       
   939 
       
   940 QT_END_NAMESPACE