• Skip to content
  • Skip to link menu
KDE 4.2 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 
00140  // FIXME_API: API dox need to be updated for Observer approach (kevin)
00141 class AKONADI_EXPORT ResourceBase : public AgentBase
00142 {
00143   Q_OBJECT
00144 
00145   public:
00170     template <typename T>
00171     static int init( int argc, char **argv )
00172     {
00173       const QString id = parseArguments( argc, argv );
00174       KApplication app;
00175       T* r = new T( id );
00176 
00177       // check if T also inherits AgentBase::Observer and
00178       // if it does, automatically register it on itself
00179       Observer *observer = dynamic_cast<Observer*>( r );
00180       if ( observer != 0 )
00181         r->registerObserver( observer );
00182       return init( r );
00183     }
00184 
00188     //FIXME_API: make sure location is renamed to this by resourcebase
00189     void setName( const QString &name );
00190 
00194     QString name() const;
00195 
00196   Q_SIGNALS:
00202     void nameChanged( const QString &name );
00203 
00204   protected Q_SLOTS:
00210     virtual void retrieveCollections() = 0;
00211 
00225     virtual void retrieveItems( const Akonadi::Collection &collection ) = 0;
00226 
00236     virtual bool retrieveItem( const Akonadi::Item &item, const QSet<QByteArray> &parts ) = 0;
00237 
00238   protected:
00244     ResourceBase( const QString & id );
00245 
00249     ~ResourceBase();
00250 
00256     void itemRetrieved( const Item &item );
00257 
00265     void changeCommitted( const Item &item );
00266 
00276     void changeCommitted( const Collection &collection );
00277 
00284     void collectionsRetrieved( const Collection::List &collections );
00285 
00293     void collectionsRetrievedIncremental( const Collection::List &changedCollections,
00294                                           const Collection::List &removedCollections );
00295 
00304     void itemsRetrieved( const Item::List &items );
00305 
00313     void setTotalItems( int amount );
00314 
00320     void setItemStreamingEnabled( bool enable );
00321 
00328     void itemsRetrievedIncremental( const Item::List &changedItems,
00329                                     const Item::List &removedItems );
00330 
00340     void itemsRetrievalDone();
00341 
00345     Collection currentCollection() const;
00346 
00350     Item currentItem() const;
00351 
00355     void synchronize();
00356 
00361     void synchronizeCollection( qint64 id );
00362 
00366     void synchronizeCollectionTree();
00367 
00371     void cancelTask();
00372 
00377     void cancelTask( const QString &error );
00378 
00382     void doSetOnline( bool online );
00383 
00384   private:
00385     static QString parseArguments( int, char** );
00386     static int init( ResourceBase *r );
00387 
00388     // dbus resource interface
00389     friend class ::ResourceAdaptor;
00390 
00391     bool requestItemDelivery( qint64 uid, const QString &remoteId, const QString &mimeType, const QStringList &parts );
00392 
00393   private:
00394     Q_DECLARE_PRIVATE( ResourceBase )
00395 
00396     Q_PRIVATE_SLOT( d_func(), void slotDeliveryDone( KJob* ) )
00397     Q_PRIVATE_SLOT( d_func(), void slotCollectionSyncDone( KJob* ) )
00398     Q_PRIVATE_SLOT( d_func(), void slotLocalListDone( KJob* ) )
00399     Q_PRIVATE_SLOT( d_func(), void slotSynchronizeCollection( const Akonadi::Collection& ) )
00400     Q_PRIVATE_SLOT( d_func(), void slotCollectionListDone( KJob* ) )
00401     Q_PRIVATE_SLOT( d_func(), void slotItemSyncDone( KJob* ) )
00402     Q_PRIVATE_SLOT( d_func(), void slotPercent( KJob*, unsigned long ) )
00403 };
00404 
00405 }
00406 
00407 #ifndef AKONADI_RESOURCE_MAIN
00408 
00411 #define AKONADI_RESOURCE_MAIN( resourceClass )                       \
00412   int main( int argc, char **argv )                            \
00413   {                                                            \
00414     return Akonadi::ResourceBase::init<resourceClass>( argc, argv ); \
00415   }
00416 #endif
00417 
00418 #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.7.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