• Skip to content
  • Skip to link menu
KDE 4.1 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:
00157     class AKONADI_EXPORT Observer  // krazy:exclude=dpointer
00158     {
00159       public:
00163         Observer();
00164 
00168         virtual ~Observer();
00169 
00175         virtual void itemAdded( const Akonadi::Item &item, const Akonadi::Collection &collection );
00176 
00182         virtual void itemChanged( const Akonadi::Item &item, const QSet<QByteArray> &partIdentifiers );
00183 
00188         virtual void itemRemoved( const Akonadi::Item &item );
00189 
00195         virtual void collectionAdded( const Akonadi::Collection &collection, const Akonadi::Collection &parent );
00196 
00201         virtual void collectionChanged( const Akonadi::Collection &collection );
00202 
00207         virtual void collectionRemoved( const Akonadi::Collection &collection );
00208     };
00209 
00214     enum Status
00215     {
00216       Idle = 0, 
00217       Running,  
00218       Broken    
00219     };
00220 
00242     template <typename T>
00243     static int init( int argc, char **argv )
00244     {
00245       const QString id = parseArguments( argc, argv );
00246       KApplication app;
00247       T* r = new T( id );
00248 
00249       // check if T also inherits AgentBase::Observer and
00250       // if it does, automatically register it on itself
00251       Observer *observer = dynamic_cast<Observer*>( r );
00252       if ( observer != 0 )
00253         r->registerObserver( observer );
00254       return init( r );
00255     }
00256 
00266     virtual int status() const;
00267 
00271     virtual QString statusMessage() const;
00272 
00276     virtual int progress() const;
00277 
00281     virtual QString progressMessage() const;
00282 
00289     virtual void configure( WId windowId );
00290 
00294     WId winIdForDialogs() const;
00295 
00296 #ifdef Q_OS_WIN
00297 
00301     void configure( qlonglong windowId );
00302 #endif
00303 
00307     QString identifier() const;
00308 
00313     virtual void cleanup();
00314 
00322     void registerObserver( Observer *observer );
00323 
00324   Q_SIGNALS:
00330     void status( int status, const QString &message = QString() );
00331 
00338     void percent( int progress );
00339 
00345     void warning( const QString& message );
00346 
00352     void error( const QString& message );
00353 
00354   protected:
00360     AgentBase( const QString & id );
00361 
00365     ~AgentBase();
00366 
00374     virtual void aboutToQuit();
00375 
00380     ChangeRecorder* changeRecorder() const;
00381 
00389     void changeProcessed();
00390 
00394     bool isOnline() const;
00395 
00399     void setOnline( bool state );
00400 
00401   protected:
00402     //@cond PRIVATE
00403     AgentBasePrivate *d_ptr;
00404     explicit AgentBase( AgentBasePrivate* d, const QString &id );
00405     //@endcond
00406 
00411     virtual void doSetOnline( bool online );
00412 
00413   private:
00414     //@cond PRIVATE
00415     static QString parseArguments( int, char** );
00416     static int init( AgentBase *r );
00417 
00418     void quit();
00419 
00420     // dbus agent interface
00421     friend class ::StatusAdaptor;
00422     friend class ::ControlAdaptor;
00423 
00424     Q_DECLARE_PRIVATE( AgentBase )
00425     Q_PRIVATE_SLOT( d_func(), void delayedInit() )
00426     Q_PRIVATE_SLOT( d_func(), void slotStatus( int, const QString& ) )
00427     Q_PRIVATE_SLOT( d_func(), void slotPercent( int ) )
00428     Q_PRIVATE_SLOT( d_func(), void slotWarning( const QString& ) )
00429     Q_PRIVATE_SLOT( d_func(), void slotError( const QString& ) )
00430     //@endcond
00431 };
00432 
00433 }
00434 
00435 #ifndef AKONADI_AGENT_MAIN
00436 
00439 #define AKONADI_AGENT_MAIN( agentClass )                       \
00440   int main( int argc, char **argv )                            \
00441   {                                                            \
00442     return Akonadi::AgentBase::init<agentClass>( argc, argv ); \
00443   }
00444 #endif
00445 
00446 #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
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.4
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