Akonadi

itemfetchhelper.h
1/***************************************************************************
2 * SPDX-FileCopyrightText: 2006-2009 Tobias Koenig <tokoe@kde.org> *
3 * *
4 * SPDX-License-Identifier: LGPL-2.0-or-later *
5 ***************************************************************************/
6
7#pragma once
8
9#include "commandcontext.h"
10#include "storage/countquerybuilder.h"
11#include "storage/datastore.h"
12#include "storage/itemretriever.h"
13
14#include "private/protocol_p.h"
15#include "private/scope_p.h"
16
17#include <functional>
18
19class ItemFetchHelperTest;
20
21namespace Akonadi
22{
23namespace Server
24{
25class Connection;
26class AkonadiServer;
27
28class ItemFetchHelper
29{
30public:
31 ItemFetchHelper(Connection *connection,
32 const Scope &scope,
33 const Protocol::ItemFetchScope &itemFetchScope,
34 const Protocol::TagFetchScope &tagFagScope,
35 AkonadiServer &akonadi,
36 const Protocol::FetchLimit &itemsLimit = Protocol::FetchLimit());
37 ItemFetchHelper(Connection *connection,
38 const CommandContext &context,
39 const Scope &scope,
40 const Protocol::ItemFetchScope &itemFetchScope,
41 const Protocol::TagFetchScope &tagFetchScope,
42 AkonadiServer &akonadi,
43 const Protocol::FetchLimit &itemsLimit = Protocol::FetchLimit());
44
45 bool fetchItems(std::function<void(Protocol::FetchItemsResponse &&)> &&callback = {});
46
47 void disableATimeUpdates();
48
49private:
50 enum ItemQueryColumns {
51 ItemQueryPimItemIdColumn,
52 ItemQueryPimItemRidColumn,
53 ItemQueryMimeTypeIdColumn,
54 ItemQueryRevColumn,
55 ItemQueryRemoteRevisionColumn,
56 ItemQuerySizeColumn,
57 ItemQueryDatetimeColumn,
58 ItemQueryCollectionIdColumn,
59 ItemQueryPimItemGidColumn,
60 ItemQueryColumnCount
61 };
62
63 void updateItemAccessTime();
64 void triggerOnDemandFetch();
65 QueryBuilder buildItemQuery();
66 QueryBuilder buildPartQuery(QSqlQuery &itemQuery, const QList<QByteArray> &partList, bool allPayload, bool allAttrs);
67 QueryBuilder buildFlagQuery(QSqlQuery &itemQuery);
68 QueryBuilder buildTagQuery(QSqlQuery &itemQuery);
69 QueryBuilder buildVRefQuery(QSqlQuery &itemQuery);
70
71 QList<Protocol::Ancestor> ancestorsForItem(Collection::Id parentColId);
72 static bool needsAccessTimeUpdate(const QList<QByteArray> &parts);
73 QVariant extractQueryResult(const QSqlQuery &query, ItemQueryColumns column) const;
74 bool isScopeLocal(const Scope &scope);
75 DataStore *storageBackend() const;
76
77private:
78 Connection *mConnection = nullptr;
79 const CommandContext &mContext;
81 Scope mScope;
82 Protocol::ItemFetchScope mItemFetchScope;
83 Protocol::TagFetchScope mTagFetchScope;
84 int mItemQueryColumnMap[ItemQueryColumnCount];
85 bool mUpdateATimeEnabled = true;
86 AkonadiServer &mAkonadi;
87 Protocol::FetchLimit mItemsLimit;
88 QString mPimItemQueryAlias;
89
90 friend class ::ItemFetchHelperTest;
91};
92
93} // namespace Server
94} // namespace Akonadi
qint64 Id
Describes the unique id type.
Definition collection.h:79
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.