Akonadi

tagdeletehandler.cpp
1/*
2 SPDX-FileCopyrightText: 2014 Daniel Vrátil <dvratil@redhat.com>
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/selectquerybuilder.h"
11#include "storage/tagqueryhelper.h"
12
13#include "private/scope_p.h"
14
15using namespace Akonadi;
16using namespace Akonadi::Server;
17
18TagDeleteHandler::TagDeleteHandler(AkonadiServer &akonadi)
19 : Handler(akonadi)
20{
21}
22
23bool TagDeleteHandler::parseStream()
24{
25 const auto &cmd = Protocol::cmdCast<Protocol::DeleteTagCommand>(m_command);
26
27 if (!checkScopeConstraints(cmd.tag(), {Scope::Uid})) {
28 return failureResponse(QStringLiteral("Only UID-based TAGREMOVE is supported"));
29 }
30
32 TagQueryHelper::scopeToQuery(cmd.tag(), connection()->context(), tagQuery);
33 if (!tagQuery.exec()) {
34 return failureResponse(QStringLiteral("Failed to obtain tags"));
35 }
36
37 const Tag::List tags = tagQuery.result();
38
39 if (!storageBackend()->removeTags(tags)) {
40 return failureResponse(QStringLiteral("Failed to remove tags"));
41 }
42
43 return successResponse<Protocol::DeleteTagResponse>();
44}
The handler interfaces describes an entity capable of handling an AkonadiIMAP command.
Definition handler.h:32
bool exec()
Executes the query, returns true on success.
Helper class for creating and executing database SELECT queries.
QList< T > result()
Returns the result of this SELECT query.
void scopeToQuery(const Scope &scope, const CommandContext &context, QueryBuilder &qb)
Add conditions to qb for the given item operation scope scope.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:38 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.