mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Fix the background check job for the connection
We can't use the quota job for that as it needs the credidentials and therefore
may re-enter the credidential code when we are currently trying to fetch the credentials.
The quotainfo.cpp part of this patch is basically a revert of d836b80153
This commit is contained in:
parent
4731b506e5
commit
b08284e4cc
3 changed files with 23 additions and 13 deletions
|
@ -139,6 +139,10 @@ Application::Application(int &argc, char **argv) :
|
|||
this, SLOT(slotAccountChanged(Account*,Account*)));
|
||||
|
||||
// startup procedure.
|
||||
connect(&_checkConnectionTimer, SIGNAL(timeout()), this, SLOT(slotCheckConnection()));
|
||||
_checkConnectionTimer.setInterval(32 * 1000); // check for connection every 32 seconds.
|
||||
_checkConnectionTimer.start();
|
||||
// Also check immediatly
|
||||
QTimer::singleShot( 0, this, SLOT( slotCheckConnection() ));
|
||||
|
||||
if( cfg.skipUpdateCheck() ) {
|
||||
|
@ -270,6 +274,8 @@ void Application::slotToggleFolderman(int state)
|
|||
folderMan->slotScheduleAllFolders();
|
||||
break;
|
||||
case Account::Disconnected:
|
||||
_checkConnectionTimer.start();
|
||||
// fall through
|
||||
case Account::SignedOut:
|
||||
case Account::InvalidCredidential:
|
||||
folderMan->setSyncEnabled(false);
|
||||
|
@ -290,6 +296,7 @@ void Application::slotConnectionValidatorResult(ConnectionValidator::Status stat
|
|||
folderMan->setSyncEnabled(true);
|
||||
// queue up the sync for all folders.
|
||||
folderMan->slotScheduleAllFolders();
|
||||
_checkConnectionTimer.stop();
|
||||
} else {
|
||||
// if we have problems here, it's unlikely that syncing will work.
|
||||
FolderMan::instance()->setSyncEnabled(false);
|
||||
|
@ -299,7 +306,6 @@ void Application::slotConnectionValidatorResult(ConnectionValidator::Status stat
|
|||
if (_userTriggeredConnect) {
|
||||
_userTriggeredConnect = false;
|
||||
}
|
||||
QTimer::singleShot(30*1000, this, SLOT(slotCheckConnection()));
|
||||
}
|
||||
_gui->startupConnected( (status == ConnectionValidator::Connected), startupFails);
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <QApplication>
|
||||
#include <QPointer>
|
||||
#include <QQueue>
|
||||
#include <QTimer>
|
||||
|
||||
#include "qtsingleapplication.h"
|
||||
|
||||
|
@ -103,6 +104,8 @@ private:
|
|||
|
||||
ClientProxy _proxy;
|
||||
|
||||
QTimer _checkConnectionTimer;
|
||||
|
||||
friend class ownCloudGui; // for _startupNetworkError
|
||||
};
|
||||
|
||||
|
|
|
@ -52,27 +52,17 @@ void QuotaInfo::slotAccountStateChanged(int state)
|
|||
switch (state) {
|
||||
case Account::SignedOut: // fall through
|
||||
case Account::InvalidCredidential:
|
||||
case Account::Disconnected:
|
||||
_jobRestartTimer->stop();
|
||||
break;
|
||||
case Account::Disconnected:
|
||||
case Account::Connected: // fall through
|
||||
slotCheckQuota();
|
||||
}
|
||||
}
|
||||
|
||||
void QuotaInfo::slotCheckQuota()
|
||||
{
|
||||
if (!_account.isNull() && _account->credentials()) {
|
||||
CheckQuotaJob *job = new CheckQuotaJob(_account, "/", this);
|
||||
connect(job, SIGNAL(quotaRetrieved(qint64,qint64)), SLOT(slotUpdateLastQuota(qint64,qint64)));
|
||||
connect(job, SIGNAL(networkError(QNetworkReply*)), SLOT(slotRequestFailed()));
|
||||
job->start();
|
||||
}
|
||||
}
|
||||
|
||||
void QuotaInfo::slotRequestFailed()
|
||||
{
|
||||
if (!_account.isNull() && _account->state() != Account::Disconnected) {
|
||||
if (!_account.isNull() && _account->state() == Account::Connected) {
|
||||
_account->setState(Account::Disconnected);
|
||||
}
|
||||
|
||||
|
@ -81,6 +71,17 @@ void QuotaInfo::slotRequestFailed()
|
|||
_jobRestartTimer->start(failIntervalT);
|
||||
}
|
||||
|
||||
void QuotaInfo::slotCheckQuota()
|
||||
{
|
||||
if (!_account.isNull() && _account->state() == Account::Connected
|
||||
&& _account->credentials() && _account->credentials()->ready()) {
|
||||
CheckQuotaJob *job = new CheckQuotaJob(_account, "/", this);
|
||||
connect(job, SIGNAL(quotaRetrieved(qint64,qint64)), SLOT(slotUpdateLastQuota(qint64,qint64)));
|
||||
connect(job, SIGNAL(networkError(QNetworkReply*)), SLOT(slotRequestFailed()));
|
||||
job->start();
|
||||
}
|
||||
}
|
||||
|
||||
void QuotaInfo::slotUpdateLastQuota(qint64 total, qint64 used)
|
||||
{
|
||||
if(_account->state() == Account::Disconnected) {
|
||||
|
|
Loading…
Reference in a new issue