Akonadi

tagdeletehandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2014 Daniel Vr├ítil <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "tagdeletehandler.h"
8 
9 #include "storage/datastore.h"
10 #include "storage/queryhelper.h"
11 #include "storage/selectquerybuilder.h"
12 
13 #include <private/imapset_p.h>
14 #include <private/scope_p.h>
15 
16 using namespace Akonadi;
17 using namespace Akonadi::Server;
18 
19 TagDeleteHandler::TagDeleteHandler(AkonadiServer &akonadi)
20  : Handler(akonadi)
21 {
22 }
23 
24 bool TagDeleteHandler::parseStream()
25 {
26  const auto &cmd = Protocol::cmdCast<Protocol::DeleteTagCommand>(m_command);
27 
28  if (!checkScopeConstraints(cmd.tag(), Scope::Uid)) {
29  return failureResponse(QStringLiteral("Only UID-based TAGREMOVE is supported"));
30  }
31 
32  SelectQueryBuilder<Tag> tagQuery;
33  QueryHelper::setToQuery(cmd.tag().uidSet(), Tag::idFullColumnName(), tagQuery);
34  if (!tagQuery.exec()) {
35  return failureResponse(QStringLiteral("Failed to obtain tags"));
36  }
37 
38  const Tag::List tags = tagQuery.result();
39 
40  if (!storageBackend()->removeTags(tags)) {
41  return failureResponse(QStringLiteral("Failed to remove tags"));
42  }
43 
44  return successResponse<Protocol::DeleteTagResponse>();
45 }
QVector< T > result()
Returns the result of this SELECT query.
bool exec()
Executes the query, returns true on success.
Helper class for creating and executing database SELECT queries.
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 Sat Jul 2 2022 06:41:49 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.