diff -r 51035f0751c2 -r 4740b34b83ce mmappcomponents/mmmtpdataprovider/src/mmmtpdputility.cpp --- a/mmappcomponents/mmmtpdataprovider/src/mmmtpdputility.cpp Wed Apr 14 16:28:17 2010 +0300 +++ b/mmappcomponents/mmmtpdataprovider/src/mmmtpdputility.cpp Tue Apr 27 17:09:22 2010 +0300 @@ -100,7 +100,7 @@ #endif // __WINDOWS_MEDIA else if ( file.Ext().CompareF( KTxtExtensionODF ) == 0 ) { - HBufC8* mime = MmMtpDpUtility::ContainerMimeType( file.FullName() ); + HBufC8* mime = MmMtpDpUtility::OdfMimeTypeL( file.FullName() ); if ( mime != NULL ) { // 3GP @@ -409,54 +409,6 @@ } // ----------------------------------------------------------------------------- -// MetadataAccessWrapper::ContainerMimeType -// Get mime type from file -// ----------------------------------------------------------------------------- -// -HBufC8* MmMtpDpUtility::ContainerMimeType( const TDesC& aFullPath ) - { - PRINT( _L( "MM MTP => MmMtpDpUtility::ContainerMimeType" ) ); - - // parse the file path - TParsePtrC pathParser( aFullPath ); - - // get the extension of file - TPtrC ext( pathParser.Ext() ); - if ( ext.Length() <= 0 ) - { - PRINT( _L( "MM MTP <> MmMtpDpUtility::ContainerMimeType file ext len == 0" ) ); - return NULL; - } - - HBufC8* mimebuf = NULL; - TInt err = KErrNone; - - // MP4/3GP - if ( ext.CompareF( KTxtExtensionMP4 ) == 0 - || ext.CompareF( KTxtExtension3GP ) == 0 - || ext.CompareF( KTxtExtension3G2 ) == 0 ) - { - TRAP( err, mimebuf = Mp4MimeTypeL( aFullPath ) ); - PRINT1( _L("MM MTP <> MmMtpDpUtility::ContainerMimeType, Mp4MimeTypeL err = %d"), err ); - } - else if ( ext.CompareF( KTxtExtensionODF ) == 0 ) - { - TRAP( err, mimebuf = OdfMimeTypeL( aFullPath ) ); - PRINT1( _L("MM MTP <> MmMtpDpUtility::ContainerMimeType, OdfMimeTypeL err = %d"), err ); - } -#ifdef __WINDOWS_MEDIA - else if ( ext.CompareF( KTxtExtensionASF ) == 0 ) - { - TRAP( err, mimebuf = AsfMimeTypeL( aFullPath ) ); - PRINT1( _L("MM MTP <> MmMtpDpUtility::ContainerMimeType, AsfMimeTypeL err = %d"), err ); - } -#endif - - PRINT( _L( "MM MTP <= MmMtpDpUtility::ContainerMimeType" ) ); - return mimebuf; - } - -// ----------------------------------------------------------------------------- // MetadataAccessWrapper::Mp4MimeTypeL // Get mime type from mp4 file // ----------------------------------------------------------------------------- @@ -519,7 +471,7 @@ // is video file else if ( mp4err == MP4_OK ) { - if ( file.Ext().CompareF( KTxtExtension3GP ) == 0 + if ( file.Ext().CompareF( KTxtExtension3GP ) == 0 || file.Ext().CompareF( KTxtExtension3G2 ) == 0 ) { mimebuf = KMimeTypeVideo3gpp().Alloc(); @@ -562,44 +514,35 @@ PRINT( _L( "MM MTP => MmMtpDpUtility::OdfMimeTypeL" ) ); HBufC8* mimebuf = NULL; - TParsePtrC file( aFullPath ); + CContent* content = CContent::NewL( aFullPath ); + CleanupStack::PushL( content ); // + content - if ( file.Ext().CompareF( KTxtExtensionODF ) == 0 ) - { - CContent* content = CContent::NewL( aFullPath ); - CleanupStack::PushL( content ); // + content - - HBufC* buffer = HBufC::NewL( KMimeTypeMaxLength ); - CleanupStack::PushL( buffer ); // + buffer + HBufC* buffer = HBufC::NewL( KMimeTypeMaxLength ); + CleanupStack::PushL( buffer ); // + buffer - TPtr data = buffer->Des(); - TInt err = content->GetStringAttribute( EMimeType, data ); - - if ( err == KErrNone ) - { - mimebuf = HBufC8::New( buffer->Length() ); + TPtr data = buffer->Des(); + TInt err = content->GetStringAttribute( EMimeType, data ); - if (mimebuf == NULL) - { - User::LeaveIfError( KErrNotFound ); - } + if ( err == KErrNone ) + { + mimebuf = HBufC8::New( buffer->Length() ); - mimebuf->Des().Copy( *buffer ); + if ( mimebuf == NULL ) + { + User::LeaveIfError( KErrNotFound ); } - // leave if NULL - if ( mimebuf == NULL ) - { - User::Leave( KErrNotFound ); - } + mimebuf->Des().Copy( *buffer ); + } - CleanupStack::PopAndDestroy( buffer ); // - buffer - CleanupStack::PopAndDestroy( content ); // - content + // leave if NULL + if ( mimebuf == NULL ) + { + User::Leave( KErrNotFound ); } - else - { - User::Leave( KErrNotSupported ); - } + + CleanupStack::PopAndDestroy( buffer ); // - buffer + CleanupStack::PopAndDestroy( content ); // - content PRINT( _L( "MM MTP <= MmMtpDpUtility::OdfMimeTypeL" ) ); return mimebuf; @@ -617,62 +560,52 @@ HBufC8* mimebuf = NULL; #ifdef __WINDOWS_MEDIA - TParsePtrC file( aFullPath ); - - if ( file.Ext().CompareF( KTxtExtensionASF ) == 0 ) - { - CHXMetaDataUtility *hxUtility = CHXMetaDataUtility::NewL(); - CleanupStack::PushL( hxUtility ); - - hxUtility->OpenFileL( aFullPath ); - PRINT( _L( "MM MTP <> MmMtpDpUtility::AsfMimeTypeL OpenFileL" ) ); + CHXMetaDataUtility *hxUtility = CHXMetaDataUtility::NewL(); + CleanupStack::PushL( hxUtility ); - HXMetaDataKeys::EHXMetaDataId id; - TUint count = 0; - TBool isAudio = EFalse; - hxUtility->GetMetaDataCount( count ); - for ( TUint i = 0; i < count; i++ ) - { - HBufC* buf = NULL; - hxUtility->GetMetaDataAt( i, id, buf ); - - if ( id == HXMetaDataKeys::EHXMimeType ) - { - TPtr des = buf->Des(); + hxUtility->OpenFileL( aFullPath ); + PRINT( _L( "MM MTP <> MmMtpDpUtility::AsfMimeTypeL OpenFileL" ) ); - if ( des.Find( KHxMimeTypeWma() ) != KErrNotFound ) - { - isAudio = ETrue; - } - else if ( des.Find( KHxMimeTypeWmv() ) != KErrNotFound ) - { - PRINT( _L( "MM MTP <> MmMtpDpUtility::AsfMimeTypeL, video" ) ); - mimebuf = KMimeTypeVideoWm().Alloc(); - break; - } + HXMetaDataKeys::EHXMetaDataId id; + TUint count = 0; + TBool isAudio = EFalse; + hxUtility->GetMetaDataCount( count ); + for ( TUint i = 0; i < count; i++ ) + { + HBufC* buf = NULL; + hxUtility->GetMetaDataAt( i, id, buf ); + + if ( id == HXMetaDataKeys::EHXMimeType ) + { + TPtr des = buf->Des(); + + if ( des.Find( KHxMimeTypeWma() ) != KErrNotFound ) + { + isAudio = ETrue; } - else if ( i == count - 1 ) + else if ( des.Find( KHxMimeTypeWmv() ) != KErrNotFound ) { - if ( isAudio ) - { - PRINT( _L( "MM MTP <> MmMtpDpUtility::AsfMimeTypeL, audio" ) ); - mimebuf = KMimeTypeAudioWm().Alloc(); - } - else - { - User::Leave( KErrNotFound ); - } + PRINT( _L( "MM MTP <> MmMtpDpUtility::AsfMimeTypeL, video" ) ); + mimebuf = KMimeTypeVideoWm().Alloc(); + break; } } - - hxUtility->ResetL(); - CleanupStack::PopAndDestroy( hxUtility ); - } - else - { - User::Leave( KErrNotSupported ); + else if ( i == count - 1 ) + { + if ( isAudio ) + { + PRINT( _L( "MM MTP <> MmMtpDpUtility::AsfMimeTypeL, audio" ) ); + mimebuf = KMimeTypeAudioWm().Alloc(); + } + else + { + User::Leave( KErrNotFound ); + } + } } + hxUtility->ResetL(); + CleanupStack::PopAndDestroy( hxUtility ); #else User::Leave( KErrNotSupported ); #endif @@ -713,7 +646,7 @@ else { PRINT( _L( "MM MTP <= MmMtpDpUtility::SubFormatCodeFromMime format not supported" ) ); - subFormatCode = EMTPSubFormatCodeUndefine; + subFormatCode = EMTPSubFormatCodeUndefined; } PRINT1( _L( "MM MTP <= MmMtpDpUtility::SubFormatCodeFromMime SubFormatCode = %d" ), subFormatCode );