| 1 | /* |
|---|---|
| 2 | SPDX-FileCopyrightText: 2009 Grégory Oestreicher <greg@kamago.net> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 | */ |
| 6 | |
| 7 | #include "davitem.h" |
| 8 | |
| 9 | #include "davurl.h" |
| 10 | |
| 11 | using namespace KDAV; |
| 12 | |
| 13 | class DavItemPrivate : public QSharedData |
| 14 | { |
| 15 | public: |
| 16 | DavUrl mUrl; |
| 17 | QString mContentType; |
| 18 | QByteArray mData; |
| 19 | QString mEtag; |
| 20 | }; |
| 21 | |
| 22 | DavItem::DavItem() |
| 23 | : d(new DavItemPrivate) |
| 24 | { |
| 25 | } |
| 26 | |
| 27 | DavItem::DavItem(const DavUrl &url, const QString &contentType, const QByteArray &data, const QString &etag) |
| 28 | : d(new DavItemPrivate) |
| 29 | { |
| 30 | d->mUrl = url; |
| 31 | d->mContentType = contentType; |
| 32 | d->mData = data; |
| 33 | d->mEtag = etag; |
| 34 | } |
| 35 | |
| 36 | DavItem::DavItem(const DavItem &other) = default; |
| 37 | DavItem::DavItem(DavItem &&) = default; |
| 38 | DavItem &DavItem::operator=(const DavItem &other) = default; |
| 39 | DavItem &DavItem::operator=(DavItem &&) = default; |
| 40 | DavItem::~DavItem() = default; |
| 41 | |
| 42 | void DavItem::setUrl(const DavUrl &url) |
| 43 | { |
| 44 | d->mUrl = url; |
| 45 | } |
| 46 | |
| 47 | DavUrl DavItem::url() const |
| 48 | { |
| 49 | return d->mUrl; |
| 50 | } |
| 51 | |
| 52 | void DavItem::setContentType(const QString &contentType) |
| 53 | { |
| 54 | d->mContentType = contentType; |
| 55 | } |
| 56 | |
| 57 | QString DavItem::contentType() const |
| 58 | { |
| 59 | return d->mContentType; |
| 60 | } |
| 61 | |
| 62 | void DavItem::setData(const QByteArray &data) |
| 63 | { |
| 64 | d->mData = data; |
| 65 | } |
| 66 | |
| 67 | QByteArray DavItem::data() const |
| 68 | { |
| 69 | return d->mData; |
| 70 | } |
| 71 | |
| 72 | void DavItem::setEtag(const QString &etag) |
| 73 | { |
| 74 | d->mEtag = etag; |
| 75 | } |
| 76 | |
| 77 | QString DavItem::etag() const |
| 78 | { |
| 79 | return d->mEtag; |
| 80 | } |
| 81 | |
| 82 | QDataStream &KDAV::operator<<(QDataStream &stream, const DavItem &item) |
| 83 | { |
| 84 | stream << item.url(); |
| 85 | stream << item.contentType(); |
| 86 | stream << item.data(); |
| 87 | stream << item.etag(); |
| 88 | |
| 89 | return stream; |
| 90 | } |
| 91 | |
| 92 | QDataStream &KDAV::operator>>(QDataStream &stream, DavItem &item) |
| 93 | { |
| 94 | QString contentType; |
| 95 | QString etag; |
| 96 | DavUrl url; |
| 97 | QByteArray data; |
| 98 | |
| 99 | stream >> url; |
| 100 | stream >> contentType; |
| 101 | stream >> data; |
| 102 | stream >> etag; |
| 103 | |
| 104 | item = DavItem(url, contentType, data, etag); |
| 105 | |
| 106 | return stream; |
| 107 | } |
| 108 |
