void Tst_qofonoTest::testManager() { QOfonoManager manager; QStringList modems = manager.modems(); QVERIFY(!modems.isEmpty()); //TODO modemAdded, modemRemoved signals ? }
Tst_locationTest::Tst_locationTest() { QOfonoManager oMan; QOfonoAssistedSatelliteNavigation satNav; satNav.setModemPath(oMan.modems().at(0)); QOfonoPositioningRequestAgent posAgent; posAgent.setAgentPath("/QOfonoTest"); satNav.registerPositioningRequestAgent("/QOfonoTest"); }
SmartMessaging::SmartMessaging(QObject* parent) : MessageHandlerBase(parent, AGENT_PATH, AGENT_SERVICE) { QOfonoManager* ofono = new QOfonoManager(this); connect(ofono, SIGNAL(modemAdded(QString)), this, SLOT(onModemAdded(QString))); connect(ofono, SIGNAL(modemRemoved(QString)), this, SLOT(onModemRemoved(QString))); QStringList modems = ofono->modems(); DEBUG_("created"); foreach (QString path, modems) { DEBUG_("modem" << path); addModem(path); }
bool QConnectionManager::connectToNetworkService(const QString &servicePath) { qDebug() << servicePath << netman->state(); if (!servicesMap.contains(servicePath) || !serviceInProgress.isEmpty()) return false; NetworkTechnology technology; QString type = servicesMap.value(servicePath)->type(); if (type.isEmpty()) return false; technology.setPath(netman->technologyPathForType(type)); if (technology.powered()) { if (servicePath.contains("cellular")) { QOfonoManager oManager; if (!oManager.available()) { qDebug() << "ofono not available."; return false; } if (oManager.modems().count() < 1) return false; QOfonoNetworkRegistration ofonoReg; ofonoReg.setModemPath(oManager.modems().at(0)); if (ofonoReg.status() != "registered" && ofonoReg.status() != "roaming") { //not on any cell network so bail qDebug() << "ofono is not registered yet"; return false; } QOfonoConnectionManager oConnManager; oConnManager.setModemPath(oManager.modems().at(0)); //isCellRoaming if (servicesMap.value(servicePath)->roaming() && !oConnManager.roamingAllowed()) { //roaming and user doesnt want connection while roaming qDebug() << "roaming not allowed"; return false; } requestConnect(servicePath); } else { requestConnect(servicePath); } } return true; }
void QOfonoConnectionContext::setContextPath(const QString &idPath) { if (idPath != contextPath()) { if(d_ptr->context) { delete d_ptr->context; d_ptr->context = 0; d_ptr->properties.clear(); } qDebug() << Q_FUNC_INFO; d_ptr->context = new OfonoConnectionContext("org.ofono", idPath, QDBusConnection::systemBus(),this); if (d_ptr->context->isValid()) { d_ptr->contextPath = idPath; connect(d_ptr->context,SIGNAL(PropertyChanged(QString,QDBusVariant)), this,SLOT(propertyChanged(QString,QDBusVariant))); QDBusPendingReply<QVariantMap> reply; reply = d_ptr->context->GetProperties(); reply.waitForFinished(); if (reply.isError()) Q_EMIT reportError(reply.error().message()); d_ptr->properties = reply.value(); Q_EMIT contextPathChanged(idPath); } else { Q_EMIT reportError("Context is not valid"); qDebug() << Q_FUNC_INFO << "error Context is not valid"; } QOfonoManager manager; if (manager.modems().count() > 0) { QOfonoConnectionManager connManager; Q_FOREACH (const QString &path, manager.modems()) { connManager.setModemPath(path); if (connManager.contexts().contains(idPath)) { d_ptr->modemPath = path; Q_EMIT modemPathChanged(path); break; } } } /* if (!validateProvisioning()) { provisionForCurrentNetwork(this->type()); } else { Q_EMIT reportError("Context provision is not valid"); qDebug() << Q_FUNC_INFO << "error Context provision is not valid"; } */ }
void CDSimPlugin::init() { debug() << "Initializing contactsd sim plugin"; mController = new CDSimController(this); QOfonoManager ofonoManager; const QStringList &modems(ofonoManager.modems()); if (modems.isEmpty()) { qWarning() << "No modem available for sim plugin"; } else { // TODO: select the correct modem mController->setModemPath(modems.first()); } }
void Tst_qofonoTest::testContextConnection() { QOfonoManager manager; QOfonoModem modem; QStringList modems = manager.modems(); modem.setModemPath(manager.modems()[0]); qDebug() << Q_FUNC_INFO << manager.modems()[0] << modem.online(); if (!modem.online()) { QSignalSpy spy_bogusContext(&modem, SIGNAL(onlineChanged(bool))); modem.setOnline(true); ::waitForSignal(&modem,SIGNAL(onlineChanged(bool)),3000); QCOMPARE(spy_bogusContext.count(),1); }
void Tst_qofonoTest::testScan() { QOfonoManager manager; QOfonoModem modem; modem.setModemPath(manager.modems()[0]); QOfonoNetworkRegistration netreg; netreg.setModemPath(manager.modems()[0]); QSignalSpy spy_scanFinished(&netreg, SIGNAL(scanFinished())); QSignalSpy spy_scanError(&netreg, SIGNAL(scanError(QString))); netreg.scan(); ::waitForSignal(&netreg, SIGNAL(scanFinished()), 1000 * 500); QCOMPARE(spy_scanError.count(),0); QCOMPARE(spy_scanFinished.count(),1); }
void Tst_qofonoTest::testConnectionManager() { QOfonoManager manager; QOfonoConnectionManager connman; QOfonoModem modem; modem.setModemPath(manager.modems()[0]); if (!modem.online()) { modem.setOnline(true); } QVERIFY(modem.online()); connman.setModemPath(manager.modems()[0]); QVERIFY(!connman.modemPath().isEmpty()); QSignalSpy spy(&connman, SIGNAL(contextAdded(QString))); connman.addContext("internet"); ::waitForSignal(&connman,SIGNAL(contextAdded(QString)),1000); QCOMPARE(spy.count(),1); // QList<QVariant> arguments ; // arguments = spy.takeFirst(); // attached // bearer // suspended // roamingAllowed // QSignalSpy spy_roaming(&connman, SIGNAL(roamingAllowedChanged(bool))); // bool expected = !connman.roamingAllowed(); // connman.setRoamingAllowed(expected); // QTest::qWait(3000); // QCOMPARE(spy_roaming.count(),1); // QList<QVariant> argumentsspy_roaming; // argumentsspy_roaming = spy_roaming.takeFirst(); // QCOMPARE(argumentsspy_roaming[0].toBool(), expected); // connman.setRoamingAllowed(false); // QTest::qWait(3000); // QCOMPARE(spy_roaming.count(),1); // QList<QVariant> argumentsspy_roaming2; // argumentsspy_roaming2 = spy_roaming.takeFirst(); // if (manager.modems()[0].contains("phonesim")) // QEXPECT_FAIL("","seems to nt work on phonesim",Continue); // QCOMPARE(argumentsspy_roaming[0].toBool(), false); // // powered // QSignalSpy spy_powered(&connman, SIGNAL(poweredChanged(bool))); // QList<QVariant> argumentsspy_powered; // bool isPowered = connman.powered(); // qDebug() << Q_FUNC_INFO << "modem powered" << connman.powered(); // connman.setPowered(!isPowered); // QTest::qWait(3000); // QCOMPARE(spy_powered.count(),2); //powers itself back on // argumentsspy_powered = spy_powered.takeFirst(); // QCOMPARE(argumentsspy_powered[0].toBool(), !isPowered); // if(!connman.powered()) { // connman.setPowered(true); // QTest::qWait(3000); // QVERIFY(connman.powered()); // } //TODO other signals }