176
178
DownloadSMTransition::onTransition(event);
181
QString DownloadSM::IDLE = "IDLE";
182
QString DownloadSM::INIT = "INIT";
183
QString DownloadSM::DOWNLOADING = "DOWNLOADING";
184
QString DownloadSM::DOWNLOADING_NOT_CONNECTED = "DOWNLOADING_NOT_CONNECTED";
185
QString DownloadSM::PAUSED = "PAUSED";
186
QString DownloadSM::PAUSED_NOT_CONNECTED = "PAUSED_NOT_CONNECTED";
187
QString DownloadSM::DOWNLOADED = "DOWNLOADED";
188
QString DownloadSM::HASHING = "HASHING";
189
QString DownloadSM::POST_PROCESSING = "POST_PROCESSING";
190
QString DownloadSM::ERROR = "ERROR";
191
QString DownloadSM::CANCELED = "CANCELED";
192
QString DownloadSM::FINISHED = "FINISHED";
180
195
* PRIVATE IMPLEMENTATION
184
199
Q_DECLARE_PUBLIC(DownloadSM)
187
explicit DownloadSMPrivate(DownloadSM* parent)
191
_downloadingNotConnectedState(),
193
_pausedNotConnectedState(),
196
_postProcessingState(),
202
DownloadSMPrivate(SMFileDownload* down, DownloadSM* parent)
206
_idleState = new State(q, "state", DownloadSM::IDLE);
207
_initState = new State(q, "state", DownloadSM::INIT);
208
_downloadingState = new State(q, "state", DownloadSM::DOWNLOADING);
209
_downloadingNotConnectedState = new State(q, "state",
210
DownloadSM::DOWNLOADING_NOT_CONNECTED);
211
_pausedState = new State(q, "state", DownloadSM::PAUSED);
212
_pausedNotConnectedState = new State(q, "state",
213
DownloadSM::PAUSED_NOT_CONNECTED);
214
_downloadedState = new State(q, "state", DownloadSM::DOWNLOADED);
215
_hashingState = new State(q, "state", DownloadSM::HASHING);
216
_postProcessingState = new State(q, "state", DownloadSM::POST_PROCESSING);
217
_errorState = new FinalState(q, "state", DownloadSM::ERROR);
218
_canceledState = new FinalState(q, "state", DownloadSM::CANCELED);
219
_finishedState = new FinalState(q, "state", DownloadSM::FINISHED);
201
221
// add the idle state transitions
202
222
_transitions.append(new HeaderTransition(_down, _idleState,
310
330
_down, SIGNAL(finished()), _finishedState));
311
331
_transitions.append(_postProcessingState->addTransition(
312
332
_down, SIGNAL(postProcessingError()), _errorState));
334
// add states set init state
335
_stateMachine.addState(_idleState);
336
_stateMachine.addState(_initState);
337
_stateMachine.addState(_downloadingState);
338
_stateMachine.addState(_downloadingNotConnectedState);
339
_stateMachine.addState(_pausedState);
340
_stateMachine.addState(_pausedNotConnectedState);
341
_stateMachine.addState(_downloadedState);
342
_stateMachine.addState(_hashingState);
343
_stateMachine.addState(_postProcessingState);
344
_stateMachine.addState(_errorState);
345
_stateMachine.addState(_canceledState);
346
_stateMachine.addState(_finishedState);
348
_stateMachine.setInitialState(_initState);
355
void setState(QString state) {
360
_stateMachine.start();
315
363
~DownloadSMPrivate() {
350
399
DownloadSM* q_ptr;
353
DownloadSM::DownloadSM(QObject* parent)
402
DownloadSM::DownloadSM(SMFileDownload* down, QObject* parent)
354
403
: QObject(parent),
355
d_ptr(new DownloadSMPrivate(this)){
404
d_ptr(new DownloadSMPrivate(down, this)){
408
DownloadSM::state() {
414
DownloadSM::setState(QString state) {
420
DownloadSM::start() {
358
425
DownloadSM::~DownloadSM() {