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 #include "davitem.h" 0008 0009 #include "davurl.h" 0010 0011 using namespace KDAV; 0012 0013 class DavItemPrivate : public QSharedData 0014 { 0015 public: 0016 DavUrl mUrl; 0017 QString mContentType; 0018 QByteArray mData; 0019 QString mEtag; 0020 }; 0021 0022 DavItem::DavItem() 0023 : d(new DavItemPrivate) 0024 { 0025 } 0026 0027 DavItem::DavItem(const DavUrl &url, const QString &contentType, const QByteArray &data, const QString &etag) 0028 : d(new DavItemPrivate) 0029 { 0030 d->mUrl = url; 0031 d->mContentType = contentType; 0032 d->mData = data; 0033 d->mEtag = etag; 0034 } 0035 0036 DavItem::DavItem(const DavItem &other) = default; 0037 DavItem::DavItem(DavItem &&) = default; 0038 DavItem &DavItem::operator=(const DavItem &other) = default; 0039 DavItem &DavItem::operator=(DavItem &&) = default; 0040 DavItem::~DavItem() = default; 0041 0042 void DavItem::setUrl(const DavUrl &url) 0043 { 0044 d->mUrl = url; 0045 } 0046 0047 DavUrl DavItem::url() const 0048 { 0049 return d->mUrl; 0050 } 0051 0052 void DavItem::setContentType(const QString &contentType) 0053 { 0054 d->mContentType = contentType; 0055 } 0056 0057 QString DavItem::contentType() const 0058 { 0059 return d->mContentType; 0060 } 0061 0062 void DavItem::setData(const QByteArray &data) 0063 { 0064 d->mData = data; 0065 } 0066 0067 QByteArray DavItem::data() const 0068 { 0069 return d->mData; 0070 } 0071 0072 void DavItem::setEtag(const QString &etag) 0073 { 0074 d->mEtag = etag; 0075 } 0076 0077 QString DavItem::etag() const 0078 { 0079 return d->mEtag; 0080 } 0081 0082 QDataStream &KDAV::operator<<(QDataStream &stream, const DavItem &item) 0083 { 0084 stream << item.url(); 0085 stream << item.contentType(); 0086 stream << item.data(); 0087 stream << item.etag(); 0088 0089 return stream; 0090 } 0091 0092 QDataStream &KDAV::operator>>(QDataStream &stream, DavItem &item) 0093 { 0094 QString contentType; 0095 QString etag; 0096 DavUrl url; 0097 QByteArray data; 0098 0099 stream >> url; 0100 stream >> contentType; 0101 stream >> data; 0102 stream >> etag; 0103 0104 item = DavItem(url, contentType, data, etag); 0105 0106 return stream; 0107 }