kpilot Library API Documentation

syncStack.h

00001 #ifndef _KPILOT_SYNCSTACK_H
00002 #define _KPILOT_SYNCSTACK_H
00003 /* syncStack.h                        KPilot
00004 **
00005 ** Copyright (C) 1998-2001,2003 by Dan Pilone
00006 **
00007 ** This defines the "ActionQueue", which is the sequence of actions
00008 ** that will occur during a HotSync. There's also two fairly
00009 ** unimportant SyncActions defined.
00010 */
00011 
00012 /*
00013 ** This program is free software; you can redistribute it and/or modify
00014 ** it under the terms of the GNU General Public License as published by
00015 ** the Free Software Foundation; either version 2 of the License, or
00016 ** (at your option) any later version.
00017 **
00018 ** This program is distributed in the hope that it will be useful,
00019 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00021 ** GNU General Public License for more details.
00022 **
00023 ** You should have received a copy of the GNU General Public License
00024 ** along with this program in a file called COPYING; if not, write to
00025 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00026 ** MA 02111-1307, USA.
00027 */
00028 
00029 /*
00030 ** Bug reports and questions can be sent to kde-pim@kde.org
00031 */
00032 
00033 #include <qptrqueue.h>
00034 
00035 #include "plugin.h"
00036 
00059 /*
00060 * The constructor with lots of parameters is DEPRECATED.
00061 *
00062 * The @p config parameter is passed on to conduit actions that may be in the queue.
00063 *
00064 * @p conduits is a list of .desktop filenames (without the extension); for each conduit,
00065 * a ConduitProxy action is created, which loads the conduit and runs the SyncAction
00066 * from that conduit.
00067 *
00068 * For FileInstallers, pass in the list of filenames and the directory in @p installDir
00069 * and @p installFiles.
00070 *
00071 * When you create an ActionQueue, pass in all the necessary conduit- and filenames.
00072 * You cannot change them later. You must also call prepare() to add all the items
00073 * to the queue; ie.
00074 *
00075 * ActionQueue s(p,c,QStringList(),"/tmp","foo.prc");
00076 *
00077 * Creates a queue with some information set, but without any actions in it.
00078 * Next, call prepare() or somesuch:
00079 *
00080 * s.prepareSync();
00081 *
00082 * This will add a buch of "standard" actions to the queue for a HotSync, ie. a
00083 * welcome message action, user check, the conduits (if any; none were specified in the
00084 * constructor above), a file install action (which will try to install /tmp/foo.prc) and
00085 * some cleanup actions.
00086 *
00087 *
00088 * Alternatively, you can use addAction() to fill up the stack yourself.
00089 */
00090 
00097 class ActionQueue : public SyncAction
00098 {
00099 Q_OBJECT
00100 public:
00101         ActionQueue(KPilotDeviceLink *device);
00103         ActionQueue(KPilotDeviceLink *device,
00104                 KConfig *config,
00105                 const QStringList &conduits = QStringList(),
00106                 const QString &installDir = QString::null,
00107                 const QStringList &installFiles = QStringList());
00108         virtual ~ActionQueue();
00109 
00110 private:
00111         QPtrQueue < SyncAction > SyncActionQueue;
00112 
00113 public:
00114         bool isEmpty() const { return SyncActionQueue.isEmpty(); };
00119         void addAction(SyncAction * a) { SyncActionQueue.enqueue(a); };
00120 
00121 protected:
00122         void clear() { SyncActionQueue.clear(); };
00123         SyncAction *nextAction() { return SyncActionQueue.dequeue(); };
00124 
00125         bool fReady;
00126         KConfig *fConfig;
00127 
00128         QString fInstallerDir;
00129         QStringList fInstallerFiles;
00130         QStringList fConduits;
00131 
00132 public:
00133         enum SyncModes {
00134                 // Exactly one of these four modes must be set
00135                 // (although Test can't be set explicitly).
00136                 //
00137                 Test=0,
00138                 Backup=1,
00139                 Restore=2,
00140                 HotSync=4,         // Normal operation
00141                                    // 8 still available
00142                 // These are optional (mixins)
00143                 //
00144                 //
00145                                    // 16 still available
00146                 WithUserCheck=0x20,
00147                 WithInstaller=0x40,
00148                 WithConduits=0x80,
00149                 // These are misc. flags you can set
00150                 FlagLocal=0x1000,
00151                                    // 8192 still available
00152                 FlagTest=0x4000,
00153                                    // 32768 still available
00154                 // These are masks you can use to select
00155                 // the bits coding the action, mixins (With*)
00156                 // and misc. flags.
00157                 //
00158                 //
00159                 ActionMask=0xf,
00160                 MixinMask=0xf0,
00161                 FlagMask=0xf000,
00162                 // These are derived values for convenience.
00163                 // Note that a HotSync doesn't install files by default.
00164                 //
00165                 //
00166                 TestMode = Test | WithUserCheck | WithConduits,
00167                 BackupMode = Backup | WithUserCheck | WithConduits,
00168                 RestoreMode = Restore | WithUserCheck,
00169                 HotSyncMode = HotSync | WithUserCheck | WithConduits
00170                 } ;
00171 
00181         /* DEPRECATED */
00182         void prepare(int m);
00183         void prepareBackup() { prepare(BackupMode); } ;
00184         void prepareRestore() { prepare(RestoreMode); } ;
00185         void prepareSync() { prepare(HotSyncMode); } ;
00186 
00203         void queueInit(int mode=WithUserCheck); 
00204         void queueConduits(KConfig *,const QStringList &conduits,int mode=0);
00205         void queueInstaller(const QString &dir,const QStringList &files);
00206         void queueCleanup();
00207         
00208         
00209 protected:
00210         virtual bool exec();
00211 
00212 protected slots:
00216         void actionCompleted(SyncAction *);
00217 };
00218 
00223 class WelcomeAction : public SyncAction
00224 {
00225 Q_OBJECT
00226 
00227 public:
00228         WelcomeAction(KPilotDeviceLink *);
00229 
00230 protected:
00231         virtual bool exec();
00232 } ;
00233 
00240 class ConduitProxy : public ConduitAction
00241 {
00242 Q_OBJECT
00243 
00244 public:
00245         ConduitProxy(KPilotDeviceLink *,
00246                 const QString &desktopName,
00247                 int m);
00248 
00249 protected:
00250         virtual bool exec();
00251 protected slots:
00252         void execDone(SyncAction *);
00253 
00254 protected:
00255         QString fDesktopName;
00256         QString fLibraryName;
00257         ConduitAction *fConduit;
00258         int fMode;
00259 } ;
00260 
00261 
00262 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:15 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001