• Skip to content
  • Skip to link menu
KDE 4.5 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

akonadi

resourcescheduler_p.h

00001 /*
00002     Copyright (c) 2007 Volker Krause <vkrause@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or modify it
00005     under the terms of the GNU Library General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or (at your
00007     option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful, but WITHOUT
00010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012     License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to the
00016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301, USA.
00018 */
00019 
00020 #ifndef AKONADI_RESOURCESCHEDULER_P_H
00021 #define AKONADI_RESOURCESCHEDULER_P_H
00022 
00023 #include <akonadi/agentbase.h>
00024 #include <akonadi/collection.h>
00025 #include <akonadi/item.h>
00026 #include <akonadi/resourcebase.h>
00027 
00028 #include <QtCore/QObject>
00029 #include <QtCore/QStringList>
00030 #include <QtDBus/QDBusMessage>
00031 
00032 namespace Akonadi {
00033 
00034 //@cond PRIVATE
00035 
00043 class ResourceScheduler : public QObject
00044 {
00045   Q_OBJECT
00046 
00047   public:
00048     enum TaskType {
00049       Invalid,
00050       SyncAll,
00051       SyncCollectionTree,
00052       SyncCollection,
00053       FetchItem,
00054       ChangeReplay,
00055       DeleteResourceCollection,
00056       SyncAllDone,
00057       Custom
00058     };
00059 
00060     class Task {
00061       static qint64 latestSerial;
00062 
00063       public:
00064         Task() : serial( ++latestSerial ), type( Invalid ), receiver( 0 ) {}
00065         qint64 serial;
00066         TaskType type;
00067         Collection collection;
00068         Item item;
00069         QSet<QByteArray> itemParts;
00070         QList<QDBusMessage> dbusMsgs;
00071         QObject *receiver;
00072         QByteArray methodName;
00073         QVariant argument;
00074 
00075         void sendDBusReplies( bool success );
00076 
00077         bool operator==( const Task &other ) const
00078         {
00079           return type == other.type
00080               && (collection == other.collection || (!collection.isValid() && !other.collection.isValid()))
00081               && (item == other.item || (!item.isValid() && !other.item.isValid()))
00082               && itemParts == other.itemParts
00083               && receiver == other.receiver
00084               && methodName == other.methodName
00085               && argument == other.argument;
00086         }
00087     };
00088 
00089     ResourceScheduler( QObject *parent = 0 );
00090 
00094     void scheduleFullSync();
00095 
00099     void scheduleCollectionTreeSync();
00100 
00105     void scheduleSync( const Collection &col );
00106 
00113     void scheduleItemFetch( const Item &item, const QSet<QByteArray> &parts, const QDBusMessage &msg );
00114 
00119     void scheduleResourceCollectionDeletion();
00120 
00124     void scheduleFullSyncCompletion();
00125 
00130     void scheduleCustomTask( QObject *receiver, const char *methodName, const QVariant &argument, ResourceBase::SchedulePriority priority = ResourceBase::Append );
00131 
00135     bool isEmpty();
00136 
00140     Task currentTask() const;
00141 
00145     void setOnline( bool state );
00146 
00150     void dump();
00151 
00157     void clear();
00158 
00159   public Q_SLOTS:
00163     void scheduleChangeReplay();
00164 
00168     void taskDone();
00169 
00173     void deferTask();
00174 
00178     void collectionRemoved( const Akonadi::Collection &collection );
00179 
00180   Q_SIGNALS:
00181     void executeFullSync();
00182     void executeCollectionSync( const Akonadi::Collection &col );
00183     void executeCollectionTreeSync();
00184     void executeItemFetch( const Akonadi::Item &item, const QSet<QByteArray> &parts );
00185     void executeResourceCollectionDeletion();
00186     void executeChangeReplay();
00187     void fullSyncComplete();
00188     void status( int status, const QString &message = QString() );
00189 
00190   private slots:
00191     void scheduleNext();
00192     void executeNext();
00193 
00194   private:
00195     void signalTaskToTracker( const Task &task, const QByteArray &taskType );
00196 
00197     // We have a number of task queues, by order of priority.
00198     // * ChangeReplay must be first:
00199     //    change replays have to happen before we pull changes from the backend, otherwise
00200     //    we will overwrite our still unsaved local changes if the backend can't do
00201     //    incremental retrieval
00202     //
00203     // * then the stuff that is "immediately after change replay", like writeFile calls.
00204     // * then ItemFetch tasks, because they are made by blocking DBus calls
00205     // * then everything else.
00206     enum QueueType {
00207       ChangeReplayQueue, // one task at most
00208       AfterChangeReplayQueue, // also one task at most, currently
00209       ItemFetchQueue,
00210       GenericTaskQueue,
00211       NQueueCount
00212     };
00213     typedef QList<Task> TaskList;
00214 
00215     static QueueType queueTypeForTaskType( TaskType type );
00216     TaskList& queueForTaskType( TaskType type );
00217 
00218     TaskList mTaskList[ NQueueCount ];
00219 
00220     Task mCurrentTask;
00221     bool mOnline;
00222 };
00223 
00224 QDebug operator<<( QDebug, const ResourceScheduler::Task& task );
00225 
00226 //@endcond
00227 
00228 }
00229 
00230 #endif

akonadi

Skip menu "akonadi"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal