akonadi
resourcescheduler.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef AKONADI_RESOURCESCHEDULER_H
00021 #define AKONADI_RESOURCESCHEDULER_H
00022
00023 #include <akonadi/collection.h>
00024 #include <akonadi/item.h>
00025
00026 #include <QtCore/QObject>
00027 #include <QtCore/QStringList>
00028 #include <QtDBus/QDBusMessage>
00029
00030 namespace Akonadi {
00031
00039 class ResourceScheduler : public QObject
00040 {
00041 Q_OBJECT
00042
00043 public:
00044 enum TaskType {
00045 Invalid,
00046 SyncAll,
00047 SyncCollectionTree,
00048 SyncCollection,
00049 FetchItem,
00050 ChangeReplay
00051 };
00052
00053 class Task {
00054 public:
00055 Task() : type( Invalid ) {}
00056 TaskType type;
00057 Collection collection;
00058 Item item;
00059 QSet<QByteArray> itemParts;
00060 QDBusMessage dbusMsg;
00061
00062 bool operator==( const Task &other ) const
00063 {
00064 return type == other.type
00065 && collection == other.collection
00066 && item == other.item
00067 && itemParts == other.itemParts;
00068 }
00069 };
00070
00071 ResourceScheduler( QObject *parent = 0 );
00072
00076 void scheduleFullSync();
00077
00081 void scheduleCollectionTreeSync();
00082
00087 void scheduleSync( const Collection &col );
00088
00095 void scheduleItemFetch( const Item &item, const QSet<QByteArray> &parts, const QDBusMessage &msg );
00096
00100 void taskDone();
00101
00105 bool isEmpty();
00106
00110 Task currentTask() const;
00111
00115 void setOnline( bool state );
00116
00117 public Q_SLOTS:
00121 void scheduleChangeReplay();
00122
00123 Q_SIGNALS:
00124 void executeFullSync();
00125 void executeCollectionSync( const Akonadi::Collection &col );
00126 void executeCollectionTreeSync();
00127 void executeItemFetch( const Akonadi::Item &item, const QSet<QByteArray> &parts );
00128 void executeChangeReplay();
00129
00130 private slots:
00131 void scheduleNext();
00132 void executeNext();
00133
00134 private:
00135 QList<Task> mTaskList;
00136 Task mCurrentTask;
00137 bool mOnline;
00138 };
00139
00140 }
00141
00142 #endif