Akonadi

agentinstancecreatejob.h
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 "agenttype.h"
10#include "akonadicore_export.h"
11
12#include <KJob>
13
14#include <memory>
15
16namespace Akonadi
17{
18class AgentInstance;
19class AgentInstanceCreateJobPrivate;
20
21/**
22 * @short Job for creating new agent instances.
23 *
24 * This class encapsulates the procedure of creating a new agent instance
25 * and optionally configuring it immediately.
26 *
27 * @code
28 *
29 * MyClass::MyClass( QWidget *parent )
30 * : QWidget( parent )
31 * {
32 * // Get agent type object
33 * Akonadi::AgentType type = Akonadi::AgentManager::self()->type( "akonadi_vcard_resource" );
34 *
35 * Akonadi::AgentInstanceCreateJob *job = new Akonadi::AgentInstanceCreateJob( type );
36 * connect( job, SIGNAL(result(KJob*)),
37 * this, SLOT(slotCreated(KJob*)) );
38 *
39 * // use this widget as parent for the config dialog
40 * job->configure( this );
41 *
42 * job->start();
43 * }
44 *
45 * ...
46 *
47 * void MyClass::slotCreated( KJob *job )
48 * {
49 * Akonadi::AgentInstanceCreateJob *createJob = static_cast<Akonadi::AgentInstanceCreateJob*>( job );
50 *
51 * qDebug() << "Created agent instance:" << createJob->instance().identifier();
52 * }
53 *
54 * @endcode
55 *
56 * @author Volker Krause <vkrause@kde.org>
57 */
58class AKONADICORE_EXPORT AgentInstanceCreateJob : public KJob
59{
60 Q_OBJECT
61
62public:
63 /**
64 * Creates a new agent instance create job.
65 *
66 * @param type The type of the agent to create.
67 * @param parent The parent object.
68 */
69 explicit AgentInstanceCreateJob(const AgentType &type, QObject *parent = nullptr);
70
71 /**
72 * Creates a new agent instance create job.
73 *
74 * @param typeId The identifier of type of the agent to create.
75 * @param parent The parent object.
76 * @since 4.5
77 */
78 explicit AgentInstanceCreateJob(const QString &typeId, QObject *parent = nullptr);
79
80 /**
81 * Destroys the agent instance create job.
82 */
84
85 /**
86 * Setup the job to show agent configuration dialog once the agent instance
87 * has been successfully started.
88 * @param parent The parent window for the configuration dialog.
89 */
90 void configure(QWidget *parent = nullptr);
91
92 /**
93 * Returns the AgentInstance object of the newly created agent instance.
94 */
95 [[nodiscard]] AgentInstance instance() const;
96
97 /**
98 * Starts the instance creation.
99 */
100 void start() override;
101
102private:
103 /// @cond PRIVATE
104 friend class Akonadi::AgentInstanceCreateJobPrivate;
105 std::unique_ptr<AgentInstanceCreateJobPrivate> const d;
106 /// @endcond
107};
108
109}
Represents one agent instance and takes care of communication with it.
Job for creating new agent instances.
~AgentInstanceCreateJob() override
Destroys the agent instance create job.
A representation of an agent instance.
A representation of an agent type.
Q_SCRIPTABLE Q_NOREPLY void start()
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:38:51 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.