File indexing completed on 2024-06-23 05:07:00
0001 /* 0002 SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "entities.h" 0010 #include "handler.h" 0011 0012 template<typename T> 0013 class QStack; 0014 0015 namespace Akonadi 0016 { 0017 namespace Server 0018 { 0019 /** 0020 @ingroup akonadi_server_handler 0021 0022 Handler for the LIST command. 0023 0024 This command is used to get a (limited) listing of the available collections. 0025 It is different from the LIST command and is more similar to FETCH. 0026 0027 The @c RID command prefix indicates that @c collection-id is a remote identifier 0028 instead of a unique identifier. In this case a resource context has to be specified 0029 previously using the @c RESSELECT command. 0030 0031 @c depths chooses between recursive (@c INF), flat (1) and local (0, ie. just the 0032 base collection) listing, 0 indicates the root collection. 0033 0034 The @c filter-list is used to restrict the listing to collection of a specific 0035 resource or content type. 0036 0037 The @c option-list allows to specify the response content to some extend: 0038 - @c STATISTICS (boolean) allows to include the collection statistics (see Status) 0039 - @c ANCESTORDEPTH (numeric) allows you to specify the number of ancestor nodes that 0040 should be included additionally to the @c parent-id included anyway. 0041 Possible values are @c 0 (the default), @c 1 for the direct parent node and @c INF for all, 0042 terminating with the root collection. 0043 0044 The name is encoded as an quoted UTF-8 string. There is no order defined for the 0045 single responses. 0046 0047 The ancestors property is encoded as a list of UID/RID pairs. 0048 */ 0049 class CollectionFetchHandler : public Handler 0050 { 0051 public: 0052 CollectionFetchHandler(AkonadiServer &akonadi); 0053 ~CollectionFetchHandler() override = default; 0054 0055 bool parseStream() override; 0056 0057 private: 0058 void listCollection(const Collection &root, const QStack<Collection> &ancestors, const QStringList &mimeTypes, const CollectionAttribute::List &attributes); 0059 QStack<Collection> ancestorsForCollection(const Collection &col); 0060 void retrieveCollections(const Collection &topParent, int depth); 0061 bool checkFilterCondition(const Collection &col) const; 0062 CollectionAttribute::List getAttributes(const Collection &colId, const QSet<QByteArray> &filter = QSet<QByteArray>()); 0063 void retrieveAttributes(const QVariantList &collectionIds); 0064 0065 Resource mResource; 0066 QList<MimeType::Id> mMimeTypes; 0067 int mAncestorDepth = 0; 0068 bool mIncludeStatistics = false; 0069 bool mEnabledCollections = false; 0070 bool mCollectionsToDisplay = false; 0071 bool mCollectionsToSynchronize = false; 0072 bool mCollectionsToIndex = false; 0073 QSet<QByteArray> mAncestorAttributes; 0074 QMap<qint64 /*id*/, Collection> mCollections; 0075 QHash<qint64 /*id*/, Collection> mAncestors; 0076 QMultiHash<qint64 /*collectionId*/, CollectionAttribute /*mimetypeId*/> mCollectionAttributes; 0077 }; 0078 0079 } // namespace Server 0080 } // namespace Akonadi