kpilot

actionQueue.h

Go to the documentation of this file.
00001 #ifndef _KPILOT_ACTIONQUEUE_H
00002 #define _KPILOT_ACTIONQUEUE_H
00003 /*
00004 **
00005 ** Copyright (C) 1998-2001,2003 by Dan Pilone
00006 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00007 **
00008 */
00009 
00010 /*
00011 ** This program is free software; you can redistribute it and/or modify
00012 ** it under the terms of the GNU General Public License as published by
00013 ** the Free Software Foundation; either version 2 of the License, or
00014 ** (at your option) any later version.
00015 **
00016 ** This program is distributed in the hope that it will be useful,
00017 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 ** GNU General Public License for more details.
00020 **
00021 ** You should have received a copy of the GNU General Public License
00022 ** along with this program in a file called COPYING; if not, write to
00023 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00024 ** MA 02110-1301, USA.
00025 */
00026 
00027 /*
00028 ** Bug reports and questions can be sent to kde-pim@kde.org
00029 */
00030 
00031 #include <qptrqueue.h>
00032 
00033 #include "syncAction.h"
00034 
00057 KDE_EXPORT class ActionQueue : public SyncAction
00058 {
00059 Q_OBJECT
00060 public:
00066     ActionQueue(KPilotLink *device);
00067 
00069     virtual ~ActionQueue();
00070 
00072     bool isEmpty() const
00073     {
00074         return SyncActionQueue.isEmpty();
00075     };
00076 
00081     void addAction(SyncAction *a)
00082     {
00083         SyncActionQueue.enqueue(a);
00084     };
00085 
00086 public:
00087     /*
00088     * Call these queue*() functions to append standard functional
00089     * blocks. You should at least call queueInit() and
00090     * queueCleanup() to add the welcome and cleanup actions to
00091     * the queue (unless you do that yourself.)
00092     *
00093     * For queueInit, a WelcomeAction is added.
00094     * For queueConduits, whatever is relevant for the conduits
00095     *   can be used, usually things in the FlagMask and ActionMask.
00096     *   The list of conduits in @p conduits is queued automatically.
00097     */
00098 
00108     void queueInit();
00109 
00119     void queueConduits(const QStringList &conduits,
00120         const SyncAction::SyncMode &mode);
00121 
00128     void queueCleanup();
00129 
00130 protected:
00135     void clear();
00136 
00142     SyncAction *nextAction()
00143     {
00144         return SyncActionQueue.dequeue();
00145     };
00146 
00148     virtual bool exec();
00149 
00150 protected slots:
00154     void actionCompleted(SyncAction *);
00155 
00156 private:
00158     QPtrQueue < SyncAction > SyncActionQueue;
00159 };
00160 
00161 
00162 #endif