• Skip to content
  • Skip to link menu
KDE 4.7 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • 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 
00236   protected Q_SLOTS:
00242     virtual void retrieveCollections() = 0;
00243 
00254     // KDE5: Make it pure virtual, for now can be called only by invokeMethod()
00255     //       in order to simulate polymorphism
00256     void retrieveCollectionAttributes( const Akonadi::Collection &collection );
00257 
00271     virtual void retrieveItems( const Akonadi::Collection &collection ) = 0;
00272 
00282     virtual bool retrieveItem( const Akonadi::Item &item, const QSet<QByteArray> &parts ) = 0;
00283 
00289     // KDE5: Make it pure virtual, for now can be called only by invokeMethod()
00290     //       in order to simulate polymorphism
00291     void abortActivity();
00292 
00293   protected:
00299     ResourceBase( const QString & id );
00300 
00304     ~ResourceBase();
00305 
00311     void itemRetrieved( const Item &item );
00312 
00319     void collectionAttributesRetrieved( const Collection &collection );
00320 
00328     void changeCommitted( const Item &item );
00329 
00339     void changeCommitted( const Collection &collection );
00340 
00347     void collectionsRetrieved( const Collection::List &collections );
00348 
00356     void collectionsRetrievedIncremental( const Collection::List &changedCollections,
00357                                           const Collection::List &removedCollections );
00358 
00366     void setCollectionStreamingEnabled( bool enable );
00367 
00376     void collectionsRetrievalDone();
00377 
00386     void itemsRetrieved( const Item::List &items );
00387 
00395     void setTotalItems( int amount );
00396 
00402     void setItemStreamingEnabled( bool enable );
00403 
00409     void setItemTransactionMode( ItemSync::TransactionMode mode );
00410 
00422     void setItemSynchronizationFetchScope( const ItemFetchScope &fetchScope );
00423 
00430     void itemsRetrievedIncremental( const Item::List &changedItems,
00431                                     const Item::List &removedItems );
00432 
00442     void itemsRetrievalDone();
00443 
00453     void clearCache();
00454 
00460     Collection currentCollection() const;
00461 
00467     Item currentItem() const;
00468 
00472     void synchronize();
00473 
00478     void synchronizeCollection( qint64 id );
00479 
00485     void synchronizeCollection( qint64 id, bool recursive );
00486 
00494     void synchronizeCollectionAttributes( qint64 id );
00495 
00499     void synchronizeCollectionTree();
00500 
00504     void cancelTask();
00505 
00510     void cancelTask( const QString &error );
00511 
00524     void deferTask();
00525 
00529     void doSetOnline( bool online );
00530 
00541     void setHierarchicalRemoteIdentifiersEnabled( bool enable );
00542 
00543     friend class ResourceScheduler;
00544     friend class ResourceState;
00545 
00553     enum SchedulePriority {
00554       Prepend,            
00555       AfterChangeReplay,  
00556       Append              
00557     };
00558 
00574     void scheduleCustomTask( QObject* receiver, const char* method, const QVariant &argument, SchedulePriority priority = Append );
00575 
00582     void taskDone();
00583 
00584   private:
00585     static QString parseArguments( int, char** );
00586     static int init( ResourceBase *r );
00587 
00588     // dbus resource interface
00589     friend class ::Akonadi__ResourceAdaptor;
00590 
00591     bool requestItemDelivery( qint64 uid, const QString &remoteId, const QString &mimeType, const QStringList &parts );
00592 
00593   private:
00594     Q_DECLARE_PRIVATE( ResourceBase )
00595 
00596     Q_PRIVATE_SLOT( d_func(), void slotAbortRequested() )
00597     Q_PRIVATE_SLOT( d_func(), void slotDeliveryDone( KJob* ) )
00598     Q_PRIVATE_SLOT( d_func(), void slotCollectionSyncDone( KJob* ) )
00599     Q_PRIVATE_SLOT( d_func(), void slotDeleteResourceCollection() )
00600     Q_PRIVATE_SLOT( d_func(), void slotDeleteResourceCollectionDone( KJob* ) )
00601     Q_PRIVATE_SLOT( d_func(), void slotCollectionDeletionDone( KJob* ) )
00602     Q_PRIVATE_SLOT( d_func(), void slotLocalListDone( KJob* ) )
00603     Q_PRIVATE_SLOT( d_func(), void slotSynchronizeCollection( const Akonadi::Collection& ) )
00604     Q_PRIVATE_SLOT( d_func(), void slotCollectionListDone( KJob* ) )
00605     Q_PRIVATE_SLOT( d_func(), void slotSynchronizeCollectionAttributes( const Akonadi::Collection& ) )
00606     Q_PRIVATE_SLOT( d_func(), void slotCollectionListForAttributesDone( KJob* ) )
00607     Q_PRIVATE_SLOT( d_func(), void slotCollectionAttributesSyncDone( KJob* ) )
00608     Q_PRIVATE_SLOT( d_func(), void slotItemSyncDone( KJob* ) )
00609     Q_PRIVATE_SLOT( d_func(), void slotPercent( KJob*, unsigned long ) )
00610     Q_PRIVATE_SLOT( d_func(), void slotDelayedEmitProgress() )
00611     Q_PRIVATE_SLOT( d_func(), void slotPrepareItemRetrieval( const Akonadi::Item& item ) )
00612     Q_PRIVATE_SLOT( d_func(), void slotPrepareItemRetrievalResult( KJob* ) )
00613     Q_PRIVATE_SLOT( d_func(), void changeCommittedResult( KJob* ) )
00614     Q_PRIVATE_SLOT( d_func(), void slotSessionReconnected() )
00615 };
00616 
00617 }
00618 
00619 #ifndef AKONADI_RESOURCE_MAIN
00620 
00623 #define AKONADI_RESOURCE_MAIN( resourceClass )                       \
00624   int main( int argc, char **argv )                            \
00625   {                                                            \
00626     return Akonadi::ResourceBase::init<resourceClass>( argc, argv ); \
00627   }
00628 #endif
00629 
00630 #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
  • 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.5
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