Libkdav2

utils.h
1 /*
2  Copyright (c) 2010 Tobias Koenig <[email protected]>
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 
31 namespace KDAV2
32 {
33 
34 /**
35  * @short A namespace that contains helper methods for DAV functionality.
36  */
37 namespace Utils
38 {
39 /**
40  * Returns the untranslated name of the given DAV @p protocol dialect.
41  */
42 QLatin1String KPIMKDAV2_EXPORT protocolName(Protocol protocol);
43 
44 /**
45  * Returns the protocol matching the given name. This is the opposite of
46  * Utils::protocolName().
47  */
48 Protocol 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  */
53 QDomElement 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  */
58 QDomElement 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  */
63 Privileges KPIMKDAV2_EXPORT extractPrivileges(const QDomElement &element);
64 
65 /**
66  * Parses a single <privilege/> tag and returns the final Privileges.
67  */
68 Privileges 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  */
73 QString KPIMKDAV2_EXPORT createUniqueId();
74 
75 /**
76  * Returns the mimetype that shall be used for contact DAV resources using @p protocol.
77  */
78 QString 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  */
85 bool extractCollection(const QDomElement &response, DavUrl url, DavCollection &collection);
86 }
87 
88 }
89 
90 #endif
Privileges KPIMKDAV2_EXPORT parsePrivilege(const QDomElement &element)
Parses a single <privilege> tag and returns the final Privileges.
Definition: utils.cpp:84
A helper class to store information about DAV collection.
Definition: davcollection.h:49
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
const QLatin1String name
A helper class to combine url and protocol of a DAV url.
Definition: davurl.h:35
bool extractCollection(const QDomElement &response, DavUrl url, DavCollection &collection)
Extract a DavCollection from the response element of a PROPFIND result.
Definition: utils.cpp:185
Protocol KPIMKDAV2_EXPORT protocolByName(const QString &name)
Returns the protocol matching the given name.
Definition: utils.cpp:146
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
Privileges KPIMKDAV2_EXPORT extractPrivileges(const QDomElement &element)
Extracts privileges from element.
Definition: utils.cpp:65
QString KPIMKDAV2_EXPORT contactsMimeType(Protocol protocol)
Returns the mimetype that shall be used for contact DAV resources using protocol. ...
Definition: utils.cpp:172
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
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-2022 The KDE developers.
Generated on Thu Jan 27 2022 23:10:33 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.