File indexing completed on 2024-06-16 04:52:27
0001 /* 0002 Copyright (c) 2009 Grégory Oestreicher <greg@kamago.net> 0003 0004 This program is free software; you can redistribute it and/or modify 0005 it under the terms of the GNU General Public License as published by 0006 the Free Software Foundation; either version 2 of the License, or 0007 (at your option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 GNU General Public License for more details. 0013 0014 You should have received a copy of the GNU General Public License 0015 along with this program; if not, write to the Free Software 0016 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #ifndef KDAV2_DAVCOLLECTION_H 0020 #define KDAV2_DAVCOLLECTION_H 0021 0022 #include "kpimkdav2_export.h" 0023 0024 #include "enums.h" 0025 0026 #include <memory> 0027 0028 #include <QtCore/QVector> 0029 #include <QtCore/QString> 0030 0031 class QColor; 0032 0033 class DavCollectionPrivate; 0034 0035 namespace KDAV2 0036 { 0037 class DavUrl; 0038 } 0039 0040 namespace KDAV2 0041 { 0042 0043 /** 0044 * @short A helper class to store information about DAV collection. 0045 * 0046 * This class is used as container to transfer information about DAV 0047 * collections between the Akonadi resource and the DAV jobs. 0048 */ 0049 class KPIMKDAV2_EXPORT DavCollection 0050 { 0051 public: 0052 /** 0053 * Defines a list of DAV collection objects. 0054 */ 0055 typedef QVector<DavCollection> List; 0056 0057 /** 0058 * Describes the possible content type of the DAV collection. 0059 */ 0060 enum ContentType { 0061 Events = 1, ///< The collection can contain event DAV resources. 0062 Todos = 2, ///< The collection can contain todo DAV resources. 0063 Contacts = 4, ///< The collection can contain contact DAV resources. 0064 FreeBusy = 8, ///< The collection can contain free/busy information. 0065 Journal = 16, ///< The collection can contain journal DAV resources. 0066 Calendar = 32 ///< The collection can contain anything calendar-related. 0067 }; 0068 Q_DECLARE_FLAGS(ContentTypes, ContentType) 0069 0070 /** 0071 * Creates an empty DAV collection. 0072 */ 0073 DavCollection(); 0074 0075 /** 0076 * Creates a new DAV collection. 0077 * 0078 * @param url The url that identifies the collection. 0079 * @param displayName The display name of the collection. 0080 * @param contentTypes The possible content types of the collection. 0081 */ 0082 DavCollection(const DavUrl &url, const QString &displayName, ContentTypes contentTypes); 0083 0084 DavCollection(const DavCollection &other); 0085 DavCollection &operator=(const DavCollection &other); 0086 0087 ~DavCollection(); 0088 0089 /** 0090 * Sets this collection CTag. 0091 */ 0092 void setCTag(const QString &ctag); 0093 0094 /** 0095 * Returns this collection CTag. The returned value will be empty 0096 * if no CTag was found. 0097 */ 0098 QString CTag() const; 0099 0100 /** 0101 * Sets the @p url that identifies the collection. 0102 */ 0103 void setUrl(const DavUrl &url); 0104 0105 /** 0106 * Returns the url that identifies the collection. 0107 */ 0108 DavUrl url() const; 0109 0110 /** 0111 * Sets the display @p name of the collection. 0112 */ 0113 void setDisplayName(const QString &name); 0114 0115 /** 0116 * Returns the display name of the collection. 0117 */ 0118 QString displayName() const; 0119 0120 /** 0121 * Sets the color for this collection 0122 */ 0123 void setColor(const QColor &color); 0124 0125 /** 0126 * Return the color of the collection, or an empty string if 0127 * none was provided by the backend. 0128 */ 0129 QColor color() const; 0130 0131 /** 0132 * Sets the possible content @p types of the collection. 0133 */ 0134 void setContentTypes(ContentTypes types); 0135 0136 /** 0137 * Returns the possible content types of the collection. 0138 */ 0139 ContentTypes contentTypes() const; 0140 0141 /** 0142 * Sets the privileges on this collection. 0143 */ 0144 void setPrivileges(Privileges privs); 0145 0146 /** 0147 * Returns the privileges on this collection. 0148 */ 0149 Privileges privileges() const; 0150 0151 private: 0152 std::unique_ptr<DavCollectionPrivate> d; 0153 }; 0154 0155 } 0156 0157 Q_DECLARE_OPERATORS_FOR_FLAGS(KDAV2::DavCollection::ContentTypes) 0158 Q_DECLARE_TYPEINFO(KDAV2::DavCollection, Q_MOVABLE_TYPE); 0159 0160 #endif