videocollection/mpxmyvideoscollection/src/vcxmyvideosalbums.cpp
changeset 35 3738fe97f027
parent 34 bbb98528c666
child 36 8aed59de29f9
equal deleted inserted replaced
34:bbb98528c666 35:3738fe97f027
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include <e32base.h>
    20 #include <e32base.h>
    21 #include <mpxlog.h>
    21 #include <mpxlog.h>
    22 #include <mpxmediacontainerdefs.h>
    22 #include <mpxmediacontainerdefs.h>
    23 #include <mpxcollectionpluginobserver.h>
    23 #include <mpxcollectionpluginobserver.h>
       
    24 #include <mpxmediageneraldefs.h>
    24 #include "vcxmyvideosalbums.h"
    25 #include "vcxmyvideosalbums.h"
    25 #include "vcxmyvideoscollectionutil.h"
    26 #include "vcxmyvideoscollectionutil.h"
    26 #include "vcxmyvideoscollectionplugin.h"
    27 #include "vcxmyvideoscollectionplugin.h"
    27 #include "vcxmyvideosmdsdb.h"
    28 #include "vcxmyvideosmdsdb.h"
    28 #include "vcxmyvideosmdsalbums.h"
    29 #include "vcxmyvideosmdsalbums.h"
   254 void CVcxMyVideosAlbums::RemoveAlbumsL( RArray<TUint32>& aAlbumIds )
   255 void CVcxMyVideosAlbums::RemoveAlbumsL( RArray<TUint32>& aAlbumIds )
   255     {
   256     {
   256     TInt count = aAlbumIds.Count();
   257     TInt count = aAlbumIds.Count();
   257     for ( TInt i = count -1; i >= 0; i-- )
   258     for ( TInt i = count -1; i >= 0; i-- )
   258         {
   259         {
   259         TBool removed = RemoveAlbum( aAlbumIds[i], EFalse /* dont compress */);
   260         TBool removed = RemoveAlbumL( aAlbumIds[i], EFalse /* dont compress */);
   260         if ( removed )
   261         if ( removed )
   261             {
   262             {
   262             aAlbumIds.Remove( i );
   263             aAlbumIds.Remove( i );
   263             }
   264             }
   264         }
   265         }
   266     
   267     
   267     iCollection.iMessageList->SendL();        
   268     iCollection.iMessageList->SendL();        
   268     }
   269     }
   269 
   270 
   270 // ----------------------------------------------------------------------------
   271 // ----------------------------------------------------------------------------
   271 // CVcxMyVideosAlbums::RemoveAlbum
   272 // CVcxMyVideosAlbums::RemoveAlbumL
   272 // ----------------------------------------------------------------------------
   273 // ----------------------------------------------------------------------------
   273 //
   274 //
   274 TBool CVcxMyVideosAlbums::RemoveAlbum( TUint32 aMdsId, TBool aCompress )
   275 TBool CVcxMyVideosAlbums::RemoveAlbumL( TUint32 aMdsId, TBool aCompress )
   275     {
   276     {
   276     TInt pos;
   277     TInt pos;
   277     CVcxMyVideosAlbum* album = Album( aMdsId, &pos );
   278     CVcxMyVideosAlbum* album = Album( aMdsId, &pos );
   278     if ( album )
   279     if ( album )
   279         {
   280         {
   280         CMPXMediaArray* albumArray = TVcxMyVideosCollectionUtil::MediaArrayL( *iAlbumList );
   281         CMPXMediaArray* albumArray = TVcxMyVideosCollectionUtil::MediaArrayL( *iAlbumList );
   281         
   282         
   282         iAlbums.Remove( pos );
   283         iAlbums.Remove( pos );
   283         albumArray->Remove( pos );
   284         albumArray->Remove( pos );
   284         
   285         
       
   286         MPX_DEBUG2("CVcxMyVideosAlbums:: removing album from pos %d", pos);
       
   287         
   285         if ( aCompress )
   288         if ( aCompress )
   286             {
   289             {
   287             iAlbums.Compress();
   290             iAlbums.Compress();
   288             }
   291             }
   289         iCollection.iMessageList->AddEventL( TMPXItemId( aMdsId, KVcxMvcMediaTypeAlbum ),
   292         iCollection.iMessageList->AddEventL( TMPXItemId( aMdsId, KVcxMvcMediaTypeAlbum ),
   309 // CVcxMyVideosAlbums::HandleGetAlbumsRespL
   312 // CVcxMyVideosAlbums::HandleGetAlbumsRespL
   310 // ----------------------------------------------------------------------------
   313 // ----------------------------------------------------------------------------
   311 //
   314 //
   312 void CVcxMyVideosAlbums::HandleGetAlbumsRespL( CMPXMedia* aAlbumList )
   315 void CVcxMyVideosAlbums::HandleGetAlbumsRespL( CMPXMedia* aAlbumList )
   313     {
   316     {
   314     // aAlbumList = iAlbums->iAlbumList
   317     // aAlbumList = iAlbumList
   315     CMPXMediaArray* array = aAlbumList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
   318     CMPXMediaArray* array = aAlbumList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
   316     TInt count = array->Count();
   319     TInt count = array->Count();
   317     TMPXItemId mpxId;
   320     TMPXItemId mpxId;
   318     CMPXMedia* album;
   321     CMPXMedia* album;
   319     for ( TInt i = 0; i < count; i++ )
   322     for ( TInt i = 0; i < count; i++ )
   362             }
   365             }
   363         }
   366         }
   364     
   367     
   365     
   368     
   366 #ifdef _DEBUG
   369 #ifdef _DEBUG
   367     TInt count = album->iVideoList.Count();
   370     if ( album )
   368 
   371         {
   369     MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: content ids for album %d arrived", aAlbumId);
   372         TInt count = album->iVideoList.Count();
   370 
   373 
   371     for ( TInt i = 0; i < album->iVideoList.Count(); i++ )
   374         MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: content ids for album %d arrived", aAlbumId);
   372         {
   375 
   373         MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: mds id = %d", album->iVideoList[i].iMdsId );
   376         for ( TInt i = 0; i < album->iVideoList.Count(); i++ )
       
   377             {
       
   378             MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: mds id = %d", album->iVideoList[i].iMdsId );
       
   379             }
   374         }
   380         }
   375 #endif
   381 #endif
   376     }
   382     }
   377 
   383 
   378 // ----------------------------------------------------------------------------
   384 // ----------------------------------------------------------------------------
   434         {
   440         {
   435         video.iRelationMdsId = aItemArray[i]->Id(); 
   441         video.iRelationMdsId = aItemArray[i]->Id(); 
   436         MPX_DEBUG3( "CVcxMyVideosAlbums:: item result[%d] = %d (id)", i, video.iRelationMdsId );
   442         MPX_DEBUG3( "CVcxMyVideosAlbums:: item result[%d] = %d (id)", i, video.iRelationMdsId );
   437         if ( video.iRelationMdsId == KNoId )
   443         if ( video.iRelationMdsId == KNoId )
   438             {
   444             {
   439             mediaArray->AtL( i )->SetTObjectValueL<TInt>( KVcxMediaMyVideosInt32Value, KErrGeneral );
   445             mediaArray->AtL( i )->SetTObjectValueL<TInt>( KVcxMediaMyVideosInt32Value,
       
   446                     KErrGeneral );
   440             }
   447             }
   441         else
   448         else
   442             {
   449             {
   443             mediaArray->AtL( i )->SetTObjectValueL<TInt>( KVcxMediaMyVideosInt32Value, KErrNone );
   450             mediaArray->AtL( i )->SetTObjectValueL<TInt>( KVcxMediaMyVideosInt32Value, KErrNone );
   444             video.iMdsId = TVcxMyVideosCollectionUtil::IdL( *mediaArray->AtL( i ) ).iId1;
   451             video.iMdsId = TVcxMyVideosCollectionUtil::IdL( *mediaArray->AtL( i ) ).iId1;
   468     {
   475     {
   469     MPX_DEBUG1("CVcxMyVideosAlbums::HandleRemoveRelationsResp() start");
   476     MPX_DEBUG1("CVcxMyVideosAlbums::HandleRemoveRelationsResp() start");
   470     
   477     
   471     // iRemoveFromAlbumVideos and mediaArray are in sync
   478     // iRemoveFromAlbumVideos and mediaArray are in sync
   472     
   479     
       
   480     TRAP_IGNORE(
       
   481     
   473     CMPXMedia* cmd             = iCollection.iActiveTask->Command();
   482     CMPXMedia* cmd             = iCollection.iActiveTask->Command();
   474     CMPXMediaArray* mediaArray = TVcxMyVideosCollectionUtil::MediaArrayL( *cmd );
   483     CMPXMediaArray* mediaArray = TVcxMyVideosCollectionUtil::MediaArrayL( *cmd );
   475     TInt count                 = iRemoveFromAlbumVideos.Count();
   484     TInt count                 = iRemoveFromAlbumVideos.Count();
   476     CMPXMedia* video;
   485     CMPXMedia* video;
   477     TInt relationId;
   486     TInt relationId;
   487         else
   496         else
   488             {
   497             {
   489             video->SetTObjectValueL( KVcxMediaMyVideosInt32Value, KErrGeneral );
   498             video->SetTObjectValueL( KVcxMediaMyVideosInt32Value, KErrGeneral );
   490             }
   499             }
   491         }
   500         }
       
   501     
       
   502     );
       
   503     
   492     iRemoveFromAlbumVideos.Reset();
   504     iRemoveFromAlbumVideos.Reset();
   493     
   505     
   494     iCollection.iActiveTask->Done();
   506     iCollection.iActiveTask->Done();
   495 
   507 
   496     MPX_DEBUG1("CVcxMyVideosAlbums::HandleRemoveRelationsResp() exit");
   508     MPX_DEBUG1("CVcxMyVideosAlbums::HandleRemoveRelationsResp() exit");
   500 // CVcxMyVideosAlbums::HandleRemoveAlbumsResp
   512 // CVcxMyVideosAlbums::HandleRemoveAlbumsResp
   501 // ----------------------------------------------------------------------------
   513 // ----------------------------------------------------------------------------
   502 //
   514 //
   503 void CVcxMyVideosAlbums::HandleRemoveAlbumsResp( CMPXMedia* aCmd,
   515 void CVcxMyVideosAlbums::HandleRemoveAlbumsResp( CMPXMedia* aCmd,
   504         RArray<TUint32>& aResultIds )
   516         RArray<TUint32>& aResultIds )
   505     {
   517     {    
       
   518     TRAP_IGNORE(
       
   519     
   506     CMPXMediaArray* mediaArray = TVcxMyVideosCollectionUtil::MediaArrayL( *aCmd );
   520     CMPXMediaArray* mediaArray = TVcxMyVideosCollectionUtil::MediaArrayL( *aCmd );
   507     TInt count = mediaArray->Count();
   521     TInt count = mediaArray->Count();
   508     TUint32 mdsId;
   522     TUint32 mdsId;
   509     CMPXMedia* album;
   523     CMPXMedia* album;
   510     for ( TInt i = 0; i < count; i++ )
   524     for ( TInt i = 0; i < count; i++ )
   519             {
   533             {
   520             album->SetTObjectValueL( KVcxMediaMyVideosInt32Value, KErrGeneral );
   534             album->SetTObjectValueL( KVcxMediaMyVideosInt32Value, KErrGeneral );
   521             }
   535             }
   522         }
   536         }
   523     
   537     
       
   538     );
       
   539     
   524     iCollection.iActiveTask->Done();
   540     iCollection.iActiveTask->Done();
   525     }
   541     }
   526 
   542 
   527 // ----------------------------------------------------------------------------
   543 // ----------------------------------------------------------------------------
   528 // CVcxMyVideosAlbums::HandleRelationEvent
   544 // CVcxMyVideosAlbums::HandleRelationEvent
   545             {
   561             {
   546             album = Album( albumId );
   562             album = Album( albumId );
   547             if ( album )
   563             if ( album )
   548                 {
   564                 {
   549                 album->Remove( aRelationArray[i].RightObjectId(), ETrue /* compress */ );                
   565                 album->Remove( aRelationArray[i].RightObjectId(), ETrue /* compress */ );                
       
   566                 iCollection.iMessageList->AddEventL( TMPXItemId( albumId, KVcxMvcMediaTypeAlbum ),
       
   567                         EMPXItemModified, EVcxMyVideosVideoListOrderChanged );
   550                 }
   568                 }
   551             iCollection.iMessageList->AddEventL( TMPXItemId( albumId, KVcxMvcMediaTypeAlbum ),
       
   552                     EMPXItemModified, EVcxMyVideosVideoListOrderChanged );
       
   553             }
   569             }
   554         else
   570         else
   555             {
   571             {
   556             //We are fetching albums already, we assume that it will be up to date.
   572             //We are fetching albums already, we assume that it will be up to date.
   557             //If that is not the case, then we should set some flag here and restart
   573             //If that is not the case, then we should set some flag here and restart
   561     iCollection.iMessageList->SendL();
   577     iCollection.iMessageList->SendL();
   562     
   578     
   563     );
   579     );
   564     }
   580     }
   565 
   581 
       
   582 // ----------------------------------------------------------------------------
       
   583 // CVcxMyVideosAlbums::UpdateAlbumL
       
   584 // Updates album attributes from aAlbum, if album is not found from memory,
       
   585 // nothing is done (no fetching from MDS).
       
   586 // ----------------------------------------------------------------------------
       
   587 //
       
   588 TBool CVcxMyVideosAlbums::UpdateAlbumL( const CMPXMedia& aAlbum )
       
   589     {
       
   590     TBool changed = EFalse;
       
   591     
       
   592     TMPXItemId mpxId = TVcxMyVideosCollectionUtil::IdL( aAlbum );
       
   593     CVcxMyVideosAlbum* album = Album( mpxId.iId1 );
       
   594 
       
   595     if ( album && album->iMedia )
       
   596         {
       
   597         CMPXMedia* media = album->iMedia;
       
   598 
       
   599         if ( media->IsSupported( KMPXMediaGeneralTitle ) )
       
   600             {
       
   601             TPtrC newTitle( TVcxMyVideosCollectionUtil::Title( aAlbum ) );
       
   602             TPtrC oldTitle( TVcxMyVideosCollectionUtil::Title( *media ) );
       
   603 
       
   604             if ( newTitle != oldTitle )
       
   605                 {
       
   606                 media->SetTextValueL( KMPXMediaGeneralTitle, newTitle );
       
   607                 iCollection.iMessageList->AddEventL( mpxId, EMPXItemModified );
       
   608                 changed = ETrue;
       
   609                 }
       
   610             }
       
   611         }
       
   612     return changed;
       
   613     }
   566 // END OF FILE
   614 // END OF FILE