Akonadi

agentbase.h
1/*
2 This file is part of akonadiresources.
3
4 SPDX-FileCopyrightText: 2006 Till Adam <adam@kde.org>
5 SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org>
6 SPDX-FileCopyrightText: 2008 Kevin Krammer <kevin.krammer@gmx.at>
7
8 SPDX-License-Identifier: LGPL-2.0-or-later
9*/
10
11#pragma once
12
13#include "akonadiagentbase_export.h"
14// AkonadiCore
15#include "akonadi/item.h"
16
17#include <QApplication>
18
19#include <KSharedConfig>
20
21#include <QDBusConnection>
22#include <QDBusContext>
23
24#include <memory>
25
26class Akonadi__ControlAdaptor;
27class Akonadi__StatusAdaptor;
28
29class KAboutData;
30
31namespace Akonadi
32{
33class AgentBasePrivate;
34class ChangeRecorder;
35class Collection;
36class Item;
37
38/**
39 * @short The base class for all Akonadi agents and resources.
40 *
41 * This class is a base class for all Akonadi agents, which covers the real
42 * agent processes and all resources.
43 *
44 * It provides:
45 * - lifetime management
46 * - change monitoring and recording
47 * - configuration interface
48 * - problem reporting
49 *
50 * Akonadi Server supports several ways to launch agents and resources:
51 * - As a separate application (@see AKONADI_AGENT_MAIN)
52 * - As a thread in the AgentServer
53 * - As a separate process, using the akonadi_agent_launcher
54 *
55 * The idea is this, the agent or resource is written as a plugin instead of an
56 * executable (@see AgentFactory). In the AgentServer case, the AgentServer
57 * looks up the plugin and launches the agent in a separate thread. In the
58 * launcher case, a new akonadi_agent_launcher process is started for each
59 * agent or resource instance.
60 *
61 * When making an Agent or Resource suitable for running in the AgentServer some
62 * extra caution is needed. Because multiple instances of several kinds of agents
63 * run in the same process, one cannot blindly use global objects like KGlobal.
64 * For this reasons several methods where added to avoid problems in this context,
65 * most notably AgentBase::config(). Additionally,
66 * one cannot use QDBusConnection::sessionBus() with dbus < 1.4, because of a
67 * multithreading bug in libdbus. Instead one should use
68 * QDBusConnection::sessionBus() which works around this problem.
69 *
70 * @author Till Adam <adam@kde.org>, Volker Krause <vkrause@kde.org>
71 */
72class AKONADIAGENTBASE_EXPORT AgentBase : public QObject, protected QDBusContext
73{
74 Q_OBJECT
75
76public:
77 /**
78 * @short The interface for reacting on monitored or replayed changes.
79 *
80 * The Observer provides an interface to react on monitored or replayed changes.
81 *
82 * Since the this base class does only tell the change recorder that the change
83 * has been processed, an AgentBase subclass which wants to actually process
84 * the change needs to subclass Observer and reimplement the methods it is
85 * interested in.
86 *
87 * Such an agent specific Observer implementation can either be done
88 * stand-alone, i.e. as a separate object, or by inheriting both AgentBase
89 * and AgentBase::Observer.
90 *
91 * The observer implementation then has registered with the agent, so it
92 * can forward the incoming changes to the observer.
93 *
94 * @note In the multiple inheritance approach the init() method automatically
95 * registers itself as the observer.
96 *
97 * @note Do not call the base implementation of reimplemented virtual methods!
98 * The default implementation disconnected themselves from the Akonadi::ChangeRecorder
99 * to enable internal optimizations for unused notifications.
100 *
101 * Example for stand-alone observer:
102 * @code
103 * class ExampleAgent : public AgentBase
104 * {
105 * public:
106 * ExampleAgent( const QString &id );
107 *
108 * ~ExampleAgent();
109 *
110 * private:
111 * AgentBase::Observer *mObserver;
112 * };
113 *
114 * class ExampleObserver : public AgentBase::Observer
115 * {
116 * protected:
117 * void itemChanged( const Item &item );
118 * };
119 *
120 * ExampleAgent::ExampleAgent( const QString &id )
121 : AgentBase( id )
122 , mObserver( 0 )
123 * {
124 * mObserver = new ExampleObserver();
125 * registerObserver( mObserver );
126 * }
127 *
128 * ExampleAgent::~ExampleAgent()
129 * {
130 * delete mObserver;
131 * }
132 *
133 * void ExampleObserver::itemChanged( const Item &item )
134 * {
135 * // do something with item
136 * qCDebug(AKONADIAGENTBASE_LOG) << "Item id=" << item.id();
137 *
138 * // let base implementation tell the change recorder that we
139 * // have processed the change
140 * AgentBase::Observer::itemChanged( item );
141 * }
142 * @endcode
143 *
144 * Example for observer through multiple inheritance:
145 * @code
146 * class ExampleAgent : public AgentBase, public AgentBase::Observer
147 * {
148 * public:
149 * ExampleAgent( const QString &id );
150 *
151 * protected:
152 * void itemChanged( const Item &item );
153 * };
154 *
155 * ExampleAgent::ExampleAgent( const QString &id )
156 : AgentBase( id )
157 * {
158 * // no need to create or register observer since
159 * // we are the observer and registration happens automatically
160 * // in init()
161 * }
162 *
163 * void ExampleAgent::itemChanged( const Item &item )
164 * {
165 * // do something with item
166 * qCDebug(AKONADIAGENTBASE_LOG) << "Item id=" << item.id();
167 *
168 * // let base implementation tell the change recorder that we
169 * // have processed the change
170 * AgentBase::Observer::itemChanged( item );
171 * }
172 * @endcode
173 *
174 * @author Kevin Krammer <kevin.krammer@gmx.at>
175 *
176 * @deprecated Use ObserverV2 instead
177 */
178 class AKONADIAGENTBASE_DEPRECATED AKONADIAGENTBASE_EXPORT Observer // krazy:exclude=dpointer
179 {
180 public:
181 /**
182 * Creates an observer instance.
183 */
184 Observer();
185
186 /**
187 * Destroys the observer instance.
188 */
189 virtual ~Observer();
190
191 /**
192 * Reimplement to handle adding of new items.
193 * @param item The newly added item.
194 * @param collection The collection @p item got added to.
195 */
196 virtual void itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection);
197
198 /**
199 * Reimplement to handle changes to existing items.
200 * @param item The changed item.
201 * @param partIdentifiers The identifiers of the item parts that has been changed.
202 */
203 virtual void itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &partIdentifiers);
204
205 /**
206 * Reimplement to handle deletion of items.
207 * @param item The deleted item.
208 */
209 virtual void itemRemoved(const Akonadi::Item &item);
210
211 /**
212 * Reimplement to handle adding of new collections.
213 * @param collection The newly added collection.
214 * @param parent The parent collection.
215 */
216 virtual void collectionAdded(const Akonadi::Collection &collection, const Akonadi::Collection &parent);
217
218 /**
219 * Reimplement to handle changes to existing collections.
220 * @param collection The changed collection.
221 */
222 virtual void collectionChanged(const Akonadi::Collection &collection);
223
224 /**
225 * Reimplement to handle deletion of collections.
226 * @param collection The deleted collection.
227 */
228 virtual void collectionRemoved(const Akonadi::Collection &collection);
229 };
230
231 /**
232 * BC extension of Observer with support for monitoring item and collection moves.
233 * Use this one instead of Observer.
234 *
235 * @since 4.4
236 */
237 class AKONADIAGENTBASE_EXPORT ObserverV2 : public Observer // krazy:exclude=dpointer
238 {
239 public:
240 using Observer::collectionChanged;
241
242 /**
243 * Reimplement to handle item moves.
244 * When using this class in combination with Akonadi::ResourceBase, inter-resource
245 * moves are handled internally already and the corresponding add or delete method
246 * is called instead.
247 *
248 * @param item The moved item.
249 * @param collectionSource The collection the item has been moved from.
250 * @param collectionDestination The collection the item has been moved to.
251 */
252 virtual void itemMoved(const Akonadi::Item &item, const Akonadi::Collection &collectionSource, const Akonadi::Collection &collectionDestination);
253
254 /**
255 * Reimplement to handle item linking.
256 * This is only relevant for virtual resources.
257 * @param item The linked item.
258 * @param collection The collection the item is linked to.
259 */
260 virtual void itemLinked(const Akonadi::Item &item, const Akonadi::Collection &collection);
261
262 /**
263 * Reimplement to handle item unlinking.
264 * This is only relevant for virtual resources.
265 * @param item The unlinked item.
266 * @param collection The collection the item is unlinked from.
267 */
268 virtual void itemUnlinked(const Akonadi::Item &item, const Akonadi::Collection &collection);
269
270 /**
271 * Reimplement to handle collection moves.
272 * When using this class in combination with Akonadi::ResourceBase, inter-resource
273 * moves are handled internally already and the corresponding add or delete method
274 * is called instead.
275 *
276 * @param collection The moved collection.
277 * @param collectionSource The previous parent collection.
278 * @param collectionDestination The new parent collection.
279 */
280 virtual void
281 collectionMoved(const Akonadi::Collection &collection, const Akonadi::Collection &collectionSource, const Akonadi::Collection &collectionDestination);
282
283 /**
284 * Reimplement to handle changes to existing collections.
285 * @param collection The changed collection.
286 * @param changedAttributes The identifiers of the collection parts/attributes that has been changed.
287 */
288 virtual void collectionChanged(const Akonadi::Collection &collection, const QSet<QByteArray> &changedAttributes);
289 };
290
291 /**
292 * BC extension of ObserverV2 with support for batch operations
293 *
294 * @warning When using ObserverV3, you will never get single-item notifications
295 * from AgentBase::Observer, even when you don't reimplement corresponding batch
296 * method from ObserverV3. For instance, when you don't reimplement itemsRemoved()
297 * here, you will not get any notifications about item removal whatsoever!
298 *
299 * @since 4.11
300 */
301 class AKONADIAGENTBASE_EXPORT ObserverV3 : public ObserverV2 // krazy:exclude=dpointer
302 {
303 public:
304 /**
305 * Reimplement to handle changes in flags of existing items
306 *
307 * @warning When using ObserverV3, you will never get notifications about
308 * flag changes via Observer::itemChanged(), even when you don't reimplement
309 * itemsFlagsChanged()!
310 *
311 * @param items The changed items
312 * @param addedFlags Flags that have been added to the item
313 * @param removedFlags Flags that have been removed from the item
314 */
315 virtual void itemsFlagsChanged(const Akonadi::Item::List &items, const QSet<QByteArray> &addedFlags, const QSet<QByteArray> &removedFlags);
316
317 /**
318 * Reimplement to handle batch notification about items deletion.
319 *
320 * @param items List of deleted items
321 */
322 virtual void itemsRemoved(const Akonadi::Item::List &items);
323
324 /**
325 * Reimplement to handle batch notification about items move
326 *
327 * @param items List of moved items
328 * @param sourceCollection Collection from where the items were moved
329 * @param destinationCollection Collection to which the items were moved
330 */
331 virtual void
332 itemsMoved(const Akonadi::Item::List &items, const Akonadi::Collection &sourceCollection, const Akonadi::Collection &destinationCollection);
333
334 /**
335 * Reimplement to handle batch notifications about items linking.
336 *
337 * @param items Linked items
338 * @param collection Collection to which the items have been linked
339 */
340 virtual void itemsLinked(const Akonadi::Item::List &items, const Akonadi::Collection &collection);
341
342 /**
343 * Reimplement to handle batch notifications about items unlinking.
344 *
345 * @param items Unlinked items
346 * @param collection Collection from which the items have been unlinked
347 */
348 virtual void itemsUnlinked(const Akonadi::Item::List &items, const Akonadi::Collection &collection);
349 };
350
351 class AKONADIAGENTBASE_EXPORT TagObserver
352 {
353 public:
354 TagObserver();
355 virtual ~TagObserver();
356
357 /**
358 * Reimplement to handle tags additions
359 *
360 * @param tag Newly added tag
361 */
362 virtual void tagAdded(const Akonadi::Tag &tag);
363
364 /**
365 * Reimplement to handle tags changes
366 *
367 * @param tag Tag that has been changed
368 */
369 virtual void tagChanged(const Akonadi::Tag &tag);
370
371 /**
372 * Reimplement to handle tags removal.
373 *
374 * @note All items that were tagged by @p tag will get a separate notification
375 * about untagging via itemsTagsChanged(). It is guaranteed that the itemsTagsChanged()
376 * notification will be delivered before this one.
377 *
378 * @param tag Tag that has been removed.
379 */
380 virtual void tagRemoved(const Akonadi::Tag &tag);
381
382 /**
383 * Reimplement to handle items tagging
384 *
385 * @param items Items that were tagged or untagged
386 * @param addedTags Set of tags that were added to all @p items
387 * @param removedTags Set of tags that were removed from all @p items
388 */
389 virtual void itemsTagsChanged(const Akonadi::Item::List &items, const QSet<Akonadi::Tag> &addedTags, const QSet<Akonadi::Tag> &removedTags);
390 };
391
392 /**
393 * This enum describes the different states the
394 * agent can be in.
395 */
396 enum Status {
397 Idle = 0, ///< The agent does currently nothing.
398 Running, ///< The agent is working on something.
399 Broken, ///< The agent encountered an error state.
400 NotConfigured ///< The agent is lacking required configuration
401 };
402
403 /**
404 * Use this method in the main function of your agent
405 * application to initialize your agent subclass.
406 * This method also takes care of creating a KApplication
407 * object and parsing command line arguments.
408 *
409 * @note In case the given class is also derived from AgentBase::Observer
410 * it gets registered as its own observer (see AgentBase::Observer), e.g.
411 * <tt>agentInstance->registerObserver( agentInstance );</tt>
412 *
413 * @code
414 *
415 * class MyAgent : public AgentBase
416 * {
417 * ...
418 * };
419 *
420 * AKONADI_AGENT_MAIN( MyAgent )
421 *
422 * @endcode
423 *
424 * @param argc number of arguments
425 * @param argv arguments for the function
426 */
427 template<typename T>
428 static int init(int argc, char **argv)
429 {
430 // Disable session management
431 qunsetenv("SESSION_MANAGER");
432
433 QApplication app(argc, argv);
434 debugAgent(argc, argv);
435 const QString id = parseArguments(argc, argv);
436 T r(id);
437
438 // check if T also inherits AgentBase::Observer and
439 // if it does, automatically register it on itself
440 auto observer = dynamic_cast<Observer *>(&r);
441 if (observer != nullptr) {
442 r.registerObserver(observer);
443 }
444 return init(r);
445 }
446
447 /**
448 * This method returns the current status code of the agent.
449 *
450 * The following return values are possible:
451 *
452 * - 0 - Idle
453 * - 1 - Running
454 * - 2 - Broken
455 * - 3 - NotConfigured
456 */
457 [[nodiscard]] virtual int status() const;
458
459 /**
460 * This method returns an i18n'ed description of the current status code.
461 */
462 [[nodiscard]] virtual QString statusMessage() const;
463
464 /**
465 * This method returns the current progress of the agent in percentage.
466 */
467 [[nodiscard]] virtual int progress() const;
468
469 /**
470 * This method returns an i18n'ed description of the current progress.
471 */
472 [[nodiscard]] virtual QString progressMessage() const;
473
474public Q_SLOTS:
475 /**
476 * This method is called whenever the agent shall show its configuration dialog
477 * to the user. It will be automatically called when the agent is started for
478 * the first time.
479 *
480 * @param windowId The parent window id.
481 *
482 * @note If the method is reimplemented it has to emit the configurationDialogAccepted()
483 * or configurationDialogRejected() signals depending on the users choice.
484 */
485 virtual void configure(WId windowId);
486
487public:
488 /**
489 * This method returns the windows id, which should be used for dialogs.
490 */
491 [[nodiscard]] WId winIdForDialogs() const;
492
493#ifdef Q_OS_WIN
494 /**
495 * Overload of @ref configure needed because WId cannot be automatically casted
496 * to qlonglong on Windows.
497 */
498 void configure(qlonglong windowId);
499#endif
500
501 /**
502 * Returns the instance identifier of this agent.
503 */
504 [[nodiscard]] QString identifier() const;
505
506 /**
507 * This method is called when the agent is removed from
508 * the system, so it can do some cleanup stuff.
509 *
510 * @note If you reimplement this in a subclass make sure
511 * to call this base implementation at the end.
512 */
513 virtual void cleanup();
514
515 /**
516 * Registers the given observer for reacting on monitored or recorded changes.
517 *
518 * @param observer The change handler to register. No ownership transfer, i.e.
519 * the caller stays owner of the pointer and can reset
520 * the registration by calling this method with @c 0
521 */
522 void registerObserver(Observer *observer);
523
524 /**
525 * This method is used to set the name of the agent.
526 *
527 * @since 4.3
528 * @param name name of the agent
529 */
530 // FIXME_API: make sure location is renamed to this by agentbase
531 void setAgentName(const QString &name);
532
533 /**
534 * Returns the name of the agent.
535 *
536 * @since 4.3
537 */
538 [[nodiscard]] QString agentName() const;
539
540 /**
541 * This method is used to set the activities of the agent.
542 *
543 * @since 6.3
544 */
545 void setActivities(const QStringList &activities);
546
547 /**
548 * Returns the activities of the agent.
549 *
550 * @since 6.3
551 */
552 [[nodiscard]] QStringList activities() const;
553
554 /**
555 * This method is used to enabled the activities of the agent.
556 *
557 * @since 6.3
558 */
559 void setActivitiesEnabled(bool enabled);
560
561 /**
562 * Returns the activities status of the agent.
563 *
564 * @since 6.3
565 */
566 [[nodiscard]] bool activitiesEnabled() const;
567
568Q_SIGNALS:
569 /**
570 * This signal is emitted whenever the name of the agent has changed.
571 *
572 * @param name The new name of the agent.
573 *
574 * @since 4.3
575 */
576 void agentNameChanged(const QString &name);
577
578 /**
579 * This signal should be emitted whenever the status of the agent has been changed.
580 * @param status The new Status code.
581 * @param message A i18n'ed description of the new status.
582 */
583 void status(int status, const QString &message = QString());
584
585 /**
586 * This signal should be emitted whenever the progress of an action in the agent
587 * (e.g. data transfer, connection establishment to remote server etc.) has changed.
588 *
589 * @param progress The progress of the action in percent.
590 */
591 void percent(int progress);
592
593 /**
594 * This signal shall be used to report warnings.
595 *
596 * @param message The i18n'ed warning message.
597 */
598 void warning(const QString &message);
599
600 /**
601 * This signal shall be used to report errors.
602 *
603 * @param message The i18n'ed error message.
604 */
605 void error(const QString &message);
606
607 /**
608 * This signal should be emitted whenever the status of the agent has been changed.
609 * @param status The object that describes the status change.
610 *
611 * @since 4.6
612 */
614
615 /**
616 * Emitted when another application has remotely asked the agent to abort
617 * its current operation.
618 * Connect to this signal if your agent supports abortion. After aborting
619 * and cleaning up, agents should return to Idle status.
620 *
621 * @since 4.4
622 */
624
625 /**
626 * Emitted if another application has changed the agent's configuration remotely
627 * and called AgentInstance::reconfigure().
628 *
629 * @since 4.2
630 */
632
633 /**
634 * Emitted when the online state changed.
635 * @param online The online state.
636 * @since 4.2
637 */
638 void onlineChanged(bool online);
639
640 /**
641 * This signal is emitted whenever the user has accepted the configuration dialog.
642 *
643 * @note Implementors of agents/resources are responsible to emit this signal if
644 * the agent/resource reimplements configure().
645 *
646 * @since 4.4
647 */
649
650 /**
651 * This signal is emitted whenever the user has rejected the configuration dialog.
652 *
653 * @note Implementors of agents/resources are responsible to emit this signal if
654 * the agent/resource reimplements configure().
655 *
656 * @since 4.4
657 */
659
660 /**
661 * This signal is emitted whenever the user has changed activities.
662 *
663 * @since 6.3
664 */
665 void agentActivitiesChanged(const QStringList &activities);
666
667 /**
668 * This signal is emitted whenever the user has changed enabled activities.
669 *
670 * @since 6.3
671 */
673
674protected:
675 /**
676 * Creates an agent base.
677 *
678 * @param id The instance id of the agent.
679 */
680 AgentBase(const QString &id);
681
682 /**
683 * Destroys the agent base.
684 */
685 ~AgentBase() override;
686
687 /**
688 * This method is called whenever the agent application is about to
689 * quit.
690 *
691 * Reimplement this method to do session cleanup (e.g. disconnecting
692 * from groupware server).
693 */
694 virtual void aboutToQuit();
695
696 /**
697 * Returns the Akonadi::ChangeRecorder object used for monitoring.
698 * Use this to configure which parts you want to monitor.
699 */
700 ChangeRecorder *changeRecorder() const;
701
702 /**
703 * Returns the config object for this Agent.
704 */
705 KSharedConfigPtr config();
706
707 /**
708 * Marks the current change as processes and replays the next change if change
709 * recording is enabled (noop otherwise). This method is called
710 * from the default implementation of the change notification slots. While not
711 * required when not using change recording, it is nevertheless recommended
712 * to call this method when done with processing a change notification.
713 */
714 void changeProcessed();
715
716 /**
717 * Returns whether the agent is currently online.
718 */
719 bool isOnline() const;
720
721 /**
722 * Sets whether the agent needs network or not.
723 *
724 * @since 4.2
725 * @todo use this in combination with QNetworkConfiguration to change
726 * the onLine status of the agent.
727 * @param needsNetwork @c true if the agents needs network. Defaults to @c false
728 */
729 void setNeedsNetwork(bool needsNetwork);
730
731 /**
732 * Sets whether the agent shall be online or not.
733 */
734 void setOnline(bool state);
735
736protected:
737 /**
738 * Sets the agent offline but will make it online again after a given time
739 *
740 * Use this method when the agent detects some problem with its backend but it wants
741 * to retry all pending operations after some time - e.g. a server can not be reached currently
742 *
743 * Example usage:
744 * @code
745 * void ExampleResource::onItemRemovedFinished(KJob *job)
746 * {
747 * if (job->error()) {
748 * Q_EMIT status(Broken, job->errorString());
749 * deferTask();
750 * setTemporaryOffline(300);
751 * return;
752 * }
753 * ...
754 * }
755 * @endcode
756 *
757 * @since 4.13
758 * @param makeOnlineInSeconds timeout in seconds after which the agent changes to online
759 */
760 void setTemporaryOffline(int makeOnlineInSeconds = 300);
761
762 /// @cond PRIVATE
763 static void debugAgent(int argc, char **argv);
764
765 std::unique_ptr<AgentBasePrivate> const d_ptr;
766 explicit AgentBase(AgentBasePrivate *d, const QString &id);
767 friend class ObserverV2;
768 /// @endcond
769
770 /**
771 * This method is called whenever the @p online status has changed.
772 * Reimplement this method to react on online status changes.
773 * @param online online status
774 */
775 virtual void doSetOnline(bool online);
776
777 virtual KAboutData aboutData() const;
778
779private:
780 /// @cond PRIVATE
781 static QString parseArguments(int argc, char **argv);
782 static int init(AgentBase &r);
783 void setOnlineInternal(bool state);
784
785 // D-Bus interface stuff
786 AKONADIAGENTBASE_NO_EXPORT void abort();
787 AKONADIAGENTBASE_NO_EXPORT void reconfigure();
788 AKONADIAGENTBASE_NO_EXPORT void quit();
789
790 // dbus agent interface
791 friend class ::Akonadi__StatusAdaptor;
792 friend class ::Akonadi__ControlAdaptor;
793
794 Q_DECLARE_PRIVATE(AgentBase)
795 Q_PRIVATE_SLOT(d_func(), void delayedInit())
796 Q_PRIVATE_SLOT(d_func(), void slotStatus(int, const QString &))
797 Q_PRIVATE_SLOT(d_func(), void slotPercent(int))
798 Q_PRIVATE_SLOT(d_func(), void slotWarning(const QString &))
799 Q_PRIVATE_SLOT(d_func(), void slotError(const QString &))
800 Q_PRIVATE_SLOT(d_func(), void slotNetworkStatusChange(bool))
801 Q_PRIVATE_SLOT(d_func(), void slotResumedFromSuspend())
802 Q_PRIVATE_SLOT(d_func(), void slotTemporaryOfflineTimeout())
803
804 /// @endcond
805};
806
807}
808
809#ifndef AKONADI_AGENT_MAIN
810/**
811 * Convenience Macro for the most common main() function for Akonadi agents.
812 */
813#define AKONADI_AGENT_MAIN(agentClass) \
814 int main(int argc, char **argv) \
815 { \
816 return Akonadi::AgentBase::init<agentClass>(argc, argv); \
817 }
818#endif
BC extension of Observer with support for monitoring item and collection moves.
Definition agentbase.h:238
BC extension of ObserverV2 with support for batch operations.
Definition agentbase.h:302
The interface for reacting on monitored or replayed changes.
Definition agentbase.h:179
The base class for all Akonadi agents and resources.
Definition agentbase.h:73
void agentActivitiesEnabledChanged(bool enabled)
This signal is emitted whenever the user has changed enabled activities.
void warning(const QString &message)
This signal shall be used to report warnings.
void configurationDialogAccepted()
This signal is emitted whenever the user has accepted the configuration dialog.
void advancedStatus(const QVariantMap &status)
This signal should be emitted whenever the status of the agent has been changed.
void onlineChanged(bool online)
Emitted when the online state changed.
void reloadConfiguration()
Emitted if another application has changed the agent's configuration remotely and called AgentInstanc...
void agentActivitiesChanged(const QStringList &activities)
This signal is emitted whenever the user has changed activities.
~AgentBase() override
Destroys the agent base.
void status(int status, const QString &message=QString())
This signal should be emitted whenever the status of the agent has been changed.
Status
This enum describes the different states the agent can be in.
Definition agentbase.h:396
@ Running
The agent is working on something.
Definition agentbase.h:398
@ Broken
The agent encountered an error state.
Definition agentbase.h:399
void percent(int progress)
This signal should be emitted whenever the progress of an action in the agent (e.g.
void abortRequested()
Emitted when another application has remotely asked the agent to abort its current operation.
static int init(int argc, char **argv)
Use this method in the main function of your agent application to initialize your agent subclass.
Definition agentbase.h:428
void agentNameChanged(const QString &name)
This signal is emitted whenever the name of the agent has changed.
void error(const QString &message)
This signal shall be used to report errors.
void configurationDialogRejected()
This signal is emitted whenever the user has rejected the configuration dialog.
AgentBase(const QString &id)
Creates an agent base.
Records and replays change notification.
Represents a collection of PIM items.
Definition collection.h:62
Represents a PIM item stored in Akonadi storage.
Definition item.h:100
An Akonadi Tag.
Definition tag.h:26
Q_SCRIPTABLE Q_NOREPLY void abort()
Q_SCRIPTABLE CaptureState status()
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 13 2024 11:54:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.