mmappcomponents/mmmtpdataprovider/src/cmmmtpdpmetadataaccesswrapper.cpp
branchGCC_SURGE
changeset 47 f3d2589f22d6
parent 35 2ee890d2f7e7
child 50 762d760dcfdf
--- a/mmappcomponents/mmmtpdataprovider/src/cmmmtpdpmetadataaccesswrapper.cpp	Wed Jun 16 16:05:08 2010 +0100
+++ b/mmappcomponents/mmmtpdataprovider/src/cmmmtpdpmetadataaccesswrapper.cpp	Thu Jul 22 16:38:21 2010 +0100
@@ -25,6 +25,7 @@
 #include <e32property.h>
 #include <mtpprivatepskeys.h>
 
+#include "mmmtpdp_variant.hrh"
 #include "cmmmtpdpmetadataaccesswrapper.h"
 #include "cmmmtpdpmetadatampxaccess.h"
 #include "cmmmtpdpmetadatavideoaccess.h"
@@ -76,6 +77,12 @@
                        KKeyReadPolicy,
                        KKeyWritePolicy);
 
+#ifdef MMMTPDP_RESET_STATUS_CLOSESESSION
+    MmMtpDpUtility::SetPSStatus(EMtpPSStatusUninitialized);
+#else
+    MmMtpDpUtility::SetPSStatus(EMtpPSStatusReadyToSync);
+#endif // MMMTPDP_RESET_STATUS_CLOSESESSION    
+    
     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::ConstructL" ) );
     }
 
@@ -95,9 +102,8 @@
     delete iMmMtpDpMetadataMpxAccess;
 
     // unblock MPX
-    RProperty::Set( KMtpPSUid,
-                    KMtpPSStatus,
-                    EMtpPSStatusUninitialized );
+    MmMtpDpUtility::SetPSStatus(EMtpPSStatusUninitialized);
+    
     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper" ) );
     }
 
@@ -291,21 +297,6 @@
     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::DeleteObjectL" ) );
     }
 
-// ---------------------------------------------------------------------------
-// CMmMtpDpMetadataAccessWrapper::SetStorageRootL
-// Sets current Drive info
-// ---------------------------------------------------------------------------
-//
-void CMmMtpDpMetadataAccessWrapper::SetStorageRootL( const TDesC& aStorageRoot )
-    {
-    PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::SetStorageRootL" ) );
-
-    iMmMtpDpMetadataVideoAccess->SetStorageRootL( aStorageRoot );
-    iMmMtpDpMetadataMpxAccess->SetStorageRootL( aStorageRoot );
-
-    PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetStorageRootL" ) );
-    }
-
 // -----------------------------------------------------------------------------
 // CMmMtpDpMetadataMpxAccess::SetImageObjPropL
 // set image specific properties specific to videos
@@ -352,6 +343,11 @@
 void CMmMtpDpMetadataAccessWrapper::OpenSessionL()
     {
     iOpenCount++;
+
+#ifdef MMMTPDP_RESET_STATUS_CLOSESESSION
+    if (iOpenCount == 1)
+        MmMtpDpUtility::SetPSStatus(EMtpPSStatusReadyToSync);
+#endif // MMMTPDP_RESET_STATUS_CLOSESESSION
     }
 
 // -----------------------------------------------------------------------------
@@ -370,8 +366,12 @@
         if ( iOpenCount == 0 )
             {
             PRINT( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CloseSessionL close" ) );
-            iMmMtpDpMetadataMpxAccess->CloseSession();
+            iMmMtpDpMetadataMpxAccess->CloseSession();    // trigger close and flush CollectionHelper
             iMmMtpDpMetadataVideoAccess->CloseSessionL();
+            
+#ifdef MMMTPDP_RESET_STATUS_CLOSESESSION
+            MmMtpDpUtility::SetPSStatus(EMtpPSStatusUninitialized);
+#endif // MMMTPDP_RESET_STATUS_CLOSESESSION
             }
         }
     else
@@ -502,7 +502,7 @@
 // CMmMtpDpMetadataAccessWrapper::GetAllAbstractMediaL
 //
 // ---------------------------------------------------------------------------
-EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetAllAbstractMediaL( const TDesC& aStoreRoot, CMPXMediaArray** aAbstractMedias, TMPXGeneralCategory aCategory )
+EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetAllAbstractMediaL( const TDesC& aStoreRoot, CDesCArray& aAbstractMedias, TMPXGeneralCategory aCategory )
     {
     iMmMtpDpMetadataMpxAccess->GetAllAbstractMediaL( aStoreRoot, aAbstractMedias, aCategory );
     }
