• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.9.1 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 
29 #include <KDE/KApplication>
30 
31 #include <QtDBus/QDBusConnection>
32 #include <QtDBus/QDBusContext>
33 
34 class Akonadi__ControlAdaptor;
35 class Akonadi__StatusAdaptor;
36 
37 namespace Akonadi {
38 
39 class AgentBasePrivate;
40 class ChangeRecorder;
41 class Collection;
42 class Item;
43 class Session;
44 
79 class AKONADI_EXPORT AgentBase : public QObject, protected QDBusContext
80 {
81  Q_OBJECT
82 
83  public:
184  class AKONADI_EXPORT Observer // krazy:exclude=dpointer
185  {
186  public:
190  Observer();
191 
195  virtual ~Observer();
196 
202  virtual void itemAdded( const Akonadi::Item &item, const Akonadi::Collection &collection );
203 
209  virtual void itemChanged( const Akonadi::Item &item, const QSet<QByteArray> &partIdentifiers );
210 
215  virtual void itemRemoved( const Akonadi::Item &item );
216 
222  virtual void collectionAdded( const Akonadi::Collection &collection, const Akonadi::Collection &parent );
223 
228  virtual void collectionChanged( const Akonadi::Collection &collection );
229 
234  virtual void collectionRemoved( const Akonadi::Collection &collection );
235  };
236 
243  class AKONADI_EXPORT ObserverV2 : public Observer // krazy:exclude=dpointer
244  {
245  public:
246  using Observer::collectionChanged;
247 
258  virtual void itemMoved( const Akonadi::Item &item, const Akonadi::Collection &collectionSource,
259  const Akonadi::Collection &collectionDestination );
260 
267  virtual void itemLinked( const Akonadi::Item &item, const Akonadi::Collection &collection );
268 
275  virtual void itemUnlinked( const Akonadi::Item &item, const Akonadi::Collection &collection );
276 
287  virtual void collectionMoved( const Akonadi::Collection &collection, const Akonadi::Collection &collectionSource,
288  const Akonadi::Collection &collectionDestination );
289 
295  virtual void collectionChanged( const Akonadi::Collection &collection, const QSet<QByteArray> &changedAttributes );
296  };
297 
302  enum Status
303  {
304  Idle = 0,
305  Running,
306  Broken
307  };
308 
330  template <typename T>
331  static int init( int argc, char **argv )
332  {
333  const QString id = parseArguments( argc, argv );
334  KApplication app;
335  T* r = new T( id );
336 
337  // check if T also inherits AgentBase::Observer and
338  // if it does, automatically register it on itself
339  Observer *observer = dynamic_cast<Observer*>( r );
340  if ( observer != 0 )
341  r->registerObserver( observer );
342  return init( r );
343  }
344 
354  virtual int status() const;
355 
359  virtual QString statusMessage() const;
360 
364  virtual int progress() const;
365 
369  virtual QString progressMessage() const;
370 
371  public Q_SLOTS:
382  virtual void configure( WId windowId );
383 
384  public:
388  WId winIdForDialogs() const;
389 
390 #ifdef Q_OS_WIN
391 
395  void configure( qlonglong windowId );
396 #endif
397 
401  QString identifier() const;
402 
410  virtual void cleanup();
411 
419  void registerObserver( Observer *observer );
420 
426  //FIXME_API: make sure location is renamed to this by agentbase
427  void setAgentName( const QString &name );
428 
434  QString agentName() const;
435 
444  static KComponentData componentData();
445 
446  Q_SIGNALS:
454  void agentNameChanged( const QString &name );
455 
461  void status( int status, const QString &message = QString() );
462 
469  void percent( int progress );
470 
476  void warning( const QString& message );
477 
483  void error( const QString& message );
484 
491  void advancedStatus( const QVariantMap &status );
492 
501  void abortRequested();
502 
509  void reloadConfiguration();
510 
516  void onlineChanged( bool online );
517 
526  void configurationDialogAccepted();
527 
536  void configurationDialogRejected();
537 
538  protected:
544  AgentBase( const QString & id );
545 
549  ~AgentBase();
550 
558  virtual void aboutToQuit();
559 
564  ChangeRecorder* changeRecorder() const;
565 
569  KSharedConfigPtr config();
570 
578  void changeProcessed();
579 
583  bool isOnline() const;
584 
592  void setNeedsNetwork( bool needsNetwork );
593 
597  void setOnline( bool state );
598 
599  protected:
600  //@cond PRIVATE
601  AgentBasePrivate *d_ptr;
602  explicit AgentBase( AgentBasePrivate* d, const QString &id );
603  friend class ObserverV2;
604  //@endcond
605 
610  virtual void doSetOnline( bool online );
611 
612  private:
613  //@cond PRIVATE
614  static QString parseArguments( int, char** );
615  static int init( AgentBase *r );
616 
617  // D-Bus interface stuff
618  void abort();
619  void reconfigure();
620  void quit();
621 
622  // dbus agent interface
623  friend class ::Akonadi__StatusAdaptor;
624  friend class ::Akonadi__ControlAdaptor;
625 
626  Q_DECLARE_PRIVATE( AgentBase )
627  Q_PRIVATE_SLOT( d_func(), void delayedInit() )
628  Q_PRIVATE_SLOT( d_func(), void slotStatus( int, const QString& ) )
629  Q_PRIVATE_SLOT( d_func(), void slotPercent( int ) )
630  Q_PRIVATE_SLOT( d_func(), void slotWarning( const QString& ) )
631  Q_PRIVATE_SLOT( d_func(), void slotError( const QString& ) )
632  Q_PRIVATE_SLOT( d_func(), void slotNetworkStatusChange( Solid::Networking::Status ) )
633  Q_PRIVATE_SLOT( d_func(), void slotResumedFromSuspend() )
634 
635  //@endcond
636 };
637 
638 }
639 
640 #ifndef AKONADI_AGENT_MAIN
641 
644 #define AKONADI_AGENT_MAIN( agentClass ) \
645  int main( int argc, char **argv ) \
646  { \
647  return Akonadi::AgentBase::init<agentClass>( argc, argv ); \
648  }
649 #endif
650 
651 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Sep 24 2012 09:06:24 by doxygen 1.8.1.1 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.9.1 API Reference

Skip menu "kdepimlibs-4.9.1 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • 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