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_DAVCOLLECTION_H
8#define KDAV_DAVCOLLECTION_H
9
10#include "kdav_export.h"
11
12#include "enums.h"
13
14#include <QList>
15#include <QSharedDataPointer>
16#include <QString>
17
18class QColor;
19
20class DavCollectionPrivate;
21
22namespace KDAV
23{
24class DavUrl;
25}
26
27namespace KDAV
28{
29/*!
30 * \class KDAV::DavCollection
31 * \inheaderfile KDAV/DavCollection
32 * \inmodule KDAV
33 *
34 * \brief A helper class to store information about DAV collection.
35 *
36 * This class is used as container to transfer information about DAV
37 * collections between the Akonadi resource and the DAV jobs.
38 */
39class KDAV_EXPORT DavCollection
40{
41public:
42 /*!
43 * Defines a list of DAV collection objects.
44 */
45 typedef QList<DavCollection> List;
46
47 /*!
48 * Describes the possible content type of the DAV collection.
49 *
50 * \value Events The collection can contain event DAV resources.
51 * \value Todos The collection can contain todo DAV resources.
52 * \value Contacts The collection can contain contact DAV resources.
53 * \value FreeBusy The collection can contain free/busy information.
54 * \value Journal The collection can contain journal DAV resources.
55 * \value Calendar The collection can contain anything calendar-related.
56 */
57 enum ContentType {
58 Events = 1,
59 Todos = 2,
60 Contacts = 4,
61 FreeBusy = 8,
62 Journal = 16,
63 Calendar = 32,
64 };
65 Q_DECLARE_FLAGS(ContentTypes, ContentType)
66
67 /*!
68 * Creates an empty DAV collection.
69 */
70 DavCollection();
71
72 /*!
73 * Creates a new DAV collection.
74 *
75 * \a url The URL that identifies the collection.
76 *
77 * \a displayName The display name of the collection.
78 *
79 * \a contentTypes The possible content types of the collection.
80 */
81 DavCollection(const DavUrl &url, const QString &displayName, ContentTypes contentTypes);
82
83 DavCollection(const DavCollection &other);
84 DavCollection(DavCollection &&);
85 DavCollection &operator=(const DavCollection &other);
86 DavCollection &operator=(DavCollection &&);
87
88 ~DavCollection();
89
90 /*!
91 * Sets this collection CTag.
92 * \sa https://github.com/apple/ccs-calendarserver/blob/master/doc/Extensions/caldav-ctag.txt
93 */
94 void setCTag(const QString &ctag);
95
96 /*!
97 * Returns this collection CTag. The returned value will be empty
98 * if no CTag was found.
99 * \sa https://github.com/apple/ccs-calendarserver/blob/master/doc/Extensions/caldav-ctag.txt
100 */
101 Q_REQUIRED_RESULT QString CTag() const;
102
103 /*!
104 * Sets the \a url that identifies the collection.
105 */
106 void setUrl(const DavUrl &url);
107
108 /*!
109 * Returns the URL that identifies the collection.
110 */
111 Q_REQUIRED_RESULT DavUrl url() const;
112
113 /*!
114 * Sets the display \a name of the collection.
115 */
116 void setDisplayName(const QString &name);
117
118 /*!
119 * Returns the display name of the collection.
120 */
121 Q_REQUIRED_RESULT QString displayName() const;
122
123 /*!
124 * Sets the color for this collection
125 */
126 void setColor(const QColor &color);
127
128 /*!
129 * Return the color of the collection, or an empty string if
130 * none was provided by the backend.
131 */
132 Q_REQUIRED_RESULT QColor color() const;
133
134 /*!
135 * Sets the possible content \a types of the collection.
136 */
137 void setContentTypes(ContentTypes types);
138
139 /*!
140 * Returns the possible content types of the collection.
141 */
142 Q_REQUIRED_RESULT ContentTypes contentTypes() const;
143
144 /*!
145 * Sets the privileges on this collection.
146 */
147 void setPrivileges(Privileges privs);
148
149 /*!
150 * Returns the privileges on this collection.
151 */
152 Q_REQUIRED_RESULT Privileges privileges() const;
153
154private:
155 QSharedDataPointer<DavCollectionPrivate> d;
156};
157
158Q_DECLARE_OPERATORS_FOR_FLAGS(DavCollection::ContentTypes)
159
160}
161
162Q_DECLARE_TYPEINFO(KDAV::DavCollection, Q_RELOCATABLE_TYPE);
163
164#endif
165

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