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 |
103 #ifdef VIDEO_COLLECTION_PLUGIN_TB92 |
104 iMyVideosMdsDb = CVcxMyVideosMdsDb::NewL( this, &AlbumsL(), iFs ); |
104 iMyVideosMdsDb = CVcxMyVideosMdsDb::NewL( this, iFs ); |
|
105 #else |
|
106 iMyVideosMdsDb = CVcxMyVideosMdsDb::NewL( this, iFs, &AlbumsL() ); |
|
107 #endif |
105 iActiveTask = CVcxMyVideosActiveTask::NewL( *this ); |
108 iActiveTask = CVcxMyVideosActiveTask::NewL( *this ); |
106 iCache = CVcxMyVideosVideoCache::NewL( *this ); |
109 iCache = CVcxMyVideosVideoCache::NewL( *this ); |
107 iMessageList = CVcxMyVideosMessageList::NewL( *this ); |
110 iMessageList = CVcxMyVideosMessageList::NewL( *this ); |
108 iOpenHandler = CVcxMyVideosOpenHandler::NewL( *this, *iCache, *iMyVideosMdsDb ); |
111 iOpenHandler = CVcxMyVideosOpenHandler::NewL( *this, *iCache, *iMyVideosMdsDb ); |
109 } |
112 } |
430 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------------."); |
433 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------------."); |
431 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items from MDS deleted, deleting from cache |" ); |
434 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items from MDS deleted, deleting from cache |" ); |
432 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------------'"); |
435 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------------'"); |
433 |
436 |
434 iCache->RemoveL( aId ); |
437 iCache->RemoveL( aId ); |
|
438 #ifndef VIDEO_COLLECTION_PLUGIN_TB92 |
435 AlbumsL().RemoveAlbumsL( aId ); |
439 AlbumsL().RemoveAlbumsL( aId ); |
|
440 #endif |
436 } |
441 } |
437 break; |
442 break; |
438 |
443 |
439 case EMPXItemInserted: |
444 case EMPXItemInserted: |
440 { |
445 { |
455 // 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 |
456 // video condition and only video objects are added to cache. Items which were detected |
461 // video condition and only video objects are added to cache. Items which were detected |
457 // to not be videos are added to nonVideoIds. |
462 // to not be videos are added to nonVideoIds. |
458 iCache->AddVideosFromMdsL( aId, videoListFetchingWasCancelled, &nonVideoIds ); |
463 iCache->AddVideosFromMdsL( aId, videoListFetchingWasCancelled, &nonVideoIds ); |
459 |
464 |
|
465 #ifndef VIDEO_COLLECTION_PLUGIN_TB92 |
460 #if 0 //TODO: do this if we want to support albums which are being added by someone else than My Videos Collection |
466 #if 0 //TODO: do this if we want to support albums which are being added by someone else than My Videos Collection |
461 |
467 |
462 //After the call nonVideoIds will contain only items which were actually added |
468 //After the call nonVideoIds will contain only items which were actually added |
463 //to albums. |
469 //to albums. |
464 AlbumsL().AddAlbumsFromMdsL( nonVideoIds ); |
470 AlbumsL().AddAlbumsFromMdsL( nonVideoIds ); |
465 #endif |
471 #endif |
|
472 #endif |
466 |
473 |
467 if ( videoListFetchingWasCancelled ) |
474 if ( videoListFetchingWasCancelled ) |
468 { |
475 { |
469 RestartVideoListFetchingL(); |
476 RestartVideoListFetchingL(); |
470 } |
477 } |
476 { |
483 { |
477 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------."); |
484 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------."); |
478 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items modified in MDS, updating cache |"); |
485 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items modified in MDS, updating cache |"); |
479 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------'"); |
486 MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------'"); |
480 CMPXMedia* video; |
487 CMPXMedia* video; |
|
488 #ifndef VIDEO_COLLECTION_PLUGIN_TB92 |
481 CMPXMedia* album; |
489 CMPXMedia* album; |
|
490 #endif |
482 TInt count = aId.Count(); |
491 TInt count = aId.Count(); |
483 for ( TInt i = count - 1; i >= 0; i-- ) |
492 for ( TInt i = count - 1; i >= 0; i-- ) |
484 { |
493 { |
485 video = iMyVideosMdsDb->CreateVideoL( aId[i], ETrue /* full details */ ); |
494 video = iMyVideosMdsDb->CreateVideoL( aId[i], ETrue /* full details */ ); |
486 |
495 |
490 iCache->UpdateVideoL( *video ); |
499 iCache->UpdateVideoL( *video ); |
491 CleanupStack::PopAndDestroy( video ); // <-1 |
500 CleanupStack::PopAndDestroy( video ); // <-1 |
492 } |
501 } |
493 else |
502 else |
494 { |
503 { |
|
504 #ifdef VIDEO_COLLECTION_PLUGIN_TB92 |
|
505 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: couldn't find the modified item from MDS"); |
|
506 aId.Remove( i ); |
|
507 #else |
495 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: item was not found from videos, checking albums"); |
508 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: item was not found from videos, checking albums"); |
496 album = iMyVideosMdsDb->iAlbums->GetAlbumL( aId[i] ); |
509 album = iMyVideosMdsDb->iAlbums->GetAlbumL( aId[i] ); |
497 |
510 |
498 if ( album ) |
511 if ( album ) |
499 { |
512 { |
529 TRAP_IGNORE( iMessageList->AddEventL( TMPXItemId( aId[i], KVcxMvcMediaTypeVideo), |
543 TRAP_IGNORE( iMessageList->AddEventL( TMPXItemId( aId[i], KVcxMvcMediaTypeVideo), |
530 aEvent ) ); |
544 aEvent ) ); |
531 } |
545 } |
532 } |
546 } |
533 |
547 |
|
548 #ifndef VIDEO_COLLECTION_PLUGIN_TB92 |
534 //nonVideoIds are albums |
549 //nonVideoIds are albums |
535 count = nonVideoIds.Count(); |
550 count = nonVideoIds.Count(); |
536 for ( TInt i = 0; i < count; i++ ) |
551 for ( TInt i = 0; i < count; i++ ) |
537 { |
552 { |
538 TRAP_IGNORE( iMessageList->AddEventL( |
553 TRAP_IGNORE( iMessageList->AddEventL( |
539 TMPXItemId( nonVideoIds[i], KVcxMvcMediaTypeAlbum ), aEvent ) ); |
554 TMPXItemId( nonVideoIds[i], KVcxMvcMediaTypeAlbum ), aEvent ) ); |
540 } |
555 } |
541 |
556 |
|
557 iAlbums->UpdateChangedAlbumsL(); |
|
558 #endif |
|
559 |
542 CleanupStack::PopAndDestroy( &nonVideoIds ); |
560 CleanupStack::PopAndDestroy( &nonVideoIds ); |
543 |
561 iMessageList->SendL(); |
544 iAlbums->UpdateChangedAlbumsL(); |
|
545 |
|
546 iMessageList->SendL(); |
|
547 } |
562 } |
548 |
563 |
549 // ---------------------------------------------------------------------------- |
564 // ---------------------------------------------------------------------------- |
550 // CVcxMyVideosCollectionPlugin::HandleStepL |
565 // CVcxMyVideosCollectionPlugin::HandleStepL |
551 // ---------------------------------------------------------------------------- |
566 // ---------------------------------------------------------------------------- |
904 { |
919 { |
905 User::Leave( leave ); |
920 User::Leave( leave ); |
906 } |
921 } |
907 } |
922 } |
908 |
923 |
909 #if 0 |
|
910 // ---------------------------------------------------------------------------- |
|
911 // CVcxMyVideosCollectionPlugin::NotifyDownloadCompletedL |
|
912 // ---------------------------------------------------------------------------- |
|
913 // |
|
914 void CVcxMyVideosCollectionPlugin::NotifyDownloadCompletedL( CMPXMedia& aVideo ) |
|
915 { |
|
916 const TInt KMediaExtSize( 8 ); |
|
917 |
|
918 HBufC8* buffer = HBufC8::NewL( KMediaExtSize ); |
|
919 CleanupStack::PushL( buffer ); |
|
920 TPtr8 des = buffer->Des(); |
|
921 |
|
922 RDesWriteStream stream; |
|
923 CleanupClosePushL( stream ); |
|
924 stream.Open( des ); |
|
925 |
|
926 aVideo.ExternalizeL( stream ); |
|
927 |
|
928 stream.CommitL(); |
|
929 |
|
930 CleanupStack::PopAndDestroy( &stream ); |
|
931 |
|
932 DownloadUtilL().NotifyDownloadCompleted( *buffer ); |
|
933 |
|
934 CleanupStack::PopAndDestroy( buffer ); |
|
935 } |
|
936 #endif |
|
937 |
|
938 // ---------------------------------------------------------------------------- |
924 // ---------------------------------------------------------------------------- |
939 // CVcxMyVideosCollectionPlugin::NotifyNewVideosCountDecreasedL |
925 // CVcxMyVideosCollectionPlugin::NotifyNewVideosCountDecreasedL |
940 // ---------------------------------------------------------------------------- |
926 // ---------------------------------------------------------------------------- |
941 // |
927 // |
942 void CVcxMyVideosCollectionPlugin::NotifyNewVideosCountDecreasedL( CMPXMedia& aVideo ) |
928 void CVcxMyVideosCollectionPlugin::NotifyNewVideosCountDecreasedL( CMPXMedia& aVideo ) |