File indexing completed on 2025-01-05 04:47:03
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2006 Tobias Koenig <tokoe@kde.org> * 0003 * * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later * 0005 ***************************************************************************/ 0006 0007 #pragma once 0008 0009 #include "entities.h" 0010 0011 #include <QByteArray> 0012 #include <QStack> 0013 #include <QString> 0014 0015 namespace Akonadi 0016 { 0017 class Scope; 0018 class ImapSet; 0019 0020 namespace Protocol 0021 { 0022 class Ancestor; 0023 class CachePolicy; 0024 class FetchCollectionsResponse; 0025 class TagFetchScope; 0026 class FetchTagsResponse; 0027 using FetchTagsResponsePtr = QSharedPointer<FetchTagsResponse>; 0028 class FetchRelationsResponse; 0029 using FetchRelationsResponsePtr = QSharedPointer<FetchRelationsResponse>; 0030 } 0031 0032 namespace Server 0033 { 0034 class CommandContext; 0035 class Connection; 0036 class AkonadiServer; 0037 0038 /** 0039 Helper functions for command handlers. 0040 */ 0041 class HandlerHelper 0042 { 0043 public: 0044 /** 0045 Returns the collection identified by the given id or path. 0046 */ 0047 static Collection collectionFromIdOrName(const QByteArray &id); 0048 0049 /** 0050 Returns the full path for the given collection. 0051 */ 0052 static QString pathForCollection(const Collection &col); 0053 0054 /** 0055 Returns the protocol representation of the cache policy of the given 0056 Collection object. 0057 */ 0058 static Protocol::CachePolicy cachePolicyResponse(const Collection &col); 0059 0060 /** 0061 Returns the protocol representation of the given collection. 0062 Make sure DataStore::activeCachePolicy() has been called before to include 0063 the effective cache policy 0064 */ 0065 static Protocol::FetchCollectionsResponse fetchCollectionsResponse(AkonadiServer &akonadi, const Collection &col); 0066 0067 /** 0068 Returns the protocol representation of the given collection. 0069 Make sure DataStore::activeCachePolicy() has been called before to include 0070 the effective cache policy 0071 */ 0072 static Protocol::FetchCollectionsResponse 0073 fetchCollectionsResponse(AkonadiServer &akonadi, 0074 const Collection &col, 0075 const CollectionAttribute::List &attributeList, 0076 bool includeStatistics = false, 0077 int ancestorDepth = 0, 0078 const QStack<Collection> &ancestors = QStack<Collection>(), 0079 const QStack<CollectionAttribute::List> &ancestorAttributes = QStack<CollectionAttribute::List>(), 0080 const QStringList &mimeTypes = QStringList()); 0081 0082 /** 0083 Returns the protocol representation of a collection ancestor chain. 0084 */ 0085 static QList<Protocol::Ancestor> ancestorsResponse(int ancestorDepth, 0086 const QStack<Collection> &ancestors, 0087 const QStack<CollectionAttribute::List> &_ancestorsAttributes = QStack<CollectionAttribute::List>()); 0088 0089 static Protocol::FetchTagsResponse fetchTagsResponse(const Tag &tag, const Protocol::TagFetchScope &tagFetchScope, Connection *connection = nullptr); 0090 0091 static Protocol::FetchRelationsResponse fetchRelationsResponse(const Relation &relation); 0092 0093 /** 0094 Converts a bytearray list of flag names into flag records. 0095 @throws HandlerException on errors during database operations 0096 */ 0097 static Flag::List resolveFlags(const QSet<QByteArray> &flagNames); 0098 0099 /** 0100 Converts a imap set of tags into tag records. 0101 @throws HandlerException on errors during database operations 0102 */ 0103 static Tag::List resolveTagsByUID(const ImapSet &tags); 0104 0105 static Tag::List resolveTagsByGID(const QStringList &tagsGIDs); 0106 0107 static Tag::List resolveTagsByRID(const QStringList &tagsRIDs, const CommandContext &context); 0108 0109 static Collection collectionFromScope(const Scope &scope, const CommandContext &context); 0110 0111 static Tag::List tagsFromScope(const Scope &scope, const CommandContext &context); 0112 }; 0113 0114 } // namespace Server 0115 } // namespace Akonadi