diff -r b79ee333c41d -r bc161388e3ce profilesapplication/Profiles/ProfileApp/SettingsViewSrc/ProfileMmfInfoUtility.cpp --- a/profilesapplication/Profiles/ProfileApp/SettingsViewSrc/ProfileMmfInfoUtility.cpp Mon Mar 15 12:40:33 2010 +0200 +++ b/profilesapplication/Profiles/ProfileApp/SettingsViewSrc/ProfileMmfInfoUtility.cpp Wed Mar 31 21:31:25 2010 +0300 @@ -27,7 +27,7 @@ #include #include #include - +#include namespace { // CONSTANTS @@ -88,5 +88,72 @@ return result; } +// ----------------------------------------------------------------------------- +// CProfileMmfInfoUtility::IsHeaderDataSupportedL +// ----------------------------------------------------------------------------- +// +TBool ProfileMmfInfoUtility::IsHeaderDataSupportedL( const TDesC& aFileName ) + { + TBool result( EFalse ); + //the max header length is 256 bytes + const TInt KMaxHeaderLength( 256 ); + HBufC8* header = HBufC8::NewLC( KMaxHeaderLength ); + TPtr8 headerPtr = header->Des(); + GetFileHeaderDataL( aFileName, headerPtr, KMaxHeaderLength ); + CMMFFormatSelectionParameters* formatPrms = + CMMFFormatSelectionParameters::NewLC(); + CMMFControllerPluginSelectionParameters* controllerPrms = + CMMFControllerPluginSelectionParameters::NewLC(); + + // Empty format parameters means: "get all the supported formats" + controllerPrms->SetRequiredPlayFormatSupportL( *formatPrms ); + RMMFControllerImplInfoArray cntrlArray; + controllerPrms->ListImplementationsL( cntrlArray ); + + for ( TInt i( cntrlArray.Count() - 1 ); i >= 0 && !result; --i ) + { + const RMMFFormatImplInfoArray& infoArray( cntrlArray[i]->PlayFormats() ); + + for ( TInt j(infoArray.Count() - 1); j >= 0; --j ) + { + if ( infoArray[j]->SupportsHeaderDataL( *header ) ) + { + result = ETrue; + break; + } + } + } + + cntrlArray.ResetAndDestroy(); + cntrlArray.Close(); + CleanupStack::PopAndDestroy( 3, header );//controllerPrms, formatPrms and header + + return result; + } + +// ----------------------------------------------------------------------------- +// CProfileMmfInfoUtility::GetFileHeaderDataL +// ----------------------------------------------------------------------------- +// +void ProfileMmfInfoUtility::GetFileHeaderDataL( const TDesC& aFileName, + TDes8& aHeaderData, TInt aMaxHeaderLength ) + { + TInt error = KErrNone; + using namespace ContentAccess; + TVirtualPathPtr path( aFileName, ContentAccess::KDefaultContentObject ); + CData* data = CData::NewLC( path, EContentShareReadWrite ); + TInt size = 0; + data->DataSizeL( size ); + if ( size > 0 ) + { + if ( size > aMaxHeaderLength ) + size = aMaxHeaderLength; + TInt pos = 0; + error = data->Seek( ESeekStart, pos ); + error = data->Read( aHeaderData, size ); + } + CleanupStack::PopAndDestroy(); // data + } + // End of File