Akonadi

itemfetchhelper.h
1 /***************************************************************************
2  * SPDX-FileCopyrightText: 2006-2009 Tobias Koenig <[email protected]> *
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/imapset_p.h>
15 #include <private/protocol_p.h>
16 #include <private/scope_p.h>
17 
18 #include <functional>
19 
20 class ItemFetchHelperTest;
21 
22 namespace Akonadi
23 {
24 namespace Server
25 {
26 class Connection;
27 class AkonadiServer;
28 
29 class ItemFetchHelper
30 {
31 public:
32  ItemFetchHelper(Connection *connection,
33  const Scope &scope,
34  const Protocol::ItemFetchScope &itemFetchScope,
35  const Protocol::TagFetchScope &tagFagScope,
36  AkonadiServer &akonadi,
37  const Protocol::FetchLimit &itemsLimit = Protocol::FetchLimit());
38  ItemFetchHelper(Connection *connection,
39  const CommandContext &context,
40  const Scope &scope,
41  const Protocol::ItemFetchScope &itemFetchScope,
42  const Protocol::TagFetchScope &tagFetchScope,
43  AkonadiServer &akonadi,
44  const Protocol::FetchLimit &itemsLimit = Protocol::FetchLimit());
45 
46  bool fetchItems(std::function<void(Protocol::FetchItemsResponse &&)> &&callback = {});
47 
48  void disableATimeUpdates();
49 
50 private:
51  enum ItemQueryColumns {
52  ItemQueryPimItemIdColumn,
53  ItemQueryPimItemRidColumn,
54  ItemQueryMimeTypeIdColumn,
55  ItemQueryRevColumn,
56  ItemQueryRemoteRevisionColumn,
57  ItemQuerySizeColumn,
58  ItemQueryDatetimeColumn,
59  ItemQueryCollectionIdColumn,
60  ItemQueryPimItemGidColumn,
61  ItemQueryColumnCount
62  };
63 
64  void updateItemAccessTime();
65  void triggerOnDemandFetch();
66  QSqlQuery buildItemQuery();
67  QSqlQuery buildPartQuery(const QVector<QByteArray> &partList, bool allPayload, bool allAttrs);
68  QSqlQuery buildFlagQuery();
69  QSqlQuery buildTagQuery();
70  QSqlQuery buildVRefQuery();
71 
72  QVector<Protocol::Ancestor> ancestorsForItem(Collection::Id parentColId);
73  static bool needsAccessTimeUpdate(const QVector<QByteArray> &parts);
74  QVariant extractQueryResult(const QSqlQuery &query, ItemQueryColumns column) const;
75  bool isScopeLocal(const Scope &scope);
76  DataStore *storageBackend() const;
77  static QByteArray relationsToByteArray(const Relation::List &relations);
78 
79 private:
80  Connection *mConnection = nullptr;
81  const CommandContext &mContext;
83  Scope mScope;
84  Protocol::ItemFetchScope mItemFetchScope;
85  Protocol::TagFetchScope mTagFetchScope;
86  int mItemQueryColumnMap[ItemQueryColumnCount];
87  bool mUpdateATimeEnabled = true;
88  AkonadiServer &mAkonadi;
89  Protocol::FetchLimit mItemsLimit;
90  QueryBuilder mItemQuery;
91  QString mPimItemQueryAlias;
92 
93  friend class ::ItemFetchHelperTest;
94 };
95 
96 } // namespace Server
97 } // namespace Akonadi
98 
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-2022 The KDE developers.
Generated on Sat Jul 2 2022 06:41:48 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.