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 "connection.h"
10 #include "itemfetchhelper.h"
11 #include "cachecleaner.h"
12 
13 using namespace Akonadi;
14 using namespace Akonadi::Server;
15 
16 ItemFetchHandler::ItemFetchHandler(AkonadiServer &akonadi)
17  : Handler(akonadi)
18 {}
19 
20 bool ItemFetchHandler::parseStream()
21 {
22  const auto &cmd = Protocol::cmdCast<Protocol::FetchItemsCommand>(m_command);
23 
24  CommandContext context = connection()->context();
25  if (!context.setScopeContext(cmd.scopeContext())) {
26  return failureResponse(QStringLiteral("Invalid scope context"));
27  }
28 
29  // We require context in case we do RID fetch
30  if (context.isEmpty() && cmd.scope().scope() == Scope::Rid) {
31  return failureResponse(QStringLiteral("No FETCH context specified"));
32  }
33 
34  CacheCleanerInhibitor inhibitor(akonadi());
35 
36  ItemFetchHelper fetchHelper(connection(), context, cmd.scope(), cmd.itemFetchScope(), cmd.tagFetchScope(), akonadi());
37  if (!fetchHelper.fetchItems()) {
38  return failureResponse(QStringLiteral("Failed to fetch items"));
39  }
40 
41  return successResponse<Protocol::FetchItemsResponse>();
42 }
The handler interfaces describes an entity capable of handling an AkonadiIMAP command.
Definition: handler.h:35
A RAII helper class to temporarily stop the CacheCleaner.
Definition: cachecleaner.h:33
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Jan 17 2021 23:20:16 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.