mmappcomponents/mmmtpdataprovider/src/cmmmtpdpmetadataaccesswrapper.cpp
branchGCC_SURGE
changeset 47 f3d2589f22d6
parent 35 2ee890d2f7e7
child 50 762d760dcfdf
equal deleted inserted replaced
36:3b7506f63335 47:f3d2589f22d6
    23 #include <bautils.h>
    23 #include <bautils.h>
    24 #include <e32math.h>
    24 #include <e32math.h>
    25 #include <e32property.h>
    25 #include <e32property.h>
    26 #include <mtpprivatepskeys.h>
    26 #include <mtpprivatepskeys.h>
    27 
    27 
       
    28 #include "mmmtpdp_variant.hrh"
    28 #include "cmmmtpdpmetadataaccesswrapper.h"
    29 #include "cmmmtpdpmetadataaccesswrapper.h"
    29 #include "cmmmtpdpmetadatampxaccess.h"
    30 #include "cmmmtpdpmetadatampxaccess.h"
    30 #include "cmmmtpdpmetadatavideoaccess.h"
    31 #include "cmmmtpdpmetadatavideoaccess.h"
    31 #include "mmmtpdputility.h"
    32 #include "mmmtpdputility.h"
    32 #include "tobjectdescription.h"
    33 #include "tobjectdescription.h"
    74                        KMtpPSStatus,
    75                        KMtpPSStatus,
    75                        RProperty::EInt,
    76                        RProperty::EInt,
    76                        KKeyReadPolicy,
    77                        KKeyReadPolicy,
    77                        KKeyWritePolicy);
    78                        KKeyWritePolicy);
    78 
    79 
       
    80 #ifdef MMMTPDP_RESET_STATUS_CLOSESESSION
       
    81     MmMtpDpUtility::SetPSStatus(EMtpPSStatusUninitialized);
       
    82 #else
       
    83     MmMtpDpUtility::SetPSStatus(EMtpPSStatusReadyToSync);
       
    84 #endif // MMMTPDP_RESET_STATUS_CLOSESESSION    
       
    85     
    79     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::ConstructL" ) );
    86     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::ConstructL" ) );
    80     }
    87     }
    81 
    88 
    82 // ---------------------------------------------------------------------------
    89 // ---------------------------------------------------------------------------
    83 // CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper
    90 // CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper
    93 
   100 
    94     delete iMmMtpDpMetadataVideoAccess;
   101     delete iMmMtpDpMetadataVideoAccess;
    95     delete iMmMtpDpMetadataMpxAccess;
   102     delete iMmMtpDpMetadataMpxAccess;
    96 
   103 
    97     // unblock MPX
   104     // unblock MPX
    98     RProperty::Set( KMtpPSUid,
   105     MmMtpDpUtility::SetPSStatus(EMtpPSStatusUninitialized);
    99                     KMtpPSStatus,
   106     
   100                     EMtpPSStatusUninitialized );
       
   101     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper" ) );
   107     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper" ) );
   102     }
   108     }
   103 
   109 
   104 // -----------------------------------------------------------------------------
   110 // -----------------------------------------------------------------------------
   105 // CMmMtpDpMetadataAccessWrapper::SetReferenceL
   111 // CMmMtpDpMetadataAccessWrapper::SetReferenceL
   289         }
   295         }
   290 
   296 
   291     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::DeleteObjectL" ) );
   297     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::DeleteObjectL" ) );
   292     }
   298     }
   293 
   299 
   294 // ---------------------------------------------------------------------------
       
   295 // CMmMtpDpMetadataAccessWrapper::SetStorageRootL
       
   296 // Sets current Drive info
       
   297 // ---------------------------------------------------------------------------
       
   298 //
       
   299 void CMmMtpDpMetadataAccessWrapper::SetStorageRootL( const TDesC& aStorageRoot )
       
   300     {
       
   301     PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::SetStorageRootL" ) );
       
   302 
       
   303     iMmMtpDpMetadataVideoAccess->SetStorageRootL( aStorageRoot );
       
   304     iMmMtpDpMetadataMpxAccess->SetStorageRootL( aStorageRoot );
       
   305 
       
   306     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetStorageRootL" ) );
       
   307     }
       
   308 
       
   309 // -----------------------------------------------------------------------------
   300 // -----------------------------------------------------------------------------
   310 // CMmMtpDpMetadataMpxAccess::SetImageObjPropL
   301 // CMmMtpDpMetadataMpxAccess::SetImageObjPropL
   311 // set image specific properties specific to videos
   302 // set image specific properties specific to videos
   312 // -----------------------------------------------------------------------------
   303 // -----------------------------------------------------------------------------
   313 //
   304 //
   350 // -----------------------------------------------------------------------------
   341 // -----------------------------------------------------------------------------
   351 //
   342 //
   352 void CMmMtpDpMetadataAccessWrapper::OpenSessionL()
   343 void CMmMtpDpMetadataAccessWrapper::OpenSessionL()
   353     {
   344     {
   354     iOpenCount++;
   345     iOpenCount++;
       
   346 
       
   347 #ifdef MMMTPDP_RESET_STATUS_CLOSESESSION
       
   348     if (iOpenCount == 1)
       
   349         MmMtpDpUtility::SetPSStatus(EMtpPSStatusReadyToSync);
       
   350 #endif // MMMTPDP_RESET_STATUS_CLOSESESSION
   355     }
   351     }
   356 
   352 
   357 // -----------------------------------------------------------------------------
   353 // -----------------------------------------------------------------------------
   358 // CMmMtpDpMetadataAccessWrapper::CloseSessionL
   354 // CMmMtpDpMetadataAccessWrapper::CloseSessionL
   359 //
   355 //
   368         iOpenCount--;
   364         iOpenCount--;
   369 
   365 
   370         if ( iOpenCount == 0 )
   366         if ( iOpenCount == 0 )
   371             {
   367             {
   372             PRINT( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CloseSessionL close" ) );
   368             PRINT( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CloseSessionL close" ) );
   373             iMmMtpDpMetadataMpxAccess->CloseSession();
   369             iMmMtpDpMetadataMpxAccess->CloseSession();    // trigger close and flush CollectionHelper
   374             iMmMtpDpMetadataVideoAccess->CloseSessionL();
   370             iMmMtpDpMetadataVideoAccess->CloseSessionL();
       
   371             
       
   372 #ifdef MMMTPDP_RESET_STATUS_CLOSESESSION
       
   373             MmMtpDpUtility::SetPSStatus(EMtpPSStatusUninitialized);
       
   374 #endif // MMMTPDP_RESET_STATUS_CLOSESESSION
   375             }
   375             }
   376         }
   376         }
   377     else
   377     else
   378         {
   378         {
   379         PRINT( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CloseSessionL already close" ) );
   379         PRINT( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CloseSessionL already close" ) );
   500 
   500 
   501 // ---------------------------------------------------------------------------
   501 // ---------------------------------------------------------------------------
   502 // CMmMtpDpMetadataAccessWrapper::GetAllAbstractMediaL
   502 // CMmMtpDpMetadataAccessWrapper::GetAllAbstractMediaL
   503 //
   503 //
   504 // ---------------------------------------------------------------------------
   504 // ---------------------------------------------------------------------------
   505 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetAllAbstractMediaL( const TDesC& aStoreRoot, CMPXMediaArray** aAbstractMedias, TMPXGeneralCategory aCategory )
   505 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetAllAbstractMediaL( const TDesC& aStoreRoot, CDesCArray& aAbstractMedias, TMPXGeneralCategory aCategory )
   506     {
   506     {
   507     iMmMtpDpMetadataMpxAccess->GetAllAbstractMediaL( aStoreRoot, aAbstractMedias, aCategory );
   507     iMmMtpDpMetadataMpxAccess->GetAllAbstractMediaL( aStoreRoot, aAbstractMedias, aCategory );
   508     }
   508     }
   509 
   509 
   510 // ---------------------------------------------------------------------------
   510 // ---------------------------------------------------------------------------
   511 // CMmMtpDpMetadataAccessWrapper::GetAllReferenceL
   511 // CMmMtpDpMetadataAccessWrapper::GetAllReferenceL
   512 //
   512 //
   513 // ---------------------------------------------------------------------------
   513 // ---------------------------------------------------------------------------
   514 //
   514 //
   515 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetAllReferenceL( CMPXMedia* aAbstractMedia, CDesCArray& aReferences )
   515 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetAllReferenceL( const CMTPObjectMetaData& aRefOwner, CDesCArray& aReferences )
   516     {
   516     {
   517     iMmMtpDpMetadataMpxAccess->GetAllReferenceL( aAbstractMedia, aReferences );
   517     TMPXGeneralCategory category = Category( aRefOwner );
   518     }
   518     if ( category == EMPXPlaylist || category == EMPXAbstractAlbum )
   519 
   519         iMmMtpDpMetadataMpxAccess->GetAllReferenceL( aRefOwner.DesC( CMTPObjectMetaData::ESuid ), category, aReferences );
   520 // ---------------------------------------------------------------------------
       
   521 // CMmMtpDpMetadataAccessWrapper::GetAbstractMediaNameL
       
   522 //
       
   523 // ---------------------------------------------------------------------------
       
   524 //
       
   525 EXPORT_C HBufC* CMmMtpDpMetadataAccessWrapper::GetAbstractMediaNameL( CMPXMedia* aAbstractMedia, TMPXGeneralCategory aCategory )
       
   526     {
       
   527     return iMmMtpDpMetadataMpxAccess->GetAbstractMediaNameL( aAbstractMedia, aCategory );
       
   528     }
   520     }
   529 
   521 
   530 // -----------------------------------------------------------------------------
   522 // -----------------------------------------------------------------------------
   531 // CMmMtpDpMetadataAccessWrapper::AddObjectL
   523 // CMmMtpDpMetadataAccessWrapper::AddObjectL
   532 // Add object (music, video, playlist and abstract media) info to DB
   524 // Add object (music, video, playlist and abstract media) info to DB
   581 // if the playlsit exist in the MPX DB
   573 // if the playlsit exist in the MPX DB
   582 // ---------------------------------------------------------------------------
   574 // ---------------------------------------------------------------------------
   583 //
   575 //
   584 TBool CMmMtpDpMetadataAccessWrapper::IsExistL( const TDesC& aSuid )
   576 TBool CMmMtpDpMetadataAccessWrapper::IsExistL( const TDesC& aSuid )
   585     {
   577     {
   586     TParsePtrC parse( aSuid );
       
   587     iMmMtpDpMetadataMpxAccess->SetStorageRootL( parse.Drive() );
       
   588     return iMmMtpDpMetadataMpxAccess->IsExistL( aSuid );
   578     return iMmMtpDpMetadataMpxAccess->IsExistL( aSuid );
   589     }
   579     }
   590 
   580 
   591 // -----------------------------------------------------------------------------
   581 // -----------------------------------------------------------------------------
   592 // CMmMtpDpMetadataAccessWrapper::AddDummyFile
   582 // CMmMtpDpMetadataAccessWrapper::AddDummyFile
   625 //
   615 //
   626 EXPORT_C void CMmMtpDpMetadataAccessWrapper::CreateDummyFile( const TDesC& aPlaylistName )
   616 EXPORT_C void CMmMtpDpMetadataAccessWrapper::CreateDummyFile( const TDesC& aPlaylistName )
   627     {
   617     {
   628     PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::CreateDummyFile, filename = %S" ), &aPlaylistName );
   618     PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::CreateDummyFile, filename = %S" ), &aPlaylistName );
   629 
   619 
   630     if ( MmMtpDpUtility::FormatFromFilename( aPlaylistName ) ==
   620     RFile newfile;
   631         EMTPFormatCodeAbstractAudioVideoPlaylist )
   621     TInt err = newfile.Replace( iFs, aPlaylistName, EFileWrite );
   632         {
   622 
   633         RFile newfile;
   623     if ( err != KErrNone )
   634         TInt err = newfile.Replace( iFs, aPlaylistName, EFileWrite );
   624         {
   635 
   625         newfile.Close();
       
   626         PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile err =  %d" ), err );
       
   627         }
       
   628     else // File created OK
       
   629         {
       
   630         err = newfile.Flush();
       
   631         newfile.Close();
       
   632         err = iFs.SetAtt( aPlaylistName, KEntryAttSystem | KEntryAttHidden,
       
   633             KEntryAttReadOnly | KEntryAttNormal );
   636         if ( err != KErrNone )
   634         if ( err != KErrNone )
   637             {
   635             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile Dummy Playlist file created. err = %d" ), err );
   638             newfile.Close();
       
   639             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile err =  %d" ), err );
       
   640             }
       
   641         else // File created OK
       
   642             {
       
   643             err = newfile.Flush();
       
   644             newfile.Close();
       
   645             err = iFs.SetAtt( aPlaylistName, KEntryAttSystem | KEntryAttHidden,
       
   646                 KEntryAttReadOnly | KEntryAttNormal );
       
   647             if ( err != KErrNone )
       
   648                 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile Dummy Playlist file created. err = %d" ), err );
       
   649             }
       
   650         }
   636         }
   651     }
   637     }
   652 
   638 
   653 // -----------------------------------------------------------------------------
   639 // -----------------------------------------------------------------------------
   654 // CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles
   640 // CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles
   683                     }
   669                     }
   684                 }
   670                 }
   685             PRINT3( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile filename = %S, err %d, entry.iSize = %d" ),
   671             PRINT3( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile filename = %S, err %d, entry.iSize = %d" ),
   686                 &fileName, err, entry.iSize );
   672                 &fileName, err, entry.iSize );
   687             }
   673             }
   688         else if ( format != EMTPFormatCodeM3UPlaylist )
   674         else
   689             {
   675             {
   690             TInt err = iFs.Delete( fileName );
   676             TInt err = iFs.Delete( fileName );
   691 
   677 
   692             PRINT2( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile filename = %S, err %d" ),
   678             PRINT2( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile filename = %S, err %d" ),
   693                 &fileName,
   679                 &fileName,
   694                 err );
   680                 err );
   695             }
   681             }
   696         else
       
   697             {
       
   698             // leave the Imported playlist in the file system
       
   699             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile, Don't delete m3u file [%S]" ), &fileName );
       
   700             }
       
   701         }
   682         }
   702     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles" ) );
   683     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles" ) );
   703     }
   684     }
   704 
   685 
   705 // ---------------------------------------------------------------------------
   686 // ---------------------------------------------------------------------------
   706 // CMmMtpDpMetadataAccessWrapper::UpdateMusicCollectionL
   687 // CMmMtpDpMetadataAccessWrapper::UpdateMusicCollectionL
   707 // Update Music collection
   688 // Update Music collection
   708 // ---------------------------------------------------------------------------
   689 // ---------------------------------------------------------------------------
   709 //
   690 //
   710 EXPORT_C void CMmMtpDpMetadataAccessWrapper::UpdateMusicCollectionL()
   691 EXPORT_C void CMmMtpDpMetadataAccessWrapper::UpdateMusicCollectionL( const TDesC& aStorageRoot )
   711     {
   692     {
       
   693     iMmMtpDpMetadataMpxAccess->SetStorageRootL( aStorageRoot );
   712     iMmMtpDpMetadataMpxAccess->UpdateMusicCollectionL( );
   694     iMmMtpDpMetadataMpxAccess->UpdateMusicCollectionL( );
   713     }
   695     }
   714 
   696 
   715 // end of file
   697 // end of file