|
1 /* |
|
2 * Copyright (c) 2008 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: Implementation for MPX My Videos Collection Move, Copy and Delete operations.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef VCXMYVIDEOSASYNCFILEOPERATIONS_H |
|
21 #define VCXMYVIDEOSASYNCFILEOPERATIONS_H |
|
22 |
|
23 // INCLUDES |
|
24 |
|
25 #include <mpxcollectionplugin.h> |
|
26 #include <mpxcollectionpath.h> |
|
27 #include <mpxcollectionmessagedefs.h> |
|
28 #include <vcxmyvideosdefs.h> |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CVcxMyVideosCollectionPlugin; |
|
32 class CVcxMyVideosAsyncFileCopy; |
|
33 class CMPXMedia; |
|
34 |
|
35 // CONSTANTS |
|
36 |
|
37 // CLASS DECLARATION |
|
38 |
|
39 /** |
|
40 * @lib mpxmyvideoscollectionplugin.lib |
|
41 */ |
|
42 NONSHARABLE_CLASS(CVcxMyVideosAsyncFileOperations) : |
|
43 public CBase |
|
44 { |
|
45 public: // Constructors and destructor |
|
46 |
|
47 /** |
|
48 * Two-phased constructor |
|
49 * @return object constructed |
|
50 */ |
|
51 static CVcxMyVideosAsyncFileOperations* NewL( CVcxMyVideosCollectionPlugin& aCollection ); |
|
52 |
|
53 /** |
|
54 * Destructor |
|
55 */ |
|
56 virtual ~CVcxMyVideosAsyncFileOperations(); |
|
57 |
|
58 public: // from base classes |
|
59 |
|
60 private: |
|
61 /** |
|
62 * Constructor |
|
63 */ |
|
64 CVcxMyVideosAsyncFileOperations( CVcxMyVideosCollectionPlugin& aCollection ); |
|
65 |
|
66 /** |
|
67 * Symbian 2nd phase constructor. |
|
68 */ |
|
69 void ConstructL (); |
|
70 |
|
71 public: |
|
72 |
|
73 /** |
|
74 * Deletes the file and removes media item from the collection. |
|
75 * |
|
76 * @param aMdsId MDS id of the item to be deleted. |
|
77 * @param aForce If ETrue, the video will be deleted even if download is ongoing. |
|
78 */ |
|
79 void DeleteVideoL( TUint32 aMdsId, TBool aForce = EFalse ); |
|
80 |
|
81 /** |
|
82 * Performs one Move or Copy operation. Called by HandleStep. |
|
83 * |
|
84 * @return MVcxMyVideosActiveTaskObserver::EDone if was last operation, |
|
85 * MVcxMyVideosActiveTaskObserver::EMoreToCome otherwise. |
|
86 */ |
|
87 MVcxMyVideosActiveTaskObserver::TStepResult HandleMoveOrCopyStepL(); |
|
88 |
|
89 /** |
|
90 * Moves or copies video to another drive. |
|
91 * |
|
92 * @param aMdsId MDS id of the item to be moved. |
|
93 * @param aMove If ETrue, the source file is deleted. |
|
94 */ |
|
95 void MoveOrCopyVideoL( TUint32 aMdsId ); |
|
96 |
|
97 /** |
|
98 * Generates and sends resp message for Move,Copy and Delete operations. |
|
99 * Does nothing if there is some other operation going on. |
|
100 * This function is called when operation is interrupted from a leave or |
|
101 * cancel request. |
|
102 * Leaves with KErrNotFound if no operation was in progress. |
|
103 * |
|
104 * @param aErr Error code which is set for non handled items in the resp array. |
|
105 */ |
|
106 void CancelOperationL( TInt aErr ); |
|
107 |
|
108 /** |
|
109 * Performs one Delete operation. Called by HandleStep. |
|
110 * |
|
111 * @return MVcxMyVideosActiveTaskObserver::EDone if was last operation, |
|
112 * MVcxMyVideosActiveTaskObserver::EMoreToCome otherwise. |
|
113 */ |
|
114 MVcxMyVideosActiveTaskObserver::TStepResult HandleDeleteStepL(); |
|
115 |
|
116 private: |
|
117 |
|
118 /** |
|
119 * Called when file is going to be moved or copied to aDrive. |
|
120 * Checks if target drive has enough free space. |
|
121 * |
|
122 * @param aPath File path of the file which is going to be moved or copied. |
|
123 * @param aDrive Target drive. |
|
124 * @return ETrue If target drive has enough space, EFalse otherwise. |
|
125 */ |
|
126 TBool DriveHasEnoughFreeSpaceL( const TDesC& aPath, TInt aDrive ); |
|
127 |
|
128 /** |
|
129 * Sends response array for Move, Copy or Delete operation. |
|
130 * |
|
131 * @param aMessageId Response message ID. |
|
132 */ |
|
133 void SendOperationRespL( TInt aCmdId ); |
|
134 |
|
135 /** |
|
136 * Generates target path for move and copy operations. |
|
137 * |
|
138 * @param aSourcePath Full source path. |
|
139 * @param aTargetPath Target path is written here. |
|
140 * @param aTargetDrive Target drive. |
|
141 */ |
|
142 void GenerateTargetPathForMoveOrCopyL( |
|
143 const TDesC& aSourcePath, TDes& aTargetPath, TInt aTargetDrive ); |
|
144 |
|
145 /** |
|
146 * Initializes member variables for the Copy or Move operations. |
|
147 * |
|
148 * @param aCmd Command received from collection client. |
|
149 */ |
|
150 void InitMoveOrCopyOperationsL( CMPXMedia& aCmd ); |
|
151 |
|
152 /** |
|
153 * Called when file copying completes in Move or Copy operations. |
|
154 * |
|
155 * @param aErr Result code of the file copy. |
|
156 */ |
|
157 void HandleFileCopyCompletedL( TInt aErr ); |
|
158 |
|
159 /** |
|
160 * Initializes MDS and collection cache before the actual file copy. |
|
161 * Does some sanity checks also. |
|
162 * |
|
163 * @param aMdsId MDS ID of the video being moved/copied. |
|
164 */ |
|
165 void InitSingleMoveOrCopyL( TUint32 aMdsId ); |
|
166 |
|
167 public: |
|
168 |
|
169 /** |
|
170 * Array containing item ids which are being moved/copied or deleted. |
|
171 */ |
|
172 RArray<TUint32> iOperationIdArray; |
|
173 |
|
174 /** |
|
175 * Array containing results for move/copy/delete operations. Array positions |
|
176 * are in sync with iOperationIdArray. |
|
177 */ |
|
178 RArray<TInt> iOperationResult; |
|
179 |
|
180 private: |
|
181 |
|
182 /** |
|
183 * File server session. |
|
184 */ |
|
185 RFs iFs; |
|
186 |
|
187 /** |
|
188 * The item currently being moved/copied or deleted. |
|
189 */ |
|
190 TInt iCurrentOperationIndex; |
|
191 |
|
192 /** |
|
193 * Target drive for Move or Copy operation. |
|
194 */ |
|
195 TInt iTargetDrive; |
|
196 |
|
197 /** |
|
198 * Set to ETrue if current operation is Move. |
|
199 */ |
|
200 TBool IsMoveOperation; |
|
201 |
|
202 /** |
|
203 * Owner of this class. |
|
204 */ |
|
205 CVcxMyVideosCollectionPlugin& iCollection; |
|
206 |
|
207 /** |
|
208 * Performs single file copy in multiple steps. |
|
209 * Used to avoid long blockings when copying large files. |
|
210 * Own. |
|
211 */ |
|
212 CVcxMyVideosAsyncFileCopy* iFileCopier; |
|
213 |
|
214 /** |
|
215 * New media which is created to collection cache in copy operation. |
|
216 * It is stored in memeber variable in case that file operations |
|
217 * fail and we have to roll MDS and cache back. Own. |
|
218 */ |
|
219 CMPXMedia* iMediaForCopyOp; |
|
220 |
|
221 /** |
|
222 * Updated media which is changed in move operation. |
|
223 * It is stored in memeber variable in case that file operations |
|
224 * fail and we have to roll MDS and cache back. Own. |
|
225 */ |
|
226 CMPXMedia* iMediaForMoveOp; |
|
227 |
|
228 /** |
|
229 * Source path for move or copy operation. |
|
230 */ |
|
231 TFileName iSourcePath; |
|
232 |
|
233 /** |
|
234 * Target path for move or copy operation. |
|
235 */ |
|
236 TFileName iTargetPath; |
|
237 |
|
238 /** |
|
239 * Flag for move operation is stored just to avoid accessing |
|
240 * CMPXMedia object too much. |
|
241 */ |
|
242 TBool iIsMoveOperation; |
|
243 |
|
244 public: // Friend classes |
|
245 |
|
246 friend class CCollectionPluginTest; |
|
247 }; |
|
248 |
|
249 #endif // VCXMYVIDEOSASYNCFILEOPERATIONS_H |
|
250 |
|
251 |