mmappcomponents/mmmtpdataprovider/src/cmmmtpdpmetadataaccesswrapper.cpp
changeset 32 edd273b3192a
parent 27 cbb1bfb7ebfb
child 35 2ee890d2f7e7
equal deleted inserted replaced
27:cbb1bfb7ebfb 32:edd273b3192a
    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" ) );
   581 // if the playlsit exist in the MPX DB
   581 // if the playlsit exist in the MPX DB
   582 // ---------------------------------------------------------------------------
   582 // ---------------------------------------------------------------------------
   583 //
   583 //
   584 TBool CMmMtpDpMetadataAccessWrapper::IsExistL( const TDesC& aSuid )
   584 TBool CMmMtpDpMetadataAccessWrapper::IsExistL( const TDesC& aSuid )
   585     {
   585     {
   586     TParsePtrC parse( aSuid );
       
   587     iMmMtpDpMetadataMpxAccess->SetStorageRootL( parse.Drive() );
       
   588     return iMmMtpDpMetadataMpxAccess->IsExistL( aSuid );
   586     return iMmMtpDpMetadataMpxAccess->IsExistL( aSuid );
   589     }
   587     }
   590 
   588 
   591 // -----------------------------------------------------------------------------
   589 // -----------------------------------------------------------------------------
   592 // CMmMtpDpMetadataAccessWrapper::AddDummyFile
   590 // CMmMtpDpMetadataAccessWrapper::AddDummyFile
   625 //
   623 //
   626 EXPORT_C void CMmMtpDpMetadataAccessWrapper::CreateDummyFile( const TDesC& aPlaylistName )
   624 EXPORT_C void CMmMtpDpMetadataAccessWrapper::CreateDummyFile( const TDesC& aPlaylistName )
   627     {
   625     {
   628     PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::CreateDummyFile, filename = %S" ), &aPlaylistName );
   626     PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::CreateDummyFile, filename = %S" ), &aPlaylistName );
   629 
   627 
   630     if ( MmMtpDpUtility::FormatFromFilename( aPlaylistName ) ==
   628     RFile newfile;
   631         EMTPFormatCodeAbstractAudioVideoPlaylist )
   629     TInt err = newfile.Replace( iFs, aPlaylistName, EFileWrite );
   632         {
   630 
   633         RFile newfile;
   631     if ( err != KErrNone )
   634         TInt err = newfile.Replace( iFs, aPlaylistName, EFileWrite );
   632         {
   635 
   633         newfile.Close();
       
   634         PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile err =  %d" ), err );
       
   635         }
       
   636     else // File created OK
       
   637         {
       
   638         err = newfile.Flush();
       
   639         newfile.Close();
       
   640         err = iFs.SetAtt( aPlaylistName, KEntryAttSystem | KEntryAttHidden,
       
   641             KEntryAttReadOnly | KEntryAttNormal );
   636         if ( err != KErrNone )
   642         if ( err != KErrNone )
   637             {
   643             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         }
   644         }
   651     }
   645     }
   652 
   646 
   653 // -----------------------------------------------------------------------------
   647 // -----------------------------------------------------------------------------
   654 // CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles
   648 // CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles
   683                     }
   677                     }
   684                 }
   678                 }
   685             PRINT3( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile filename = %S, err %d, entry.iSize = %d" ),
   679             PRINT3( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile filename = %S, err %d, entry.iSize = %d" ),
   686                 &fileName, err, entry.iSize );
   680                 &fileName, err, entry.iSize );
   687             }
   681             }
   688         else if ( format != EMTPFormatCodeM3UPlaylist )
   682         else
   689             {
   683             {
   690             TInt err = iFs.Delete( fileName );
   684             TInt err = iFs.Delete( fileName );
   691 
   685 
   692             PRINT2( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile filename = %S, err %d" ),
   686             PRINT2( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile filename = %S, err %d" ),
   693                 &fileName,
   687                 &fileName,
   694                 err );
   688                 err );
   695             }
   689             }
   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         }
   690         }
   702     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles" ) );
   691     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles" ) );
   703     }
   692     }
   704 
   693 
   705 // ---------------------------------------------------------------------------
   694 // ---------------------------------------------------------------------------
   706 // CMmMtpDpMetadataAccessWrapper::UpdateMusicCollectionL
   695 // CMmMtpDpMetadataAccessWrapper::UpdateMusicCollectionL
   707 // Update Music collection
   696 // Update Music collection
   708 // ---------------------------------------------------------------------------
   697 // ---------------------------------------------------------------------------
   709 //
   698 //
   710 EXPORT_C void CMmMtpDpMetadataAccessWrapper::UpdateMusicCollectionL()
   699 EXPORT_C void CMmMtpDpMetadataAccessWrapper::UpdateMusicCollectionL( const TDesC& aStorageRoot )
   711     {
   700     {
       
   701     iMmMtpDpMetadataMpxAccess->SetStorageRootL( aStorageRoot );
   712     iMmMtpDpMetadataMpxAccess->UpdateMusicCollectionL( );
   702     iMmMtpDpMetadataMpxAccess->UpdateMusicCollectionL( );
   713     }
   703     }
   714 
   704 
   715 // end of file
   705 // end of file