1 | /* |
2 | Copyright (c) 2009 Volker Krause <vkrause@kde.org> |
3 | |
4 | This library is free software; you can redistribute it and/or modify it |
5 | under the terms of the GNU Library General Public License as published by |
6 | the Free Software Foundation; either version 2 of the License, or (at your |
7 | option) any later version. |
8 | |
9 | This library is distributed in the hope that it will be useful, but WITHOUT |
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public |
12 | License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to the |
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
17 | 02110-1301, USA. |
18 | */ |
19 | |
20 | #ifndef AKONADI_AGENTSEARCHINTERFACE_H |
21 | #define AKONADI_AGENTSEARCHINTERFACE_H |
22 | |
23 | #include "akonadi_export.h" |
24 | #include <QString> |
25 | |
26 | namespace Akonadi { |
27 | |
28 | class Collection; |
29 | class AgentSearchInterfacePrivate; |
30 | class ImapSet; |
31 | |
32 | /** |
33 | * @short An interface for agents (or resources) that support searching in their backend. |
34 | * |
35 | * Inherit from this additionally to Akonadi::AgentBase (or Akonadi::ResourceBase) |
36 | * and implement its two pure virtual methods. |
37 | * |
38 | * Make sure to add the @c Search capability to the agent desktop file. |
39 | * |
40 | * @since 4.5 |
41 | */ |
42 | class AKONADI_EXPORT AgentSearchInterface |
43 | { |
44 | public: |
45 | enum ResultScope { |
46 | Uid, |
47 | Rid |
48 | }; |
49 | |
50 | /** |
51 | * Creates a new agent search interface. |
52 | */ |
53 | AgentSearchInterface(); |
54 | |
55 | /** |
56 | * Destroys the agent search interface. |
57 | */ |
58 | virtual ~AgentSearchInterface(); |
59 | |
60 | /** |
61 | * Adds a new search. |
62 | * |
63 | * @param query The query string, using the language specified in @p queryLanguage |
64 | * @param queryLanguage The query language used for @p query |
65 | * @param resultCollection The destination collection for the search results. It's a virtual |
66 | * collection, results can be added/removed using Akonadi::LinkJob and Akonadi::UnlinkJob respectively. |
67 | */ |
68 | virtual void addSearch(const QString &query, const QString &queryLanguage, const Akonadi::Collection &resultCollection) = 0; |
69 | |
70 | /** |
71 | * Removes a previously added search. |
72 | * @param resultCollection The result collection given in an previous addSearch() call. |
73 | * You do not need to take care of deleting results in there, the collection is just provided as a way to |
74 | * identify the search. |
75 | */ |
76 | virtual void removeSearch(const Akonadi::Collection &resultCollection) = 0; |
77 | |
78 | /** |
79 | * Perform a search on remote storage and return results using SearchResultJob. |
80 | * |
81 | * @since 4.13 |
82 | */ |
83 | virtual void search(const QString &query, const Collection &collection) = 0; |
84 | |
85 | void searchFinished(const QVector<qint64> result, ResultScope scope); |
86 | void searchFinished(const ImapSet &result, ResultScope scope); |
87 | void searchFinished(const QVector<QByteArray> &result); |
88 | private: |
89 | //@cond PRIVATE |
90 | AgentSearchInterfacePrivate *const d; |
91 | //@endcond |
92 | }; |
93 | |
94 | } |
95 | |
96 | #endif |
97 | |