• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.13.3 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 
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:
185  class AKONADI_EXPORT Observer // krazy:exclude=dpointer
186  {
187  public:
191  Observer();
192 
196  virtual ~Observer();
197 
203  virtual void itemAdded( const Akonadi::Item &item, const Akonadi::Collection &collection );
204 
210  virtual void itemChanged( const Akonadi::Item &item, const QSet<QByteArray> &partIdentifiers );
211 
216  virtual void itemRemoved( const Akonadi::Item &item );
217 
223  virtual void collectionAdded( const Akonadi::Collection &collection, const Akonadi::Collection &parent );
224 
229  virtual void collectionChanged( const Akonadi::Collection &collection );
230 
235  virtual void collectionRemoved( const Akonadi::Collection &collection );
236  };
237 
244  class AKONADI_EXPORT ObserverV2 : public Observer // krazy:exclude=dpointer
245  {
246  public:
247  using Observer::collectionChanged;
248 
259  virtual void itemMoved( const Akonadi::Item &item, const Akonadi::Collection &collectionSource,
260  const Akonadi::Collection &collectionDestination );
261 
268  virtual void itemLinked( const Akonadi::Item &item, const Akonadi::Collection &collection );
269 
276  virtual void itemUnlinked( const Akonadi::Item &item, const Akonadi::Collection &collection );
277 
288  virtual void collectionMoved( const Akonadi::Collection &collection, const Akonadi::Collection &collectionSource,
289  const Akonadi::Collection &collectionDestination );
290 
296  virtual void collectionChanged( const Akonadi::Collection &collection, const QSet<QByteArray> &changedAttributes );
297  };
298 
309  class AKONADI_EXPORT ObserverV3 : public ObserverV2 // krazy:exclude=dpointer
310  {
311  public:
323  virtual void itemsFlagsChanged( const Akonadi::Item::List &items, const QSet<QByteArray> &addedFlags, const QSet<QByteArray> &removedFlags );
324 
330  virtual void itemsRemoved( const Akonadi::Item::List &items );
331 
339  virtual void itemsMoved( const Akonadi::Item::List &items, const Akonadi::Collection &sourceCollection,
340  const Akonadi::Collection &destinationCollection );
341 
348  virtual void itemsLinked( const Akonadi::Item::List &items, const Akonadi::Collection &collection );
349 
356  virtual void itemsUnlinked( const Akonadi::Item::List &items, const Akonadi::Collection &collection );
357  };
358 
368  class AKONADI_EXPORT ObserverV4: public ObserverV3 // krazy:exclude=dpointer
369  {
370  public:
376  virtual void tagAdded( const Akonadi::Tag &tag );
377 
383  virtual void tagChanged( const Akonadi::Tag &tag );
384 
394  virtual void tagRemoved( const Akonadi::Tag &tag );
395 
403  virtual void itemsTagsChanged( const Akonadi::Item::List &items, const QSet<Akonadi::Tag> &addedTags, const QSet<Akonadi::Tag> &removedTags );
404  };
405 
410  enum Status {
411  Idle = 0,
412  Running,
413  Broken,
414  NotConfigured
415  };
416 
441  template <typename T>
442  static int init( int argc, char **argv )
443  {
444  const QString id = parseArguments( argc, argv );
445  KApplication app;
446  T* r = new T( id );
447 
448  // check if T also inherits AgentBase::Observer and
449  // if it does, automatically register it on itself
450  Observer *observer = dynamic_cast<Observer*>( r );
451  if ( observer != 0 ) {
452  r->registerObserver( observer );
453  }
454  return init( r );
455  }
456 
467  virtual int status() const;
468 
472  virtual QString statusMessage() const;
473 
477  virtual int progress() const;
478 
482  virtual QString progressMessage() const;
483 
484  public Q_SLOTS:
495  virtual void configure( WId windowId );
496 
497  public:
501  WId winIdForDialogs() const;
502 
503 #ifdef Q_OS_WIN
504 
508  void configure( qlonglong windowId );
509 #endif
510 
514  QString identifier() const;
515 
523  virtual void cleanup();
524 
532  void registerObserver( Observer *observer );
533 
540  //FIXME_API: make sure location is renamed to this by agentbase
541  void setAgentName( const QString &name );
542 
548  QString agentName() const;
549 
558  static KComponentData componentData();
559 
560  Q_SIGNALS:
568  void agentNameChanged( const QString &name );
569 
575  void status( int status, const QString &message = QString() );
576 
583  void percent( int progress );
584 
590  void warning( const QString& message );
591 
597  void error( const QString& message );
598 
605  void advancedStatus( const QVariantMap &status );
606 
615  void abortRequested();
616 
623  void reloadConfiguration();
624 
630  void onlineChanged( bool online );
631 
640  void configurationDialogAccepted();
641 
650  void configurationDialogRejected();
651 
652  protected:
658  AgentBase( const QString & id );
659 
663  ~AgentBase();
664 
672  virtual void aboutToQuit();
673 
678  ChangeRecorder* changeRecorder() const;
679 
683  KSharedConfigPtr config();
684 
692  void changeProcessed();
693 
697  bool isOnline() const;
698 
707  void setNeedsNetwork( bool needsNetwork );
708 
712  void setOnline( bool state );
713 
737  void setTemporaryOffline(int makeOnlineInSeconds = 300);
738 
739  protected:
740  //@cond PRIVATE
741  AgentBasePrivate *d_ptr;
742  explicit AgentBase( AgentBasePrivate* d, const QString &id );
743  friend class ObserverV2;
744  //@endcond
745 
751  virtual void doSetOnline( bool online );
752 
753  private:
754  //@cond PRIVATE
755  static QString parseArguments( int, char** );
756  static int init( AgentBase *r );
757  void setOnlineInternal( bool state );
758 
759  // D-Bus interface stuff
760  void abort();
761  void reconfigure();
762  void quit();
763 
764  // dbus agent interface
765  friend class ::Akonadi__StatusAdaptor;
766  friend class ::Akonadi__ControlAdaptor;
767 
768  Q_DECLARE_PRIVATE( AgentBase )
769  Q_PRIVATE_SLOT( d_func(), void delayedInit() )
770  Q_PRIVATE_SLOT( d_func(), void slotStatus( int, const QString& ) )
771  Q_PRIVATE_SLOT( d_func(), void slotPercent( int ) )
772  Q_PRIVATE_SLOT( d_func(), void slotWarning( const QString& ) )
773  Q_PRIVATE_SLOT( d_func(), void slotError( const QString& ) )
774  Q_PRIVATE_SLOT( d_func(), void slotNetworkStatusChange( Solid::Networking::Status ) )
775  Q_PRIVATE_SLOT( d_func(), void slotResumedFromSuspend() )
776  Q_PRIVATE_SLOT(d_func(), void slotTemporaryOfflineTimeout())
777 
778  //@endcond
779 };
780 
781 }
782 
783 #ifndef AKONADI_AGENT_MAIN
784 
787 #define AKONADI_AGENT_MAIN( agentClass ) \
788  int main( int argc, char **argv ) \
789  { \
790  return Akonadi::AgentBase::init<agentClass>( argc, argv ); \
791  }
792 #endif
793 
794 #endif
Akonadi::AgentBase::Status
Status
This enum describes the different states the agent can be in.
Definition: agentbase.h:410
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
Akonadi::AgentBase::Observer
The interface for reacting on monitored or replayed changes.
Definition: agentbase.h:185
Akonadi::AgentBasePrivate
Definition: agentbase_p.h:39
Akonadi::AgentBase
The base class for all Akonadi agents and resources.
Definition: agentbase.h:80
Akonadi::AgentBase::ObserverV2
BC extension of Observer with support for monitoring item and collection moves.
Definition: agentbase.h:244
Akonadi::AgentBase::ObserverV3
BC extension of ObserverV2 with support for batch operations.
Definition: agentbase.h:309
Akonadi::AgentBase::Broken
The agent encountered an error state.
Definition: agentbase.h:413
Akonadi::AgentBase::ObserverV4
Observer that adds support for item tagging.
Definition: agentbase.h:368
Akonadi::Tag
An Akonadi Tag.
Definition: tag.h:44
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:442
Akonadi::AgentBase::Running
The agent is working on something.
Definition: agentbase.h:412
Akonadi::ChangeRecorder
Records and replays change notification.
Definition: changerecorder.h:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Mon Jul 21 2014 08:03:49 by doxygen 1.8.6 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.13.3 API Reference

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