diff --git a/src/gui/folderwizard.cpp b/src/gui/folderwizard.cpp index 4b2fb74fc..c1a583f55 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() << "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() << "resourcetype"); connect(job, SIGNAL(directoryListingSubfolders(QStringList)), SLOT(slotUpdateDirectories(QStringList))); job->start(); diff --git a/src/gui/selectivesyncdialog.cpp b/src/gui/selectivesyncdialog.cpp index eda087c59..70348472b 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() << "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 3f34596e3..91b5bb5c1 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() << "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)), this, SLOT(directoryListingIteratedSlot(QString,QMap))); QObject::connect(lsColJob, SIGNAL(finishedWithError(QNetworkReply*)), this, SLOT(lsJobFinishedWithErrorSlot(QNetworkReply*))); diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index c8bab2c92..e592fb72e 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 properties) +{ + _properties = properties; +} + +QList LsColJob::properties() const +{ + return _properties; +} + void LsColJob::start() { + QList 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 += " \n"; + } else { + propStr += " <" + prop.mid(colIdx+1) + " xmlns=\"" + ns + "\" />\n"; + } + } else { + propStr += " \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("\n" "\n" " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" + + propStr + " \n" "\n"); QBuffer *buf = new QBuffer(this); diff --git a/src/libsync/networkjobs.h b/src/libsync/networkjobs.h index 73ee08b6d..d50f673be 100644 --- a/src/libsync/networkjobs.h +++ b/src/libsync/networkjobs.h @@ -136,20 +136,37 @@ public: void start() Q_DECL_OVERRIDE; QHash _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 properties); + QList properties() const; + signals: void directoryListingSubfolders(const QStringList &items); - void directoryListingIterated(const QString name, QMap properties); + void directoryListingIterated(const QString &name, const QMap &properties); void finishedWithError(QNetworkReply *reply); void finishedWithoutError(); private slots: virtual bool finished() Q_DECL_OVERRIDE; + +private: + QList _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