videocollection/mpxmyvideoscollection/src/vcxmyvideoscollectionplugin.cpp
changeset 35 3738fe97f027
parent 34 bbb98528c666
child 36 8aed59de29f9
equal deleted inserted replaced
34:bbb98528c666 35:3738fe97f027
   215     else
   215     else
   216         {
   216         {
   217         MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: fetching from MDS");
   217         MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: fetching from MDS");
   218         video = iMyVideosMdsDb->CreateVideoL( ids[0].iId1, ETrue /* full details */ );    
   218         video = iMyVideosMdsDb->CreateVideoL( ids[0].iId1, ETrue /* full details */ );    
   219         }
   219         }
   220         
   220     
   221     iObs->HandleMedia( video, KErrNone );
   221     if ( video )
       
   222         {
       
   223         iObs->HandleMedia( video, KErrNone );
       
   224         }
       
   225     else
       
   226         {
       
   227         iObs->HandleMedia( NULL, KErrNotFound );    
       
   228         }
   222     
   229     
   223     CleanupStack::PopAndDestroy( &ids );          // <-2
   230     CleanupStack::PopAndDestroy( &ids );          // <-2
   224     CleanupStack::PopAndDestroy( &supportedIds ); // <-1
   231     CleanupStack::PopAndDestroy( &supportedIds ); // <-1
   225     }
   232     }
   226 
   233 
   288             case KMPXCommandIdCollectionSet:
   295             case KMPXCommandIdCollectionSet:
   289                 {
   296                 {
   290                 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: sync KMPXCommandIdCollectionSet arrived");
   297                 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: sync KMPXCommandIdCollectionSet arrived");
   291                 
   298                 
   292                 CMPXMedia* video = aCmd.Value<CMPXMedia>( KMPXCommandColSetMedia );
   299                 CMPXMedia* video = aCmd.Value<CMPXMedia>( KMPXCommandColSetMedia );
   293                 SetVideoL( *video );
   300                 
       
   301                 TMPXItemId mpxId = TVcxMyVideosCollectionUtil::IdL( *video );
       
   302                 if ( mpxId.iId2 == KVcxMvcMediaTypeVideo )
       
   303                     {
       
   304                     SetVideoL( *video );
       
   305                     }
       
   306                 else if ( mpxId.iId2 == KVcxMvcMediaTypeAlbum )
       
   307                     {
       
   308                     iMyVideosMdsDb->iAlbums->SetAlbumL( *video );
       
   309                     }
       
   310                 else
       
   311                     {
       
   312                     User::Leave( KErrNotFound );
       
   313                     }
   294                 }
   314                 }
   295                 break;
   315                 break;
   296             
   316             
   297             case KVcxCommandIdMyVideos:
   317             case KVcxCommandIdMyVideos:
   298                 {
   318                 {
   484             {
   504             {
   485             MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------.");
   505             MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------.");
   486             MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items modified in MDS, updating cache |");
   506             MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items modified in MDS, updating cache |");
   487             MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------'");
   507             MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------'");
   488             CMPXMedia* video;
   508             CMPXMedia* video;
   489             for ( TInt i = 0; i < aId.Count(); i++ )
   509             CMPXMedia* album;
       
   510             TInt count = aId.Count();
       
   511             for ( TInt i = count - 1; i >= 0; i-- )
   490                 {
   512                 {
   491                 video = iMyVideosMdsDb->CreateVideoL( aId[i], ETrue /* full details */ );
   513                 video = iMyVideosMdsDb->CreateVideoL( aId[i], ETrue /* full details */ );
   492                 
   514                 
   493                 if ( video )
   515                 if ( video )
   494                     {
   516                     {
   496                     iCache->UpdateVideoL( *video );
   518                     iCache->UpdateVideoL( *video );
   497                     CleanupStack::PopAndDestroy( video ); // <-1
   519                     CleanupStack::PopAndDestroy( video ); // <-1
   498                     }
   520                     }
   499                 else
   521                 else
   500                     {
   522                     {
   501                     MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: couldn't find the modified item from MDS");
   523                     MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: item was not found from videos, checking albums");
   502                     }
   524                     album = iMyVideosMdsDb->iAlbums->GetAlbumL( aId[i] );
   503                 }
   525                     
       
   526                     if ( album )
       
   527                         {
       
   528                         CleanupStack::PushL( album ); // 1->
       
   529                         iAlbums->UpdateAlbumL( *album ); // this will add event to iMessageList if necessarry
       
   530                         CleanupStack::PopAndDestroy( album ); // <-1
       
   531                         }
       
   532                     else
       
   533                         {
       
   534                         MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: couldn't find the modified item from MDS");
       
   535                         }
       
   536                     aId.Remove( i );
       
   537                     }
       
   538                 }
       
   539             
   504             }
   540             }
   505             
       
   506             //TODO: handle album modify events
       
   507             break;
   541             break;
   508         }
   542         }
   509 
   543 
   510         TInt pos;
   544         TInt pos;
   511         TInt count = aId.Count();
   545         TInt count = aId.Count();
   523                 TRAP_IGNORE( iMessageList->AddEventL( TMPXItemId( aId[i], KVcxMvcMediaTypeVideo),
   557                 TRAP_IGNORE( iMessageList->AddEventL( TMPXItemId( aId[i], KVcxMvcMediaTypeVideo),
   524                         aEvent ) );
   558                         aEvent ) );
   525                 }
   559                 }
   526             }
   560             }
   527 
   561 
   528         if ( aEvent == EMPXItemInserted )
   562     //nonVideoIds are albums
   529             {
   563     count = nonVideoIds.Count();
   530             //nonVideoIds are albums
   564     for ( TInt i = 0; i < count; i++ )
   531             TInt count = nonVideoIds.Count();
   565         {
   532             for ( TInt i = 0; i < count; i++ )
   566         TRAP_IGNORE( iMessageList->AddEventL(
   533                 {
   567                 TMPXItemId( nonVideoIds[i], KVcxMvcMediaTypeAlbum ), aEvent ) );
   534                 TRAP_IGNORE( iMessageList->AddEventL(
   568         }
   535                         TMPXItemId( nonVideoIds[i], KVcxMvcMediaTypeAlbum ), aEvent ) );
       
   536                 }
       
   537             }
       
   538 
   569 
   539     CleanupStack::PopAndDestroy( &nonVideoIds );
   570     CleanupStack::PopAndDestroy( &nonVideoIds );
   540     
   571     
   541     iMessageList->SendL();
   572     iMessageList->SendL();
   542     }
   573     }
   595                         }
   626                         }
   596                     MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: KVcxCommandMyVideosGetMediaFullDetailsByMpxId cmd: MDS ID %d requested", mpxId.iId1 );
   627                     MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: KVcxCommandMyVideosGetMediaFullDetailsByMpxId cmd: MDS ID %d requested", mpxId.iId1 );
   597 
   628 
   598                     CMPXMedia* video = iMyVideosMdsDb->CreateVideoL(
   629                     CMPXMedia* video = iMyVideosMdsDb->CreateVideoL(
   599                             mpxId.iId1, ETrue /* full details */ );
   630                             mpxId.iId1, ETrue /* full details */ );
       
   631                     
       
   632                     if ( !video )
       
   633                         {
       
   634                         User::Leave( KErrNotFound );
       
   635                         }
   600                     
   636                     
   601                     CleanupStack::PushL( video ); // 1->
   637                     CleanupStack::PushL( video ); // 1->
   602                                         
   638                                         
   603                     cmd.SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, video );
   639                     cmd.SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, video );
   604                     CleanupStack::PopAndDestroy( video ); // <-1
   640                     CleanupStack::PopAndDestroy( video ); // <-1
   966 
  1002 
   967     RArray<TUint32> ids;
  1003     RArray<TUint32> ids;
   968     ids.Reset();
  1004     ids.Reset();
   969     CleanupClosePushL( ids ); // 1->
  1005     CleanupClosePushL( ids ); // 1->
   970     ids.AppendL( mpxId.iId1 );
  1006     ids.AppendL( mpxId.iId1 );
   971     HandleMyVideosDbEvent( EMPXItemInserted, ids ); //this will fetch from mds to cache and sync with downloads
  1007     HandleMyVideosDbEvent( EMPXItemInserted, ids ); //this will fetch from mds to cache
   972     CleanupStack::PopAndDestroy( &ids ); // <-1
  1008     CleanupStack::PopAndDestroy( &ids ); // <-1
   973     }
  1009     }
   974 
  1010 
   975 // ----------------------------------------------------------------------------
  1011 // ----------------------------------------------------------------------------
   976 // CVcxMyVideosCollectionPlugin::SetTransactionIdL
  1012 // CVcxMyVideosCollectionPlugin::SetTransactionIdL