mmappcomponents/mmmtpdataprovider/src/cmmmtpdpmetadataaccesswrapper.cpp
changeset 25 d881023c13eb
parent 0 a2952bb97e68
child 27 cbb1bfb7ebfb
equal deleted inserted replaced
21:a05c44bc3c61 25:d881023c13eb
    14 * Description:  Meta data access wrapper
    14 * Description:  Meta data access wrapper
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
       
    19 #include <mtp/mmtpdataproviderframework.h>
       
    20 #include <mtp/mmtpobjectmgr.h>
       
    21 #include <mtp/cmtptypestring.h>
       
    22 #include <mtp/cmtpobjectmetadata.h>
    19 #include <bautils.h>
    23 #include <bautils.h>
    20 #include <e32math.h>
    24 #include <e32math.h>
    21 #include <mtp/mmtpdataproviderframework.h>
       
    22 #include <e32property.h>
    25 #include <e32property.h>
    23 #include <MtpPrivatePSKeys.h>
    26 #include <mtpprivatepskeys.h>
    24 
    27 
    25 #include "cmmmtpdpmetadataaccesswrapper.h"
    28 #include "cmmmtpdpmetadataaccesswrapper.h"
    26 #include "cmmmtpdpmetadatampxaccess.h"
    29 #include "cmmmtpdpmetadatampxaccess.h"
    27 #include "cmmmtpdpmetadatavideoaccess.h"
    30 #include "cmmmtpdpmetadatavideoaccess.h"
    28 #include "mmmtpdputility.h"
    31 #include "mmmtpdputility.h"
       
    32 #include "tobjectdescription.h"
    29 #include "mmmtpdplogger.h"
    33 #include "mmmtpdplogger.h"
    30 
    34 
    31 const TInt KMMMTPDummyFileArrayGranularity = 5;
    35 const TInt KMmMtpDummyFileArrayGranularity = 5;
    32 
    36 
    33 CMmMtpDpMetadataAccessWrapper* CMmMtpDpMetadataAccessWrapper::NewL( RFs& aRfs, 
    37 CMmMtpDpMetadataAccessWrapper* CMmMtpDpMetadataAccessWrapper::NewL( MMTPDataProviderFramework& aFramework )
    34     MMTPDataProviderFramework& aFramework )
    38     {
    35     {
    39     CMmMtpDpMetadataAccessWrapper* me = new (ELeave) CMmMtpDpMetadataAccessWrapper( aFramework );
    36     CMmMtpDpMetadataAccessWrapper* me = new (ELeave) CMmMtpDpMetadataAccessWrapper( aRfs, aFramework );
       
    37     CleanupStack::PushL( me );
    40     CleanupStack::PushL( me );
    38     me->ConstructL();
    41     me->ConstructL();
    39     CleanupStack::Pop( me );
    42     CleanupStack::Pop( me );
    40     
    43 
    41     return me;
    44     return me;
    42     }
    45     }
    43 
    46 
    44 CMmMtpDpMetadataAccessWrapper::CMmMtpDpMetadataAccessWrapper( RFs& aRfs, 
    47 CMmMtpDpMetadataAccessWrapper::CMmMtpDpMetadataAccessWrapper( MMTPDataProviderFramework& aFramework ) :
    45     MMTPDataProviderFramework& aFramework ) :
    48     iFramework( aFramework ),
    46     iRfs( aRfs ),
    49     iFs( aFramework.Fs() )
    47     iFramework( aFramework )
    50     {
    48     {
    51     // Do nothing
    49     
       
    50     }
    52     }
    51 
    53 
    52 // ---------------------------------------------------------------------------
    54 // ---------------------------------------------------------------------------
    53 // CMmMtpDpMetadataAccessWrapper::ConstructL
    55 // CMmMtpDpMetadataAccessWrapper::ConstructL
    54 // Second-phase
    56 // Second-phase
    56 //
    58 //
    57 void CMmMtpDpMetadataAccessWrapper::ConstructL()
    59 void CMmMtpDpMetadataAccessWrapper::ConstructL()
    58     {
    60     {
    59     PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::ConstructL" ) );
    61     PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::ConstructL" ) );
    60 
    62 
    61     iMmMtpDpMetadataMpxAccess = CMmMtpDpMetadataMpxAccess::NewL( iRfs, iFramework );
    63     iMmMtpDpMetadataMpxAccess = CMmMtpDpMetadataMpxAccess::NewL( iFs );
    62 
    64 
    63     iMmMtpDpMetadataVideoAccess = CMmMtpDpMetadataVideoAccess::NewL( iRfs );
    65     iMmMtpDpMetadataVideoAccess = CMmMtpDpMetadataVideoAccess::NewL( iFs );
    64     
    66 
    65     iPlaylistArray = new ( ELeave ) CDesCArrayFlat( KMMMTPDummyFileArrayGranularity );
    67     iAbstractMediaArray = new ( ELeave ) CDesCArrayFlat( KMmMtpDummyFileArrayGranularity );
    66     
    68 
    67     // Create the PS key to notify subscribers that MTP mode is activated
    69     // Create the PS key to notify subscribers that MTP mode is activated
    68     _LIT_SECURITY_POLICY_C1(KKeyReadPolicy, ECapabilityReadUserData);
    70     _LIT_SECURITY_POLICY_C1(KKeyReadPolicy, ECapabilityReadUserData);
    69     _LIT_SECURITY_POLICY_C1(KKeyWritePolicy, ECapabilityWriteUserData);
    71     _LIT_SECURITY_POLICY_C1(KKeyWritePolicy, ECapabilityWriteUserData);
    70     RProperty::Define( KMtpPSUid, 
    72     RProperty::Define( KMtpPSUid,
    71                        KMtpPSStatus, 
    73                        KMtpPSStatus,
    72                        RProperty::EInt, 
    74                        RProperty::EInt,
    73                        KKeyReadPolicy, 
    75                        KKeyReadPolicy,
    74                        KKeyWritePolicy);
    76                        KKeyWritePolicy);
    75 
    77 
    76     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::ConstructL" ) );
    78     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::ConstructL" ) );
    77     }
    79     }
    78 
    80 
    84 CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper()
    86 CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper()
    85     {
    87     {
    86     PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper" ) );
    88     PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper" ) );
    87     RemoveDummyFiles();
    89     RemoveDummyFiles();
    88 
    90 
    89     delete iPlaylistArray;
    91     delete iAbstractMediaArray;
    90 
    92 
    91     delete iMmMtpDpMetadataVideoAccess;
    93     delete iMmMtpDpMetadataVideoAccess;
    92     delete iMmMtpDpMetadataMpxAccess;
    94     delete iMmMtpDpMetadataMpxAccess;
    93     
    95 
    94     // unblock MPX
    96     // unblock MPX
    95     RProperty::Set( KMtpPSUid, 
    97     RProperty::Set( KMtpPSUid,
    96                     KMtpPSStatus, 
    98                     KMtpPSStatus,
    97                     EMtpPSStatusUninitialized);
    99                     EMtpPSStatusUninitialized );
    98     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper" ) );
   100     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper" ) );
    99     }
   101     }
   100 
   102 
   101 // -----------------------------------------------------------------------------
   103 // -----------------------------------------------------------------------------
   102 // CMmMtpDpMetadataAccessWrapper::SetPlaylist
   104 // CMmMtpDpMetadataAccessWrapper::SetReferenceL
   103 // Set playlist to DB
   105 // Set abstract media to DB
   104 // -----------------------------------------------------------------------------
   106 // -----------------------------------------------------------------------------
   105 //
   107 //
   106 EXPORT_C void CMmMtpDpMetadataAccessWrapper::SetPlaylistL( const TDesC& aPlaylistFileName, CDesCArray& aRefFileArray )
   108 EXPORT_C void CMmMtpDpMetadataAccessWrapper::SetReferenceL( const CMTPObjectMetaData& aObject,
   107     {
   109     CDesCArray& aRefFileArray )
   108     PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::SetPlaylistL aPlaylistFileName = %S" ), &aPlaylistFileName );
   110     {
   109 
   111     TPtrC refOwner( aObject.DesC( CMTPObjectMetaData::ESuid ) );
   110     if ( !MmMtpDpUtility::IsVideoL( aPlaylistFileName, iFramework ) )
   112     PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::SetReferenceL reference owner = %S" ),
   111         {
   113         &refOwner );
   112         iMmMtpDpMetadataMpxAccess->SetPlaylistL( aPlaylistFileName, aRefFileArray );
   114 
   113         }
   115     TMPXGeneralCategory category = Category( aObject );
   114 
   116     if ( category == EMPXPlaylist || category == EMPXAbstractAlbum )
   115     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetPlaylistL" ) );
   117         {
   116     }
   118         iMmMtpDpMetadataMpxAccess->SetReferenceL( refOwner, aRefFileArray, category );
   117 
   119         }
   118 // ---------------------------------------------------------------------------
   120 
   119 // CMmMtpDpMetadataAccessWrapper::AddMediaL
   121     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetReferenceL" ) );
       
   122     }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL
   120 // Gets a piece of metadata from the collection
   126 // Gets a piece of metadata from the collection
   121 // ---------------------------------------------------------------------------
   127 // ---------------------------------------------------------------------------
   122 //
   128 //
   123 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL( const TUint16 aPropCode,
   129 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL( const TUint16 aPropCode,
   124     MMTPType& aNewData,
   130     MMTPType& aNewData,
   125     const CMTPObjectMetaData& aObjectMetaData )
   131     const CMTPObjectMetaData& aObjectMetaData )
   126     {
   132     {
   127     PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL" ) );
   133     PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL" ) );
   128 
   134 
   129     TPtrC fullFileName( aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ) );
   135     TMPXGeneralCategory category = Category( aObjectMetaData );
   130     if ( !MmMtpDpUtility::IsVideoL( fullFileName, iFramework ) )
   136     switch ( category )
   131         {
   137         {
   132         iMmMtpDpMetadataMpxAccess->GetObjectMetadataValueL( aPropCode,
   138         case EMPXAbstractAlbum:
   133             aNewData,
   139             if ( aPropCode == EMTPObjectPropCodeDateAdded && EMTPTypeString == aNewData.Type() )
   134             aObjectMetaData );
   140                 {
   135         }
   141                 TBuf<KMtpMaxDateTimeStringLength> timeStr;
   136     else
   142                 MmMtpDpUtility::GetObjectDateModifiedL( iFs,
   137         {
   143                     aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ),
   138         iMmMtpDpMetadataVideoAccess->GetObjectMetadataValueL( aPropCode,
   144                     timeStr );
   139             aNewData,
   145                 PRINT1( _L( "MM MTP <> CGetObjectPropList::ServiceOneObjectPropertyL Date time %S" ), &timeStr );
   140             aObjectMetaData );
   146 
       
   147                 ( ( CMTPTypeString & ) aNewData ).SetL( timeStr );
       
   148                 break;
       
   149                 }
       
   150             // else
       
   151             // get from mpx
       
   152         case EMPXPlaylist:
       
   153         case EMPXSong:
       
   154             {
       
   155             iMmMtpDpMetadataMpxAccess->GetObjectMetadataValueL( aPropCode,
       
   156                 aNewData,
       
   157                 aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ),
       
   158                 category );
       
   159             }
       
   160             break;
       
   161         case EMPXVideo:
       
   162             if ( aPropCode == EMTPObjectPropCodeDateAdded && EMTPTypeString == aNewData.Type() )
       
   163                 {
       
   164                 TBuf<KMtpMaxDateTimeStringLength> timeStr;
       
   165                 MmMtpDpUtility::GetObjectDateModifiedL( iFs,
       
   166                     aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ),
       
   167                     timeStr );
       
   168                 PRINT1( _L( "MM MTP <> CGetObjectPropList::ServiceOneObjectPropertyL Date time %S" ), &timeStr );
       
   169 
       
   170                 ( ( CMTPTypeString & ) aNewData ).SetL( timeStr );
       
   171                 }
       
   172             else
       
   173                 {
       
   174                 iMmMtpDpMetadataVideoAccess->GetObjectMetadataValueL( aPropCode,
       
   175                     aNewData,
       
   176                     aObjectMetaData );
       
   177                 }
       
   178             break;
       
   179         default:
       
   180             // do nothing
       
   181             break;
   141         }
   182         }
   142 
   183 
   143     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL" ) );
   184     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL" ) );
   144     }
   185     }
   145 
   186 
   152     const MMTPType& aNewData,
   193     const MMTPType& aNewData,
   153     const CMTPObjectMetaData& aObjectMetaData )
   194     const CMTPObjectMetaData& aObjectMetaData )
   154     {
   195     {
   155     PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL" ) );
   196     PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL" ) );
   156 
   197 
   157     TPtrC fullFileName( aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ) );
   198     TMPXGeneralCategory category = Category( aObjectMetaData );
   158     if ( MmMtpDpUtility::IsVideoL( fullFileName, iFramework ) )
   199     switch ( category )
   159         {
   200         {
   160         iMmMtpDpMetadataVideoAccess->SetObjectMetadataValueL( aPropCode,
   201         case EMPXAbstractAlbum:
   161             aNewData,
   202         case EMPXSong:
   162             aObjectMetaData );
   203         case EMPXPlaylist:
   163         }
   204             iMmMtpDpMetadataMpxAccess->SetObjectMetadataValueL( aPropCode,
   164     else
   205                 aNewData,
   165         {
   206                 aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ),
   166         iMmMtpDpMetadataMpxAccess->SetObjectMetadataValueL( aPropCode,
   207                 category );
   167             aNewData,
   208             break;
   168             aObjectMetaData );
   209         case EMPXVideo:
   169         }
   210             iMmMtpDpMetadataVideoAccess->SetObjectMetadataValueL( aPropCode,
   170 
   211                 aNewData,
       
   212                 aObjectMetaData );
       
   213             break;
       
   214         default:
       
   215             break;
       
   216         }
   171 
   217 
   172     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL" ) );
   218     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL" ) );
   173     }
   219     }
   174 
   220 
   175 // ---------------------------------------------------------------------------
   221 // ---------------------------------------------------------------------------
   176 // CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL
   222 // CMmMtpDpMetadataAccessWrapper::RenameObjectL
   177 // Renames the file part of a record in the collection database
   223 // Renames the file part of a record in the collection database
   178 // ---------------------------------------------------------------------------
   224 // ---------------------------------------------------------------------------
   179 //
   225 //
   180 EXPORT_C void CMmMtpDpMetadataAccessWrapper::RenameObjectL( const TDesC& aOldFileName,
   226 EXPORT_C void CMmMtpDpMetadataAccessWrapper::RenameObjectL( const CMTPObjectMetaData& aOldObject,
   181     const TDesC& aNewFileName )
   227     const TDesC& aNewFileName )
   182     {
   228     {
       
   229     TPtrC oldFileName( aOldObject.DesC( CMTPObjectMetaData::ESuid ) );
   183     PRINT2( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::RenameObjectL old = %S, new = %S" ),
   230     PRINT2( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::RenameObjectL old = %S, new = %S" ),
   184         &aOldFileName,
   231         &oldFileName,
   185         &aNewFileName );
   232         &aNewFileName );
   186     
   233 
   187    TMTPFormatCode formatCode = MmMtpDpUtility::FormatFromFilename( aOldFileName );
   234     TMPXGeneralCategory category = Category( aOldObject );
   188     if ( formatCode == EMTPFormatCodeWMV )
   235     switch ( category )
   189         {
   236         {
   190         iMmMtpDpMetadataVideoAccess->RenameRecordL( aOldFileName, aNewFileName );
   237         case EMPXSong:
   191         }
   238         case EMPXAbstractAlbum:
   192     else
   239         case EMPXPlaylist:
   193         {
   240             {
   194         if ( !MmMtpDpUtility::IsVideoL( aNewFileName , iFramework ) )
   241             iMmMtpDpMetadataMpxAccess->RenameObjectL( oldFileName,
   195             {
   242                 aNewFileName,
   196             iMmMtpDpMetadataMpxAccess->RenameObjectL( aOldFileName, aNewFileName, formatCode );
   243                 category );
   197             }
   244             }
   198         else
   245             break;
   199             {
   246         case EMPXVideo:
   200             iMmMtpDpMetadataVideoAccess->RenameRecordL( aOldFileName, aNewFileName );
   247             iMmMtpDpMetadataVideoAccess->RenameRecordL( oldFileName, aNewFileName );
   201             }
   248             break;
   202         }
   249         default:
       
   250             break;
       
   251         }
       
   252 
   203 
   253 
   204     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::RenameObjectL" ) );
   254     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::RenameObjectL" ) );
   205     }
   255     }
   206 
   256 
   207 // ---------------------------------------------------------------------------
   257 // ---------------------------------------------------------------------------
   208 // CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL
   258 // CMmMtpDpMetadataAccessWrapper::DeleteObjectL
   209 // Deletes metadata information associated with the object
   259 // Deletes metadata information associated with the object
   210 // ---------------------------------------------------------------------------
   260 // ---------------------------------------------------------------------------
   211 //
   261 //
   212 void CMmMtpDpMetadataAccessWrapper::DeleteObjectL( const TDesC& aFullFileName,
   262 void CMmMtpDpMetadataAccessWrapper::DeleteObjectL( const CMTPObjectMetaData& aObject )
   213     const TUint aFormatCode )
   263     {
   214     {
   264     TPtrC fileName( aObject.DesC( CMTPObjectMetaData::ESuid ) );
   215     PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::DeleteObjectL" ) );
   265     PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::DeleteObjectL name = %S" ), &fileName );
   216 
   266 
   217     TMPXGeneralCategory category = Category( aFormatCode );
   267     TMPXGeneralCategory category = Category( aObject );
   218     
   268 
   219     // Have to do this.  File might not be in file system anymore, have to 
       
   220     // reply on ObjectManager
       
   221     if ( ( aFormatCode == EMTPFormatCodeMP4Container )
       
   222         || ( aFormatCode == EMTPFormatCode3GPContainer )
       
   223         || ( aFormatCode == EMTPFormatCodeASF ) )
       
   224         {
       
   225         if ( MmMtpDpUtility::IsVideoL( aFullFileName, iFramework ) )
       
   226             {
       
   227             category = EMPXVideo;
       
   228             }
       
   229         else
       
   230             {
       
   231             category = EMPXSong;
       
   232             }
       
   233         }
       
   234     
       
   235     switch ( category )
   269     switch ( category )
   236         {
   270         {
       
   271         case EMPXSong:
       
   272         case EMPXAbstractAlbum:
   237         case EMPXPlaylist:
   273         case EMPXPlaylist:
   238         case EMPXSong:
   274             {
   239             {
   275             iMmMtpDpMetadataMpxAccess->DeleteObjectL( fileName, category );
   240             iMmMtpDpMetadataMpxAccess->DeleteObjectL( aFullFileName, category );
       
   241             }
   276             }
   242             break;
   277             break;
   243 
   278 
   244         case EMPXVideo:
   279         case EMPXVideo:
   245             {
   280             {
   246             iMmMtpDpMetadataVideoAccess->DeleteRecordL( aFullFileName );
   281             iMmMtpDpMetadataVideoAccess->DeleteRecordL( fileName );
   247             }
   282             }
   248             break;
   283             break;
   249 
   284 
   250         default:
   285         default:
   251             PRINT( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::DeleteObjectL default" ) );
   286             PRINT( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::DeleteObjectL default" ) );
   267     iMmMtpDpMetadataVideoAccess->SetStorageRootL( aStorageRoot );
   302     iMmMtpDpMetadataVideoAccess->SetStorageRootL( aStorageRoot );
   268     iMmMtpDpMetadataMpxAccess->SetStorageRootL( aStorageRoot );
   303     iMmMtpDpMetadataMpxAccess->SetStorageRootL( aStorageRoot );
   269 
   304 
   270     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetStorageRootL" ) );
   305     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetStorageRootL" ) );
   271     }
   306     }
       
   307 
   272 // -----------------------------------------------------------------------------
   308 // -----------------------------------------------------------------------------
   273 // CMmMtpDpMetadataMpxAccess::SetImageObjPropL
   309 // CMmMtpDpMetadataMpxAccess::SetImageObjPropL
   274 // set image specific properties specific to videos
   310 // set image specific properties specific to videos
   275 // -----------------------------------------------------------------------------
   311 // -----------------------------------------------------------------------------
   276 //
   312 //
   277 void CMmMtpDpMetadataAccessWrapper::SetImageObjPropL( const TDesC& aFullFileName,
   313 void CMmMtpDpMetadataAccessWrapper::SetImageObjPropL( const CMTPObjectMetaData& aObject,
   278     const TUint32 aWidth,
   314     const TUint32 aWidth,
   279     const TUint32 aHeight )
   315     const TUint32 aHeight )
   280     {
   316     {
   281     if ( MmMtpDpUtility::IsVideoL( aFullFileName, iFramework ) )
   317     TMPXGeneralCategory category = Category( aObject );
   282         {
   318     if ( category == EMPXVideo )
   283         iMmMtpDpMetadataVideoAccess->SetStorageRootL( aFullFileName );
   319         {
   284         iMmMtpDpMetadataVideoAccess->SetImageObjPropL( aFullFileName, aWidth, aHeight );
   320         TPtrC fullFileName( aObject.DesC( CMTPObjectMetaData::ESuid ) );
       
   321         iMmMtpDpMetadataVideoAccess->SetStorageRootL( fullFileName );
       
   322         iMmMtpDpMetadataVideoAccess->SetImageObjPropL( fullFileName,
       
   323             aWidth,
       
   324             aHeight );
   285         }
   325         }
   286     }
   326     }
   287 
   327 
   288 // -----------------------------------------------------------------------------
   328 // -----------------------------------------------------------------------------
   289 // CMmMtpDpMetadataMpxAccess::GetImageObjPropL
   329 // CMmMtpDpMetadataMpxAccess::GetImageObjPropL
   290 // get image specific properties specific to videos
   330 // get image specific properties specific to videos
   291 // -----------------------------------------------------------------------------
   331 // -----------------------------------------------------------------------------
   292 //
   332 //
   293 void CMmMtpDpMetadataAccessWrapper::GetImageObjPropL( const TDesC& aFullFileName,
   333 void CMmMtpDpMetadataAccessWrapper::GetImageObjPropL( const CMTPObjectMetaData& aObject,
   294     TUint32& aWidth,
   334     TUint32& aWidth,
   295     TUint32& aHeight )
   335     TUint32& aHeight )
   296     {
   336     {
   297     if ( MmMtpDpUtility::IsVideoL( aFullFileName, iFramework ) )
   337     TMPXGeneralCategory category = Category( aObject );
   298         {
   338     if ( category == EMPXVideo )
   299         iMmMtpDpMetadataVideoAccess->SetStorageRootL( aFullFileName );
   339         {
   300         iMmMtpDpMetadataVideoAccess->GetImageObjPropL( aFullFileName, aWidth, aHeight );
   340         TPtrC fullFileName( aObject.DesC( CMTPObjectMetaData::ESuid ) );
   301         }
   341         iMmMtpDpMetadataVideoAccess->SetStorageRootL( fullFileName );
   302     }
   342         iMmMtpDpMetadataVideoAccess->GetImageObjPropL( fullFileName, aWidth, aHeight );
   303 // ----------------------------------------------------------------------------- 
   343         }
       
   344     }
       
   345 
       
   346 // -----------------------------------------------------------------------------
   304 // CMmMtpDpMetadataAccessWrapper::OpenSessionL
   347 // CMmMtpDpMetadataAccessWrapper::OpenSessionL
   305 // Called when the MTP session is initialised
   348 // Called when the MTP session is initialised
   306 // -----------------------------------------------------------------------------
   349 // -----------------------------------------------------------------------------
   307 //
   350 //
   308 void CMmMtpDpMetadataAccessWrapper::OpenSessionL()
   351 void CMmMtpDpMetadataAccessWrapper::OpenSessionL()
   332 // ---------------------------------------------------------------------------
   375 // ---------------------------------------------------------------------------
   333 // CMmMtpDpMetadataAccessWrapper::Category
   376 // CMmMtpDpMetadataAccessWrapper::Category
   334 // Get category according format code
   377 // Get category according format code
   335 // ---------------------------------------------------------------------------
   378 // ---------------------------------------------------------------------------
   336 //
   379 //
   337 TMPXGeneralCategory CMmMtpDpMetadataAccessWrapper::Category( const TUint aFormatCode )
   380 TMPXGeneralCategory CMmMtpDpMetadataAccessWrapper::Category( const CMTPObjectMetaData& aObject )
   338     {
   381     {
   339     TMPXGeneralCategory category = EMPXNoCategory;
   382     TMPXGeneralCategory category = EMPXNoCategory;
   340     switch ( aFormatCode )
   383     TUint formatCode = aObject.Uint( CMTPObjectMetaData::EFormatCode );
   341         {
   384     switch ( formatCode )
       
   385         {
       
   386         case EMTPFormatCodeASF:
       
   387         case EMTPFormatCodeMP4Container:
       
   388         case EMTPFormatCode3GPContainer:
       
   389             {
       
   390             TUint aSubFormatCode = aObject.Uint( CMTPObjectMetaData::EFormatSubCode );
       
   391             if ( aSubFormatCode == EMTPSubFormatCodeUnknown )
       
   392                 {
       
   393                 category = ContainerCategory( aObject.DesC( CMTPObjectMetaData::ESuid ) );
       
   394                 if ( category == EMPXSong )
       
   395                     aSubFormatCode = EMTPSubFormatCodeAudio;
       
   396                 else if ( category == EMPXVideo )
       
   397                     aSubFormatCode = EMTPSubFormatCodeVideo;
       
   398                 else
       
   399                     aSubFormatCode = EMTPSubFormatCodeUndefine;
       
   400                 const_cast<CMTPObjectMetaData&>(aObject).SetUint( CMTPObjectMetaData::EFormatSubCode, aSubFormatCode );
       
   401                 // If object doesn't exist, do nothing
       
   402                 TRAP_IGNORE( iFramework.ObjectMgr().ModifyObjectL( aObject ) );
       
   403                 }
       
   404             else if ( aSubFormatCode == EMTPSubFormatCodeAudio )
       
   405                 category = EMPXSong;
       
   406             else if ( aSubFormatCode == EMTPSubFormatCodeVideo )
       
   407                 category = EMPXVideo;
       
   408             else if( aSubFormatCode == EMTPSubFormatCodeUndefine )
       
   409                 category = EMPXOther;
       
   410             }
       
   411             break;
       
   412 
   342         case EMTPFormatCodeMP3:
   413         case EMTPFormatCodeMP3:
   343         case EMTPFormatCodeWAV:
   414         case EMTPFormatCodeWAV:
   344         case EMTPFormatCodeWMA:
   415         case EMTPFormatCodeWMA:
   345         case EMTPFormatCodeAAC:
   416         case EMTPFormatCodeAAC:
   346         case EMTPFormatCodeASF:
       
   347         case EMTPFormatCodeMP4Container:
       
   348         case EMTPFormatCode3GPContainer:
       
   349             {
   417             {
   350             category = EMPXSong;
   418             category = EMPXSong;
   351             }
   419             }
   352             break;
   420             break;
   353 
   421 
       
   422         case EMTPFormatCodeM3UPlaylist:
   354         case EMTPFormatCodeAbstractAudioVideoPlaylist:
   423         case EMTPFormatCodeAbstractAudioVideoPlaylist:
   355             {
   424             {
   356             category = EMPXPlaylist;
   425             category = EMPXPlaylist;
   357             }
   426             }
   358             break;
   427             break;
   359 
   428 
       
   429         case EMTPFormatCodeAbstractAudioAlbum:
       
   430             {
       
   431             category = EMPXAbstractAlbum;
       
   432             }
       
   433             break;
       
   434 
   360         case EMTPFormatCodeWMV:
   435         case EMTPFormatCodeWMV:
   361             {
   436             {
   362             category = EMPXVideo;
   437             category = EMPXVideo;
   363             }
   438             }
   364             break;
   439             break;
   365 
   440 
   366         default:
   441         default:
   367             break;
   442             break;
   368         }
   443         }
       
   444     PRINT1( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::Category category = %d" ), category );
   369     return category;
   445     return category;
   370     }
   446     }
   371 
   447 
   372 // ---------------------------------------------------------------------------
   448 TMPXGeneralCategory CMmMtpDpMetadataAccessWrapper::ContainerCategory( const TDesC& aFullFileName )
   373 // CMmMtpDpMetadataAccessWrapper::GetAllPlaylistL
   449     {
   374 // 
   450     PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::ContainerCategory aFullFileName = %S" ), &aFullFileName );
   375 // ---------------------------------------------------------------------------
   451 
   376 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetAllPlaylistL( const TDesC& aStoreRoot, CMPXMediaArray** aPlaylists )
   452     TMPXGeneralCategory category = EMPXNoCategory;
   377     {
   453     TParsePtrC pathParser( aFullFileName );
   378     iMmMtpDpMetadataMpxAccess->GetAllPlaylistL( aStoreRoot, aPlaylists );
   454     TPtrC ext( pathParser.Ext() );
       
   455 
       
   456     if ( ext.Length() <= 0 )
       
   457         category = EMPXOther;
       
   458 
       
   459     if ( ext.CompareF( KTxtExtensionMP4 ) == 0
       
   460         || ext.CompareF( KTxtExtension3GP ) == 0
       
   461         || ext.CompareF( KTxtExtension3G2 ) == 0
       
   462         || ext.CompareF( KTxtExtensionODF ) == 0
       
   463         || ext.CompareF( KTxtExtensionASF ) == 0 )
       
   464         {
       
   465         HBufC8* mimetype = MmMtpDpUtility::ContainerMimeType( aFullFileName );
       
   466         if ( mimetype != NULL )
       
   467             {
       
   468             TMmMtpSubFormatCode subFormatCode = MmMtpDpUtility::SubFormatCodeFromMime( *mimetype );
       
   469 
       
   470             if ( subFormatCode == EMTPSubFormatCodeVideo )
       
   471                 category = EMPXVideo;
       
   472             else if( subFormatCode == EMTPSubFormatCodeAudio )
       
   473                 category = EMPXSong;
       
   474             else
       
   475                 category = EMPXOther;
       
   476             }
       
   477         }
       
   478     else if ( ext.CompareF( KTxtExtensionO4V ) == 0 )
       
   479         category = EMPXVideo;
       
   480     else
       
   481         category = EMPXOther;
       
   482 
       
   483     PRINT1( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::ContainerCategory, category = %d" ), category );
       
   484     return category;
       
   485     }
       
   486 
       
   487 // ---------------------------------------------------------------------------
       
   488 // CMmMtpDpMetadataAccessWrapper::GetAllAbstractMediaL
       
   489 //
       
   490 // ---------------------------------------------------------------------------
       
   491 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetAllAbstractMediaL( const TDesC& aStoreRoot, CMPXMediaArray** aAbstractMedias, TMPXGeneralCategory aCategory )
       
   492     {
       
   493     iMmMtpDpMetadataMpxAccess->GetAllAbstractMediaL( aStoreRoot, aAbstractMedias, aCategory );
   379     }
   494     }
   380 
   495 
   381 // ---------------------------------------------------------------------------
   496 // ---------------------------------------------------------------------------
   382 // CMmMtpDpMetadataAccessWrapper::GetAllReferenceL
   497 // CMmMtpDpMetadataAccessWrapper::GetAllReferenceL
   383 // 
   498 //
   384 // ---------------------------------------------------------------------------
   499 // ---------------------------------------------------------------------------
   385 //s
   500 //
   386 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetAllReferenceL( CMPXMedia* aPlaylist, CDesCArray& aReferences )
   501 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetAllReferenceL( CMPXMedia* aAbstractMedia, CDesCArray& aReferences )
   387     {
   502     {
   388     iMmMtpDpMetadataMpxAccess->GetAllReferenceL( aPlaylist, aReferences );
   503     iMmMtpDpMetadataMpxAccess->GetAllReferenceL( aAbstractMedia, aReferences );
   389     }
   504     }
   390 
   505 
   391 // ---------------------------------------------------------------------------
   506 // ---------------------------------------------------------------------------
   392 // CMmMtpDpMetadataAccessWrapper::GetPlaylistNameL
   507 // CMmMtpDpMetadataAccessWrapper::GetAbstractMediaNameL
   393 // 
   508 //
   394 // ---------------------------------------------------------------------------
   509 // ---------------------------------------------------------------------------
   395 //
   510 //
   396 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetPlaylistNameL( CMPXMedia* aPlaylist, TDes& aPlaylistName )
   511 EXPORT_C HBufC* CMmMtpDpMetadataAccessWrapper::GetAbstractMediaNameL( CMPXMedia* aAbstractMedia, TMPXGeneralCategory aCategory )
   397     {
   512     {
   398     iMmMtpDpMetadataMpxAccess->GetPlaylistNameL( aPlaylist, aPlaylistName );
   513     return iMmMtpDpMetadataMpxAccess->GetAbstractMediaNameL( aAbstractMedia, aCategory );
   399     }
   514     }
   400 
   515 
   401 // ----------------------------------------------------------------------------- 
   516 // -----------------------------------------------------------------------------
   402 // CMmMtpDpMetadataAccessWrapper::AddObjectL
   517 // CMmMtpDpMetadataAccessWrapper::AddObjectL
   403 // Add object (music, video and playlist) info to DB
   518 // Add object (music, video, playlist and abstract media) info to DB
   404 // -----------------------------------------------------------------------------
   519 // -----------------------------------------------------------------------------
   405 //
   520 //
   406 void CMmMtpDpMetadataAccessWrapper::AddObjectL( const TDesC& aFullFileName, TBool aIsVideo /*= EFalse */ )
   521 void CMmMtpDpMetadataAccessWrapper::AddObjectL( const CMTPObjectMetaData& aObject )
   407     {
   522     {
   408     PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL aFullFileName = %S" ), &aFullFileName );
   523     PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL" ) );
   409 
   524     TMPXGeneralCategory category = Category( aObject );
   410     if ( aFullFileName.Length() <= 0)
   525 
   411         {
   526     TPtrC fullFileName( aObject.DesC( CMTPObjectMetaData::ESuid ) );
   412         User::Leave( KErrArgument );
   527     if ( category == EMPXVideo )
   413         }
       
   414     if ( aIsVideo )
       
   415         {
   528         {
   416         PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL Addvideo" ) );
   529         PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL Addvideo" ) );
   417         iMmMtpDpMetadataVideoAccess->AddVideoL( aFullFileName );
   530         iMmMtpDpMetadataVideoAccess->AddVideoL( fullFileName );
   418         }
   531         }
   419     else
   532     else if ( category == EMPXPlaylist || category == EMPXAbstractAlbum )
   420         {
   533         {
   421         if ( MmMtpDpUtility::IsVideoL( aFullFileName, iFramework ) )
   534         PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL AddPlaylist" ) );
   422             {
   535         iMmMtpDpMetadataMpxAccess->AddAbstractMediaL( fullFileName,
   423             PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL Addvideo" ) );
   536             category );
   424             iMmMtpDpMetadataVideoAccess->AddVideoL( aFullFileName );
   537         }
   425             }
   538     else if ( category == EMPXSong )
   426         else
   539         {
   427             {
   540         PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL AddSong" ) );
   428             TMTPFormatCode formatCode = MmMtpDpUtility::FormatFromFilename( aFullFileName );
   541         iMmMtpDpMetadataMpxAccess->AddSongL( fullFileName );
   429 
       
   430             if ( formatCode == EMTPFormatCodeM3UPlaylist
       
   431                 || formatCode == EMTPFormatCodeMPLPlaylist
       
   432                 || formatCode == EMTPFormatCodeAbstractAudioVideoPlaylist
       
   433                 || formatCode == EMTPFormatCodeAbstractAudioPlaylist
       
   434                 || formatCode == EMTPFormatCodeAbstractVideoPlaylist
       
   435                 || formatCode == EMTPFormatCodeASXPlaylist
       
   436                 || formatCode == EMTPFormatCodePLSPlaylist )
       
   437                 {
       
   438                 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL AddPlaylist" ) );
       
   439                 iMmMtpDpMetadataMpxAccess->AddPlaylistL( aFullFileName );
       
   440                 }
       
   441             else
       
   442                 {
       
   443                 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL AddSong" ) );
       
   444                 iMmMtpDpMetadataMpxAccess->AddSongL( aFullFileName );
       
   445                 }
       
   446             }
       
   447         }
   542         }
   448 
   543 
   449     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::AddObjectL" ) );
   544     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::AddObjectL" ) );
   450     }
   545     }
   451 
   546 
   452 // ---------------------------------------------------------------------------
   547 // ---------------------------------------------------------------------------
   453 // CMmMtpDpMetadataAccessWrapper::GetModifiedContentL
   548 // CMmMtpDpMetadataAccessWrapper::GetModifiedContentL
   454 // Get Modified content
   549 // Get Modified content
   455 // ---------------------------------------------------------------------------
   550 // ---------------------------------------------------------------------------
   456 //
   551 //
   457 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetModifiedContentL( const TDesC& aStorageRoot, 
   552 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetModifiedContentL( const TDesC& aStorageRoot,
   458     TInt& arrayCount, 
   553     TInt& arrayCount,
   459     CDesCArray& aModifiedcontent )
   554     CDesCArray& aModifiedcontent )
   460     {
   555     {
   461     iMmMtpDpMetadataMpxAccess->SetStorageRootL( aStorageRoot );
   556     iMmMtpDpMetadataMpxAccess->SetStorageRootL( aStorageRoot );
   462     iMmMtpDpMetadataMpxAccess->GetModifiedContentL( arrayCount, aModifiedcontent );
   557     iMmMtpDpMetadataMpxAccess->GetModifiedContentL( arrayCount, aModifiedcontent );
   463     }
   558     }
   477     TParsePtrC parse( aSuid );
   572     TParsePtrC parse( aSuid );
   478     iMmMtpDpMetadataMpxAccess->SetStorageRootL( parse.Drive() );
   573     iMmMtpDpMetadataMpxAccess->SetStorageRootL( parse.Drive() );
   479     return iMmMtpDpMetadataMpxAccess->IsExistL( aSuid );
   574     return iMmMtpDpMetadataMpxAccess->IsExistL( aSuid );
   480     }
   575     }
   481 
   576 
   482 // ----------------------------------------------------------------------------- 
   577 // -----------------------------------------------------------------------------
   483 // CMmMtpDpMetadataAccessWrapper::AddDummyFile
   578 // CMmMtpDpMetadataAccessWrapper::AddDummyFile
   484 // Add one dummy file to dummy files array
   579 // Add one dummy file to dummy files array
   485 // -----------------------------------------------------------------------------
   580 // -----------------------------------------------------------------------------
   486 //
   581 //
   487 EXPORT_C void CMmMtpDpMetadataAccessWrapper::AddDummyFileL( const TDesC& aDummyFileName )
   582 EXPORT_C void CMmMtpDpMetadataAccessWrapper::AddDummyFileL( const TDesC& aDummyFileName )
   488     {
   583     {
   489     PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::AddDummyFile aDummyFileName(%S)" ), &aDummyFileName );
   584     PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::AddDummyFile aDummyFileName(%S)" ), &aDummyFileName );
   490     iPlaylistArray->AppendL( aDummyFileName );
   585     iAbstractMediaArray->AppendL( aDummyFileName );
   491     }
   586     }
   492 
   587 
   493 // ----------------------------------------------------------------------------- 
   588 // -----------------------------------------------------------------------------
   494 // CMmMtpDpMetadataAccessWrapper::DeleteDummyFile
   589 // CMmMtpDpMetadataAccessWrapper::DeleteDummyFile
   495 // Delete one dummy file from dummy files array
   590 // Delete one dummy file from dummy files array
   496 // -----------------------------------------------------------------------------
   591 // -----------------------------------------------------------------------------
   497 //
   592 //
   498 EXPORT_C void CMmMtpDpMetadataAccessWrapper::DeleteDummyFile( const TDesC& aDummyFileName )
   593 EXPORT_C void CMmMtpDpMetadataAccessWrapper::DeleteDummyFile( const TDesC& aDummyFileName )
   499     {
   594     {
   500     PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::DeleteDummyFile aDummyFileName(%S)" ), &aDummyFileName );
   595     PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::DeleteDummyFile aDummyFileName(%S)" ), &aDummyFileName );
   501     TInt pos = 0;
   596     TInt pos = 0;
   502     if ( iPlaylistArray->Count() > 0 )
   597     if ( iAbstractMediaArray->Count() > 0 )
   503         {
   598         {
   504         if ( 0 == iPlaylistArray->Find( aDummyFileName, pos ) )
   599         if ( 0 == iAbstractMediaArray->Find( aDummyFileName, pos ) )
   505             {
   600             {
   506             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::DeleteDummyFile pos = %d" ), pos );
   601             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::DeleteDummyFile pos = %d" ), pos );
   507             iPlaylistArray->Delete( pos );
   602             iAbstractMediaArray->Delete( pos );
   508             }
   603             }
   509         }
   604         }
   510     }
   605     }
   511 
   606 
   512 // -----------------------------------------------------------------------------
   607 // -----------------------------------------------------------------------------
   520 
   615 
   521     if ( MmMtpDpUtility::FormatFromFilename( aPlaylistName ) ==
   616     if ( MmMtpDpUtility::FormatFromFilename( aPlaylistName ) ==
   522         EMTPFormatCodeAbstractAudioVideoPlaylist )
   617         EMTPFormatCodeAbstractAudioVideoPlaylist )
   523         {
   618         {
   524         RFile newfile;
   619         RFile newfile;
   525         TInt err = newfile.Replace( iFramework.Fs(), aPlaylistName, EFileWrite );
   620         TInt err = newfile.Replace( iFs, aPlaylistName, EFileWrite );
   526 
   621 
   527         if ( err != KErrNone )
   622         if ( err != KErrNone )
   528             {
   623             {
   529             newfile.Close();
   624             newfile.Close();
   530             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile err =  %d" ), err );
   625             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile err =  %d" ), err );
   531             }
   626             }
   532         else // File created OK
   627         else // File created OK
   533             {
   628             {
   534             err = newfile.Flush();
   629             err = newfile.Flush();
   535             newfile.Close();
   630             newfile.Close();
   536             err = iFramework.Fs().SetAtt( aPlaylistName, KEntryAttSystem | KEntryAttHidden,
   631             err = iFs.SetAtt( aPlaylistName, KEntryAttSystem | KEntryAttHidden,
   537                 KEntryAttReadOnly | KEntryAttNormal );
   632                 KEntryAttReadOnly | KEntryAttNormal );
   538             if ( err != KErrNone )
   633             if ( err != KErrNone )
   539                 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile Dummy Playlist file created. err = %d" ), err );
   634                 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile Dummy Playlist file created. err = %d" ), err );
   540             }
   635             }
   541         }
   636         }
   542     }
   637     }
   543 
   638 
   544 // -----------------------------------------------------------------------------
   639 // -----------------------------------------------------------------------------
   545 // CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles
   640 // CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles
   546 // Remove all dummy file of which format is "pla", and leave the "m3u"
   641 // Remove all dummy file of which format is "pla" and "alb", and leave the "m3u"
   547 // -----------------------------------------------------------------------------
   642 // -----------------------------------------------------------------------------
   548 //
   643 //
   549 void CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles()
   644 void CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles()
   550     {
   645     {
   551     PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles" ) );
   646     PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles" ) );
   552     
   647 
   553     TInt count = iPlaylistArray->Count();
   648     TInt count = iAbstractMediaArray->Count();
       
   649     PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles, count = %d" ), count );
   554     // Check if playlist file is a dummy file or an imported file
   650     // Check if playlist file is a dummy file or an imported file
   555     for ( TInt i = 0; i < count; i++ )
   651     for ( TInt i = 0; i < count; i++ )
   556         {
   652         {
   557         if ( MmMtpDpUtility::FormatFromFilename( (*iPlaylistArray)[i] ) !=
   653         TPtrC fileName( (*iAbstractMediaArray)[i] );
   558             EMTPFormatCodeM3UPlaylist )
   654         PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles, fileName = %S" ), &fileName );
   559             {
   655         
   560             // delete the virtual playlist
   656         TMTPFormatCode format = MmMtpDpUtility::FormatFromFilename( fileName );
   561             // iFramework has release don't use iFramework.FS()
   657         PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles, format = 0x%x" ), format );
   562             TInt err = iRfs.Delete( (*iPlaylistArray)[i] );
   658         if ( format == EMTPFormatCodeAbstractAudioAlbum )
       
   659             {
       
   660             // delete the abstract album if its size is zero
       
   661             TEntry entry;
       
   662             TInt err = iFs.Entry( fileName, entry );
       
   663             if ( err == KErrNone && entry.iSize == 0 )
       
   664                 {
       
   665                 TRAP( err, iMmMtpDpMetadataMpxAccess->DeleteObjectL( fileName, EMPXAbstractAlbum ) );
       
   666                 if( err == KErrNone )
       
   667                     {
       
   668                     err = iFs.Delete( fileName );
       
   669                     }
       
   670                 }
       
   671             PRINT3( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile filename = %S, err %d, entry.iSize = %d" ),
       
   672                 &fileName, err, entry.iSize );
       
   673             }
       
   674         else if ( format != EMTPFormatCodeM3UPlaylist )
       
   675             {
       
   676             TInt err = iFs.Delete( fileName );
   563 
   677 
   564             PRINT2( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile filename = %S, err %d" ),
   678             PRINT2( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile filename = %S, err %d" ),
   565                 &( (*iPlaylistArray)[i] ),
   679                 &fileName,
   566                 err );
   680                 err );
   567             }
   681             }
   568         else
   682         else
   569             {
   683             {
   570             // leave the Imported playlist in the file system
   684             // leave the Imported playlist in the file system
   571             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile, Don't delete m3u file [%S]" ), &( (*iPlaylistArray)[i] ) );
   685             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile, Don't delete m3u file [%S]" ), &fileName );
   572             }
   686             }
   573         }
   687         }
   574     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles" ) );
   688     PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles" ) );
   575     }
   689     }
   576 
   690 
   577 // ---------------------------------------------------------------------------
   691 // ---------------------------------------------------------------------------
   578 // CMmMtpDpMetadataAccessWrapper::UpdateMusicCollectionL
   692 // CMmMtpDpMetadataAccessWrapper::UpdateMusicCollectionL
   579 // Update Music collection
   693 // Update Music collection
   580 // ---------------------------------------------------------------------------
   694 // ---------------------------------------------------------------------------
   581 //
   695 //
   582 EXPORT_C void CMmMtpDpMetadataAccessWrapper::UpdateMusicCollectionL() 
   696 EXPORT_C void CMmMtpDpMetadataAccessWrapper::UpdateMusicCollectionL()
   583     {
   697     {
   584     iMmMtpDpMetadataMpxAccess->UpdateMusicCollectionL( );
   698     iMmMtpDpMetadataMpxAccess->UpdateMusicCollectionL( );
   585     }
   699     }
   586 
   700 
   587 // end of file
   701 // end of file