Akonadi

searchmanager.h
1 /*
2  SPDX-FileCopyrightText: 2010 Volker Krause <[email protected]>
3  SPDX-FileCopyrightText: 2013 Daniel Vr├ítil <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #pragma once
9 
10 #include "akthread.h"
11 
12 #include <QMutex>
13 #include <QSet>
14 #include <QVector>
15 
16 class QTimer;
17 class QPluginLoader;
18 
19 namespace Akonadi
20 {
21 class AbstractSearchPlugin;
22 
23 namespace Server
24 {
25 class AbstractSearchEngine;
26 class Collection;
27 class SearchTaskManager;
28 
29 /**
30  * SearchManager creates and deletes persistent searches for all currently
31  * active search engines.
32  */
33 class SearchManager : public AkThread
34 {
35  Q_OBJECT
36  Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Akonadi.SearchManager")
37 
38 public:
39  /** Create a new search manager with the given @p searchEngines. */
40  explicit SearchManager(const QStringList &searchEngines, SearchTaskManager &agentSearchManager);
41 
42  ~SearchManager() override;
43 
44  /**
45  * Updates the search query asynchronously. Returns immediately
46  */
47  virtual void updateSearchAsync(const Collection &collection);
48 
49  /**
50  * Updates the search query synchronously.
51  */
52  virtual void updateSearch(const Collection &collection);
53 
54  /**
55  * Returns currently available search plugins.
56  */
58 
59 public Q_SLOTS:
60  virtual void scheduleSearchUpdate();
61 
62  /**
63  * This is called via D-Bus from AgentManager to register an agent with
64  * search interface.
65  */
66  virtual void registerInstance(const QString &id);
67 
68  /**
69  * This is called via D-Bus from AgentManager to unregister an agent with
70  * search interface.
71  */
72  virtual void unregisterInstance(const QString &id);
73 
74 private Q_SLOTS:
75  void searchUpdateTimeout();
76  void searchUpdateResultsAvailable(const QSet<qint64> &results);
77 
78  /**
79  * Actual implementation of search updates.
80  *
81  * This method has to be called using QMetaObject::invokeMethod.
82  */
83  void updateSearchImpl(const Akonadi::Server::Collection &collection);
84 
85 private:
86  void init() override;
87  void quit() override;
88 
89  // Called from main thread
90  void loadSearchPlugins();
91  // Called from manager thread
92  void initSearchPlugins();
93 
94  SearchTaskManager &mAgentSearchManager;
95  QStringList mEngineNames;
96  QVector<QPluginLoader *> mPluginLoaders;
99 
100  QTimer *mSearchUpdateTimer = nullptr;
101 
102  QMutex mLock;
103  QSet<qint64> mUpdatingCollections;
104 };
105 
106 } // namespace Server
107 } // namespace Akonadi
108 
Q_OBJECTQ_OBJECT
SearchManager(const QStringList &searchEngines, SearchTaskManager &agentSearchManager)
Create a new search manager with the given searchEngines.
Q_SLOTSQ_SLOTS
Q_CLASSINFO(Name, Value)
virtual void updateSearch(const Collection &collection)
Updates the search query synchronously.
Represents a collection of PIM items.
Definition: collection.h:61
virtual void updateSearchAsync(const Collection &collection)
Updates the search query asynchronously.
virtual void unregisterInstance(const QString &id)
This is called via D-Bus from AgentManager to unregister an agent with search interface.
virtual QVector< AbstractSearchPlugin * > searchPlugins() const
Returns currently available search plugins.
virtual void registerInstance(const QString &id)
This is called via D-Bus from AgentManager to register an agent with search interface.
SearchManager creates and deletes persistent searches for all currently active search engines.
Definition: searchmanager.h:33
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jul 2 2022 06:41:49 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.