| 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_DAVITEM_H |
| 8 | #define KDAV_DAVITEM_H |
| 9 | |
| 10 | #include "kdav_export.h" |
| 11 | |
| 12 | #include <QByteArray> |
| 13 | #include <QDataStream> |
| 14 | #include <QList> |
| 15 | #include <QSharedDataPointer> |
| 16 | #include <QString> |
| 17 | |
| 18 | class DavItemPrivate; |
| 19 | |
| 20 | namespace KDAV |
| 21 | { |
| 22 | class DavUrl; |
| 23 | } |
| 24 | |
| 25 | namespace KDAV |
| 26 | { |
| 27 | /*! |
| 28 | * \class KDAV::DavItem |
| 29 | * \inheaderfile KDAV/DavItem |
| 30 | * \inmodule KDAV |
| 31 | * |
| 32 | * \brief A helper class to store information about DAV resources. |
| 33 | * |
| 34 | * This class is used as container to transfer information about DAV |
| 35 | * resources between the Akonadi resource and the DAV jobs. |
| 36 | * |
| 37 | * \note While the DAV RFC names them DAV resource we call them items |
| 38 | * to comply to Akonadi terminology. |
| 39 | */ |
| 40 | class KDAV_EXPORT DavItem |
| 41 | { |
| 42 | public: |
| 43 | /*! |
| 44 | * Defines a list of DAV item objects. |
| 45 | */ |
| 46 | typedef QList<DavItem> List; |
| 47 | |
| 48 | /*! |
| 49 | * Creates an empty DAV item. |
| 50 | */ |
| 51 | DavItem(); |
| 52 | |
| 53 | /*! |
| 54 | * Creates a new DAV item. |
| 55 | * |
| 56 | * \a url The URL that identifies the item. |
| 57 | * |
| 58 | * \a contentType The content type of the item. |
| 59 | * |
| 60 | * \a data The actual raw content data of the item. |
| 61 | * |
| 62 | * \a etag The ETag of the item. |
| 63 | */ |
| 64 | DavItem(const DavUrl &url, const QString &contentType, const QByteArray &data, const QString &etag); |
| 65 | |
| 66 | DavItem(const DavItem &other); |
| 67 | DavItem(DavItem &&); |
| 68 | DavItem &operator=(const DavItem &other); |
| 69 | DavItem &operator=(DavItem &&); |
| 70 | |
| 71 | ~DavItem(); |
| 72 | |
| 73 | /*! |
| 74 | * Sets the \a url that identifies the item. |
| 75 | */ |
| 76 | void setUrl(const DavUrl &url); |
| 77 | |
| 78 | /*! |
| 79 | * Returns the URL that identifies the item. |
| 80 | */ |
| 81 | Q_REQUIRED_RESULT DavUrl url() const; |
| 82 | |
| 83 | /*! |
| 84 | * Sets the content \a type of the item. |
| 85 | */ |
| 86 | void setContentType(const QString &type); |
| 87 | |
| 88 | /*! |
| 89 | * Returns the content type of the item. |
| 90 | */ |
| 91 | Q_REQUIRED_RESULT QString contentType() const; |
| 92 | |
| 93 | /*! |
| 94 | * Sets the raw content \a data of the item. |
| 95 | */ |
| 96 | void setData(const QByteArray &data); |
| 97 | |
| 98 | /*! |
| 99 | * Returns the raw content data of the item. |
| 100 | */ |
| 101 | Q_REQUIRED_RESULT QByteArray data() const; |
| 102 | |
| 103 | /*! |
| 104 | * Sets the \a etag of the item. |
| 105 | * \sa https://tools.ietf.org/html/rfc4918#section-8.6 |
| 106 | */ |
| 107 | void setEtag(const QString &etag); |
| 108 | |
| 109 | /*! |
| 110 | * Returns the ETag of the item. |
| 111 | * \sa https://tools.ietf.org/html/rfc4918#section-8.6 |
| 112 | */ |
| 113 | Q_REQUIRED_RESULT QString etag() const; |
| 114 | |
| 115 | private: |
| 116 | QSharedDataPointer<DavItemPrivate> d; |
| 117 | }; |
| 118 | |
| 119 | KDAV_EXPORT QDataStream &operator<<(QDataStream &out, const DavItem &item); |
| 120 | KDAV_EXPORT QDataStream &operator>>(QDataStream &in, DavItem &item); |
| 121 | } |
| 122 | |
| 123 | Q_DECLARE_TYPEINFO(KDAV::DavItem, Q_RELOCATABLE_TYPE); |
| 124 | |
| 125 | #endif |
| 126 | |