1/*
2 SPDX-FileCopyrightText: 2010 Tobias Koenig <tokoe@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "davurl.h"
8
9
10using namespace KDAV;
11
12namespace KDAV
13{
14class DavUrlPrivate : public QSharedData
15{
16public:
17 Protocol mProtocol = KDAV::CalDav;
18 QUrl mUrl;
19};
20}
21
22DavUrl::DavUrl()
23 : d(new DavUrlPrivate)
24{
25}
26
27DavUrl::DavUrl(const QUrl &url, Protocol protocol)
28 : d(new DavUrlPrivate)
29{
30 d->mUrl = url;
31 d->mProtocol = protocol;
32}
33
34DavUrl::DavUrl(const DavUrl &) = default;
35DavUrl::DavUrl(DavUrl &&) = default;
36DavUrl::~DavUrl() = default;
37DavUrl &DavUrl::operator=(const DavUrl &) = default;
38DavUrl &DavUrl::operator=(DavUrl &&) = default;
39
40void DavUrl::setUrl(const QUrl &url)
41{
42 d->mUrl = url;
43}
44
45QUrl DavUrl::url() const
46{
47 return d->mUrl;
48}
49
50void DavUrl::setProtocol(Protocol protocol)
51{
52 d->mProtocol = protocol;
53}
54
55Protocol DavUrl::protocol() const
56{
57 return d->mProtocol;
58}
59
60QString DavUrl::toDisplayString() const
61{
62 auto url = d->mUrl;
63 url.setUserInfo(userInfo: QString());
64 return url.toDisplayString();
65}
66
67QDataStream &KDAV::operator<<(QDataStream &stream, const DavUrl &url)
68{
69 stream << QString::number(url.protocol());
70 stream << url.url();
71
72 return stream;
73}
74
75QDataStream &KDAV::operator>>(QDataStream &stream, DavUrl &davUrl)
76{
77 QUrl url;
78 QString p;
79
80 stream >> p;
81 stream >> url;
82
83 davUrl = DavUrl(url, static_cast<Protocol>(p.toInt()));
84
85 return stream;
86}
87

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