Akonadi

resourceselecthandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2009 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "resourceselecthandler.h"
8 
9 #include "connection.h"
10 
11 using namespace Akonadi;
12 using namespace Akonadi::Server;
13 
14 ResourceSelectHandler::ResourceSelectHandler(AkonadiServer &akonadi)
15  : Handler(akonadi)
16 {
17 }
18 
20 {
21  const auto &cmd = Protocol::cmdCast<Protocol::SelectResourceCommand>(m_command);
22 
23  CommandContext context = connection()->context();
24  if (cmd.resourceId().isEmpty()) {
25  context.setResource({});
26  connection()->setContext(context);
27  return successResponse<Protocol::SelectResourceResponse>();
28  }
29 
30  const Resource res = Resource::retrieveByName(cmd.resourceId());
31  if (!res.isValid()) {
32  return failureResponse(cmd.resourceId() % QStringLiteral(" is not a valid resource identifier"));
33  }
34 
35  context.setResource(res);
36  connection()->setContext(context);
37 
38  return successResponse<Protocol::SelectResourceResponse>();
39 }
bool parseStream() override
Parse and handle the IMAP message using the streaming parser.
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-2023 The KDE developers.
Generated on Wed Jun 7 2023 03:53:31 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.