mmappcomponents/mmmtpdataprovider/src/cmmmtpdpmetadatampxaccess.cpp
branchRCL_3
changeset 14 05b0d2323768
parent 9 bee149131e4b
child 17 780c925249c1
equal deleted inserted replaced
9:bee149131e4b 14:05b0d2323768
    42 
    42 
    43 #include "cmmmtpdpmetadatampxaccess.h"
    43 #include "cmmmtpdpmetadatampxaccess.h"
    44 #include "mmmtpdplogger.h"
    44 #include "mmmtpdplogger.h"
    45 #include "mmmtpdputility.h"
    45 #include "mmmtpdputility.h"
    46 #include "tmmmtpdppanic.h"
    46 #include "tmmmtpdppanic.h"
       
    47 #include "tobjectdescription.h"
    47 
    48 
    48 static const TInt KMtpInvalidSongID = 0x1FFFFFFF;
    49 static const TInt KMtpInvalidSongID = 0x1FFFFFFF;
    49 static const TInt KMtpChannelMono = 1;
    50 static const TInt KMtpChannelMono = 1;
    50 static const TInt KMtpChannelStereo = 2;
    51 static const TInt KMtpChannelStereo = 2;
    51 static const TInt KMtpDateTimeStringLength = 15;
    52 
    52 static const TInt KMtpMaxStringLength = 255;
    53 
    53 static const TInt KMtpMaxDescriptionLength = 0x200;
       
    54 
       
    55 _LIT( KMtpDateTimeFormat, "%F%Y%M%DT%H%T%S" );
       
    56 _LIT( KMtpDateTimeConnector, "T" );
    54 _LIT( KMtpDateTimeConnector, "T" );
    57 _LIT( KEmptyText, "" );
    55 _LIT( KEmptyText, "" );
    58 
    56 
    59 #if defined(_DEBUG) || defined(MMMTPDP_PERFLOG)
    57 #if defined(_DEBUG) || defined(MMMTPDP_PERFLOG)
    60 _LIT( KMpxCollectionNewL, "MpxCollectionNewL" );
    58 _LIT( KMpxCollectionNewL, "MpxCollectionNewL" );
   204         case EMTPObjectPropCodeDateModified:
   202         case EMTPObjectPropCodeDateModified:
   205         case EMTPObjectPropCodeDateAdded:
   203         case EMTPObjectPropCodeDateAdded:
   206         case EMTPObjectPropCodeDateCreated:
   204         case EMTPObjectPropCodeDateCreated:
   207             {
   205             {
   208             TTime time( *media.Value<TInt64> ( attrib ) );
   206             TTime time( *media.Value<TInt64> ( attrib ) );
   209             TBuf<KMtpDateTimeStringLength> timeStr;
   207             TBuf<KMtpMaxDateTimeStringLength> timeStr;
   210             time.FormatL( timeStr, KMtpDateTimeFormat );
   208             time.FormatL( timeStr, KMtpDateTimeFormat );
   211 
   209 
   212             if ( EMTPTypeString == aNewData.Type() )
   210             if ( EMTPTypeString == aNewData.Type() )
   213                 {
   211                 {
   214                 ( ( CMTPTypeString & ) aNewData ).SetL( timeStr );
   212                 ( ( CMTPTypeString & ) aNewData ).SetL( timeStr );
   256             break;
   254             break;
   257 
   255 
   258         case EMTPObjectPropCodeOriginalReleaseDate:
   256         case EMTPObjectPropCodeOriginalReleaseDate:
   259             {
   257             {
   260             // Compose DateTime string in format YYYYMMDDTHHMMSS
   258             // Compose DateTime string in format YYYYMMDDTHHMMSS
   261             TBuf<KMtpDateTimeStringLength> dateTime;
   259             TBuf<KMtpMaxDateTimeStringLength> dateTime;
   262             dateTime.Zero();
   260             dateTime.Zero();
   263 
   261 
   264             // NOTE: Handled specially, shouldn't leave like other property, following S60
   262             // NOTE: Handled specially, shouldn't leave like other property, following S60
   265             if ( !isSupported )
   263             if ( !isSupported )
   266                 {
   264                 {
   429     CleanupStack::PushL( searchMedia ); // + searchMeida
   427     CleanupStack::PushL( searchMedia ); // + searchMeida
   430 
   428 
   431     searchMedia->SetTObjectValueL( KMPXMediaGeneralType, EMPXGroup );
   429     searchMedia->SetTObjectValueL( KMPXMediaGeneralType, EMPXGroup );
   432     searchMedia->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong );
   430     searchMedia->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong );
   433     searchMedia->SetTObjectValueL<TBool>( aWMPMediaID, aFlag );
   431     searchMedia->SetTObjectValueL<TBool>( aWMPMediaID, aFlag );
   434 
       
   435     searchMedia->SetTextValueL( KMPXMediaGeneralDrive, iStoreRoot );
   432     searchMedia->SetTextValueL( KMPXMediaGeneralDrive, iStoreRoot );
   436 
   433 
   437     RArray<TMPXAttribute> songAttributes;
   434     RArray<TMPXAttribute> songAttributes;
   438     CleanupClosePushL( songAttributes ); // + songAttributes
   435     CleanupClosePushL( songAttributes ); // + songAttributes
   439     songAttributes.AppendL( KMPXMediaGeneralUri );
   436     songAttributes.AppendL( KMPXMediaGeneralUri );
   440 
   437 
   441     PRINT( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::FindWMPMediaLC searchMedia setup with no problems" ) );
   438     PRINT( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::FindWMPMediaLC searchMedia setup with no problems" ) );
   442 
   439 
   443     CMPXMedia* foundMedia = CollectionHelperL()->FindAllL(
   440     CMPXMedia* foundMedia = CollectionHelperL()->FindAllL( *searchMedia,
   444         *searchMedia,
       
   445         songAttributes.Array() );
   441         songAttributes.Array() );
   446     PRINT( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::FindWMPMediaLC foundMedia assigned from FindAllL" ) );
   442     PRINT( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::FindWMPMediaLC foundMedia assigned from FindAllL" ) );
   447 
   443 
   448     CleanupStack::PopAndDestroy( &songAttributes ); // - songAttributes
   444     CleanupStack::PopAndDestroy( &songAttributes ); // - songAttributes
   449     CleanupStack::PopAndDestroy( searchMedia ); // - searchMedia
   445     CleanupStack::PopAndDestroy( searchMedia ); // - searchMedia
   840         case EMTPObjectPropCodeOriginalReleaseDate:
   836         case EMTPObjectPropCodeOriginalReleaseDate:
   841             {
   837             {
   842             MMTPType::CopyL( aNewData, *textData );
   838             MMTPType::CopyL( aNewData, *textData );
   843 
   839 
   844             TBuf<KMtpMaxStringLength> data;
   840             TBuf<KMtpMaxStringLength> data;
   845             data.Copy( textData->StringChars().Left( KMtpDateTimeStringLength ) );
   841             data.Copy( textData->StringChars().Left( KMtpMaxDateTimeStringLength ) );
   846             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::SetMetadataValueL 0xDC99 date = %S" ),
   842             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::SetMetadataValueL 0xDC99 date = %S" ),
   847                 &data );
   843                 &data );
   848             if ( data.Length() < KMtpDateTimeStringLength )
   844             if ( data.Length() < KMtpMaxDateTimeStringLength )
   849                 {
   845                 {
   850                 PRINT( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::SetMetadataValueL 0xDC99 date string is too short" ) );
   846                 PRINT( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::SetMetadataValueL 0xDC99 date string is too short" ) );
   851                 break;
   847                 break;
   852                 }
   848                 }
   853 
   849 
   925             TUint length = desData->NumElements();
   921             TUint length = desData->NumElements();
   926             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::SetMetadataValueL length = %d" ),
   922             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::SetMetadataValueL length = %d" ),
   927                 length );
   923                 length );
   928             if ( length != 0 )
   924             if ( length != 0 )
   929                 {
   925                 {
   930                 TBuf<KMtpMaxDescriptionLength> text;
   926                 length = ( length < KMTPMaxDescriptionLen ) ? length : KMTPMaxDescriptionLen;
   931                 text.Zero();
   927                 HBufC* text = HBufC::NewLC( length );    // + text
       
   928                 TPtr ptr = text->Des();
       
   929 
   932                 for ( TUint i = 0; i < length; i++ )
   930                 for ( TUint i = 0; i < length; i++ )
   933                     text.Append( desData->ElementUint( i ) );
   931                     ptr.Append( desData->ElementUint( i ) );
   934                 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::SetMetadataValueL text = %S" ),
   932                 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::SetMetadataValueL text = %S" ),
   935                     &text );
   933                     text );
   936                 aMediaProp.SetTextValueL( KMPXMediaGeneralComment, text );
   934                 aMediaProp.SetTextValueL( KMPXMediaGeneralComment, *text );
       
   935                 CleanupStack::PopAndDestroy( text );    // - text
   937                 }
   936                 }
   938             else
   937             else
   939                 {
   938                 {
   940                 aMediaProp.SetTextValueL( KMPXMediaGeneralComment, KEmptyText );
   939                 aMediaProp.SetTextValueL( KMPXMediaGeneralComment, KEmptyText );
   941                 }
   940                 }
   982     CleanupStack::PushL( searchMedia ); // + searchMedia
   981     CleanupStack::PushL( searchMedia ); // + searchMedia
   983 
   982 
   984     searchMedia->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem );
   983     searchMedia->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem );
   985     searchMedia->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong );
   984     searchMedia->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong );
   986     searchMedia->SetTextValueL( KMPXMediaGeneralUri, aFullFileName );
   985     searchMedia->SetTextValueL( KMPXMediaGeneralUri, aFullFileName );
       
   986     searchMedia->SetTextValueL( KMPXMediaGeneralDrive, iStoreRoot );
   987 
   987 
   988     RArray<TMPXAttribute> songAttributes;
   988     RArray<TMPXAttribute> songAttributes;
   989     CleanupClosePushL( songAttributes ); // + songAttributes
   989     CleanupClosePushL( songAttributes ); // + songAttributes
   990     songAttributes.AppendL( KMPXMediaGeneralUri );
   990     songAttributes.AppendL( KMPXMediaGeneralUri );
   991 
   991 
  1272 void CMmMtpDpMetadataMpxAccess::SetStorageRootL( const TDesC& aStorageRoot )
  1272 void CMmMtpDpMetadataMpxAccess::SetStorageRootL( const TDesC& aStorageRoot )
  1273     {
  1273     {
  1274     PRINT1( _L( "MM MTP => CMmMtpDpMetadataMpxAccess::SetStorageRoot aStoreRoot = %S" ), &aStorageRoot );
  1274     PRINT1( _L( "MM MTP => CMmMtpDpMetadataMpxAccess::SetStorageRoot aStoreRoot = %S" ), &aStorageRoot );
  1275 
  1275 
  1276     // get the drive number
  1276     // get the drive number
  1277     TParse pathParser;
  1277     TParsePtrC pathParser( aStorageRoot );
  1278     User::LeaveIfError( pathParser.Set( aStorageRoot, NULL, NULL ) );
       
  1279     TChar driveChar( pathParser.Drive()[0] );
  1278     TChar driveChar( pathParser.Drive()[0] );
  1280 
  1279 
  1281     TInt driveNumber;
  1280     TInt driveNumber;
  1282     User::LeaveIfError( RFs::CharToDrive( driveChar, driveNumber ) );
  1281     User::LeaveIfError( RFs::CharToDrive( driveChar, driveNumber ) );
  1283     PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::SetStorageRoot drive number = %d" ), driveNumber );
  1282     PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::SetStorageRoot drive number = %d" ), driveNumber );
  1636     CleanupStack::PushL( searchMedia ); // + searchMedia
  1635     CleanupStack::PushL( searchMedia ); // + searchMedia
  1637 
  1636 
  1638     searchMedia->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem );
  1637     searchMedia->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem );
  1639     searchMedia->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXPlaylist );
  1638     searchMedia->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXPlaylist );
  1640     searchMedia->SetTextValueL( KMPXMediaGeneralUri, aSuid );
  1639     searchMedia->SetTextValueL( KMPXMediaGeneralUri, aSuid );
       
  1640     searchMedia->SetTextValueL( KMPXMediaGeneralDrive, iStoreRoot );
  1641 
  1641 
  1642     RArray<TMPXAttribute> playlistAttributes;
  1642     RArray<TMPXAttribute> playlistAttributes;
  1643     CleanupClosePushL( playlistAttributes ); // + playlistAttributes
  1643     CleanupClosePushL( playlistAttributes ); // + playlistAttributes
  1644     playlistAttributes.AppendL( KMPXMediaGeneralId );
  1644     playlistAttributes.AppendL( KMPXMediaGeneralId );
  1645     playlistAttributes.AppendL( KMPXMediaGeneralTitle );
  1645     playlistAttributes.AppendL( KMPXMediaGeneralTitle );