Example #1
0
void CheckInternetOp::onConnectHostFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (isAborted())
    {
        LOG_DEBUG(QString::fromUtf8("connectHost self aborted!"));
        return;
    }

    if (op->isAborted())
    {
        LOG_DEBUG(QString::fromUtf8("connectHost op aborted!"));
        return notifyFinished(AbortedError);
    }

    int result = op->result();
    LOG_DEBUG(QString::fromUtf8("connectHost result: %1").arg(result));
    if (result != NoError)
    {
        return retry();
    }

    notifyFinished(NoError);
}
Example #2
0
void ChangeRouterWanSettingsOp::onSoapFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (isAborted())
    {
        return;
    }

    int result = op->result();
    if (result != NoError)
    {
        return notifyFinished(result);
    }

    QVariant varResponseCode = op->value("responseCode");
    if (!varResponseCode.isValid())
    {
        return notifyFinished(UnknownError);
    }

    bool ok;
    int responseCode = varResponseCode.toInt(&ok);
    if (!ok)
    {
        return notifyFinished(UnknownError);
    }

    notifyFinished(NoError);
}
Example #3
0
void ReconnectRouterOp::onDiscoverRouterFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (isAborted())
    {
        LOG_DEBUG(QString::fromUtf8("discoverRouter self aborted!"));
        return;
    }

    if (op->isAborted())
    {
        LOG_DEBUG(QString::fromUtf8("discoverRouter op aborted!"));
        return notifyFinished(AbortedError);
    }

    int result = op->result();
    LOG_DEBUG(QString::fromUtf8("discoverRouterSoap result: %1").arg(result));
    if (result != NoError)
    {
        return retry();
    }

    int matchIndex = op->value("matchIndex").toInt();
    LOG_DEBUG(QString::fromUtf8("matchIndex %1").arg(matchIndex));
    if (matchIndex < 0)
    {
        return retry();
    }

    copyValues(op);
    notifyFinished(NoError);
}
Example #4
0
void MasterDiscoverRouterSoapOp::onOpFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (op->isAborted())
    {
        LOG_DEBUG(QString::fromUtf8("MasterDiscoverRouterSoapOp::onOpFinished() aborted"));
        return;
    }

    int result = op->result();
    LOG_DEBUG(QString::fromUtf8("MasterDiscoverRouterSoapOp::onOpFinished() %1").arg(result));

    if (result != NoError)
    {
        if (m_retryCount < m_maxRetryCount)
        {
            LOG_DEBUG(QString::fromUtf8("MasterDiscoverRouterSoapOp Failed, but will retry later"));
            ++m_retryCount;
            m_timer1.setSingleShot(true);
            m_timer1.setInterval(m_retryDelay);
            connect(&m_timer1, SIGNAL(timeout()), SLOT(onRetryTimeout()));
            m_timer1.start();
            return;
        }
        LOG_DEBUG(QString::fromUtf8("MasterDiscoverRouterSoapOp Failed, no more retry chance!"));
        return notifyFinished(UnknownError);
    }

    copyValues(op);
    notifyFinished(NoError);
}
Example #5
0
void ReconnectRouterOp::onConnectProfileFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (isAborted())
    {
        LOG_DEBUG(QString::fromUtf8("connectProfile self aborted!"));
        return;
    }

    if (op->isAborted())
    {
        LOG_DEBUG(QString::fromUtf8("connectProfile op aborted!"));
        return notifyFinished(AbortedError);
    }

    int result = op->result();
    LOG_DEBUG(QString::fromUtf8("connectWlanProfile %1 result: %1").arg(m_wifiName).arg(result));
    if (result == WlanProfileNotFound )
    {
        LOG_DEBUG(QString::fromUtf8("recreate profile?"));
        notifyFinished(WlanProfileNotFound);
    }
    if (result != NoError)
    {
        return retry();
    }

    discoverRouter();
}
Example #6
0
void ChangeRouterPasswordOp::onCreateProfileFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (op->isAborted())
    {
        return;
    }

    int result = op->result();
    LOG_DEBUG(QString::fromUtf8("createWlanProfile result: %1").arg(result));
    if (result == WlanRadioOffError || result == WlanServiceDownError || result == WlanNoDeviceError)
    {
        return notifyFinished(NoError);
    }

    if (result != AsyncOp::NoError)
    {
        return notifyFinished(result);
    }

    m_op = m_bean->reconnectRouter(3000, 10, m_infoResp.value(QLatin1String("NewWLANMACAddress")).toString(), m_infoResp.value(QLatin1String("NewSSID")).toString(), true);
    connect(m_op, SIGNAL(finished()), SLOT(onReconnectFinished()));
}
Example #7
0
void CheckRouterSoapOp::onGetInfo3Finished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (op->isAborted())
    {
        LOG_DEBUG(QString::fromUtf8("CheckRouterSoapOp::onGetInfo3Finished() aborted"));
        return;
    }

    int result = op->result();
    LOG_DEBUG(QString::fromUtf8("CheckRouterSoapOp::onGetInfo3Finished() %1").arg(result));

    if (result != NoError)
    {
        return notifyFinished(UnknownError);
    }

    bool ok;
    int responseCode = op->value("responseCode").toInt(&ok);
    if (!ok || responseCode != 0)
    {
        LOG_DEBUG(QString::fromUtf8("CheckRouterSoapOp::onGetInfo3Finished() response error: %1 %2").arg(responseCode).arg(ok));
        return notifyFinished(result);
    }

    m_values.unite(qvariant_cast<QVariantMap>(op->value("response")));
    setValues(m_values);
    notifyFinished(result);
}
Example #8
0
void ChangeRouterWifiPasswordOp::onSetWLANFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (isAborted())
    {
        return;
    }

    int result = op->result();
    LOG_DEBUG(QString::fromUtf8("onSetWLANFinished %1").arg(result));
    if (result != NoError)
    {
        return notifyFinished(result);
    }

    QVariant varResponseCode = op->value("responseCode");
    if (!varResponseCode.isValid())
    {
        return notifyFinished(UnknownError);
    }

    bool ok;
    int responseCode = varResponseCode.toInt(&ok);
    if (!ok)
    {
        return notifyFinished(UnknownError);
    }

    if (responseCode != 0)
    {
        return notifyFinished(UnknownError);
    }

    if (m_configFinish)
    {
        m_op = m_bean->m_soapCore->invoke(QLatin1String("DeviceConfig"), QLatin1String("ConfigurationFinished"), QLatin1String("NewStatus"), QLatin1String("ChangesApplied"));
        connect(m_op, SIGNAL(finished()), SLOT(onCommitFinished()));

        connect(&m_timer1, SIGNAL(timeout()), SLOT(onTimeout1()));
        m_timer1.setSingleShot(true);
        m_timer1.start(8000);
    }
    else
    {
        notifyFinished(NoError);
    }
}
Example #9
0
void ChangeRouterWifiPasswordOp::onCommitFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (isAborted())
    {
        return;
    }

    LOG_DEBUG(QString::fromUtf8("onCommitFinished %1").arg(op->result()));

    notifyFinished(NoError);
}
Example #10
0
void ChangeRouterPasswordOp::onGetKeysFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (isAborted())
    {
        return;
    }

    int result = op->result();
    if (result != NoError)
    {
        return notifyFinished(result);
    }

    QVariant varResponseCode = op->value("responseCode");
    if (!varResponseCode.isValid())
    {
        return notifyFinished(UnknownError);
    }

    bool ok;
    int responseCode = varResponseCode.toInt(&ok);
    if (!ok)
    {
        return notifyFinished(UnknownError);
    }

    if (responseCode != 0)
    {
        return notifyFinished(UnknownError);
    }

    QVariant varResponse = op->value("response");
    if (!varResponse.isValid())
    {
        return notifyFinished(UnknownError);
    }

    QVariantMap resp = qvariant_cast<QVariantMap>(varResponse);
    m_currentWifiKey = resp.value(QLatin1String("NewWPAPassphrase")).toString();

    m_bean->m_soapCore->setWrappedMode(false);
    m_op = m_bean->m_soapCore->invoke(QLatin1String("LANConfigSecurity"), QLatin1String("GetInfo"));
    connect(m_op, SIGNAL(finished()), SLOT(onGetLanInfoFinished()));
}
Example #11
0
void ChangeRouterPasswordOp::onConfigOutFinished()
{
    m_timer1.stop();

    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (op->isAborted())
    {
        return;
    }

    if (isAborted())
    {
        return;
    }

    int result = op->result();
    if (result != NoError)
    {
        return notifyFinished(result);
    }

    QVariant varResponseCode = op->value("responseCode");
    if (!varResponseCode.isValid())
    {
        return notifyFinished(UnknownError);
    }

    bool ok;
    int responseCode = varResponseCode.toInt(&ok);
    if (!ok)
    {
        return notifyFinished(UnknownError);
    }

//	if (responseCode != 0) {
//		return notifyFinished(UnknownError);
//	}

//	notifyFinished(NoError);

    updateProfile();
}
Example #12
0
void ChangeRouterPasswordOp::onWifiConfigFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (isAborted())
    {
        return;
    }

    int result = op->result();
    if (result != NoError)
    {
        return notifyFinished(result);
    }

    QVariant varResponseCode = op->value("responseCode");
    if (!varResponseCode.isValid())
    {
        return notifyFinished(UnknownError);
    }

    bool ok;
    int responseCode = varResponseCode.toInt(&ok);
    if (!ok)
    {
        return notifyFinished(UnknownError);
    }

    if (responseCode != 0)
    {
        return notifyFinished(UnknownError);
    }

    if (!m_adminPassword.isNull())
    {
        startAdminConfig();
    }
    else
    {
        startConfigOut();
    }
}
Example #13
0
void ChangeRouterPasswordOp::onReconnectFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (op->isAborted())
    {
        return;
    }

    int result = op->result();
    LOG_DEBUG(QString::fromUtf8("reconnectRouter result: %1").arg(result));

    if (result != NoError)
    {
        notifyFinished(result);
    }

    notifyFinished(NoError);
}
Example #14
0
void RestartRouterOp::onConfigStarted()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (isAborted())
    {
        return;
    }

    int result = op->result();
    LOG_DEBUG(QString::fromUtf8("onConfigStarted %1").arg(result));
    if (result != NoError)
    {
        return notifyFinished(result);
    }

    QVariant varResponseCode = op->value("responseCode");
    if (!varResponseCode.isValid())
    {
        return notifyFinished(UnknownError);
    }

    bool ok;
    int responseCode = varResponseCode.toInt(&ok);
    if (!ok)
    {
        return notifyFinished(UnknownError);
    }

    if (responseCode != 0)
    {
        return notifyFinished(UnknownError);
    }

    m_op = m_bean->m_soapCore->invoke(QLatin1String("DeviceConfig"), QLatin1String("ConfigurationFinished"), QLatin1String("NewStatus"), QLatin1String("RebootRequired"));
    connect(m_op, SIGNAL(finished()), SLOT(onConfigFinished()));
}
Example #15
0
void ChangeRouterWifiPasswordOp::onConfigStarted()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (isAborted())
    {
        return;
    }

    int result = op->result();
    LOG_DEBUG(QString::fromUtf8("onConfigStarted %1").arg(result));
    if (result != NoError)
    {
        return notifyFinished(result);
    }

    QVariant varResponseCode = op->value("responseCode");
    if (!varResponseCode.isValid())
    {
        return notifyFinished(UnknownError);
    }

    bool ok;
    int responseCode = varResponseCode.toInt(&ok);
    if (!ok)
    {
        return notifyFinished(UnknownError);
    }

    if (responseCode != 0)
    {
        return notifyFinished(UnknownError);
    }

    m_op = m_bean->m_soapCore->invoke(NS_WLANConfiguration, QLatin1String("GetInfo"));
    connect(m_op, SIGNAL(finished()), SLOT(onGetInfoFinished()));
}
Example #16
0
void EnsureSoapOp::onSoapFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    int result = op->result();
    if (result != NoError)
    {
        if (++m_currentCount <= m_retryCount)
        {
            LOG_DEBUG(QString::fromUtf8("EnsureSoap: failed, retry %1").arg(m_currentCount));
            m_timer1.start(m_delay);
            return;
        }
        LOG_DEBUG(QString::fromUtf8("EnsureSoap: no more chance!"));
        return notifyFinished(result);
    }

    LOG_DEBUG(QString::fromUtf8("EnsureSoap: OK!"));
    notifyFinished(NoError);
}
Example #17
0
void RestartRouterOp::onConfigFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (isAborted())
    {
        return;
    }

    int result = op->result();
    LOG_DEBUG(QString::fromUtf8("onConfigFinished %1").arg(result));
    if (result != NoError)
    {
        return notifyFinished(result);
    }

    QVariant varResponseCode = op->value("responseCode");
    if (!varResponseCode.isValid())
    {
        return notifyFinished(UnknownError);
    }

    bool ok;
    int responseCode = varResponseCode.toInt(&ok);
    if (!ok)
    {
        return notifyFinished(UnknownError);
    }

    if (responseCode != 0)
    {
        return notifyFinished(UnknownError);
    }

    notifyFinished(NoError);
}
Example #18
0
void CheckRouterSoapOp::onGetInfo2Finished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (op->isAborted())
    {
        LOG_DEBUG(QString::fromUtf8("CheckRouterSoapOp::onGetInfo2Finished() aborted"));
        return;
    }

    int result = op->result();
    LOG_DEBUG(QString::fromUtf8("CheckRouterSoapOp::onGetInfo2Finished() %1").arg(result));

    if (result != NoError)
    {
        return notifyFinished(result);
    }

    bool ok;
    int responseCode = op->value("responseCode").toInt(&ok);
    if (!ok || responseCode != 0)
    {
        LOG_DEBUG(QString::fromUtf8("CheckRouterSoapOp::onGetInfo2Finished() response error: %1 %2").arg(responseCode).arg(ok));
        return notifyFinished(UnknownError);
    }

    m_values.unite(qvariant_cast<QVariantMap>(op->value("response")));

    SoapCore *soapCore = m_bean->m_soapCore;
    QString host = soapCore->host();
    soapCore->setHost(m_host);
    m_op = soapCore->invoke(QLatin1String("DeviceInfo"), QLatin1String("GetSysUpTime"));
    soapCore->setHost(host);
    connect(m_op, SIGNAL(finished()), SLOT(onGetInfo3Finished()));
}
Example #19
0
void ChangeRouterWifiPasswordOp::onGetInfoFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (isAborted())
    {
        return;
    }

    int result = op->result();
    LOG_DEBUG(QString::fromUtf8("onGetInfoFinished %1").arg(result));
    if (result != NoError)
    {
        return notifyFinished(result);
    }

    QVariant varResponseCode = op->value("responseCode");
    if (!varResponseCode.isValid())
    {
        return notifyFinished(UnknownError);
    }

    bool ok;
    int responseCode = varResponseCode.toInt(&ok);
    if (!ok)
    {
        return notifyFinished(UnknownError);
    }

    if (responseCode != 0)
    {
        return notifyFinished(UnknownError);
    }

    QVariant varResponse = op->value("response");
    if (!varResponse.isValid())
    {
        return notifyFinished(UnknownError);
    }

    QVariantMap response = qvariant_cast<QVariantMap>(varResponse);

    QString ssid = m_ssid.isNull() ? response.value(QLatin1String("NewSSID")).toString() : m_ssid;

    QStringList paramNames;
    QStringList paramValues;

    paramNames << QLatin1String("NewSSID") << QLatin1String("NewRegion") << QLatin1String("NewChannel") << QLatin1String("NewWirelessMode");
    paramValues << ssid << response.value(QLatin1String("NewRegion")).toString() << response.value(QLatin1String("NewChannel")).toString() << response.value(QLatin1String("NewWirelessMode")).toString();

    QString actionName;
    if (m_password.isNull())
    {
        actionName = QLatin1String("SetWLANNoSecurity");
    }
    else
    {
        actionName = QLatin1String("SetWLANWPAPSKByPassphrase");
        paramNames << QLatin1String("NewWPAEncryptionModes") << QLatin1String("NewWPAPassphrase");
        paramValues << QLatin1String("WPA2-PSK") << m_password;
    }
    m_bean->m_soapCore->setWrappedMode(false);
    m_op = m_bean->m_soapCore->invoke(NS_WLANConfiguration, actionName, paramNames, paramValues);
    connect(m_op, SIGNAL(finished()), SLOT(onSetWLANFinished()));
}
Example #20
0
void DiscoverRouterSoapOp::process()
{
    QStringList ls1;
    QList<QVariantMap> ls2;
    for (int i = 0; i < m_opList.count(); i++)
    {
        AsyncOp *op = m_opList.at(i);
        if (op->isFinished() && op->result() == NoError)
        {
            ls1.append(m_ls.at(i));
            ls2.append(op->values());
        }
    }

    if (ls1.isEmpty())
    {
        LOG_DEBUG(QString::fromUtf8("No router found!"));
        notifyFinished(UnknownError);
        return;
    }

    QSet<QString> set1;
    int count = ls1.count();
    int i = 0;
    while (i < count)
    {
        const QVariantMap& varMap = ls2.at(i);
        QString mac = varMap.value(QLatin1String("newwlanmacaddress")).toString().toUpper();
        if (set1.find(mac) == set1.end())
        {
            set1.insert(mac);
            i++;
        }
        else
        {
            ls1.removeAt(i);
            ls2.removeAt(i);
            count--;
        }
    }

    int matchIndex = -1;
    QVariantList fullList;
    LOG_DEBUG(QString::fromUtf8("found %1 router(s)").arg(ls1.count()));
    for (int i = 0; i < ls1.count(); i++)
    {
        QString hostName = ls1.at(i);
        QVariantMap varMap = ls2.at(i);
        varMap.insert(QLatin1String("soapHostName"), hostName);
        QString mac = varMap.value(QLatin1String("newwlanmacaddress")).toString().toUpper();
        fullList.push_back(varMap);
        m_mac = mac;
        //if (!m_mac.isNull() && mac.compare(m_mac, Qt::CaseInsensitive) == 0) {
        matchIndex = i;
        //}
        LOG_DEBUG(QString::fromUtf8("%1 [%2]").arg(hostName).arg(mac));
    }

    setValue("fullList", fullList);
    setValue("matchIndex", matchIndex);
    notifyFinished(NoError);
}
Example #21
0
void ChangeRouterPasswordOp::onGetLanInfoFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (isAborted())
    {
        return;
    }

    int result = op->result();
    if (result != NoError)
    {
        return notifyFinished(result);
    }

    QVariant varResponseCode = op->value("responseCode");
    if (!varResponseCode.isValid())
    {
        return notifyFinished(UnknownError);
    }

    bool ok;
    int responseCode = varResponseCode.toInt(&ok);
    if (!ok)
    {
        return notifyFinished(UnknownError);
    }

    if (responseCode != 0)
    {
        return notifyFinished(UnknownError);
    }

    QVariant varResponse = op->value("response");
    if (!varResponse.isValid())
    {
        return notifyFinished(UnknownError);
    }

    QVariantMap resp = qvariant_cast<QVariantMap>(varResponse);

    /*	if (!m_wifiPassword.isNull()) {
    		if (m_currentWifiKey != m_oldWifiPassword) {
    			return notifyFinished(InvalidWifiPasswordError);
    		}
    	}
    */
    if (!m_adminPassword.isNull())
    {
        QString oldAdminPassword = resp.value(QLatin1String("NewPassword")).toString();
        if (oldAdminPassword != m_oldAdminPassword)
        {
            return notifyFinished(InvalidAdminPasswordError);
        }
    }

    m_bean->m_soapCore->setWrappedMode(false);
    m_op = m_bean->m_soapCore->invoke(QLatin1String("DeviceConfig"), QLatin1String("ConfigurationStarted"), QStringList(QLatin1String("NewSessionID")), QStringList(m_bean->m_soapCore->sessionId()));
    LOG_DEBUG(QString::fromUtf8("ConfigurationStarted ssid: %1").arg(m_bean->m_soapCore->sessionId()));
    connect(m_op, SIGNAL(finished()), SLOT(onConfigInFinished()));
}