Akonadi

itemretrievalmanager.h
1 /*
2  SPDX-FileCopyrightText: 2009 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef AKONADI_ITEMRETRIEVALMANAGER_H
8 #define AKONADI_ITEMRETRIEVALMANAGER_H
9 
10 #include "itemretriever.h"
11 #include "itemretrievalrequest.h"
12 #include "akthread.h"
13 #include <shared/akstd.h>
14 
15 #include <QHash>
16 #include <QObject>
17 #include <QReadWriteLock>
18 #include <QWaitCondition>
19 
20 #include <unordered_map>
21 
22 class OrgFreedesktopAkonadiResourceInterface;
23 
24 namespace Akonadi
25 {
26 namespace Server
27 {
28 
29 class Collection;
30 class ItemRetrievalJob;
31 class AbstractItemRetrievalJob;
32 
33 class AbstractItemRetrievalJobFactory
34 {
35 public:
36  virtual ~AbstractItemRetrievalJobFactory() = default;
37 
38  virtual AbstractItemRetrievalJob *retrievalJob(ItemRetrievalRequest request, QObject *parent) = 0;
39 
40 protected:
41  explicit AbstractItemRetrievalJobFactory() = default;
42 
43 private:
44  Q_DISABLE_COPY_MOVE(AbstractItemRetrievalJobFactory)
45 };
46 
48 class ItemRetrievalManager : public AkThread
49 {
50  Q_OBJECT
51 public:
52  explicit ItemRetrievalManager(QObject *parent = nullptr);
53  explicit ItemRetrievalManager(std::unique_ptr<AbstractItemRetrievalJobFactory> factory, QObject *parent = nullptr);
54  ~ItemRetrievalManager() override;
55 
60  virtual void requestItemDelivery(ItemRetrievalRequest request);
61 
62  void triggerCollectionSync(const QString &resource, qint64 colId);
63  void triggerCollectionTreeSync(const QString &resource);
64 
65 Q_SIGNALS:
66  void requestFinished(const Akonadi::Server::ItemRetrievalResult &result);
67  void requestAdded();
68 
69 private:
70  OrgFreedesktopAkonadiResourceInterface *resourceInterface(const QString &id);
71  QVector<AbstractItemRetrievalJob *> scheduleJobsForIdleResourcesLocked();
72 
73 private Q_SLOTS:
74  void init() override;
75 
76  void serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner);
77  void processRequest();
78  void retrievalJobFinished(Akonadi::Server::AbstractItemRetrievalJob *job);
79 
80 protected:
81  std::unique_ptr<AbstractItemRetrievalJobFactory> mJobFactory;
82 
87 
89  std::unordered_map<QString, std::list<ItemRetrievalRequest>> mPendingRequests;
92 
93  // resource dbus interface cache
94  std::unordered_map<QString, std::unique_ptr<OrgFreedesktopAkonadiResourceInterface>> mResourceInterfaces;
95 };
96 
97 } // namespace Server
98 } // namespace Akonadi
99 
100 #endif
Manages and processes item retrieval requests.
QCA_EXPORT void init()
QWaitCondition mWaitCondition
Used to let requesting threads wait until the request has been processed.
Details of a single item retrieval request.
Definition: item.h:31
QReadWriteLock mLock
Protects mPendingRequests and every Request object posted to it.
QHash< QString, AbstractItemRetrievalJob * > mCurrentJobs
Currently running jobs, one per resource.
Helper integration between Akonadi and Qt.
std::unordered_map< QString, std::list< ItemRetrievalRequest > > mPendingRequests
Pending requests queues, one per resource.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Jul 4 2020 23:16:51 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.