[Pkg-owncloud-commits] [owncloud-client] 36/103: Fix the background check job for the connection
Sandro Knauß
hefee-guest at moszumanska.debian.org
Wed Apr 30 18:08:57 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit b08284e4ccf8e134fce9b2b5e86679b06ee90cc5
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Sat Apr 19 09:45:54 2014 +0200
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 d836b8015353c18c733d33b410d36a25c7201acd
---
src/mirall/application.cpp | 8 +++++++-
src/mirall/application.h | 3 +++
src/mirall/quotainfo.cpp | 25 +++++++++++++------------
3 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/src/mirall/application.cpp b/src/mirall/application.cpp
index 5ca1412..aa1ed30 100644
--- a/src/mirall/application.cpp
+++ b/src/mirall/application.cpp
@@ -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);
diff --git a/src/mirall/application.h b/src/mirall/application.h
index 95939e8..2acffbb 100644
--- a/src/mirall/application.h
+++ b/src/mirall/application.h
@@ -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
};
diff --git a/src/mirall/quotainfo.cpp b/src/mirall/quotainfo.cpp
index c1c20b8..71fd29c 100644
--- a/src/mirall/quotainfo.cpp
+++ b/src/mirall/quotainfo.cpp
@@ -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) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list