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_COLLECTIONCREATEJOB_H |
21 | #define AKONADI_COLLECTIONCREATEJOB_H |
22 | |
23 | #include <akonadi/job.h> |
24 | |
25 | namespace Akonadi { |
26 | |
27 | class Collection; |
28 | class CollectionCreateJobPrivate; |
29 | |
30 | /** |
31 | * @short Job that creates a new collection in the Akonadi storage. |
32 | * |
33 | * This job creates a new collection with all the set properties. |
34 | * You have to use setParentCollection() to define the collection the |
35 | * new collection shall be located in. |
36 | * |
37 | * @code |
38 | * |
39 | * // create a new top-level collection |
40 | * Akonadi::Collection collection; |
41 | * collection.setParentCollection( Collection::root() ); |
42 | * collection.setName( "Events" ); |
43 | * collection.setContentMimeTypes( QStringList( "text/calendar" ) ); |
44 | * |
45 | * Akonadi::CollectionCreateJob *job = new Akonadi::CollectionCreateJob( collection ); |
46 | * connect( job, SIGNAL(result(KJob*)), this, SLOT(createResult(KJob*)) ); |
47 | * |
48 | * @endcode |
49 | * |
50 | * @author Volker Krause <vkrause@kde.org> |
51 | */ |
52 | class AKONADI_EXPORT CollectionCreateJob : public Job |
53 | { |
54 | Q_OBJECT |
55 | public: |
56 | /** |
57 | * Creates a new collection create job. |
58 | * |
59 | * @param collection The new collection. @p collection must have a parent collection |
60 | * set with a unique identifier. If a resource context is specified in the current session |
61 | * (that is you are using it within Akonadi::ResourceBase), the parent collection can be |
62 | * identified by its remote identifier as well. |
63 | * @param parent The parent object. |
64 | */ |
65 | explicit CollectionCreateJob(const Collection &collection, QObject *parent = 0); |
66 | |
67 | /** |
68 | * Destroys the collection create job. |
69 | */ |
70 | virtual ~CollectionCreateJob(); |
71 | |
72 | /** |
73 | * Returns the created collection if the job was executed successfully. |
74 | */ |
75 | Collection collection() const; |
76 | |
77 | protected: |
78 | virtual void doStart(); |
79 | virtual void doHandleResponse(const QByteArray &tag, const QByteArray &data); |
80 | |
81 | private: |
82 | Q_DECLARE_PRIVATE(CollectionCreateJob) |
83 | }; |
84 | |
85 | } |
86 | |
87 | #endif |
88 | |