From: Claudio Cambra Date: Thu, 20 Apr 2023 13:14:57 +0000 (+0800) Subject: Implement support for system tags in propfindjob X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~10^2~49^2~10 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=045541d32301dd6aa69c1967af62254ec401f62b;p=nextcloud-desktop.git Implement support for system tags in propfindjob Signed-off-by: Claudio Cambra fix --- diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index d858d5320..cb6189cad 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -63,6 +63,8 @@ constexpr auto notModifiedStatusCode = 304; constexpr auto propfindPropElementTagName = "prop"; constexpr auto propfindFileTagElementTagName = "tag"; constexpr auto propfindFileTagsContainerElementTagName = "tags"; +constexpr auto propfindSystemFileTagElementTagName = "system-tag"; +constexpr auto propfindSystemFileTagsContainerElementTagName = "system-tags"; RequestEtagJob::RequestEtagJob(AccountPtr account, const QString &path, QObject *parent) : AbstractNetworkJob(account, path, parent) @@ -665,6 +667,9 @@ QVariantMap PropfindJob::processPropfindDomDocument(const QDomDocument &domDocum if (propChildElementTagName == propfindFileTagsContainerElementTagName) { const auto tagList = processTagsInPropfindDomDocument(domDocument); items.insert(propChildElementTagName, tagList); + } else if (propChildElementTagName == propfindSystemFileTagsContainerElementTagName) { + const auto systemTagList = processSystemTagsInPropfindDomDocument(domDocument); + items.insert(propChildElementTagName, systemTagList); } else { items.insert(propChildElementTagName, propChildElement.text()); } @@ -702,6 +707,40 @@ QStringList PropfindJob::processTagsInPropfindDomDocument(const QDomDocument &do return tagList; } +QVariantList PropfindJob::processSystemTagsInPropfindDomDocument(const QDomDocument &domDocument) +{ + const auto systemTagNodes = domDocument.elementsByTagName(propfindSystemFileTagElementTagName); + if (systemTagNodes.isEmpty()) { + return {}; + } + + const auto systemTagCount = systemTagNodes.count(); + auto systemTagsList = QVariantList(); + + for (auto i = 0; i < systemTagCount; ++i) { + const auto systemTagNode = systemTagNodes.at(i); + const auto systemTagElem = systemTagNode.toElement(); + + if (systemTagElem.isNull()) { + continue; + } + + auto systemTagMap = QVariantMap{ { QStringLiteral("tag"), systemTagElem.text() } }; + + const auto systemTagElemAttrs = systemTagElem.attributes(); + for (auto i = 0; i < systemTagElemAttrs.count(); ++i) { + const auto systemTagElemAttrNode = systemTagElemAttrs.item(i); + const auto systemTagElemAttr = systemTagElemAttrNode.toAttr(); + + systemTagMap.insert(systemTagElemAttr.name(), systemTagElemAttr.value()); + } + + systemTagsList.append(systemTagMap); + } + + return systemTagsList; +} + /*********************************************************************************************/ #ifndef TOKEN_AUTH_ONLY diff --git a/src/libsync/networkjobs.h b/src/libsync/networkjobs.h index 11f3c26ac..533217466 100644 --- a/src/libsync/networkjobs.h +++ b/src/libsync/networkjobs.h @@ -201,6 +201,7 @@ private slots: private: static QVariantMap processPropfindDomDocument(const QDomDocument &domDocument); static QStringList processTagsInPropfindDomDocument(const QDomDocument &domDocument); + static QVariantList processSystemTagsInPropfindDomDocument(const QDomDocument &domDocument); QList _properties; };