• Skip to content
  • Skip to link menu
KDE 4.8 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • 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/QDBusConnection>
00032 #include <QtDBus/QDBusContext>
00033 
00034 class Akonadi__ControlAdaptor;
00035 class Akonadi__StatusAdaptor;
00036 
00037 namespace Akonadi {
00038 
00039 class AgentBasePrivate;
00040 class ChangeRecorder;
00041 class Collection;
00042 class Item;
00043 class Session;
00044 
00079 class AKONADI_EXPORT AgentBase : public QObject, protected QDBusContext
00080 {
00081   Q_OBJECT
00082 
00083   public:
00184     class AKONADI_EXPORT Observer  // krazy:exclude=dpointer
00185     {
00186       public:
00190         Observer();
00191 
00195         virtual ~Observer();
00196 
00202         virtual void itemAdded( const Akonadi::Item &item, const Akonadi::Collection &collection );
00203 
00209         virtual void itemChanged( const Akonadi::Item &item, const QSet<QByteArray> &partIdentifiers );
00210 
00215         virtual void itemRemoved( const Akonadi::Item &item );
00216 
00222         virtual void collectionAdded( const Akonadi::Collection &collection, const Akonadi::Collection &parent );
00223 
00228         virtual void collectionChanged( const Akonadi::Collection &collection );
00229 
00234         virtual void collectionRemoved( const Akonadi::Collection &collection );
00235     };
00236 
00243     class AKONADI_EXPORT ObserverV2 : public Observer  // krazy:exclude=dpointer
00244     {
00245       public:
00246         using Observer::collectionChanged;
00247 
00258         virtual void itemMoved( const Akonadi::Item &item, const Akonadi::Collection &collectionSource,
00259                                 const Akonadi::Collection &collectionDestination );
00260 
00267         virtual void itemLinked( const Akonadi::Item &item, const Akonadi::Collection &collection );
00268 
00275         virtual void itemUnlinked( const Akonadi::Item &item, const Akonadi::Collection &collection );
00276 
00287         virtual void collectionMoved( const Akonadi::Collection &collection, const Akonadi::Collection &collectionSource,
00288                                       const Akonadi::Collection &collectionDestination );
00289 
00295         virtual void collectionChanged( const Akonadi::Collection &collection, const QSet<QByteArray> &changedAttributes );
00296     };
00297 
00302     enum Status
00303     {
00304       Idle = 0, 
00305       Running,  
00306       Broken    
00307     };
00308 
00330     template <typename T>
00331     static int init( int argc, char **argv )
00332     {
00333       const QString id = parseArguments( argc, argv );
00334       KApplication app;
00335       T* r = new T( id );
00336 
00337       // check if T also inherits AgentBase::Observer and
00338       // if it does, automatically register it on itself
00339       Observer *observer = dynamic_cast<Observer*>( r );
00340       if ( observer != 0 )
00341         r->registerObserver( observer );
00342       return init( r );
00343     }
00344 
00354     virtual int status() const;
00355 
00359     virtual QString statusMessage() const;
00360 
00364     virtual int progress() const;
00365 
00369     virtual QString progressMessage() const;
00370 
00371   public Q_SLOTS:
00382     virtual void configure( WId windowId );
00383 
00384   public:
00388     WId winIdForDialogs() const;
00389 
00390 #ifdef Q_OS_WIN
00391 
00395     void configure( qlonglong windowId );
00396 #endif
00397 
00401     QString identifier() const;
00402 
00410     virtual void cleanup();
00411 
00419     void registerObserver( Observer *observer );
00420 
00426     //FIXME_API: make sure location is renamed to this by agentbase
00427     void setAgentName( const QString &name );
00428 
00434     QString agentName() const;
00435 
00444     static KComponentData componentData();
00445 
00446   Q_SIGNALS:
00454     void agentNameChanged( const QString &name );
00455 
00461     void status( int status, const QString &message = QString() );
00462 
00469     void percent( int progress );
00470 
00476     void warning( const QString& message );
00477 
00483     void error( const QString& message );
00484 
00491     void advancedStatus( const QVariantMap &status );
00492 
00501     void abortRequested();
00502 
00509     void reloadConfiguration();
00510 
00516     void onlineChanged( bool online );
00517 
00526     void configurationDialogAccepted();
00527 
00536     void configurationDialogRejected();
00537 
00538   protected:
00544     AgentBase( const QString & id );
00545 
00549     ~AgentBase();
00550 
00558     virtual void aboutToQuit();
00559 
00564     ChangeRecorder* changeRecorder() const;
00565 
00569     KSharedConfigPtr config();
00570 
00578     void changeProcessed();
00579 
00583     bool isOnline() const;
00584 
00592     void setNeedsNetwork( bool needsNetwork );
00593 
00597     void setOnline( bool state );
00598 
00599   protected:
00600     //@cond PRIVATE
00601     AgentBasePrivate *d_ptr;
00602     explicit AgentBase( AgentBasePrivate* d, const QString &id );
00603     friend class ObserverV2;
00604     //@endcond
00605 
00610     virtual void doSetOnline( bool online );
00611 
00612   private:
00613     //@cond PRIVATE
00614     static QString parseArguments( int, char** );
00615     static int init( AgentBase *r );
00616 
00617     // D-Bus interface stuff
00618     void abort();
00619     void reconfigure();
00620     void quit();
00621 
00622     // dbus agent interface
00623     friend class ::Akonadi__StatusAdaptor;
00624     friend class ::Akonadi__ControlAdaptor;
00625 
00626     Q_DECLARE_PRIVATE( AgentBase )
00627     Q_PRIVATE_SLOT( d_func(), void delayedInit() )
00628     Q_PRIVATE_SLOT( d_func(), void slotStatus( int, const QString& ) )
00629     Q_PRIVATE_SLOT( d_func(), void slotPercent( int ) )
00630     Q_PRIVATE_SLOT( d_func(), void slotWarning( const QString& ) )
00631     Q_PRIVATE_SLOT( d_func(), void slotError( const QString& ) )
00632     Q_PRIVATE_SLOT( d_func(), void slotNetworkStatusChange( Solid::Networking::Status ) )
00633     Q_PRIVATE_SLOT( d_func(), void slotResumedFromSuspend() )
00634 
00635     //@endcond
00636 };
00637 
00638 }
00639 
00640 #ifndef AKONADI_AGENT_MAIN
00641 
00644 #define AKONADI_AGENT_MAIN( agentClass )                       \
00645   int main( int argc, char **argv )                            \
00646   {                                                            \
00647     return Akonadi::AgentBase::init<agentClass>( argc, argv ); \
00648   }
00649 #endif
00650 
00651 #endif

akonadi

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • 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
Generated for KDE-PIM Libraries by doxygen 1.7.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