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

akonadi

  • sources
  • kde-4.14
  • kdepimlibs
  • 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 
35 class Akonadi__ControlAdaptor;
36 class Akonadi__StatusAdaptor;
37 
38 namespace Akonadi {
39 
40 class AgentBasePrivate;
41 class ChangeRecorder;
42 class Collection;
43 class Item;
44 class Session;
45 
80 class AKONADI_EXPORT AgentBase : public QObject, protected QDBusContext
81 {
82  Q_OBJECT
83 
84 public:
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 
485 public Q_SLOTS:
496  virtual void configure(WId windowId);
497 
498 public:
502  WId winIdForDialogs() const;
503 
504 #ifdef Q_OS_WIN
505 
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 
561 Q_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 
653 protected:
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 
715 protected:
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 
754 private:
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
785 
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::AgentBase::Status
Status
This enum describes the different states the agent can be in.
Definition: agentbase.h:411
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
QMap
Akonadi::AgentBase::Observer
The interface for reacting on monitored or replayed changes.
Definition: agentbase.h:186
Akonadi::AgentBasePrivate
Definition: agentbase_p.h:39
Akonadi::AgentBase
The base class for all Akonadi agents and resources.
Definition: agentbase.h:80
QDBusContext
QObject
Akonadi::AgentBase::ObserverV2
BC extension of Observer with support for monitoring item and collection moves.
Definition: agentbase.h:245
QSet< QByteArray >
QString
Akonadi::AgentBase::ObserverV3
BC extension of ObserverV2 with support for batch operations.
Definition: agentbase.h:310
Akonadi::AgentBase::Broken
The agent encountered an error state.
Definition: agentbase.h:414
Akonadi::AgentBase::ObserverV4
Observer that adds support for item tagging.
Definition: agentbase.h:369
Akonadi::Tag
An Akonadi Tag.
Definition: tag.h:43
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::Running
The agent is working on something.
Definition: agentbase.h:413
Akonadi::ChangeRecorder
Records and replays change notification.
Definition: changerecorder.h:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:02 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs 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

Search



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