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

akonadi

  • sources
  • kde-4.12
  • kdepimlibs
  • akonadi
resourcebase.h
1 /*
2  This file is part of akonadiresources.
3 
4  Copyright (c) 2006 Till Adam <adam@kde.org>
5  Copyright (c) 2007 Volker Krause <vkrause@kde.org>
6 
7  This library is free software; you can redistribute it and/or modify it
8  under the terms of the GNU Library General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version.
11 
12  This library is distributed in the hope that it will be useful, but WITHOUT
13  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15  License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to the
19  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  02110-1301, USA.
21 */
22 
23 #ifndef AKONADI_RESOURCEBASE_H
24 #define AKONADI_RESOURCEBASE_H
25 
26 #include "akonadi_export.h"
27 
28 #include <akonadi/agentbase.h>
29 #include <akonadi/collection.h>
30 #include <akonadi/item.h>
31 #include <akonadi/itemsync.h>
32 
33 class KJob;
34 class Akonadi__ResourceAdaptor;
35 class ResourceState;
36 
37 namespace Akonadi {
38 
39 class ResourceBasePrivate;
40 
146  // FIXME_API: API dox need to be updated for Observer approach (kevin)
147 class AKONADI_EXPORT ResourceBase : public AgentBase
148 {
149  Q_OBJECT
150 
151  public:
179  template <typename T>
180  static int init( int argc, char **argv )
181  {
182  const QString id = parseArguments( argc, argv );
183  KApplication app;
184  T* r = new T( id );
185 
186  // check if T also inherits AgentBase::Observer and
187  // if it does, automatically register it on itself
188  Observer *observer = dynamic_cast<Observer*>( r );
189  if ( observer != 0 )
190  r->registerObserver( observer );
191 
192  return init( r );
193  }
194 
198  void setName( const QString &name );
199 
203  QString name() const;
204 
217  void setAutomaticProgressReporting( bool enabled );
218 
219  Q_SIGNALS:
225  void nameChanged( const QString &name );
226 
230  void synchronized();
231 
238  void attributesSynchronized( qlonglong collectionId );
239 
245  void collectionTreeSynchronized();
246 
247  protected Q_SLOTS:
253  virtual void retrieveCollections() = 0;
254 
265  // KDE5: Make it pure virtual, for now can be called only by invokeMethod()
266  // in order to simulate polymorphism
267  void retrieveCollectionAttributes( const Akonadi::Collection &collection );
268 
282  virtual void retrieveItems( const Akonadi::Collection &collection ) = 0;
283 
293  virtual bool retrieveItem( const Akonadi::Item &item, const QSet<QByteArray> &parts ) = 0;
294 
300  // KDE5: Make it pure virtual, for now can be called only by invokeMethod()
301  // in order to simulate polymorphism
302  void abortActivity();
303 
308  // KDE5: Make it pure virtual, for now can be called only by invokeMethod()
309  // in order to simulate polymorphism
310  QString dumpResourceToString() const
311  {
312  return QString();
313  }
314 
315  protected:
321  ResourceBase( const QString & id );
322 
326  ~ResourceBase();
327 
333  void itemRetrieved( const Item &item );
334 
341  void collectionAttributesRetrieved( const Collection &collection );
342 
350  void changeCommitted( const Item &item );
351 
361  void changesCommitted( const Item::List &items );
362 
372  void changeCommitted( const Collection &collection );
373 
380  void collectionsRetrieved( const Collection::List &collections );
381 
389  void collectionsRetrievedIncremental( const Collection::List &changedCollections,
390  const Collection::List &removedCollections );
391 
399  void setCollectionStreamingEnabled( bool enable );
400 
409  void collectionsRetrievalDone();
410 
420  void itemsRetrieved( const Item::List &items );
421 
430  void setTotalItems( int amount );
431 
437  void setItemStreamingEnabled( bool enable );
438 
445  void setItemTransactionMode( ItemSync::TransactionMode mode );
446 
458  void setItemSynchronizationFetchScope( const ItemFetchScope &fetchScope );
459 
466  void itemsRetrievedIncremental( const Item::List &changedItems,
467  const Item::List &removedItems );
468 
478  void itemsRetrievalDone();
479 
489  void clearCache();
490 
500  void invalidateCache( const Collection &collection );
501 
507  Collection currentCollection() const;
508 
514  Item currentItem() const;
515 
519  void synchronize();
520 
525  void synchronizeCollection( qint64 id );
526 
532  void synchronizeCollection( qint64 id, bool recursive );
533 
541  void synchronizeCollectionAttributes( qint64 id );
542 
546  void synchronizeCollectionTree();
547 
551  void cancelTask();
552 
558  void cancelTask( const QString &error );
559 
572  void deferTask();
573 
577  void doSetOnline( bool online );
578 
590  void setHierarchicalRemoteIdentifiersEnabled( bool enable );
591 
592  friend class ResourceScheduler;
593  friend class ::ResourceState;
594 
602  enum SchedulePriority {
603  Prepend,
604  AfterChangeReplay,
605  Append
606  };
607 
623  void scheduleCustomTask( QObject* receiver, const char* method, const QVariant &argument, SchedulePriority priority = Append );
624 
631  void taskDone();
632 
637  QString dumpNotificationListToString() const;
638 
647  void dumpMemoryInfo() const;
648 
655  QString dumpMemoryInfoToString() const;
656 
661  QString dumpSchedulerToString() const;
662 
663  private:
664  static QString parseArguments( int, char** );
665  static int init( ResourceBase *r );
666 
667  // dbus resource interface
668  friend class ::Akonadi__ResourceAdaptor;
669 
670  bool requestItemDelivery( qint64 uid, const QString &remoteId, const QString &mimeType, const QStringList &parts );
671 
672  QString requestItemDeliveryV2( qint64 uid, const QString &remoteId, const QString &mimeType, const QStringList &parts );
673 
674  private:
675  Q_DECLARE_PRIVATE( ResourceBase )
676 
677  Q_PRIVATE_SLOT( d_func(), void slotAbortRequested() )
678  Q_PRIVATE_SLOT( d_func(), void slotDeliveryDone( KJob* ) )
679  Q_PRIVATE_SLOT( d_func(), void slotCollectionSyncDone( KJob* ) )
680  Q_PRIVATE_SLOT( d_func(), void slotDeleteResourceCollection() )
681  Q_PRIVATE_SLOT( d_func(), void slotDeleteResourceCollectionDone( KJob* ) )
682  Q_PRIVATE_SLOT( d_func(), void slotCollectionDeletionDone( KJob* ) )
683  Q_PRIVATE_SLOT( d_func(), void slotInvalidateCache( const Akonadi::Collection& ) )
684  Q_PRIVATE_SLOT( d_func(), void slotLocalListDone( KJob* ) )
685  Q_PRIVATE_SLOT( d_func(), void slotSynchronizeCollection( const Akonadi::Collection& ) )
686  Q_PRIVATE_SLOT( d_func(), void slotCollectionListDone( KJob* ) )
687  Q_PRIVATE_SLOT( d_func(), void slotSynchronizeCollectionAttributes( const Akonadi::Collection& ) )
688  Q_PRIVATE_SLOT( d_func(), void slotCollectionListForAttributesDone( KJob* ) )
689  Q_PRIVATE_SLOT( d_func(), void slotCollectionAttributesSyncDone( KJob* ) )
690  Q_PRIVATE_SLOT( d_func(), void slotItemSyncDone( KJob* ) )
691  Q_PRIVATE_SLOT( d_func(), void slotPercent( KJob*, unsigned long ) )
692  Q_PRIVATE_SLOT( d_func(), void slotDelayedEmitProgress() )
693  Q_PRIVATE_SLOT( d_func(), void slotPrepareItemRetrieval( const Akonadi::Item& item ) )
694  Q_PRIVATE_SLOT( d_func(), void slotPrepareItemRetrievalResult( KJob* ) )
695  Q_PRIVATE_SLOT( d_func(), void changeCommittedResult( KJob* ) )
696  Q_PRIVATE_SLOT( d_func(), void slotSessionReconnected() )
697  Q_PRIVATE_SLOT( d_func(), void slotRecursiveMoveReplay( RecursiveMover* ) )
698  Q_PRIVATE_SLOT( d_func(), void slotRecursiveMoveReplayResult( KJob* ) )
699 };
700 
701 }
702 
703 #ifndef AKONADI_RESOURCE_MAIN
704 
707 #define AKONADI_RESOURCE_MAIN( resourceClass ) \
708  int main( int argc, char **argv ) \
709  { \
710  return Akonadi::ResourceBase::init<resourceClass>( argc, argv ); \
711  }
712 #endif
713 
714 #endif
Akonadi::RecursiveMover
Helper class for expanding inter-resource collection moves inside ResourceBase.
Definition: recursivemover_p.h:37
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
Akonadi::AgentBase::Observer
The interface for reacting on monitored or replayed changes.
Definition: agentbase.h:185
Akonadi::AgentBase
The base class for all Akonadi agents and resources.
Definition: agentbase.h:80
Akonadi::ResourceBase::SchedulePriority
SchedulePriority
Describes the scheduling priority of a task that has been queued for execution.
Definition: resourcebase.h:602
Akonadi::ResourceBase::AfterChangeReplay
The task is scheduled after the last ChangeReplay task in the queue.
Definition: resourcebase.h:604
Akonadi::ItemFetchScope
Specifies which parts of an item should be fetched from the Akonadi storage.
Definition: itemfetchscope.h:68
Akonadi::ItemSync::TransactionMode
TransactionMode
Transaction mode used by ItemSync.
Definition: itemsync.h:158
Akonadi::ResourceBase::dumpResourceToString
QString dumpResourceToString() const
Dump resource internals, for debugging.
Definition: resourcebase.h:310
Akonadi::ResourceBase::init
static int init(int argc, char **argv)
Use this method in the main function of your resource application to initialize your resource subclas...
Definition: resourcebase.h:180
Akonadi::ResourceBase::Prepend
The task will be executed as soon as the current task has finished.
Definition: resourcebase.h:603
Akonadi::Collection::List
QList< Collection > List
Describes a list of collections.
Definition: collection.h:81
Akonadi::ResourceBase
The base class for all Akonadi resources.
Definition: resourcebase.h:147
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:27 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



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