Libkdav2

davprincipalsearchjob.h
1/*
2 Copyright (c) 2011 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#ifndef KDAV2_DAVPRINCIPALSEARCHJOB_H
20#define KDAV2_DAVPRINCIPALSEARCHJOB_H
21
22#include "kpimkdav2_export.h"
23
24#include "davjobbase.h"
25#include "davurl.h"
26
27#include <QtCore/QList>
28#include <QtCore/QPair>
29#include <QtCore/QString>
30
31#include <KCoreAddons/KJob>
32
33class QDomDocument;
34
35namespace KDAV2
36{
37
38/**
39 * @short A job that search a DAV principal on a server
40 *
41 * This job is used to search a principal on a server
42 * that implement the dav-property-search REPORT (RFC3744).
43 *
44 * The properties to fetch are set with @ref fetchProperty().
45 */
46class KPIMKDAV2_EXPORT DavPrincipalSearchJob : public DavJobBase
47{
48 Q_OBJECT
49
50public:
51 /**
52 * Types of search that are supported by this job.
53 * DisplayName will match on the DAV displayname property.
54 * EmailAddress will match on the CalDav calendar-user-address-set property.
55 */
57 DisplayName,
58 EmailAddress
59 };
60
61 /**
62 * Simple struct to hold the search job results
63 */
64 struct Result {
65 QString propertyNamespace;
66 QString property;
67 QString value;
68 };
69
70 /**
71 * Creates a new dav principal search job
72 *
73 * @param url The URL to use in the REPORT query.
74 * @param type The type that the filter will match.
75 * @param filter The filter that will be used to match the displayname attribute.
76 * @param parent The parent object.
77 */
78 explicit DavPrincipalSearchJob(const DavUrl &url, FilterType type, const QString &filter, QObject *parent = nullptr);
79
80 /**
81 * Add a new property to fetch from the server.
82 *
83 * @param name The name of the property.
84 * @param ns The namespace of this property, defaults to 'DAV:'.
85 */
86 void fetchProperty(const QString &name, const QString &ns = QString());
87
88 /**
89 * Starts the job
90 */
91 void start() Q_DECL_OVERRIDE;
92
93 /**
94 * Return the DavUrl used by this job
95 */
96 DavUrl davUrl() const;
97
98 /**
99 * Get the job results.
100 */
101 QList<Result> results() const;
102
103private Q_SLOTS:
104 void principalCollectionSetSearchFinished(KJob *job);
105 void principalPropertySearchFinished(KJob *job);
106
107private:
108 void buildReportQuery(QDomDocument &query);
109
110private:
111 DavUrl mUrl;
112 FilterType mType;
113 QString mFilter;
114 int mPrincipalPropertySearchSubJobCount;
115 bool mPrincipalPropertySearchSubJobSuccessful;
116 QList< QPair<QString, QString> > mFetchProperties;
117 QList<Result> mResults;
118};
119
120}
121
122#endif
base class for the jobs used by the resource.
Definition davjobbase.h:38
A job that search a DAV principal on a server.
FilterType
Types of search that are supported by this job.
A helper class to combine url and protocol of a DAV url.
Definition davurl.h:36
Q_SCRIPTABLE Q_NOREPLY void start()
Simple struct to hold the search job results.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:50:09 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.