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 "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: Manages Upnp actions needed by Store Manager |
|
15 * Version : %version: tr1ido#1.1.6 % << Don't touch! |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __CMSMTRANSFERENGINE_H |
|
22 #define __CMSMTRANSFERENGINE_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <badesca.h> |
|
26 #include <f32file.h> |
|
27 #include "upnpfiletransfersessionobserver.h" |
|
28 |
|
29 // Forward declarations |
|
30 class MUPnPAVController; |
|
31 class MCmSmTransferObserver; |
|
32 class CCmDmMain; |
|
33 class CCmStoreListItem; |
|
34 class MCmSqlMain; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 /** |
|
38 * Class represents methods to communication with AV Controller API. |
|
39 * |
|
40 * @lib cmstoremanager.lib |
|
41 * |
|
42 * @since S60 5.1 |
|
43 */ |
|
44 NONSHARABLE_CLASS( CCmSmTransferEngine ): public CBase, |
|
45 public MUPnPFileTransferSessionObserver |
|
46 { |
|
47 |
|
48 public: |
|
49 |
|
50 // panic codes |
|
51 enum TCmSmTransferEnginePanic |
|
52 { |
|
53 ECmSmTransferQueueMessedUp = 30 |
|
54 }; |
|
55 |
|
56 // Copy statuses |
|
57 enum TCmSmCopyStatus |
|
58 { |
|
59 ECmSmCopyNever, |
|
60 ECmSmCopyContinued, |
|
61 ECmSmCopySuccess |
|
62 }; |
|
63 public: |
|
64 |
|
65 /** |
|
66 * Two-phased constructor. |
|
67 * |
|
68 * @since S60 5.1 |
|
69 * @param aObserver, observer pointer |
|
70 * @param aDBMngr, database manager |
|
71 * @param aItems, reference to items array |
|
72 * @param aItemIds, reference to item id array |
|
73 * @return pointer to CCmSmTransferEngine class |
|
74 */ |
|
75 static CCmSmTransferEngine* NewL( MCmSmTransferObserver* aObserver, |
|
76 CCmDmMain* aDBMngr, RPointerArray<CCmStoreListItem>& aItems, |
|
77 RArray<TInt>& aItemIds ); |
|
78 |
|
79 /** |
|
80 * Two-phased constructor. |
|
81 * |
|
82 * @since S60 5.1 |
|
83 * @param aObserver, observer pointer |
|
84 * @param aDBMngr, database manager |
|
85 * @param aItems, reference to items array |
|
86 * @param aItemIds, reference to item id array |
|
87 * @return pointer to CCmSmTransferEngine class |
|
88 */ |
|
89 static CCmSmTransferEngine* NewLC( MCmSmTransferObserver* aObserver, |
|
90 CCmDmMain* aDBMngr, RPointerArray<CCmStoreListItem>& aItems, |
|
91 RArray<TInt>& aItemIds ); |
|
92 |
|
93 /** |
|
94 * Destructor. |
|
95 */ |
|
96 virtual ~CCmSmTransferEngine(); |
|
97 |
|
98 public: |
|
99 |
|
100 /** |
|
101 * Sets av controller |
|
102 * |
|
103 * @since S60 5.1 |
|
104 * @param aAVControl, pointer to av controller |
|
105 * @return None |
|
106 */ |
|
107 void SetAvController( MUPnPAVController* aAVController ); |
|
108 |
|
109 /** |
|
110 * Lists media servers |
|
111 * |
|
112 * @since S60 5.1 |
|
113 * @param aDevices, device list |
|
114 * @return None |
|
115 */ |
|
116 void GetMediaServersL( CUpnpAVDeviceList*& aDevices ); |
|
117 |
|
118 /** |
|
119 * Resets file arrays |
|
120 * |
|
121 * @since S60 5.1 |
|
122 * @param None |
|
123 * @return None |
|
124 */ |
|
125 void ResetFileArrays(); |
|
126 |
|
127 /** |
|
128 * Cancel UPnP copy operation |
|
129 * |
|
130 * @since S60 5.1 |
|
131 * @param None |
|
132 * @return None |
|
133 */ |
|
134 void CancelCopy(); |
|
135 |
|
136 /** |
|
137 * Copy files |
|
138 * |
|
139 * @since S60 5.1 |
|
140 * @param aDevId, device identifier |
|
141 * @param aDevice, device |
|
142 * @return None |
|
143 */ |
|
144 void CopyFilesL( TUint8 aDevId, CUpnpAVDevice* aDevice ); |
|
145 |
|
146 /** |
|
147 * Continue Copying files |
|
148 * |
|
149 * @since S60 5.1 |
|
150 * @return None |
|
151 */ |
|
152 void ContinueCopyFilesL(); |
|
153 |
|
154 /** |
|
155 * Transferred data |
|
156 * |
|
157 * @since S60 5.1 |
|
158 * @param None |
|
159 * @return data amount |
|
160 */ |
|
161 TInt DataAmount() const; |
|
162 |
|
163 /** |
|
164 * Returns file list |
|
165 * |
|
166 * @since S60 5.1 |
|
167 * @param None |
|
168 * @return file array |
|
169 */ |
|
170 CDesCArray& FilesToBeRemoved(); |
|
171 |
|
172 /** |
|
173 * Delete file list |
|
174 * |
|
175 * @since S60 5.1 |
|
176 * @param None |
|
177 * @return None |
|
178 */ |
|
179 void DeleteToBeRemoved(); |
|
180 |
|
181 /** |
|
182 * Returns file list |
|
183 * |
|
184 * @since S60 5.1 |
|
185 * @param None |
|
186 * @return file array |
|
187 */ |
|
188 CDesCArray& FilesToBeShrinked(); |
|
189 |
|
190 /** |
|
191 * Delete file list |
|
192 * |
|
193 * @since S60 5.1 |
|
194 * @param None |
|
195 * @return None |
|
196 */ |
|
197 void DeleteToBeShrinked(); |
|
198 |
|
199 /** |
|
200 * Returns item ids which need to be deleted |
|
201 * |
|
202 * @since S60 5.1 |
|
203 * @param None |
|
204 * @return Item ids |
|
205 */ |
|
206 RArray<TInt>& ToBeDeleted(); |
|
207 |
|
208 /** |
|
209 * Cancel operation |
|
210 * |
|
211 * @since S60 5.1 |
|
212 * @param None |
|
213 * @return None |
|
214 */ |
|
215 void CancelOperation(); |
|
216 |
|
217 protected: |
|
218 |
|
219 // From base class MUPnPFileTransferSessionObserver |
|
220 |
|
221 /** |
|
222 * From MUPnPFileTransferSessionObserver |
|
223 * See base class definition |
|
224 */ |
|
225 void TransferStarted( TInt aKey, TInt aStatus ); |
|
226 |
|
227 /** |
|
228 * From MUPnPFileTransferSessionObserver |
|
229 * See base class definition |
|
230 */ |
|
231 void TransferCompleted( TInt aKey, TInt aStatus, |
|
232 const TDesC& aFilePath ); |
|
233 |
|
234 /** |
|
235 * From MUPnPFileTransferSessionObserver |
|
236 * See base class definition |
|
237 */ |
|
238 void TransferProgress( TInt aKey, TInt aBytes, |
|
239 TInt aTotalBytes ); |
|
240 |
|
241 /** |
|
242 * From MUPnPFileTransferSessionObserver |
|
243 * See base class definition |
|
244 */ |
|
245 void MediaServerDisappeared( |
|
246 TUPnPDeviceDisconnectedReason aReason ); |
|
247 |
|
248 private: |
|
249 |
|
250 /** |
|
251 * Copying one file |
|
252 * |
|
253 * @since S60 5.1 |
|
254 * @param None |
|
255 * @return None |
|
256 */ |
|
257 void CopySingleFileL(); |
|
258 |
|
259 /** |
|
260 * Connects to device |
|
261 * |
|
262 * @since S60 5.1 |
|
263 * @param aDevice to be connected |
|
264 * @return None |
|
265 */ |
|
266 void ConnectedToDeviceL( const CUpnpAVDevice& aDevice ); |
|
267 |
|
268 /** |
|
269 * Wait |
|
270 * |
|
271 * @since S60 5.1 |
|
272 * @param aDelay, delay in seconds |
|
273 * @return None |
|
274 */ |
|
275 void WaitForProgress( TInt aDelay ); |
|
276 |
|
277 /** |
|
278 * Abort operation |
|
279 * |
|
280 * @since S60 5.1 |
|
281 * @param aError, error code |
|
282 * @return None |
|
283 */ |
|
284 void AbortTransfer( TInt aError ); |
|
285 |
|
286 /** |
|
287 * Adds stored item to database |
|
288 * |
|
289 * @since S60 5.1 |
|
290 * @param aFileName, name of the stored file |
|
291 * @param aUDN, where file was stored |
|
292 * @param aTimeStamp, time stamp for store |
|
293 * @return None |
|
294 */ |
|
295 void AddStoredL( const TDesC& aFileName, const TDesC8& aUDN, |
|
296 TTime aTimeStamp ); |
|
297 |
|
298 /** |
|
299 * Handles item status values |
|
300 * @param aKey, database id of item |
|
301 * @return None |
|
302 */ |
|
303 void HandleItemStatusL( const TInt aKey ); |
|
304 |
|
305 /** |
|
306 * Updates status |
|
307 * |
|
308 * @since S60 5.1 |
|
309 * @param aStatus, status to be set |
|
310 * @param aFid, file id |
|
311 * @param aMsId, media server id |
|
312 * @return None |
|
313 */ |
|
314 void UpdateStoreTransferStatus( TUint aStatus, TInt64 aFid, |
|
315 TInt64 aMsId ); |
|
316 |
|
317 /** |
|
318 * Returns index to transferred items array |
|
319 * |
|
320 * @since S60 5.1 |
|
321 * @param aKey, database id |
|
322 * @return index to item array |
|
323 */ |
|
324 TInt GetArrayIndex( TInt aKey ); |
|
325 |
|
326 /** |
|
327 * Returns ETrue if file is already on server |
|
328 * |
|
329 * @since S60 5.1 |
|
330 * @param aIndex, index to iItems array |
|
331 * @return ETrue if file is duplicate |
|
332 */ |
|
333 TBool IsDuplicateL( const TInt aIndex ); |
|
334 |
|
335 /** |
|
336 * Handle to copying files once |
|
337 * |
|
338 * @since S60 3.2 |
|
339 * @param None |
|
340 * @return None |
|
341 */ |
|
342 void CopyFilesOnceL(); |
|
343 |
|
344 /** |
|
345 * Complete the copy process |
|
346 * |
|
347 * @since S60 3.2 |
|
348 * @param None |
|
349 * @return None |
|
350 */ |
|
351 void FinishCopy(); |
|
352 |
|
353 /** |
|
354 * Performs the first phase of two phase construction. |
|
355 * |
|
356 * @since S60 5.1 |
|
357 * @param aObserver, transfer observer |
|
358 * @param aDBMngr, database manager |
|
359 * @param aItems, store items |
|
360 * @param aItemIds, item ids |
|
361 * @return None |
|
362 */ |
|
363 CCmSmTransferEngine( MCmSmTransferObserver* aObserver, |
|
364 CCmDmMain* aDBMngr, RPointerArray<CCmStoreListItem>& aItems, |
|
365 RArray<TInt>& aItemIds ); |
|
366 |
|
367 /** |
|
368 * Performs the second phase construction. |
|
369 */ |
|
370 void ConstructL(); |
|
371 |
|
372 |
|
373 private: |
|
374 |
|
375 /** |
|
376 * Pointer to AV Controller |
|
377 */ |
|
378 MUPnPAVController* iAVController; // not owned |
|
379 |
|
380 /** |
|
381 * Browse action Observer |
|
382 */ |
|
383 MCmSmTransferObserver* iObserver; // not owned |
|
384 |
|
385 /** |
|
386 * Database manager |
|
387 */ |
|
388 CCmDmMain* iDBManager; // not owned |
|
389 |
|
390 /** |
|
391 * File transfer started |
|
392 */ |
|
393 TTime iTransferStarted; |
|
394 |
|
395 /** |
|
396 * Device |
|
397 */ |
|
398 CUpnpAVDevice* iDevice; // not owned |
|
399 |
|
400 /** |
|
401 * File Data amount in kbytes |
|
402 */ |
|
403 TInt iTransferredData; |
|
404 |
|
405 /** |
|
406 * Total transferred data amount in kbytes |
|
407 */ |
|
408 TInt iTotalTransferredData; |
|
409 |
|
410 /** |
|
411 * Items to store |
|
412 */ |
|
413 RPointerArray<CCmStoreListItem>& iItems; |
|
414 |
|
415 /** |
|
416 * Ids of the selected store items |
|
417 */ |
|
418 RArray<TInt>& iItemIds; |
|
419 |
|
420 /** |
|
421 * Item ids to be deleted |
|
422 */ |
|
423 RArray<TInt> iToBeDeleted; // owned |
|
424 |
|
425 /** |
|
426 * Index of the processed file |
|
427 */ |
|
428 TInt iIndex; |
|
429 |
|
430 /** |
|
431 * Index of the current mediaserver |
|
432 */ |
|
433 TUint8 iDevId; |
|
434 |
|
435 /** |
|
436 * File to be removed |
|
437 */ |
|
438 CDesCArray* iFilesToBeRemoved; // owned |
|
439 |
|
440 /** |
|
441 * File to be shrinked |
|
442 */ |
|
443 CDesCArray* iFilesToBeShrinked; // owned |
|
444 |
|
445 /** |
|
446 * Database wrapper ( member variable because of performance issues ) |
|
447 */ |
|
448 MCmSqlMain* iDbWrapper; // owned |
|
449 |
|
450 /** Browse session */ |
|
451 MUPnPFileUploadSession* iUploadSession; // not owned |
|
452 |
|
453 /** |
|
454 * Transfer queue |
|
455 */ |
|
456 RArray<TInt> iTransferQueue; |
|
457 |
|
458 /** |
|
459 * Copy status |
|
460 */ |
|
461 TCmSmCopyStatus iCopyStatus; |
|
462 |
|
463 /** |
|
464 * File server session |
|
465 */ |
|
466 RFs iFSession; |
|
467 |
|
468 }; |
|
469 |
|
470 #endif // __CMSMTRANSFERENGINE_H |
|