Libkdav2

davitem.cpp
1/*
2 Copyright (c) 2009 Grégory Oestreicher <greg@kamago.net>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17*/
18
19#include "davitem.h"
20
21#include "davurl.h"
22
23using namespace KDAV2;
24
25class DavItemPrivate
26{
27public:
28 DavItemPrivate(DavItem *qPtr) : q(qPtr) {}
29
30 void fillFrom(const DavItemPrivate &other);
31
32 DavItem *q;
33
34 DavUrl mUrl;
35 QString mContentType;
36 QByteArray mData;
37 QString mEtag;
38};
39
40void DavItemPrivate::fillFrom(const DavItemPrivate& other)
41{
42 mUrl = other.mUrl;
43 mContentType = other.mContentType;
44 mData = other.mData;
45 mEtag = other.mEtag;
46}
47
48
50 : d(std::unique_ptr<DavItemPrivate>(new DavItemPrivate(this)))
51{
52}
53
54DavItem::DavItem(const DavUrl &url, const QString &contentType, const QByteArray &data, const QString &etag)
55 : d(std::unique_ptr<DavItemPrivate>(new DavItemPrivate(this)))
56{
57 d->mUrl = url;
58 d->mContentType = contentType;
59 d->mData = data;
60 d->mEtag = etag;
61}
62
63DavItem::DavItem(const DavItem &other)
64 : d(std::unique_ptr<DavItemPrivate>(new DavItemPrivate(this)))
65{
66 d->fillFrom(*other.d.get());
67}
68
69DavItem &DavItem::operator=(const DavItem &other)
70{
71 d->fillFrom(*other.d.get());
72 return *this;
73}
74
75DavItem::~DavItem()
76{
77}
78
79void DavItem::setUrl(const DavUrl &url)
80{
81 d->mUrl = url;
82}
83
85{
86 return d->mUrl;
87}
88
89void DavItem::setContentType(const QString &contentType)
90{
91 d->mContentType = contentType;
92}
93
95{
96 return d->mContentType;
97}
98
100{
101 d->mData = data;
102}
103
105{
106 return d->mData;
107}
108
109void DavItem::setEtag(const QString &etag)
110{
111 d->mEtag = etag;
112}
113
115{
116 return d->mEtag;
117}
118
119QDataStream &KDAV2::operator<<(QDataStream &stream, const DavItem &item)
120{
121 stream << item.url();
122 stream << item.contentType();
123 stream << item.data();
124 stream << item.etag();
125
126 return stream;
127}
128
129QDataStream &KDAV2::operator>>(QDataStream &stream, DavItem &item)
130{
131 QString contentType, etag;
132 DavUrl url;
133 QByteArray data;
134
135 stream >> url;
136 stream >> contentType;
137 stream >> data;
138 stream >> etag;
139
140 item = DavItem(url, contentType, data, etag);
141
142 return stream;
143}
A helper class to store information about DAV resources.
Definition davitem.h:52
QString contentType() const
Returns the content type of the item.
Definition davitem.cpp:94
DavUrl url() const
Returns the url that identifies the item.
Definition davitem.cpp:84
void setEtag(const QString &etag)
Sets the etag of the item.
Definition davitem.cpp:109
QByteArray data() const
Returns the raw content data of the item.
Definition davitem.cpp:104
DavItem()
Creates an empty DAV item.
Definition davitem.cpp:49
void setUrl(const DavUrl &url)
Sets the url that identifies the item.
Definition davitem.cpp:79
void setData(const QByteArray &data)
Sets the raw content data of the item.
Definition davitem.cpp:99
QString etag() const
Returns the etag of the item.
Definition davitem.cpp:114
void setContentType(const QString &type)
Sets the content type of the item.
Definition davitem.cpp:89
A helper class to combine url and protocol of a DAV url.
Definition davurl.h:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:11:32 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.