void LoginManager::onLoginReply(QNetworkReply* reply, int code, const QJsonObject& obj) { if (code == HTTP_OK) { _accessToken = obj["token"].toString(); _refreshToken = obj["refresh_token"].toString(); if (!_accessToken.isEmpty()) emit loginSuccess(); else emit loginError(tr("Wrong response from the server")); } else emit loginError(getErrorString(reply, obj)); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), localServer(0) { QPixmapCache::setCacheLimit(200000); client = new RemoteClient; connect(client, SIGNAL(connectionClosedEventReceived(const Event_ConnectionClosed &)), this, SLOT(processConnectionClosedEvent(const Event_ConnectionClosed &))); connect(client, SIGNAL(serverShutdownEventReceived(const Event_ServerShutdown &)), this, SLOT(processServerShutdownEvent(const Event_ServerShutdown &))); connect(client, SIGNAL(loginError(Response::ResponseCode, QString, quint32)), this, SLOT(loginError(Response::ResponseCode, QString, quint32))); connect(client, SIGNAL(socketError(const QString &)), this, SLOT(socketError(const QString &))); connect(client, SIGNAL(serverTimeout()), this, SLOT(serverTimeout())); connect(client, SIGNAL(statusChanged(ClientStatus)), this, SLOT(statusChanged(ClientStatus))); connect(client, SIGNAL(protocolVersionMismatch(int, int)), this, SLOT(protocolVersionMismatch(int, int))); connect(client, SIGNAL(userInfoChanged(const ServerInfo_User &)), this, SLOT(userInfoReceived(const ServerInfo_User &)), Qt::BlockingQueuedConnection); clientThread = new QThread(this); client->moveToThread(clientThread); clientThread->start(); createActions(); createMenus(); tabSupervisor = new TabSupervisor(client); connect(tabSupervisor, SIGNAL(setMenu(QList<QMenu *>)), this, SLOT(updateTabMenu(QList<QMenu *>))); connect(tabSupervisor, SIGNAL(localGameEnded()), this, SLOT(localGameEnded())); tabSupervisor->addDeckEditorTab(0); setCentralWidget(tabSupervisor); retranslateUi(); resize(900, 700); restoreGeometry(settingsCache->getMainWindowGeometry()); aFullScreen->setChecked(windowState() & Qt::WindowFullScreen); }
void LoginManager::onAccessTokenRequestReady(QByteArray ba) { //qDebug() << "onAccessTokenRequestReady" << ba; if (_oauthManager->lastError() == KQOAuthManager::RequestUnauthorized) { // 401/406 QJsonDocument jsonResponse = QJsonDocument::fromJson(ba); QJsonArray array = jsonResponse.array(); QString message = tr("Unsuccessful login. Please try again."); if (array.size() > 0) { QJsonObject o = array.at(0).toObject(); if (o.value("code") != QJsonValue::Undefined) { QString code = o["code"].toString(); if (code == "USER_AUTHENTICATION_FAILED") { message = tr("Sorry, wrong email address, username or password. Please check again. <a href=\"%1\">Have you forgotten your password</a>?").arg("https://musescore.com/user/password"); } else if (code == "USER_DENIED") { message = tr("This account has been blocked."); } else if (code == "USER_NOT_ACTIVATED") { message = tr("Your account has not been activated yet. Please check your mailbox to activate your account or <a href=\"%1\">request a new activation email</a>.").arg("https://musescore.com/user/resendregistrationpassword"); } else if (code == "USER_TIMESTAMP_EXPIRED") { message = tr("The local time on your device is not set right. Please check it and adjust. It's advised to set the time/timezone to automatic. If you still can't log in, <a href=\"%1\">contact us</a>.").arg("https://musescore.com/contact?category=Login%20problems"); } } } emit loginError(message); } else if (_oauthManager->lastError() == KQOAuthManager::NetworkError) { QMessageBox::critical(0, tr("Network error"), tr("Please check your Internet connection")); } else if (_oauthManager->lastError() == KQOAuthManager::ContentOperationNotPermittedError) { QMessageBox::critical(0, tr("Please upgrade"), tr("Your MuseScore version is too old to use this feature.<br/> <a href=\"%1\">Please upgrade first</a>.").arg("http://musescore.org")); } }
void EvernoteSync::startSyncThreaded() { m_storageManager->log("EvernoteSync::startSyncThreaded()"); EvernoteSyncThread *enSyncThread = new EvernoteSyncThread(m_evernoteAccess, this); connect(enSyncThread, SIGNAL(finished()), SLOT(threadFinished())); connect(enSyncThread, SIGNAL(syncFinished(bool,QString)), SIGNAL(syncFinished(bool,QString))); connect(enSyncThread, SIGNAL(loginError(QString)), SIGNAL(loginError(QString))); connect(enSyncThread, SIGNAL(firstChunkDone()), SIGNAL(firstChunkDone())); connect(enSyncThread, SIGNAL(syncProgressChanged(int)), SLOT(updateSyncProgress(int))); connect(enSyncThread, SIGNAL(syncStatusMessage(QString)), SLOT(updateSyncStatusMessage(QString))); connect(enSyncThread, SIGNAL(fullSyncDoneChanged()), SIGNAL(fullSyncDoneChanged())); connect(enSyncThread, SIGNAL(authTokenInvalid()), SIGNAL(authTokenInvalid())); connect(enSyncThread, SIGNAL(rateLimitReached(int)), SLOT(rateLimitReached(int))); updateSyncStatusMessage("Starting sync"); enSyncThread->start(QThread::LowPriority); emit syncStarted(); }
void EvernoteSyncThread::run() { #ifndef QT_SIMULATOR connect(m_evernoteAccess, SIGNAL(finished(bool,QString)), SIGNAL(syncFinished(bool,QString))); connect(m_evernoteAccess, SIGNAL(loginError(QString)), SIGNAL(loginError(QString))); connect(m_evernoteAccess, SIGNAL(firstChunkDone()), SIGNAL(firstChunkDone())); connect(m_evernoteAccess, SIGNAL(syncProgressChanged(int)), SIGNAL(syncProgressChanged(int))); connect(m_evernoteAccess, SIGNAL(syncStatusMessage(QString)), SIGNAL(syncStatusMessage(QString))); connect(m_evernoteAccess, SIGNAL(fullSyncDoneChanged()), SIGNAL(fullSyncDoneChanged())); connect(m_evernoteAccess, SIGNAL(authTokenInvalid()), SIGNAL(authTokenInvalid())); connect(m_evernoteAccess, SIGNAL(rateLimitReached(int)), SIGNAL(rateLimitReached(int))); m_evernoteAccess->synchronize(); m_evernoteAccess->disconnect(this); #else emit syncProgressChanged(100); emit syncFinished(true, QLatin1String("Dummy sync")); #endif }
DVRServer::DVRServer(int id, QObject *parent) : QObject(parent), m_configuration(id), m_devicesLoaded(false) { m_api = new ServerRequestManager(this); connect(&m_configuration, SIGNAL(changed()), this, SIGNAL(changed())); connect(m_api, SIGNAL(loginSuccessful()), SLOT(updateCameras())); connect(m_api, SIGNAL(disconnected()), SLOT(disconnectedSlot())); connect(m_api, SIGNAL(loginRequestStarted()), this, SIGNAL(loginRequestStarted())); connect(m_api, SIGNAL(loginSuccessful()), this, SIGNAL(loginSuccessful())); connect(m_api, SIGNAL(serverError(QString)), this, SIGNAL(serverError(QString))); connect(m_api, SIGNAL(loginError(QString)), this, SIGNAL(loginError(QString))); connect(m_api, SIGNAL(disconnected()), this, SIGNAL(disconnected())); connect(m_api, SIGNAL(statusChanged(int)), this, SIGNAL(statusChanged(int))); connect(m_api, SIGNAL(onlineChanged(bool)), this, SIGNAL(onlineChanged(bool))); connect(&m_refreshTimer, SIGNAL(timeout()), SLOT(updateCameras())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), localServer(0), bHasActivated(false), cardUpdateProcess(0) { connect(settingsCache, SIGNAL(pixmapCacheSizeChanged(int)), this, SLOT(pixmapCacheSizeChanged(int))); pixmapCacheSizeChanged(settingsCache->getPixmapCacheSize()); client = new RemoteClient; connect(client, SIGNAL(connectionClosedEventReceived(const Event_ConnectionClosed &)), this, SLOT(processConnectionClosedEvent(const Event_ConnectionClosed &))); connect(client, SIGNAL(serverShutdownEventReceived(const Event_ServerShutdown &)), this, SLOT(processServerShutdownEvent(const Event_ServerShutdown &))); connect(client, SIGNAL(loginError(Response::ResponseCode, QString, quint32)), this, SLOT(loginError(Response::ResponseCode, QString, quint32))); connect(client, SIGNAL(socketError(const QString &)), this, SLOT(socketError(const QString &))); connect(client, SIGNAL(serverTimeout()), this, SLOT(serverTimeout())); connect(client, SIGNAL(statusChanged(ClientStatus)), this, SLOT(statusChanged(ClientStatus))); connect(client, SIGNAL(protocolVersionMismatch(int, int)), this, SLOT(protocolVersionMismatch(int, int))); connect(client, SIGNAL(userInfoChanged(const ServerInfo_User &)), this, SLOT(userInfoReceived(const ServerInfo_User &)), Qt::BlockingQueuedConnection); connect(client, SIGNAL(registerAccepted()), this, SLOT(registerAccepted())); connect(client, SIGNAL(registerAcceptedNeedsActivate()), this, SLOT(registerAcceptedNeedsActivate())); connect(client, SIGNAL(registerError(Response::ResponseCode, QString, quint32)), this, SLOT(registerError(Response::ResponseCode, QString, quint32))); connect(client, SIGNAL(activateAccepted()), this, SLOT(activateAccepted())); connect(client, SIGNAL(activateError()), this, SLOT(activateError())); clientThread = new QThread(this); client->moveToThread(clientThread); clientThread->start(); createActions(); createMenus(); tabSupervisor = new TabSupervisor(client); connect(tabSupervisor, SIGNAL(setMenu(QList<QMenu *>)), this, SLOT(updateTabMenu(QList<QMenu *>))); connect(tabSupervisor, SIGNAL(localGameEnded()), this, SLOT(localGameEnded())); connect(tabSupervisor, SIGNAL(maximize()), this, SLOT(maximize())); tabSupervisor->addDeckEditorTab(0); setCentralWidget(tabSupervisor); retranslateUi(); resize(900, 700); restoreGeometry(settingsCache->getMainWindowGeometry()); aFullScreen->setChecked(windowState() & Qt::WindowFullScreen); if (QSystemTrayIcon::isSystemTrayAvailable()) { createTrayActions(); createTrayIcon(); } connect(&settingsCache->shortcuts(), SIGNAL(shortCutchanged()),this,SLOT(refreshShortcuts())); refreshShortcuts(); }
void OptionsServerPage::currentServerChanged(const QModelIndex &newIndex, const QModelIndex &oldIndex) { DVRServer *server = oldIndex.data(DVRServersModel::DVRServerRole).value<DVRServer *>(); if (server) { saveChanges(server); server->disconnect(this); m_connectionStatus->setVisible(false); } server = newIndex.data(DVRServersModel::DVRServerRole).value<DVRServer *>(); if (!server) { m_nameEdit->clear(); m_hostnameEdit->clear(); m_portEdit->clear(); m_usernameEdit->clear(); m_passwordEdit->clear(); m_connectionType->setCurrentIndex(DVRServerConnectionType::RTSP); return; } m_nameEdit->setText(server->configuration().displayName()); m_hostnameEdit->setText(server->configuration().hostname()); m_portEdit->setText(QString::number(server->serverPort())); m_usernameEdit->setText(server->configuration().username()); m_passwordEdit->setText(server->configuration().password()); m_autoConnect->setChecked(server->configuration().autoConnect()); m_connectionType->setCurrentIndex(server->configuration().connectionType()); connect(server, SIGNAL(loginSuccessful()), SLOT(setLoginSuccessful())); connect(server, SIGNAL(loginError(QString)), SLOT(setLoginError(QString))); connect(server, SIGNAL(loginRequestStarted()), SLOT(setLoginConnecting())); checkServer(); if (server->isOnline()) setLoginSuccessful(); else if (server->isLoginPending()) setLoginConnecting(); else if (!server->errorMessage().isEmpty()) setLoginError(server->errorMessage()); }
void RemoteClient::loginResponse(const Response &response) { const Response_Login &resp = response.GetExtension(Response_Login::ext); if (response.response_code() == Response::RespOk) { setStatus(StatusLoggedIn); emit userInfoChanged(resp.user_info()); QList<ServerInfo_User> buddyList; for (int i = resp.buddy_list_size() - 1; i >= 0; --i) buddyList.append(resp.buddy_list(i)); emit buddyListReceived(buddyList); QList<ServerInfo_User> ignoreList; for (int i = resp.ignore_list_size() - 1; i >= 0; --i) ignoreList.append(resp.ignore_list(i)); emit ignoreListReceived(ignoreList); } else { emit loginError(response.response_code(), QString::fromStdString(resp.denied_reason_str()), resp.denied_end_time()); setStatus(StatusDisconnecting); } }
bool facebook_client::login(const char *username, const char *password) { handle_entry("login"); username_ = username; password_ = password; if (cookies.empty()) { // Set device ID ptrA device( parent->getStringA(FACEBOOK_KEY_DEVICE_ID)); if (device != NULL) cookies["datr"] = device; // Get initial cookies flap(REQUEST_HOME); } // Prepare login data std::string data = "persistent=1"; data += "&email=" + utils::url::encode(username); data += "&pass="******"&locale=" + std::string(locale); // Send validation http::response resp = flap(REQUEST_LOGIN, &data); // Save Device ID if (!cookies["datr"].empty()) parent->setString(FACEBOOK_KEY_DEVICE_ID, cookies["datr"].c_str()); if (resp.code == HTTP_CODE_FOUND && resp.headers.find("Location") != resp.headers.end()) { // Check for invalid requests if (resp.headers["Location"].find("invalid_request.php") != std::string::npos) { client_notify(TranslateT("Login error: Invalid request.")); parent->debugLogA(" ! ! Login error: Invalid request."); return handle_error("login", FORCE_QUIT); } // Check whether some Facebook things are required if (resp.headers["Location"].find("help.php") != std::string::npos) { client_notify(TranslateT("Login error: Some Facebook things are required.")); parent->debugLogA(" ! ! Login error: Some Facebook things are required."); // return handle_error("login", FORCE_QUIT); } // Check whether setting Machine name is required if (resp.headers["Location"].find("/checkpoint/") != std::string::npos) { resp = flap(REQUEST_SETUP_MACHINE, NULL, NULL, REQUEST_GET); if (resp.data.find("login_approvals_no_phones") != std::string::npos) { // Code approval - but no phones in account loginError(parent, utils::text::source_get_value(&resp.data, 4, "login_approvals_no_phones", "<div", ">", "</div>")); return handle_error("login", FORCE_QUIT); } std::string inner_data; if (resp.data.find("name=\"submit[Continue]\"") != std::string::npos) { // Check if we need to approve also last unapproved device if (resp.data.find("name=\"name_action_selected\"") == std::string::npos) { // 1) Continue inner_data = "submit[Continue]=Continue"; inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); inner_data += "&fb_dtsg=" + utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\""); resp = flap(REQUEST_SETUP_MACHINE, &inner_data); // 2) Approve last unknown login // inner_data = "submit[I%20don't%20recognize]=I%20don't%20recognize"; // Don't recognize - this will force to change account password inner_data = "submit[This%20is%20Okay]=This%20is%20Okay"; // Recognize inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); inner_data += "&fb_dtsg=" + utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\""); resp = flap(REQUEST_SETUP_MACHINE, &inner_data); // 3) Save last device inner_data = "submit[Continue]=Continue"; inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); inner_data += "&fb_dtsg=" + utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\""); inner_data += "&name_action_selected=save_device"; // Save device - or "dont_save" resp = flap(REQUEST_SETUP_MACHINE, &inner_data); } // Save this actual device inner_data = "submit[Continue]=Continue"; inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); inner_data += "&fb_dtsg=" + utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\""); inner_data += "&name_action_selected=save_device"; // Save device - or "dont_save" resp = flap(REQUEST_SETUP_MACHINE, &inner_data); } // Save actual machine name // inner_data = "machine_name=Miranda%20NG&submit[Don't%20Save]=Don't%20Save"; // Don't save inner_data = "machine_name=Miranda%20NG&submit[Save%20Device]=Save%20Device"; // Save inner_data += "&lsd=" + utils::text::source_get_value(&resp.data, 3, "name=\"lsd\"", "value=\"", "\""); inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); inner_data += "&fb_dtsg=" + utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\""); resp = flap(REQUEST_SETUP_MACHINE, &inner_data); } } switch (resp.code) { case HTTP_CODE_FAKE_DISCONNECTED: { // When is error only because timeout, try login once more if (handle_error("login")) return login(username, password); else return handle_error("login", FORCE_QUIT); } case HTTP_CODE_OK: // OK page returned, but that is regular login page we don't want in fact { // Check whether captcha code is required if (resp.data.find("id=\"captcha\"") != std::string::npos) { client_notify(TranslateT("Login error: Captcha code is required. Bad login credentials?")); parent->debugLogA(" ! ! Login error: Captcha code is required."); return handle_error("login", FORCE_QUIT); } // Get and notify error message loginError(parent, utils::text::source_get_value(&resp.data, 4, "login_error_box", "<div", ">", "</div>")); } case HTTP_CODE_FORBIDDEN: // Forbidden case HTTP_CODE_NOT_FOUND: // Not Found default: return handle_error("login", FORCE_QUIT); case HTTP_CODE_FOUND: // Found and redirected to Home, Logged in, everything is OK { if (cookies.find("c_user") != cookies.end()) { this->self_.user_id = cookies.find("c_user")->second; parent->setString(FACEBOOK_KEY_ID, this->self_.user_id.c_str()); parent->debugLogA(" Got self user id: %s", this->self_.user_id.c_str()); return handle_success("login"); } else { client_notify(TranslateT("Login error, probably bad login credentials.")); parent->debugLogA(" ! ! Login error, probably bad login credentials."); return handle_error("login", FORCE_QUIT); } } } }
void FAccount::onLoginError(QString error_id, QString error_message) { debugMessage("account->loginHttps() error!"); emit loginError(this, "Login Error", QString("%1 (%2)").arg(error_message).arg(error_id)); }