Akonadi

itemretriever.h
1 /*
2  SPDX-FileCopyrightText: 2009 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef ITEMRETRIEVER_H
8 #define ITEMRETRIEVER_H
9 
10 #include <QObject>
11 #include <QDateTime>
12 
13 #include "../exception.h"
14 #include "entities.h"
15 
16 #include <private/scope_p.h>
17 #include <private/imapset_p.h>
18 
19 #include <optional>
20 
21 AKONADI_EXCEPTION_MAKE_INSTANCE(ItemRetrieverException);
22 
23 namespace Akonadi
24 {
25 namespace Server
26 {
27 
28 class Connection;
29 class CommandContext;
30 class ItemRetrievalManager;
31 class ItemRetrievalRequest;
32 
40 class ItemRetriever : public QObject
41 {
42  Q_OBJECT
43 
44 public:
45  explicit ItemRetriever(ItemRetrievalManager &manager, Connection *connection, const CommandContext &context);
46 
47  Connection *connection() const;
48 
49  void setRetrieveParts(const QVector<QByteArray> &parts);
50  QVector<QByteArray> retrieveParts() const;
51  void setRetrieveFullPayload(bool fullPayload);
52  void setChangedSince(const QDateTime &changedSince);
53  void setItemSet(const ImapSet &set, const Collection &collection = Collection());
54  void setItemSet(const ImapSet &set, bool isUid);
55  void setItem(Entity::Id id);
57  void setCollection(const Collection &collection, bool recursive = true);
58 
60  void setScope(const Scope &scope);
61  Scope scope() const;
62 
63  bool exec();
64 
65  QByteArray lastError() const;
66 
67 Q_SIGNALS:
68  void itemsRetrieved(const QVector<qint64> &ids);
69 
70 private:
71  QSqlQuery buildQuery() const;
72 
77  void verifyCache();
78 
80  bool runItemRetrievalRequests(std::list<ItemRetrievalRequest> requests);
81  struct PreparedRequests {
82  std::list<ItemRetrievalRequest> requests;
83  QVector<qint64> readyItems;
84  };
85  std::optional<PreparedRequests> prepareRequests(QSqlQuery &query, const QByteArrayList &parts);
86 
87  Akonadi::ImapSet mItemSet;
88  Collection mCollection;
89  Scope mScope;
90  ItemRetrievalManager &mItemRetrievalManager;
91  Connection *mConnection = nullptr;
92  const CommandContext &mContext;
93  QVector<QByteArray> mParts;
94  bool mFullPayload;
95  bool mRecursive;
96  QDateTime mChangedSince;
97  mutable QByteArray mLastError;
98  bool mCanceled;
99 };
100 
101 } // namespace Server
102 } // namespace Akonadi
103 
104 #endif
void setCollection(const Collection &collection, bool recursive=true)
Retrieve all items in the given collection.
Helper class for retrieving missing items parts from remote resources.
Definition: itemretriever.h:40
Represents a collection of PIM items.
Definition: collection.h:63
Q_SIGNALSQ_SIGNALS
Q_OBJECTQ_OBJECT
Manages and processes item retrieval requests.
void setScope(const Scope &scope)
Retrieve all items matching the given item scope.
Helper integration between Akonadi and Qt.
An Connection represents one connection of a client to the server.
Definition: connection.h:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Jul 8 2020 23:15:03 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.