• Skip to content
  • Skip to link menu
KDE 4.2 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 
00360     void reloadConfiguration();
00361 
00367     void onlineChanged( bool b );
00368 
00369   protected:
00375     AgentBase( const QString & id );
00376 
00380     ~AgentBase();
00381 
00389     virtual void aboutToQuit();
00390 
00395     ChangeRecorder* changeRecorder() const;
00396 
00404     void changeProcessed();
00405 
00409     bool isOnline() const;
00410 
00418     void setNeedsNetwork( bool needsNetwork );
00419 
00423     void setOnline( bool state );
00424 
00425   protected:
00426     //@cond PRIVATE
00427     AgentBasePrivate *d_ptr;
00428     explicit AgentBase( AgentBasePrivate* d, const QString &id );
00429     //@endcond
00430 
00435     virtual void doSetOnline( bool online );
00436 
00437   private:
00438     //@cond PRIVATE
00439     static QString parseArguments( int, char** );
00440     static int init( AgentBase *r );
00441 
00442     // D-Bus interface stuff
00443     void reconfigure();
00444     void quit();
00445 
00446     // dbus agent interface
00447     friend class ::StatusAdaptor;
00448     friend class ::ControlAdaptor;
00449 
00450     Q_DECLARE_PRIVATE( AgentBase )
00451     Q_PRIVATE_SLOT( d_func(), void delayedInit() )
00452     Q_PRIVATE_SLOT( d_func(), void slotStatus( int, const QString& ) )
00453     Q_PRIVATE_SLOT( d_func(), void slotPercent( int ) )
00454     Q_PRIVATE_SLOT( d_func(), void slotWarning( const QString& ) )
00455     Q_PRIVATE_SLOT( d_func(), void slotError( const QString& ) )
00456     Q_PRIVATE_SLOT( d_func(), void slotNetworkStatusChange( Solid::Networking::Status ) )
00457 
00458     //@endcond
00459 };
00460 
00461 }
00462 
00463 #ifndef AKONADI_AGENT_MAIN
00464 
00467 #define AKONADI_AGENT_MAIN( agentClass )                       \
00468   int main( int argc, char **argv )                            \
00469   {                                                            \
00470     return Akonadi::AgentBase::init<agentClass>( argc, argv ); \
00471   }
00472 #endif
00473 
00474 #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
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.6
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