• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.7 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 
662  void doSetOnline(bool online);
663 
675  void setHierarchicalRemoteIdentifiersEnabled(bool enable);
676 
677  friend class ResourceScheduler;
678  friend class ::ResourceState;
679 
687  enum SchedulePriority {
688  Prepend,
689  AfterChangeReplay,
690  Append
691  };
692 
708  void scheduleCustomTask(QObject *receiver, const char *method, const QVariant &argument, SchedulePriority priority = Append);
709 
716  void taskDone();
717 
722  QString dumpNotificationListToString() const;
723 
732  void dumpMemoryInfo() const;
733 
740  QString dumpMemoryInfoToString() const;
741 
746  QString dumpSchedulerToString() const;
747 
748 private:
749  static QString parseArguments(int, char **);
750  static int init(ResourceBase *r);
751 
752  // dbus resource interface
753  friend class ::Akonadi__ResourceAdaptor;
754 
755  bool requestItemDelivery(qint64 uid, const QString &remoteId, const QString &mimeType, const QStringList &parts);
756 
757  QString requestItemDeliveryV2(qint64 uid, const QString &remoteId, const QString &mimeType, const QStringList &parts);
758 
759 private:
760  Q_DECLARE_PRIVATE(ResourceBase)
761 
762  Q_PRIVATE_SLOT(d_func(), void slotAbortRequested())
763  Q_PRIVATE_SLOT(d_func(), void slotDeliveryDone(KJob *))
764  Q_PRIVATE_SLOT(d_func(), void slotCollectionSyncDone(KJob *))
765  Q_PRIVATE_SLOT(d_func(), void slotDeleteResourceCollection())
766  Q_PRIVATE_SLOT(d_func(), void slotDeleteResourceCollectionDone(KJob *))
767  Q_PRIVATE_SLOT(d_func(), void slotCollectionDeletionDone(KJob *))
768  Q_PRIVATE_SLOT(d_func(), void slotInvalidateCache(const Akonadi::Collection &))
769  Q_PRIVATE_SLOT(d_func(), void slotLocalListDone(KJob *))
770  Q_PRIVATE_SLOT(d_func(), void slotSynchronizeCollection(const Akonadi::Collection &))
771  Q_PRIVATE_SLOT(d_func(), void slotCollectionListDone(KJob *))
772  Q_PRIVATE_SLOT(d_func(), void slotSynchronizeCollectionAttributes(const Akonadi::Collection &))
773  Q_PRIVATE_SLOT(d_func(), void slotCollectionListForAttributesDone(KJob *))
774  Q_PRIVATE_SLOT(d_func(), void slotCollectionAttributesSyncDone(KJob *))
775  Q_PRIVATE_SLOT(d_func(), void slotItemSyncDone(KJob *))
776  Q_PRIVATE_SLOT(d_func(), void slotPercent(KJob *, unsigned long))
777  Q_PRIVATE_SLOT(d_func(), void slotDelayedEmitProgress())
778  Q_PRIVATE_SLOT(d_func(), void slotPrepareItemRetrieval(const Akonadi::Item &item))
779  Q_PRIVATE_SLOT(d_func(), void slotPrepareItemRetrievalResult(KJob *))
780  Q_PRIVATE_SLOT(d_func(), void changeCommittedResult(KJob *))
781  Q_PRIVATE_SLOT(d_func(), void slotSessionReconnected())
782  Q_PRIVATE_SLOT(d_func(), void slotRecursiveMoveReplay(RecursiveMover *))
783  Q_PRIVATE_SLOT(d_func(), void slotRecursiveMoveReplayResult(KJob *))
784  Q_PRIVATE_SLOT(d_func(), void slotItemRetrievalCollectionFetchDone(KJob *))
785  Q_PRIVATE_SLOT(d_func(), void slotAttributeRetrievalCollectionFetchDone(KJob *))
786 };
787 
788 }
789 
790 #ifndef AKONADI_RESOURCE_MAIN
791 
794 #define AKONADI_RESOURCE_MAIN( resourceClass ) \
795  int main( int argc, char **argv ) \
796  { \
797  return Akonadi::ResourceBase::init<resourceClass>( argc, argv ); \
798  }
799 #endif
800 
801 #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:687
Akonadi::ResourceBase::AfterChangeReplay
The task is scheduled after the last ChangeReplay task in the queue.
Definition: resourcebase.h:689
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
FreeBusyManager::Singleton.
Definition: actionstatemanager_p.h:28
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:688
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 Sun Apr 26 2015 12:45:19 by doxygen 1.8.9.1 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.7 API Reference

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