profilesapplication/Profiles/ProfileApp/SettingsViewSrc/ProfileMmfInfoUtility.cpp
branchRCL_3
changeset 11 bc161388e3ce
parent 0 ca436256272f
equal deleted inserted replaced
10:b79ee333c41d 11:bc161388e3ce
    25 
    25 
    26 // EXTERNAL INCLUDES
    26 // EXTERNAL INCLUDES
    27 #include <e32std.h>
    27 #include <e32std.h>
    28 #include <badesca.h>
    28 #include <badesca.h>
    29 #include <mmf/common/mmfcontrollerpluginresolver.h>
    29 #include <mmf/common/mmfcontrollerpluginresolver.h>
    30 
    30 #include <caf/caf.h>
    31 namespace
    31 namespace
    32 	{
    32 	{
    33 	// CONSTANTS
    33 	// CONSTANTS
    34 	_LIT8( KProfileRngMimeType,    "application/vnd.nokia.ringing-tone" );
    34 	_LIT8( KProfileRngMimeType,    "application/vnd.nokia.ringing-tone" );
    35 	//_LIT8( KProfilePlainTextType,  "text/plain" );
    35 	//_LIT8( KProfilePlainTextType,  "text/plain" );
    86     CleanupStack::PopAndDestroy( 2, formatPrms );
    86     CleanupStack::PopAndDestroy( 2, formatPrms );
    87 
    87 
    88     return result;
    88     return result;
    89     }
    89     }
    90 
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CProfileMmfInfoUtility::IsHeaderDataSupportedL
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 TBool ProfileMmfInfoUtility::IsHeaderDataSupportedL( const TDesC& aFileName )
       
    96 	{
       
    97 	TBool result( EFalse );
       
    98 	//the max header length is 256 bytes
       
    99 	const TInt KMaxHeaderLength( 256 );
       
   100 	HBufC8* header = HBufC8::NewLC( KMaxHeaderLength );
       
   101 	TPtr8 headerPtr = header->Des();
       
   102 	GetFileHeaderDataL( aFileName, headerPtr, KMaxHeaderLength );
       
   103 	CMMFFormatSelectionParameters* formatPrms =
       
   104 			CMMFFormatSelectionParameters::NewLC();
       
   105 	CMMFControllerPluginSelectionParameters* controllerPrms =
       
   106 			CMMFControllerPluginSelectionParameters::NewLC();
       
   107 
       
   108 	// Empty format parameters means: "get all the supported formats"
       
   109 	controllerPrms->SetRequiredPlayFormatSupportL( *formatPrms );
       
   110 	RMMFControllerImplInfoArray cntrlArray;
       
   111 	controllerPrms->ListImplementationsL( cntrlArray );
       
   112 
       
   113 	for ( TInt i( cntrlArray.Count() - 1 ); i >= 0 && !result; --i )
       
   114 		{
       
   115 		const RMMFFormatImplInfoArray& infoArray( cntrlArray[i]->PlayFormats() );
       
   116 
       
   117 		for ( TInt j(infoArray.Count() - 1); j >= 0; --j )
       
   118 			{
       
   119 			if ( infoArray[j]->SupportsHeaderDataL( *header ) )
       
   120 				{
       
   121 				result = ETrue;
       
   122 				break;
       
   123 				}
       
   124 			}
       
   125 		}
       
   126 
       
   127 	cntrlArray.ResetAndDestroy();
       
   128 	cntrlArray.Close();
       
   129 	CleanupStack::PopAndDestroy( 3, header );//controllerPrms, formatPrms and header
       
   130 
       
   131 	return result;
       
   132 	}
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // CProfileMmfInfoUtility::GetFileHeaderDataL
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 void ProfileMmfInfoUtility::GetFileHeaderDataL( const TDesC& aFileName,
       
   139 		TDes8& aHeaderData, TInt aMaxHeaderLength )
       
   140 	{
       
   141 	TInt error = KErrNone;
       
   142 	using namespace ContentAccess;
       
   143 	TVirtualPathPtr path( aFileName, ContentAccess::KDefaultContentObject );
       
   144 	CData* data = CData::NewLC( path, EContentShareReadWrite );
       
   145 	TInt size = 0;
       
   146 	data->DataSizeL( size );
       
   147 	if ( size > 0 )
       
   148 		{
       
   149 		if ( size > aMaxHeaderLength )
       
   150 			size = aMaxHeaderLength;
       
   151 		TInt pos = 0;
       
   152 		error = data->Seek( ESeekStart, pos );
       
   153 		error = data->Read( aHeaderData, size );
       
   154 		}
       
   155 	CleanupStack::PopAndDestroy(); // data
       
   156 	}
       
   157 
    91 //  End of File
   158 //  End of File
    92 
   159