• 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
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() : serial( ++latestSerial ), type( Invalid ), receiver( 0 ) {}
72  qint64 serial;
73  TaskType type;
74  Collection collection;
75  Item item;
76  QSet<QByteArray> itemParts;
77  QList<QDBusMessage> dbusMsgs;
78  QObject *receiver;
79  QByteArray methodName;
80  QVariant argument;
81 
82  void sendDBusReplies( const QString &errorMsg );
83 
84  bool operator==( const Task &other ) const
85  {
86  return type == other.type
87  && (collection == other.collection || (!collection.isValid() && !other.collection.isValid()))
88  && (item == other.item || (!item.isValid() && !other.item.isValid()))
89  && itemParts == other.itemParts
90  && receiver == other.receiver
91  && methodName == other.methodName
92  && argument == other.argument;
93  }
94  };
95 
96  explicit ResourceScheduler( QObject *parent = 0 );
97 
101  void scheduleFullSync();
102 
106  void scheduleCollectionTreeSync();
107 
112  void scheduleSync( const Collection &col );
113 
118  void scheduleAttributesSync( const Collection &collection );
119 
126  void scheduleItemFetch( const Item &item, const QSet<QByteArray> &parts, const QDBusMessage &msg );
127 
132  void scheduleResourceCollectionDeletion();
133 
138  void scheduleCacheInvalidation( const Collection &collection );
139 
143  void scheduleFullSyncCompletion();
144 
148  void scheduleCollectionTreeSyncCompletion();
149 
154  void scheduleCustomTask( QObject *receiver, const char *methodName, const QVariant &argument, ResourceBase::SchedulePriority priority = ResourceBase::Append );
155 
159  void scheduleMoveReplay( const Collection &movedCollection, RecursiveMover *mover );
160 
164  bool isEmpty();
165 
169  Task currentTask() const;
170 
174  void setOnline( bool state );
175 
179  void dump();
183  QString dumpToString() const;
184 
190  void clear();
191 
197  void cancelQueues();
198 
199  public Q_SLOTS:
203  void scheduleChangeReplay();
204 
208  void taskDone();
209 
213  void deferTask();
214 
218  void collectionRemoved( const Akonadi::Collection &collection );
219 
220  Q_SIGNALS:
221  void executeFullSync();
222  void executeCollectionAttributesSync( const Akonadi::Collection &col );
223  void executeCollectionSync( const Akonadi::Collection &col );
224  void executeCollectionTreeSync();
225  void executeItemFetch( const Akonadi::Item &item, const QSet<QByteArray> &parts );
226  void executeResourceCollectionDeletion();
227  void executeCacheInvalidation( const Akonadi::Collection &collection );
228  void executeChangeReplay();
229  void executeRecursiveMoveReplay( RecursiveMover *mover );
230  void collectionTreeSyncComplete();
231  void fullSyncComplete();
232  void status( int status, const QString &message = QString() );
233 
234  private slots:
235  void scheduleNext();
236  void executeNext();
237 
238  private:
239  void signalTaskToTracker( const Task &task, const QByteArray &taskType, const QString &debugString = QString() );
240 
241  // We have a number of task queues, by order of priority.
242  // * ChangeReplay must be first:
243  // change replays have to happen before we pull changes from the backend, otherwise
244  // we will overwrite our still unsaved local changes if the backend can't do
245  // incremental retrieval
246  //
247  // * then the stuff that is "immediately after change replay", like writeFile calls.
248  // * then ItemFetch tasks, because they are made by blocking DBus calls
249  // * then everything else.
250  enum QueueType {
251  PrependTaskQueue,
252  ChangeReplayQueue, // one task at most
253  AfterChangeReplayQueue, // also one task at most, currently
254  ItemFetchQueue,
255  GenericTaskQueue,
256  NQueueCount
257  };
258  typedef QList<Task> TaskList;
259 
260  static QueueType queueTypeForTaskType( TaskType type );
261  TaskList& queueForTaskType( TaskType type );
262 
263  TaskList mTaskList[ NQueueCount ];
264 
265  Task mCurrentTask;
266  int mCurrentTasksQueue; // queue mCurrentTask came from
267  bool mOnline;
268 };
269 
270 QDebug operator<<( QDebug, const ResourceScheduler::Task& task );
271 QTextStream& operator<<( QTextStream&, const ResourceScheduler::Task& task );
272 
273 //@endcond
274 
275 }
276 
277 #endif
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:605
Akonadi::ResourceBase::SchedulePriority
SchedulePriority
Describes the scheduling priority of a task that has been queued for execution.
Definition: resourcebase.h:602
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