File indexing completed on 2024-04-28 03:53:54

0001 /*
0002     SPDX-FileCopyrightText: 2009 Grégory Oestreicher <greg@kamago.net>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KDAV_DAVCOLLECTION_H
0008 #define KDAV_DAVCOLLECTION_H
0009 
0010 #include "kdav_export.h"
0011 
0012 #include "enums.h"
0013 
0014 #include <QList>
0015 #include <QSharedDataPointer>
0016 #include <QString>
0017 
0018 class QColor;
0019 
0020 class DavCollectionPrivate;
0021 
0022 namespace KDAV
0023 {
0024 class DavUrl;
0025 }
0026 
0027 namespace KDAV
0028 {
0029 /**
0030  * @class DavCollection davcollection.h <KDAV/DavCollection>
0031  *
0032  * @short A helper class to store information about DAV collection.
0033  *
0034  * This class is used as container to transfer information about DAV
0035  * collections between the Akonadi resource and the DAV jobs.
0036  */
0037 class KDAV_EXPORT DavCollection
0038 {
0039 public:
0040     /**
0041      * Defines a list of DAV collection objects.
0042      */
0043     typedef QList<DavCollection> List;
0044 
0045     /**
0046      * Describes the possible content type of the DAV collection.
0047      */
0048     enum ContentType {
0049         Events = 1, ///< The collection can contain event DAV resources.
0050         Todos = 2, ///< The collection can contain todo DAV resources.
0051         Contacts = 4, ///< The collection can contain contact DAV resources.
0052         FreeBusy = 8, ///< The collection can contain free/busy information.
0053         Journal = 16, ///< The collection can contain journal DAV resources.
0054         Calendar = 32, ///< The collection can contain anything calendar-related.
0055     };
0056     Q_DECLARE_FLAGS(ContentTypes, ContentType)
0057 
0058     /**
0059      * Creates an empty DAV collection.
0060      */
0061     DavCollection();
0062 
0063     /**
0064      * Creates a new DAV collection.
0065      *
0066      * @param url The URL that identifies the collection.
0067      * @param displayName The display name of the collection.
0068      * @param contentTypes The possible content types of the collection.
0069      */
0070     DavCollection(const DavUrl &url, const QString &displayName, ContentTypes contentTypes);
0071 
0072     DavCollection(const DavCollection &other);
0073     DavCollection(DavCollection &&);
0074     DavCollection &operator=(const DavCollection &other);
0075     DavCollection &operator=(DavCollection &&);
0076 
0077     ~DavCollection();
0078 
0079     /**
0080      * Sets this collection CTag.
0081      * @see https://github.com/apple/ccs-calendarserver/blob/master/doc/Extensions/caldav-ctag.txt
0082      */
0083     void setCTag(const QString &ctag);
0084 
0085     /**
0086      * Returns this collection CTag. The returned value will be empty
0087      * if no CTag was found.
0088      * @see https://github.com/apple/ccs-calendarserver/blob/master/doc/Extensions/caldav-ctag.txt
0089      */
0090     Q_REQUIRED_RESULT QString CTag() const;
0091 
0092     /**
0093      * Sets the @p url that identifies the collection.
0094      */
0095     void setUrl(const DavUrl &url);
0096 
0097     /**
0098      * Returns the URL that identifies the collection.
0099      */
0100     Q_REQUIRED_RESULT DavUrl url() const;
0101 
0102     /**
0103      * Sets the display @p name of the collection.
0104      */
0105     void setDisplayName(const QString &name);
0106 
0107     /**
0108      * Returns the display name of the collection.
0109      */
0110     Q_REQUIRED_RESULT QString displayName() const;
0111 
0112     /**
0113      * Sets the color for this collection
0114      */
0115     void setColor(const QColor &color);
0116 
0117     /**
0118      * Return the color of the collection, or an empty string if
0119      * none was provided by the backend.
0120      */
0121     Q_REQUIRED_RESULT QColor color() const;
0122 
0123     /**
0124      * Sets the possible content @p types of the collection.
0125      */
0126     void setContentTypes(ContentTypes types);
0127 
0128     /**
0129      * Returns the possible content types of the collection.
0130      */
0131     Q_REQUIRED_RESULT ContentTypes contentTypes() const;
0132 
0133     /**
0134      * Sets the privileges on this collection.
0135      */
0136     void setPrivileges(Privileges privs);
0137 
0138     /**
0139      * Returns the privileges on this collection.
0140      */
0141     Q_REQUIRED_RESULT Privileges privileges() const;
0142 
0143 private:
0144     QSharedDataPointer<DavCollectionPrivate> d;
0145 };
0146 
0147 Q_DECLARE_OPERATORS_FOR_FLAGS(DavCollection::ContentTypes)
0148 
0149 }
0150 
0151 Q_DECLARE_TYPEINFO(KDAV::DavCollection, Q_RELOCATABLE_TYPE);
0152 
0153 #endif