• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • akonadi
agentbase.h
1/*
2 This file is part of akonadiresources.
3
4 Copyright (c) 2006 Till Adam <adam@kde.org>
5 Copyright (c) 2007 Volker Krause <vkrause@kde.org>
6 Copyright (c) 2008 Kevin Krammer <kevin.krammer@gmx.at>
7
8 This library is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Library General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or (at your
11 option) any later version.
12
13 This library is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
16 License for more details.
17
18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to the
20 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 02110-1301, USA.
22*/
23
24#ifndef AKONADI_AGENTBASE_H
25#define AKONADI_AGENTBASE_H
26
27#include "akonadi_export.h"
28#include <akonadi/item.h>
29
30#include <KDE/KApplication>
31
32#include <QtDBus/QDBusConnection>
33#include <QtDBus/QDBusContext>
34
35class Akonadi__ControlAdaptor;
36class Akonadi__StatusAdaptor;
37
38namespace Akonadi {
39
40class AgentBasePrivate;
41class ChangeRecorder;
42class Collection;
43class Item;
44class Session;
45
80class AKONADI_EXPORT AgentBase : public QObject, protected QDBusContext
81{
82 Q_OBJECT
83
84public:
186 class AKONADI_EXPORT Observer // krazy:exclude=dpointer
187 {
188 public:
192 Observer();
193
197 virtual ~Observer();
198
204 virtual void itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection);
205
211 virtual void itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &partIdentifiers);
212
217 virtual void itemRemoved(const Akonadi::Item &item);
218
224 virtual void collectionAdded(const Akonadi::Collection &collection, const Akonadi::Collection &parent);
225
230 virtual void collectionChanged(const Akonadi::Collection &collection);
231
236 virtual void collectionRemoved(const Akonadi::Collection &collection);
237 };
238
245 class AKONADI_EXPORT ObserverV2 : public Observer // krazy:exclude=dpointer
246 {
247 public:
248 using Observer::collectionChanged;
249
260 virtual void itemMoved(const Akonadi::Item &item, const Akonadi::Collection &collectionSource,
261 const Akonadi::Collection &collectionDestination);
262
269 virtual void itemLinked(const Akonadi::Item &item, const Akonadi::Collection &collection);
270
277 virtual void itemUnlinked(const Akonadi::Item &item, const Akonadi::Collection &collection);
278
289 virtual void collectionMoved(const Akonadi::Collection &collection, const Akonadi::Collection &collectionSource,
290 const Akonadi::Collection &collectionDestination);
291
297 virtual void collectionChanged(const Akonadi::Collection &collection, const QSet<QByteArray> &changedAttributes);
298 };
299
310 class AKONADI_EXPORT ObserverV3 : public ObserverV2 // krazy:exclude=dpointer
311 {
312 public:
324 virtual void itemsFlagsChanged(const Akonadi::Item::List &items, const QSet<QByteArray> &addedFlags, const QSet<QByteArray> &removedFlags);
325
331 virtual void itemsRemoved(const Akonadi::Item::List &items);
332
340 virtual void itemsMoved(const Akonadi::Item::List &items, const Akonadi::Collection &sourceCollection,
341 const Akonadi::Collection &destinationCollection);
342
349 virtual void itemsLinked(const Akonadi::Item::List &items, const Akonadi::Collection &collection);
350
357 virtual void itemsUnlinked(const Akonadi::Item::List &items, const Akonadi::Collection &collection);
358 };
359
369 class AKONADI_EXPORT ObserverV4 : public ObserverV3 // krazy:exclude=dpointer
370 {
371 public:
377 virtual void tagAdded(const Akonadi::Tag &tag);
378
384 virtual void tagChanged(const Akonadi::Tag &tag);
385
395 virtual void tagRemoved(const Akonadi::Tag &tag);
396
404 virtual void itemsTagsChanged(const Akonadi::Item::List &items, const QSet<Akonadi::Tag> &addedTags, const QSet<Akonadi::Tag> &removedTags);
405 };
406
411 enum Status {
412 Idle = 0,
413 Running,
414 Broken,
415 NotConfigured
416 };
417
442 template <typename T>
443 static int init(int argc, char **argv)
444 {
445 const QString id = parseArguments(argc, argv);
446 KApplication app;
447 T *r = new T(id);
448
449 // check if T also inherits AgentBase::Observer and
450 // if it does, automatically register it on itself
451 Observer *observer = dynamic_cast<Observer *>(r);
452 if (observer != 0) {
453 r->registerObserver(observer);
454 }
455 return init(r);
456 }
457
468 virtual int status() const;
469
473 virtual QString statusMessage() const;
474
478 virtual int progress() const;
479
483 virtual QString progressMessage() const;
484
485public Q_SLOTS:
496 virtual void configure(WId windowId);
497
498public:
502 WId winIdForDialogs() const;
503
504#ifdef Q_OS_WIN
509 void configure(qlonglong windowId);
510#endif
511
515 QString identifier() const;
516
524 virtual void cleanup();
525
533 void registerObserver(Observer *observer);
534
541 //FIXME_API: make sure location is renamed to this by agentbase
542 void setAgentName(const QString &name);
543
549 QString agentName() const;
550
559 static KComponentData componentData();
560
561Q_SIGNALS:
569 void agentNameChanged(const QString &name);
570
576 void status(int status, const QString &message = QString());
577
584 void percent(int progress);
585
591 void warning(const QString &message);
592
598 void error(const QString &message);
599
606 void advancedStatus(const QVariantMap &status);
607
616 void abortRequested();
617
624 void reloadConfiguration();
625
631 void onlineChanged(bool online);
632
641 void configurationDialogAccepted();
642
651 void configurationDialogRejected();
652
653protected:
659 AgentBase(const QString &id);
660
664 ~AgentBase();
665
673 virtual void aboutToQuit();
674
679 ChangeRecorder *changeRecorder() const;
680
684 KSharedConfigPtr config();
685
693 void changeProcessed();
694
698 bool isOnline() const;
699
708 void setNeedsNetwork(bool needsNetwork);
709
713 void setOnline(bool state);
714
715protected:
739 void setTemporaryOffline(int makeOnlineInSeconds = 300);
740
741 //@cond PRIVATE
742 AgentBasePrivate *d_ptr;
743 explicit AgentBase(AgentBasePrivate *d, const QString &id);
744 friend class ObserverV2;
745 //@endcond
746
752 virtual void doSetOnline(bool online);
753
754private:
755 //@cond PRIVATE
756 static QString parseArguments(int, char **);
757 static int init(AgentBase *r);
758 void setOnlineInternal(bool state);
759
760 // D-Bus interface stuff
761 void abort();
762 void reconfigure();
763 void quit();
764
765 // dbus agent interface
766 friend class ::Akonadi__StatusAdaptor;
767 friend class ::Akonadi__ControlAdaptor;
768
769 Q_DECLARE_PRIVATE(AgentBase)
770 Q_PRIVATE_SLOT(d_func(), void delayedInit())
771 Q_PRIVATE_SLOT(d_func(), void slotStatus(int, const QString &))
772 Q_PRIVATE_SLOT(d_func(), void slotPercent(int))
773 Q_PRIVATE_SLOT(d_func(), void slotWarning(const QString &))
774 Q_PRIVATE_SLOT(d_func(), void slotError(const QString &))
775 Q_PRIVATE_SLOT(d_func(), void slotNetworkStatusChange(Solid::Networking::Status))
776 Q_PRIVATE_SLOT(d_func(), void slotResumedFromSuspend())
777 Q_PRIVATE_SLOT(d_func(), void slotTemporaryOfflineTimeout())
778
779 //@endcond
780};
781
782}
783
784#ifndef AKONADI_AGENT_MAIN
788#define AKONADI_AGENT_MAIN( agentClass ) \
789 int main( int argc, char **argv ) \
790 { \
791 return Akonadi::AgentBase::init<agentClass>( argc, argv ); \
792 }
793#endif
794
795#endif
Akonadi::AgentBasePrivate
Definition: agentbase_p.h:40
Akonadi::AgentBase::ObserverV2
BC extension of Observer with support for monitoring item and collection moves.
Definition: agentbase.h:246
Akonadi::AgentBase::ObserverV3
BC extension of ObserverV2 with support for batch operations.
Definition: agentbase.h:311
Akonadi::AgentBase::ObserverV4
Observer that adds support for item tagging.
Definition: agentbase.h:370
Akonadi::AgentBase::Observer
The interface for reacting on monitored or replayed changes.
Definition: agentbase.h:187
Akonadi::AgentBase
The base class for all Akonadi agents and resources.
Definition: agentbase.h:81
Akonadi::AgentBase::warning
void warning(const QString &message)
This signal shall be used to report warnings.
Akonadi::AgentBase::setOnline
void setOnline(bool state)
Sets whether the agent shall be online or not.
Akonadi::AgentBase::~AgentBase
~AgentBase()
Destroys the agent base.
Akonadi::AgentBase::configurationDialogAccepted
void configurationDialogAccepted()
This signal is emitted whenever the user has accepted the configuration dialog.
Akonadi::AgentBase::aboutToQuit
virtual void aboutToQuit()
This method is called whenever the agent application is about to quit.
Akonadi::AgentBase::advancedStatus
void advancedStatus(const QVariantMap &status)
This signal should be emitted whenever the status of the agent has been changed.
Akonadi::AgentBase::setTemporaryOffline
void setTemporaryOffline(int makeOnlineInSeconds=300)
Sets the agent offline but will make it online again after a given time.
Akonadi::AgentBase::onlineChanged
void onlineChanged(bool online)
Emitted when the online state changed.
Akonadi::AgentBase::status
virtual int status() const
This method returns the current status code of the agent.
Akonadi::AgentBase::reloadConfiguration
void reloadConfiguration()
Emitted if another application has changed the agent's configuration remotely and called AgentInstanc...
Akonadi::AgentBase::progressMessage
virtual QString progressMessage() const
This method returns an i18n'ed description of the current progress.
Akonadi::AgentBase::winIdForDialogs
WId winIdForDialogs() const
This method returns the windows id, which should be used for dialogs.
Akonadi::AgentBase::configure
virtual void configure(WId windowId)
This method is called whenever the agent shall show its configuration dialog to the user.
Akonadi::AgentBase::isOnline
bool isOnline() const
Returns whether the agent is currently online.
Akonadi::AgentBase::status
void status(int status, const QString &message=QString())
This signal should be emitted whenever the status of the agent has been changed.
Akonadi::AgentBase::Status
Status
This enum describes the different states the agent can be in.
Definition: agentbase.h:411
Akonadi::AgentBase::Running
@ Running
The agent is working on something.
Definition: agentbase.h:413
Akonadi::AgentBase::Broken
@ Broken
The agent encountered an error state.
Definition: agentbase.h:414
Akonadi::AgentBase::percent
void percent(int progress)
This signal should be emitted whenever the progress of an action in the agent (e.g.
Akonadi::AgentBase::cleanup
virtual void cleanup()
This method is called when the agent is removed from the system, so it can do some cleanup stuff.
Akonadi::AgentBase::abortRequested
void abortRequested()
Emitted when another application has remotely asked the agent to abort its current operation.
Akonadi::AgentBase::setNeedsNetwork
void setNeedsNetwork(bool needsNetwork)
Sets whether the agent needs network or not.
Akonadi::AgentBase::doSetOnline
virtual void doSetOnline(bool online)
This method is called whenever the online status has changed.
Akonadi::AgentBase::statusMessage
virtual QString statusMessage() const
This method returns an i18n'ed description of the current status code.
Akonadi::AgentBase::progress
virtual int progress() const
This method returns the current progress of the agent in percentage.
Akonadi::AgentBase::agentNameChanged
void agentNameChanged(const QString &name)
This signal is emitted whenever the name of the agent has changed.
Akonadi::AgentBase::init
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:443
Akonadi::AgentBase::error
void error(const QString &message)
This signal shall be used to report errors.
Akonadi::AgentBase::configurationDialogRejected
void configurationDialogRejected()
This signal is emitted whenever the user has rejected the configuration dialog.
Akonadi::AgentBase::AgentBase
AgentBase(const QString &id)
Creates an agent base.
Akonadi::ChangeRecorder
Records and replays change notification.
Definition: changerecorder.h:48
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:76
Akonadi::Tag
An Akonadi Tag.
Definition: tag.h:44
Akonadi
FreeBusyManager::Singleton.
Definition: actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal