void VkAccount::OpenConfigurationDialog () { auto dia = new AccountConfigDialog; AccConfigDia_ = dia; dia->SetFileLogEnabled (EnableFileLog_); dia->SetPublishTuneEnabled (PublishTune_); dia->SetMarkAsOnline (MarkAsOnline_); dia->SetUpdateStatusEnabled (UpdateStatus_); connect (dia, SIGNAL (reauthRequested ()), Conn_, SLOT (reauth ())); connect (dia, SIGNAL (rejected ()), dia, SLOT (deleteLater ())); connect (dia, SIGNAL (accepted ()), this, SLOT (handleConfigDialogAccepted ())); dia->show (); }
void VkAuthManager::handleGotForm () { auto reply = qobject_cast<QNetworkReply*> (sender ()); reply->deleteLater (); if (reply->error () != QNetworkReply::NoError) { qWarning () << Q_FUNC_INFO << reply->error () << reply->errorString (); IsRequesting_ = false; if (!IsRequestScheduled_) { IsRequestScheduled_ = true; ScheduleTimer_->start (30000); } return; } const auto& location = reply->header (QNetworkRequest::LocationHeader).toUrl (); if (location.isEmpty ()) { reauth (); return; } if (CheckReply (location)) return; RequestURL (location); }
StreamWatch::StreamWatch(QtSpeech*& speech, QWidget *parent) :QWidget(parent) ,speech(speech) { streamLine = new QLineEdit(this); textEdit = new QTextEdit(this); shutUpBox = new QCheckBox(this); textEdit->setReadOnly(true); shutUpBox->setText("Shut up"); streamLine->setText("runnerguy2489"); QVBoxLayout *lay = new QVBoxLayout(this); lay->addWidget(streamLine); lay->addWidget(textEdit); lay->addWidget(shutUpBox); nam = new QNetworkAccessManager(this); QTimer *reauthTimer = new QTimer(this); reauthTimer->setInterval(30000); reauthTimer->setSingleShot(false); reauthTimer->start(); retryTimer = new QTimer(this); retryTimer->setInterval(30000); retryTimer->setSingleShot(true); connect(reauthTimer, SIGNAL(timeout()), this, SLOT(reauth())); connect(retryTimer, SIGNAL(timeout()), this, SLOT(reauth())); haveToken = false; wasDown = false; connect(streamLine, SIGNAL(returnPressed()), this, SLOT(reauth())); connect(nam, &QNetworkAccessManager::finished, [](QNetworkReply *repl) { repl->deleteLater(); }); reauth(); }
SingleAccAuth::SingleAccAuth (const QUrl& url, const QString& login, ICoreProxy_ptr proxy, QObject *parent) : QObject { parent } , Proxy_ { proxy } , BaseURL_ { url } , Login_ { login } { LoadQueue (); reauth (); }
void SingleAccAuth::handleHSFinished () { const auto reply = qobject_cast<QNetworkReply*> (sender ()); reply->deleteLater (); const auto& data = QString::fromLatin1 (reply->readAll ()); auto split = data.split ('\n', QString::SkipEmptyParts); for (auto& part : split) part = part.trimmed (); const auto& status = split.value (0); if (status == "OK") { SID_ = split.value (1); NowPlayingUrl_ = QUrl::fromEncoded (split.value (2).toLatin1 ()); SubmissionsUrl_ = QUrl::fromEncoded (split.value (3).toLatin1 ()); if (!Queue_.isEmpty ()) QTimer::singleShot (0, this, SLOT (rotateSubmitQueue ())); return; } if (status == "BADTIME") { const auto& e = Util::MakeNotification ("Scroblibre", tr ("Your system clock is too incorrect."), PCritical_); Proxy_->GetEntityManager ()->HandleEntity (e); } else if (status.startsWith ("FAILED")) { const auto& e = Util::MakeNotification ("Scroblibre", tr ("Temporary server failure for %1, please try again later.") .arg (UrlToService (BaseURL_)), PCritical_); Proxy_->GetEntityManager ()->HandleEntity (e); } else if (status == "BANNED") { const auto& e = Util::MakeNotification ("Scroblibre", tr ("Sorry, the client is banned on %1.") .arg (UrlToService (BaseURL_)), PCritical_); Proxy_->GetEntityManager ()->HandleEntity (e); } else if (status == "BADAUTH") { const auto& e = Util::MakeNotification ("Scroblibre", tr ("Invalid authentication on %1.") .arg (UrlToService (BaseURL_)), PCritical_); Proxy_->GetEntityManager ()->HandleEntity (e); reauth (true); return; } else { const auto& e = Util::MakeNotification ("Scroblibre", tr ("General server error for %1.") .arg (UrlToService (BaseURL_)), PCritical_); Proxy_->GetEntityManager ()->HandleEntity (e); } if (ReauthScheduled_) return; QTimer::singleShot (120 * 1000, this, SLOT (reauth ())); ReauthScheduled_ = true; }
void EvernoteSession::sync(){ if(syncInProgress){ return; } syncInProgress = true; syncCancelled = false; try{ for(int i=0;i<5;i++){ try{ recreateUserStoreClient(false); recreateSyncClient(false); qDebug() << "EvernoteSession :: start sync..."; int cacheUsn = DatabaseManager::instance()->getIntSetting(SettingsKeys::SERVER_USN); qDebug() << "EvernoteSession :: saved USN: " << cacheUsn; SyncChunk chunk; int percent = 0; while(true){ syncStarted(percent); syncClient->getSyncChunk(chunk, Settings::instance()->getAuthToken().toStdString(), cacheUsn, 1024, false); if(cacheUsn >= chunk.updateCount){ break; } percent = (int)((double)(100* (double)cacheUsn/(double)chunk.updateCount)); syncStarted(percent); std::vector <Tag> tags = chunk.tags; if(!tags.empty()){ tagsSyncStarted(); DatabaseManager::instance()->beginTransacton(); for(int i=0;i<tags.size();i++){ if(syncCancelled){ syncCancelled = false; syncInProgress = false; syncFinished(); return; } Tag tag = tags.at(i); DatabaseManager::instance()->saveTag(tag); qDebug() << "EvernoteSession :: tag " << tag.name.c_str(); } DatabaseManager::instance()->commitTransaction(); } syncStarted(percent); if(syncCancelled){ syncCancelled = false; syncInProgress = false; syncFinished(); return; } std::vector <Notebook> notebooks = chunk.notebooks; qDebug() << "EvernoteSession :: notebooks " << chunk.notebooks.size(); if(!notebooks.empty()){ notebooksSyncStarted(); DatabaseManager::instance()->beginTransacton(); for(int i=0;i<notebooks.size();i++){ if(syncCancelled){ syncCancelled = false; syncInProgress = false; syncFinished(); return; } Notebook notebook = notebooks.at(i); DatabaseManager::instance()->saveNotebook(notebook); qDebug() << "EvernoteSession :: notebook " << notebook.name.c_str(); } DatabaseManager::instance()->commitTransaction(); } syncStarted(percent); if(syncCancelled){ syncCancelled = false; syncInProgress = false; syncFinished(); return; } std::vector <Note> notes = chunk.notes; qDebug() << "EvernoteSession :: notes " << chunk.notes.size(); if(!notes.empty()){ DatabaseManager::instance()->beginTransacton(); for(int i=0;i<notes.size();i++){ if(syncCancelled){ syncCancelled = false; syncInProgress = false; syncFinished(); return; } Note note = notes.at(i); if(note.deleted){ DatabaseManager::instance()->deleteNote(note); }else{ DatabaseManager::instance()->saveNote(note); } qDebug() << "EvernoteSession :: note " << note.title.c_str(); } DatabaseManager::instance()->commitTransaction(); } syncStarted(percent); std::vector <SavedSearch> searches = chunk.searches; qDebug() << "EvernoteSession :: searches " << chunk.searches.size(); if(!searches.empty()) { DatabaseManager::instance()->beginTransacton(); for(int i=0; i < searches.size(); i++) { SavedSearch search = searches.at(i); DatabaseManager::instance()->saveSavedSearch(search); qDebug() << "EvernoteSession :: search " << search.name.c_str(); } DatabaseManager::instance()->commitTransaction(); } syncStarted(percent); qDebug() << "expunged notes: " << chunk.expungedNotes.size(); cacheUsn = chunk.chunkHighUSN; DatabaseManager::instance()->beginTransacton(); DatabaseManager::instance()->makeIntSetting(SettingsKeys::SERVER_USN, cacheUsn); DatabaseManager::instance()->commitTransaction(); if(cacheUsn >= chunk.updateCount){ break; } qDebug() << "Current usn: " << cacheUsn << " high usn: " << chunk.chunkHighUSN << ", update count: " << chunk.updateCount; } qDebug() << "EvernoteSession :: sync finished"; break; }catch(EDAMSystemException &e){ qDebug() << "EvernoteSession :: Edam SYSTEM EXCEPTION " << e.what() << " " << e.errorCode; if(e.errorCode == 9){ reauth(); } } } }catch(TException &tx){ qDebug() << "EvernoteSession :: excetion while sync: " << tx.what(); syncFailed("Network error"); } syncInProgress = false; syncFinished(); Cache::instance()->load(); }