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 QSqlQuery buildItemQuery();
66 QSqlQuery buildPartQuery(const QList<QByteArray> &partList, bool allPayload, bool allAttrs);
67 QSqlQuery buildFlagQuery();
68 QSqlQuery buildTagQuery();
69 QSqlQuery buildVRefQuery();
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 QueryBuilder mItemQuery;
89 QString mPimItemQueryAlias;
90
91 friend class ::ItemFetchHelperTest;
92};
93
94} // namespace Server
95} // 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 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.