KDAV

davmanager.cpp
1/*
2 SPDX-FileCopyrightText: 2010 Tobias Koenig <tokoe@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "davmanager_p.h"
8
9#include "protocols/caldavprotocol_p.h"
10#include "protocols/carddavprotocol_p.h"
11#include "protocols/groupdavprotocol_p.h"
12
13#include <KIO/DavJob>
14
15#include "libkdav_debug.h"
16
17#include <QUrl>
18
19using namespace KDAV;
20
21DavManager::DavManager() = default;
22DavManager::~DavManager() = default;
23
24DavManager *DavManager::self()
25{
26 static DavManager sSelf;
27 return &sSelf;
28}
29
30KIO::DavJob *DavManager::createPropFindJob(const QUrl &url, const QString &document, const QString &depth) const
31{
33
34 job->addMetaData(QStringLiteral("cookies"), QStringLiteral("none"));
35 job->addMetaData(QStringLiteral("no-auth-prompt"), QStringLiteral("true"));
36 job->setProperty("davDepth", QVariant::fromValue(depth));
37
38 return job;
39}
40
41KIO::DavJob *DavManager::createReportJob(const QUrl &url, const QString &document, const QString &depth) const
42{
44
45 job->addMetaData(QStringLiteral("cookies"), QStringLiteral("none"));
46 job->addMetaData(QStringLiteral("no-auth-prompt"), QStringLiteral("true"));
47 job->setProperty("davDepth", QVariant::fromValue(depth));
48
49 return job;
50}
51
52KIO::DavJob *DavManager::createPropPatchJob(const QUrl &url, const QString &document) const
53{
55 const QString header = QStringLiteral("Content-Type: text/xml");
56 job->addMetaData(QStringLiteral("customHTTPHeader"), header);
57 job->addMetaData(QStringLiteral("cookies"), QStringLiteral("none"));
58 job->addMetaData(QStringLiteral("no-auth-prompt"), QStringLiteral("true"));
59 return job;
60}
61
62const DavProtocolBase *DavManager::davProtocol(Protocol protocol)
63{
64 const auto d = DavManager::self();
65 if (!d->mProtocols[protocol]) {
66 switch (protocol) {
67 case KDAV::CalDav:
68 d->mProtocols[KDAV::CalDav].reset(new CaldavProtocol());
69 break;
70 case KDAV::CardDav:
71 d->mProtocols[KDAV::CardDav].reset(new CarddavProtocol());
72 break;
73 case KDAV::GroupDav:
74 d->mProtocols[KDAV::GroupDav].reset(new GroupdavProtocol());
75 break;
76 default:
77 qCCritical(KDAV_LOG) << "Unknown protocol: " << static_cast<int>(protocol);
78 return nullptr;
79 }
80 }
81
82 return d->mProtocols[protocol].get();
83}
void addMetaData(const QMap< QString, QString > &values)
The KDAV namespace.
Protocol
Describes the DAV protocol dialect.
Definition enums.h:20
@ GroupDav
The GroupDav protocol as defined in http://www.groupdav.org.
Definition enums.h:23
@ CardDav
The CardDav protocol as defined in https://devguide.calconnect.org/CardDAV.
Definition enums.h:22
@ CalDav
The CalDav protocol as defined in https://devguide.calconnect.org/CalDAV.
Definition enums.h:21
KIOCORE_EXPORT DavJob * davPropFind(const QUrl &url, const QString &properties, const QString &depth, JobFlags flags=DefaultFlags)
KIOCORE_EXPORT DavJob * davPropPatch(const QUrl &url, const QString &properties, JobFlags flags=DefaultFlags)
KIOCORE_EXPORT DavJob * davReport(const QUrl &url, const QString &report, const QString &depth, JobFlags flags=DefaultFlags)
DefaultFlags
HideProgressInfo
bool setProperty(const char *name, QVariant &&value)
QVariant fromValue(T &&value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:05:53 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.