Akonadi

resourcesynchronizationjob.h
1 /*
2  * SPDX-FileCopyrightText: 2009 Volker Krause <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  */
6 
7 #pragma once
8 
9 #include "akonadicore_export.h"
10 
11 #include <KJob>
12 
13 #include <memory>
14 
15 namespace Akonadi
16 {
17 class AgentInstance;
18 class ResourceSynchronizationJobPrivate;
19 
20 /**
21  * @short Job that synchronizes a resource.
22  *
23  * This job will trigger a resource to synchronize the backend it is
24  * responsible for (e.g. a local file or a groupware server) with the
25  * Akonadi storage.
26  *
27  * If you only want to trigger the synchronization without being
28  * interested in the result, using Akonadi::AgentInstance::synchronize() is enough.
29  * If you want to wait until it's finished, use this class.
30  *
31  * Example:
32  *
33  * @code
34  * using namespace Akonadi;
35  *
36  * const AgentInstance resource = AgentManager::self()->instance( "myresourceidentifier" );
37  *
38  * ResourceSynchronizationJob *job = new ResourceSynchronizationJob( resource );
39  * connect( job, SIGNAL(result(KJob*)), SLOT(synchronizationFinished(KJob*)) );
40  * job->start();
41  *
42  * @endcode
43  *
44  * @note This is a KJob, not an Akonadi::Job, so it won't auto-start!
45  *
46  * @author Volker Krause <[email protected]>
47  * @since 4.4
48  */
49 class AKONADICORE_EXPORT ResourceSynchronizationJob : public KJob
50 {
51  Q_OBJECT
52 
53 public:
54  /**
55  * Creates a new synchronization job for the given resource.
56  *
57  * @param instance The resource instance to synchronize.
58  */
59  explicit ResourceSynchronizationJob(const AgentInstance &instance, QObject *parent = nullptr);
60 
61  /**
62  * Destroys the synchronization job.
63  */
64  ~ResourceSynchronizationJob() override;
65 
66  /**
67  * Returns whether a full synchronization will be done, or just the collection tree (without items).
68  * The default is @c false, i.e. a full sync will be requested.
69  *
70  * @since 4.8
71  */
72  Q_REQUIRED_RESULT bool collectionTreeOnly() const;
73 
74  /**
75  * Sets the collectionTreeOnly property.
76  *
77  * @param collectionTreeOnly If set, only the collection tree will be synchronized.
78  * @since 4.8
79  */
80  void setCollectionTreeOnly(bool collectionTreeOnly);
81 
82  /**
83  * Returns the resource that has been synchronized.
84  */
85  Q_REQUIRED_RESULT AgentInstance resource() const;
86 
87  /* reimpl */
88  void start() override;
89 
90  /*
91  * @since 5.1
92  */
93  void setTimeoutCountLimit(int count);
94  Q_REQUIRED_RESULT int timeoutCountLimit() const;
95 
96 private:
97  /// @cond PRIVATE
98  friend class ResourceSynchronizationJobPrivate;
99  std::unique_ptr<ResourceSynchronizationJobPrivate> const d;
100  /// @endcond
101 };
102 
103 }
104 
Q_SCRIPTABLE Q_NOREPLY void start()
Job that synchronizes a resource.
Represents one agent instance and takes care of communication with it.
A representation of an agent instance.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jul 2 2022 06:41:49 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.