videocollection/mpxmyvideoscollection/src/vcxmyvideosvideocache.cpp
changeset 30 4f111d64a341
parent 1 6711b85517b7
child 34 bbb98528c666
equal deleted inserted replaced
2:dec420019252 30:4f111d64a341
     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:    Video list cache. Contains cached data from MDS.*
    14 * Description:   Video list cache. Contains cached data from MDS.*
    15 */
    15 */
    16 
       
    17 
    16 
    18 
    17 
    19 
    18 
    20 // INCLUDE FILES
    19 // INCLUDE FILES
    21 #include <mpxlog.h>
    20 #include <mpxlog.h>
   383         TInt pos;
   382         TInt pos;
   384         if ( !FindVideoByMdsIdL( aMdsIds[j], pos ) )
   383         if ( !FindVideoByMdsIdL( aMdsIds[j], pos ) )
   385             {
   384             {
   386             MPX_DEBUG2("CVcxMyVideosVideoCache:: MDSID(%d) not found from cache, ok", aMdsIds[j]);
   385             MPX_DEBUG2("CVcxMyVideosVideoCache:: MDSID(%d) not found from cache, ok", aMdsIds[j]);
   387             
   386             
       
   387             //TODO: This doesnt work with new mds cmd queue. Cancel must be done if there is _any_ async req going on.
       
   388             //      Maybe the fetching could be changed to asynchronous...
   388             if ( iCollection.iMyVideosMdsDb->iVideoListFetchingIsOngoing )
   389             if ( iCollection.iMyVideosMdsDb->iVideoListFetchingIsOngoing )
   389                 {
   390                 {
   390                 // If list fetching is not canceled, CreateVideoObjectL will leave with KErrNotReady.
   391                 // If list fetching is not canceled, CreateVideoObjectL will leave with KErrNotReady.
   391                 MPX_DEBUG1("CVcxMyVideosVideoCache:: video list fetching is ongoing, canceling it to be able to fetch single items!");
   392                 MPX_DEBUG1("CVcxMyVideosVideoCache:: video list fetching is ongoing, canceling it to be able to fetch single items!");
   392                 iCollection.iMyVideosMdsDb->Cancel();
   393                 iCollection.iMyVideosMdsDb->Cancel();
   586 
   587 
   587     MPX_DEBUG2("CVcxMyVideosVideoCache:: aForce = %d", aForce );
   588     MPX_DEBUG2("CVcxMyVideosVideoCache:: aForce = %d", aForce );
   588     
   589     
   589     TVcxMyVideosSortingOrder sortingOrder = SortingOrderL();
   590     TVcxMyVideosSortingOrder sortingOrder = SortingOrderL();
   590         
   591         
   591     if ( iCollection.iMyVideosMdsDb->iVideoListFetchingIsOngoing
   592     if ( IsFetchingVideoList
   592             && sortingOrder == iLastSortingOrder && !aForce )
   593             && sortingOrder == iLastSortingOrder && !aForce )
   593         {
   594         {
   594         MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList creation is already ongoing, skipping");
   595         MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList creation is already ongoing, skipping");
   595         return;
   596         return;
   596         }
   597         }
   597                    
   598                    
   598     if ( iVideoListIsPartial || (sortingOrder != iLastSortingOrder) || aForce )
   599     if ( iVideoListIsPartial || (sortingOrder != iLastSortingOrder) || aForce )
   599         {
   600         {
   600         MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList was partial or in wrong order or aForce was ETrue, recreating");
   601         MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList was partial or in wrong order or aForce was ETrue, recreating");
   601 
   602 
   602         if ( iCollection.iMyVideosMdsDb->iVideoListFetchingIsOngoing )
   603         if ( IsFetchingVideoList )
   603             {
   604             {
   604             MPX_DEBUG1("CVcxMyVideosVideoCache:: video list fetching is ongoing, canceling it");
   605             MPX_DEBUG1("CVcxMyVideosVideoCache:: video list fetching is ongoing, canceling it");
   605             iCollection.iMyVideosMdsDb->Cancel();
   606             iCollection.iMyVideosMdsDb->Cancel( CVcxMyVideosMdsDb::EGetVideoList );
       
   607             IsFetchingVideoList = EFalse;
   606             }
   608             }
   607         
   609         
   608         ResetVideoListL();
   610         ResetVideoListL();
   609                         
   611                         
   610         TBool ascending = ETrue;
   612         TBool ascending = ETrue;
   626                 sortingOrder,
   628                 sortingOrder,
   627                 ascending,
   629                 ascending,
   628                 EFalse /* brief list */,
   630                 EFalse /* brief list */,
   629                 iVideoList /* use existing */ );
   631                 iVideoList /* use existing */ );
   630 
   632 
       
   633         IsFetchingVideoList = ETrue;
   631         iLastSortingOrder   = sortingOrder;
   634         iLastSortingOrder   = sortingOrder;
   632         iVideoListIsPartial = ETrue;
   635         iVideoListIsPartial = ETrue;
   633         }
   636         }
   634     else
   637     else
   635         {
   638         {
  1028             
  1031             
  1029             changed = ETrue;
  1032             changed = ETrue;
  1030             }
  1033             }
  1031         }
  1034         }
  1032     
  1035     
  1033     // 23
  1036     // 22
  1034     if ( aVideo.IsSupported( KMPXMediaVideoHeight ) )
  1037     if ( aVideo.IsSupported( KMPXMediaVideoHeight ) )
  1035         {
  1038         {
  1036         TUint16 height = aVideo.ValueTObjectL<TUint16>( KMPXMediaVideoHeight ); 
  1039         TUint16 height = aVideo.ValueTObjectL<TUint16>( KMPXMediaVideoHeight ); 
  1037         if ( height != videoInCache->ValueTObjectL<TUint16>( KMPXMediaVideoHeight ) )
  1040         if ( height != videoInCache->ValueTObjectL<TUint16>( KMPXMediaVideoHeight ) )
  1038             {
  1041             {
  1489 //
  1492 //
  1490 void CVcxMyVideosVideoCache::ResetVideoListL()
  1493 void CVcxMyVideosVideoCache::ResetVideoListL()
  1491     {
  1494     {
  1492     MPX_FUNC("CVcxMyVideosVideoCache::ResetVideoListL");
  1495     MPX_FUNC("CVcxMyVideosVideoCache::ResetVideoListL");
  1493 
  1496 
  1494     iCollection.iMyVideosMdsDb->Cancel();
  1497     //TODO: when should we cancel...
       
  1498     //iCollection.iMyVideosMdsDb->Cancel();
  1495 
  1499 
  1496     CMPXMediaArray* mediaArray =
  1500     CMPXMediaArray* mediaArray =
  1497             iVideoList->ValueCObjectL<CMPXMediaArray>( KMPXMediaArrayContents );
  1501             iVideoList->ValueCObjectL<CMPXMediaArray>( KMPXMediaArrayContents );
  1498     CleanupStack::PushL( mediaArray ); // 1->
  1502     CleanupStack::PushL( mediaArray ); // 1->
  1499     
  1503