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/agentbase.h>
00024 #include <akonadi/collection.h>
00025 #include <akonadi/item.h>
00026
00027 #include <QtCore/QObject>
00028 #include <QtCore/QStringList>
00029 #include <QtDBus/QDBusMessage>
00030
00031 namespace Akonadi {
00032
00033
00034
00042 class ResourceScheduler : public QObject
00043 {
00044 Q_OBJECT
00045
00046 public:
00047 enum TaskType {
00048 Invalid,
00049 SyncAll,
00050 SyncCollectionTree,
00051 SyncCollection,
00052 FetchItem,
00053 ChangeReplay
00054 };
00055
00056 class Task {
00057 public:
00058 Task() : type( Invalid ) {}
00059 TaskType type;
00060 Collection collection;
00061 Item item;
00062 QSet<QByteArray> itemParts;
00063 QDBusMessage dbusMsg;
00064
00065 bool operator==( const Task &other ) const
00066 {
00067 return type == other.type
00068 && collection == other.collection
00069 && item == other.item
00070 && itemParts == other.itemParts;
00071 }
00072 };
00073
00074 ResourceScheduler( QObject *parent = 0 );
00075
00079 void scheduleFullSync();
00080
00084 void scheduleCollectionTreeSync();
00085
00090 void scheduleSync( const Collection &col );
00091
00098 void scheduleItemFetch( const Item &item, const QSet<QByteArray> &parts, const QDBusMessage &msg );
00099
00103 void taskDone();
00104
00108 bool isEmpty();
00109
00113 Task currentTask() const;
00114
00118 void setOnline( bool state );
00119
00120 public Q_SLOTS:
00124 void scheduleChangeReplay();
00125
00126 Q_SIGNALS:
00127 void executeFullSync();
00128 void executeCollectionSync( const Akonadi::Collection &col );
00129 void executeCollectionTreeSync();
00130 void executeItemFetch( const Akonadi::Item &item, const QSet<QByteArray> &parts );
00131 void executeChangeReplay();
00132 void status( int status, const QString &message = QString() );
00133
00134 private slots:
00135 void scheduleNext();
00136 void executeNext();
00137
00138 private:
00139 QList<Task> mTaskList;
00140 Task mCurrentTask;
00141 bool mOnline;
00142 };
00143
00144
00145
00146 }
00147
00148 #endif