• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • 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 
00032 class KJob;
00033 class ResourceAdaptor;
00034 
00035 namespace Akonadi {
00036 
00037 class ResourceBasePrivate;
00038 
00143  // FIXME_API: API dox need to be updated for Observer approach (kevin)
00144 class AKONADI_EXPORT ResourceBase : public AgentBase
00145 {
00146   Q_OBJECT
00147 
00148   public:
00173     template <typename T>
00174     static int init( int argc, char **argv )
00175     {
00176       const QString id = parseArguments( argc, argv );
00177       KApplication app;
00178       T* r = new T( id );
00179 
00180       // check if T also inherits AgentBase::Observer and
00181       // if it does, automatically register it on itself
00182       Observer *observer = dynamic_cast<Observer*>( r );
00183       if ( observer != 0 )
00184         r->registerObserver( observer );
00185       return init( r );
00186     }
00187 
00191     //FIXME_API: make sure location is renamed to this by resourcebase
00192     void setName( const QString &name );
00193 
00197     QString name() const;
00198 
00199   Q_SIGNALS:
00205     void nameChanged( const QString &name );
00206 
00210     void synchronized();
00211 
00212   protected Q_SLOTS:
00218     virtual void retrieveCollections() = 0;
00219 
00233     virtual void retrieveItems( const Akonadi::Collection &collection ) = 0;
00234 
00244     virtual bool retrieveItem( const Akonadi::Item &item, const QSet<QByteArray> &parts ) = 0;
00245 
00246   protected:
00252     ResourceBase( const QString & id );
00253 
00257     ~ResourceBase();
00258 
00264     void itemRetrieved( const Item &item );
00265 
00273     void changeCommitted( const Item &item );
00274 
00284     void changeCommitted( const Collection &collection );
00285 
00292     void collectionsRetrieved( const Collection::List &collections );
00293 
00301     void collectionsRetrievedIncremental( const Collection::List &changedCollections,
00302                                           const Collection::List &removedCollections );
00303 
00311     void setCollectionStreamingEnabled( bool enable );
00312 
00321     void collectionsRetrievalDone();
00322 
00331     void itemsRetrieved( const Item::List &items );
00332 
00340     void setTotalItems( int amount );
00341 
00347     void setItemStreamingEnabled( bool enable );
00348 
00355     void itemsRetrievedIncremental( const Item::List &changedItems,
00356                                     const Item::List &removedItems );
00357 
00367     void itemsRetrievalDone();
00368 
00378     void clearCache();
00379 
00383     Collection currentCollection() const;
00384 
00388     Item currentItem() const;
00389 
00393     void synchronize();
00394 
00399     void synchronizeCollection( qint64 id );
00400 
00404     void synchronizeCollectionTree();
00405 
00409     void cancelTask();
00410 
00415     void cancelTask( const QString &error );
00416 
00423     void deferTask();
00424 
00428     void doSetOnline( bool online );
00429 
00430   private:
00431     static QString parseArguments( int, char** );
00432     static int init( ResourceBase *r );
00433 
00434     // dbus resource interface
00435     friend class ::ResourceAdaptor;
00436 
00437     bool requestItemDelivery( qint64 uid, const QString &remoteId, const QString &mimeType, const QStringList &parts );
00438 
00439   private:
00440     Q_DECLARE_PRIVATE( ResourceBase )
00441 
00442     Q_PRIVATE_SLOT( d_func(), void slotDeliveryDone( KJob* ) )
00443     Q_PRIVATE_SLOT( d_func(), void slotCollectionSyncDone( KJob* ) )
00444     Q_PRIVATE_SLOT( d_func(), void slotDeleteResourceCollection() )
00445     Q_PRIVATE_SLOT( d_func(), void slotDeleteResourceCollectionDone( KJob* ) )
00446     Q_PRIVATE_SLOT( d_func(), void slotCollectionDeletionDone( KJob* ) )
00447     Q_PRIVATE_SLOT( d_func(), void slotLocalListDone( KJob* ) )
00448     Q_PRIVATE_SLOT( d_func(), void slotSynchronizeCollection( const Akonadi::Collection& ) )
00449     Q_PRIVATE_SLOT( d_func(), void slotCollectionListDone( KJob* ) )
00450     Q_PRIVATE_SLOT( d_func(), void slotItemSyncDone( KJob* ) )
00451     Q_PRIVATE_SLOT( d_func(), void slotPercent( KJob*, unsigned long ) )
00452 };
00453 
00454 }
00455 
00456 #ifndef AKONADI_RESOURCE_MAIN
00457 
00460 #define AKONADI_RESOURCE_MAIN( resourceClass )                       \
00461   int main( int argc, char **argv )                            \
00462   {                                                            \
00463     return Akonadi::ResourceBase::init<resourceClass>( argc, argv ); \
00464   }
00465 #endif
00466 
00467 #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
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.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