| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2009 Grégory Oestreicher <greg@kamago.net> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 | */ |
| 6 | |
| 7 | #ifndef KDAV_DAVPROTOCOLBASE_H |
| 8 | #define KDAV_DAVPROTOCOLBASE_H |
| 9 | |
| 10 | #include "kdav_export.h" |
| 11 | |
| 12 | #include "davcollection.h" |
| 13 | |
| 14 | #include <QDomDocument> |
| 15 | #include <QMap> |
| 16 | #include <QVariant> |
| 17 | #include <memory> |
| 18 | |
| 19 | namespace KDAV |
| 20 | { |
| 21 | /*! |
| 22 | * \internal |
| 23 | * \brief Base class for XML query builders |
| 24 | */ |
| 25 | class XMLQueryBuilder |
| 26 | { |
| 27 | public: |
| 28 | typedef std::shared_ptr<XMLQueryBuilder> Ptr; |
| 29 | |
| 30 | virtual ~XMLQueryBuilder(); |
| 31 | |
| 32 | virtual QDomDocument buildQuery() const = 0; |
| 33 | virtual QString mimeType() const = 0; |
| 34 | |
| 35 | void setParameter(const QString &key, const QVariant &value); |
| 36 | QVariant parameter(const QString &key) const; |
| 37 | |
| 38 | private: |
| 39 | QMap<QString, QVariant> mParameters; |
| 40 | }; |
| 41 | |
| 42 | /*! |
| 43 | * \internal |
| 44 | * \brief Base class for various DAV groupware dialects. |
| 45 | * |
| 46 | * This class provides an interface to query the DAV dialect |
| 47 | * specific features and abstract them. |
| 48 | * |
| 49 | * The functionality is implemented in: |
| 50 | * - CaldavProtocol |
| 51 | * - CarddavProtocol |
| 52 | * - GroupdavProtocol |
| 53 | */ |
| 54 | class DavProtocolBase |
| 55 | { |
| 56 | public: |
| 57 | /*! |
| 58 | * Destroys the DAV protocol base. |
| 59 | */ |
| 60 | virtual ~DavProtocolBase(); |
| 61 | |
| 62 | /*! |
| 63 | * Returns whether the DAV protocol dialect supports principal |
| 64 | * queries. If true, it must return the home set it provides |
| 65 | * access to with principalHomeSet() and the home set namespace |
| 66 | * with principalHomeSetNS(); |
| 67 | */ |
| 68 | virtual bool supportsPrincipals() const = 0; |
| 69 | |
| 70 | /*! |
| 71 | * Returns whether the DAV protocol dialect supports the REPORT |
| 72 | * command to query all resources of a collection. |
| 73 | * If not, PROPFIND command will be used instead. |
| 74 | */ |
| 75 | virtual bool useReport() const = 0; |
| 76 | |
| 77 | /*! |
| 78 | * Returns whether the DAV protocol dialect supports the MULTIGET command. |
| 79 | * |
| 80 | * If MULTIGET is supported, the content of all DAV resources |
| 81 | * can be fetched in Akonadi::ResourceBase::retrieveItems() already and |
| 82 | * there is no need to call Akonadi::ResourceBase::retrieveItem() for every single |
| 83 | * DAV resource. |
| 84 | * |
| 85 | * Protocols that have MULTIGET capabilities must inherit from |
| 86 | * DavMultigetProtocol instead of this class. |
| 87 | */ |
| 88 | virtual bool useMultiget() const = 0; |
| 89 | |
| 90 | /*! |
| 91 | * Returns the home set that this protocol supports. |
| 92 | */ |
| 93 | virtual QString principalHomeSet() const; |
| 94 | |
| 95 | /*! |
| 96 | * Returns the namespace of the home set. |
| 97 | */ |
| 98 | virtual QString principalHomeSetNS() const; |
| 99 | |
| 100 | /*! |
| 101 | * Returns the XML document that represents the DAV query to |
| 102 | * list all available DAV collections. |
| 103 | */ |
| 104 | virtual XMLQueryBuilder::Ptr collectionsQuery() const = 0; |
| 105 | |
| 106 | /*! |
| 107 | * Returns @c true if the given <prop> element of a multistatus response contains a |
| 108 | * valid collection for this protocol. |
| 109 | */ |
| 110 | virtual bool containsCollection(const QDomElement &propElem) const = 0; |
| 111 | |
| 112 | /*! |
| 113 | * Returns a list of XML documents that represent DAV queries to |
| 114 | * list all available DAV resources inside a specific DAV collection. |
| 115 | */ |
| 116 | virtual QList<XMLQueryBuilder::Ptr> itemsQueries() const = 0; |
| 117 | |
| 118 | /*! |
| 119 | * Returns the possible content types for the collection that |
| 120 | * is described by the passed @p propstat element of a PROPFIND result. |
| 121 | */ |
| 122 | virtual DavCollection::ContentTypes collectionContentTypes(const QDomElement &propstat) const = 0; |
| 123 | }; |
| 124 | } |
| 125 | |
| 126 | #endif |
| 127 | |