1 /*
2     SPDX-FileCopyrightText: 2008 Volker Krause <vkrause@kde.org>
3 
4     SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "akonadicore_export.h"
10 #include "item.h"
11 #include "job.h"
12 
13 namespace Akonadi
14 {
15 class Collection;
16 class LinkJobPrivate;
17 
18 /**
19  * @short Job that links items inside the Akonadi storage.
20  *
21  * This job allows you to create references to a set of items in a virtual
22  * collection.
23  *
24  * Example:
25  *
26  * @code
27  *
28  * // Links the given items to the given virtual collection
29  * const Akonadi::Collection virtualCollection = ...
30  * const Akonadi::Item::List items = ...
31  *
32  * Akonadi::LinkJob *job = new Akonadi::LinkJob( virtualCollection, items );
33  * connect( job, SIGNAL(result(KJob*)), SLOT(jobFinished(KJob*)) );
34  *
35  * ...
36  *
37  * MyClass::jobFinished( KJob *job )
38  * {
39  *   if ( job->error() )
40  *     qDebug() << "Error occurred";
41  *   else
42  *     qDebug() << "Linked items successfully";
43  * }
44  *
45  * @endcode
46  *
47  * @author Volker Krause <vkrause@kde.org>
48  * @since 4.2
49  * @see UnlinkJob
50  */
51 class AKONADICORE_EXPORT LinkJob : public Job
52 {
53     Q_OBJECT
54 public:
55     /**
56      * Creates the link job.
57      *
58      * The job will create references to the given items in the given collection.
59      *
60      * @param collection The collection in which the references should be created.
61      * @param items The items of which the references should be created.
62      * @param parent The parent object.
63      */
64     LinkJob(const Collection &collection, const Item::List &items, QObject *parent = nullptr);
65 
66     /**
67      * Destroys the link job.
68      */
69     ~LinkJob() override;
70 
71 protected:
72     void doStart() override;
73     bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override;
74 
75 private:
76     Q_DECLARE_PRIVATE(LinkJob)
77     template<typename T> friend class LinkJobImpl;
78 };
79 
80 }
81 
82