|
1 /* |
|
2 * Copyright (c) 2007 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 the License "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: Active object to split up long running db tasks* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32base.h> |
|
21 #include <mpxlog.h> |
|
22 #include "vcxmyvideosactivetask.h" |
|
23 |
|
24 // ============================ MEMBER FUNCTIONS ============================= |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // Constructor |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 CVcxMyVideosActiveTask::CVcxMyVideosActiveTask( MVcxMyVideosActiveTaskObserver& aObserver ) : |
|
31 CActive( CActive::EPriorityStandard ), |
|
32 iObserver( aObserver ) |
|
33 { |
|
34 } |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // 2nd-phase constructor |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 void CVcxMyVideosActiveTask::ConstructL() |
|
41 { |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // Two-Phase Constructor |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 CVcxMyVideosActiveTask* CVcxMyVideosActiveTask::NewL( MVcxMyVideosActiveTaskObserver& aObserver ) |
|
49 { |
|
50 CVcxMyVideosActiveTask* self = new(ELeave) CVcxMyVideosActiveTask( aObserver); |
|
51 CleanupStack::PushL( self ); |
|
52 self->ConstructL(); |
|
53 CleanupStack::Pop( self ); |
|
54 return self; |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // Destructor |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 CVcxMyVideosActiveTask::~CVcxMyVideosActiveTask() |
|
62 { |
|
63 Cancel(); |
|
64 delete iCurCommand; |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // Start the operation |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 void CVcxMyVideosActiveTask::StartL( TMPXCommandId aTask, const CMPXCommand& aCommand ) |
|
72 { |
|
73 MPX_FUNC("CVcxMyVideosActiveTask::StartL"); |
|
74 delete iCurCommand; |
|
75 iCurCommand = NULL; |
|
76 iCurCommand = CMPXMedia::NewL( aCommand ); |
|
77 iCurTask = aTask; |
|
78 iCurStep = 0; |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // Sets current command, unit test function |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 void CVcxMyVideosActiveTask::SetNewCommandL( const CMPXCommand& aCommand ) |
|
86 { |
|
87 delete iCurCommand; |
|
88 iCurCommand = NULL; |
|
89 iCurCommand = CMPXMedia::NewL( aCommand ); |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // Get the current step |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 TInt CVcxMyVideosActiveTask::GetStep() |
|
97 { |
|
98 return iCurStep; |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // Get the current task |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 TMPXCommandId CVcxMyVideosActiveTask::GetTask() |
|
106 { |
|
107 return iCurTask; |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // Get the current media |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 CMPXMedia& CVcxMyVideosActiveTask::GetCommand() |
|
115 { |
|
116 return *iCurCommand; |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // Get the current media |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 CMPXMedia* CVcxMyVideosActiveTask::Command() |
|
124 { |
|
125 return iCurCommand; |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // From CActive |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 void CVcxMyVideosActiveTask::RunL() |
|
133 { |
|
134 switch ( iObserver.HandleStepL() ) |
|
135 { |
|
136 case MVcxMyVideosActiveTaskObserver::EDone: |
|
137 Done(); |
|
138 break; |
|
139 } |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CVcxMyVideosActiveTask::Done |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 void CVcxMyVideosActiveTask::Done() |
|
147 { |
|
148 iObserver.HandleOperationCompleted( KErrNone ); |
|
149 delete iCurCommand; |
|
150 iCurCommand = NULL; |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // CVcxMyVideosActiveTask::ContinueStepping |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 void CVcxMyVideosActiveTask::ContinueStepping() |
|
158 { |
|
159 } |
|
160 |
|
161 void CVcxMyVideosActiveTask::Cancel() |
|
162 { |
|
163 if( iCurCommand ) |
|
164 { |
|
165 iObserver.HandleOperationCompleted( KErrCancel ); |
|
166 delete iCurCommand; |
|
167 iCurCommand = NULL; |
|
168 } |
|
169 } |
|
170 |
|
171 // --------------------------------------------------------------------------- |
|
172 // From CActive |
|
173 // --------------------------------------------------------------------------- |
|
174 // |
|
175 void CVcxMyVideosActiveTask::DoCancel() |
|
176 { |
|
177 } |
|
178 |
|
179 // --------------------------------------------------------------------------- |
|
180 // From CActive |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 TInt CVcxMyVideosActiveTask::RunError( TInt /*aError*/ ) |
|
184 { |
|
185 return KErrNone; |
|
186 } |
|
187 |
|
188 // END OF FILE |