Akonadi

itemretriever.h
1/*
2 SPDX-FileCopyrightText: 2009 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QDateTime>
10#include <QObject>
11
12#include "../exception.h"
13#include "entities.h"
14
15#include "private/scope_p.h"
16
17#include <optional>
18
19AKONADI_EXCEPTION_MAKE_INSTANCE(ItemRetrieverException);
20
21namespace Akonadi
22{
23namespace Server
24{
25class Connection;
26class CommandContext;
27class ItemRetrievalManager;
28class ItemRetrievalRequest;
29
30/**
31 Helper class for retrieving missing items parts from remote resources.
32
33 Stuff in here happens in the calling thread and does not access shared data.
34
35 @todo make usable for Fetch by allowing to share queries
36*/
37class ItemRetriever : public QObject
38{
40
41public:
42 explicit ItemRetriever(ItemRetrievalManager &manager, Connection *connection, const CommandContext &context);
43
44 Connection *connection() const;
45
46 void setRetrieveParts(const QList<QByteArray> &parts);
47 QList<QByteArray> retrieveParts() const;
48 void setRetrieveFullPayload(bool fullPayload);
49 void setChangedSince(const QDateTime &changedSince);
50 void setItemSet(const QList<PimItem::Id> &set, const Collection &collection = Collection());
51 void setItem(PimItem::Id id);
52 /** Retrieve all items in the given collection. */
53 void setCollection(const Collection &collection, bool recursive = true);
54
55 /** Retrieve all items matching the given item scope. */
56 void setScope(const Scope &scope);
57 Scope scope() const;
58
59 bool exec();
60
61 QByteArray lastError() const;
62
64 void itemsRetrieved(const QList<qint64> &ids);
65
66private:
67 QSqlQuery buildQuery() const;
68
69 /**
70 * Checks if external files are still present
71 * This costs extra, but allows us to automatically recover from something changing the external file storage.
72 */
73 void verifyCache();
74
75 /// Execute the retrieval
76 bool runItemRetrievalRequests(std::list<ItemRetrievalRequest> requests);
77 struct PreparedRequests {
78 std::list<ItemRetrievalRequest> requests;
79 QList<qint64> readyItems;
80 };
81 std::optional<PreparedRequests> prepareRequests(QSqlQuery &query, const QByteArrayList &parts);
82
83 QList<PimItem::Id> mItemSet;
84 Collection mCollection;
85 Scope mScope;
86 ItemRetrievalManager &mItemRetrievalManager;
87 Connection *mConnection = nullptr;
88 const CommandContext &mContext;
89 QList<QByteArray> mParts;
90 bool mFullPayload;
91 bool mRecursive;
92 QDateTime mChangedSince;
93 mutable QByteArray mLastError;
94 bool mCanceled;
95};
96
97} // namespace Server
98} // namespace Akonadi
Represents a collection of PIM items.
Definition collection.h:62
An Connection represents one connection of a client to the server.
Definition connection.h:39
Manages and processes item retrieval requests.
Helper class for retrieving missing items parts from remote resources.
void setScope(const Scope &scope)
Retrieve all items matching the given item scope.
void setCollection(const Collection &collection, bool recursive=true)
Retrieve all items in the given collection.
Helper integration between Akonadi and Qt.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:38 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.