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); 00102 #if 0 00103 00104 ActionQueue(KPilotDeviceLink *device, 00105 KConfig *config, 00106 const QStringList &conduits = QStringList(), 00107 const QString &installDir = QString::null, 00108 const QStringList &installFiles = QStringList()); 00109 #endif 00110 00111 virtual ~ActionQueue(); 00112 00113 private: 00114 QPtrQueue < SyncAction > SyncActionQueue; 00115 00116 public: 00117 bool isEmpty() const { return SyncActionQueue.isEmpty(); }; 00122 void addAction(SyncAction * a) { SyncActionQueue.enqueue(a); }; 00123 00124 protected: 00125 void clear() { SyncActionQueue.clear(); }; 00126 SyncAction *nextAction() { return SyncActionQueue.dequeue(); }; 00127 00128 bool fReady; 00129 KConfig *fConfig; 00130 00131 QString fInstallerDir; 00132 QStringList fInstallerFiles; 00133 QStringList fConduits; 00134 00135 public: 00136 enum SyncModes { 00137 // Exactly one of these four modes must be set 00138 // (although Test can't be set explicitly). 00139 // 00140 Test=0, 00141 Backup=1, 00142 Restore=2, 00143 HotSync=4, // Normal operation 00144 // 8 still available 00145 // These are optional (mixins) 00146 // 00147 // 00148 WithBackup=0x10, 00149 WithUserCheck=0x20, 00150 WithInstaller=0x40, 00151 WithConduits=0x80, 00152 00153 // These are misc. flags you can set 00154 FlagPCToHH=0x100, 00155 FlagHHToPC=0x200, 00156 FlagLocal=0x1000, 00157 FlagFull=0x2000, 00158 // 8192 still available 00159 FlagTest=0x4000, 00160 00161 // 32768 still available 00162 // These are masks you can use to select 00163 // the bits coding the action, mixins (With*) 00164 // and misc. flags. 00165 // 00166 // 00167 ActionMask=0xf, 00168 MixinMask=0xf0, 00169 FlagMask=0xff00, 00170 // These are derived values for convenience. 00171 // Note that a HotSync doesn't install files by default. 00172 // 00173 // 00174 TestMode = Test | WithUserCheck | WithConduits | FlagTest, 00175 BackupMode = Backup | WithUserCheck | WithConduits | WithBackup, 00176 RestoreMode = Restore | WithUserCheck, 00177 HotSyncMode = HotSync | WithUserCheck | WithConduits 00178 } ; 00179 00180 #if 0 00181 00190 /* DEPRECATED */ 00191 void prepare(int m); 00192 void prepareBackup() { prepare(BackupMode); } ; 00193 void prepareRestore() { prepare(RestoreMode); } ; 00194 void prepareSync() { prepare(HotSyncMode); } ; 00195 #endif 00196 00213 void queueInit(int mode=WithUserCheck); 00214 void queueConduits(KConfig *,const QStringList &conduits,int mode=0); 00215 void queueInstaller(const QString &dir,const QStringList &files); 00216 void queueCleanup(); 00217 00218 00219 protected: 00220 virtual bool exec(); 00221 00222 protected slots: 00226 void actionCompleted(SyncAction *); 00227 }; 00228 00233 class WelcomeAction : public SyncAction 00234 { 00235 Q_OBJECT 00236 00237 public: 00238 WelcomeAction(KPilotDeviceLink *); 00239 00240 protected: 00241 virtual bool exec(); 00242 } ; 00243 00249 class SorryAction : public SyncAction 00250 { 00251 Q_OBJECT 00252 00253 public: 00254 SorryAction(KPilotDeviceLink *); 00255 00256 protected: 00257 virtual bool exec(); 00258 } ; 00259 00266 class ConduitProxy : public ConduitAction 00267 { 00268 Q_OBJECT 00269 00270 public: 00271 ConduitProxy(KPilotDeviceLink *, 00272 const QString &desktopName, 00273 int m); 00274 00275 protected: 00276 virtual bool exec(); 00277 protected slots: 00278 void execDone(SyncAction *); 00279 00280 protected: 00281 QString fDesktopName; 00282 QString fLibraryName; 00283 ConduitAction *fConduit; 00284 int fMode; 00285 } ; 00286 00287 00288 #endif
KDE Logo
This file is part of the documentation for kpilot Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:57:49 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003