void ConnectionAgentPlugin::sendUserReply(const QVariantMap &input)
{
    if (!connManagerInterface || !connManagerInterface->isValid()) {
        Q_EMIT errorReported("","ConnectionAgent not available");
        return;
    }
    QDBusPendingReply<> reply = connManagerInterface->sendUserReply(input);
    reply.waitForFinished();
    if (reply.isError()) {
        qDebug() << Q_FUNC_INFO << reply.error().message();
        Q_EMIT errorReported("",reply.error().message());
    }
}
Exemplo n.º 2
0
void QmlPreviewClient::messageReceived(const QByteArray &data)
{
    QmlDebug::QPacket packet(dataStreamVersion(), data);
    qint8 command;
    packet >> command;
    switch (command) {
    case Request: {
        QString path;
        packet >> path;
        emit pathRequested(path);
        break;
    }
    case Error: {
        QString error;
        packet >> error;
        emit errorReported(error);
        break;
    }
    case Fps: {
        FpsInfo info;
        packet >> info.numSyncs >> info.minSync >> info.maxSync >> info.totalSync
               >> info.numRenders >> info.minRender >> info.maxRender >> info.totalRender;
        emit fpsReported(info);
        break;
    }
    default:
        qDebug() << "invalid command" << command;
        break;
    }
}
void ConnectionAgentPlugin::sendConnectReply(const QString &replyMessage, int timeout)
{
    if (!connManagerInterface || !connManagerInterface->isValid()) {
        Q_EMIT errorReported("","ConnectionAgent not available");
        return;
    }
    connManagerInterface->sendConnectReply(replyMessage,timeout);
}
void ConnectionAgentPlugin::connectToType(const QString &type)
{
    if (!connManagerInterface || !connManagerInterface->isValid()) {
        Q_EMIT errorReported("","ConnectionAgent not available");
        return;
    }

    connManagerInterface->connectToType(type);
}
Exemplo n.º 5
0
void QConnectionManager::connectToType(const QString &type)
{
    qDebug() << type;
    currentType = type;
    QString techPath = netman->technologyPathForType(type);

    if (techPath.isEmpty()) {
        Q_EMIT errorReported("","Type not valid");
        return;
    }

    NetworkTechnology netTech;
    netTech.setPath(techPath);

    if (!netTech.powered()) { // user has indicated they want a connection
        netTech.setPowered(true);
    }
    QStringList servicesList = netman->servicesList(type);
    bool needConfig = false;

    if (servicesList.isEmpty()) {
        if (type == "wifi") {
            QObject::connect(&netTech,SIGNAL(scanFinished()),this,SLOT(onScanFinished()));
            netTech.scan();
        } else {
            needConfig = true;
//            Q_EMIT errorReported("Service not found"); ?? do we want to report an error
        }
    } else {
        currentType = "";

        Q_FOREACH (const QString path, servicesList) {
            // try harder with cell. a favorite is one that has been connected
            // if there is a context configured but not yet connected, try to connect anyway

            if (servicesMap.contains(path) &&
                    (servicesMap.value(path)->favorite()
                     || servicesMap.value(path)->type() == "cellular")) {
                connectToNetworkService(path);
                needConfig = false;
                return;
            } else {
                needConfig = true;
            }
        }
    }
    if (needConfig) {
        Q_EMIT configurationNeeded(type);
    }
}
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)));
}
void Tst_connectionagent::tst_onErrorReported()
{
    QSignalSpy spy(&QConnectionAgent::instance(), SIGNAL(errorReported(QString,QString)));
    QConnectionAgent::instance().onErrorReported("test_path","Test error");

    QCOMPARE(spy.count(),1);
    QList<QVariant> arguments;
    arguments = spy.takeFirst();
    QCOMPARE(arguments.at(0).toString(), QString("test_path"));
    QCOMPARE(arguments.at(1).toString(), QString("Test error"));

    QConnectionAgent::instance().connectToType("test");
    QCOMPARE(spy.count(),1);
    arguments = spy.takeFirst();
    QCOMPARE(arguments.at(0).toString(), QString(""));
    QCOMPARE(arguments.at(1).toString(), QString("Type not valid"));

}
void ConnectionAgentPlugin::onErrorReported(const QString &servicePath, const QString &error)
{
    Q_EMIT errorReported(servicePath, error);
}
Exemplo n.º 9
0
void STAccount::reportError(const QString &msg){
    emit errorReported(msg, this);
}
Exemplo n.º 10
0
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()));

}
Exemplo n.º 11
0
void QConnectionManager::serviceStateChanged(const QString &state)
{
    NetworkService *service = static_cast<NetworkService *>(sender());
    qDebug() << state << service->name();

    if (currentNetworkState == "disconnect") {
        ua->sendConnectReply("Clear");
    }
    if (state == "failure") {
        serviceInProgress.clear();

        Q_EMIT errorReported(service->path(), "Connection failure: "+ service->name());
        autoConnect();
    }
    if (currentNetworkState == "configuration" && state == "ready"
            && netman->state() != "online") {
        goodConnectTimer->start();
    }

    //manual connection
    if ((state == "ready" || state == "online") && service->path() != serviceInProgress) {
        qDebug() << "manual connection of" << service->path() << "detected, enabling auto connect timeout";
        lastManuallyConnectedService = service->path();
        manualConnnectionTimer.start();
    }

    //auto migrate
    if (service->path() == serviceInProgress
            && state == "online") {
        serviceInProgress.clear();
    }

    //auto migrate
    if (state == "idle") {
        if (lastManuallyConnectedService == service->path()) {
            lastManuallyConnectedService.clear();
            manualConnnectionTimer.invalidate();
        }

        if (serviceInProgress == service->path())
            serviceInProgress.clear();

        previousConnectedService = service->path();
        if (service->type() == "ethernet") { //keep this alive
            NetworkTechnology tech;
            tech.setPath(netman->technologyPathForService(service->path()));
            if (tech.powered()) {
               requestConnect(service->path());
            }
        } else {
            updateServicesMap();
            qDebug() <<"serviceInProgress"<< serviceInProgress;
            // If a manual connection has recently been detected autoConnect() will do nothing.
            // Always call autoConnect() here as this state change could be that manual connection
            // disconnecting.
            autoConnect();
        }
    }

    if (!(currentNetworkState == "online" && state == "association"))
        Q_EMIT connectionState(state, service->type());

        currentNetworkState = state;
        QSettings confFile;
        confFile.beginGroup("Connectionagent");
        confFile.setValue("connected",currentNetworkState);
}
Exemplo n.º 12
0
void QConnectionManager::serviceErrorChanged(const QString &error)
{
    qDebug() << error;
    NetworkService *service = static_cast<NetworkService *>(sender());
    Q_EMIT errorReported(service->path(),error);
}
Exemplo n.º 13
0
// from useragent
void QConnectionManager::onErrorReported(const QString &servicePath, const QString &error)
{
    qDebug() << error;
    Q_EMIT errorReported(servicePath, error);
    serviceInProgress.clear();
}
Exemplo n.º 14
0
void UserAgent::reportError(const QString &servicePath, const QString &error)
{
    Q_EMIT errorReported(servicePath, error);
}
Exemplo n.º 15
0
void UserAgent::reportError(const QString &error) {
    emit errorReported(error);
}