Akonadi
7 #include "collectiondeletehandler.h"
9 #include "connection.h"
10 #include "handlerhelper.h"
11 #include "search/searchmanager.h"
12 #include "storage/collectionqueryhelper.h"
13 #include "storage/datastore.h"
14 #include "storage/selectquerybuilder.h"
15 #include "storage/transaction.h"
17 #include <private/scope_p.h>
20 using namespace Akonadi::Server;
22 CollectionDeleteHandler::CollectionDeleteHandler(AkonadiServer &akonadi)
27 bool CollectionDeleteHandler::deleteRecursive(
Collection &col)
31 if (!deleteRecursive(child)) {
36 DataStore *db = connection()->storageBackend();
40 bool CollectionDeleteHandler::parseStream()
42 const auto &cmd = Protocol::cmdCast<Protocol::DeleteCollectionCommand>(m_command);
44 Collection collection = HandlerHelper::collectionFromScope(cmd.collection(), connection()->context());
45 if (!collection.isValid()) {
46 return failureResponse(QStringLiteral(
"No such collection."));
50 if (collection.resource().name() ==
QLatin1String(AKONADI_SEARCH_RESOURCE)) {
52 if (collection.parentId() == 0) {
53 return failureResponse(QStringLiteral(
"Cannot delete virtual root collection"));
57 Transaction transaction(storageBackend(), QStringLiteral(
"DELETE"));
59 if (!deleteRecursive(collection)) {
60 return failureResponse(QStringLiteral(
"Unable to delete collection"));
63 if (!transaction.
commit()) {
64 return failureResponse(QStringLiteral(
"Unable to commit transaction"));
67 return successResponse<Protocol::DeleteCollectionResponse>();
This class handles all the database access.
Helper class for DataStore transaction handling.
Represents a collection of PIM items.
The handler interfaces describes an entity capable of handling an AkonadiIMAP command.
virtual bool cleanupCollection(Collection &collection)
removes the given collection and all its content
bool commit()
Commits the transaction.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Feb 5 2023 03:58:29 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.