• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.8.5 API Reference
  • KDE Home
  • Contact Us
 

akonadi

resourcebase.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 
00007     This library is free software; you can redistribute it and/or modify it
00008     under the terms of the GNU Library General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or (at your
00010     option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful, but WITHOUT
00013     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00015     License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public License
00018     along with this library; see the file COPYING.LIB.  If not, write to the
00019     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020     02110-1301, USA.
00021 */
00022 
00023 #ifndef AKONADI_RESOURCEBASE_H
00024 #define AKONADI_RESOURCEBASE_H
00025 
00026 #include "akonadi_export.h"
00027 
00028 #include <akonadi/agentbase.h>
00029 #include <akonadi/collection.h>
00030 #include <akonadi/item.h>
00031 #include <akonadi/itemsync.h>
00032 
00033 class KJob;
00034 class Akonadi__ResourceAdaptor;
00035 
00036 namespace Akonadi {
00037 
00038 class ResourceBasePrivate;
00039 
00145  // FIXME_API: API dox need to be updated for Observer approach (kevin)
00146 class AKONADI_EXPORT ResourceBase : public AgentBase
00147 {
00148   Q_OBJECT
00149 
00150   public:
00175     template <typename T>
00176     static int init( int argc, char **argv )
00177     {
00178       const QString id = parseArguments( argc, argv );
00179       KApplication app;
00180       T* r = new T( id );
00181 
00182       // check if T also inherits AgentBase::Observer and
00183       // if it does, automatically register it on itself
00184       Observer *observer = dynamic_cast<Observer*>( r );
00185       if ( observer != 0 )
00186         r->registerObserver( observer );
00187 
00188       return init( r );
00189     }
00190 
00194     void setName( const QString &name );
00195 
00199     QString name() const;
00200 
00213     void setAutomaticProgressReporting( bool enabled );
00214 
00215   Q_SIGNALS:
00221     void nameChanged( const QString &name );
00222 
00226     void synchronized();
00227 
00234     void attributesSynchronized( qlonglong collectionId );
00235 
00241     void collectionTreeSynchronized();
00242 
00243   protected Q_SLOTS:
00249     virtual void retrieveCollections() = 0;
00250 
00261     // KDE5: Make it pure virtual, for now can be called only by invokeMethod()
00262     //       in order to simulate polymorphism
00263     void retrieveCollectionAttributes( const Akonadi::Collection &collection );
00264 
00278     virtual void retrieveItems( const Akonadi::Collection &collection ) = 0;
00279 
00289     virtual bool retrieveItem( const Akonadi::Item &item, const QSet<QByteArray> &parts ) = 0;
00290 
00296     // KDE5: Make it pure virtual, for now can be called only by invokeMethod()
00297     //       in order to simulate polymorphism
00298     void abortActivity();
00299 
00300   protected:
00306     ResourceBase( const QString & id );
00307 
00311     ~ResourceBase();
00312 
00318     void itemRetrieved( const Item &item );
00319 
00326     void collectionAttributesRetrieved( const Collection &collection );
00327 
00335     void changeCommitted( const Item &item );
00336 
00346     void changeCommitted( const Collection &collection );
00347 
00354     void collectionsRetrieved( const Collection::List &collections );
00355 
00363     void collectionsRetrievedIncremental( const Collection::List &changedCollections,
00364                                           const Collection::List &removedCollections );
00365 
00373     void setCollectionStreamingEnabled( bool enable );
00374 
00383     void collectionsRetrievalDone();
00384 
00393     void itemsRetrieved( const Item::List &items );
00394 
00402     void setTotalItems( int amount );
00403 
00409     void setItemStreamingEnabled( bool enable );
00410 
00416     void setItemTransactionMode( ItemSync::TransactionMode mode );
00417 
00429     void setItemSynchronizationFetchScope( const ItemFetchScope &fetchScope );
00430 
00437     void itemsRetrievedIncremental( const Item::List &changedItems,
00438                                     const Item::List &removedItems );
00439 
00449     void itemsRetrievalDone();
00450 
00460     void clearCache();
00461 
00470     void invalidateCache( const Collection &collection );
00471 
00477     Collection currentCollection() const;
00478 
00484     Item currentItem() const;
00485 
00489     void synchronize();
00490 
00495     void synchronizeCollection( qint64 id );
00496 
00502     void synchronizeCollection( qint64 id, bool recursive );
00503 
00511     void synchronizeCollectionAttributes( qint64 id );
00512 
00516     void synchronizeCollectionTree();
00517 
00521     void cancelTask();
00522 
00527     void cancelTask( const QString &error );
00528 
00541     void deferTask();
00542 
00546     void doSetOnline( bool online );
00547 
00558     void setHierarchicalRemoteIdentifiersEnabled( bool enable );
00559 
00560     friend class ResourceScheduler;
00561     friend class ResourceState;
00562 
00570     enum SchedulePriority {
00571       Prepend,            
00572       AfterChangeReplay,  
00573       Append              
00574     };
00575 
00591     void scheduleCustomTask( QObject* receiver, const char* method, const QVariant &argument, SchedulePriority priority = Append );
00592 
00599     void taskDone();
00600 
00605     QString dumpNotificationListToString() const;
00606 
00611     QString dumpSchedulerToString() const;
00612 
00613   private:
00614     static QString parseArguments( int, char** );
00615     static int init( ResourceBase *r );
00616 
00617     // dbus resource interface
00618     friend class ::Akonadi__ResourceAdaptor;
00619 
00620     bool requestItemDelivery( qint64 uid, const QString &remoteId, const QString &mimeType, const QStringList &parts );
00621 
00622   private:
00623     Q_DECLARE_PRIVATE( ResourceBase )
00624 
00625     Q_PRIVATE_SLOT( d_func(), void slotAbortRequested() )
00626     Q_PRIVATE_SLOT( d_func(), void slotDeliveryDone( KJob* ) )
00627     Q_PRIVATE_SLOT( d_func(), void slotCollectionSyncDone( KJob* ) )
00628     Q_PRIVATE_SLOT( d_func(), void slotDeleteResourceCollection() )
00629     Q_PRIVATE_SLOT( d_func(), void slotDeleteResourceCollectionDone( KJob* ) )
00630     Q_PRIVATE_SLOT( d_func(), void slotCollectionDeletionDone( KJob* ) )
00631     Q_PRIVATE_SLOT( d_func(), void slotInvalidateCache( const Akonadi::Collection& ) )
00632     Q_PRIVATE_SLOT( d_func(), void slotLocalListDone( KJob* ) )
00633     Q_PRIVATE_SLOT( d_func(), void slotSynchronizeCollection( const Akonadi::Collection& ) )
00634     Q_PRIVATE_SLOT( d_func(), void slotCollectionListDone( KJob* ) )
00635     Q_PRIVATE_SLOT( d_func(), void slotSynchronizeCollectionAttributes( const Akonadi::Collection& ) )
00636     Q_PRIVATE_SLOT( d_func(), void slotCollectionListForAttributesDone( KJob* ) )
00637     Q_PRIVATE_SLOT( d_func(), void slotCollectionAttributesSyncDone( KJob* ) )
00638     Q_PRIVATE_SLOT( d_func(), void slotItemSyncDone( KJob* ) )
00639     Q_PRIVATE_SLOT( d_func(), void slotPercent( KJob*, unsigned long ) )
00640     Q_PRIVATE_SLOT( d_func(), void slotDelayedEmitProgress() )
00641     Q_PRIVATE_SLOT( d_func(), void slotPrepareItemRetrieval( const Akonadi::Item& item ) )
00642     Q_PRIVATE_SLOT( d_func(), void slotPrepareItemRetrievalResult( KJob* ) )
00643     Q_PRIVATE_SLOT( d_func(), void changeCommittedResult( KJob* ) )
00644     Q_PRIVATE_SLOT( d_func(), void slotSessionReconnected() )
00645 };
00646 
00647 }
00648 
00649 #ifndef AKONADI_RESOURCE_MAIN
00650 
00653 #define AKONADI_RESOURCE_MAIN( resourceClass )                       \
00654   int main( int argc, char **argv )                            \
00655   {                                                            \
00656     return Akonadi::ResourceBase::init<resourceClass>( argc, argv ); \
00657   }
00658 #endif
00659 
00660 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:25:19 by doxygen 1.7.5 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.8.5 API Reference

Skip menu "kdepimlibs-4.8.5 API Reference"
  • 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
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