File indexing completed on 2024-11-10 04:40:28
0001 /* 0002 SPDX-FileCopyrightText: 2006 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "akonadicore_export.h" 0010 #include "job.h" 0011 0012 namespace Akonadi 0013 { 0014 class Collection; 0015 class CollectionDeleteJobPrivate; 0016 0017 /** 0018 * @short Job that deletes a collection in the Akonadi storage. 0019 * 0020 * This job deletes a collection and all its sub-collections as well as all associated content. 0021 * 0022 * @code 0023 * 0024 * Akonadi::Collection collection = ... 0025 * 0026 * Akonadi::CollectionDeleteJob *job = new Akonadi::CollectionDeleteJob( collection ); 0027 * connect( job, SIGNAL(result(KJob*)), this, SLOT(deletionResult(KJob*)) ); 0028 * 0029 * @endcode 0030 * 0031 * @note This job deletes the data from the backend storage. To delete the collection 0032 * from the Akonadi storage only, leaving the backend storage unchanged, delete 0033 * the Agent instead, as follows. (Note that if it's a sub-collection, deleting 0034 * the agent will also delete its parent collection; in this case the only 0035 * option is to delete the sub-collection data in both Akonadi and backend 0036 * storage.) 0037 * 0038 * @code 0039 * 0040 * const Akonadi::AgentInstance instance = 0041 * Akonadi::AgentManager::self()->instance( collection.resource() ); 0042 * if ( instance.isValid() ) { 0043 * Akonadi::AgentManager::self()->removeInstance( instance ); 0044 * } 0045 * 0046 * @endcode 0047 * 0048 * @author Volker Krause <vkrause@kde.org> 0049 */ 0050 class AKONADICORE_EXPORT CollectionDeleteJob : public Job 0051 { 0052 Q_OBJECT 0053 0054 public: 0055 /** 0056 * Creates a new collection delete job. The collection needs to either have a unique 0057 * identifier or a remote identifier set. Note that using a remote identifier only works 0058 * in a resource context (that is from within ResourceBase), as remote identifiers 0059 * are not guaranteed to be globally unique. 0060 * 0061 * @param collection The collection to delete. 0062 * @param parent The parent object. 0063 */ 0064 explicit CollectionDeleteJob(const Collection &collection, QObject *parent = nullptr); 0065 0066 /** 0067 * Destroys the collection delete job. 0068 */ 0069 ~CollectionDeleteJob() override; 0070 0071 protected: 0072 void doStart() override; 0073 bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override; 0074 0075 private: 0076 Q_DECLARE_PRIVATE(CollectionDeleteJob) 0077 }; 0078 0079 }