示例#1
0
文件: shotgun.cpp 项目: mjmvisser/pug
void Shotgun::setApiKey(const QString key)
{
    if (m_config.apiKey != key) {
        m_config.apiKey = key;
        emit apiKeyChanged(m_config.apiKey);
    }
}
示例#2
0
void HueBridgeConnection::setApiKey(const QString &apiKey)
{
    if (m_apiKey != apiKey) {
        m_apiKey = apiKey;
        m_baseApiUrl = "http://" + m_bridge.toString() + "/api/" + m_apiKey + "/";
        emit apiKeyChanged();
    }
}
示例#3
0
void Request::setApiKey(const QString &key) {
    Q_D(Request);
    
    if (key != d->apiKey) {
        d->apiKey = key;
        emit apiKeyChanged();
    }
#ifdef QYOUTUBE_DEBUG
    qDebug() << "QYouTube::Request::setApiKey" << key;
#endif
}
示例#4
0
void HueBridgeConnection::createUserFinished()
{
    QNetworkReply *reply = static_cast<QNetworkReply*>(sender());
    reply->deleteLater();

    QByteArray response = reply->readAll();
    qDebug() << "create user finished" << response;

#if QT_VERSION >= 0x050000
    QJsonParseError error;
    QJsonDocument jsonDoc = QJsonDocument::fromJson(response, &error);

    if (error.error != QJsonParseError::NoError) {
        qWarning() << "createUserFinished: cannot parse response:" << error.errorString() << response;
        return;
    }
    QVariant rsp = jsonDoc.toVariant();
#else
    QJson::Parser parser;
    bool ok;
    QVariant rsp = parser.parse(response, &ok);
    if(!ok) {
        qWarning() << "createUserFinished: cannot parse response:" << response;
        return;
    }
#endif

    QVariantMap map = rsp.toList().first().toMap();
    if (map.contains("error")) {
        QString errorMessage = map.value("error").toMap().value("description").toString();
        qWarning() << "error creating user" << errorMessage;
        emit createUserFailed(errorMessage);
        return;
    }

    if (!map.contains("success")) {
        qWarning() << "Huh? Neither error nor success contained in response...";
        return;
    }

    m_apiKey = map.value("success").toMap().value("username").toString();
    emit apiKeyChanged();

    m_baseApiUrl = "http://" + m_bridge.toString() + "/api/" + m_apiKey + "/";
    emit connectedBridgeChanged();
}
示例#5
0
void KeyStore::setApiKey(const QString &apiKey)
{
    m_settings.setValue("apiKey", apiKey);
    emit apiKeyChanged();
}