QuotaInfo: allow only one job at the same time

This commit is contained in:
Olivier Goffart 2015-06-26 16:58:34 +02:00
parent e7d7646151
commit 236951d9b3
2 changed files with 12 additions and 5 deletions

View file

@ -85,12 +85,17 @@ void QuotaInfo::slotCheckQuota()
return;
}
if (_job) {
// The previous job was not finished? Then we cancel it!
_job->deleteLater();
}
AccountPtr account = _accountState->account();
PropfindJob *job = new PropfindJob(account, "/", this);
job->setProperties(QList<QByteArray>() << "quota-available-bytes" << "quota-used-bytes");
connect(job, SIGNAL(result(QVariantMap)), SLOT(slotUpdateLastQuota(QVariantMap)));
connect(job, SIGNAL(networkError(QNetworkReply*)), SLOT(slotRequestFailed()));
job->start();
_job = new PropfindJob(account, "/", this);
_job->setProperties(QList<QByteArray>() << "quota-available-bytes" << "quota-used-bytes");
connect(_job, SIGNAL(result(QVariantMap)), SLOT(slotUpdateLastQuota(QVariantMap)));
connect(_job, SIGNAL(networkError(QNetworkReply*)), SLOT(slotRequestFailed()));
_job->start();
}
void QuotaInfo::slotUpdateLastQuota(const QVariantMap &result)

View file

@ -22,6 +22,7 @@
namespace OCC {
class AccountState;
class PropfindJob;
/**
* This class handle the getting the quota to display in the UI
@ -71,6 +72,7 @@ private:
QTimer _jobRestartTimer;
QDateTime _lastQuotaRecieved; // the time at which de quota was recieved last
bool _active; // if we should check at regular interval (when the UI is visible)
QPointer<PropfindJob> _job; // the currently running job
};