File indexing completed on 2024-04-21 03:53:52

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_DAVITEM_H
0008 #define KDAV_DAVITEM_H
0009 
0010 #include "kdav_export.h"
0011 
0012 #include <QByteArray>
0013 #include <QDataStream>
0014 #include <QList>
0015 #include <QSharedDataPointer>
0016 #include <QString>
0017 
0018 class DavItemPrivate;
0019 
0020 namespace KDAV
0021 {
0022 class DavUrl;
0023 }
0024 
0025 namespace KDAV
0026 {
0027 /**
0028  * @class DavItem davitem.h <KDAV/DavItem>
0029  *
0030  * @short A helper class to store information about DAV resources.
0031  *
0032  * This class is used as container to transfer information about DAV
0033  * resources between the Akonadi resource and the DAV jobs.
0034  *
0035  * @note While the DAV RFC names them DAV resource we call them items
0036  *       to comply to Akonadi terminology.
0037  */
0038 class KDAV_EXPORT DavItem
0039 {
0040 public:
0041     /**
0042      * Defines a list of DAV item objects.
0043      */
0044     typedef QList<DavItem> List;
0045 
0046     /**
0047      * Creates an empty DAV item.
0048      */
0049     DavItem();
0050 
0051     /**
0052      * Creates a new DAV item.
0053      *
0054      * @param url The URL that identifies the item.
0055      * @param contentType The content type of the item.
0056      * @param data The actual raw content data of the item.
0057      * @param etag The ETag of the item.
0058      */
0059     DavItem(const DavUrl &url, const QString &contentType, const QByteArray &data, const QString &etag);
0060 
0061     DavItem(const DavItem &other);
0062     DavItem(DavItem &&);
0063     DavItem &operator=(const DavItem &other);
0064     DavItem &operator=(DavItem &&);
0065 
0066     ~DavItem();
0067 
0068     /**
0069      * Sets the @p url that identifies the item.
0070      */
0071     void setUrl(const DavUrl &url);
0072 
0073     /**
0074      * Returns the URL that identifies the item.
0075      */
0076     Q_REQUIRED_RESULT DavUrl url() const;
0077 
0078     /**
0079      * Sets the content @p type of the item.
0080      */
0081     void setContentType(const QString &type);
0082 
0083     /**
0084      * Returns the content type of the item.
0085      */
0086     Q_REQUIRED_RESULT QString contentType() const;
0087 
0088     /**
0089      * Sets the raw content @p data of the item.
0090      */
0091     void setData(const QByteArray &data);
0092 
0093     /**
0094      * Returns the raw content data of the item.
0095      */
0096     Q_REQUIRED_RESULT QByteArray data() const;
0097 
0098     /**
0099      * Sets the @p etag of the item.
0100      * @see https://tools.ietf.org/html/rfc4918#section-8.6
0101      */
0102     void setEtag(const QString &etag);
0103 
0104     /**
0105      * Returns the ETag of the item.
0106      * @see https://tools.ietf.org/html/rfc4918#section-8.6
0107      */
0108     Q_REQUIRED_RESULT QString etag() const;
0109 
0110 private:
0111     QSharedDataPointer<DavItemPrivate> d;
0112 };
0113 
0114 KDAV_EXPORT QDataStream &operator<<(QDataStream &out, const DavItem &item);
0115 KDAV_EXPORT QDataStream &operator>>(QDataStream &in, DavItem &item);
0116 }
0117 
0118 Q_DECLARE_TYPEINFO(KDAV::DavItem, Q_RELOCATABLE_TYPE);
0119 
0120 #endif