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

source code of kdav/src/common/davprotocolbase_p.h