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
11using namespace KDAV;
12
13class DavItemPrivate : public QSharedData
14{
15public:
16 DavUrl mUrl;
17 QString mContentType;
18 QByteArray mData;
19 QString mEtag;
20};
21
22DavItem::DavItem()
23 : d(new DavItemPrivate)
24{
25}
26
27DavItem::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
36DavItem::DavItem(const DavItem &other) = default;
37DavItem::DavItem(DavItem &&) = default;
38DavItem &DavItem::operator=(const DavItem &other) = default;
39DavItem &DavItem::operator=(DavItem &&) = default;
40DavItem::~DavItem() = default;
41
42void DavItem::setUrl(const DavUrl &url)
43{
44 d->mUrl = url;
45}
46
47DavUrl DavItem::url() const
48{
49 return d->mUrl;
50}
51
52void DavItem::setContentType(const QString &contentType)
53{
54 d->mContentType = contentType;
55}
56
57QString DavItem::contentType() const
58{
59 return d->mContentType;
60}
61
62void DavItem::setData(const QByteArray &data)
63{
64 d->mData = data;
65}
66
67QByteArray DavItem::data() const
68{
69 return d->mData;
70}
71
72void DavItem::setEtag(const QString &etag)
73{
74 d->mEtag = etag;
75}
76
77QString DavItem::etag() const
78{
79 return d->mEtag;
80}
81
82QDataStream &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
92QDataStream &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

source code of kdav/src/common/davitem.cpp