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;
29class QueryBuilder;
30
31/**
32 Helper class for retrieving missing items parts from remote resources.
33
34 Stuff in here happens in the calling thread and does not access shared data.
35
36 @todo make usable for Fetch by allowing to share queries
37*/
38class ItemRetriever : public QObject
39{
41
42public:
43 explicit ItemRetriever(ItemRetrievalManager &manager, Connection *connection, const CommandContext &context);
44
45 Connection *connection() const;
46
47 void setRetrieveParts(const QList<QByteArray> &parts);
48 QList<QByteArray> retrieveParts() const;
49 void setRetrieveFullPayload(bool fullPayload);
50 void setChangedSince(const QDateTime &changedSince);
51 void setItemSet(const QList<PimItem::Id> &set, const Collection &collection = Collection());
52 void setItem(PimItem::Id id);
53 /** Retrieve all items in the given collection. */
54 void setCollection(const Collection &collection, bool recursive = true);
55
56 /** Retrieve all items matching the given item scope. */
57 void setScope(const Scope &scope);
58 Scope scope() const;
59
60 bool exec();
61
62 QByteArray lastError() const;
63
65 void itemsRetrieved(const QList<qint64> &ids);
66
67private:
68 QueryBuilder buildQuery() const;
69
70 /**
71 * Checks if external files are still present
72 * This costs extra, but allows us to automatically recover from something changing the external file storage.
73 */
74 void verifyCache();
75
76 /// Execute the retrieval
77 bool runItemRetrievalRequests(std::list<ItemRetrievalRequest> requests);
78 struct PreparedRequests {
79 std::list<ItemRetrievalRequest> requests;
80 QList<qint64> readyItems;
81 };
82 std::optional<PreparedRequests> prepareRequests(QSqlQuery &query, const QByteArrayList &parts);
83
84 QList<PimItem::Id> mItemSet;
85 Collection mCollection;
86 Scope mScope;
87 ItemRetrievalManager &mItemRetrievalManager;
88 Connection *mConnection = nullptr;
89 const CommandContext &mContext;
90 QList<QByteArray> mParts;
91 bool mFullPayload;
92 bool mRecursive;
93 QDateTime mChangedSince;
94 mutable QByteArray mLastError;
95 bool mCanceled;
96};
97
98} // namespace Server
99} // 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 class to construct arbitrary SQL queries.
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 Mon Nov 4 2024 16:31:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.