Libkdav2

utils.h
1/*
2 Copyright (c) 2010 Tobias Koenig <tokoe@kde.org>
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#ifndef KDAV2_DAVUTILS_H
20#define KDAV2_DAVUTILS_H
21
22#include "kpimkdav2_export.h"
23
24#include "davcollection.h"
25#include "enums.h"
26
27#include <QtCore/QUrl>
28#include <QtXml/QDomElement>
29#include <QtCore/QVector>
30
31namespace KDAV2
32{
33
34/**
35 * @short A namespace that contains helper methods for DAV functionality.
36 */
37namespace Utils
38{
39/**
40 * Returns the untranslated name of the given DAV @p protocol dialect.
41 */
42QLatin1String KPIMKDAV2_EXPORT protocolName(Protocol protocol);
43
44/**
45 * Returns the protocol matching the given name. This is the opposite of
46 * Utils::protocolName().
47 */
48Protocol KPIMKDAV2_EXPORT protocolByName(const QString &name);
49
50/**
51 * Returns the first child element of @p parent that has the given @p tagName and is part of the @p namespaceUri.
52 */
53QDomElement KPIMKDAV2_EXPORT firstChildElementNS(const QDomElement &parent, const QString &namespaceUri, const QString &tagName);
54
55/**
56 * Returns the next sibling element of @p element that has the given @p tagName and is part of the @p namespaceUri.
57 */
58QDomElement KPIMKDAV2_EXPORT nextSiblingElementNS(const QDomElement &element, const QString &namespaceUri, const QString &tagName);
59
60/**
61 * Extracts privileges from @p element. The <privilege/> tags are expected to be first level children of @p element.
62 */
63Privileges KPIMKDAV2_EXPORT extractPrivileges(const QDomElement &element);
64
65/**
66 * Parses a single <privilege/> tag and returns the final Privileges.
67 */
68Privileges KPIMKDAV2_EXPORT parsePrivilege(const QDomElement &element);
69
70/**
71 * Creates a unique identifier that can be used as a file name to upload the dav item
72 */
73QString KPIMKDAV2_EXPORT createUniqueId();
74
75/**
76 * Returns the mimetype that shall be used for contact DAV resources using @p protocol.
77 */
78QString KPIMKDAV2_EXPORT contactsMimeType(Protocol protocol);
79
80/**
81 * Extract a DavCollection from the response element of a PROPFIND result.
82 *
83 * @return false if a collection could not be extracted.
84 */
85bool extractCollection(const QDomElement &response, DavUrl url, DavCollection &collection);
86}
87
88}
89
90#endif
A helper class to store information about DAV collection.
A helper class to combine url and protocol of a DAV url.
Definition davurl.h:36
Protocol KPIMKDAV2_EXPORT protocolByName(const QString &name)
Returns the protocol matching the given name.
Definition utils.cpp:146
Privileges KPIMKDAV2_EXPORT parsePrivilege(const QDomElement &element)
Parses a single <privilege> tag and returns the final Privileges.
Definition utils.cpp:84
QString KPIMKDAV2_EXPORT contactsMimeType(Protocol protocol)
Returns the mimetype that shall be used for contact DAV resources using protocol.
Definition utils.cpp:172
bool extractCollection(const QDomElement &response, DavUrl url, DavCollection &collection)
Extract a DavCollection from the response element of a PROPFIND result.
Definition utils.cpp:185
QDomElement KPIMKDAV2_EXPORT firstChildElementNS(const QDomElement &parent, const QString &namespaceUri, const QString &tagName)
Returns the first child element of parent that has the given tagName and is part of the namespaceUri.
Definition utils.cpp:37
QDomElement KPIMKDAV2_EXPORT nextSiblingElementNS(const QDomElement &element, const QString &namespaceUri, const QString &tagName)
Returns the next sibling element of element that has the given tagName and is part of the namespaceUr...
Definition utils.cpp:51
QString KPIMKDAV2_EXPORT createUniqueId()
Creates a unique identifier that can be used as a file name to upload the dav item.
Definition utils.cpp:163
Privileges KPIMKDAV2_EXPORT extractPrivileges(const QDomElement &element)
Extracts privileges from element.
Definition utils.cpp:65
QLatin1String KPIMKDAV2_EXPORT protocolName(Protocol protocol)
Returns the untranslated name of the given DAV protocol dialect.
Definition utils.cpp:127
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:32:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.