void LoginManager::tryLogin() { disconnect(this, SIGNAL(loginSuccess()), this, SLOT(tryLogin())); connect(this, SIGNAL(getUserSuccess()), this, SLOT(onTryLoginSuccess())); connect(this, SIGNAL(getUserError(QString)), this, SLOT(onTryLoginError(QString))); getUser(); }
void LoginManager::onTryLoginError(const QString& error) { Q_UNUSED(error); disconnect(this, SIGNAL(getUserSuccess()), this, SLOT(onTryLoginSuccess())); disconnect(this, SIGNAL(getUserError(QString)), this, SLOT(onTryLoginError(QString))); connect(this, SIGNAL(loginSuccess()), this, SLOT(tryLogin())); logout(); mscore->showLoginDialog(); }
void LoginManager::onTryLoginError(const QString& error) { Q_UNUSED(error); disconnect(this, SIGNAL(getUserSuccess()), this, SLOT(onTryLoginSuccess())); disconnect(this, SIGNAL(getUserError(QString)), this, SLOT(onTryLoginError(QString))); connect(this, SIGNAL(loginSuccess()), this, SLOT(tryLogin())); logout(); #ifdef USE_WEBENGINE loginInteractive(); #else mscore->showLoginDialog(); #endif }
void LoginManager::onGetUserReply(QNetworkReply* reply, int code, const QJsonObject& user) { // qDebug() << "onGetUserReply" << code << reply->errorString(); if (code == HTTP_OK) { if (user.value("name") != QJsonValue::Undefined) { _userName = user.value("name").toString(); _uid = user.value("id").toString().toInt(); emit getUserSuccess(); } else emit getUserError(tr("Wrong response from the server")); } else emit getUserError(tr("Error while getting user info: %1").arg(getErrorString(reply, user))); }
void LoginManager::onGetUserRequestReady(QByteArray ba) { //qDebug() << "onGetUserRequestReady" << ba; disconnect(_oauthManager, SIGNAL(requestReady(QByteArray)), this, SLOT(onGetUserRequestReady(QByteArray))); if (_oauthManager->lastError() == KQOAuthManager::NoError) { QJsonDocument jsonResponse = QJsonDocument::fromJson(ba); QJsonObject user = jsonResponse.object(); if (user.value("name") != QJsonValue::Undefined) { _userName = user.value("name").toString(); _uid = user.value("id").toString().toInt(); emit getUserSuccess(); } else { emit getUserError(tr("Error while getting user info. Please try again")); } } else if (_oauthManager->lastError() != KQOAuthManager::NetworkError) { emit getUserError(tr("Error while getting user info: %1").arg(_oauthManager->lastError())); } }
void LoginManager::onTryLoginSuccess() { disconnect(this, SIGNAL(getUserSuccess()), this, SLOT(onTryLoginSuccess())); disconnect(this, SIGNAL(getUserError(QString)), this, SLOT(onTryLoginError(QString))); emit tryLoginSuccess(); }