1 | /* |
2 | SPDX-FileCopyrightText: 2011 Grégory Oestreicher <greg@kamago.net> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #ifndef KDAV_DAVPRINCIPALSEARCHJOB_H |
8 | #define KDAV_DAVPRINCIPALSEARCHJOB_H |
9 | |
10 | #include "kdav_export.h" |
11 | |
12 | #include "davjobbase.h" |
13 | #include "davurl.h" |
14 | |
15 | #include <QString> |
16 | |
17 | namespace KDAV |
18 | { |
19 | class DavPrincipalSearchJobPrivate; |
20 | |
21 | /*! |
22 | * \class KDAV::DavPrincipalSearchJob |
23 | * \inheaderfile KDAV/DavPrincipalSearchJob |
24 | * \inmodule KDAV |
25 | * |
26 | * \brief A job that search a DAV principal on a server. |
27 | * |
28 | * This job is used to search a principal on a server |
29 | * that implement the dav-property-search REPORT (RFC3744). |
30 | * |
31 | * The properties to fetch are set with @ref fetchProperty(). |
32 | */ |
33 | class KDAV_EXPORT DavPrincipalSearchJob : public DavJobBase |
34 | { |
35 | Q_OBJECT |
36 | |
37 | public: |
38 | /*! |
39 | * Types of search that are supported by this job. |
40 | * \value DisplayName Will match on the DAV displayname property. |
41 | * \value EmailAddress Will match on the CalDav calendar-user-address-set property. |
42 | */ |
43 | enum FilterType { |
44 | DisplayName, |
45 | EmailAddress, |
46 | }; |
47 | |
48 | /*! |
49 | * \inmodule KDAV |
50 | * \brief Simple struct to hold the search job results. |
51 | */ |
52 | struct Result { |
53 | /*! |
54 | * \variable KDAV::DavPrincipalSearchJob::Result::propertyNamespace |
55 | */ |
56 | QString propertyNamespace; |
57 | /*! |
58 | * \variable KDAV::DavPrincipalSearchJob::Result::property |
59 | */ |
60 | QString property; |
61 | /*! |
62 | * \variable KDAV::DavPrincipalSearchJob::Result::value |
63 | */ |
64 | QString value; |
65 | }; |
66 | |
67 | /*! |
68 | * Creates a new DAV principal search job |
69 | * |
70 | * \a url The URL to use in the REPORT query. |
71 | * |
72 | * \a type The type that the filter will match. |
73 | * |
74 | * \a filter The filter that will be used to match the displayname attribute. |
75 | * |
76 | * \a 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 | * \a name The name of the property. |
84 | * |
85 | * \a ns The namespace of this property, defaults to 'DAV:'. |
86 | */ |
87 | void fetchProperty(const QString &name, const QString &ns = QString()); |
88 | |
89 | /*! |
90 | * Starts the job |
91 | */ |
92 | void start() override; |
93 | |
94 | /*! |
95 | * Return the DavUrl used by this job |
96 | */ |
97 | Q_REQUIRED_RESULT DavUrl davUrl() const; |
98 | |
99 | /*! |
100 | * Get the job results. |
101 | */ |
102 | Q_REQUIRED_RESULT QList<Result> results() const; |
103 | |
104 | private: |
105 | Q_DECLARE_PRIVATE(DavPrincipalSearchJob) |
106 | }; |
107 | } |
108 | |
109 | Q_DECLARE_TYPEINFO(KDAV::DavPrincipalSearchJob::Result, Q_RELOCATABLE_TYPE); |
110 | #endif |
111 | |