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

akonadi

  • sources
  • kde-4.14
  • 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 
193  return init(r);
194  }
195 
199  void setName(const QString &name);
200 
204  QString name() const;
205 
218  void setAutomaticProgressReporting(bool enabled);
219 
220 Q_SIGNALS:
226  void nameChanged(const QString &name);
227 
231  void synchronized();
232 
239  void attributesSynchronized(qlonglong collectionId);
240 
246  void collectionTreeSynchronized();
247 
263  void retrieveNextItemSyncBatch(int remainingBatchSize);
264 
265 protected Q_SLOTS:
271  virtual void retrieveCollections() = 0;
272 
283  // KDE5: Make it pure virtual, for now can be called only by invokeMethod()
284  // in order to simulate polymorphism
285  void retrieveCollectionAttributes(const Akonadi::Collection &collection);
286 
300  virtual void retrieveItems(const Akonadi::Collection &collection) = 0;
301 
310  int itemSyncBatchSize() const;
311 
319  void setItemSyncBatchSize(int batchSize);
320 
330  virtual bool retrieveItem(const Akonadi::Item &item, const QSet<QByteArray> &parts) = 0;
331 
337  // KDE5: Make it pure virtual, for now can be called only by invokeMethod()
338  // in order to simulate polymorphism
339  void abortActivity();
340 
345  // KDE5: Make it pure virtual, for now can be called only by invokeMethod()
346  // in order to simulate polymorphism
347  QString dumpResourceToString() const
348  {
349  return QString();
350  }
351 
352 protected:
358  ResourceBase(const QString &id);
359 
363  ~ResourceBase();
364 
370  void itemRetrieved(const Item &item);
371 
378  void collectionAttributesRetrieved(const Collection &collection);
379 
387  void changeCommitted(const Item &item);
388 
398  void changesCommitted(const Item::List &items);
399 
409  void changeCommitted(const Tag &tag);
410 
420  void changeCommitted(const Collection &collection);
421 
428  void collectionsRetrieved(const Collection::List &collections);
429 
437  void collectionsRetrievedIncremental(const Collection::List &changedCollections,
438  const Collection::List &removedCollections);
439 
447  void setCollectionStreamingEnabled(bool enable);
448 
457  void collectionsRetrievalDone();
458 
472  void setKeepLocalCollectionChanges(const QSet<QByteArray> &parts);
473 
483  void itemsRetrieved(const Item::List &items);
484 
500  void setTotalItems(int amount);
501 
515  void setDisableAutomaticItemDeliveryDone(bool disable);
516 
522  void setItemStreamingEnabled(bool enable);
523 
530  void setItemTransactionMode(ItemSync::TransactionMode mode);
531 
544  void setItemMergingMode(ItemSync::MergeMode mode);
545 
557  void setItemSynchronizationFetchScope(const ItemFetchScope &fetchScope);
558 
565  void itemsRetrievedIncremental(const Item::List &changedItems,
566  const Item::List &removedItems);
567 
577  void itemsRetrievalDone();
578 
588  void clearCache();
589 
599  void invalidateCache(const Collection &collection);
600 
606  Collection currentCollection() const;
607 
613  Item currentItem() const;
614 
618  void synchronize();
619 
624  void synchronizeCollection(qint64 id);
625 
631  void synchronizeCollection(qint64 id, bool recursive);
632 
640  void synchronizeCollectionAttributes(qint64 id);
641 
645  void synchronizeCollectionTree();
646 
650  void cancelTask();
651 
657  void cancelTask(const QString &error);
658 
671  void deferTask();
672 
679  void doSetOnline(bool online);
680 
692  void setHierarchicalRemoteIdentifiersEnabled(bool enable);
693 
694  friend class ResourceScheduler;
695  friend class ::ResourceState;
696 
704  enum SchedulePriority {
705  Prepend,
706  AfterChangeReplay,
707  Append
708  };
709 
725  void scheduleCustomTask(QObject *receiver, const char *method, const QVariant &argument, SchedulePriority priority = Append);
726 
733  void taskDone();
734 
739  QString dumpNotificationListToString() const;
740 
749  void dumpMemoryInfo() const;
750 
757  QString dumpMemoryInfoToString() const;
758 
763  QString dumpSchedulerToString() const;
764 
765 private:
766  static QString parseArguments(int, char **);
767  static int init(ResourceBase *r);
768 
769  // dbus resource interface
770  friend class ::Akonadi__ResourceAdaptor;
771 
772  bool requestItemDelivery(qint64 uid, const QString &remoteId, const QString &mimeType, const QStringList &parts);
773 
774  QString requestItemDeliveryV2(qint64 uid, const QString &remoteId, const QString &mimeType, const QStringList &parts);
775 
776 private:
777  Q_DECLARE_PRIVATE(ResourceBase)
778 
779  Q_PRIVATE_SLOT(d_func(), void slotAbortRequested())
780  Q_PRIVATE_SLOT(d_func(), void slotDeliveryDone(KJob *))
781  Q_PRIVATE_SLOT(d_func(), void slotCollectionSyncDone(KJob *))
782  Q_PRIVATE_SLOT(d_func(), void slotDeleteResourceCollection())
783  Q_PRIVATE_SLOT(d_func(), void slotDeleteResourceCollectionDone(KJob *))
784  Q_PRIVATE_SLOT(d_func(), void slotCollectionDeletionDone(KJob *))
785  Q_PRIVATE_SLOT(d_func(), void slotInvalidateCache(const Akonadi::Collection &))
786  Q_PRIVATE_SLOT(d_func(), void slotLocalListDone(KJob *))
787  Q_PRIVATE_SLOT(d_func(), void slotSynchronizeCollection(const Akonadi::Collection &))
788  Q_PRIVATE_SLOT(d_func(), void slotCollectionListDone(KJob *))
789  Q_PRIVATE_SLOT(d_func(), void slotSynchronizeCollectionAttributes(const Akonadi::Collection &))
790  Q_PRIVATE_SLOT(d_func(), void slotCollectionListForAttributesDone(KJob *))
791  Q_PRIVATE_SLOT(d_func(), void slotCollectionAttributesSyncDone(KJob *))
792  Q_PRIVATE_SLOT(d_func(), void slotItemSyncDone(KJob *))
793  Q_PRIVATE_SLOT(d_func(), void slotPercent(KJob *, unsigned long))
794  Q_PRIVATE_SLOT(d_func(), void slotDelayedEmitProgress())
795  Q_PRIVATE_SLOT(d_func(), void slotPrepareItemRetrieval(const Akonadi::Item &item))
796  Q_PRIVATE_SLOT(d_func(), void slotPrepareItemRetrievalResult(KJob *))
797  Q_PRIVATE_SLOT(d_func(), void changeCommittedResult(KJob *))
798  Q_PRIVATE_SLOT(d_func(), void slotSessionReconnected())
799  Q_PRIVATE_SLOT(d_func(), void slotRecursiveMoveReplay(RecursiveMover *))
800  Q_PRIVATE_SLOT(d_func(), void slotRecursiveMoveReplayResult(KJob *))
801  Q_PRIVATE_SLOT(d_func(), void slotItemRetrievalCollectionFetchDone(KJob *))
802  Q_PRIVATE_SLOT(d_func(), void slotAttributeRetrievalCollectionFetchDone(KJob *))
803 };
804 
805 }
806 
807 #ifndef AKONADI_RESOURCE_MAIN
808 
811 #define AKONADI_RESOURCE_MAIN( resourceClass ) \
812  int main( int argc, char **argv ) \
813  { \
814  return Akonadi::ResourceBase::init<resourceClass>( argc, argv ); \
815  }
816 #endif
817 
818 #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:186
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:704
QObject
Akonadi::ResourceBase::AfterChangeReplay
The task is scheduled after the last ChangeReplay task in the queue.
Definition: resourcebase.h:706
QSet< QByteArray >
QString
QList
QStringList
Akonadi::ItemFetchScope
Specifies which parts of an item should be fetched from the Akonadi storage.
Definition: itemfetchscope.h:69
Akonadi::ItemSync::TransactionMode
TransactionMode
Transaction mode used by ItemSync.
Definition: itemsync.h:170
Akonadi::ResourceBase::dumpResourceToString
QString dumpResourceToString() const
Dump resource internals, for debugging.
Definition: resourcebase.h:347
Akonadi::Tag
An Akonadi Tag.
Definition: tag.h:43
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:705
Akonadi::ResourceBase
The base class for all Akonadi resources.
Definition: resourcebase.h:147
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:03 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
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

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