diff options
author | Daniel Molkentin <danimo@owncloud.com> | 2015-06-29 19:45:55 +0300 |
---|---|---|
committer | Daniel Molkentin <danimo@owncloud.com> | 2015-06-29 19:45:55 +0300 |
commit | eff4daa00bef2f031c4db4d6470d15c315927f41 (patch) | |
tree | 7303628cb293b5eaddf71ea76bacef4f7f29a542 /src/gui/quotainfo.h | |
parent | 0735aa1fbda46a46f5de41ecf2d8ce2f319ece17 (diff) | |
parent | 076f8ea1058315ab96397ab578034a8af412354a (diff) |
Merge remote-tracking branch 'origin/master' into doxygenify
Conflicts:
src/gui/quotainfo.h
Diffstat (limited to 'src/gui/quotainfo.h')
-rw-r--r-- | src/gui/quotainfo.h | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/src/gui/quotainfo.h b/src/gui/quotainfo.h index bb1912857..286bfca6e 100644 --- a/src/gui/quotainfo.h +++ b/src/gui/quotainfo.h @@ -17,31 +17,52 @@ #include <QObject> #include <QPointer> #include <QVariant> - -class QTimer; +#include <QTimer> +#include <QDateTime> namespace OCC { - class AccountState; +class PropfindJob; /*! - * \brief The QuotaInfo class + * \brief handles getting the quota to display in the UI + * + * It is typically owned by the AccountSetting page. + * + * The quota is requested if those 3 conditions are met: + * - This object is active via setActive() (typically if the settings page is visible.) + * - The account is connected. + * - Every 30 seconds (defaultIntervalT) or 5 seconds in case of failure (failIntervalT) + * + * We only request the quota when the UI is visible otherwise this might slow down the server with + * too many requests. But we still need to do it every 30 seconds otherwise user complains that the + * quota is not updated fast enough when changed on the server. + * + * If the quota job is not finished within 30 seconds, it is cancelled and another one is started + * * \ingroup gui */ class QuotaInfo : public QObject { Q_OBJECT public: - QuotaInfo(AccountState *account); + explicit QuotaInfo(OCC::AccountState* accountState, QObject* parent = 0); qint64 lastQuotaTotalBytes() const { return _lastQuotaTotalBytes; } qint64 lastQuotaUsedBytes() const { return _lastQuotaUsedBytes; } + /** + * When the quotainfo is active, it requests the quota at regular interval. + * When setting it to active it will request the quota imediatly if the last time + * the quota was requested was more than the interval + */ + void setActive(bool active); + public Q_SLOTS: void slotCheckQuota(); private Q_SLOTS: void slotUpdateLastQuota(const QVariantMap &); - void slotAccountStateChanged(int state); + void slotAccountStateChanged(); void slotRequestFailed(); Q_SIGNALS: @@ -53,7 +74,10 @@ private: QPointer<AccountState> _accountState; qint64 _lastQuotaTotalBytes; qint64 _lastQuotaUsedBytes; - QTimer *_jobRestartTimer; + 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 }; |