[Pkg-owncloud-commits] [owncloud-client] 81/164: LsColJob: one must now specify the properties

Sandro Knauß hefee-guest at moszumanska.debian.org
Sun Mar 22 11:56:56 UTC 2015


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 bd6769a3fde0d8ceb0369cd5f64c9b546163cddc
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Mon Mar 2 11:00:37 2015 +0100

    LsColJob: one must now specify the properties
    
    So the discovery phase don't ask for the quota, and the selective sync
    don't ask for all the other properties
    
    Issue #2906
---
 src/gui/folderwizard.cpp        |  2 ++
 src/gui/selectivesyncdialog.cpp |  1 +
 src/libsync/discoveryphase.cpp  |  5 +++++
 src/libsync/networkjobs.cpp     | 42 ++++++++++++++++++++++++++++++-----------
 src/libsync/networkjobs.h       | 19 ++++++++++++++++++-
 5 files changed, 57 insertions(+), 12 deletions(-)

diff --git a/src/gui/folderwizard.cpp b/src/gui/folderwizard.cpp
index 4b2fb74..c1a583f 100644
--- a/src/gui/folderwizard.cpp
+++ b/src/gui/folderwizard.cpp
@@ -357,6 +357,7 @@ void FolderWizardRemotePath::slotUpdateDirectories(const QStringList &list)
 void FolderWizardRemotePath::slotRefreshFolders()
 {
     LsColJob *job = new LsColJob(_account, "/", this);
+    job->setProperties(QList<QByteArray>() << "resourcetype");
     connect(job, SIGNAL(directoryListingSubfolders(QStringList)),
             SLOT(slotUpdateDirectories(QStringList)));
     job->start();
@@ -367,6 +368,7 @@ void FolderWizardRemotePath::slotItemExpanded(QTreeWidgetItem *item)
 {
     QString dir = item->data(0, Qt::UserRole).toString();
     LsColJob *job = new LsColJob(_account, dir, this);
+    job->setProperties(QList<QByteArray>() << "resourcetype");
     connect(job, SIGNAL(directoryListingSubfolders(QStringList)),
             SLOT(slotUpdateDirectories(QStringList)));
     job->start();
diff --git a/src/gui/selectivesyncdialog.cpp b/src/gui/selectivesyncdialog.cpp
index eda087c..7034847 100644
--- a/src/gui/selectivesyncdialog.cpp
+++ b/src/gui/selectivesyncdialog.cpp
@@ -56,6 +56,7 @@ QSize SelectiveSyncTreeView::sizeHint() const
 void SelectiveSyncTreeView::refreshFolders()
 {
     LsColJob *job = new LsColJob(_account, _folderPath, this);
+    job->setProperties(QList<QByteArray>() << "resourcetype" << "quota-used-bytes");
     connect(job, SIGNAL(directoryListingSubfolders(QStringList)),
             this, SLOT(slotUpdateDirectories(QStringList)));
     connect(job, SIGNAL(finishedWithError(QNetworkReply*)),
diff --git a/src/libsync/discoveryphase.cpp b/src/libsync/discoveryphase.cpp
index 3f34596..91b5bb5 100644
--- a/src/libsync/discoveryphase.cpp
+++ b/src/libsync/discoveryphase.cpp
@@ -169,6 +169,11 @@ void DiscoverySingleDirectoryJob::start()
 {
     // Start the actual HTTP job
     LsColJob *lsColJob = new LsColJob(_account, _subPath, this);
+    lsColJob->setProperties(QList<QByteArray>() << "resourcetype" << "getlastmodified"
+                        << "getcontentlength" << "getetag" << "http://owncloud.org/ns:id"
+                        << "http://owncloud.org/ns:downloadURL" << "http://owncloud.org/ns:dDC"
+                        << "http://owncloud.org/ns:permissions");
+
     QObject::connect(lsColJob, SIGNAL(directoryListingIterated(QString,QMap<QString,QString>)),
                      this, SLOT(directoryListingIteratedSlot(QString,QMap<QString,QString>)));
     QObject::connect(lsColJob, SIGNAL(finishedWithError(QNetworkReply*)), this, SLOT(lsJobFinishedWithErrorSlot(QNetworkReply*)));
diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp
index c8bab2c..e592fb7 100644
--- a/src/libsync/networkjobs.cpp
+++ b/src/libsync/networkjobs.cpp
@@ -329,24 +329,44 @@ LsColJob::LsColJob(AccountPtr account, const QString &path, QObject *parent)
 {
 }
 
+void LsColJob::setProperties(QList<QByteArray> properties)
+{
+    _properties = properties;
+}
+
+QList<QByteArray> LsColJob::properties() const
+{
+    return _properties;
+}
+
 void LsColJob::start()
 {
+    QList<QByteArray> properties = _properties;
+
+    if (properties.isEmpty()) {
+        qWarning() << "Propfind with no properties!";
+    }
+    QByteArray propStr;
+    foreach (const QByteArray &prop, properties) {
+        if (prop.contains(':')) {
+            int colIdx = prop.lastIndexOf(":");
+            auto ns = prop.left(colIdx);
+            if (ns == "http://owncloud.org/ns") {
+                propStr += "    <oc:" + prop.mid(colIdx+1) + " />\n";
+            } else {
+                propStr += "    <" + prop.mid(colIdx+1) + " xmlns=\"" + ns + "\" />\n";
+            }
+        } else {
+            propStr += "    <d:" + prop + " />\n";
+        }
+    }
+
     QNetworkRequest req;
     req.setRawHeader("Depth", "1");
-    // FIXME The results are delivered without namespace, if this is ever a problem we need to check it..
     QByteArray xml("<?xml version=\"1.0\" ?>\n"
                    "<d:propfind xmlns:d=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\">\n"
                    "  <d:prop>\n"
-                   "    <d:resourcetype/>\n"
-                   "    <d:quota-used-bytes/>\n"
-                   "    <d:getlastmodified/>\n"
-                   "    <d:getcontentlength/>\n"
-                   "    <d:resourcetype/>\n"
-                   "    <d:getetag/>\n"
-                   "    <oc:id/>\n"
-                   "    <oc:downloadURL/>\n"
-                   "    <oc:dDC/>\n"
-                   "    <oc:permissions/>\n"
+                   + propStr +
                    "  </d:prop>\n"
                    "</d:propfind>\n");
     QBuffer *buf = new QBuffer(this);
diff --git a/src/libsync/networkjobs.h b/src/libsync/networkjobs.h
index 73ee08b..d50f673 100644
--- a/src/libsync/networkjobs.h
+++ b/src/libsync/networkjobs.h
@@ -136,20 +136,37 @@ public:
     void start() Q_DECL_OVERRIDE;
     QHash<QString, qint64> _sizes;
 
+    /**
+     * Used to specify which properties shall be retrieved.
+     *
+     * The properties can
+     *  - contain no colon: they refer to a property in the DAV: namespace
+     *  - contain a colon: and thus specify an explicit namespace,
+     *    e.g. "ns:with:colons:bar", which is "bar" in the "ns:with:colons" namespace
+     */
+    void setProperties(QList<QByteArray> properties);
+    QList<QByteArray> properties() const;
+
 signals:
     void directoryListingSubfolders(const QStringList &items);
-    void directoryListingIterated(const QString name, QMap<QString,QString> properties);
+    void directoryListingIterated(const QString &name, const QMap<QString,QString> &properties);
     void finishedWithError(QNetworkReply *reply);
     void finishedWithoutError();
 
 private slots:
     virtual bool finished() Q_DECL_OVERRIDE;
+
+private:
+    QList<QByteArray> _properties;
 };
 
 /**
  * @brief The PropfindJob class
  *
  * Setting the desired properties with setProperties() is mandatory.
+ *
+ * Note that this job is only for querying one item.
+ * There is also the LsColJob which can be used to list collections
  */
 class PropfindJob : public AbstractNetworkJob {
     Q_OBJECT

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