• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

akonadi

agentbase.h

00001 /*
00002     This file is part of akonadiresources.
00003 
00004     Copyright (c) 2006 Till Adam <adam@kde.org>
00005     Copyright (c) 2007 Volker Krause <vkrause@kde.org>
00006     Copyright (c) 2008 Kevin Krammer <kevin.krammer@gmx.at>
00007 
00008     This library is free software; you can redistribute it and/or modify it
00009     under the terms of the GNU Library General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or (at your
00011     option) any later version.
00012 
00013     This library is distributed in the hope that it will be useful, but WITHOUT
00014     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00016     License for more details.
00017 
00018     You should have received a copy of the GNU Library General Public License
00019     along with this library; see the file COPYING.LIB.  If not, write to the
00020     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00021     02110-1301, USA.
00022 */
00023 
00024 #ifndef AKONADI_AGENTBASE_H
00025 #define AKONADI_AGENTBASE_H
00026 
00027 #include "akonadi_export.h"
00028 
00029 #include <KDE/KApplication>
00030 
00031 #include <QtDBus/QDBusContext>
00032 
00033 class ControlAdaptor;
00034 class StatusAdaptor;
00035 
00036 namespace Akonadi {
00037 
00038 class AgentBasePrivate;
00039 class ChangeRecorder;
00040 class Collection;
00041 class Item;
00042 class Session;
00043 
00058 class AKONADI_EXPORT AgentBase : public QObject, protected QDBusContext
00059 {
00060   Q_OBJECT
00061 
00062   public:
00159     class AKONADI_EXPORT Observer  // krazy:exclude=dpointer
00160     {
00161       public:
00165         Observer();
00166 
00170         virtual ~Observer();
00171 
00177         virtual void itemAdded( const Akonadi::Item &item, const Akonadi::Collection &collection );
00178 
00184         virtual void itemChanged( const Akonadi::Item &item, const QSet<QByteArray> &partIdentifiers );
00185 
00190         virtual void itemRemoved( const Akonadi::Item &item );
00191 
00197         virtual void collectionAdded( const Akonadi::Collection &collection, const Akonadi::Collection &parent );
00198 
00203         virtual void collectionChanged( const Akonadi::Collection &collection );
00204 
00209         virtual void collectionRemoved( const Akonadi::Collection &collection );
00210     };
00211 
00218     class AKONADI_EXPORT ObserverV2 : public Observer  // krazy:exclude=dpointer
00219     {
00220       public:
00221         using Observer::collectionChanged;
00222 
00233         virtual void itemMoved( const Akonadi::Item &item, const Akonadi::Collection &collectionSource,
00234                                 const Akonadi::Collection &collectionDestination );
00235 
00242         virtual void itemLinked( const Akonadi::Item &item, const Akonadi::Collection &collection );
00243 
00250         virtual void itemUnlinked( const Akonadi::Item &item, const Akonadi::Collection &collection );
00251 
00262         virtual void collectionMoved( const Akonadi::Collection &collection, const Akonadi::Collection &collectionSource,
00263                                       const Akonadi::Collection &collectionDestination );
00264 
00270         virtual void collectionChanged( const Akonadi::Collection &collection, const QSet<QByteArray> &changedAttributes );
00271     };
00272 
00277     enum Status
00278     {
00279       Idle = 0, 
00280       Running,  
00281       Broken    
00282     };
00283 
00305     template <typename T>
00306     static int init( int argc, char **argv )
00307     {
00308       const QString id = parseArguments( argc, argv );
00309       KApplication app;
00310       T* r = new T( id );
00311 
00312       // check if T also inherits AgentBase::Observer and
00313       // if it does, automatically register it on itself
00314       Observer *observer = dynamic_cast<Observer*>( r );
00315       if ( observer != 0 )
00316         r->registerObserver( observer );
00317       return init( r );
00318     }
00319 
00329     virtual int status() const;
00330 
00334     virtual QString statusMessage() const;
00335 
00339     virtual int progress() const;
00340 
00344     virtual QString progressMessage() const;
00345 
00356     virtual void configure( WId windowId );
00357 
00361     WId winIdForDialogs() const;
00362 
00363 #ifdef Q_OS_WIN
00364 
00368     void configure( qlonglong windowId );
00369 #endif
00370 
00374     QString identifier() const;
00375 
00383     virtual void cleanup();
00384 
00392     void registerObserver( Observer *observer );
00393 
00399     //FIXME_API: make sure location is renamed to this by agentbase
00400     void setAgentName( const QString &name );
00401 
00407     QString agentName() const;
00408 
00409   Q_SIGNALS:
00417     void agentNameChanged( const QString &name );
00418 
00424     void status( int status, const QString &message = QString() );
00425 
00432     void percent( int progress );
00433 
00439     void warning( const QString& message );
00440 
00446     void error( const QString& message );
00447 
00456     void abortRequested();
00457 
00464     void reloadConfiguration();
00465 
00471     void onlineChanged( bool b );
00472 
00481     void configurationDialogAccepted();
00482 
00491     void configurationDialogRejected();
00492 
00493   protected:
00499     AgentBase( const QString & id );
00500 
00504     ~AgentBase();
00505 
00513     virtual void aboutToQuit();
00514 
00519     ChangeRecorder* changeRecorder() const;
00520 
00528     void changeProcessed();
00529 
00533     bool isOnline() const;
00534 
00542     void setNeedsNetwork( bool needsNetwork );
00543 
00547     void setOnline( bool state );
00548 
00549   protected:
00550     //@cond PRIVATE
00551     AgentBasePrivate *d_ptr;
00552     explicit AgentBase( AgentBasePrivate* d, const QString &id );
00553     //@endcond
00554 
00559     virtual void doSetOnline( bool online );
00560 
00561   private:
00562     //@cond PRIVATE
00563     static QString parseArguments( int, char** );
00564     static int init( AgentBase *r );
00565 
00566     // D-Bus interface stuff
00567     void abort();
00568     void reconfigure();
00569     void quit();
00570 
00571     // dbus agent interface
00572     friend class ::StatusAdaptor;
00573     friend class ::ControlAdaptor;
00574 
00575     Q_DECLARE_PRIVATE( AgentBase )
00576     Q_PRIVATE_SLOT( d_func(), void delayedInit() )
00577     Q_PRIVATE_SLOT( d_func(), void slotStatus( int, const QString& ) )
00578     Q_PRIVATE_SLOT( d_func(), void slotPercent( int ) )
00579     Q_PRIVATE_SLOT( d_func(), void slotWarning( const QString& ) )
00580     Q_PRIVATE_SLOT( d_func(), void slotError( const QString& ) )
00581     Q_PRIVATE_SLOT( d_func(), void slotNetworkStatusChange( Solid::Networking::Status ) )
00582 
00583     //@endcond
00584 };
00585 
00586 }
00587 
00588 #ifndef AKONADI_AGENT_MAIN
00589 
00592 #define AKONADI_AGENT_MAIN( agentClass )                       \
00593   int main( int argc, char **argv )                            \
00594   {                                                            \
00595     return Akonadi::AgentBase::init<agentClass>( argc, argv ); \
00596   }
00597 #endif
00598 
00599 #endif

akonadi

Skip menu "akonadi"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal