[Pkg-owncloud-commits] [owncloud-client] 177/470: Quota: Change quota path if single folder #4460

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu May 12 16:25:00 UTC 2016


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 ff4cdc3161ddbb74a0fe10f969043ff898fbb93a
Author: Christian Kamm <mail at ckamm.de>
Date:   Thu Mar 17 15:33:37 2016 +0100

    Quota: Change quota path if single folder #4460
    
    Since the quota is a per-folder value, this will make the displayed data
    more useful when a single sync folder is configured.
    
    Of course each subfolder could have a different quota again.
---
 src/gui/quotainfo.cpp | 21 ++++++++++++++++++++-
 src/gui/quotainfo.h   |  3 +++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/gui/quotainfo.cpp b/src/gui/quotainfo.cpp
index 02d5dfd..ba124de 100644
--- a/src/gui/quotainfo.cpp
+++ b/src/gui/quotainfo.cpp
@@ -15,6 +15,7 @@
 #include "account.h"
 #include "accountstate.h"
 #include "networkjobs.h"
+#include "folderman.h"
 #include "creds/abstractcredentials.h"
 
 #include <QTimer>
@@ -79,6 +80,24 @@ bool QuotaInfo::canGetQuota() const
         && account->credentials()->ready();
 }
 
+QString QuotaInfo::quotaBaseFolder() const
+{
+    // If there's exactly one folder, use its remote path.
+    // Otherwise use /
+    bool foundOne = false;
+    QString path = "/";
+    for (const auto & folder : FolderMan::instance()->map()) {
+        if (folder->accountState() == _accountState) {
+            if (foundOne)
+                return "/";
+            foundOne = true;
+            path = folder->remotePath();
+        }
+    }
+
+    return path;
+}
+
 void QuotaInfo::slotCheckQuota()
 {
     if (! canGetQuota()) {
@@ -91,7 +110,7 @@ void QuotaInfo::slotCheckQuota()
     }
 
     AccountPtr account = _accountState->account();
-    _job = new PropfindJob(account, "/", this);
+    _job = new PropfindJob(account, quotaBaseFolder(), 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()));
diff --git a/src/gui/quotainfo.h b/src/gui/quotainfo.h
index b9ada1a..480fe78 100644
--- a/src/gui/quotainfo.h
+++ b/src/gui/quotainfo.h
@@ -71,6 +71,9 @@ Q_SIGNALS:
 private:
     bool canGetQuota() const;
 
+    /// Returns the folder that quota shall be retrieved for
+    QString quotaBaseFolder() const;
+
     QPointer<AccountState> _accountState;
     qint64 _lastQuotaTotalBytes;
     qint64 _lastQuotaUsedBytes;

-- 
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