• 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
resourcescheduler_p.h
1 /*
2  Copyright (c) 2007 Volker Krause <vkrause@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #ifndef AKONADI_RESOURCESCHEDULER_P_H
21 #define AKONADI_RESOURCESCHEDULER_P_H
22 
23 #include <akonadi/agentbase.h>
24 #include <akonadi/collection.h>
25 #include <akonadi/item.h>
26 #include <akonadi/resourcebase.h>
27 
28 #include <QtCore/QObject>
29 #include <QtCore/QStringList>
30 #include <QtDBus/QDBusMessage>
31 
32 namespace Akonadi {
33 
34 class RecursiveMover;
35 
36 //@cond PRIVATE
37 
45 class ResourceScheduler : public QObject
46 {
47  Q_OBJECT
48 
49 public:
50  // If you change this enum, keep s_taskTypes in sync in resourcescheduler.cpp
51  enum TaskType {
52  Invalid,
53  SyncAll,
54  SyncCollectionTree,
55  SyncCollection,
56  SyncCollectionAttributes,
57  FetchItem,
58  ChangeReplay,
59  RecursiveMoveReplay,
60  DeleteResourceCollection,
61  InvalideCacheForCollection,
62  SyncAllDone,
63  SyncCollectionTreeDone,
64  Custom
65  };
66 
67  class Task {
68  static qint64 latestSerial;
69 
70  public:
71  Task()
72  : serial(++latestSerial)
73  , type(Invalid)
74  , receiver(0)
75  {
76  }
77  qint64 serial;
78  TaskType type;
79  Collection collection;
80  Item item;
81  QSet<QByteArray> itemParts;
82  QList<QDBusMessage> dbusMsgs;
83  QObject *receiver;
84  QByteArray methodName;
85  QVariant argument;
86 
87  void sendDBusReplies(const QString &errorMsg);
88 
89  bool operator==(const Task &other) const
90  {
91  return type == other.type
92  && (collection == other.collection || (!collection.isValid() && !other.collection.isValid()))
93  && (item == other.item || (!item.isValid() && !other.item.isValid()))
94  && itemParts == other.itemParts
95  && receiver == other.receiver
96  && methodName == other.methodName
97  && argument == other.argument;
98  }
99  };
100 
101  explicit ResourceScheduler(QObject *parent = 0);
102 
106  void scheduleFullSync();
107 
111  void scheduleCollectionTreeSync();
112 
117  void scheduleSync(const Collection &col);
118 
123  void scheduleAttributesSync(const Collection &collection);
124 
131  void scheduleItemFetch(const Item &item, const QSet<QByteArray> &parts, const QDBusMessage &msg);
132 
137  void scheduleResourceCollectionDeletion();
138 
143  void scheduleCacheInvalidation(const Collection &collection);
144 
148  void scheduleFullSyncCompletion();
149 
153  void scheduleCollectionTreeSyncCompletion();
154 
159  void scheduleCustomTask(QObject *receiver, const char *methodName, const QVariant &argument, ResourceBase::SchedulePriority priority = ResourceBase::Append);
160 
164  void scheduleMoveReplay(const Collection &movedCollection, RecursiveMover *mover);
165 
169  bool isEmpty();
170 
174  Task currentTask() const;
175 
179  void setOnline(bool state);
180 
184  void dump();
188  QString dumpToString() const;
189 
195  void clear();
196 
202  void cancelQueues();
203 
204 public Q_SLOTS:
208  void scheduleChangeReplay();
209 
213  void taskDone();
214 
218  void deferTask();
219 
223  void collectionRemoved(const Akonadi::Collection &collection);
224 
225 Q_SIGNALS:
226  void executeFullSync();
227  void executeCollectionAttributesSync(const Akonadi::Collection &col);
228  void executeCollectionSync(const Akonadi::Collection &col);
229  void executeCollectionTreeSync();
230  void executeItemFetch(const Akonadi::Item &item, const QSet<QByteArray> &parts);
231  void executeResourceCollectionDeletion();
232  void executeCacheInvalidation(const Akonadi::Collection &collection);
233  void executeChangeReplay();
234  void executeRecursiveMoveReplay(RecursiveMover *mover);
235  void collectionTreeSyncComplete();
236  void fullSyncComplete();
237  void status(int status, const QString &message = QString());
238 
239 private Q_SLOTS:
240  void scheduleNext();
241  void executeNext();
242 
243 private:
244  void signalTaskToTracker(const Task &task, const QByteArray &taskType, const QString &debugString = QString());
245 
246  // We have a number of task queues, by order of priority.
247  // * PrependTaskQueue is for deferring the current task
248  // * ChangeReplay must be first:
249  // change replays have to happen before we pull changes from the backend, otherwise
250  // we will overwrite our still unsaved local changes if the backend can't do
251  // incremental retrieval
252  //
253  // * then the stuff that is "immediately after change replay", like writeFile calls.
254  // * then tasks which the user is waiting for, like ItemFetch (clicking on a mail) or
255  // SyncCollectionAttributes (folder properties dialog in kmail)
256  // * then everything else (which includes the background email checking, which can take quite some time).
257  enum QueueType {
258  PrependTaskQueue,
259  ChangeReplayQueue, // one task at most
260  AfterChangeReplayQueue, // also one task at most, currently
261  UserActionQueue,
262  GenericTaskQueue,
263  NQueueCount
264  };
265  typedef QList<Task> TaskList;
266 
267  static QueueType queueTypeForTaskType(TaskType type);
268  TaskList &queueForTaskType(TaskType type);
269 
270  TaskList mTaskList[NQueueCount];
271 
272  Task mCurrentTask;
273  int mCurrentTasksQueue; // queue mCurrentTask came from
274  bool mOnline;
275 };
276 
277 QDebug operator<<(QDebug, const ResourceScheduler::Task &task);
278 QTextStream &operator<<(QTextStream &, const ResourceScheduler::Task &task);
279 
280 //@endcond
281 
282 }
283 
284 #endif
QByteArray
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
Akonadi::ResourceBase::Append
The task will be executed after all tasks currently in the queue are finished.
Definition: resourcebase.h:707
QTextStream
Akonadi::ResourceBase::SchedulePriority
SchedulePriority
Describes the scheduling priority of a task that has been queued for execution.
Definition: resourcebase.h:704
QObject
QSet< QByteArray >
QString
QList
QDebug
QDBusMessage
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