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 DeleteResourceCollection
00055 };
00056
00057 class Task {
00058 public:
00059 Task() : type( Invalid ) {}
00060 TaskType type;
00061 Collection collection;
00062 Item item;
00063 QSet<QByteArray> itemParts;
00064 QDBusMessage dbusMsg;
00065
00066 bool operator==( const Task &other ) const
00067 {
00068 return type == other.type
00069 && collection == other.collection
00070 && item == other.item
00071 && itemParts == other.itemParts;
00072 }
00073 };
00074
00075 ResourceScheduler( QObject *parent = 0 );
00076
00080 void scheduleFullSync();
00081
00085 void scheduleCollectionTreeSync();
00086
00091 void scheduleSync( const Collection &col );
00092
00099 void scheduleItemFetch( const Item &item, const QSet<QByteArray> &parts, const QDBusMessage &msg );
00100
00105 void scheduleResourceCollectionDeletion();
00106
00110 void taskDone();
00111
00115 bool isEmpty();
00116
00120 Task currentTask() const;
00121
00125 void setOnline( bool state );
00126
00127 public Q_SLOTS:
00131 void scheduleChangeReplay();
00132
00133 Q_SIGNALS:
00134 void executeFullSync();
00135 void executeCollectionSync( const Akonadi::Collection &col );
00136 void executeCollectionTreeSync();
00137 void executeItemFetch( const Akonadi::Item &item, const QSet<QByteArray> &parts );
00138 void executeResourceCollectionDeletion();
00139 void executeChangeReplay();
00140 void status( int status, const QString &message = QString() );
00141
00142 private slots:
00143 void scheduleNext();
00144 void executeNext();
00145
00146 private:
00147 QList<Task> mTaskList;
00148 Task mCurrentTask;
00149 bool mOnline;
00150 };
00151
00152
00153
00154 }
00155
00156 #endif