98 void CVcxMyVideosCollectionPlugin::ConstructL () |
98 void CVcxMyVideosCollectionPlugin::ConstructL () |
99 { |
99 { |
100 MPX_FUNC("CVcxMyVideosCollectionPlugin::ConstructL"); |
100 MPX_FUNC("CVcxMyVideosCollectionPlugin::ConstructL"); |
101 |
101 |
102 User::LeaveIfError( iFs.Connect() ); |
102 User::LeaveIfError( iFs.Connect() ); |
103 #ifdef VIDEO_COLLECTION_PLUGIN_TB92 |
103 #ifndef VCX_ALBUMS |
104 iMyVideosMdsDb = CVcxMyVideosMdsDb::NewL( this, iFs ); |
104 iMyVideosMdsDb = CVcxMyVideosMdsDb::NewL( this, iFs ); |
105 #else |
105 #else |
106 iMyVideosMdsDb = CVcxMyVideosMdsDb::NewL( this, iFs, &AlbumsL() ); |
106 iMyVideosMdsDb = CVcxMyVideosMdsDb::NewL( this, iFs, &AlbumsL() ); |
107 #endif |
107 #endif |
108 iActiveTask = CVcxMyVideosActiveTask::NewL( *this ); |
108 iActiveTask = CVcxMyVideosActiveTask::NewL( *this ); |
401 // CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent |
401 // CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent |
402 // ---------------------------------------------------------------------------------------------------------- |
402 // ---------------------------------------------------------------------------------------------------------- |
403 // |
403 // |
404 void CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent( |
404 void CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent( |
405 TMPXChangeEventType aEvent, |
405 TMPXChangeEventType aEvent, |
406 RArray<TUint32>& aId ) |
406 RArray<TUint32>& aId, |
407 { |
407 TInt aEventsLeft ) |
408 TRAPD( err, DoHandleMyVideosDbEventL( aEvent, aId )); |
408 { |
|
409 TRAPD( err, DoHandleMyVideosDbEventL( aEvent, aId, aEventsLeft )); |
409 if ( err != KErrNone ) |
410 if ( err != KErrNone ) |
410 { |
411 { |
411 MPX_DEBUG2("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() leaved with error code: %d", err); |
412 MPX_DEBUG2("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() leaved with error code: %d", err); |
412 } |
413 } |
413 } |
414 } |
416 // CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL |
417 // CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL |
417 // ---------------------------------------------------------------------------------------------------------- |
418 // ---------------------------------------------------------------------------------------------------------- |
418 // |
419 // |
419 void CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL( |
420 void CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL( |
420 TMPXChangeEventType aEvent, |
421 TMPXChangeEventType aEvent, |
421 RArray<TUint32>& aId ) |
422 RArray<TUint32>& aId, |
|
423 TInt /*aEventsLeft*/ ) |
422 { |
424 { |
423 MPX_FUNC("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL"); |
425 MPX_FUNC("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL"); |
424 |
426 |
425 RArray<TUint32> nonVideoIds; |
427 RArray<TUint32> nonVideoIds; |
426 nonVideoIds.Reset(); |
428 nonVideoIds.Reset(); |
431 case EMPXItemDeleted: |
433 case EMPXItemDeleted: |
432 { |
434 { |
433 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------------."); |
435 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------------."); |
434 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items from MDS deleted, deleting from cache |" ); |
436 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items from MDS deleted, deleting from cache |" ); |
435 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------------'"); |
437 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------------'"); |
436 |
438 |
437 iCache->RemoveL( aId ); |
439 iCache->RemoveL( aId, EFalse ); |
438 #ifndef VIDEO_COLLECTION_PLUGIN_TB92 |
440 |
|
441 CategoriesL().ResetVideoCountersL(); |
|
442 CategoriesL().UpdateCategoriesL( *iCache->iVideoList, 0 ); |
|
443 CategoriesL().UpdateCategoriesNewVideoNamesL(); |
|
444 |
|
445 #ifdef VCX_ALBUMS |
439 AlbumsL().RemoveAlbumsL( aId ); |
446 AlbumsL().RemoveAlbumsL( aId ); |
440 #endif |
447 #endif |
441 } |
448 } |
442 break; |
449 break; |
443 |
450 |
458 |
465 |
459 // After the call, aId will contain only items which were actually inserted to cache. |
466 // After the call, aId will contain only items which were actually inserted to cache. |
460 // We receive add events for all object types. When fetching the item from MDS we use |
467 // We receive add events for all object types. When fetching the item from MDS we use |
461 // video condition and only video objects are added to cache. Items which were detected |
468 // video condition and only video objects are added to cache. Items which were detected |
462 // to not be videos are added to nonVideoIds. |
469 // to not be videos are added to nonVideoIds. |
463 iCache->AddVideosFromMdsL( aId, videoListFetchingWasCancelled, &nonVideoIds ); |
470 iCache->AddVideosFromMdsL( aId, videoListFetchingWasCancelled, |
464 |
471 &nonVideoIds, EFalse /* dont update categories*/ ); |
465 #ifndef VIDEO_COLLECTION_PLUGIN_TB92 |
472 |
|
473 CategoriesL().ResetVideoCountersL(); |
|
474 CategoriesL().UpdateCategoriesL( *iCache->iVideoList, 0 ); |
|
475 CategoriesL().UpdateCategoriesNewVideoNamesL(); |
|
476 |
|
477 #ifdef VCX_ALBUMS |
466 #if 0 //TODO: do this if we want to support albums which are being added by someone else than My Videos Collection |
478 #if 0 //TODO: do this if we want to support albums which are being added by someone else than My Videos Collection |
467 |
479 |
468 //After the call nonVideoIds will contain only items which were actually added |
480 //After the call nonVideoIds will contain only items which were actually added |
469 //to albums. |
481 //to albums. |
470 AlbumsL().AddAlbumsFromMdsL( nonVideoIds ); |
482 AlbumsL().AddAlbumsFromMdsL( nonVideoIds ); |
483 { |
495 { |
484 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------."); |
496 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------."); |
485 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items modified in MDS, updating cache |"); |
497 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items modified in MDS, updating cache |"); |
486 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------'"); |
498 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------'"); |
487 CMPXMedia* video; |
499 CMPXMedia* video; |
488 #ifndef VIDEO_COLLECTION_PLUGIN_TB92 |
500 #ifdef VCX_ALBUMS |
489 CMPXMedia* album; |
501 CMPXMedia* album; |
490 #endif |
502 #endif |
491 TInt count = aId.Count(); |
503 TInt count = aId.Count(); |
492 for ( TInt i = count - 1; i >= 0; i-- ) |
504 for ( TInt i = count - 1; i >= 0; i-- ) |
493 { |
505 { |
499 iCache->UpdateVideoL( *video ); |
511 iCache->UpdateVideoL( *video ); |
500 CleanupStack::PopAndDestroy( video ); // <-1 |
512 CleanupStack::PopAndDestroy( video ); // <-1 |
501 } |
513 } |
502 else |
514 else |
503 { |
515 { |
504 #ifdef VIDEO_COLLECTION_PLUGIN_TB92 |
516 #ifndef VCX_ALBUMS |
505 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: couldn't find the modified item from MDS"); |
517 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: couldn't find the modified item from MDS"); |
506 aId.Remove( i ); |
518 aId.Remove( i ); |
507 #else |
519 #else |
508 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: item was not found from videos, checking albums"); |
520 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: item was not found from videos, checking albums"); |
509 album = iMyVideosMdsDb->iAlbums->GetAlbumL( aId[i] ); |
521 album = iMyVideosMdsDb->iAlbums->GetAlbumL( aId[i] ); |
543 TRAP_IGNORE( iMessageList->AddEventL( TMPXItemId( aId[i], KVcxMvcMediaTypeVideo), |
555 TRAP_IGNORE( iMessageList->AddEventL( TMPXItemId( aId[i], KVcxMvcMediaTypeVideo), |
544 aEvent ) ); |
556 aEvent ) ); |
545 } |
557 } |
546 } |
558 } |
547 |
559 |
548 #ifndef VIDEO_COLLECTION_PLUGIN_TB92 |
560 #ifdef VCX_ALBUMS |
549 //nonVideoIds are albums |
561 //nonVideoIds are albums |
550 count = nonVideoIds.Count(); |
562 count = nonVideoIds.Count(); |
551 for ( TInt i = 0; i < count; i++ ) |
563 for ( TInt i = 0; i < count; i++ ) |
552 { |
564 { |
553 TRAP_IGNORE( iMessageList->AddEventL( |
565 TRAP_IGNORE( iMessageList->AddEventL( |
707 KVcxMessageMyVideosGetMediasByMpxIdResp ); |
719 KVcxMessageMyVideosGetMediasByMpxIdResp ); |
708 |
720 |
709 SetTransactionIdL( cmd, *message ); |
721 SetTransactionIdL( cmd, *message ); |
710 |
722 |
711 iMessageList->AddL( message ); |
723 iMessageList->AddL( message ); |
|
724 CleanupStack::Pop( message ); // <-3 |
712 iMessageList->SendL(); |
725 iMessageList->SendL(); |
713 |
726 |
714 if ( videoListFetchingWasCancelled ) |
727 if ( videoListFetchingWasCancelled ) |
715 { |
728 { |
716 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: video list fetching was cancelled, restarting"); |
729 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: video list fetching was cancelled, restarting"); |
717 RestartVideoListFetchingL(); |
730 RestartVideoListFetchingL(); |
718 } |
731 } |
719 |
732 |
720 CleanupStack::Pop( message ); // <-3 |
|
721 CleanupStack::PopAndDestroy( &mdsIds2 ); // <-2 |
733 CleanupStack::PopAndDestroy( &mdsIds2 ); // <-2 |
722 CleanupStack::PopAndDestroy( &mdsIds ); // <-1 |
734 CleanupStack::PopAndDestroy( &mdsIds ); // <-1 |
723 |
735 |
724 stepResult = MVcxMyVideosActiveTaskObserver::EDone; |
736 stepResult = MVcxMyVideosActiveTaskObserver::EDone; |
725 } |
737 } |
962 |
974 |
963 RArray<TUint32> ids; |
975 RArray<TUint32> ids; |
964 ids.Reset(); |
976 ids.Reset(); |
965 CleanupClosePushL( ids ); // 1-> |
977 CleanupClosePushL( ids ); // 1-> |
966 ids.AppendL( mpxId.iId1 ); |
978 ids.AppendL( mpxId.iId1 ); |
967 HandleMyVideosDbEvent( EMPXItemInserted, ids ); //this will fetch from mds to cache |
979 HandleMyVideosDbEvent( EMPXItemInserted, ids, 0 ); //this will fetch from mds to cache |
968 CleanupStack::PopAndDestroy( &ids ); // <-1 |
980 CleanupStack::PopAndDestroy( &ids ); // <-1 |
969 } |
981 } |
970 |
982 |
971 // ---------------------------------------------------------------------------- |
983 // ---------------------------------------------------------------------------- |
972 // CVcxMyVideosCollectionPlugin::SetTransactionIdL |
984 // CVcxMyVideosCollectionPlugin::SetTransactionIdL |