diff options
Diffstat (limited to 'src/plugins/bearer/connman/qofonoservice_linux.cpp')
-rw-r--r-- | src/plugins/bearer/connman/qofonoservice_linux.cpp | 899 |
1 files changed, 97 insertions, 802 deletions
diff --git a/src/plugins/bearer/connman/qofonoservice_linux.cpp b/src/plugins/bearer/connman/qofonoservice_linux.cpp index 1983276d94..f5da52a341 100644 --- a/src/plugins/bearer/connman/qofonoservice_linux.cpp +++ b/src/plugins/bearer/connman/qofonoservice_linux.cpp @@ -75,256 +75,133 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, ObjectPathPropert QT_BEGIN_NAMESPACE QOfonoManagerInterface::QOfonoManagerInterface( QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), - QLatin1String(OFONO_MANAGER_PATH), + : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE), + QStringLiteral(OFONO_MANAGER_PATH), OFONO_MANAGER_INTERFACE, QDBusConnection::systemBus(), parent) { qDBusRegisterMetaType<ObjectPathProperties>(); qDBusRegisterMetaType<PathPropertiesList>(); + + QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE), + QStringLiteral(OFONO_MANAGER_PATH), + QStringLiteral(OFONO_MANAGER_INTERFACE), + QStringLiteral("ModemAdded"), + this,SLOT(modemAdded(QDBusObjectPath, QVariantMap))); + QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE), + QStringLiteral(OFONO_MANAGER_PATH), + QStringLiteral(OFONO_MANAGER_INTERFACE), + QStringLiteral("ModemRemoved"), + this,SLOT(modemRemoved(QDBusObjectPath))); } QOfonoManagerInterface::~QOfonoManagerInterface() { } -QList <QDBusObjectPath> QOfonoManagerInterface::getModems() +QStringList QOfonoManagerInterface::getModems() { - QList <QDBusObjectPath> modemList; - QList<QVariant> argumentList; - QDBusReply<PathPropertiesList > reply = this->asyncCallWithArgumentList(QLatin1String("GetModems"), argumentList); - if (reply.isValid()) { - foreach (ObjectPathProperties modem, reply.value()) { - modemList << modem.path; + if (modemList.isEmpty()) { + QList<QVariant> argumentList; + QDBusPendingReply<PathPropertiesList> reply = asyncCallWithArgumentList(QLatin1String("GetModems"), argumentList); + reply.waitForFinished(); + if (!reply.isError()) { + foreach (ObjectPathProperties modem, reply.value()) { + modemList << modem.path.path(); + } + } else { + qDebug() << reply.error().message(); } } return modemList; } -QDBusObjectPath QOfonoManagerInterface::currentModem() +QString QOfonoManagerInterface::currentModem() { - QList<QDBusObjectPath> modems = getModems(); - foreach (const QDBusObjectPath &modem, modems) { - QOfonoModemInterface device(modem.path()); + QStringList modems = getModems(); + foreach (const QString &modem, modems) { + QOfonoModemInterface device(modem); if (device.isPowered() && device.isOnline()) return modem; } - return QDBusObjectPath(); -} - - -void QOfonoManagerInterface::connectNotify(const QMetaMethod &signal) -{ - static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoManagerInterface::propertyChanged); - if (signal == propertyChangedSignal) { - if (!connection().connect(QLatin1String(OFONO_SERVICE), - QLatin1String(OFONO_MANAGER_PATH), - QLatin1String(OFONO_MANAGER_INTERFACE), - QLatin1String("PropertyChanged"), - this,SIGNAL(propertyChanged(QString,QDBusVariant)))) { - qWarning() << "PropertyCHanged not connected"; - } - } - - static const QMetaMethod propertyChangedContextSignal = QMetaMethod::fromSignal(&QOfonoManagerInterface::propertyChangedContext); - if (signal == propertyChangedContextSignal) { - QOfonoDBusHelper *helper; - helper = new QOfonoDBusHelper(this); - - QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), - QLatin1String(OFONO_MANAGER_PATH), - QLatin1String(OFONO_MANAGER_INTERFACE), - QLatin1String("PropertyChanged"), - helper,SLOT(propertyChanged(QString,QDBusVariant))); - - - QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), - this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))); - } + return QString(); } -void QOfonoManagerInterface::disconnectNotify(const QMetaMethod &signal) +void QOfonoManagerInterface::modemAdded(const QDBusObjectPath &path, const QVariantMap &/*var*/) { - static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoManagerInterface::propertyChanged); - if (signal == propertyChangedSignal) { - + if (!modemList.contains(path.path())) { + modemList << path.path(); + Q_EMIT modemChanged(); } } -QVariant QOfonoManagerInterface::getProperty(const QString &property) +void QOfonoManagerInterface::modemRemoved(const QDBusObjectPath &path) { - QVariantMap map = getProperties(); - if (map.contains(property)) { - return map.value(property); - } else { - qDebug() << Q_FUNC_INFO << "does not contain" << property; + if (modemList.contains(path.path())) { + modemList.removeOne(path.path()); + Q_EMIT modemChanged(); } - return QVariant(); -} - -QVariantMap QOfonoManagerInterface::getProperties() -{ - QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); - if (reply.isValid()) - return reply.value(); - else - return QVariantMap(); -} - -QOfonoDBusHelper::QOfonoDBusHelper(QObject * parent) - : QObject(parent) -{ -} - -QOfonoDBusHelper::~QOfonoDBusHelper() -{ -} - -void QOfonoDBusHelper::propertyChanged(const QString &item, const QDBusVariant &var) -{ - QDBusMessage msg = this->message(); - Q_EMIT propertyChangedContext(msg.path() ,item, var); } QOfonoModemInterface::QOfonoModemInterface(const QString &dbusPathName, QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE), dbusPathName, OFONO_MODEM_INTERFACE, QDBusConnection::systemBus(), parent) { + QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE), + path(), + OFONO_MODEM_INTERFACE, + QStringLiteral("PropertyChanged"), + this,SLOT(propertyChanged(QString,QDBusVariant))); } QOfonoModemInterface::~QOfonoModemInterface() { } -bool QOfonoModemInterface::isPowered() +void QOfonoModemInterface::propertyChanged(const QString &name,const QDBusVariant &value) { - QVariant var = getProperty("Powered"); - return qdbus_cast<bool>(var); + propertiesMap[name] = value.variant(); } -bool QOfonoModemInterface::isOnline() +bool QOfonoModemInterface::isPowered() { - QVariant var = getProperty("Online"); + QVariant var = getProperty(QStringLiteral("Powered")); return qdbus_cast<bool>(var); } -QString QOfonoModemInterface::getName() -{ - QVariant var = getProperty("Name"); - return qdbus_cast<QString>(var); -} - -QString QOfonoModemInterface::getManufacturer() -{ - QVariant var = getProperty("Manufacturer"); - return qdbus_cast<QString>(var); - -} - -QString QOfonoModemInterface::getModel() -{ - - QVariant var = getProperty("Model"); - return qdbus_cast<QString>(var); -} - -QString QOfonoModemInterface::getRevision() -{ - QVariant var = getProperty("Revision"); - return qdbus_cast<QString>(var); - -} -QString QOfonoModemInterface::getSerial() -{ - QVariant var = getProperty("Serial"); - return qdbus_cast<QString>(var); - -} - -QStringList QOfonoModemInterface::getFeatures() -{ - //sms, sim - QVariant var = getProperty("Features"); - return qdbus_cast<QStringList>(var); -} - -QStringList QOfonoModemInterface::getInterfaces() -{ - QVariant var = getProperty("Interfaces"); - return qdbus_cast<QStringList>(var); -} - -QString QOfonoModemInterface::defaultInterface() +bool QOfonoModemInterface::isOnline() { - foreach (const QString &modem,getInterfaces()) { - return modem; - } - return QString(); + QVariant var = getProperty(QStringLiteral("Online")); + return qdbus_cast<bool>(var); } - -void QOfonoModemInterface::connectNotify(const QMetaMethod &signal) +QVariantMap QOfonoModemInterface::getProperties() { - static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoModemInterface::propertyChanged); - if (signal == propertyChangedSignal) { - if (!connection().connect(QLatin1String(OFONO_SERVICE), - this->path(), - QLatin1String(OFONO_MODEM_INTERFACE), - QLatin1String("PropertyChanged"), - this,SIGNAL(propertyChanged(QString,QDBusVariant)))) { - qWarning() << "PropertyCHanged not connected"; - } + if (propertiesMap.isEmpty()) { + QList<QVariant> argumentList; + QDBusPendingReply<QVariantMap> reply = asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList); + if (!reply.isError()) { + propertiesMap = reply.value(); } - - static const QMetaMethod propertyChangedContextSignal = QMetaMethod::fromSignal(&QOfonoModemInterface::propertyChangedContext); - if (signal == propertyChangedContextSignal) { - QOfonoDBusHelper *helper; - helper = new QOfonoDBusHelper(this); - - QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), - this->path(), - QLatin1String(OFONO_MODEM_INTERFACE), - QLatin1String("PropertyChanged"), - helper,SLOT(propertyChanged(QString,QDBusVariant))); - - - QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), - this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection); - }} - -void QOfonoModemInterface::disconnectNotify(const QMetaMethod &signal) -{ - static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoModemInterface::propertyChanged); - if (signal == propertyChangedSignal) { - } -} - -QVariantMap QOfonoModemInterface::getProperties() -{ - QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); - return reply.value(); + return propertiesMap; } QVariant QOfonoModemInterface::getProperty(const QString &property) { QVariant var; QVariantMap map = getProperties(); - if (map.contains(property)) { - var = map.value(property); - } else { - qDebug() << Q_FUNC_INFO << "does not contain" << property; - } + var = map.value(property); return var; } QOfonoNetworkRegistrationInterface::QOfonoNetworkRegistrationInterface(const QString &dbusPathName, QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE), dbusPathName, OFONO_NETWORK_REGISTRATION_INTERFACE, QDBusConnection::systemBus(), parent) @@ -335,337 +212,33 @@ QOfonoNetworkRegistrationInterface::~QOfonoNetworkRegistrationInterface() { } -QString QOfonoNetworkRegistrationInterface::getStatus() -{ - /* - "unregistered" Not registered to any network - "registered" Registered to home network - "searching" Not registered, but searching - "denied" Registration has been denied - "unknown" Status is unknown - "roaming" Registered, but roaming*/ - QVariant var = getProperty("Status"); - return qdbus_cast<QString>(var); -} - -quint16 QOfonoNetworkRegistrationInterface::getLac() -{ - QVariant var = getProperty("LocationAreaCode"); - return var.value<quint16>(); -} - - -quint32 QOfonoNetworkRegistrationInterface::getCellId() -{ - QVariant var = getProperty("CellId"); - return var.value<quint32>(); -} - QString QOfonoNetworkRegistrationInterface::getTechnology() { - // "gsm", "edge", "umts", "hspa","lte" - QVariant var = getProperty("Technology"); - return qdbus_cast<QString>(var); -} - -QString QOfonoNetworkRegistrationInterface::getOperatorName() -{ - QVariant var = getProperty("Name"); + QVariant var = getProperty(QStringLiteral("Technology")); return qdbus_cast<QString>(var); } -int QOfonoNetworkRegistrationInterface::getSignalStrength() -{ - QVariant var = getProperty("Strength"); - return qdbus_cast<int>(var); - -} - -QString QOfonoNetworkRegistrationInterface::getBaseStation() -{ - QVariant var = getProperty("BaseStation"); - return qdbus_cast<QString>(var); -} - -QList <QDBusObjectPath> QOfonoNetworkRegistrationInterface::getOperators() -{ - QList <QDBusObjectPath> operatorList; - QList<QVariant> argumentList; - QDBusReply<PathPropertiesList > reply = this->asyncCallWithArgumentList(QLatin1String("GetOperators"), - argumentList); - if (reply.isValid()) { - foreach (ObjectPathProperties netop, reply.value()) { - operatorList << netop.path; - } - } - return operatorList; -} - -void QOfonoNetworkRegistrationInterface::connectNotify(const QMetaMethod &signal) -{ - static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoNetworkRegistrationInterface::propertyChanged); - if (signal == propertyChangedSignal) { - if (!connection().connect(QLatin1String(OFONO_SERVICE), - this->path(), - QLatin1String(OFONO_NETWORK_REGISTRATION_INTERFACE), - QLatin1String("PropertyChanged"), - this,SIGNAL(propertyChanged(QString,QDBusVariant)))) { - qWarning() << "PropertyCHanged not connected"; - } - } - - static const QMetaMethod propertyChangedContextSignal = QMetaMethod::fromSignal(&QOfonoNetworkRegistrationInterface::propertyChangedContext); - if (signal == propertyChangedContextSignal) { - QOfonoDBusHelper *helper; - helper = new QOfonoDBusHelper(this); - - QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), - this->path(), - QLatin1String(OFONO_NETWORK_REGISTRATION_INTERFACE), - QLatin1String("PropertyChanged"), - helper,SLOT(propertyChanged(QString,QDBusVariant))); - - - QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), - this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection); - } -} - -void QOfonoNetworkRegistrationInterface::disconnectNotify(const QMetaMethod &signal) -{ - static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoNetworkRegistrationInterface::propertyChanged); - if (signal == propertyChangedSignal) { - - } -} - QVariant QOfonoNetworkRegistrationInterface::getProperty(const QString &property) { QVariant var; QVariantMap map = getProperties(); - if (map.contains(property)) { - var = map.value(property); - } else { - qDebug() << Q_FUNC_INFO << "does not contain" << property; - } + var = map.value(property); return var; } QVariantMap QOfonoNetworkRegistrationInterface::getProperties() { - QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); - return reply.value(); -} - - - -QOfonoNetworkOperatorInterface::QOfonoNetworkOperatorInterface(const QString &dbusPathName, QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), - dbusPathName, - OFONO_NETWORK_OPERATOR_INTERFACE, - QDBusConnection::systemBus(), parent) -{ -} - -QOfonoNetworkOperatorInterface::~QOfonoNetworkOperatorInterface() -{ -} - -QString QOfonoNetworkOperatorInterface::getName() -{ - QVariant var = getProperty("Name"); - return qdbus_cast<QString>(var); -} - -QString QOfonoNetworkOperatorInterface::getStatus() -{ - // "unknown", "available", "current" and "forbidden" - QVariant var = getProperty("Status"); - return qdbus_cast<QString>(var); -} - -QString QOfonoNetworkOperatorInterface::getMcc() -{ - QVariant var = getProperty("MobileCountryCode"); - return qdbus_cast<QString>(var); -} - -QString QOfonoNetworkOperatorInterface::getMnc() -{ - QVariant var = getProperty("MobileNetworkCode"); - return qdbus_cast<QString>(var); -} - -QStringList QOfonoNetworkOperatorInterface::getTechnologies() -{ - QVariant var = getProperty("Technologies"); - return qdbus_cast<QStringList>(var); -} - -void QOfonoNetworkOperatorInterface::connectNotify(const QMetaMethod &signal) -{ - Q_UNUSED(signal); -// static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoNetworkOperatorInterface::propertyChanged); -// if (signal == propertyChangedSignal) { -// if (!connection().connect(QLatin1String(OFONO_SERVICE), -// this->path(), -// QLatin1String(OFONO_NETWORK_OPERATOR_INTERFACE), -// QLatin1String("PropertyChanged"), -// this,SIGNAL(propertyChanged(QString,QDBusVariant)))) { -// qWarning() << "PropertyCHanged not connected"; -// } -// } - -// static const QMetaMethod propertyChangedContextSignal = QMetaMethod::fromSignal(&QOfonoNetworkOperatorInterface::propertyChangedContext); -// if (signal == propertyChangedContextSignal) { -// QOfonoDBusHelper *helper; -// helper = new QOfonoDBusHelper(this); - -// QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), -// this->path(), -// QLatin1String(OFONO_NETWORK_OPERATOR_INTERFACE), -// QLatin1String("PropertyChanged"), -// helper,SLOT(propertyChanged(QString,QDBusVariant))); - - -// QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), -// this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection); -// } -} - -void QOfonoNetworkOperatorInterface::disconnectNotify(const QMetaMethod &signal) -{ - Q_UNUSED(signal); -// static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoNetworkOperatorInterface::propertyChanged); -// if (signal == propertyChangedSignal) { - -// } -} - -QVariant QOfonoNetworkOperatorInterface::getProperty(const QString &property) -{ - QVariant var; - QVariantMap map = getProperties(); - if (map.contains(property)) { - var = map.value(property); - } else { - qDebug() << Q_FUNC_INFO << "does not contain" << property; - } - return var; -} - -QVariantMap QOfonoNetworkOperatorInterface::getProperties() -{ - QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); - return reply.value(); -} - -QOfonoSimInterface::QOfonoSimInterface(const QString &dbusPathName, QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), - dbusPathName, - OFONO_SIM_MANAGER_INTERFACE, - QDBusConnection::systemBus(), parent) -{ -} - -QOfonoSimInterface::~QOfonoSimInterface() -{ -} - -bool QOfonoSimInterface::isPresent() -{ - QVariant var = getProperty("Present"); - return qdbus_cast<bool>(var); -} - -QString QOfonoSimInterface::getHomeMcc() -{ - QVariant var = getProperty("MobileCountryCode"); - return qdbus_cast<QString>(var); -} - -QString QOfonoSimInterface::getHomeMnc() -{ - QVariant var = getProperty("MobileNetworkCode"); - return qdbus_cast<QString>(var); -} - -// QStringList subscriberNumbers(); -// QMap<QString,QString> serviceNumbers(); -QString QOfonoSimInterface::pinRequired() -{ - QVariant var = getProperty("PinRequired"); - return qdbus_cast<QString>(var); -} - -QString QOfonoSimInterface::lockedPins() -{ - QVariant var = getProperty("LockedPins"); - return qdbus_cast<QString>(var); -} - -QString QOfonoSimInterface::cardIdentifier() -{ - QVariant var = getProperty("CardIdentifier"); - return qdbus_cast<QString>(var); -} - -void QOfonoSimInterface::connectNotify(const QMetaMethod &signal) -{ - Q_UNUSED(signal); -// static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoSimInterface::propertyChanged); -// if (signal == propertyChangedSignal) { -// if (!connection().connect(QLatin1String(OFONO_SERVICE), -// this->path(), -// QLatin1String(OFONO_SIM_MANAGER_INTERFACE), -// QLatin1String("PropertyChanged"), -// this,SIGNAL(propertyChanged(QString,QDBusVariant)))) { -// qWarning() << "PropertyCHanged not connected"; -// } -// } - -// static const QMetaMethod propertyChangedContextSignal = QMetaMethod::fromSignal(&QOfonoSimInterface::propertyChangedContext); -// if (signal == propertyChangedContextSignal) { -// QOfonoDBusHelper *helper; -// helper = new QOfonoDBusHelper(this); - -// QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), -// this->path(), -// QLatin1String(OFONO_SIM_MANAGER_INTERFACE), -// QLatin1String("PropertyChanged"), -// helper,SLOT(propertyChanged(QString,QDBusVariant))); - - -// QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), -// this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection); -// } -} - -void QOfonoSimInterface::disconnectNotify(const QMetaMethod &signal) -{ - Q_UNUSED(signal); -// static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoSimInterface::propertyChanged); -// if (signal == propertyChangedSignal) { - -// } -} - -QVariant QOfonoSimInterface::getProperty(const QString &property) -{ - QVariant var; - QVariantMap map = getProperties(); - if (map.contains(property)) { - var = map.value(property); - } else { - qDebug() << Q_FUNC_INFO << "does not contain" << property; + if (propertiesMap.isEmpty()) { + QList<QVariant> argumentList; + QDBusPendingReply<QVariantMap> reply = asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList); + reply.waitForFinished(); + if (!reply.isError()) { + propertiesMap = reply.value(); + } else { + qDebug() << reply.error().message(); + } } - return var; -} - -QVariantMap QOfonoSimInterface::getProperties() -{ - QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); - return reply.value(); + return propertiesMap; } QOfonoDataConnectionManagerInterface::QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent) @@ -674,340 +247,62 @@ QOfonoDataConnectionManagerInterface::QOfonoDataConnectionManagerInterface(const OFONO_DATA_CONNECTION_MANAGER_INTERFACE, QDBusConnection::systemBus(), parent) { + QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), + path(), + QLatin1String(OFONO_MODEM_INTERFACE), + QLatin1String("PropertyChanged"), + this,SLOT(propertyChanged(QString,QDBusVariant))); } QOfonoDataConnectionManagerInterface::~QOfonoDataConnectionManagerInterface() { } -QList<QDBusObjectPath> QOfonoDataConnectionManagerInterface::getPrimaryContexts() +QStringList QOfonoDataConnectionManagerInterface::contexts() { - QList <QDBusObjectPath> contextList; - QList<QVariant> argumentList; - QDBusReply<PathPropertiesList > reply = this->asyncCallWithArgumentList(QLatin1String("GetContexts"), - argumentList); - if (reply.isValid()) { - foreach (ObjectPathProperties context, reply.value()) { - contextList << context.path; + if (contextList.isEmpty()) { + QDBusPendingReply<PathPropertiesList > reply = call(QLatin1String("GetContexts")); + reply.waitForFinished(); + if (!reply.isError()) { + foreach (ObjectPathProperties context, reply.value()) { + contextList << context.path.path(); + } } } return contextList; } -bool QOfonoDataConnectionManagerInterface::isAttached() -{ - QVariant var = getProperty("Attached"); - return qdbus_cast<bool>(var); -} - -bool QOfonoDataConnectionManagerInterface::isRoamingAllowed() +bool QOfonoDataConnectionManagerInterface::roamingAllowed() { - QVariant var = getProperty("RoamingAllowed"); + QVariant var = getProperty(QStringLiteral("RoamingAllowed")); return qdbus_cast<bool>(var); } -bool QOfonoDataConnectionManagerInterface::isPowered() -{ - QVariant var = getProperty("Powered"); - return qdbus_cast<bool>(var); -} - -void QOfonoDataConnectionManagerInterface::connectNotify(const QMetaMethod &signal) -{ - Q_UNUSED(signal); -// static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoDataConnectionManagerInterface::propertyChanged); -// if (signal == propertyChangedSignal) { -// if (!connection().connect(QLatin1String(OFONO_SERVICE), -// this->path(), -// QLatin1String(OFONO_DATA_CONNECTION_MANAGER_INTERFACE), -// QLatin1String("PropertyChanged"), -// this,SIGNAL(propertyChanged(QString,QDBusVariant)))) { -// qWarning() << "PropertyCHanged not connected"; -// } -// } - -// static const QMetaMethod propertyChangedContextSignal = QMetaMethod::fromSignal(&QOfonoDataConnectionManagerInterface::propertyChangedContext); -// if (signal == propertyChangedContextSignal) { -// QOfonoDBusHelper *helper; -// helper = new QOfonoDBusHelper(this); - -// QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), -// this->path(), -// QLatin1String(OFONO_DATA_CONNECTION_MANAGER_INTERFACE), -// QLatin1String("PropertyChanged"), -// helper,SLOT(propertyChanged(QString,QDBusVariant))); - - -// QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), -// this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection); -// } -} - -void QOfonoDataConnectionManagerInterface::disconnectNotify(const QMetaMethod &signal) -{ - Q_UNUSED(signal); -// static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoDataConnectionManagerInterface::propertyChanged); -// if (signal == propertyChangedSignal) { - -// } -} - QVariant QOfonoDataConnectionManagerInterface::getProperty(const QString &property) { QVariant var; QVariantMap map = getProperties(); - if (map.contains(property)) { - var = map.value(property); - } else { - qDebug() << Q_FUNC_INFO << "does not contain" << property; - } + var = map.value(property); return var; } QVariantMap QOfonoDataConnectionManagerInterface::getProperties() { - QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); - return reply.value(); -} - -QOfonoConnectionContextInterface::QOfonoConnectionContextInterface(const QString &dbusPathName, QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), - dbusPathName, - OFONO_DATA_CONTEXT_INTERFACE, - QDBusConnection::systemBus(), parent) -{ -} - -QOfonoConnectionContextInterface::~QOfonoConnectionContextInterface() -{ -} - -bool QOfonoConnectionContextInterface::isActive() -{ - QVariant var = getProperty("Active"); - return qdbus_cast<bool>(var); -} - -QString QOfonoConnectionContextInterface::getApName() -{ - QVariant var = getProperty("AccessPointName"); - return qdbus_cast<QString>(var); -} - -QString QOfonoConnectionContextInterface::getType() -{ - QVariant var = getProperty("Type"); - return qdbus_cast<QString>(var); -} - -QString QOfonoConnectionContextInterface::getName() -{ - QVariant var = getProperty("Name"); - return qdbus_cast<QString>(var); -} - -QVariantMap QOfonoConnectionContextInterface::getSettings() -{ - QVariant var = getProperty("Settings"); - return qdbus_cast<QVariantMap>(var); -} - -QString QOfonoConnectionContextInterface::getInterface() -{ - QVariant var = getProperty("Interface"); - return qdbus_cast<QString>(var); -} - -QString QOfonoConnectionContextInterface::getAddress() -{ - QVariant var = getProperty("Address"); - return qdbus_cast<QString>(var); -} - -bool QOfonoConnectionContextInterface::setActive(bool on) -{ -// this->setProperty("Active", QVariant(on)); - - return setProp("Active", QVariant::fromValue(on)); -} - -bool QOfonoConnectionContextInterface::setApn(const QString &name) -{ - return setProp("AccessPointName", QVariant::fromValue(name)); -} - -void QOfonoConnectionContextInterface::connectNotify(const QMetaMethod &signal) -{ - Q_UNUSED(signal); -// static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoConnectionContextInterface::propertyChanged); -// if (signal == propertyChangedSignal) { -// if (!connection().connect(QLatin1String(OFONO_SERVICE), -// this->path(), -// QLatin1String(OFONO_DATA_CONTEXT_INTERFACE), -// QLatin1String("PropertyChanged"), -// this,SIGNAL(propertyChanged(QString,QDBusVariant)))) { -// qWarning() << "PropertyCHanged not connected"; -// } -// } - -// static const QMetaMethod propertyChangedContextSignal = QMetaMethod::fromSignal(&QOfonoConnectionContextInterface::propertyChangedContext); -// if (signal == propertyChangedContextSignal) { -// QOfonoDBusHelper *helper; -// helper = new QOfonoDBusHelper(this); - -// QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), -// this->path(), -// QLatin1String(OFONO_DATA_CONTEXT_INTERFACE), -// QLatin1String("PropertyChanged"), -// helper,SLOT(propertyChanged(QString,QDBusVariant))); - - -// QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), -// this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection); -// } -} - -void QOfonoConnectionContextInterface::disconnectNotify(const QMetaMethod &signal) -{ - Q_UNUSED(signal); -// static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoConnectionContextInterface::propertyChanged); -// if (signal == propertyChangedSignal) { - -// } -} - -QVariant QOfonoConnectionContextInterface::getProperty(const QString &property) -{ - QVariant var; - QVariantMap map = getProperties(); - if (map.contains(property)) { - var = map.value(property); - } else { - qDebug() << Q_FUNC_INFO << "does not contain" << property; - } - return var; -} - -QVariantMap QOfonoConnectionContextInterface::getProperties() -{ - QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); - return reply.value(); -} - -bool QOfonoConnectionContextInterface::setProp(const QString &property, const QVariant &var) -{ - QList<QVariant> args; - args << QVariant::fromValue(property) << QVariant::fromValue(QDBusVariant(var)); - - QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect, - QLatin1String("SetProperty"), - args); - bool ok = true; - if (reply.type() != QDBusMessage::ReplyMessage) { - qWarning() << reply.errorMessage(); - ok = false; - } - qWarning() << reply.errorMessage(); - return ok; -} - -QOfonoSmsInterface::QOfonoSmsInterface(const QString &dbusPathName, QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), - dbusPathName, - OFONO_SMS_MANAGER_INTERFACE, - QDBusConnection::systemBus(), parent) -{ -} - -QOfonoSmsInterface::~QOfonoSmsInterface() -{ -} - -void QOfonoSmsInterface::connectNotify(const QMetaMethod &signal) -{ - static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoSmsInterface::propertyChanged); - if (signal == propertyChangedSignal) { - if (!connection().connect(QLatin1String(OFONO_SERVICE), - this->path(), - QLatin1String(OFONO_SMS_MANAGER_INTERFACE), - QLatin1String("PropertyChanged"), - this,SIGNAL(propertyChanged(QString,QDBusVariant)))) { - qWarning() << "PropertyCHanged not connected"; - } - } - - static const QMetaMethod propertyChangedContextSignal = QMetaMethod::fromSignal(&QOfonoSmsInterface::propertyChangedContext); - if (signal == propertyChangedContextSignal) { - QOfonoDBusHelper *helper; - helper = new QOfonoDBusHelper(this); - - QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), - this->path(), - QLatin1String(OFONO_SMS_MANAGER_INTERFACE), - QLatin1String("PropertyChanged"), - helper,SLOT(propertyChanged(QString,QDBusVariant))); - - - QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), - this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))); - } - - static const QMetaMethod immediateMessageSignal = QMetaMethod::fromSignal(&QOfonoSmsInterface::immediateMessage); - if (signal == immediateMessageSignal) { - if (!connection().connect(QLatin1String(OFONO_SERVICE), - this->path(), - QLatin1String(OFONO_SMS_MANAGER_INTERFACE), - QLatin1String("ImmediateMessage"), - this,SIGNAL(immediateMessage(QString,QVariantMap)))) { - qWarning() << "PropertyCHanged not connected"; - } - } - - static const QMetaMethod incomingMessageSignal = QMetaMethod::fromSignal(&QOfonoSmsInterface::incomingMessage); - if (signal == incomingMessageSignal) { - if (!connection().connect(QLatin1String(OFONO_SERVICE), - this->path(), - QLatin1String(OFONO_SMS_MANAGER_INTERFACE), - QLatin1String("IncomingMessage"), - this,SIGNAL(incomingMessage(QString,QVariantMap)))) { - qWarning() << "PropertyCHanged not connected"; + if (propertiesMap.isEmpty()) { + QList<QVariant> argumentList; + QDBusPendingReply<QVariantMap> reply = asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList); + if (!reply.isError()) { + propertiesMap = reply.value(); } } + return propertiesMap; } -void QOfonoSmsInterface::disconnectNotify(const QMetaMethod &signal) -{ - static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoSmsInterface::propertyChanged); - if (signal == propertyChangedSignal) { - - } -} - -QVariant QOfonoSmsInterface::getProperty(const QString &property) -{ - QVariant var; - QVariantMap map = getProperties(); - if (map.contains(property)) { - var = map.value(property); - } else { - qDebug() << Q_FUNC_INFO << "does not contain" << property; - } - return var; -} - -QVariantMap QOfonoSmsInterface::getProperties() -{ - QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); - return reply.value(); -} - -void QOfonoSmsInterface::sendMessage(const QString &to, const QString &message) +void QOfonoDataConnectionManagerInterface::propertyChanged(const QString &name, const QDBusVariant &value) { - QDBusReply<QString> reply = this->call(QLatin1String("SendMessage"), - QVariant::fromValue(to), - QVariant::fromValue(message)); - if (reply.error().type() == QDBusError::InvalidArgs) - qWarning("%s", qPrintable(reply.error().message())); + propertiesMap[name] = value.variant(); + if (name == QStringLiteral("RoamingAllowed")) + Q_EMIT roamingAllowedChanged(value.variant().toBool()); } QT_END_NAMESPACE |