1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * The source file of the operation thread of file manager |
|
16 * |
|
17 */ |
|
18 |
|
19 #include "fmoperationthread.h" |
|
20 #include "fmbackuprestorehandler.h" |
|
21 |
|
22 #include <QDir> |
|
23 #include <QStack> |
|
24 |
|
25 /* |
|
26 * Constructs the operation thread with \a parent. |
|
27 */ |
|
28 FmOperationThread::FmOperationThread( QObject *parent ) : QThread( parent ), |
|
29 mStop( false), mOperationBase( 0 ) |
|
30 { |
|
31 setPriority( LowestPriority ); |
|
32 } |
|
33 |
|
34 /* |
|
35 * Destructs the operation thread. |
|
36 */ |
|
37 FmOperationThread::~FmOperationThread() |
|
38 { |
|
39 } |
|
40 |
|
41 /* |
|
42 * Prepare some conditions before starts the operation. |
|
43 * Returns the error id. |
|
44 * \a operationBase the operation to be prepared. |
|
45 */ |
|
46 int FmOperationThread::prepareOperationAndStart( FmOperationBase* operationBase ) |
|
47 { |
|
48 if ( isRunning() ) { |
|
49 return FmErrAlreadyStarted; |
|
50 } |
|
51 mOperationBase = operationBase; |
|
52 int ret = mOperationBase->prepare(); |
|
53 if ( ret == FmErrNone ) { |
|
54 mStop = false; |
|
55 start(); |
|
56 } |
|
57 return ret; |
|
58 } |
|
59 |
|
60 /* Stops the current thread. |
|
61 * Caused by user interaction. |
|
62 */ |
|
63 void FmOperationThread::stop() |
|
64 { |
|
65 mStop = true; |
|
66 } |
|
67 |
|
68 /* |
|
69 * reimp |
|
70 */ |
|
71 void FmOperationThread::run() |
|
72 { |
|
73 mOperationBase->start( &mStop ); |
|
74 } |
|
75 |
|