@@ -512,19 +512,11 @@
 //
 // ---------------------------------------------------------------------------
 //
-EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetAllReferenceL( CMPXMedia* aAbstractMedia, CDesCArray& aReferences )
+EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetAllReferenceL( const CMTPObjectMetaData& aRefOwner, CDesCArray& aReferences )
     {
-    iMmMtpDpMetadataMpxAccess->GetAllReferenceL( aAbstractMedia, aReferences );
-    }
-
-// ---------------------------------------------------------------------------
-// CMmMtpDpMetadataAccessWrapper::GetAbstractMediaNameL
-//
-// ---------------------------------------------------------------------------
-//
-EXPORT_C HBufC* CMmMtpDpMetadataAccessWrapper::GetAbstractMediaNameL( CMPXMedia* aAbstractMedia, TMPXGeneralCategory aCategory )
-    {
-    return iMmMtpDpMetadataMpxAccess->GetAbstractMediaNameL( aAbstractMedia, aCategory );
+    TMPXGeneralCategory category = Category( aRefOwner );
+    if ( category == EMPXPlaylist || category == EMPXAbstractAlbum )
+        iMmMtpDpMetadataMpxAccess->GetAllReferenceL( aRefOwner.DesC( CMTPObjectMetaData::ESuid ), category, aReferences );
     }
 
 // -----------------------------------------------------------------------------
@@ -583,8 +575,6 @@
 //
 TBool CMmMtpDpMetadataAccessWrapper::IsExistL( const TDesC& aSuid )
     {
-    TParsePtrC parse( aSuid );
-    iMmMtpDpMetadataMpxAccess->SetStorageRootL( parse.Drive() );
     return iMmMtpDpMetadataMpxAccess->IsExistL( aSuid );
     }
 
@@ -627,26 +617,22 @@
     {
     PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::CreateDummyFile, filename = %S" ), &aPlaylistName );
 
-    if ( MmMtpDpUtility::FormatFromFilename( aPlaylistName ) ==
-        EMTPFormatCodeAbstractAudioVideoPlaylist )
+    RFile newfile;
+    TInt err = newfile.Replace( iFs, aPlaylistName, EFileWrite );
+
+    if ( err != KErrNone )
         {
-        RFile newfile;
-        TInt err = newfile.Replace( iFs, aPlaylistName, EFileWrite );
-
+        newfile.Close();
+        PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile err =  %d" ), err );
+        }
+    else // File created OK
+        {
+        err = newfile.Flush();
+        newfile.Close();
+        err = iFs.SetAtt( aPlaylistName, KEntryAttSystem | KEntryAttHidden,
+            KEntryAttReadOnly | KEntryAttNormal );
         if ( err != KErrNone )
-            {
-            newfile.Close();
-            PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile err =  %d" ), err );
-            }
-        else // File created OK
-            {
-            err = newfile.Flush();
-            newfile.Close();
-            err = iFs.SetAtt( aPlaylistName, KEntryAttSystem | KEntryAttHidden,
-                KEntryAttReadOnly | KEntryAttNormal );
-            if ( err != KErrNone )
-                PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile Dummy Playlist file created. err = %d" ), err );
-            }
+            PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile Dummy Playlist file created. err = %d" ), err );
         }
     }
 
@@ -685,7 +671,7 @@
             PRINT3( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile filename = %S, err %d, entry.iSize = %d" ),
                 &fileName, err, entry.iSize );
             }
-        else if ( format != EMTPFormatCodeM3UPlaylist )
+        else
             {
             TInt err = iFs.Delete( fileName );
 
@@ -693,11 +679,6 @@
                 &fileName,
                 err );
             }
-        else
-            {
-            // leave the Imported playlist in the file system
-            PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile, Don't delete m3u file [%S]" ), &fileName );
-            }
         }
     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles" ) );
     }
@@ -707,8 +688,9 @@
 // Update Music collection
 // ---------------------------------------------------------------------------
 //
-EXPORT_C void CMmMtpDpMetadataAccessWrapper::UpdateMusicCollectionL()
+EXPORT_C void CMmMtpDpMetadataAccessWrapper::UpdateMusicCollectionL( const TDesC& aStorageRoot )
     {
+    iMmMtpDpMetadataMpxAccess->SetStorageRootL( aStorageRoot );
     iMmMtpDpMetadataMpxAccess->UpdateMusicCollectionL( );
     }