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

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