Akonadi

itemfetchhelper.h
1 /***************************************************************************
2  * Copyright (C) 2006-2009 by Tobias Koenig <[email protected]> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU Library General Public License as *
6  * published by the Free Software Foundation; either version 2 of the *
7  * License, or (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU Library General Public *
15  * License along with this program; if not, write to the *
16  * Free Software Foundation, Inc., *
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18  ***************************************************************************/
19 
20 #ifndef AKONADI_ITEMFETCHHELPER_H
21 #define AKONADI_ITEMFETCHHELPER_H
22 
23 
24 #include "storage/countquerybuilder.h"
25 #include "storage/datastore.h"
26 #include "storage/itemretriever.h"
27 #include "commandcontext.h"
28 
29 #include <private/imapset_p.h>
30 #include <private/scope_p.h>
31 #include <private/protocol_p.h>
32 
33 #include <functional>
34 
35 class ItemFetchHelperTest;
36 
37 namespace Akonadi
38 {
39 
40 namespace Server
41 {
42 
43 class AggregatedItemFetchScope;
44 class Connection;
45 class AkonadiServer;
46 
47 class ItemFetchHelper
48 {
49 public:
50  ItemFetchHelper(Connection *connection, const Scope &scope,
51  const Protocol::ItemFetchScope &itemFetchScope,
52  const Protocol::TagFetchScope &tagFagScope,
53  AkonadiServer &akonadi);
54  ItemFetchHelper(Connection *connection, const CommandContext &context, const Scope &scope,
55  const Protocol::ItemFetchScope &itemFetchScope,
56  const Protocol::TagFetchScope &tagFetchScope,
57  AkonadiServer &akonadi);
58 
59  bool fetchItems(std::function<void(Protocol::FetchItemsResponse &&)> &&callback = {});
60 
61  void disableATimeUpdates();
62 
63 private:
64  enum ItemQueryColumns {
65  ItemQueryPimItemIdColumn,
66  ItemQueryPimItemRidColumn,
67  ItemQueryMimeTypeIdColumn,
68  ItemQueryRevColumn,
69  ItemQueryRemoteRevisionColumn,
70  ItemQuerySizeColumn,
71  ItemQueryDatetimeColumn,
72  ItemQueryCollectionIdColumn,
73  ItemQueryPimItemGidColumn,
74  ItemQueryColumnCount
75  };
76 
77  void updateItemAccessTime();
78  void triggerOnDemandFetch();
79  QSqlQuery buildItemQuery();
80  QSqlQuery buildPartQuery(const QVector<QByteArray> &partList, bool allPayload, bool allAttrs);
81  QSqlQuery buildFlagQuery();
82  QSqlQuery buildTagQuery();
83  QSqlQuery buildVRefQuery();
84 
85  QVector<Protocol::Ancestor> ancestorsForItem(Collection::Id parentColId);
86  static bool needsAccessTimeUpdate(const QVector<QByteArray> &parts);
87  QVariant extractQueryResult(const QSqlQuery &query, ItemQueryColumns column) const;
88  bool isScopeLocal(const Scope &scope);
89  DataStore *storageBackend() const;
90  static QByteArray tagsToByteArray(const Tag::List &tags);
91  static QByteArray relationsToByteArray(const Relation::List &relations);
92 
93 private:
94  Connection *mConnection = nullptr;
95  const CommandContext &mContext;
97  Scope mScope;
98  Protocol::ItemFetchScope mItemFetchScope;
99  Protocol::TagFetchScope mTagFetchScope;
100  int mItemQueryColumnMap[ItemQueryColumnCount];
101  bool mUpdateATimeEnabled = true;
102  AkonadiServer &mAkonadi;
103 
104  friend class ::ItemFetchHelperTest;
105 };
106 
107 } // namespace Server
108 } // namespace Akonadi
109 
110 #endif
qint64 Id
Describes the unique id type.
Definition: collection.h:82
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jun 5 2020 23:08:55 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.