kpilot
actionQueue.ccGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "options.h"
00031
00032 #include <qtimer.h>
00033
00034 #include "actions.h"
00035 #include "plugin.h"
00036
00037 #include "actionQueue.moc"
00038
00039
00040
00041
00042 ActionQueue::ActionQueue(KPilotLink *d) :
00043 SyncAction(d,"ActionQueue")
00044
00045 {
00046 FUNCTIONSETUP;
00047 }
00048
00049 ActionQueue::~ActionQueue()
00050 {
00051 FUNCTIONSETUP;
00052 clear();
00053 }
00054
00055 void ActionQueue::clear()
00056 {
00057 SyncAction *del = 0L;
00058 while ( (del = nextAction()) )
00059 {
00060 delete del;
00061 }
00062
00063 Q_ASSERT(isEmpty());
00064 }
00065
00066 void ActionQueue::queueInit()
00067 {
00068 FUNCTIONSETUP;
00069
00070 addAction(new WelcomeAction(fHandle));
00071 }
00072
00073 void ActionQueue::queueConduits(const QStringList &l,
00074 const SyncAction::SyncMode &m)
00075 {
00076 FUNCTIONSETUP;
00077
00078
00079
00080
00081 for (QStringList::ConstIterator it = l.begin();
00082 it != l.end();
00083 ++it)
00084 {
00085 if ((*it).startsWith(CSL1("internal_")))
00086 {
00087 #ifdef DEBUG
00088 DEBUGKPILOT << fname <<
00089 ": Ignoring conduit " << *it << endl;
00090 #endif
00091 continue;
00092 }
00093
00094 #ifdef DEBUG
00095 DEBUGKPILOT << fname
00096 << ": Creating proxy with mode=" << m.name() << endl;
00097 #endif
00098 ConduitProxy *cp = new ConduitProxy(fHandle,*it,m);
00099 addAction(cp);
00100 }
00101 }
00102
00103 void ActionQueue::queueCleanup()
00104 {
00105 addAction(new CleanupAction(fHandle));
00106 }
00107
00108 bool ActionQueue::exec()
00109 {
00110 actionCompleted(0L);
00111 return true;
00112 }
00113
00114 void ActionQueue::actionCompleted(SyncAction *b)
00115 {
00116 FUNCTIONSETUP;
00117
00118 if (b)
00119 {
00120 #ifdef DEBUG
00121 DEBUGKPILOT << fname
00122 << ": Completed action "
00123 << b->name()
00124 << endl;
00125 #endif
00126 delete b;
00127 }
00128
00129 if (isEmpty())
00130 {
00131 delayDone();
00132 return;
00133 }
00134 if ( deviceLink() && (!deviceLink()->tickle()) )
00135 {
00136 emit logError(i18n("The connection to the handheld "
00137 "was lost. Synchronization cannot continue."));
00138 clear();
00139 delayDone();
00140 return;
00141 }
00142
00143 SyncAction *a = nextAction();
00144
00145 if (!a)
00146 {
00147 WARNINGKPILOT << "NULL action on stack."
00148 << endl;
00149 return;
00150 }
00151
00152 #ifdef DEBUG
00153 DEBUGKPILOT << fname
00154 << ": Will run action "
00155 << a->name()
00156 << endl;
00157 #endif
00158
00159 QObject::connect(a, SIGNAL(logMessage(const QString &)),
00160 this, SIGNAL(logMessage(const QString &)));
00161 QObject::connect(a, SIGNAL(logError(const QString &)),
00162 this, SIGNAL(logMessage(const QString &)));
00163 QObject::connect(a, SIGNAL(logProgress(const QString &, int)),
00164 this, SIGNAL(logProgress(const QString &, int)));
00165 QObject::connect(a, SIGNAL(syncDone(SyncAction *)),
00166 this, SLOT(actionCompleted(SyncAction *)));
00167
00168
00169
00170 QTimer::singleShot(0,a,SLOT(execConduit()));
00171 }
00172
|