• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 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  Idle = 0,
304  Running,
305  Broken,
306  NotConfigured
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  }
343  return init( r );
344  }
345 
356  virtual int status() const;
357 
361  virtual QString statusMessage() const;
362 
366  virtual int progress() const;
367 
371  virtual QString progressMessage() const;
372 
373  public Q_SLOTS:
384  virtual void configure( WId windowId );
385 
386  public:
390  WId winIdForDialogs() const;
391 
392 #ifdef Q_OS_WIN
393 
397  void configure( qlonglong windowId );
398 #endif
399 
403  QString identifier() const;
404 
412  virtual void cleanup();
413 
421  void registerObserver( Observer *observer );
422 
428  //FIXME_API: make sure location is renamed to this by agentbase
429  void setAgentName( const QString &name );
430 
436  QString agentName() const;
437 
446  static KComponentData componentData();
447 
448  Q_SIGNALS:
456  void agentNameChanged( const QString &name );
457 
463  void status( int status, const QString &message = QString() );
464 
471  void percent( int progress );
472 
478  void warning( const QString& message );
479 
485  void error( const QString& message );
486 
493  void advancedStatus( const QVariantMap &status );
494 
503  void abortRequested();
504 
511  void reloadConfiguration();
512 
518  void onlineChanged( bool online );
519 
528  void configurationDialogAccepted();
529 
538  void configurationDialogRejected();
539 
540  protected:
546  AgentBase( const QString & id );
547 
551  ~AgentBase();
552 
560  virtual void aboutToQuit();
561 
566  ChangeRecorder* changeRecorder() const;
567 
571  KSharedConfigPtr config();
572 
580  void changeProcessed();
581 
585  bool isOnline() const;
586 
594  void setNeedsNetwork( bool needsNetwork );
595 
599  void setOnline( bool state );
600 
601  protected:
602  //@cond PRIVATE
603  AgentBasePrivate *d_ptr;
604  explicit AgentBase( AgentBasePrivate* d, const QString &id );
605  friend class ObserverV2;
606  //@endcond
607 
612  virtual void doSetOnline( bool online );
613 
614  private:
615  //@cond PRIVATE
616  static QString parseArguments( int, char** );
617  static int init( AgentBase *r );
618  void setOnlineInternal( bool state );
619 
620  // D-Bus interface stuff
621  void abort();
622  void reconfigure();
623  void quit();
624 
625  // dbus agent interface
626  friend class ::Akonadi__StatusAdaptor;
627  friend class ::Akonadi__ControlAdaptor;
628 
629  Q_DECLARE_PRIVATE( AgentBase )
630  Q_PRIVATE_SLOT( d_func(), void delayedInit() )
631  Q_PRIVATE_SLOT( d_func(), void slotStatus( int, const QString& ) )
632  Q_PRIVATE_SLOT( d_func(), void slotPercent( int ) )
633  Q_PRIVATE_SLOT( d_func(), void slotWarning( const QString& ) )
634  Q_PRIVATE_SLOT( d_func(), void slotError( const QString& ) )
635  Q_PRIVATE_SLOT( d_func(), void slotNetworkStatusChange( Solid::Networking::Status ) )
636  Q_PRIVATE_SLOT( d_func(), void slotResumedFromSuspend() )
637 
638  //@endcond
639 };
640 
641 }
642 
643 #ifndef AKONADI_AGENT_MAIN
644 
647 #define AKONADI_AGENT_MAIN( agentClass ) \
648  int main( int argc, char **argv ) \
649  { \
650  return Akonadi::AgentBase::init<agentClass>( argc, argv ); \
651  }
652 #endif
653 
654 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:27:31 by doxygen 1.8.3.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.10.5 API Reference

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