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

akonadi

  • sources
  • kde-4.12
  • 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:
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 
363  enum Status {
364  Idle = 0,
365  Running,
366  Broken,
367  NotConfigured
368  };
369 
394  template <typename T>
395  static int init( int argc, char **argv )
396  {
397  const QString id = parseArguments( argc, argv );
398  KApplication app;
399  T* r = new T( id );
400 
401  // check if T also inherits AgentBase::Observer and
402  // if it does, automatically register it on itself
403  Observer *observer = dynamic_cast<Observer*>( r );
404  if ( observer != 0 ) {
405  r->registerObserver( observer );
406  }
407  return init( r );
408  }
409 
420  virtual int status() const;
421 
425  virtual QString statusMessage() const;
426 
430  virtual int progress() const;
431 
435  virtual QString progressMessage() const;
436 
437  public Q_SLOTS:
448  virtual void configure( WId windowId );
449 
450  public:
454  WId winIdForDialogs() const;
455 
456 #ifdef Q_OS_WIN
457 
461  void configure( qlonglong windowId );
462 #endif
463 
467  QString identifier() const;
468 
476  virtual void cleanup();
477 
485  void registerObserver( Observer *observer );
486 
493  //FIXME_API: make sure location is renamed to this by agentbase
494  void setAgentName( const QString &name );
495 
501  QString agentName() const;
502 
511  static KComponentData componentData();
512 
513  Q_SIGNALS:
521  void agentNameChanged( const QString &name );
522 
528  void status( int status, const QString &message = QString() );
529 
536  void percent( int progress );
537 
543  void warning( const QString& message );
544 
550  void error( const QString& message );
551 
558  void advancedStatus( const QVariantMap &status );
559 
568  void abortRequested();
569 
576  void reloadConfiguration();
577 
583  void onlineChanged( bool online );
584 
593  void configurationDialogAccepted();
594 
603  void configurationDialogRejected();
604 
605  protected:
611  AgentBase( const QString & id );
612 
616  ~AgentBase();
617 
625  virtual void aboutToQuit();
626 
631  ChangeRecorder* changeRecorder() const;
632 
636  KSharedConfigPtr config();
637 
645  void changeProcessed();
646 
650  bool isOnline() const;
651 
660  void setNeedsNetwork( bool needsNetwork );
661 
665  void setOnline( bool state );
666 
667  protected:
668  //@cond PRIVATE
669  AgentBasePrivate *d_ptr;
670  explicit AgentBase( AgentBasePrivate* d, const QString &id );
671  friend class ObserverV2;
672  //@endcond
673 
679  virtual void doSetOnline( bool online );
680 
681  private:
682  //@cond PRIVATE
683  static QString parseArguments( int, char** );
684  static int init( AgentBase *r );
685  void setOnlineInternal( bool state );
686 
687  // D-Bus interface stuff
688  void abort();
689  void reconfigure();
690  void quit();
691 
692  // dbus agent interface
693  friend class ::Akonadi__StatusAdaptor;
694  friend class ::Akonadi__ControlAdaptor;
695 
696  Q_DECLARE_PRIVATE( AgentBase )
697  Q_PRIVATE_SLOT( d_func(), void delayedInit() )
698  Q_PRIVATE_SLOT( d_func(), void slotStatus( int, const QString& ) )
699  Q_PRIVATE_SLOT( d_func(), void slotPercent( int ) )
700  Q_PRIVATE_SLOT( d_func(), void slotWarning( const QString& ) )
701  Q_PRIVATE_SLOT( d_func(), void slotError( const QString& ) )
702  Q_PRIVATE_SLOT( d_func(), void slotNetworkStatusChange( Solid::Networking::Status ) )
703  Q_PRIVATE_SLOT( d_func(), void slotResumedFromSuspend() )
704 
705  //@endcond
706 };
707 
708 }
709 
710 #ifndef AKONADI_AGENT_MAIN
711 
714 #define AKONADI_AGENT_MAIN( agentClass ) \
715  int main( int argc, char **argv ) \
716  { \
717  return Akonadi::AgentBase::init<agentClass>( argc, argv ); \
718  }
719 #endif
720 
721 #endif
Akonadi::AgentBase::Status
Status
This enum describes the different states the agent can be in.
Definition: agentbase.h:363
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:38
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:366
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:395
Akonadi::AgentBase::Running
The agent is working on something.
Definition: agentbase.h:365
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 Tue Oct 14 2014 23:00:26 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
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

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