void ConnectionAgentPlugin::onUserInputRequested(const QString &service, const QVariantMap &fields) { // we do this as qtdbus does not understand QVariantMap very well. // we need to manually demarshall QVariantMap map; QMapIterator<QString, QVariant> i(fields); // this works for Passphrase at least. anything else? while (i.hasNext()) { i.next(); QDBusArgument arg = fields.value(i.key()).value<QDBusArgument>(); QVariantMap vmap = qdbus_cast<QVariantMap>(arg); map.insert(i.key(), vmap); } Q_EMIT userInputRequested(service, map); }
void Tst_connectionagent::tst_onUserInputRequested() { QSignalSpy spy(&QConnectionAgent::instance(), SIGNAL(userInputRequested(QString,QVariantMap))); QVariantMap map; map.insert("test",true); QConnectionAgent::instance().onUserInputRequested(QLatin1String("test_path"), map); QCOMPARE(spy.count(),1); QList<QVariant> arguments; arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toString(), QString("test_path")); QVariantMap map2 = arguments.at(1).toMap(); QCOMPARE(map2.keys().at(0), QString("test")); }
void UserAgent::requestUserInput(ServiceRequestData* data) { m_req_data = data; QVariantList fields; foreach (const QString &key, data->fields.keys()) { QVariantMap field; field.insert("name", key); field.insert("type", data->fields.value(key).toMap().value("Type")); fields.append(QVariant(field)); } emit userInputRequested(data->objectPath, fields); }
void ConnectionAgentPlugin::connectToConnectiond(QString) { if (connManagerInterface) { delete connManagerInterface; connManagerInterface = 0; } if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(CONND_SERVICE)) { qDebug() << Q_FUNC_INFO << QString("connection service not available").arg(CONND_SERVICE); QDBusReply<void> reply = QDBusConnection::sessionBus().interface()->startService(CONND_SERVICE); if (!reply.isValid()) { qDebug() << Q_FUNC_INFO << reply.error().message(); return; } } connManagerInterface = new com::jolla::Connectiond(CONND_SERVICE, CONND_PATH, QDBusConnection::sessionBus(), this); if (!connManagerInterface->isValid()) { qDebug() << Q_FUNC_INFO << "is not valid interface"; } connect(connManagerInterface,SIGNAL(connectionRequest()), this,SLOT(onConnectionRequested())); connect(connManagerInterface,SIGNAL(configurationNeeded(QString)), this,SIGNAL(configurationNeeded(QString))); connect(connManagerInterface,SIGNAL(userInputCanceled()), this,SIGNAL(userInputCanceled())); connect(connManagerInterface, SIGNAL(errorReported(QString, QString)), this, SLOT(onErrorReported(QString, QString))); connect(connManagerInterface,SIGNAL(connectionState(QString, QString)), this,SLOT(onConnectionState(QString, QString))); connect(connManagerInterface,SIGNAL(requestBrowser(QString)), this,SLOT(onRequestBrowser(QString))); connect(connManagerInterface,SIGNAL(userInputRequested(QString,QVariantMap)), this,SLOT(onUserInputRequested(QString,QVariantMap)), Qt::UniqueConnection); connect(connManagerInterface,SIGNAL(tetheringFinished(bool)), this,SLOT(onTetheringFinished(bool))); }
ScriptUi::ScriptUi(QWidget *parent) : QDockWidget(parent), ui(new Ui::ScriptUi) { qRegisterMetaType<UserRequest>("UserRequest"); ui->setupUi(this); ui->informationBox->hide(); connect(HilecSingleton::hilec(), SIGNAL(userInputRequested(UserRequest)), SLOT(handleUserRequest(UserRequest))); connect(HilecSingleton::hilec(), SIGNAL(userInputAborted(int)), SLOT(abortUserRequest(int))); connect(HilecSingleton::hilec(), SIGNAL(newProgressBar(int,QString, int)), SLOT(onNewPrgoressBar(int,QString, int))); connect(HilecSingleton::hilec(), SIGNAL(progressBarUpdated(int,int)), SLOT(onProgressBarUpdated(int,int))); connect(HilecSingleton::hilec(), SIGNAL(progressBarRemoved(int)), SLOT(onProgressBarRemoved(int))); connect(HilecSingleton::hilec(), SIGNAL(newInfoPanel(int,QString,QStringList)), SLOT(onNewInfoPanel(int,QString,QStringList))); connect(HilecSingleton::hilec(), SIGNAL(infoPanelUpdated(int,QStringList)), SLOT(onInfoPanelUpdated(int,QStringList))); connect(HilecSingleton::hilec(), SIGNAL(infoPanelRemoved(int)), SLOT(onInfoPanelRemoved(int))); connect(HilecSingleton::hilec(), SIGNAL(infoCleared()), ui->information, SLOT(clear())); connect(HilecSingleton::hilec(), SIGNAL(infoCleared()), ui->informationBox, SLOT(hide())); connect(HilecSingleton::hilec(), SIGNAL(infoAppended(QString)), ui->information, SLOT(append(QString))); connect(HilecSingleton::hilec(), SIGNAL(infoAppended(QString)), ui->informationBox, SLOT(show())); connect(HilecSingleton::hilec(), SIGNAL(scriptExecutionFinished()), SLOT(onScriptFinished())); //connect(HilecSingleton::hilec(), SIGNAL(), SLOT()); connect(this, SIGNAL(newUserInput(int,int,QList<QVariant>)), HilecSingleton::hilec(), SLOT(userInput(int,int, const QList<QVariant>&))); }
QConnectionManager::QConnectionManager(QObject *parent) : QObject(parent), netman(NetworkManagerFactory::createInstance()), currentNetworkState(QString()), currentType(QString()), currentNotification(0), askForRoaming(false), isEthernet(false), connmanAvailable(false), handoverInProgress(false), oContext(0), tetheringWifiTech(0), tetheringEnabled(false), flightModeSuppression(false) { qDebug() << Q_FUNC_INFO; manualConnnectionTimer.invalidate(); connect(netman,SIGNAL(availabilityChanged(bool)),this,SLOT(connmanAvailabilityChanged(bool))); connectionAdaptor = new ConnAdaptor(this); QDBusConnection dbus = QDBusConnection::sessionBus(); if (!dbus.registerService(CONND_SERVICE)) { qDebug() << "XXXXXXXXXXX could not register service XXXXXXXXXXXXXXXXXX"; } if (!dbus.registerObject(CONND_PATH, this)) { qDebug() << "XXXXXXXXXXX could not register object XXXXXXXXXXXXXXXXXX"; } askForRoaming = askRoaming(); connect(&clockModel,SIGNAL(timeUpdatesChanged()),this,SLOT(timeUpdatesChanged())); ua = new UserAgent(this); connect(ua,SIGNAL(userInputRequested(QString,QVariantMap)), this,SLOT(onUserInputRequested(QString,QVariantMap))); connect(ua,SIGNAL(connectionRequest()),this,SLOT(onConnectionRequest())); connect(ua,SIGNAL(errorReported(QString, QString)),this,SLOT(onErrorReported(QString, QString))); connect(ua,SIGNAL(userInputCanceled()),this,SLOT(onUserInputCanceled())); connect(ua,SIGNAL(userInputRequested(QString,QVariantMap)), this,SLOT(onUserInputRequested(QString,QVariantMap)), Qt::UniqueConnection); connect(ua,SIGNAL(browserRequested(QString,QString)), this,SLOT(browserRequest(QString,QString)), Qt::UniqueConnection); connect(netman,SIGNAL(servicesListChanged(QStringList)),this,SLOT(servicesListChanged(QStringList))); connect(netman,SIGNAL(stateChanged(QString)),this,SLOT(networkStateChanged(QString))); connect(netman,SIGNAL(servicesChanged()),this,SLOT(setup())); connect(netman,SIGNAL(offlineModeChanged(bool)),this,SLOT(offlineModeChanged(bool))); QFile connmanConf("/etc/connman/main.conf"); if (connmanConf.open(QIODevice::ReadOnly | QIODevice::Text)) { while (!connmanConf.atEnd()) { QString line = connmanConf.readLine(); if (line.startsWith("DefaultAutoConnectTechnologies")) { QString token = line.section(" = ",1,1).simplified(); techPreferenceList = token.split(","); break; } } connmanConf.close(); } if (techPreferenceList.isEmpty()) //ethernet,bluetooth,cellular,wifi is default techPreferenceList << "wifi" << "cellular" << "bluetooth" << "ethernet"; mceWatch = new WakeupWatcher(this); connect(mceWatch,SIGNAL(displayStateChanged(QString)),this,SLOT(displayStateChanged(QString))); connect(mceWatch,SIGNAL(sleepStateChanged(bool)),this,SLOT(sleepStateChanged(bool))); connmanAvailable = QDBusConnection::systemBus().interface()->isServiceRegistered("net.connman"); if (connmanAvailable) setup(); goodConnectTimer = new QTimer(this); goodConnectTimer->setSingleShot(true); goodConnectTimer->setInterval(12 * 1000); connect(goodConnectTimer,SIGNAL(timeout()),this,SLOT(connectionTimeout())); }
// from useragent void QConnectionManager::onUserInputRequested(const QString &servicePath, const QVariantMap &fields) { qDebug() << servicePath; // gets called when a connman service gets called to connect and needs more configurations. Q_EMIT userInputRequested(servicePath, fields); }
void UserAgent::requestUserInput(ServiceRequestData* data) { m_req_data = data; Q_EMIT userInputRequested(data->objectPath, data->fields); }