1 | /* |
2 | Copyright (c) 2006 Volker Krause <vkrause@kde.org> |
3 | |
4 | This library is free software; you can redistribute it and/or modify it |
5 | under the terms of the GNU Library General Public License as published by |
6 | the Free Software Foundation; either version 2 of the License, or (at your |
7 | option) any later version. |
8 | |
9 | This library is distributed in the hope that it will be useful, but WITHOUT |
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public |
12 | License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to the |
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
17 | 02110-1301, USA. |
18 | */ |
19 | |
20 | #ifndef AKONADI_COLLECTIONDELETEJOB_H |
21 | #define AKONADI_COLLECTIONDELETEJOB_H |
22 | |
23 | #include <akonadi/job.h> |
24 | |
25 | namespace Akonadi { |
26 | |
27 | class Collection; |
28 | class CollectionDeleteJobPrivate; |
29 | |
30 | /** |
31 | * @short Job that deletes a collection in the Akonadi storage. |
32 | * |
33 | * This job deletes a collection and all its sub-collections as well as all associated content. |
34 | * |
35 | * @code |
36 | * |
37 | * Akonadi::Collection collection = ... |
38 | * |
39 | * Akonadi::CollectionDeleteJob *job = new Akonadi::CollectionDeleteJob( collection ); |
40 | * connect( job, SIGNAL(result(KJob*)), this, SLOT(deletionResult(KJob*)) ); |
41 | * |
42 | * @endcode |
43 | * |
44 | * @note This job deletes the data from the backend storage. To delete the collection |
45 | * from the Akonadi storage only, leaving the backend storage unchanged, delete |
46 | * the Agent instead, as follows. (Note that if it's a sub-collection, deleting |
47 | * the agent will also delete its parent collection; in this case the only |
48 | * option is to delete the sub-collection data in both Akonadi and backend |
49 | * storage.) |
50 | * |
51 | * @code |
52 | * |
53 | * const Akonadi::AgentInstance instance = |
54 | * Akonadi::AgentManager::self()->instance( collection.resource() ); |
55 | * if ( instance.isValid() ) { |
56 | * Akonadi::AgentManager::self()->removeInstance( instance ); |
57 | * } |
58 | * |
59 | * @endcode |
60 | * |
61 | * @author Volker Krause <vkrause@kde.org> |
62 | */ |
63 | class AKONADI_EXPORT CollectionDeleteJob : public Job |
64 | { |
65 | Q_OBJECT |
66 | |
67 | public: |
68 | /** |
69 | * Creates a new collection delete job. The collection needs to either have a unique |
70 | * identifier or a remote identifier set. Note that using a remote identifier only works |
71 | * in a resource context (that is from within ResourceBase), as remote identifiers |
72 | * are not guaranteed to be globally unique. |
73 | * |
74 | * @param collection The collection to delete. |
75 | * @param parent The parent object. |
76 | */ |
77 | explicit CollectionDeleteJob(const Collection &collection, QObject *parent = 0); |
78 | |
79 | /** |
80 | * Destroys the collection delete job. |
81 | */ |
82 | ~CollectionDeleteJob(); |
83 | |
84 | protected: |
85 | virtual void doStart(); |
86 | |
87 | private: |
88 | Q_DECLARE_PRIVATE(CollectionDeleteJob) |
89 | }; |
90 | |
91 | } |
92 | |
93 | #endif |
94 | |