File indexing completed on 2024-05-26 05:17:01
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_DAVPROTOCOLBASE_H 0020 #define KDAV2_DAVPROTOCOLBASE_H 0021 0022 #include "kpimkdav2_export.h" 0023 0024 #include "davcollection.h" 0025 0026 #include <QtCore/QList> 0027 #include <QtCore/QMap> 0028 #include <QtXml/QDomDocument> 0029 #include <QSharedPointer> 0030 #include <QVariant> 0031 0032 namespace KDAV2 0033 { 0034 0035 /** 0036 * @short Base class for XML query builders 0037 */ 0038 class KPIMKDAV2_EXPORT XMLQueryBuilder 0039 { 0040 public: 0041 typedef QSharedPointer<XMLQueryBuilder> Ptr; 0042 0043 virtual ~XMLQueryBuilder(); 0044 0045 virtual QDomDocument buildQuery() const = 0; 0046 virtual QString mimeType() const = 0; 0047 0048 void setParameter(const QString &key, const QVariant &value); 0049 QVariant parameter(const QString &key) const; 0050 0051 private: 0052 QMap<QString, QVariant> mParameters; 0053 }; 0054 0055 /** 0056 * @short Base class for various DAV groupware dialects. 0057 * 0058 * This class provides an interface to query the DAV dialect 0059 * specific features and abstract them. 0060 * 0061 * The functionality is implemented in: 0062 * @li CaldavProtocol 0063 * @li CarddavProtocol 0064 * @li GroupdavProtocol 0065 */ 0066 class KPIMKDAV2_EXPORT DavProtocolBase 0067 { 0068 public: 0069 /** 0070 * Destroys the dav protocol base. 0071 */ 0072 virtual ~DavProtocolBase(); 0073 0074 /** 0075 * Returns whether the dav protocol dialect supports principal 0076 * queries. If true, it must return the home set it provides 0077 * access to with principalHomeSet() and the home set namespace 0078 * with principalHomeSetNS(); 0079 */ 0080 virtual bool supportsPrincipals() const = 0; 0081 0082 /** 0083 * Return whether the dav protocol dialect supports CTags. 0084 * 0085 * If true, it must fetch them in the collectionsQuery(). 0086 */ 0087 virtual bool supportsCTags() const = 0; 0088 0089 /** 0090 * Returns whether the dav protocol dialect supports the REPORT 0091 * command to query all resources of a collection. 0092 * If not, PROPFIND command will be used instead. 0093 */ 0094 virtual bool useReport() const = 0; 0095 0096 /** 0097 * Returns whether the dav protocol dialect supports the MULTIGET command. 0098 * 0099 * If MULTIGET is supported, the content of all dav resources 0100 * can be fetched in ResourceBase::retrieveItems() already and 0101 * there is no need to call ResourceBase::retrieveItem() for every single 0102 * dav resource. 0103 * 0104 * Protocols that have MULTIGET capabilities must inherit from 0105 * DavMultigetProtocol instead of this class. 0106 */ 0107 virtual bool useMultiget() const = 0; 0108 0109 /** 0110 * Returns the home set that this protocol supports. 0111 */ 0112 virtual QString principalHomeSet() const; 0113 0114 /** 0115 * Returns the namespace of the home set. 0116 */ 0117 virtual QString principalHomeSetNS() const; 0118 0119 /** 0120 * Returns the XML document that represents the DAV query to 0121 * list all available DAV collections. 0122 */ 0123 virtual XMLQueryBuilder::Ptr collectionsQuery() const = 0; 0124 0125 /** 0126 * Returns the XQuery string that filters out the relevant XML elements 0127 * from the result returned by the query that is provided by collectionQuery(). 0128 */ 0129 virtual QString collectionsXQuery() const = 0; 0130 0131 /** 0132 * Returns a list of XML documents that represent DAV queries to 0133 * list all available DAV resources inside a specific DAV collection. 0134 */ 0135 virtual QVector<XMLQueryBuilder::Ptr> itemsQueries() const = 0; 0136 0137 /** 0138 * Returns the possible content types for the collection that 0139 * is described by the passed @p propstat element of a PROPFIND result. 0140 */ 0141 virtual DavCollection::ContentTypes collectionContentTypes(const QDomElement &propstat) const = 0; 0142 }; 0143 0144 } 0145 0146 #endif