File indexing completed on 2024-05-26 05:13:52
0001 /* 0002 SPDX-FileCopyrightText: 2009 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "akonadiagentbase_export.h" 0010 #include <QString> 0011 0012 #include <memory> 0013 0014 namespace Akonadi 0015 { 0016 class Collection; 0017 class AgentSearchInterfacePrivate; 0018 class ImapSet; 0019 0020 /** 0021 * @short An interface for agents (or resources) that support searching in their backend. 0022 * 0023 * Inherit from this additionally to Akonadi::AgentBase (or Akonadi::ResourceBase) 0024 * and implement its two pure virtual methods. 0025 * 0026 * Make sure to add the @c Search capability to the agent desktop file. 0027 * 0028 * @since 4.5 0029 */ 0030 class AKONADIAGENTBASE_EXPORT AgentSearchInterface 0031 { 0032 public: 0033 enum ResultScope { 0034 Uid, 0035 Rid, 0036 }; 0037 0038 /** 0039 * Creates a new agent search interface. 0040 */ 0041 AgentSearchInterface(); 0042 0043 /** 0044 * Destroys the agent search interface. 0045 */ 0046 virtual ~AgentSearchInterface(); 0047 0048 /** 0049 * Adds a new search. 0050 * 0051 * @param query The query string, using the language specified in @p queryLanguage 0052 * @param queryLanguage The query language used for @p query 0053 * @param resultCollection The destination collection for the search results. It's a virtual 0054 * collection, results can be added/removed using Akonadi::LinkJob and Akonadi::UnlinkJob respectively. 0055 */ 0056 virtual void addSearch(const QString &query, const QString &queryLanguage, const Akonadi::Collection &resultCollection) = 0; 0057 0058 /** 0059 * Removes a previously added search. 0060 * @param resultCollection The result collection given in an previous addSearch() call. 0061 * You do not need to take care of deleting results in there, the collection is just provided as a way to 0062 * identify the search. 0063 */ 0064 virtual void removeSearch(const Akonadi::Collection &resultCollection) = 0; 0065 0066 /** 0067 * Perform a search on remote storage and return results using SearchResultJob. 0068 * 0069 * @since 4.13 0070 */ 0071 virtual void search(const QString &query, const Collection &collection) = 0; 0072 0073 void searchFinished(const QList<qint64> &result, ResultScope scope); 0074 void searchFinished(const ImapSet &result, ResultScope scope); 0075 void searchFinished(const QList<QByteArray> &result); 0076 0077 private: 0078 /// @cond PRIVATE 0079 std::unique_ptr<AgentSearchInterfacePrivate> const d; 0080 /// @endcond 0081 }; 0082 0083 }