Akonadi

itemfetchhandler.cpp
1 /***************************************************************************
2  * SPDX-FileCopyrightText: 2006 Tobias Koenig <[email protected]> *
3  * *
4  * SPDX-License-Identifier: LGPL-2.0-or-later *
5  ***************************************************************************/
6 
7 #include "itemfetchhandler.h"
8 
9 #include "cachecleaner.h"
10 #include "connection.h"
11 #include "itemfetchhelper.h"
12 
13 using namespace Akonadi;
14 using namespace Akonadi::Server;
15 
16 ItemFetchHandler::ItemFetchHandler(AkonadiServer &akonadi)
17  : Handler(akonadi)
18 {
19 }
20 
21 bool ItemFetchHandler::parseStream()
22 {
23  const auto &cmd = Protocol::cmdCast<Protocol::FetchItemsCommand>(m_command);
24 
25  CommandContext context = connection()->context();
26  if (!context.setScopeContext(cmd.scopeContext())) {
27  return failureResponse(QStringLiteral("Invalid scope context"));
28  }
29 
30  // We require context in case we do RID fetch
31  if (context.isEmpty() && cmd.scope().scope() == Scope::Rid) {
32  return failureResponse(QStringLiteral("No FETCH context specified"));
33  }
34 
35  CacheCleanerInhibitor inhibitor(akonadi());
36 
37  ItemFetchHelper fetchHelper(connection(), context, cmd.scope(), cmd.itemFetchScope(), cmd.tagFetchScope(), akonadi(), cmd.itemsLimit());
38  if (!fetchHelper.fetchItems()) {
39  return failureResponse(QStringLiteral("Failed to fetch items"));
40  }
41 
42  return successResponse<Protocol::FetchItemsResponse>();
43 }
A RAII helper class to temporarily stop the CacheCleaner.
Definition: cachecleaner.h:31
The handler interfaces describes an entity capable of handling an AkonadiIMAP command.
Definition: handler.h:39
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Jun 27 2022 04:01:06 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.