branch | RCL_3 |
changeset 26 | 67eb01668b0e |
parent 16 | 7f2b2a65da29 |
child 45 | baf439b22ddd |
23:8f0df5c82986 | 26:67eb01668b0e |
---|---|
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Implementation of My Videos collection Plugin interface* |
14 * Description: Implementation of My Videos collection Plugin interface* |
15 */ |
15 */ |
16 |
|
17 |
16 |
18 |
17 |
19 |
18 |
20 // INCLUDE FILES |
19 // INCLUDE FILES |
21 #include <e32cmn.h> |
20 #include <e32cmn.h> |
33 #include <drmutility.h> |
32 #include <drmutility.h> |
34 #include <bautils.h> |
33 #include <bautils.h> |
35 #include "vcxmyvideoscollectionplugin.h" |
34 #include "vcxmyvideoscollectionplugin.h" |
36 #include "vcxmyvideoscollection.hrh" |
35 #include "vcxmyvideoscollection.hrh" |
37 #include "vcxmyvideoscollectionutil.h" |
36 #include "vcxmyvideoscollectionutil.h" |
38 #include "vcxmyvideosdownloadutil.h" |
|
39 #include "vcxmyvideosvideocache.h" |
37 #include "vcxmyvideosvideocache.h" |
40 #include "vcxmyvideoscategories.h" |
38 #include "vcxmyvideoscategories.h" |
41 #include "vcxmyvideosmessagelist.h" |
39 #include "vcxmyvideosmessagelist.h" |
42 #include "vcxmyvideosasyncfileoperations.h" |
40 #include "vcxmyvideosasyncfileoperations.h" |
43 #include "vcxmyvideosopenhandler.h" |
41 #include "vcxmyvideosopenhandler.h" |
44 |
42 #include "vcxmyvideosmdsalbums.h" |
45 const TInt KMaxFileDeleteAttempts = 4; |
43 #include "vcxmyvideosalbums.h" |
46 const TInt KFileDeleteLoopDelay = 100000; |
44 |
47 |
45 |
48 // ============================ MEMBER FUNCTIONS ============================== |
46 // ============================ MEMBER FUNCTIONS ============================== |
49 |
47 |
50 // ---------------------------------------------------------------------------- |
48 // ---------------------------------------------------------------------------- |
51 // Two-phased constructor. |
49 // Two-phased constructor. |
71 { |
69 { |
72 MPX_FUNC("CVcxMyVideosCollectionPlugin::~CVcxMyVideosCollectionPlugin"); |
70 MPX_FUNC("CVcxMyVideosCollectionPlugin::~CVcxMyVideosCollectionPlugin"); |
73 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: this = %x", this); |
71 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: this = %x", this); |
74 |
72 |
75 delete iMyVideosMdsDb; |
73 delete iMyVideosMdsDb; |
76 delete iDownloadUtil; |
|
77 delete iCache; |
74 delete iCache; |
78 delete iMessageList; |
75 delete iMessageList; |
79 delete iCategories; |
76 delete iCategories; |
80 delete iAsyncFileOperations; |
77 delete iAsyncFileOperations; |
81 delete iActiveTask; |
78 delete iActiveTask; |
82 delete iOpenHandler; |
79 delete iOpenHandler; |
80 delete iAlbums; |
|
83 iFs.Close(); |
81 iFs.Close(); |
84 } |
82 } |
85 |
83 |
86 // ---------------------------------------------------------------------------- |
84 // ---------------------------------------------------------------------------- |
87 // Constructor. |
85 // Constructor. |
100 void CVcxMyVideosCollectionPlugin::ConstructL () |
98 void CVcxMyVideosCollectionPlugin::ConstructL () |
101 { |
99 { |
102 MPX_FUNC("CVcxMyVideosCollectionPlugin::ConstructL"); |
100 MPX_FUNC("CVcxMyVideosCollectionPlugin::ConstructL"); |
103 |
101 |
104 User::LeaveIfError( iFs.Connect() ); |
102 User::LeaveIfError( iFs.Connect() ); |
105 |
103 #ifdef VIDEO_COLLECTION_PLUGIN_TB92 |
106 iMyVideosMdsDb = CVcxMyVideosMdsDb::NewL( this, iFs ); |
104 iMyVideosMdsDb = CVcxMyVideosMdsDb::NewL( this, iFs ); |
105 #else |
|
106 iMyVideosMdsDb = CVcxMyVideosMdsDb::NewL( this, iFs, &AlbumsL() ); |
|
107 #endif |
|
107 iActiveTask = CVcxMyVideosActiveTask::NewL( *this ); |
108 iActiveTask = CVcxMyVideosActiveTask::NewL( *this ); |
108 iCache = CVcxMyVideosVideoCache::NewL( *this ); |
109 iCache = CVcxMyVideosVideoCache::NewL( *this ); |
109 iMessageList = CVcxMyVideosMessageList::NewL( *this ); |
110 iMessageList = CVcxMyVideosMessageList::NewL( *this ); |
110 iOpenHandler = CVcxMyVideosOpenHandler::NewL( *this, *iCache, *iMyVideosMdsDb ); |
111 iOpenHandler = CVcxMyVideosOpenHandler::NewL( *this, *iCache, *iMyVideosMdsDb ); |
111 } |
112 } |
130 const CMPXCollectionPath& aPath, |
131 const CMPXCollectionPath& aPath, |
131 const TArray<TMPXAttribute>& aAttrs, |
132 const TArray<TMPXAttribute>& aAttrs, |
132 const TArray<TCapability>& /*aCaps*/, |
133 const TArray<TCapability>& /*aCaps*/, |
133 CMPXAttributeSpecs* /*aSpecs*/) |
134 CMPXAttributeSpecs* /*aSpecs*/) |
134 { |
135 { |
135 MPX_FUNC("CMPXMyVideosDbPlugin::MediaL"); |
136 MPX_FUNC("CVcxMyVideosCollectionPlugin::MediaL"); |
136 MPX_DEBUG_PATH(aPath); |
137 MPX_DEBUG_PATH(aPath); |
137 |
138 |
138 RArray<TInt> supportedIds; |
139 RArray<TInt> supportedIds; |
139 CleanupClosePushL( supportedIds ); // 1-> |
140 CleanupClosePushL( supportedIds ); // 1-> |
140 |
141 |
163 CleanupStack::PopAndDestroy( path ); |
164 CleanupStack::PopAndDestroy( path ); |
164 } |
165 } |
165 |
166 |
166 if ( ids.Count() == 0 ) |
167 if ( ids.Count() == 0 ) |
167 { |
168 { |
168 MPX_DEBUG1("CMPXMyVideosDbPlugin:: request didn't contain any items ids, aborting"); |
169 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: request didn't contain any items ids, aborting"); |
169 |
170 |
170 iObs->HandleMedia( NULL, KErrArgument ); |
171 iObs->HandleMedia( NULL, KErrArgument ); |
171 CleanupStack::PopAndDestroy( &ids ); // <-2 |
172 CleanupStack::PopAndDestroy( &ids ); // <-2 |
172 CleanupStack::PopAndDestroy( &supportedIds ); // <-1 |
173 CleanupStack::PopAndDestroy( &supportedIds ); // <-1 |
173 return; |
174 return; |
179 CMPXMedia* videoInCache = iCache->FindVideoByMdsIdL( ids[0].iId1, pos ); |
180 CMPXMedia* videoInCache = iCache->FindVideoByMdsIdL( ids[0].iId1, pos ); |
180 |
181 |
181 if ( videoInCache ) |
182 if ( videoInCache ) |
182 { |
183 { |
183 // 0 attributes means "get all" -> can't use cache |
184 // 0 attributes means "get all" -> can't use cache |
184 MPX_DEBUG2("CMPXMyVideosDbPlugin:: client is requesting %d attributes", aAttrs.Count()); |
185 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: client is requesting %d attributes", aAttrs.Count()); |
185 if ( aAttrs.Count() > 0 ) |
186 if ( aAttrs.Count() > 0 ) |
186 { |
187 { |
187 TBool nonSupportedAttrCanBeFoundFromMds; |
188 TBool nonSupportedAttrCanBeFoundFromMds; |
188 if ( TVcxMyVideosCollectionUtil::AreSupported( *videoInCache, aAttrs, |
189 if ( TVcxMyVideosCollectionUtil::AreSupported( *videoInCache, aAttrs, |
189 nonSupportedAttrCanBeFoundFromMds ) ) |
190 nonSupportedAttrCanBeFoundFromMds ) ) |
190 { |
191 { |
191 MPX_DEBUG1("CMPXMyVideosDbPlugin:: all attributes found from cache"); |
192 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: all attributes found from cache"); |
192 useCachedVideo = ETrue; |
193 useCachedVideo = ETrue; |
193 } |
194 } |
194 else |
195 else |
195 { |
196 { |
196 MPX_DEBUG1("CMPXMyVideosDbPlugin:: all attributes NOT found from cache"); |
197 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: all attributes NOT found from cache"); |
197 if ( !nonSupportedAttrCanBeFoundFromMds ) |
198 if ( !nonSupportedAttrCanBeFoundFromMds ) |
198 { |
199 { |
199 MPX_DEBUG1("CMPXMyVideosDbPlugin:: none of the non cached attrs can be found from MDS -> use cached version"); |
200 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: none of the non cached attrs can be found from MDS -> use cached version"); |
200 useCachedVideo = ETrue; |
201 useCachedVideo = ETrue; |
201 } |
202 } |
202 else |
203 else |
203 { |
204 { |
204 MPX_DEBUG1("CMPXMyVideosDbPlugin:: at least one of the non cached attributes can be found from MDS"); |
205 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: at least one of the non cached attributes can be found from MDS"); |
205 } |
206 } |
206 } |
207 } |
207 } |
208 } |
208 } |
209 } |
209 |
210 |
210 CMPXMedia* video; |
211 CMPXMedia* video; |
211 |
212 |
212 if ( useCachedVideo ) |
213 if ( useCachedVideo ) |
213 { |
214 { |
214 MPX_DEBUG1("CMPXMyVideosDbPlugin:: using cached video"); |
215 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: using cached video"); |
215 video = CMPXMedia::CopyL( *videoInCache ); |
216 video = CMPXMedia::CopyL( *videoInCache ); |
216 } |
217 } |
217 else |
218 else |
218 { |
219 { |
219 MPX_DEBUG1("CMPXMyVideosDbPlugin:: fetching from MDS"); |
220 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: fetching from MDS"); |
220 video = iMyVideosMdsDb->CreateVideoL( ids[0].iId1, ETrue /* full details */ ); |
221 video = iMyVideosMdsDb->CreateVideoL( ids[0].iId1, ETrue /* full details */ ); |
221 } |
222 } |
222 |
223 |
223 iObs->HandleMedia( video, KErrNone ); |
224 if ( video ) |
225 { |
|
226 iObs->HandleMedia( video, KErrNone ); |
|
227 } |
|
228 else |
|
229 { |
|
230 iObs->HandleMedia( NULL, KErrNotFound ); |
|
231 } |
|
224 |
232 |
225 CleanupStack::PopAndDestroy( &ids ); // <-2 |
233 CleanupStack::PopAndDestroy( &ids ); // <-2 |
226 CleanupStack::PopAndDestroy( &supportedIds ); // <-1 |
234 CleanupStack::PopAndDestroy( &supportedIds ); // <-1 |
227 } |
235 } |
228 |
236 |
244 // ---------------------------------------------------------------------------- |
252 // ---------------------------------------------------------------------------- |
245 // |
253 // |
246 void CVcxMyVideosCollectionPlugin::CommandL( |
254 void CVcxMyVideosCollectionPlugin::CommandL( |
247 CMPXCommand& aCmd) |
255 CMPXCommand& aCmd) |
248 { |
256 { |
249 MPX_FUNC("CVcxMyVideosCollectionPlugin::CommandL 2"); |
257 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::CommandL() start"); |
250 |
258 |
251 if ( !aCmd.IsSupported( KMPXCommandGeneralId ) ) |
259 if ( !aCmd.IsSupported( KMPXCommandGeneralId ) ) |
252 { |
260 { |
253 User::Leave( KErrArgument ); |
261 User::Leave( KErrArgument ); |
254 } |
262 } |
290 case KMPXCommandIdCollectionSet: |
298 case KMPXCommandIdCollectionSet: |
291 { |
299 { |
292 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: sync KMPXCommandIdCollectionSet arrived"); |
300 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: sync KMPXCommandIdCollectionSet arrived"); |
293 |
301 |
294 CMPXMedia* video = aCmd.Value<CMPXMedia>( KMPXCommandColSetMedia ); |
302 CMPXMedia* video = aCmd.Value<CMPXMedia>( KMPXCommandColSetMedia ); |
295 SetVideoL( *video ); |
303 |
304 TMPXItemId mpxId = TVcxMyVideosCollectionUtil::IdL( *video ); |
|
305 if ( mpxId.iId2 == KVcxMvcMediaTypeVideo ) |
|
306 { |
|
307 SetVideoL( *video ); |
|
308 } |
|
309 else if ( mpxId.iId2 == KVcxMvcMediaTypeAlbum ) |
|
310 { |
|
311 iMyVideosMdsDb->iAlbums->SetAlbumL( *video ); |
|
312 } |
|
313 else |
|
314 { |
|
315 User::Leave( KErrNotFound ); |
|
316 } |
|
296 } |
317 } |
297 break; |
318 break; |
298 |
319 |
299 case KVcxCommandIdMyVideos: |
320 case KVcxCommandIdMyVideos: |
300 { |
321 { |
309 |
330 |
310 case KVcxCommandMyVideosCancelDelete: |
331 case KVcxCommandMyVideosCancelDelete: |
311 { |
332 { |
312 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: sync KVcxCommandMyVideosCancelDelete arrived"); |
333 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: sync KVcxCommandMyVideosCancelDelete arrived"); |
313 iActiveTask->Cancel(); |
334 iActiveTask->Cancel(); |
335 } |
|
336 break; |
|
337 |
|
338 case KVcxCommandMyVideosAddAlbum: |
|
339 { |
|
340 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: sync KVcxCommandMyVideosAddAlbum arrived"); |
|
341 AlbumsL().AddAlbumL( aCmd ); |
|
314 } |
342 } |
315 break; |
343 break; |
316 } |
344 } |
317 } |
345 } |
318 break; |
346 break; |
322 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: UNKNOWN SYNC COMMAND ARRIVED"); |
350 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: UNKNOWN SYNC COMMAND ARRIVED"); |
323 User::Leave( KErrNotSupported ); |
351 User::Leave( KErrNotSupported ); |
324 } |
352 } |
325 } |
353 } |
326 } |
354 } |
327 |
355 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::CommandL() exit"); |
328 } |
356 } |
329 |
357 |
330 // ---------------------------------------------------------------------------- |
358 // ---------------------------------------------------------------------------- |
331 // Find the items matching the media specifications |
359 // Find the items matching the media specifications |
332 // ---------------------------------------------------------------------------- |
360 // ---------------------------------------------------------------------------- |
364 // CVcxMyVideosCollectionPlugin::SendMessages |
392 // CVcxMyVideosCollectionPlugin::SendMessages |
365 // ---------------------------------------------------------------------------------------------------------- |
393 // ---------------------------------------------------------------------------------------------------------- |
366 // |
394 // |
367 void CVcxMyVideosCollectionPlugin::SendMessages( CMPXMessage& aMessages ) |
395 void CVcxMyVideosCollectionPlugin::SendMessages( CMPXMessage& aMessages ) |
368 { |
396 { |
369 #if _DEBUG |
|
370 TRAP_IGNORE( |
|
371 |
|
372 if ( aMessages.IsSupported( KMPXMessageArrayContents ) ) |
|
373 { |
|
374 const CMPXMessageArray* messageArray = |
|
375 aMessages.Value<CMPXMessageArray>(KMPXMessageArrayContents); |
|
376 |
|
377 for( TInt i = 0; i < messageArray->Count(); i++ ) |
|
378 { |
|
379 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: sending message ID: %d in array", ++iTotalMessagesSent); |
|
380 messageArray->AtL( i )->SetTObjectValueL<TUint32>( KVcxMediaMyVideosMessageId, iTotalMessagesSent ); |
|
381 iMessagesInArraySent++; |
|
382 } |
|
383 |
|
384 MPX_DEBUG3("CVcxMyVideosCollectionPlugin:: total messages sent (MSG ID): %d, messages in array sent: %d", |
|
385 iTotalMessagesSent, iMessagesInArraySent); |
|
386 } |
|
387 else |
|
388 { |
|
389 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: NO ARRAY IN MESSAGE!!!"); |
|
390 return; |
|
391 } |
|
392 |
|
393 ); |
|
394 #endif |
|
395 |
|
396 iObs->HandleMessage( aMessages ); |
397 iObs->HandleMessage( aMessages ); |
397 } |
398 } |
398 |
399 |
399 // ---------------------------------------------------------------------------------------------------------- |
400 // ---------------------------------------------------------------------------------------------------------- |
400 // CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent |
401 // CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent |
402 // |
403 // |
403 void CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent( |
404 void CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent( |
404 TMPXChangeEventType aEvent, |
405 TMPXChangeEventType aEvent, |
405 RArray<TUint32>& aId ) |
406 RArray<TUint32>& aId ) |
406 { |
407 { |
407 //MPX_FUNC("CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent"); |
|
408 TRAPD( err, DoHandleMyVideosDbEventL( aEvent, aId )); |
408 TRAPD( err, DoHandleMyVideosDbEventL( aEvent, aId )); |
409 if ( err != KErrNone ) |
409 if ( err != KErrNone ) |
410 { |
410 { |
411 MPX_DEBUG2("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() leaved with error code: %d", err); |
411 MPX_DEBUG2("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() leaved with error code: %d", err); |
412 } |
412 } |
419 void CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL( |
419 void CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL( |
420 TMPXChangeEventType aEvent, |
420 TMPXChangeEventType aEvent, |
421 RArray<TUint32>& aId ) |
421 RArray<TUint32>& aId ) |
422 { |
422 { |
423 MPX_FUNC("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL"); |
423 MPX_FUNC("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL"); |
424 |
|
425 RArray<TUint32> nonVideoIds; |
|
426 nonVideoIds.Reset(); |
|
427 CleanupClosePushL( nonVideoIds ); |
|
424 |
428 |
425 switch ( aEvent ) |
429 switch ( aEvent ) |
426 { |
430 { |
427 case EMPXItemDeleted: |
431 case EMPXItemDeleted: |
428 { |
432 { |
429 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------------."); |
433 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------------."); |
430 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items from MDS deleted, deleting from cache |" ); |
434 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items from MDS deleted, deleting from cache |" ); |
431 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------------'"); |
435 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------------'"); |
432 |
436 |
433 iCache->RemoveL( aId ); |
437 iCache->RemoveL( aId ); |
438 #ifndef VIDEO_COLLECTION_PLUGIN_TB92 |
|
439 AlbumsL().RemoveAlbumsL( aId ); |
|
440 #endif |
|
434 } |
441 } |
435 break; |
442 break; |
436 |
443 |
437 case EMPXItemInserted: |
444 case EMPXItemInserted: |
438 { |
445 { |
441 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() ------------------------------------'"); |
448 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() ------------------------------------'"); |
442 |
449 |
443 if ( iMyVideosMdsDb->iVideoListFetchingIsOngoing ) |
450 if ( iMyVideosMdsDb->iVideoListFetchingIsOngoing ) |
444 { |
451 { |
445 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: video list fetching is ongoing, ignoring add event"); |
452 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: video list fetching is ongoing, ignoring add event"); |
453 CleanupStack::PopAndDestroy( &nonVideoIds ); |
|
446 return; |
454 return; |
447 } |
455 } |
448 |
456 |
449 TBool videoListFetchingWasCancelled = EFalse; |
457 TBool videoListFetchingWasCancelled = EFalse; |
450 |
458 |
451 // After the call, aId will contain only items which were actually inserted to cache. |
459 // After the call, aId will contain only items which were actually inserted to cache. |
452 // We receive add events for all object types. When fetching the item from MDS we use |
460 // We receive add events for all object types. When fetching the item from MDS we use |
453 // video condition and only video objects are added to cache. |
461 // video condition and only video objects are added to cache. Items which were detected |
454 iCache->AddVideosFromMdsL( aId, videoListFetchingWasCancelled ); |
462 // to not be videos are added to nonVideoIds. |
463 iCache->AddVideosFromMdsL( aId, videoListFetchingWasCancelled, &nonVideoIds ); |
|
464 |
|
465 #ifndef VIDEO_COLLECTION_PLUGIN_TB92 |
|
466 #if 0 //TODO: do this if we want to support albums which are being added by someone else than My Videos Collection |
|
467 |
|
468 //After the call nonVideoIds will contain only items which were actually added |
|
469 //to albums. |
|
470 AlbumsL().AddAlbumsFromMdsL( nonVideoIds ); |
|
471 #endif |
|
472 #endif |
|
473 |
|
455 if ( videoListFetchingWasCancelled ) |
474 if ( videoListFetchingWasCancelled ) |
456 { |
475 { |
457 RestartVideoListFetchingL(); |
476 RestartVideoListFetchingL(); |
458 } |
477 } |
459 |
478 } |
460 SyncWithDownloadsL( aId ); |
479 |
461 } |
|
462 break; |
480 break; |
463 |
481 |
464 case EMPXItemModified: |
482 case EMPXItemModified: |
465 { |
483 { |
466 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------."); |
484 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------."); |
467 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items modified in MDS, updating cache |"); |
485 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items modified in MDS, updating cache |"); |
468 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------'"); |
486 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------'"); |
469 CMPXMedia* video; |
487 CMPXMedia* video; |
470 for ( TInt i = 0; i < aId.Count(); i++ ) |
488 #ifndef VIDEO_COLLECTION_PLUGIN_TB92 |
489 CMPXMedia* album; |
|
490 #endif |
|
491 TInt count = aId.Count(); |
|
492 for ( TInt i = count - 1; i >= 0; i-- ) |
|
471 { |
493 { |
472 video = iMyVideosMdsDb->CreateVideoL( aId[i], ETrue /* full details */ ); |
494 video = iMyVideosMdsDb->CreateVideoL( aId[i], ETrue /* full details */ ); |
473 |
495 |
474 if ( video ) |
496 if ( video ) |
475 { |
497 { |
477 iCache->UpdateVideoL( *video ); |
499 iCache->UpdateVideoL( *video ); |
478 CleanupStack::PopAndDestroy( video ); // <-1 |
500 CleanupStack::PopAndDestroy( video ); // <-1 |
479 } |
501 } |
480 else |
502 else |
481 { |
503 { |
504 #ifdef VIDEO_COLLECTION_PLUGIN_TB92 |
|
482 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: couldn't find the modified item from MDS"); |
505 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: couldn't find the modified item from MDS"); |
483 } |
506 aId.Remove( i ); |
484 } |
507 #else |
485 } |
508 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: item was not found from videos, checking albums"); |
486 SyncWithDownloadsL( aId ); |
509 album = iMyVideosMdsDb->iAlbums->GetAlbumL( aId[i] ); |
510 |
|
511 if ( album ) |
|
512 { |
|
513 CleanupStack::PushL( album ); // 1-> |
|
514 iAlbums->UpdateAlbumL( *album ); // this will add event to iMessageList if necessarry |
|
515 CleanupStack::PopAndDestroy( album ); // <-1 |
|
516 } |
|
517 else |
|
518 { |
|
519 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: couldn't find the modified item from MDS"); |
|
520 } |
|
521 aId.Remove( i ); |
|
522 #endif |
|
523 } |
|
524 } |
|
525 |
|
526 } |
|
487 break; |
527 break; |
488 } |
528 } |
489 |
529 |
490 TInt pos; |
530 TInt pos; |
491 for ( TInt i = 0; i < aId.Count(); i++ ) |
531 TInt count = aId.Count(); |
492 { |
532 for ( TInt i = 0; i < count; i++ ) |
493 if ( aEvent == EMPXItemInserted ) |
533 { |
494 { |
534 if ( aEvent == EMPXItemInserted ) |
495 // add item from cache to the message if we have it. |
535 { |
496 CMPXMedia* video = iCache->FindVideoByMdsIdL( aId[i], pos ); |
536 // add item from cache to the message if we have it. |
497 TRAP_IGNORE( iMessageList->AddEventL( TMPXItemId( aId[i], 0), aEvent, 0, video ) ); |
537 CMPXMedia* video = iCache->FindVideoByMdsIdL( aId[i], pos ); |
498 } |
538 TRAP_IGNORE( iMessageList->AddEventL( TMPXItemId( aId[i], KVcxMvcMediaTypeVideo), |
499 else |
539 aEvent, 0, video ) ); |
500 { |
540 } |
501 TRAP_IGNORE( iMessageList->AddEventL( TMPXItemId( aId[i], 0), aEvent ) ); |
541 else |
502 } |
542 { |
503 } |
543 TRAP_IGNORE( iMessageList->AddEventL( TMPXItemId( aId[i], KVcxMvcMediaTypeVideo), |
504 |
544 aEvent ) ); |
505 iMessageList->SendL(); |
545 } |
546 } |
|
547 |
|
548 #ifndef VIDEO_COLLECTION_PLUGIN_TB92 |
|
549 //nonVideoIds are albums |
|
550 count = nonVideoIds.Count(); |
|
551 for ( TInt i = 0; i < count; i++ ) |
|
552 { |
|
553 TRAP_IGNORE( iMessageList->AddEventL( |
|
554 TMPXItemId( nonVideoIds[i], KVcxMvcMediaTypeAlbum ), aEvent ) ); |
|
555 } |
|
556 |
|
557 iAlbums->UpdateChangedAlbumsL(); |
|
558 #endif |
|
559 |
|
560 CleanupStack::PopAndDestroy( &nonVideoIds ); |
|
561 iMessageList->SendL(); |
|
506 } |
562 } |
507 |
563 |
508 // ---------------------------------------------------------------------------- |
564 // ---------------------------------------------------------------------------- |
509 // CVcxMyVideosCollectionPlugin::HandleStepL |
565 // CVcxMyVideosCollectionPlugin::HandleStepL |
510 // ---------------------------------------------------------------------------- |
566 // ---------------------------------------------------------------------------- |
511 // |
567 // |
512 TBool CVcxMyVideosCollectionPlugin::HandleStepL() |
568 MVcxMyVideosActiveTaskObserver::TStepResult CVcxMyVideosCollectionPlugin::HandleStepL() |
513 { |
569 { |
514 MPX_FUNC("CVcxMyVideosCollectionPlugin::HandleStepL"); |
570 MPX_FUNC("CVcxMyVideosCollectionPlugin::HandleStepL"); |
515 |
571 |
516 TBool done(ETrue); |
572 MVcxMyVideosActiveTaskObserver::TStepResult stepResult(MVcxMyVideosActiveTaskObserver::EDone); |
517 |
573 |
518 switch ( iActiveTask->GetTask() ) |
574 switch ( iActiveTask->GetTask() ) |
519 { |
575 { |
520 case KMPXCommandIdCollectionSet: |
576 case KMPXCommandIdCollectionSet: |
521 { |
577 { |
530 |
586 |
531 CleanupStack::PopAndDestroy( video ); |
587 CleanupStack::PopAndDestroy( video ); |
532 |
588 |
533 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: async KMPXCommandIdCollectionSet out"); |
589 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: async KMPXCommandIdCollectionSet out"); |
534 |
590 |
535 done = ETrue; |
591 stepResult = MVcxMyVideosActiveTaskObserver::EDone; |
536 |
|
537 break; |
592 break; |
538 } |
593 } |
539 case KVcxCommandIdMyVideos: |
594 case KVcxCommandIdMyVideos: |
540 { |
595 { |
541 CMPXCommand& cmd = iActiveTask->GetCommand(); |
596 CMPXCommand& cmd = iActiveTask->GetCommand(); |
546 } |
601 } |
547 |
602 |
548 TInt myVideosCmd( cmd.ValueTObjectL<TUint>( KVcxMediaMyVideosCommandId ) ); |
603 TInt myVideosCmd( cmd.ValueTObjectL<TUint>( KVcxMediaMyVideosCommandId ) ); |
549 |
604 |
550 switch ( myVideosCmd ) |
605 switch ( myVideosCmd ) |
551 { |
606 { |
552 case KVcxCommandMyVideosStartDownload: |
|
553 { |
|
554 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: Handling KVcxCommandMyVideosStartDownload command."); |
|
555 |
|
556 CMPXMedia* video = CMPXMedia::NewL( *(iActiveTask->GetCommand().Value<CMPXMedia>( |
|
557 KMPXCommandColAddMedia)) ); |
|
558 CleanupStack::PushL( video ); // 1-> |
|
559 |
|
560 if ( !iCache->iVideoList ) |
|
561 { |
|
562 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: iVideoListCache = NULL -> creating new empty iVideoListCache"); |
|
563 iCache->iVideoListIsPartial = ETrue; |
|
564 iCache->iVideoList = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL(); |
|
565 } |
|
566 |
|
567 TBool resume = EFalse; |
|
568 |
|
569 if ( video->IsSupported( KVcxMediaMyVideosDownloadId ) ) |
|
570 { |
|
571 TUint32 downloadId = video->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ); |
|
572 if ( downloadId != 0 ) |
|
573 { |
|
574 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: download id %d given by the client -> this is download resume", |
|
575 downloadId); |
|
576 resume = ETrue; |
|
577 |
|
578 // load the existing item to cache if its not there already |
|
579 } |
|
580 } |
|
581 |
|
582 if ( !resume ) |
|
583 { |
|
584 if ( !video->IsSupported( KVcxMediaMyVideosRemoteUrl ) ) |
|
585 { |
|
586 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: KVcxMediaMyVideosRemoteUrl not supported -> leaving with KErrArgument"); |
|
587 User::Leave( KErrArgument ); |
|
588 } |
|
589 |
|
590 if ( video->ValueText( KVcxMediaMyVideosRemoteUrl ).Length() > |
|
591 KVcxMvcMaxUrlLength ) |
|
592 { |
|
593 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: url longer than 1024 -> leaving with KErrArgument"); |
|
594 User::Leave( KErrArgument ); |
|
595 } |
|
596 |
|
597 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: starting download for url: %S", |
|
598 &video->ValueText( KVcxMediaMyVideosRemoteUrl ) ); |
|
599 |
|
600 video->SetTObjectValueL<TUint8>( KVcxMediaMyVideosOrigin, EVcxMyVideosOriginDownloaded ); |
|
601 video->SetTObjectValueL<TUint8>( KVcxMediaMyVideosDownloadState, |
|
602 static_cast<TUint8>(EVcxMyVideosDlStateDownloading) ); |
|
603 video->SetTObjectValueL<TUint32>( KMPXMediaGeneralFlags, EVcxMyVideosVideoNew ); |
|
604 |
|
605 HBufC* fileName = DownloadUtilL().CreateFilePathL( *video ); |
|
606 CleanupStack::PushL( fileName ); // 2-> |
|
607 video->SetTextValueL( KMPXMediaGeneralUri, *fileName ); |
|
608 CleanupStack::PopAndDestroy( fileName ); // <-2 |
|
609 } |
|
610 |
|
611 TRAPD( err, DownloadUtilL().StartDownloadL( *video ) ); //download id is written to video object |
|
612 |
|
613 if ( err != KErrNone ) |
|
614 { |
|
615 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: StartDownloadL left: %d", err); |
|
616 User::Leave( err ); |
|
617 } |
|
618 |
|
619 if ( !resume ) |
|
620 { |
|
621 TUint32 newDownloadId = video->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ); |
|
622 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: new download ID: %d", |
|
623 newDownloadId); |
|
624 |
|
625 AddVideoToMdsAndCacheL( *video ); |
|
626 } |
|
627 else |
|
628 { |
|
629 // clear old error codes from the dl item |
|
630 TInt pos; |
|
631 |
|
632 CMPXMedia* videoInCache = iCache->FindVideoByMdsIdL( |
|
633 TVcxMyVideosCollectionUtil::IdL( *video ), pos ); |
|
634 if ( videoInCache ) |
|
635 { |
|
636 videoInCache->SetTObjectValueL<TInt>( KVcxMediaMyVideosDownloadError, 0 ); |
|
637 videoInCache->SetTObjectValueL<TInt>( KVcxMediaMyVideosDownloadGlobalError, 0 ); |
|
638 } |
|
639 } |
|
640 |
|
641 CleanupStack::PopAndDestroy( video ); // <-1 |
|
642 done = ETrue; |
|
643 } |
|
644 break; |
|
645 |
|
646 case KVcxCommandMyVideosCancelDownload: |
|
647 { |
|
648 // Error code is returned to client if dl item was left to system. |
|
649 // If file delete fails, then mds item is also left to system. |
|
650 |
|
651 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: Handling KVcxCommandMyVideosCancelDownload command."); |
|
652 |
|
653 CMPXMedia* video = CMPXMedia::NewL( *(iActiveTask->GetCommand().Value<CMPXMedia>( |
|
654 KMPXCommandColAddMedia)) ); |
|
655 CleanupStack::PushL( video ); // 1-> |
|
656 |
|
657 if ( !video->IsSupported( KVcxMediaMyVideosDownloadId ) || |
|
658 !video->IsSupported( KMPXMediaGeneralId ) || |
|
659 !video->IsSupported( KMPXMediaGeneralUri ) ) |
|
660 { |
|
661 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: parameter missing, can't cancel dl, leaving with KErrArgument"); |
|
662 User::Leave( KErrArgument ); |
|
663 } |
|
664 |
|
665 TUint32 downloadId = video->ValueTObjectL<TUint32>( |
|
666 KVcxMediaMyVideosDownloadId ); |
|
667 DownloadUtilL().CancelDownload( downloadId, ETrue /* remove file */ ); |
|
668 |
|
669 if ( BaflUtils::FileExists( iFs, video->ValueText( KMPXMediaGeneralUri ) ) ) |
|
670 { |
|
671 TMPXItemId mpxItemId = video->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ); |
|
672 TInt err( KErrNone ); |
|
673 |
|
674 for ( TInt i = 0; i < KMaxFileDeleteAttempts; i++ ) |
|
675 { |
|
676 TRAP( err, AsyncFileOperationsL().DeleteVideoL( mpxItemId.iId1, ETrue ) ); |
|
677 |
|
678 if ( err == KErrInUse ) |
|
679 { |
|
680 MPX_DEBUG1( "CVcxMyVideosCollectionPlugin:: file is already in use, waiting a moment and try again"); |
|
681 User::After( KFileDeleteLoopDelay ); |
|
682 } |
|
683 else |
|
684 { |
|
685 break; |
|
686 } |
|
687 } |
|
688 |
|
689 if ( err != KErrNone && err != KErrNotFound ) |
|
690 { |
|
691 #ifdef _DEBUG |
|
692 if ( err == KErrInUse ) |
|
693 { |
|
694 TVcxMyVideosCollectionUtil::PrintOpenFileHandlesL( |
|
695 video->ValueText( KMPXMediaGeneralUri ), iFs ); |
|
696 } |
|
697 #endif |
|
698 |
|
699 // Some error occured when cancelling download operation, dl item is however gone and file is left |
|
700 // -> change dl id to 0 and leave mpx collection item there. Report operation to client as a success. |
|
701 MPX_DEBUG1( "CVcxMyVideosCollectionPlugin:: dl item is gone from dl manager, file and mpx item are left, setting dl id to 0"); |
|
702 TRAP_IGNORE( SetDownloadIdToZeroL( downloadId ) ); |
|
703 } |
|
704 } |
|
705 |
|
706 CleanupStack::PopAndDestroy( video ); // <-1 |
|
707 done = ETrue; |
|
708 } |
|
709 break; |
|
710 |
|
711 case KVcxCommandMyVideosPauseDownload: |
|
712 { |
|
713 CMPXMedia& cmd = iActiveTask->GetCommand(); |
|
714 if ( !cmd.IsSupported( KVcxMediaMyVideosDownloadId ) ) |
|
715 { |
|
716 User::Leave( KErrArgument ); |
|
717 } |
|
718 else |
|
719 { |
|
720 TInt err = DownloadUtilL().PauseDownload( |
|
721 cmd.ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ) ); |
|
722 User::LeaveIfError( err ); |
|
723 } |
|
724 done = ETrue; |
|
725 } |
|
726 break; |
|
727 |
|
728 case KVcxCommandMyVideosGetMediaFullDetailsByMpxId: |
607 case KVcxCommandMyVideosGetMediaFullDetailsByMpxId: |
729 { |
608 { |
730 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: KVcxCommandMyVideosGetMediaFullDetailsByMpxId received"); |
609 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: KVcxCommandMyVideosGetMediaFullDetailsByMpxId received"); |
731 CMPXMedia& cmd = iActiveTask->GetCommand(); |
610 CMPXMedia& cmd = iActiveTask->GetCommand(); |
732 TMPXItemId mpxId( TVcxMyVideosCollectionUtil::IdL( cmd ) ); |
611 TMPXItemId mpxId( TVcxMyVideosCollectionUtil::IdL( cmd ) ); |
736 } |
615 } |
737 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: KVcxCommandMyVideosGetMediaFullDetailsByMpxId cmd: MDS ID %d requested", mpxId.iId1 ); |
616 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: KVcxCommandMyVideosGetMediaFullDetailsByMpxId cmd: MDS ID %d requested", mpxId.iId1 ); |
738 |
617 |
739 CMPXMedia* video = iMyVideosMdsDb->CreateVideoL( |
618 CMPXMedia* video = iMyVideosMdsDb->CreateVideoL( |
740 mpxId.iId1, ETrue /* full details */ ); |
619 mpxId.iId1, ETrue /* full details */ ); |
741 |
620 |
742 if ( !video ) |
621 if ( !video ) |
743 { |
622 { |
744 User::Leave( KErrGeneral ); |
623 User::Leave( KErrNotFound ); |
745 } |
624 } |
746 |
625 |
747 CleanupStack::PushL( video ); // 1-> |
626 CleanupStack::PushL( video ); // 1-> |
748 |
627 |
749 TBool eventsAdded; |
|
750 SyncVideoWithDownloadsL( *video, eventsAdded, |
|
751 EFalse /* dont add event to iMessageList */ ); |
|
752 |
|
753 cmd.SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, video ); |
628 cmd.SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, video ); |
754 CleanupStack::PopAndDestroy( video ); // <-1 |
629 CleanupStack::PopAndDestroy( video ); // <-1 |
755 |
630 |
756 cmd.SetTObjectValueL<TUid>(KMPXMessageCollectionId, TUid::Uid( |
631 cmd.SetTObjectValueL<TUid>(KMPXMessageCollectionId, TUid::Uid( |
757 KVcxUidMyVideosMpxCollection)); |
632 KVcxUidMyVideosMpxCollection)); |
758 |
633 |
759 done = ETrue; |
634 stepResult = MVcxMyVideosActiveTaskObserver::EDone; |
760 } |
635 } |
761 break; |
636 break; |
762 |
637 |
763 case KVcxCommandMyVideosGetMediasByMpxId: |
638 case KVcxCommandMyVideosGetMediasByMpxId: |
764 { |
639 { |
800 } |
675 } |
801 |
676 |
802 if ( !iCache->iVideoList ) |
677 if ( !iCache->iVideoList ) |
803 { |
678 { |
804 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: iVideoListCache = NULL -> creating new empty iCache->iVideoList"); |
679 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: iVideoListCache = NULL -> creating new empty iCache->iVideoList"); |
805 iCache->iVideoListIsPartial = ETrue; |
680 iCache->SetComplete( EFalse ); |
806 iCache->iVideoList = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL(); |
681 iCache->iVideoList = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL(); |
807 } |
682 } |
808 |
683 |
809 TBool videoListFetchingWasCancelled = EFalse; |
684 TBool videoListFetchingWasCancelled = EFalse; |
810 |
685 |
811 if ( iCache->iVideoListIsPartial ) |
686 if ( !iCache->IsComplete() ) |
812 { |
687 { |
813 // Load items to cache |
688 // Load items to cache |
814 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: loading requested items to iCache->iVideoList"); |
689 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: loading requested items to iCache->iVideoList"); |
815 |
690 |
816 iCache->AddVideosFromMdsL( mdsIds, videoListFetchingWasCancelled ); |
691 iCache->AddVideosFromMdsL( mdsIds, videoListFetchingWasCancelled ); |
817 if ( mdsIds.Count() > 0 ) |
|
818 { |
|
819 SyncWithDownloadsL( mdsIds ); |
|
820 } |
|
821 } |
692 } |
822 else |
693 else |
823 { |
694 { |
824 // iCache->iVideoList contains all |
695 // iCache->iVideoList contains all |
825 } |
696 } |
848 |
719 |
849 CleanupStack::Pop( message ); // <-3 |
720 CleanupStack::Pop( message ); // <-3 |
850 CleanupStack::PopAndDestroy( &mdsIds2 ); // <-2 |
721 CleanupStack::PopAndDestroy( &mdsIds2 ); // <-2 |
851 CleanupStack::PopAndDestroy( &mdsIds ); // <-1 |
722 CleanupStack::PopAndDestroy( &mdsIds ); // <-1 |
852 |
723 |
853 done = ETrue; |
724 stepResult = MVcxMyVideosActiveTaskObserver::EDone; |
854 } |
725 } |
855 break; |
726 break; |
856 |
727 |
857 case KVcxCommandMyVideosCopy: |
728 case KVcxCommandMyVideosCopy: |
858 case KVcxCommandMyVideosMove: |
729 case KVcxCommandMyVideosMove: |
859 { |
730 { |
860 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: KVcxCommandMyVideosMove or Copy step"); |
731 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: KVcxCommandMyVideosMove or Copy step"); |
861 done = AsyncFileOperationsL().HandleMoveOrCopyStepL(); |
732 stepResult = AsyncFileOperationsL().HandleMoveOrCopyStepL(); |
862 } |
733 } |
863 break; |
734 break; |
864 |
735 |
865 case KVcxCommandMyVideosDelete: |
736 case KVcxCommandMyVideosDelete: |
866 { |
737 { |
867 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: KVcxCommandMyVideosDelete step"); |
738 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: KVcxCommandMyVideosDelete step"); |
868 done = AsyncFileOperationsL().HandleDeleteStepL(); |
739 stepResult = AsyncFileOperationsL().HandleDeleteStepL(); |
869 } |
740 } |
870 break; |
741 break; |
742 |
|
743 case KVcxCommandMyVideosAddToAlbum: |
|
744 iAlbums->AddVideosToAlbumL( &iActiveTask->GetCommand() ); |
|
745 stepResult = MVcxMyVideosActiveTaskObserver::EStopStepping; |
|
746 break; |
|
747 |
|
748 case KVcxCommandMyVideosRemoveFromAlbum: |
|
749 iAlbums->RemoveVideosFromAlbumL( &iActiveTask->GetCommand() ); |
|
750 stepResult = MVcxMyVideosActiveTaskObserver::EStopStepping; |
|
751 break; |
|
752 |
|
753 case KVcxCommandMyVideosAddAlbum: |
|
754 { |
|
755 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: async KVcxCommandMyVideosAddAlbum arrived"); |
|
756 AlbumsL().AddAlbumL( iActiveTask->GetCommand() ); |
|
757 stepResult = MVcxMyVideosActiveTaskObserver::EDone; |
|
758 break; |
|
759 } |
|
760 |
|
761 case KVcxCommandMyVideosRemoveAlbums: |
|
762 { |
|
763 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: async KVcxCommandMyVideosRemoveAlbums arrived"); |
|
764 AlbumsL().RemoveAlbumsFromMdsOnlyL( iActiveTask->Command() ); |
|
765 stepResult = MVcxMyVideosActiveTaskObserver::EStopStepping; |
|
766 break; |
|
767 } |
|
768 |
|
769 |
|
871 } |
770 } |
872 } |
771 } |
873 break; |
772 break; |
874 |
773 |
875 |
774 |
876 case KMPXCommandIdCollectionRemoveMedia: |
775 case KMPXCommandIdCollectionRemoveMedia: |
877 { |
776 { |
878 TMPXItemId mpxId = iActiveTask->GetCommand().ValueTObjectL<TMPXItemId>( |
777 TMPXItemId mpxId = iActiveTask->GetCommand().ValueTObjectL<TMPXItemId>( |
879 KMPXMediaGeneralId ); |
778 KMPXMediaGeneralId ); |
880 AsyncFileOperationsL().DeleteVideoL( mpxId.iId1 ); |
779 AsyncFileOperationsL().DeleteVideoL( mpxId.iId1 ); |
881 done = ETrue; |
780 stepResult = MVcxMyVideosActiveTaskObserver::EDone; |
882 break; |
781 break; |
883 } |
782 } |
884 |
783 |
885 default: |
784 default: |
886 { |
785 { |
887 // Should never happen! |
786 // Should never happen! |
888 ASSERT(0); |
787 ASSERT(0); |
889 break; |
788 break; |
890 } |
789 } |
891 } |
790 } |
892 return done; |
791 return stepResult; |
893 } |
792 } |
894 |
793 |
895 |
794 |
896 // ---------------------------------------------------------------------------- |
795 // ---------------------------------------------------------------------------- |
897 // Handler for async operations completed |
796 // Handler for async operations completed |
903 MPX_FUNC("CVcxMyVideosCollectionPlugin::HandleOperationCompleted"); |
802 MPX_FUNC("CVcxMyVideosCollectionPlugin::HandleOperationCompleted"); |
904 |
803 |
905 if ( aErr != KErrNone ) |
804 if ( aErr != KErrNone ) |
906 { |
805 { |
907 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: Leave or cancel happened during the operation: %d", aErr); |
806 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: Leave or cancel happened during the operation: %d", aErr); |
908 TRAPD( err, AsyncFileOperationsL().CancelOperationL( aErr ) ); // generates resp message for move,copy or delete operations |
807 |
909 if ( err != KErrNone ) |
808 if ( iAsyncFileOperations ) |
910 { |
809 { |
911 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: failed to generate resp msg: %d", err); |
810 TRAPD( err, AsyncFileOperationsL().CancelOperationL( aErr ) ); // generates resp message for move,copy or delete operations |
811 if ( err != KErrNone ) |
|
812 { |
|
813 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: failed to generate resp msg: %d", err); |
|
814 } |
|
912 } |
815 } |
913 } |
816 } |
914 |
817 |
915 |
818 |
916 |
819 |
919 |
822 |
920 iObs->HandleCommandComplete( &cmd, KErrNone ); |
823 iObs->HandleCommandComplete( &cmd, KErrNone ); |
921 } |
824 } |
922 |
825 |
923 // ---------------------------------------------------------------------------- |
826 // ---------------------------------------------------------------------------- |
924 // CVcxMyVideosCollectionPlugin::HandleDlEvent |
|
925 // From CVcxMyVideosDownloadUtilObserver |
|
926 // ---------------------------------------------------------------------------- |
|
927 // |
|
928 void CVcxMyVideosCollectionPlugin::HandleDlEvent( TVcxMyVideosDownloadState aState, |
|
929 TUint32 aDownloadId, |
|
930 TInt aProgress, |
|
931 TInt64 aDownloaded, |
|
932 TInt32 aError, |
|
933 TInt32 aGlobalError ) |
|
934 { |
|
935 TRAPD( err, DoHandleDlEventL( aState, aDownloadId, aProgress, |
|
936 aDownloaded, aError, aGlobalError ) ); |
|
937 if ( err != KErrNone ) |
|
938 { |
|
939 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: DoHandleDlEventL left with error code: %d", err); |
|
940 } |
|
941 } |
|
942 |
|
943 // ---------------------------------------------------------------------------- |
|
944 // CVcxMyVideosCollectionPlugin::DoHandleDlEventL |
|
945 // ---------------------------------------------------------------------------- |
|
946 // |
|
947 void CVcxMyVideosCollectionPlugin::DoHandleDlEventL( TVcxMyVideosDownloadState aState, |
|
948 TUint32 aDownloadId, |
|
949 TInt aProgress, |
|
950 TInt64 aDownloaded, |
|
951 TInt32 aError, |
|
952 TInt32 aGlobalError ) |
|
953 { |
|
954 MPX_FUNC("CVcxMyVideosCollectionPlugin::DoHandleDlEventL"); |
|
955 |
|
956 CMPXMedia* video = iCache->FindVideoByDownloadIdL( aDownloadId ); |
|
957 |
|
958 MPX_DEBUG3("CVcxMyVideosCollectionPlugin:: dl event for download ID %d, pointer = %x) arrived.", aDownloadId, video); |
|
959 |
|
960 TBool sendEvent = EFalse; |
|
961 if ( video ) |
|
962 { |
|
963 TMPXItemId mpxId( TVcxMyVideosCollectionUtil::IdL( *video ) ); |
|
964 MPX_DEBUG4("CVcxMyVideosCollectionPlugin:: MPX item (MDS ID %d) (DL ID %d) %S", |
|
965 mpxId.iId1, aDownloadId, &TVcxMyVideosCollectionUtil::Title( *video ) ); |
|
966 |
|
967 TUint8 currentState = TVcxMyVideosCollectionUtil::DownloadStateL( *video ); |
|
968 |
|
969 if ( currentState == EVcxMyVideosDlStateDownloaded ) |
|
970 { |
|
971 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: already in Downloaded state, discarding event"); |
|
972 return; |
|
973 } |
|
974 |
|
975 if ( currentState != aState ) |
|
976 { |
|
977 MPX_DEBUG5("CVcxMyVideosCollectionPlugin:: updating (mds id: %d) (dl id: %d) state: %S -> %S", |
|
978 mpxId.iId1, aDownloadId, &DownloadState( currentState ), &DownloadState( aState ) ); |
|
979 video->SetTObjectValueL<TUint8>( KVcxMediaMyVideosDownloadState, static_cast<TUint8>(aState) ); |
|
980 sendEvent = ETrue; |
|
981 |
|
982 if ( aState == EVcxMyVideosDlStateDownloaded ) |
|
983 { |
|
984 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: downloaded state received -> setting download id to 0"); |
|
985 |
|
986 //1. set download id to 0 |
|
987 video->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 ); |
|
988 |
|
989 //2. update drm flag |
|
990 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
991 RFile64 dlFile; |
|
992 #else |
|
993 RFile dlFile; |
|
994 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
995 TInt err = dlFile.Open( iFs, video->ValueText( KMPXMediaGeneralUri ), EFileRead ); |
|
996 if ( err == KErrNone ) |
|
997 { |
|
998 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: file opened ok for drm reading"); |
|
999 CleanupClosePushL( dlFile ); // 1-> |
|
1000 DRM::CDrmUtility* drmUtil = DRM::CDrmUtility::NewLC(); // 2-> |
|
1001 if ( drmUtil->IsProtectedL( dlFile ) ) |
|
1002 { |
|
1003 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: file is DRM protected, setting the property flag"); |
|
1004 TUint32 flags = video->ValueTObjectL<TUint32>( KMPXMediaGeneralFlags ); |
|
1005 flags |= EVcxMyVideosVideoDrmProtected; |
|
1006 video->SetTObjectValueL<TUint32>( KMPXMediaGeneralFlags, flags ); |
|
1007 } |
|
1008 else |
|
1009 { |
|
1010 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: file is not DRM protected"); |
|
1011 } |
|
1012 CleanupStack::PopAndDestroy( drmUtil ); // <-2 |
|
1013 CleanupStack::PopAndDestroy( &dlFile ); // <-1 |
|
1014 } |
|
1015 else |
|
1016 { |
|
1017 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: file didnt open for drm reading, %d", err); |
|
1018 } |
|
1019 NotifyDownloadCompletedL( *video ); |
|
1020 |
|
1021 //3. Update file size using iCache->UpdateVideoL function since it changes item position and |
|
1022 // sends category modified events if necessarry. |
|
1023 CMPXMedia* updateObject = CMPXMedia::NewL(); |
|
1024 CleanupStack::PushL( updateObject ); // 1-> |
|
1025 updateObject->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, mpxId ); |
|
1026 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
1027 updateObject->SetTObjectValueL<TInt64>( KMPXMediaGeneralExtSizeInt64, |
|
1028 static_cast<TInt64>( aDownloaded ) ); |
|
1029 // set current value to 0 to force event sending and video list position updating |
|
1030 video->SetTObjectValueL<TInt64>( KMPXMediaGeneralExtSizeInt64, 0 ); |
|
1031 #else |
|
1032 updateObject->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, |
|
1033 static_cast<TInt>( aDownloaded ) ); |
|
1034 // set current value to 0 to force event sending and video list position updating |
|
1035 video->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, 0 ); |
|
1036 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
1037 iCache->UpdateVideoL( *updateObject ); |
|
1038 CleanupStack::PopAndDestroy( updateObject ); // <-1 |
|
1039 // find video again since it might have been deleted in iCache->UpdateVideoL |
|
1040 TInt pos; |
|
1041 video = iCache->FindVideoByMdsIdL( mpxId.iId1, pos ); |
|
1042 |
|
1043 //file size and download id are saved to database |
|
1044 iMyVideosMdsDb->UpdateVideoL( *video ); |
|
1045 sendEvent = EFalse; // MDS will send the event, this avoids duplicate |
|
1046 } |
|
1047 |
|
1048 if ( aState == EVcxMyVideosDlStateFailed ) |
|
1049 { |
|
1050 video->SetTObjectValueL<TInt32>( KVcxMediaMyVideosDownloadError, aError ); |
|
1051 video->SetTObjectValueL<TInt32>( KVcxMediaMyVideosDownloadGlobalError, |
|
1052 aGlobalError ); |
|
1053 } |
|
1054 } |
|
1055 else |
|
1056 { |
|
1057 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: state was already same(%S), skipping state update.", &DownloadState( currentState )); |
|
1058 } |
|
1059 |
|
1060 TInt8 currentProgress = video->ValueTObjectL<TInt8>( KVcxMediaMyVideosDownloadProgress ); |
|
1061 if ( currentProgress != aProgress ) |
|
1062 { |
|
1063 MPX_DEBUG4("CVcxMyVideosCollectionPlugin:: (dl id: %d) progress: %d -> %d", |
|
1064 aDownloadId, currentProgress, aProgress ); |
|
1065 |
|
1066 video->SetTObjectValueL<TInt8>( KVcxMediaMyVideosDownloadProgress, |
|
1067 static_cast<TInt8>( aProgress ) ); |
|
1068 // Don't send the update event for progress. |
|
1069 //sendEvent = ETrue; |
|
1070 } |
|
1071 else |
|
1072 { |
|
1073 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: progress was already same(%d), skipping progress update.", currentProgress); |
|
1074 } |
|
1075 |
|
1076 TInt64 currentFileSize = 0; |
|
1077 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
1078 if ( video->IsSupported( KMPXMediaGeneralExtSizeInt64 ) ) |
|
1079 { |
|
1080 currentFileSize = video->ValueTObjectL<TInt64>( KMPXMediaGeneralExtSizeInt64 ); |
|
1081 } |
|
1082 #else |
|
1083 if ( video->IsSupported( KMPXMediaGeneralSize ) ) |
|
1084 { |
|
1085 currentFileSize = video->ValueTObjectL<TInt>( KMPXMediaGeneralSize ); |
|
1086 } |
|
1087 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
1088 if ( currentFileSize != aDownloaded ) |
|
1089 { |
|
1090 MPX_DEBUG4("CVcxMyVideosCollectionPlugin:: updating (dl id: %d) size: %ld -> %ld", |
|
1091 aDownloadId, currentFileSize, aDownloaded ); |
|
1092 |
|
1093 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
1094 video->SetTObjectValueL<TInt64>( KMPXMediaGeneralExtSizeInt64, aDownloaded ); |
|
1095 #else |
|
1096 TInt newFileSize( aDownloaded ); |
|
1097 video->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, newFileSize ); |
|
1098 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
1099 //sendEvent = ETrue; |
|
1100 } |
|
1101 |
|
1102 if ( sendEvent ) |
|
1103 { |
|
1104 iMessageList->AddEventL( mpxId, EMPXItemModified ); |
|
1105 iMessageList->SendL(); |
|
1106 } |
|
1107 } |
|
1108 else |
|
1109 { |
|
1110 if ( (aState != EVcxMyVideosDlStateDownloaded) && (aProgress < 100) && |
|
1111 !iCache->iVideoListIsPartial ) |
|
1112 { |
|
1113 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: -----------------------------------------------------------------------."); |
|
1114 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: Event for progressing download arrived, but the MPX/MDS item not found!|"); |
|
1115 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: -> deleting download. |"); |
|
1116 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: -----------------------------------------------------------------------'"); |
|
1117 |
|
1118 RHttpDownload* download = DownloadUtilL().Download( aDownloadId ); |
|
1119 if ( download ) |
|
1120 { |
|
1121 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: Download ID (%d) not found from MPX/MDS, deleting download!", |
|
1122 aDownloadId ); |
|
1123 DownloadUtilL().DeleteDownloadAsync( aDownloadId, ETrue ); |
|
1124 } |
|
1125 } |
|
1126 } |
|
1127 } |
|
1128 |
|
1129 // ---------------------------------------------------------------------------- |
|
1130 // CVcxMyVideosCollectionPlugin::SyncWithDownloadsL |
|
1131 // ---------------------------------------------------------------------------- |
|
1132 // |
|
1133 void CVcxMyVideosCollectionPlugin::SyncWithDownloadsL( |
|
1134 RArray<TUint32>& aItemsInCache ) |
|
1135 { |
|
1136 MPX_FUNC("CVcxMyVideosCollectionPlugin::SyncWithDownloadsL()"); |
|
1137 |
|
1138 TBool eventsAdded = EFalse; |
|
1139 for ( TInt i = 0; i < aItemsInCache.Count(); i++ ) |
|
1140 { |
|
1141 TInt pos; |
|
1142 CMPXMedia* video = iCache->FindVideoByMdsIdL( aItemsInCache[i], pos ); |
|
1143 if ( video ) |
|
1144 { |
|
1145 SyncVideoWithDownloadsL( *video, eventsAdded ); |
|
1146 } |
|
1147 } |
|
1148 if ( eventsAdded ) |
|
1149 { |
|
1150 iMessageList->SendL(); |
|
1151 } |
|
1152 } |
|
1153 |
|
1154 // ---------------------------------------------------------------------------- |
|
1155 // CVcxMyVideosCollectionPlugin::SyncVideoWithDownloadsL |
|
1156 // ---------------------------------------------------------------------------- |
|
1157 // |
|
1158 void CVcxMyVideosCollectionPlugin::SyncVideoWithDownloadsL( CMPXMedia& aVideo, |
|
1159 TBool& aEventAdded, TBool aAddEvent ) |
|
1160 { |
|
1161 TInt downloadId( TVcxMyVideosCollectionUtil::DownloadIdL( aVideo ) ); |
|
1162 |
|
1163 if ( downloadId ) |
|
1164 { |
|
1165 RHttpDownload* download( DownloadUtilL().Download( downloadId ) ); |
|
1166 |
|
1167 if ( download ) |
|
1168 { |
|
1169 MPX_DEBUG2("CVcxMyVideosCollectionPlugin::SyncVideoWithDownloadsL() item (DL ID: %d) found from dl manager", downloadId); |
|
1170 |
|
1171 TBool modified = EFalse; |
|
1172 SyncVideoAndDownloadL( aVideo, *download, modified ); |
|
1173 if ( modified && aAddEvent ) |
|
1174 { |
|
1175 iMessageList->AddEventL( TVcxMyVideosCollectionUtil::IdL( aVideo ), |
|
1176 EMPXItemModified ); |
|
1177 aEventAdded = ETrue; |
|
1178 } |
|
1179 } |
|
1180 else |
|
1181 { |
|
1182 //download id != 0 and it is not found from download manager -> we set download id to 0 |
|
1183 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: download id %d != 0 and no corresponding download found from Download Manager", |
|
1184 downloadId); |
|
1185 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: -> setting download id to 0"); |
|
1186 aVideo.SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 ); |
|
1187 iMyVideosMdsDb->UpdateVideoL( aVideo ); // if video list fetching is ongoing, this will leave with KErrNotReady |
|
1188 } |
|
1189 } |
|
1190 } |
|
1191 |
|
1192 // ---------------------------------------------------------------------------- |
|
1193 // CVcxMyVideosCollectionPlugin::SyncVideoAndDownloadL |
|
1194 // ---------------------------------------------------------------------------- |
|
1195 // |
|
1196 void CVcxMyVideosCollectionPlugin::SyncVideoAndDownloadL( |
|
1197 CMPXMedia& aVideo, |
|
1198 RHttpDownload& aDownload, |
|
1199 TBool& aModified ) |
|
1200 { |
|
1201 MPX_FUNC("CVcxMyVideosCollectionPlugin::SyncVideoAndDownloadL()"); |
|
1202 |
|
1203 aModified = EFalse; |
|
1204 |
|
1205 TBuf<KMaxUrlLength> downloadUrl; |
|
1206 aDownload.GetStringAttribute( EDlAttrReqUrl, downloadUrl ); |
|
1207 if ( aVideo.ValueText( KVcxMediaMyVideosRemoteUrl ) |
|
1208 != downloadUrl ) |
|
1209 { |
|
1210 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: urls in MPX and DL Manager differ!"); |
|
1211 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: remote url in MPX: %S", |
|
1212 &(aVideo.ValueText( KVcxMediaMyVideosRemoteUrl ))); |
|
1213 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: remote url in DL Manager: %S", |
|
1214 &downloadUrl); |
|
1215 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: -> updating MPX cache"); |
|
1216 |
|
1217 aVideo.SetTextValueL( KVcxMediaMyVideosRemoteUrl, downloadUrl ); |
|
1218 aModified = ETrue; |
|
1219 } |
|
1220 else |
|
1221 { |
|
1222 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: remote urls already same in dl manager and mpx"); |
|
1223 } |
|
1224 |
|
1225 // KVcxMediaMyVideosDownloadState |
|
1226 TVcxMyVideosDownloadState dlStateInDlManager; |
|
1227 DownloadUtilL().GetDownloadState( aDownload, dlStateInDlManager ); |
|
1228 |
|
1229 TUint8 dlStateInMpxCache; |
|
1230 if ( aVideo.IsSupported( KVcxMediaMyVideosDownloadState )) |
|
1231 { |
|
1232 dlStateInMpxCache = aVideo.ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState ); |
|
1233 } |
|
1234 else |
|
1235 { |
|
1236 dlStateInMpxCache = static_cast<TUint8>( EVcxMyVideosDlStateNone ); |
|
1237 } |
|
1238 |
|
1239 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: dl state in dl manager: %S", &DownloadState( dlStateInDlManager )); |
|
1240 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: dl state in mpx cache: %S", &DownloadState( dlStateInMpxCache )); |
|
1241 |
|
1242 if ( static_cast<TUint8>( dlStateInDlManager ) != dlStateInMpxCache ) |
|
1243 { |
|
1244 if ( dlStateInDlManager == EVcxMyVideosDlStateDownloaded ) |
|
1245 { |
|
1246 // Download finished event has arrived when we weren't around, call event handler to get things right. |
|
1247 // Collection is updated and download is deleted from Download Manager. |
|
1248 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: Download is in Finished state and collection has download id != 0"); |
|
1249 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: -> we have missed download finished event, lets generate it by ourselves."); |
|
1250 |
|
1251 TUint64 downloaded( 0 ); |
|
1252 TUint8 progress( DownloadUtilL().DownloadProgress( aDownload, downloaded, EFalse ) ); |
|
1253 TUint32 downloadId( aVideo.ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ) ); |
|
1254 HandleDlEvent( dlStateInDlManager, downloadId, |
|
1255 progress, downloaded, KErrNone, KErrNone ); |
|
1256 DownloadUtilL().DeleteDownloadAsync( downloadId, EFalse /* don't delete content */ ); |
|
1257 } |
|
1258 else |
|
1259 { |
|
1260 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: dl state in dl manager differs of mpx cache-> updating mpx cache"); |
|
1261 aVideo.SetTObjectValueL<TUint8>( KVcxMediaMyVideosDownloadState, |
|
1262 static_cast<TUint8>( dlStateInDlManager ) ); |
|
1263 aModified = ETrue; |
|
1264 } |
|
1265 } |
|
1266 else |
|
1267 { |
|
1268 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: download state already same in dl manager and mds"); |
|
1269 } |
|
1270 |
|
1271 // KVcxMediaMyVideosDownloadProgress |
|
1272 TUint64 downloaded = 0; |
|
1273 TInt8 dlProgressInDlManager = DownloadUtilL().DownloadProgress( |
|
1274 aDownload, downloaded, EFalse ); |
|
1275 |
|
1276 TInt8 dlProgressInMpxCache; |
|
1277 if ( aVideo.IsSupported( KVcxMediaMyVideosDownloadProgress ) ) |
|
1278 { |
|
1279 dlProgressInMpxCache = aVideo.ValueTObjectL<TInt8>( KVcxMediaMyVideosDownloadProgress ); |
|
1280 } |
|
1281 else |
|
1282 { |
|
1283 aVideo.SetTObjectValueL<TInt8>( KVcxMediaMyVideosDownloadProgress, 0 ); |
|
1284 dlProgressInMpxCache = 0; |
|
1285 } |
|
1286 |
|
1287 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: dl progress in dl manager: %d", dlProgressInDlManager); |
|
1288 MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: dl progress in mpx cache: %d", dlProgressInMpxCache); |
|
1289 |
|
1290 if ( dlProgressInDlManager != dlProgressInMpxCache ) |
|
1291 { |
|
1292 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: dl progress in dl manager differs of mpx cache-> updating mpx cache"); |
|
1293 aVideo.SetTObjectValueL<TInt8>( KVcxMediaMyVideosDownloadProgress, |
|
1294 static_cast<TInt8>( dlProgressInDlManager ) ); |
|
1295 aModified = ETrue; |
|
1296 } |
|
1297 else |
|
1298 { |
|
1299 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: download progress already same in dl manager and mds"); |
|
1300 } |
|
1301 } |
|
1302 |
|
1303 // ---------------------------------------------------------------------------- |
|
1304 // CVcxMyVideosCollectionPlugin::SyncVideoListWithDownloadsL |
|
1305 // ---------------------------------------------------------------------------- |
|
1306 // |
|
1307 void CVcxMyVideosCollectionPlugin::SyncVideoListWithDownloadsL( CMPXMedia& aVideoList, |
|
1308 TBool aSendEvents, TInt aStartPos ) |
|
1309 { |
|
1310 MPX_FUNC("CVcxMyVideosCollectionPlugin::SyncVideoListWithDownloadsL"); |
|
1311 |
|
1312 CMPXMediaArray* videoArray = aVideoList.Value<CMPXMediaArray>( |
|
1313 KMPXMediaArrayContents); |
|
1314 |
|
1315 CMPXMedia* video; |
|
1316 |
|
1317 TBool eventsAdded = EFalse; |
|
1318 for ( TInt i = aStartPos; i < videoArray->Count(); i++ ) |
|
1319 { |
|
1320 video = (*videoArray)[i]; |
|
1321 SyncVideoWithDownloadsL( *video, eventsAdded, aSendEvents ); |
|
1322 } |
|
1323 if ( eventsAdded ) |
|
1324 { |
|
1325 iMessageList->SendL(); |
|
1326 } |
|
1327 } |
|
1328 |
|
1329 // ---------------------------------------------------------------------------- |
|
1330 // CVcxMyVideosCollectionPlugin::DownloadUtil |
|
1331 // ---------------------------------------------------------------------------- |
|
1332 // |
|
1333 CVcxMyVideosDownloadUtil& CVcxMyVideosCollectionPlugin::DownloadUtilL() |
|
1334 { |
|
1335 if ( !iDownloadUtil ) |
|
1336 { |
|
1337 iDownloadUtil = CVcxMyVideosDownloadUtil::NewL( *this, iFs ); |
|
1338 } |
|
1339 |
|
1340 if ( !iOrphanDownloadsCleared ) |
|
1341 { |
|
1342 if ( !iCache->iVideoListIsPartial ) |
|
1343 { |
|
1344 iOrphanDownloadsCleared = ETrue; |
|
1345 iDownloadUtil->ClearOrphanDownloadsL( *iCache->iVideoList ); |
|
1346 } |
|
1347 } |
|
1348 |
|
1349 return *iDownloadUtil; |
|
1350 } |
|
1351 |
|
1352 // ---------------------------------------------------------------------------- |
|
1353 // CVcxMyVideosCollectionPlugin::CategoriesL |
827 // CVcxMyVideosCollectionPlugin::CategoriesL |
1354 // ---------------------------------------------------------------------------- |
828 // ---------------------------------------------------------------------------- |
1355 // |
829 // |
1356 CVcxMyVideosCategories& CVcxMyVideosCollectionPlugin::CategoriesL() |
830 CVcxMyVideosCategories& CVcxMyVideosCollectionPlugin::CategoriesL() |
1357 { |
831 { |
1358 if ( !iCategories ) |
832 if ( !iCategories ) |
1359 { |
833 { |
1360 iCategories = CVcxMyVideosCategories::NewL( *this ); |
834 iCategories = CVcxMyVideosCategories::NewL( *this ); |
1361 } |
835 } |
1362 return *iCategories; |
836 return *iCategories; |
837 } |
|
838 |
|
839 // ---------------------------------------------------------------------------- |
|
840 // CVcxMyVideosCollectionPlugin::AlbumsL |
|
841 // TODO: Unecessarry func since we always load this |
|
842 // ---------------------------------------------------------------------------- |
|
843 // |
|
844 CVcxMyVideosAlbums& CVcxMyVideosCollectionPlugin::AlbumsL() |
|
845 { |
|
846 if ( !iAlbums ) |
|
847 { |
|
848 iAlbums = CVcxMyVideosAlbums::NewL( *this ); |
|
849 } |
|
850 return *iAlbums; |
|
1363 } |
851 } |
1364 |
852 |
1365 // ---------------------------------------------------------------------------- |
853 // ---------------------------------------------------------------------------- |
1366 // CVcxMyVideosCollectionPlugin::HandleCreateVideoListResp |
854 // CVcxMyVideosCollectionPlugin::HandleCreateVideoListResp |
1367 // ---------------------------------------------------------------------------- |
855 // ---------------------------------------------------------------------------- |
1432 User::Leave( leave ); |
920 User::Leave( leave ); |
1433 } |
921 } |
1434 } |
922 } |
1435 |
923 |
1436 // ---------------------------------------------------------------------------- |
924 // ---------------------------------------------------------------------------- |
1437 // CVcxMyVideosCollectionPlugin::NotifyDownloadCompletedL |
925 // CVcxMyVideosCollectionPlugin::NotifyNewVideosCountDecreasedL |
1438 // ---------------------------------------------------------------------------- |
926 // ---------------------------------------------------------------------------- |
1439 // |
927 // |
1440 void CVcxMyVideosCollectionPlugin::NotifyDownloadCompletedL( CMPXMedia& aVideo ) |
928 void CVcxMyVideosCollectionPlugin::NotifyNewVideosCountDecreasedL( CMPXMedia& aVideo ) |
1441 { |
929 { |
1442 const TInt KMediaExtSize( 8 ); |
930 const TInt KMediaExtSize( 8 ); |
1443 |
931 |
1444 HBufC8* buffer = HBufC8::NewL( KMediaExtSize ); |
932 HBufC8* buffer = HBufC8::NewL( KMediaExtSize ); |
1445 CleanupStack::PushL( buffer ); |
933 CleanupStack::PushL( buffer ); |
1446 TPtr8 des = buffer->Des(); |
934 TPtr8 des = buffer->Des(); |
1452 aVideo.ExternalizeL( stream ); |
940 aVideo.ExternalizeL( stream ); |
1453 |
941 |
1454 stream.CommitL(); |
942 stream.CommitL(); |
1455 |
943 |
1456 CleanupStack::PopAndDestroy( &stream ); |
944 CleanupStack::PopAndDestroy( &stream ); |
1457 |
945 |
1458 DownloadUtilL().NotifyDownloadCompleted( *buffer ); |
|
1459 |
|
1460 CleanupStack::PopAndDestroy( buffer ); |
|
1461 } |
|
1462 |
|
1463 // ---------------------------------------------------------------------------- |
|
1464 // CVcxMyVideosCollectionPlugin::NotifyNewVideosCountDecreasedL |
|
1465 // ---------------------------------------------------------------------------- |
|
1466 // |
|
1467 void CVcxMyVideosCollectionPlugin::NotifyNewVideosCountDecreasedL( CMPXMedia& aVideo ) |
|
1468 { |
|
1469 const TInt KMediaExtSize( 8 ); |
|
1470 |
|
1471 HBufC8* buffer = HBufC8::NewL( KMediaExtSize ); |
|
1472 CleanupStack::PushL( buffer ); |
|
1473 TPtr8 des = buffer->Des(); |
|
1474 |
|
1475 RDesWriteStream stream; |
|
1476 CleanupClosePushL( stream ); |
|
1477 stream.Open( des ); |
|
1478 |
|
1479 aVideo.ExternalizeL( stream ); |
|
1480 |
|
1481 stream.CommitL(); |
|
1482 |
|
1483 CleanupStack::PopAndDestroy( &stream ); |
|
1484 |
|
1485 DownloadUtilL().NotifyNewVideosCountDecreased( *buffer ); |
|
1486 |
|
1487 CleanupStack::PopAndDestroy( buffer ); |
946 CleanupStack::PopAndDestroy( buffer ); |
1488 } |
947 } |
1489 |
948 |
1490 // ---------------------------------------------------------------------------- |
949 // ---------------------------------------------------------------------------- |
1491 // CVcxMyVideosCollectionPlugin::AddVideoToMdsAndCacheL |
950 // CVcxMyVideosCollectionPlugin::AddVideoToMdsAndCacheL |
1503 |
962 |
1504 RArray<TUint32> ids; |
963 RArray<TUint32> ids; |
1505 ids.Reset(); |
964 ids.Reset(); |
1506 CleanupClosePushL( ids ); // 1-> |
965 CleanupClosePushL( ids ); // 1-> |
1507 ids.AppendL( mpxId.iId1 ); |
966 ids.AppendL( mpxId.iId1 ); |
1508 HandleMyVideosDbEvent( EMPXItemInserted, ids ); //this will fetch from mds to cache and sync with downloads |
967 HandleMyVideosDbEvent( EMPXItemInserted, ids ); //this will fetch from mds to cache |
1509 CleanupStack::PopAndDestroy( &ids ); // <-1 |
968 CleanupStack::PopAndDestroy( &ids ); // <-1 |
1510 } |
969 } |
1511 |
970 |
1512 // ---------------------------------------------------------------------------- |
971 // ---------------------------------------------------------------------------- |
1513 // CVcxMyVideosCollectionPlugin::SetTransactionIdL |
972 // CVcxMyVideosCollectionPlugin::SetTransactionIdL |
1619 EVcxMyVideosVideoListOrderChanged ); |
1078 EVcxMyVideosVideoListOrderChanged ); |
1620 |
1079 |
1621 iMessageList->SendL(); |
1080 iMessageList->SendL(); |
1622 } |
1081 } |
1623 |
1082 |
1624 // ---------------------------------------------------------------------------- |
|
1625 // CVcxMyVideosCollectionPlugin::SetDownloadIdToZeroL |
|
1626 // ---------------------------------------------------------------------------- |
|
1627 // |
|
1628 void CVcxMyVideosCollectionPlugin::SetDownloadIdToZeroL( TUint aDownloadId ) |
|
1629 { |
|
1630 CMPXMedia* video = iCache->FindVideoByDownloadIdL( aDownloadId ); |
|
1631 if ( video ) |
|
1632 { |
|
1633 video->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 ); |
|
1634 video->SetTObjectValueL<TUint8>( KVcxMediaMyVideosDownloadState, |
|
1635 static_cast<TUint8>( EVcxMyVideosDlStateNone ) ); |
|
1636 iMyVideosMdsDb->UpdateVideoL( *video ); |
|
1637 iMessageList->AddEventL( TVcxMyVideosCollectionUtil::IdL( |
|
1638 *video ), EMPXItemModified ); |
|
1639 iMessageList->SendL(); |
|
1640 } |
|
1641 } |
|
1642 |
|
1643 #ifdef _DEBUG |
|
1644 // ---------------------------------------------------------------------------- |
|
1645 // CVcxMyVideosCollectionPlugin::DownloadState |
|
1646 // ---------------------------------------------------------------------------- |
|
1647 // |
|
1648 const TDesC& CVcxMyVideosCollectionPlugin::DownloadState( TUint8 aDlState ) |
|
1649 { |
|
1650 _LIT(KDlStateNoneDes, "None"); |
|
1651 _LIT(KDlStateDownloadingDes, "Downloading"); |
|
1652 _LIT(KDlStateFailedDes, "Failed"); |
|
1653 _LIT(KDlStatePausedDes, "Paused"); |
|
1654 _LIT(KDlStateDownloadedDes, "Downloaded"); |
|
1655 |
|
1656 switch ( aDlState ) |
|
1657 { |
|
1658 case EVcxMyVideosDlStateNone: |
|
1659 return KDlStateNoneDes; |
|
1660 case EVcxMyVideosDlStateDownloading: |
|
1661 return KDlStateDownloadingDes; |
|
1662 case EVcxMyVideosDlStateFailed: |
|
1663 return KDlStateFailedDes; |
|
1664 case EVcxMyVideosDlStatePaused: |
|
1665 return KDlStatePausedDes; |
|
1666 case EVcxMyVideosDlStateDownloaded: |
|
1667 return KDlStateDownloadedDes; |
|
1668 default: |
|
1669 return KNullDesC; |
|
1670 } |
|
1671 } |
|
1672 #endif |
|
1673 |