File indexing completed on 2024-06-23 05:07:01
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2006 Tobias Koenig <tokoe@kde.org> * 0003 * * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later * 0005 ***************************************************************************/ 0006 0007 #include "itemfetchhandler.h" 0008 0009 #include "cachecleaner.h" 0010 #include "connection.h" 0011 #include "itemfetchhelper.h" 0012 0013 using namespace Akonadi; 0014 using namespace Akonadi::Server; 0015 0016 ItemFetchHandler::ItemFetchHandler(AkonadiServer &akonadi) 0017 : Handler(akonadi) 0018 { 0019 } 0020 0021 bool ItemFetchHandler::parseStream() 0022 { 0023 const auto &cmd = Protocol::cmdCast<Protocol::FetchItemsCommand>(m_command); 0024 0025 CommandContext context = connection()->context(); 0026 if (!context.setScopeContext(cmd.scopeContext())) { 0027 return failureResponse(QStringLiteral("Invalid scope context")); 0028 } 0029 0030 // We require context in case we do RID fetch 0031 if (context.isEmpty() && cmd.scope().scope() == Scope::Rid) { 0032 return failureResponse(QStringLiteral("No FETCH context specified")); 0033 } 0034 0035 CacheCleanerInhibitor inhibitor(akonadi()); 0036 0037 ItemFetchHelper fetchHelper(connection(), context, cmd.scope(), cmd.itemFetchScope(), cmd.tagFetchScope(), akonadi(), cmd.itemsLimit()); 0038 if (!fetchHelper.fetchItems()) { 0039 return failureResponse(QStringLiteral("Failed to fetch items")); 0040 } 0041 0042 return successResponse<Protocol::FetchItemsResponse>(); 0043 }