File indexing completed on 2025-01-05 04:46:55

0001 /*
0002     SPDX-FileCopyrightText: 2009 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 
0011 #include "private/scope_p.h"
0012 
0013 namespace Akonadi
0014 {
0015 namespace Server
0016 {
0017 class CommandContext;
0018 class QueryBuilder;
0019 
0020 /**
0021   Helper methods to generate WHERE clauses for collection queries based on a Scope object.
0022 */
0023 namespace CollectionQueryHelper
0024 {
0025 /**
0026   Add conditions to @p qb for the given remote identifier @p rid.
0027   The rid context is taken from @p context.
0028 */
0029 void remoteIdToQuery(const QStringList &rids, const CommandContext &context, QueryBuilder &qb);
0030 
0031 /**
0032   Add conditions to @p qb for the given collection operation scope @p scope.
0033   The rid context is taken from @p context, if none is specified an exception is thrown.
0034 */
0035 void scopeToQuery(const Scope &scope, const CommandContext &context, QueryBuilder &qb);
0036 
0037 /**
0038   Checks if a collection could exist in the given parent folder with the given name.
0039 */
0040 bool hasAllowedName(const Collection &collection, const QString &name, Collection::Id parent);
0041 
0042 /**
0043   Checks if a collection could be moved from its current parent into the given one.
0044 */
0045 bool canBeMovedTo(const Collection &collection, const Collection &parent);
0046 
0047 /**
0048   Retrieve the collection referred to by the given hierarchical RID chain.
0049 */
0050 Collection resolveHierarchicalRID(const QList<Scope::HRID> &hridChain, Resource::Id resId);
0051 
0052 /**
0053   Returns an existing collection specified by the given scope. If that does not
0054   specify exactly one valid collection, an exception is thrown.
0055 */
0056 Collection singleCollectionFromScope(const Scope &scope, const CommandContext &context);
0057 }
0058 
0059 } // namespace Server
0060 } // namespace Akonadi