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

akonadi

  • 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 
543  void setItemSynchronizationFetchScope(const ItemFetchScope &fetchScope);
544 
551  void itemsRetrievedIncremental(const Item::List &changedItems,
552  const Item::List &removedItems);
553 
563  void itemsRetrievalDone();
564 
574  void clearCache();
575 
585  void invalidateCache(const Collection &collection);
586 
592  Collection currentCollection() const;
593 
599  Item currentItem() const;
600 
604  void synchronize();
605 
610  void synchronizeCollection(qint64 id);
611 
617  void synchronizeCollection(qint64 id, bool recursive);
618 
626  void synchronizeCollectionAttributes(qint64 id);
627 
631  void synchronizeCollectionTree();
632 
636  void cancelTask();
637 
643  void cancelTask(const QString &error);
644 
657  void deferTask();
658 
665  void doSetOnline(bool online);
666 
678  void setHierarchicalRemoteIdentifiersEnabled(bool enable);
679 
680  friend class ResourceScheduler;
681  friend class ::ResourceState;
682 
690  enum SchedulePriority {
691  Prepend,
692  AfterChangeReplay,
693  Append
694  };
695 
711  void scheduleCustomTask(QObject *receiver, const char *method, const QVariant &argument, SchedulePriority priority = Append);
712 
719  void taskDone();
720 
725  QString dumpNotificationListToString() const;
726 
735  void dumpMemoryInfo() const;
736 
743  QString dumpMemoryInfoToString() const;
744 
749  QString dumpSchedulerToString() const;
750 
751 private:
752  static QString parseArguments(int, char **);
753  static int init(ResourceBase *r);
754 
755  // dbus resource interface
756  friend class ::Akonadi__ResourceAdaptor;
757 
758  bool requestItemDelivery(qint64 uid, const QString &remoteId, const QString &mimeType, const QStringList &parts);
759 
760  QString requestItemDeliveryV2(qint64 uid, const QString &remoteId, const QString &mimeType, const QStringList &parts);
761 
762 private:
763  Q_DECLARE_PRIVATE(ResourceBase)
764 
765  Q_PRIVATE_SLOT(d_func(), void slotAbortRequested())
766  Q_PRIVATE_SLOT(d_func(), void slotDeliveryDone(KJob *))
767  Q_PRIVATE_SLOT(d_func(), void slotCollectionSyncDone(KJob *))
768  Q_PRIVATE_SLOT(d_func(), void slotDeleteResourceCollection())
769  Q_PRIVATE_SLOT(d_func(), void slotDeleteResourceCollectionDone(KJob *))
770  Q_PRIVATE_SLOT(d_func(), void slotCollectionDeletionDone(KJob *))
771  Q_PRIVATE_SLOT(d_func(), void slotInvalidateCache(const Akonadi::Collection &))
772  Q_PRIVATE_SLOT(d_func(), void slotLocalListDone(KJob *))
773  Q_PRIVATE_SLOT(d_func(), void slotSynchronizeCollection(const Akonadi::Collection &))
774  Q_PRIVATE_SLOT(d_func(), void slotCollectionListDone(KJob *))
775  Q_PRIVATE_SLOT(d_func(), void slotSynchronizeCollectionAttributes(const Akonadi::Collection &))
776  Q_PRIVATE_SLOT(d_func(), void slotCollectionListForAttributesDone(KJob *))
777  Q_PRIVATE_SLOT(d_func(), void slotCollectionAttributesSyncDone(KJob *))
778  Q_PRIVATE_SLOT(d_func(), void slotItemSyncDone(KJob *))
779  Q_PRIVATE_SLOT(d_func(), void slotPercent(KJob *, unsigned long))
780  Q_PRIVATE_SLOT(d_func(), void slotDelayedEmitProgress())
781  Q_PRIVATE_SLOT(d_func(), void slotPrepareItemRetrieval(const Akonadi::Item &item))
782  Q_PRIVATE_SLOT(d_func(), void slotPrepareItemRetrievalResult(KJob *))
783  Q_PRIVATE_SLOT(d_func(), void changeCommittedResult(KJob *))
784  Q_PRIVATE_SLOT(d_func(), void slotSessionReconnected())
785  Q_PRIVATE_SLOT(d_func(), void slotRecursiveMoveReplay(RecursiveMover *))
786  Q_PRIVATE_SLOT(d_func(), void slotRecursiveMoveReplayResult(KJob *))
787  Q_PRIVATE_SLOT(d_func(), void slotItemRetrievalCollectionFetchDone(KJob *))
788  Q_PRIVATE_SLOT(d_func(), void slotAttributeRetrievalCollectionFetchDone(KJob *))
789 };
790 
791 }
792 
793 #ifndef AKONADI_RESOURCE_MAIN
794 
797 #define AKONADI_RESOURCE_MAIN( resourceClass ) \
798  int main( int argc, char **argv ) \
799  { \
800  return Akonadi::ResourceBase::init<resourceClass>( argc, argv ); \
801  }
802 #endif
803 
804 #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:690
Akonadi::ResourceBase::AfterChangeReplay
The task is scheduled after the last ChangeReplay task in the queue.
Definition: resourcebase.h:692
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:164
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:691
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-2015 The KDE developers.
Generated on Wed Dec 23 2015 17:45:40 by doxygen 1.8.5 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-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 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
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