os/mm/mmlibs/mmfw/src/ControllerFramework/mmfcontrollerpluginresolver.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/src/ControllerFramework/mmfcontrollerpluginresolver.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1805 @@
     1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <badesca.h>
    1.20 +#include <utf.h>
    1.21 +#include <uri8.h>
    1.22 +#include <uriutils.h>
    1.23 +#include <mmf/plugin/mmfplugininterfaceuids.hrh>
    1.24 +#include <mmf/common/mmfcontrollerpluginresolver.h>
    1.25 +#include "mmfmatchdata.h"
    1.26 +#include <mmf/server/mmfdatasourcesink.hrh>
    1.27 +#include "MMFFormatImplementationInformationBody.h"
    1.28 +#include <mm/mmpluginutils.h>
    1.29 +
    1.30 +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    1.31 +#include <mmf/common/taggeddataparser.h>
    1.32 +#endif
    1.33 +
    1.34 +_LIT8(KSupplier, "<s>");
    1.35 +_LIT8(KMediaId, "<i>");
    1.36 +_LIT8(KUriScheme,"<u>");
    1.37 +_LIT8(KNonNetwork,"<n>");
    1.38 +_LIT8(KPlayFormatCollectionUid, "<p>");
    1.39 +_LIT8(KRecordFormatCollectionUid, "<r>");
    1.40 +_LIT8(KFormatFileExtension, "<e>");
    1.41 +_LIT8(KFormatMimeType, "<m>");
    1.42 +_LIT8(KFormatHeaderData, "<h>");
    1.43 +_LIT8(KHeapSize, "<a>");
    1.44 +_LIT8(KCustomInterfaceSupport, "<c>");
    1.45 +_LIT8(KSecureDRMProcessMode, "<d>");
    1.46 +_LIT8(KStackSize, "<t>");
    1.47 +_LIT8(KTagMatch, "*<?>*");
    1.48 +_LIT8(KTagYes,"yes");
    1.49 +
    1.50 +const TInt KTagLength = 3;
    1.51 +
    1.52 +const TInt KMaxExtLen = 5 ;
    1.53 +const TInt KDesCArrayGranularity = 1;
    1.54 +
    1.55 +const TInt KUriPriorityHigh = 3;
    1.56 +const TInt KUriPriorityMedium = 2;
    1.57 +const TInt KUriPriorityLow = 1;
    1.58 +const TInt KUriPriorityNone = 0;
    1.59 +
    1.60 +static const TUid KUidInterfaceFormatDecode = {KMmfUidPluginInterfaceFormatDecode};
    1.61 +static const TUid KUidInterfaceFormatEncode = {KMmfUidPluginInterfaceFormatEncode};
    1.62 +static const TUid KUidInterfaceMMFController = {KMmfUidPluginInterfaceController};
    1.63 +
    1.64 +
    1.65 +EXPORT_C CMMFFormatSelectionParameters* CMMFFormatSelectionParameters::NewL()
    1.66 +	{
    1.67 +	CMMFFormatSelectionParameters* s = CMMFFormatSelectionParameters::NewLC();
    1.68 +	CleanupStack::Pop(s);
    1.69 +	return s;
    1.70 +	}
    1.71 +
    1.72 +EXPORT_C CMMFFormatSelectionParameters* CMMFFormatSelectionParameters::NewLC()
    1.73 +	{
    1.74 +	CMMFFormatSelectionParameters* s = new(ELeave) CMMFFormatSelectionParameters;
    1.75 +	CleanupStack::PushL(s);
    1.76 +	return s;
    1.77 +	}
    1.78 +
    1.79 +CMMFFormatSelectionParameters* CMMFFormatSelectionParameters::NewL(const CMMFFormatSelectionParameters& aParams)
    1.80 +	{
    1.81 +	CMMFFormatSelectionParameters* s = CMMFFormatSelectionParameters::NewLC();
    1.82 +	s->ConstructL(aParams);
    1.83 +	CleanupStack::Pop(s);
    1.84 +	return s;
    1.85 +	}
    1.86 +
    1.87 +void CMMFFormatSelectionParameters::ConstructL(const CMMFFormatSelectionParameters& aParams)
    1.88 +	{
    1.89 +	iMatchReqData = CMatchData::CreateL();
    1.90 +	iMatchReqData->SetMatchDataL(aParams.MatchData());
    1.91 +	iMatchReqData->SetMatchUriSchemeL(aParams.MatchUriScheme());
    1.92 +	iMatchDataType = aParams.MatchDataType();
    1.93 +	}
    1.94 +
    1.95 +CMMFFormatSelectionParameters::~CMMFFormatSelectionParameters()
    1.96 +	{
    1.97 +	delete iMatchReqData;
    1.98 +	iMatchReqData= NULL;
    1.99 +	}
   1.100 +
   1.101 +CMMFFormatSelectionParameters::CMMFFormatSelectionParameters()
   1.102 +	{
   1.103 +	iMatchDataType = EMatchAny;
   1.104 +	}
   1.105 +	
   1.106 +EXPORT_C void CMMFFormatSelectionParameters::SetMatchToFileNameL(const TDesC& aFileName)
   1.107 +	{
   1.108 +	delete iMatchReqData;
   1.109 +	iMatchReqData = NULL;
   1.110 +	iMatchDataType = EMatchAny;	
   1.111 +	// Extract the extension from the data passed in
   1.112 +
   1.113 +	// Parse the path and extract the extension
   1.114 +	_LIT( KDot, "." ) ;
   1.115 +	_LIT8( KDot8, "." );
   1.116 +
   1.117 +	// If there is no dot "." in aFileName then assume that we have been passed the extension only (if KMaxExtLen or less)
   1.118 +	if ( (aFileName.Length() <= KMaxExtLen) && (aFileName.Find( KDot ) == KErrNotFound) )
   1.119 +		{
   1.120 +		RBuf8 temp;
   1.121 +		CleanupClosePushL(temp);
   1.122 +		temp.CreateL(aFileName.Length()+1);
   1.123 +		User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(temp, aFileName));
   1.124 +		temp.Insert(0,KDot8);
   1.125 +		
   1.126 +		iMatchReqData = CMatchData::CreateL();
   1.127 +		iMatchReqData->SetMatchDataL(temp);
   1.128 +		
   1.129 +		CleanupStack::PopAndDestroy(&temp);
   1.130 +		
   1.131 +		}
   1.132 +	else if ( aFileName.Find( KDot ) == 0 )  // the first character is dot so assume extension only
   1.133 +		{
   1.134 +		RBuf8 temp;
   1.135 +		CleanupClosePushL(temp);
   1.136 +		temp.CreateL(aFileName.Length());
   1.137 +		User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(temp, aFileName));
   1.138 +			
   1.139 +		iMatchReqData = CMatchData::CreateL();
   1.140 +		iMatchReqData->SetMatchDataL(temp);
   1.141 +		
   1.142 +		CleanupStack::PopAndDestroy(&temp);
   1.143 +		
   1.144 +		}
   1.145 +	else // We have been given the whole filename.  Use TParse to extract the extension.
   1.146 +		{
   1.147 +		TParse parser ;
   1.148 +		parser.Set( aFileName, NULL, NULL ) ;
   1.149 +		if ( !( parser.NamePresent() ) )
   1.150 +			User::Leave( KErrBadName ) ;
   1.151 +		if ( !( parser.PathPresent() ) )
   1.152 +			{
   1.153 +			RFs fsSession ;
   1.154 +			User::LeaveIfError(fsSession.Connect());
   1.155 +			TInt error = fsSession.Parse(aFileName, parser);
   1.156 +			fsSession.Close();
   1.157 +			User::LeaveIfError(error);
   1.158 +			}
   1.159 +		// Parser should now have the full filename and path
   1.160 +		TPtrC extension = parser.Ext();
   1.161 +		
   1.162 +		RBuf8 temp;
   1.163 +		CleanupClosePushL(temp);
   1.164 +		temp.CreateL(extension.Length());
   1.165 +		User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(temp, extension));
   1.166 +			
   1.167 +		iMatchReqData = CMatchData::CreateL();
   1.168 +		iMatchReqData->SetMatchDataL(temp);
   1.169 +		
   1.170 +		CleanupStack::PopAndDestroy(&temp);
   1.171 +		
   1.172 +		}
   1.173 +
   1.174 +	// If we're here, we must now have the file extension
   1.175 +	iMatchDataType = EMatchFileExtension;
   1.176 +	}
   1.177 +	
   1.178 +EXPORT_C void CMMFFormatSelectionParameters::SetMatchToUriL(const TDesC& aUrl)
   1.179 +	{
   1.180 +	delete iMatchReqData;
   1.181 +	iMatchReqData = NULL;
   1.182 +	iMatchDataType = EMatchAny;	
   1.183 +	
   1.184 +	CUri8* uri = UriUtils::CreateUriL(aUrl); //Converts the TDesC16 aUrl to TDesC8 type
   1.185 +   	CleanupStack::PushL(uri);
   1.186 +  	const TDesC8& path = uri->Uri().Extract(EUriPath);
   1.187 +	
   1.188 +	// Now parse the file name 
   1.189 +   	TInt pos = path.LocateReverse('.');
   1.190 +   
   1.191 +   	if(pos != KErrNotFound) // if not found, then by default match data is NULL
   1.192 +   		{
   1.193 +   		TPtrC8 extension(path.Right(path.Length()-pos));
   1.194 +   		iMatchReqData = CMatchData::CreateL();
   1.195 +   		iMatchReqData->SetMatchDataL(extension);
   1.196 +  		}
   1.197 +   	CleanupStack::PopAndDestroy(uri);
   1.198 +   
   1.199 +   	// If we're here, we must now have the file extension
   1.200 +   	// Use match file extension, because we are matching to the file extension of the file specified by the URI
   1.201 +  	iMatchDataType = EMatchFileExtension;
   1.202 +	}
   1.203 +	
   1.204 +/**
   1.205 +	@publishedPartner
   1.206 +	@prototype
   1.207 +	
   1.208 +	Sets this object to match to uri scheme and file extension specified by a URI.
   1.209 +	
   1.210 +	The Uri scheme and extension are saved in iMatchReqData. Further,iMatchData contains uri extension, 
   1.211 +	iMatchUriScheme contains uri scheme.
   1.212 +
   1.213 +	@param  aUri
   1.214 +	        The URI containing the scheme and uri extension to be matched. 
   1.215 +
   1.216 +*/	
   1.217 +EXPORT_C void CMMFFormatSelectionParameters::SetMatchToUriSupportL(const TDesC& aUrl)
   1.218 +	{
   1.219 +	delete iMatchReqData;
   1.220 +	iMatchReqData = NULL;
   1.221 +	iMatchDataType = EMatchAny;	
   1.222 +	
   1.223 +	CUri8* uri = UriUtils::CreateUriL(aUrl); //Converts the TDesC16 aUrl to TDesC8 type
   1.224 +	CleanupStack::PushL(uri);
   1.225 +	
   1.226 +	const TDesC8& scheme = uri->Uri().Extract(EUriScheme);  //get the uri scheme
   1.227 +	iMatchReqData = CMatchData::CreateL();
   1.228 +	iMatchReqData->SetMatchUriSchemeL(scheme);
   1.229 +	
   1.230 +	const TDesC8& path = uri->Uri().Extract(EUriPath); 		
   1.231 +	// Now parse the file name 
   1.232 +	TInt pos = path.LocateReverse('.');
   1.233 +	
   1.234 +	if(pos != KErrNotFound) // if not found, by default match data is NULL
   1.235 +		{
   1.236 +		TPtrC8 extension(path.Right(path.Length()-pos));
   1.237 +		iMatchReqData->SetMatchDataL(extension);
   1.238 + 		}
   1.239 +		
   1.240 +	CleanupStack::PopAndDestroy(uri);
   1.241 +	// If we're here, we must now have the uri saved in iMatchData. Now, set match type 
   1.242 +	// to EMatchUri for checking schema and uri extension
   1.243 +	iMatchDataType = EMatchUri;
   1.244 +	}
   1.245 +	
   1.246 +
   1.247 +
   1.248 +EXPORT_C void CMMFFormatSelectionParameters::SetMatchToMimeTypeL(const TDesC8& aMimeType)
   1.249 +	{
   1.250 +	delete iMatchReqData;
   1.251 +	iMatchReqData = NULL;
   1.252 +	iMatchDataType = EMatchAny;	
   1.253 +	
   1.254 +	iMatchReqData = CMatchData::CreateL();
   1.255 +	iMatchReqData->SetMatchDataL(aMimeType);
   1.256 +	iMatchDataType = EMatchMimeType;
   1.257 +	}
   1.258 +
   1.259 +EXPORT_C void CMMFFormatSelectionParameters::SetMatchToHeaderDataL(const TDesC8& aHeaderData)
   1.260 +	{
   1.261 +	delete iMatchReqData;
   1.262 +	iMatchReqData = NULL;
   1.263 +	iMatchDataType = EMatchAny;	
   1.264 +	
   1.265 +	iMatchReqData = CMatchData::CreateL();
   1.266 +	iMatchReqData->SetMatchDataL(aHeaderData);	
   1.267 +	iMatchDataType = EMatchHeaderData;
   1.268 +	}
   1.269 +
   1.270 +EXPORT_C const TDesC8& CMMFFormatSelectionParameters::MatchData() const
   1.271 +	{
   1.272 +	if (iMatchReqData)
   1.273 +		{
   1.274 +		return iMatchReqData->MatchData();
   1.275 +		}
   1.276 +	else
   1.277 +		{
   1.278 +		return KNullDesC8;	
   1.279 +		}
   1.280 +	}
   1.281 +
   1.282 +/**
   1.283 +	@publishedPartner
   1.284 +	@prototype
   1.285 +	
   1.286 +	Returns the uri scheme used to perform the plugin match.
   1.287 +	
   1.288 +	@return The uri scheme.
   1.289 +
   1.290 +*/	
   1.291 +EXPORT_C const TDesC8& CMMFFormatSelectionParameters::MatchUriScheme() const
   1.292 +	{
   1.293 +	if (iMatchReqData)
   1.294 +		{
   1.295 +		return iMatchReqData->MatchUriScheme();
   1.296 +		}
   1.297 +	else
   1.298 +		{
   1.299 +		return KNullDesC8;
   1.300 +		}
   1.301 +	}
   1.302 +	
   1.303 +EXPORT_C CMMFFormatSelectionParameters::TMatchDataType CMMFFormatSelectionParameters::MatchDataType() const
   1.304 +	{
   1.305 +	return iMatchDataType;
   1.306 +	}
   1.307 +
   1.308 +CMMFPluginSelectionParameters::CMMFPluginSelectionParameters(TUid aPluginInterfaceUid) :
   1.309 +	iPluginInterfaceUid(aPluginInterfaceUid)
   1.310 +	{
   1.311 +	iPreferredSupplierMatchType = ENoPreferredSupplierMatch;
   1.312 +	iMediaIdMatchType = ENoMediaIdMatch;
   1.313 +	}
   1.314 +
   1.315 +CMMFPluginSelectionParameters::~CMMFPluginSelectionParameters()
   1.316 +	{
   1.317 +	delete iPreferredSupplier;
   1.318 +	iMediaIds.Reset();
   1.319 +	iMediaIds.Close();
   1.320 +	}
   1.321 +
   1.322 +EXPORT_C void CMMFPluginSelectionParameters::SetPreferredSupplierL(const TDesC& aPreferredSupplier, TPreferredSupplierMatchType aMatchType)
   1.323 +	{
   1.324 +	delete iPreferredSupplier;
   1.325 +	iPreferredSupplier = NULL;
   1.326 +	iPreferredSupplier = aPreferredSupplier.AllocL();
   1.327 +	iPreferredSupplierMatchType = aMatchType;
   1.328 +	}
   1.329 +
   1.330 +EXPORT_C void CMMFPluginSelectionParameters::SetMediaIdsL(const RArray<TUid>& aMediaIds, TMediaIdMatchType aMatchType)
   1.331 +	{
   1.332 +	iMediaIds.Reset();
   1.333 +	for (TInt i=0; i<aMediaIds.Count(); i++)
   1.334 +		{
   1.335 +		User::LeaveIfError(iMediaIds.Append(aMediaIds[i]));
   1.336 +		}
   1.337 +	iMediaIdMatchType = aMatchType;
   1.338 +	}
   1.339 +
   1.340 +EXPORT_C const TDesC& CMMFPluginSelectionParameters::PreferredSupplier() const
   1.341 +	{
   1.342 +	if (iPreferredSupplier)
   1.343 +		return *iPreferredSupplier;
   1.344 +	else
   1.345 +		return KNullDesC;
   1.346 +	}
   1.347 +
   1.348 +EXPORT_C CMMFPluginSelectionParameters::TPreferredSupplierMatchType CMMFPluginSelectionParameters::PreferredSupplierMatchType() const
   1.349 +	{
   1.350 +	return iPreferredSupplierMatchType;
   1.351 +	}
   1.352 +
   1.353 +EXPORT_C const RArray<TUid>& CMMFPluginSelectionParameters::MediaIds() const
   1.354 +	{
   1.355 +	return iMediaIds;
   1.356 +	}
   1.357 +
   1.358 +EXPORT_C CMMFPluginSelectionParameters::TMediaIdMatchType CMMFPluginSelectionParameters::MediaIdMatchType() const
   1.359 +	{
   1.360 +	return iMediaIdMatchType;
   1.361 +	}
   1.362 +
   1.363 +EXPORT_C TUid CMMFPluginSelectionParameters::InterfaceUid() const
   1.364 +	{
   1.365 +	return iPluginInterfaceUid;
   1.366 +	}
   1.367 +
   1.368 +
   1.369 +TBool CMMFPluginSelectionParameters::CheckMediaIdSupportL(const CMMFPluginImplementationInformation& aPlugin) const
   1.370 +	{
   1.371 +	TBool ret = EFalse;
   1.372 +	switch (MediaIdMatchType())
   1.373 +		{
   1.374 +	case CMMFPluginSelectionParameters::ENoMediaIdMatch:
   1.375 +		// No match required so suitable
   1.376 +		ret = ETrue;
   1.377 +		break;
   1.378 +	case CMMFPluginSelectionParameters::EAllowOtherMediaIds:
   1.379 +		// Just check that the requested media id is supported by the plugin
   1.380 +		{
   1.381 +		for (TInt i=0; i<MediaIds().Count(); i++)
   1.382 +			{
   1.383 +			if (aPlugin.SupportsMediaId(MediaIds()[i]))
   1.384 +				{
   1.385 +				ret = ETrue;
   1.386 +				break;
   1.387 +				}
   1.388 +			}
   1.389 +		break;
   1.390 +		}
   1.391 +	case CMMFPluginSelectionParameters::EAllowOnlySuppliedMediaIds:
   1.392 +		// Check the media id counts are the same, and that all requested ones are present
   1.393 +		{
   1.394 +		TInt found=0;
   1.395 +		for (TInt i=0; i<MediaIds().Count(); i++)
   1.396 +			{
   1.397 +			if (aPlugin.SupportsMediaId(MediaIds()[i]))
   1.398 +				found++;
   1.399 +			}
   1.400 +		// Check all request mediaIds are present
   1.401 +		if ((found == MediaIds().Count()) && (found == aPlugin.SupportedMediaIds().Count()))
   1.402 +			ret = ETrue;
   1.403 +		break;
   1.404 +		}
   1.405 +	default:
   1.406 +		User::Leave(KErrNotSupported);
   1.407 +		break;
   1.408 +		}
   1.409 +	return ret;
   1.410 +	}
   1.411 +
   1.412 +
   1.413 +
   1.414 +EXPORT_C CMMFControllerPluginSelectionParameters* CMMFControllerPluginSelectionParameters::NewL()
   1.415 +	{
   1.416 +	CMMFControllerPluginSelectionParameters* s = CMMFControllerPluginSelectionParameters::NewLC();
   1.417 +	CleanupStack::Pop(s);
   1.418 +	return s;	
   1.419 +	}
   1.420 +
   1.421 +EXPORT_C CMMFControllerPluginSelectionParameters* CMMFControllerPluginSelectionParameters::NewLC()
   1.422 +	{
   1.423 +	CMMFControllerPluginSelectionParameters* s = new(ELeave) CMMFControllerPluginSelectionParameters;
   1.424 +	CleanupStack::PushL(s);
   1.425 +	return s;
   1.426 +	}
   1.427 +
   1.428 +CMMFControllerPluginSelectionParameters::CMMFControllerPluginSelectionParameters() :
   1.429 +	CMMFPluginSelectionParameters(KUidInterfaceMMFController)
   1.430 +	{
   1.431 +	}
   1.432 +
   1.433 +CMMFControllerPluginSelectionParameters::~CMMFControllerPluginSelectionParameters()
   1.434 +	{
   1.435 +	delete iRequiredPlayFormatSupport;
   1.436 +	delete iRequiredRecordFormatSupport;
   1.437 +	}
   1.438 +
   1.439 +EXPORT_C void CMMFControllerPluginSelectionParameters::SetRequiredPlayFormatSupportL(const CMMFFormatSelectionParameters& aRequiredSupport)
   1.440 +	{
   1.441 +	delete iRequiredPlayFormatSupport;
   1.442 +	iRequiredPlayFormatSupport = NULL;
   1.443 +	iRequiredPlayFormatSupport = CMMFFormatSelectionParameters::NewL(aRequiredSupport);
   1.444 +	}
   1.445 +
   1.446 +EXPORT_C void CMMFControllerPluginSelectionParameters::SetRequiredRecordFormatSupportL(const CMMFFormatSelectionParameters& aRequiredSupport)
   1.447 +	{
   1.448 +	delete iRequiredRecordFormatSupport;
   1.449 +	iRequiredRecordFormatSupport = NULL;
   1.450 +	iRequiredRecordFormatSupport = CMMFFormatSelectionParameters::NewL(aRequiredSupport);
   1.451 +	}
   1.452 +
   1.453 +EXPORT_C void CMMFControllerPluginSelectionParameters::ListImplementationsL(RMMFControllerImplInfoArray& aImplementations) const
   1.454 +	{
   1.455 +	aImplementations.ResetAndDestroy();
   1.456 +
   1.457 +	RImplInfoPtrArray ecomArray;
   1.458 +	CleanupResetAndDestroyPushL(ecomArray);
   1.459 +
   1.460 +	MmPluginUtils::FindImplementationsL(InterfaceUid(), ecomArray);
   1.461 +
   1.462 +	TInt index;
   1.463 +	// Create Controller Implementation Information for each entry
   1.464 +	for (index=0; index<ecomArray.Count(); index++)
   1.465 +		{
   1.466 +		CMMFControllerImplementationInformation* c = NULL;
   1.467 +		if (ecomArray[index] == NULL)
   1.468 +			{
   1.469 +			User::Leave(KErrNoMemory);
   1.470 +			}
   1.471 +		TRAPD(error, c = CMMFControllerImplementationInformation::NewL(*(ecomArray[index])));
   1.472 +
   1.473 +		if (error == KErrNone)
   1.474 +			{
   1.475 +			CleanupStack::PushL(c);
   1.476 +			
   1.477 +		// If required, get the play and record formats for the controller.
   1.478 +			if (iRequiredPlayFormatSupport)
   1.479 +				{
   1.480 +				c->GetPlayFormatsL();
   1.481 +				}
   1.482 +			if (iRequiredRecordFormatSupport)
   1.483 +				{
   1.484 +				c->GetRecordFormatsL();
   1.485 +				}
   1.486 +			
   1.487 +			// Find out whether this controller matches the client's requirements...
   1.488 +			TBool suitable = EFalse;
   1.489 +			TInt arrayPos; 
   1.490 +			suitable = CheckUriSupport(iRequiredPlayFormatSupport, c, c->PlayFormats());
   1.491 +			if(suitable)
   1.492 +				{
   1.493 +				suitable = CheckUriSupport(iRequiredRecordFormatSupport, c, c->RecordFormats());
   1.494 +				}
   1.495 +			if(suitable)
   1.496 +				{
   1.497 +				MatchImplementationToSelectParamsL(aImplementations, *c, arrayPos);
   1.498 +				}
   1.499 +			else
   1.500 +				{
   1.501 +				arrayPos = -1;	
   1.502 +				}
   1.503 +			
   1.504 +			if (arrayPos >=0)
   1.505 +				{
   1.506 +				// This plugin is suitable - insert it into the array at the suggested position
   1.507 +				User::LeaveIfError(aImplementations.Insert(c, arrayPos));
   1.508 +				CleanupStack::Pop(c);
   1.509 +				}
   1.510 +			else
   1.511 +				{
   1.512 +				// This plugin isn't suitable so just destroy it
   1.513 +				CleanupStack::PopAndDestroy(c);
   1.514 +				}
   1.515 +			}
   1.516 +		else if (error != KErrCorrupt)
   1.517 +			{
   1.518 +			// Ignore the plugin if it is corrupt.  Otherwise, leave.
   1.519 +			// if error !=KErrNone, c hasn't been constructed so it is safe to leave
   1.520 +			User::Leave(error);
   1.521 +			}
   1.522 +		}
   1.523 +
   1.524 +	CleanupStack::PopAndDestroy();//ecomArray
   1.525 +	}
   1.526 +
   1.527 +void CMMFControllerPluginSelectionParameters::MatchImplementationToSelectParamsL(RMMFControllerImplInfoArray& aImplementations, const CMMFControllerImplementationInformation& aPlugin, TInt& aArrayPos) const
   1.528 +	{
   1.529 +	TBool suitable = EFalse;
   1.530 +	
   1.531 +	// First, check whether the plugin supports the required play formats
   1.532 +	suitable = CheckFormatSupportL(iRequiredPlayFormatSupport, aPlugin.PlayFormats());
   1.533 +	
   1.534 +	// Next, check the record formats
   1.535 +	if (suitable)
   1.536 +		suitable = CheckFormatSupportL(iRequiredRecordFormatSupport, aPlugin.RecordFormats());
   1.537 +		
   1.538 +	// Next, check for correct media id support
   1.539 +	if (suitable)
   1.540 +		suitable = CheckMediaIdSupportL(aPlugin);
   1.541 +
   1.542 +	// Finally, calculate the position the plugin should take in aImplementations depending on the preferred supplier and version number.
   1.543 +	if (suitable)
   1.544 +		aArrayPos = CheckPreferredSupplierL(aImplementations, aPlugin);
   1.545 +	else
   1.546 +		aArrayPos = -1;
   1.547 +	}
   1.548 +
   1.549 +/**
   1.550 +	Checks the given Controller for uri support. Uri support may be there 
   1.551 +	if either requiredscheme or extension matches with that given controller
   1.552 +	
   1.553 +	@param  aSelectParams 
   1.554 +			Describes the selection parameter which a controller needs to 
   1.555 +			support in order to be selected
   1.556 +			
   1.557 +	@param	aPlugin
   1.558 +			The controller plugin which is checked for uri support 
   1.559 +			
   1.560 +	@param	aFormats
   1.561 +			The play or record formats looked for extension match
   1.562 +*/	
   1.563 +TBool CMMFControllerPluginSelectionParameters::CheckUriSupport(CMMFFormatSelectionParameters* aSelectParams, CMMFControllerImplementationInformation* aPlugin, const RMMFFormatImplInfoArray& aFormats) const
   1.564 +	{
   1.565 +	// If aSelectParams are NULL (ie none were set) then the plugin must be suitable!
   1.566 +	if (aSelectParams == NULL)
   1.567 +		return ETrue;
   1.568 +	
   1.569 +	//If EMatchUri not set then the plugin might be suitable!
   1.570 +	if(aSelectParams->MatchDataType() != CMMFFormatSelectionParameters::EMatchUri)
   1.571 +		{
   1.572 +		return ETrue;
   1.573 +		}
   1.574 +		
   1.575 +	TBool suitable = EFalse;
   1.576 +	TInt index;
   1.577 +	
   1.578 +	//If <n>yes is there in the aPlugin's opaque data, 
   1.579 +	//URI support not assumed. So, don't load the controller
   1.580 +	if(!aPlugin->SupportsNetworkCapability())
   1.581 +		{
   1.582 +		return EFalse;	
   1.583 +		}
   1.584 +
   1.585 +    //the uri scheme to be matched for
   1.586 +	if (aPlugin->SupportsUriScheme(aSelectParams->MatchUriScheme()))
   1.587 +		{
   1.588 +		aPlugin->SetUriPriority(KUriPriorityMedium);
   1.589 +		suitable = ETrue;
   1.590 +		}
   1.591 +	else
   1.592 +		{
   1.593 +		//if other uri scheme support declared, but not the required one,
   1.594 +		// even then controller not supported
   1.595 +		if(aPlugin->SupportedUriSchemes().Count() > 0)
   1.596 +			{
   1.597 +			return EFalse;		
   1.598 +			}
   1.599 +		}
   1.600 +	
   1.601 +		
   1.602 +	//then match Uri extension. .
   1.603 +	
   1.604 +	//if ctrl has no network capability, then lowest priority given on matching file extension
   1.605 +	for (index=0;index<aFormats.Count();index++)
   1.606 +		{
   1.607 +		if (aFormats[index]-> SupportsFileExtension(aSelectParams->MatchData()))
   1.608 +			{
   1.609 +			if(!suitable)
   1.610 +				{
   1.611 +				aPlugin->SetUriPriority(KUriPriorityLow);	
   1.612 +				}
   1.613 +			else
   1.614 +				{
   1.615 +				aPlugin->SetUriPriority(KUriPriorityHigh);
   1.616 +				}
   1.617 +			
   1.618 +			suitable = ETrue;
   1.619 +			break;
   1.620 +			}
   1.621 +		}
   1.622 +	
   1.623 +	return suitable;
   1.624 +	}
   1.625 +
   1.626 +TInt CMMFControllerPluginSelectionParameters::CheckPreferredSupplierL(RMMFControllerImplInfoArray& aImplementations, const CMMFControllerImplementationInformation& aPlugin) const
   1.627 +	{
   1.628 +	// Set the return value to indicated the plugin is not suitable.
   1.629 +	TBool pluginSuitable = EFalse;
   1.630 +	TBool needToPlaceInVersionOrder = EFalse;
   1.631 +	TBool needToPlaceInUriPriorityOrder = EFalse;
   1.632 +
   1.633 +	if((iRequiredPlayFormatSupport && (iRequiredPlayFormatSupport->MatchDataType() == CMMFFormatSelectionParameters::EMatchUri))
   1.634 +	 || (iRequiredRecordFormatSupport && (iRequiredRecordFormatSupport->MatchDataType() == CMMFFormatSelectionParameters::EMatchUri)))
   1.635 +		{
   1.636 +		needToPlaceInUriPriorityOrder = ETrue;
   1.637 +		}
   1.638 +	
   1.639 +	switch (PreferredSupplierMatchType())
   1.640 +		{
   1.641 +	case ENoPreferredSupplierMatch:
   1.642 +		// No match, so suitable.
   1.643 +		pluginSuitable = ETrue;
   1.644 +	    break;
   1.645 +	case EPreferredSupplierPluginsFirstInList:
   1.646 +		pluginSuitable = ETrue;
   1.647 +		if (aPlugin.SupportsSupplier(PreferredSupplier()))
   1.648 +			needToPlaceInVersionOrder = ETrue;
   1.649 +		break;
   1.650 +	case EOnlyPreferredSupplierPluginsReturned:
   1.651 +		if (aPlugin.SupportsSupplier(PreferredSupplier()))
   1.652 +			{
   1.653 +			pluginSuitable = ETrue;
   1.654 +			needToPlaceInVersionOrder = ETrue;
   1.655 +			}
   1.656 +		break;
   1.657 +	default:
   1.658 +		User::Leave(KErrNotSupported);
   1.659 +		}
   1.660 +
   1.661 +	TInt arrayPos;
   1.662 +			
   1.663 +	if (!pluginSuitable)
   1.664 +		{
   1.665 +		arrayPos = -1;
   1.666 +		}
   1.667 +		
   1.668 +	else
   1.669 +		{
   1.670 +		if(needToPlaceInUriPriorityOrder)
   1.671 +			{
   1.672 +			arrayPos = aImplementations.Count();
   1.673 +			// Cycle through aImplementations to find the first plugin with a uri priority LOWER than aPlugin's
   1.674 +			for (TInt i=0; i<aImplementations.Count(); i++)
   1.675 +				{
   1.676 +				CMMFControllerImplementationInformation* c = aImplementations[i];
   1.677 +				
   1.678 +				if(PreferredSupplierMatchType() == ENoPreferredSupplierMatch) //case 1
   1.679 +					{
   1.680 +					/**
   1.681 +					Place the plugin based on its Uri priority.
   1.682 +					Arrange the plugins in Decreasing order of their priority. In case if two or more plugins 
   1.683 +					have similar priority, append the next one at the end. 
   1.684 +					*/
   1.685 +					if (c->UriPriority() < aPlugin.UriPriority())
   1.686 +						{
   1.687 +						arrayPos = i;//plugin will be inserted before c in the array
   1.688 +						break;
   1.689 +						}
   1.690 +					}
   1.691 +				else
   1.692 +					{
   1.693 +					if(!needToPlaceInVersionOrder)  //case 2
   1.694 +						{
   1.695 +						/**
   1.696 +						This reflects the case EPreferredSupplierPluginsFirstInList and 
   1.697 +						aPlugin supplier not matching.
   1.698 +						Place the plugin based on its Uri Priority after the required suppliers plugin.
   1.699 +						If priority is equal, new plugin will be placed last.
   1.700 +						*/
   1.701 +						if( (c->Supplier() != PreferredSupplier()) && (c->UriPriority() < aPlugin.UriPriority()))
   1.702 +							{
   1.703 +							arrayPos = i;//plugin will be inserted before c in the array
   1.704 +							break;
   1.705 +							}
   1.706 +						}
   1.707 +					else  //case 3
   1.708 +						{
   1.709 +						/** 
   1.710 +						This reflects the case where 
   1.711 +						Supplier matches and EPreferredSupplierPluginsFirstInList is specified.
   1.712 +						OR
   1.713 +						Supplier matches and EOnlyPreferredSupplierPluginsReturned is specified.
   1.714 +						*/
   1.715 +						if(c->Supplier() == PreferredSupplier()) 
   1.716 +							{
   1.717 +							if(c->UriPriority() == aPlugin.UriPriority())
   1.718 +								{
   1.719 +								if(c->Version() <= aPlugin.Version())
   1.720 +									{
   1.721 +									arrayPos = i;//plugin will be inserted before c in the array
   1.722 +									break;
   1.723 +									}
   1.724 +								}
   1.725 +							else 
   1.726 +								{
   1.727 +								if(c->UriPriority() < aPlugin.UriPriority())
   1.728 +									{
   1.729 +									arrayPos = i;//plugin will be inserted before c in the array
   1.730 +									break;
   1.731 +									}
   1.732 +								}
   1.733 +							}
   1.734 +						else
   1.735 +							{
   1.736 +							/**
   1.737 +							This is a case of aImplementations now having unpreferred suppliers 
   1.738 +							when EPreferredSupplierPluginsFirstInList is specified and aPlugin is
   1.739 +							of preferred supplier but least priority.
   1.740 +							*/
   1.741 +							arrayPos = i;//plugin will be inserted before c in the array
   1.742 +							break;
   1.743 +							}
   1.744 +						}
   1.745 +					}
   1.746 +				}
   1.747 +			}
   1.748 +			
   1.749 +		else
   1.750 +			{
   1.751 +			if (!needToPlaceInVersionOrder)  
   1.752 +				{
   1.753 +				/**
   1.754 +				place it at the end.
   1.755 +				*/
   1.756 +				arrayPos = aImplementations.Count();
   1.757 +				}
   1.758 +			else
   1.759 +				{
   1.760 +				// Insert the plugin at the beginning of the array, in version order if possible.
   1.761 +				// Make an assumption: if we've been asked for format support, then only plugins 
   1.762 +				// that support the same format will be in the array - so ordering them by version
   1.763 +				// will be meaningful.  Otherwise, there's no point.
   1.764 +				if ((iRequiredPlayFormatSupport && (iRequiredPlayFormatSupport->MatchDataType() != CMMFFormatSelectionParameters::EMatchAny))
   1.765 +					|| (iRequiredRecordFormatSupport && (iRequiredRecordFormatSupport->MatchDataType() != CMMFFormatSelectionParameters::EMatchAny)))
   1.766 +					{
   1.767 +					// Put the plugin in version order at the beginning of the list
   1.768 +
   1.769 +					// Set aArrayPos to the end of the array in case this plugin has the lowest version number
   1.770 +					arrayPos = aImplementations.Count();
   1.771 +					// Cycle through aImplementations to find the first plugin with a version number LOWER than aPlugin
   1.772 +					for (TInt i=0; i<aImplementations.Count(); i++)
   1.773 +						{
   1.774 +						CMMFControllerImplementationInformation* c = aImplementations[i];
   1.775 +						if (c->Supplier() == aPlugin.Supplier())
   1.776 +							{
   1.777 +							if (c->Version() <= aPlugin.Version())
   1.778 +								{
   1.779 +								arrayPos = i;//plugin will be inserted before c in the array
   1.780 +								break;
   1.781 +								}
   1.782 +							}
   1.783 +						else
   1.784 +							{
   1.785 +							arrayPos = i; //c has wrong supplier so this plugin must go before c
   1.786 +							break;
   1.787 +							}
   1.788 +						}
   1.789 +					}
   1.790 +				else
   1.791 +					{
   1.792 +					// We can't use the version numbers meaningfully, so just put this plugin
   1.793 +					// at the top of the list.
   1.794 +					arrayPos = 0;
   1.795 +					}
   1.796 +				}
   1.797 +			}
   1.798 +		}
   1.799 +	
   1.800 +	return arrayPos;
   1.801 +	}
   1.802 +
   1.803 +TBool CMMFControllerPluginSelectionParameters::CheckFormatSupportL(CMMFFormatSelectionParameters* aSelectParams, const RMMFFormatImplInfoArray& aFormats) const
   1.804 +	{
   1.805 +	// If aSelectParams are NULL (ie none were set) then the plugin must be suitable!
   1.806 +	if (aSelectParams == NULL)
   1.807 +		return ETrue;
   1.808 +
   1.809 +	TBool suitable = EFalse;
   1.810 +
   1.811 +	// Check all the formats in aFormats.  If any support the required data type, return ETrue.
   1.812 +	TInt index;
   1.813 +	switch (aSelectParams->MatchDataType())
   1.814 +		{
   1.815 +	case CMMFFormatSelectionParameters::EMatchAny:
   1.816 +		// All plugins intrinsically match this!
   1.817 +		suitable = ETrue;
   1.818 +		break;
   1.819 +	case CMMFFormatSelectionParameters::EMatchFileExtension:
   1.820 +		for (index=0;index<aFormats.Count();index++)
   1.821 +			{
   1.822 +			if (aFormats[index]->SupportsFileExtension(aSelectParams->MatchData()))
   1.823 +				{
   1.824 +				suitable = ETrue;
   1.825 +				break;
   1.826 +				}
   1.827 +			}
   1.828 +		break;
   1.829 +	case CMMFFormatSelectionParameters::EMatchMimeType:
   1.830 +		for (index=0;index<aFormats.Count();index++)
   1.831 +			{
   1.832 +			if (aFormats[index]->SupportsMimeType(aSelectParams->MatchData()))
   1.833 +				{
   1.834 +				suitable = ETrue;
   1.835 +				break;
   1.836 +				}
   1.837 +			}
   1.838 +		break;
   1.839 +	case CMMFFormatSelectionParameters::EMatchHeaderData:
   1.840 +		for (index=0;index<aFormats.Count();index++)
   1.841 +			{
   1.842 +			if (aFormats[index]->SupportsHeaderDataL(aSelectParams->MatchData()))
   1.843 +				{
   1.844 +				suitable = ETrue;
   1.845 +				break;
   1.846 +				}
   1.847 +			}
   1.848 +		break;
   1.849 +		
   1.850 +	case CMMFFormatSelectionParameters::EMatchUri:
   1.851 +		{
   1.852 +		suitable = ETrue; //if uri match specifically looked , then that has been already matched in a CheckUriSupport()
   1.853 +		break;	
   1.854 +		}
   1.855 +		
   1.856 +
   1.857 +	default:
   1.858 +		User::Leave(KErrNotSupported);
   1.859 +		};
   1.860 +
   1.861 +	return suitable;
   1.862 +	}
   1.863 +
   1.864 +
   1.865 +
   1.866 +EXPORT_C CMMFControllerSecureDrmPluginSelectionParameters* CMMFControllerSecureDrmPluginSelectionParameters::NewL()
   1.867 +	{
   1.868 +	CMMFControllerSecureDrmPluginSelectionParameters* s = CMMFControllerSecureDrmPluginSelectionParameters::NewLC();
   1.869 +	CleanupStack::Pop(s);
   1.870 +	return s;	
   1.871 +	}
   1.872 +
   1.873 +EXPORT_C CMMFControllerSecureDrmPluginSelectionParameters* CMMFControllerSecureDrmPluginSelectionParameters::NewLC()
   1.874 +	{
   1.875 +	CMMFControllerSecureDrmPluginSelectionParameters* s = new(ELeave) CMMFControllerSecureDrmPluginSelectionParameters;
   1.876 +	CleanupStack::PushL(s);
   1.877 +	return s;
   1.878 +	}
   1.879 +
   1.880 +CMMFControllerSecureDrmPluginSelectionParameters::CMMFControllerSecureDrmPluginSelectionParameters() :
   1.881 +	CMMFControllerPluginSelectionParameters()
   1.882 +	{
   1.883 +	}
   1.884 +
   1.885 +EXPORT_C void CMMFControllerSecureDrmPluginSelectionParameters::ListImplementationsL(RMMFControllerImplInfoArray& aImplementations) const
   1.886 +	{
   1.887 +	CMMFControllerPluginSelectionParameters::ListImplementationsL(aImplementations);
   1.888 +	TInt pluginsCount = aImplementations.Count();
   1.889 +	for (TInt i = pluginsCount - 1; i >= 0; i--)
   1.890 +		{
   1.891 +		CMMFControllerImplementationInformation* c = aImplementations[i];
   1.892 +		if (!c->SupportsSecureDRMProcessMode())
   1.893 +			{
   1.894 +			aImplementations.Remove(i);
   1.895 +			delete c;
   1.896 +			}
   1.897 +		}
   1.898 +	aImplementations.Compress();
   1.899 +	}
   1.900 +
   1.901 +
   1.902 +
   1.903 +CMMFFormatPluginSelectionParameters::CMMFFormatPluginSelectionParameters(TUid aInterfaceUid) :
   1.904 +	CMMFPluginSelectionParameters(aInterfaceUid)
   1.905 +	{
   1.906 +	}
   1.907 +
   1.908 +CMMFFormatPluginSelectionParameters::~CMMFFormatPluginSelectionParameters()
   1.909 +	{
   1.910 +	delete iRequiredFormatSupport;
   1.911 +	}
   1.912 +
   1.913 +EXPORT_C void CMMFFormatPluginSelectionParameters::SetRequiredFormatSupportL(const CMMFFormatSelectionParameters& aRequiredSupport)
   1.914 +	{
   1.915 +	delete iRequiredFormatSupport;
   1.916 +	iRequiredFormatSupport = NULL;
   1.917 +	iRequiredFormatSupport = CMMFFormatSelectionParameters::NewL(aRequiredSupport);
   1.918 +	}
   1.919 +
   1.920 +EXPORT_C void CMMFFormatPluginSelectionParameters::ListImplementationsL(RMMFFormatImplInfoArray& aImplementations) const
   1.921 +	{
   1.922 +	aImplementations.ResetAndDestroy();
   1.923 +
   1.924 +	RImplInfoPtrArray ecomArray;
   1.925 +	CleanupResetAndDestroyPushL(ecomArray);
   1.926 +
   1.927 +	MmPluginUtils::FindImplementationsL(InterfaceUid(), ecomArray);
   1.928 +
   1.929 +
   1.930 +	TInt index;
   1.931 +	// Create Format Implementation Information for each entry
   1.932 +	for (index=0; index<ecomArray.Count(); index++)
   1.933 +		{
   1.934 +		CMMFFormatImplementationInformation* c = NULL;
   1.935 +		TRAPD(error, c = CMMFFormatImplementationInformation::NewL(*(ecomArray[index])));
   1.936 +
   1.937 +		if (error == KErrNone)
   1.938 +			{
   1.939 +			CleanupStack::PushL(c);
   1.940 +			// Find out whether this format matches the client's requirements...
   1.941 +			TInt arrayPos;
   1.942 +			MatchImplementationToSelectParamsL(aImplementations, *c, arrayPos);
   1.943 +			if (arrayPos >=0)
   1.944 +				{
   1.945 +				// This plugin is suitable - insert it into the array at the suggested position
   1.946 +				User::LeaveIfError(aImplementations.Insert(c, arrayPos));
   1.947 +				CleanupStack::Pop(c);
   1.948 +				}
   1.949 +			else
   1.950 +				{
   1.951 +				// This plugin isn't suitable so just destroy it
   1.952 +				CleanupStack::PopAndDestroy(c);
   1.953 +				}
   1.954 +			}
   1.955 +		else if (error != KErrCorrupt)
   1.956 +			{
   1.957 +			// Ignore the plugin if it is corrupt.  Otherwise, leave.
   1.958 +			// if error !=KErrNone, c hasn't been constructed so it is safe to leave
   1.959 +			User::Leave(error);
   1.960 +			}
   1.961 +		}
   1.962 +
   1.963 +	CleanupStack::PopAndDestroy();//ecomArray
   1.964 +	}
   1.965 +
   1.966 +void CMMFFormatPluginSelectionParameters::MatchImplementationToSelectParamsL(RMMFFormatImplInfoArray& aImplementations, const CMMFFormatImplementationInformation& aPlugin, TInt& aArrayPos) const
   1.967 +	{
   1.968 +	TBool suitable = EFalse;
   1.969 +
   1.970 +	// First, check whether the plugin supports the required play formats
   1.971 +	suitable = CheckFormatSupportL(aPlugin);
   1.972 +
   1.973 +	// Next, check for correct media id support
   1.974 +	if (suitable)
   1.975 +		suitable = CheckMediaIdSupportL(aPlugin);
   1.976 +
   1.977 +	// Finally, calculate the position the plugin should take in aImplementations depending on the preferred supplier and version number.
   1.978 +	if (suitable)
   1.979 +		aArrayPos = CheckPreferredSupplierL(aImplementations, aPlugin);
   1.980 +	else
   1.981 +		aArrayPos = -1;
   1.982 +	}
   1.983 +
   1.984 +TInt CMMFFormatPluginSelectionParameters::CheckPreferredSupplierL(RMMFFormatImplInfoArray& aImplementations, const CMMFFormatImplementationInformation& aPlugin) const
   1.985 +	{
   1.986 +	// Set the return value to indicated the plugin is not suitable.
   1.987 +	TBool pluginSuitable = EFalse;
   1.988 +	TBool needToPlaceInVersionOrder = EFalse;
   1.989 +
   1.990 +	switch (PreferredSupplierMatchType())
   1.991 +		{
   1.992 +	case ENoPreferredSupplierMatch:
   1.993 +		// No match, so suitable.
   1.994 +		pluginSuitable = ETrue;
   1.995 +		break;
   1.996 +	case EPreferredSupplierPluginsFirstInList:
   1.997 +		pluginSuitable = ETrue;
   1.998 +		if (aPlugin.SupportsSupplier(PreferredSupplier()))
   1.999 +			needToPlaceInVersionOrder = ETrue;
  1.1000 +		break;
  1.1001 +	case EOnlyPreferredSupplierPluginsReturned:
  1.1002 +		if (aPlugin.SupportsSupplier(PreferredSupplier()))
  1.1003 +			{
  1.1004 +			pluginSuitable = ETrue;
  1.1005 +			needToPlaceInVersionOrder = ETrue;
  1.1006 +			}
  1.1007 +		break;
  1.1008 +	default:
  1.1009 +		User::Leave(KErrNotSupported);
  1.1010 +		}
  1.1011 +
  1.1012 +
  1.1013 +	TInt arrayPos;
  1.1014 +
  1.1015 +	if (!pluginSuitable)
  1.1016 +		{
  1.1017 +		arrayPos = -1;
  1.1018 +		}
  1.1019 +	else
  1.1020 +		{
  1.1021 +		if (!needToPlaceInVersionOrder)
  1.1022 +			{
  1.1023 +			arrayPos = aImplementations.Count();
  1.1024 +			}
  1.1025 +		else
  1.1026 +			{
  1.1027 +			// Insert the plugin at the beginning of the array, in version order if possible.
  1.1028 +			// Make an assumption: if we've been asked for format support, then only plugins 
  1.1029 +			// that support the same format will be in the array - so ordering them by version
  1.1030 +			// will be meaningful.  Otherwise, there's no point.
  1.1031 +			if (iRequiredFormatSupport && (iRequiredFormatSupport->MatchDataType() != CMMFFormatSelectionParameters::EMatchAny))
  1.1032 +				{
  1.1033 +				// Put the plugin in version order at the beginning of the list
  1.1034 +
  1.1035 +				// Set aArrayPos to the end of the array in case this plugin has the lowest version number
  1.1036 +				arrayPos = aImplementations.Count();
  1.1037 +				// Cycle through aImplementations to find the first plugin with a version number LOWER than aPlugin
  1.1038 +				for (TInt i=0; i<aImplementations.Count(); i++)
  1.1039 +					{
  1.1040 +					CMMFFormatImplementationInformation* c = aImplementations[i];
  1.1041 +					if ((c->Supplier() == aPlugin.Supplier())
  1.1042 +						&& (c->Version() <= aPlugin.Version()))
  1.1043 +						{
  1.1044 +						arrayPos = i;//plugin will be inserted before c in the array
  1.1045 +						break;
  1.1046 +						}
  1.1047 +					}
  1.1048 +				}
  1.1049 +			else
  1.1050 +				{
  1.1051 +				// We can't use the version numbers meaningfully, so just put this plugin
  1.1052 +				// at the top of the list.
  1.1053 +				arrayPos = 0;
  1.1054 +				}
  1.1055 +			}
  1.1056 +		}
  1.1057 +	return arrayPos;
  1.1058 +	}
  1.1059 +
  1.1060 +TBool CMMFFormatPluginSelectionParameters::CheckFormatSupportL(const CMMFFormatImplementationInformation& aPlugin) const
  1.1061 +	{
  1.1062 +	// If iRequiredFormatSupport is NULL (ie no requirements set) then the plugin must be suitable!
  1.1063 +	if (iRequiredFormatSupport == NULL)
  1.1064 +		return ETrue;
  1.1065 +
  1.1066 +	TBool suitable = EFalse;
  1.1067 +
  1.1068 +	switch (iRequiredFormatSupport->MatchDataType())
  1.1069 +		{
  1.1070 +	case CMMFFormatSelectionParameters::EMatchAny:
  1.1071 +		suitable = ETrue;
  1.1072 +		break;
  1.1073 +	case CMMFFormatSelectionParameters::EMatchFileExtension:
  1.1074 +		if (aPlugin.SupportsFileExtension(iRequiredFormatSupport->MatchData()))
  1.1075 +			suitable = ETrue;
  1.1076 +		break;
  1.1077 +	case CMMFFormatSelectionParameters::EMatchMimeType:
  1.1078 +		if (aPlugin.SupportsMimeType(iRequiredFormatSupport->MatchData()))
  1.1079 +			suitable = ETrue;
  1.1080 +		break;
  1.1081 +	case CMMFFormatSelectionParameters::EMatchHeaderData:
  1.1082 +		if (aPlugin.SupportsHeaderDataL(iRequiredFormatSupport->MatchData()))
  1.1083 +			suitable = ETrue;
  1.1084 +		break;
  1.1085 +	default:
  1.1086 +		User::Leave(KErrNotSupported);
  1.1087 +		};
  1.1088 +
  1.1089 +	return suitable;
  1.1090 +	}
  1.1091 +
  1.1092 +
  1.1093 +EXPORT_C CMMFFormatEncodePluginSelectionParameters* CMMFFormatEncodePluginSelectionParameters::NewL()
  1.1094 +	{
  1.1095 +	CMMFFormatEncodePluginSelectionParameters* s = CMMFFormatEncodePluginSelectionParameters::NewLC();
  1.1096 +	CleanupStack::Pop(s);
  1.1097 +	return s;
  1.1098 +	}
  1.1099 +
  1.1100 +EXPORT_C CMMFFormatEncodePluginSelectionParameters* CMMFFormatEncodePluginSelectionParameters::NewLC()
  1.1101 +	{
  1.1102 +	CMMFFormatEncodePluginSelectionParameters* s = new(ELeave) CMMFFormatEncodePluginSelectionParameters;
  1.1103 +	CleanupStack::PushL(s);
  1.1104 +	return s;
  1.1105 +	}
  1.1106 +
  1.1107 +CMMFFormatEncodePluginSelectionParameters::CMMFFormatEncodePluginSelectionParameters() :
  1.1108 +	CMMFFormatPluginSelectionParameters(KUidInterfaceFormatEncode)
  1.1109 +	{
  1.1110 +	}
  1.1111 +
  1.1112 +
  1.1113 +EXPORT_C CMMFFormatDecodePluginSelectionParameters* CMMFFormatDecodePluginSelectionParameters::NewL()
  1.1114 +	{
  1.1115 +	CMMFFormatDecodePluginSelectionParameters* s = CMMFFormatDecodePluginSelectionParameters::NewLC();
  1.1116 +	CleanupStack::Pop(s);
  1.1117 +	return s;
  1.1118 +	}
  1.1119 +
  1.1120 +EXPORT_C CMMFFormatDecodePluginSelectionParameters* CMMFFormatDecodePluginSelectionParameters::NewLC()
  1.1121 +	{
  1.1122 +	CMMFFormatDecodePluginSelectionParameters* s = new(ELeave) CMMFFormatDecodePluginSelectionParameters;
  1.1123 +	CleanupStack::PushL(s);
  1.1124 +	return s;
  1.1125 +	}
  1.1126 +
  1.1127 +CMMFFormatDecodePluginSelectionParameters::CMMFFormatDecodePluginSelectionParameters() :
  1.1128 +	CMMFFormatPluginSelectionParameters(KUidInterfaceFormatDecode)
  1.1129 +	{
  1.1130 +	}
  1.1131 +
  1.1132 +
  1.1133 +
  1.1134 +
  1.1135 +
  1.1136 +void TaggedDataParser::ParseTaggedDataL(const TDesC8& aData, MTaggedDataParserClient& aClient)
  1.1137 +	{
  1.1138 +	TPtrC8 data(aData);
  1.1139 +	TInt readPosition = 0;
  1.1140 +	TBool moreData = data.Length() ? ETrue : EFalse;
  1.1141 +	while (moreData)
  1.1142 +		{
  1.1143 +		// Assumes that this segment will begin with a tag
  1.1144 +		TPtrC8 restOfData = data.Mid(readPosition);
  1.1145 +
  1.1146 +		TInt endPos = restOfData.MatchF(KTagMatch);
  1.1147 +		if (endPos == KErrNotFound)
  1.1148 +			User::Leave(KErrCorrupt);
  1.1149 +
  1.1150 +		// extract the tag
  1.1151 +		TPtrC8 tag = restOfData.Left(KTagLength);
  1.1152 +		
  1.1153 +	
  1.1154 +		readPosition += KTagLength;
  1.1155 +
  1.1156 +		// Find the next tag
  1.1157 +		restOfData.Set(data.Mid(readPosition));
  1.1158 +		endPos = restOfData.MatchF(KTagMatch);
  1.1159 +
  1.1160 +		TPtrC8 tagData;
  1.1161 +		if (endPos == KErrNotFound)
  1.1162 +			{
  1.1163 +			// If we didn't find a tag, we must be at the end of the data
  1.1164 +			tagData.Set(restOfData);
  1.1165 +			readPosition = restOfData.Length();
  1.1166 +			moreData = EFalse;
  1.1167 +			}
  1.1168 +		else
  1.1169 +			{
  1.1170 +			tagData.Set(restOfData.Left(endPos));
  1.1171 +			readPosition += endPos;
  1.1172 +			}
  1.1173 +
  1.1174 +		aClient.ProcessTaggedDataL(tag, tagData);		
  1.1175 +		}
  1.1176 +	}
  1.1177 +
  1.1178 +void TaggedDataParser::ConvertTextToUidL(const TDesC8& aData, TUid& aUid)
  1.1179 +	{
  1.1180 +	// Make sure aData is in the correct format - "0x12345678"
  1.1181 +	_LIT8(K0x, "0x");
  1.1182 +	_LIT8(K0X, "0X");
  1.1183 +	if ((aData.Length() == 10) && ((aData.FindF(K0x) == 0) || (aData.FindF(K0X) == 0)))
  1.1184 +		{
  1.1185 +		// only take the right 8 characters (ie discard the "0x")
  1.1186 +		TLex8 lex(aData.Right(8));
  1.1187 +		TUint32 value = 0;
  1.1188 +		User::LeaveIfError(lex.Val(value, EHex));
  1.1189 +		aUid.iUid = value;
  1.1190 +		}
  1.1191 +	else
  1.1192 +		User::Leave(KErrCorrupt);
  1.1193 +	}
  1.1194 +
  1.1195 +
  1.1196 +void TaggedDataParser::ConvertTextToTUintL(const TDesC8& aData, TUint& aUint)
  1.1197 +	{
  1.1198 +	// Determine whether hex or decimal then parse as such
  1.1199 +	_LIT8(K0x, "0x");
  1.1200 +	_LIT8(K0X, "0X");
  1.1201 +	if (((aData.FindF(K0x) == 0) || (aData.FindF(K0X) == 0)) && (aData.Length() >= 3))
  1.1202 +		{
  1.1203 +		// only take the characters after "0x"
  1.1204 +		TLex8 lex(aData.Right(aData.Length()-2));
  1.1205 +		TUint32 value = 0;
  1.1206 +		User::LeaveIfError(lex.Val(value, EHex));
  1.1207 +		aUint = value;
  1.1208 +		}
  1.1209 +	else if (aData.Length() > 0)
  1.1210 +		{
  1.1211 +		TLex8 lex(aData.Right(aData.Length()));
  1.1212 +		TUint32 value = 0;
  1.1213 +		User::LeaveIfError(lex.Val(value, EDecimal));
  1.1214 +		aUint = value;
  1.1215 +		}
  1.1216 +	else
  1.1217 +		User::Leave(KErrCorrupt);
  1.1218 +	}
  1.1219 +
  1.1220 +
  1.1221 +EXPORT_C TBool CMMFPluginImplementationInformation::SupportsSupplier(const TDesC& aSupplier) const
  1.1222 +	{
  1.1223 +	if (iSupplier)
  1.1224 +		{
  1.1225 +		if (aSupplier.CompareF(*iSupplier) == KErrNone)
  1.1226 +			return ETrue;
  1.1227 +		}
  1.1228 +	return EFalse;
  1.1229 +	}
  1.1230 +
  1.1231 +EXPORT_C TBool CMMFPluginImplementationInformation::SupportsMediaId(TUid aMediaId) const
  1.1232 +	{
  1.1233 +	TInt location = iMediaIds.Find(aMediaId);
  1.1234 +	return (location != KErrNotFound);
  1.1235 +	}
  1.1236 +	
  1.1237 +EXPORT_C TUid CMMFPluginImplementationInformation::Uid() const
  1.1238 +	{
  1.1239 +	return iUid;
  1.1240 +	}
  1.1241 +
  1.1242 +EXPORT_C const TDesC& CMMFPluginImplementationInformation::DisplayName() const
  1.1243 +	{
  1.1244 +	if (iDisplayName)
  1.1245 +		return *iDisplayName;
  1.1246 +	else
  1.1247 +		return KNullDesC;
  1.1248 +	}
  1.1249 +
  1.1250 +EXPORT_C const TDesC& CMMFPluginImplementationInformation::Supplier() const
  1.1251 +	{
  1.1252 +	if (iSupplier)
  1.1253 +		return *iSupplier;
  1.1254 +	else
  1.1255 +		return KNullDesC;
  1.1256 +	}
  1.1257 +
  1.1258 +EXPORT_C TInt CMMFPluginImplementationInformation::Version() const
  1.1259 +	{
  1.1260 +	return iVersion;
  1.1261 +	}
  1.1262 +	
  1.1263 +EXPORT_C const RArray<TUid>& CMMFPluginImplementationInformation::SupportedMediaIds() const
  1.1264 +	{
  1.1265 +	return iMediaIds;
  1.1266 +	}
  1.1267 +
  1.1268 +CMMFPluginImplementationInformation::~CMMFPluginImplementationInformation()
  1.1269 +	{
  1.1270 +	delete iDisplayName;
  1.1271 +	delete iSupplier;
  1.1272 +	iMediaIds.Close();
  1.1273 +	}
  1.1274 +
  1.1275 +
  1.1276 +CMMFPluginImplementationInformation::CMMFPluginImplementationInformation()
  1.1277 +	{
  1.1278 +	}
  1.1279 +
  1.1280 +void CMMFPluginImplementationInformation::SetSupplierL(const TDesC8& aData)
  1.1281 +	{
  1.1282 +	delete iSupplier;
  1.1283 +	iSupplier = NULL;
  1.1284 +	// Convert aData to unicode...
  1.1285 +	iSupplier = HBufC::NewL(aData.Length());
  1.1286 +	TPtr ptr = iSupplier->Des();
  1.1287 +	User::LeaveIfError(CnvUtfConverter::ConvertToUnicodeFromUtf8(ptr, aData));
  1.1288 +	}
  1.1289 +
  1.1290 +void CMMFPluginImplementationInformation::AddMediaIdL(const TDesC8& aData)
  1.1291 +	{
  1.1292 +	TUid mediaId;
  1.1293 +	TaggedDataParser::ConvertTextToUidL(aData, mediaId);
  1.1294 +	User::LeaveIfError(iMediaIds.Append(mediaId));
  1.1295 +	}
  1.1296 +
  1.1297 +CMMFControllerImplementationInformation* CMMFControllerImplementationInformation::NewL(const CImplementationInformation& aImplInfo)
  1.1298 +	{
  1.1299 +	CMMFControllerImplementationInformation* s = CMMFControllerImplementationInformation::NewLC(aImplInfo);
  1.1300 +	CleanupStack::Pop(s);
  1.1301 +	return s;
  1.1302 +	}
  1.1303 +
  1.1304 +CMMFControllerImplementationInformation* CMMFControllerImplementationInformation::NewLC(const CImplementationInformation& aImplInfo)
  1.1305 +	{
  1.1306 +	CMMFControllerImplementationInformation* s = new(ELeave) CMMFControllerImplementationInformation;
  1.1307 +	CleanupStack::PushL(s);
  1.1308 +	s->ConstructL(aImplInfo);
  1.1309 +	return s;
  1.1310 +	}
  1.1311 +	
  1.1312 +EXPORT_C CMMFControllerImplementationInformation* CMMFControllerImplementationInformation::NewL(TUid aUid)
  1.1313 +	{
  1.1314 +	RImplInfoPtrArray ecomArray;
  1.1315 +	CleanupResetAndDestroyPushL(ecomArray);
  1.1316 +	
  1.1317 +	MmPluginUtils::FindImplementationsL(KUidInterfaceMMFController, ecomArray);
  1.1318 +
  1.1319 +	TInt index;
  1.1320 +	CMMFControllerImplementationInformation* controller = NULL;
  1.1321 +	// Create Controller Implementation Information for the entry with the requested UID
  1.1322 +	for (index=0; index<ecomArray.Count() && (controller==NULL); index++)
  1.1323 +		{
  1.1324 +		if (ecomArray[index] == NULL)
  1.1325 +			{
  1.1326 +			User::Leave(KErrNoMemory);
  1.1327 +			}
  1.1328 +			
  1.1329 +		if (ecomArray[index]->ImplementationUid()==aUid)
  1.1330 +			{
  1.1331 +			// Create the impl info object, and get the play and record formats supported by the plugin
  1.1332 +			controller = CMMFControllerImplementationInformation::NewL(*(ecomArray[index]));
  1.1333 +
  1.1334 +			CleanupStack::PushL(controller); // INC023207 - Placed controller on CleanupStack
  1.1335 +			controller->GetPlayFormatsL();
  1.1336 +			controller->GetRecordFormatsL(); // INC023207
  1.1337 +			CleanupStack::Pop();
  1.1338 +			}
  1.1339 +		}
  1.1340 +
  1.1341 +	if (controller == NULL)
  1.1342 +		{
  1.1343 +		User::Leave(KErrNotFound);
  1.1344 +		}
  1.1345 +	
  1.1346 +	CleanupStack::PopAndDestroy(); // ecomArray
  1.1347 +	return controller;	
  1.1348 +	}
  1.1349 +
  1.1350 +EXPORT_C const RMMFFormatImplInfoArray& CMMFControllerImplementationInformation::PlayFormats() const
  1.1351 +	{
  1.1352 +	return iPlayFormats;
  1.1353 +	}
  1.1354 +
  1.1355 +EXPORT_C const RMMFFormatImplInfoArray& CMMFControllerImplementationInformation::RecordFormats() const
  1.1356 +	{
  1.1357 +	return iRecordFormats;
  1.1358 +	}
  1.1359 +
  1.1360 +
  1.1361 +EXPORT_C TUint CMMFControllerImplementationInformation::HeapSpaceRequired() const
  1.1362 +	{
  1.1363 +	return iHeapSpaceRequired;
  1.1364 +	}
  1.1365 +
  1.1366 +EXPORT_C TUint CMMFControllerImplementationInformation::StackSize() const
  1.1367 +	{
  1.1368 +	return iStackSize;
  1.1369 +	}
  1.1370 +/**
  1.1371 +	@publishedPartner
  1.1372 +	@prototype
  1.1373 +	
  1.1374 +	Returns the uri schemes of this plugin.
  1.1375 +
  1.1376 +	@return The array of uri schemes.
  1.1377 +*/
  1.1378 +EXPORT_C const CDesC8Array& CMMFControllerImplementationInformation::SupportedUriSchemes() const  
  1.1379 +	{
  1.1380 +	return *iUriSchemes;
  1.1381 +	}
  1.1382 +
  1.1383 +/**
  1.1384 +	@publishedPartner
  1.1385 +	@prototype
  1.1386 +	
  1.1387 +	Tests whether the plugin supports aUriScheme.
  1.1388 +	
  1.1389 +	@param  aUriScheme
  1.1390 +	        The required Uri Scheme.
  1.1391 +
  1.1392 +	@return A boolean indicating if the plugin supports aUriScheme. ETrue if this plugin supports aUriScheme, EFalse if not.
  1.1393 +*/
  1.1394 +EXPORT_C TBool CMMFControllerImplementationInformation::SupportsUriScheme(const TDesC8& aUriScheme) const
  1.1395 +  	{
  1.1396 +  	TInt position;
  1.1397 +  	TInt error = iUriSchemes->FindIsq(aUriScheme, position, ECmpFolded);
  1.1398 +  	return (error==KErrNone);
  1.1399 +  	}
  1.1400 +	
  1.1401 +/**
  1.1402 +	@publishedPartner
  1.1403 +	@prototype
  1.1404 +
  1.1405 +	Sets the uri priority of this controller
  1.1406 +
  1.1407 +	@param  aUriPriority
  1.1408 +	        The Uri priority to be assigned.
  1.1409 +*/
  1.1410 +EXPORT_C void CMMFControllerImplementationInformation::SetUriPriority(TInt aUriPriority)
  1.1411 +	{
  1.1412 +	iUriPriority = aUriPriority;
  1.1413 +	}
  1.1414 +
  1.1415 +/**
  1.1416 +	@publishedPartner
  1.1417 +	@prototype
  1.1418 +	
  1.1419 +	Retrieves the uri priority of this controller
  1.1420 +	
  1.1421 +	@return  The assigned Uri priority.
  1.1422 +*/
  1.1423 +EXPORT_C TInt CMMFControllerImplementationInformation::UriPriority() const
  1.1424 +	{
  1.1425 +	return iUriPriority;
  1.1426 +	}
  1.1427 +
  1.1428 +/**
  1.1429 +	@publishedPartner
  1.1430 +	@prototype
  1.1431 +	
  1.1432 +	Tests whether the controller plugin supports url
  1.1433 +		
  1.1434 +	@return A boolean indicating if the plugin supports url. ETrue for uri supporting controller, EFalse if not.
  1.1435 +*/
  1.1436 +EXPORT_C TBool CMMFControllerImplementationInformation::SupportsNetworkCapability() const
  1.1437 +	{
  1.1438 +	return iIsNetworkCtrl;
  1.1439 +	}
  1.1440 +
  1.1441 +/**
  1.1442 +	@publishedPartner
  1.1443 +	@prototype
  1.1444 +	
  1.1445 +	Check whether the controller plugin supports secure DRM process mode
  1.1446 +	
  1.1447 +	@return  A boolean indicating if the plugin supports secure DRM process mode. 
  1.1448 +*/
  1.1449 +EXPORT_C TBool CMMFControllerImplementationInformation::SupportsSecureDRMProcessMode() const
  1.1450 +	{
  1.1451 +	return iSupportsSecureDRMProcessMode;
  1.1452 +	}
  1.1453 +
  1.1454 +CMMFControllerImplementationInformation::CMMFControllerImplementationInformation()
  1.1455 +	{
  1.1456 +	iUriPriority = KUriPriorityNone;
  1.1457 +	iIsNetworkCtrl = ETrue;
  1.1458 +	iPlayFormatCollectionUid = KNullUid;
  1.1459 +	iRecordFormatCollectionUid = KNullUid;
  1.1460 +	iHeapSpaceRequired = KMMFDefaultControllerThreadHeapSize;
  1.1461 +	iSupportsSecureDRMProcessMode = EFalse;
  1.1462 +	iStackSize = KDefaultStackSize;
  1.1463 +	}
  1.1464 +
  1.1465 +void CMMFControllerImplementationInformation::ConstructL(const CImplementationInformation& aImplInfo)
  1.1466 +	{
  1.1467 +	iUriSchemes = new(ELeave) CDesC8ArrayFlat(KDesCArrayGranularity);
  1.1468 +	iUid = aImplInfo.ImplementationUid();
  1.1469 +	iDisplayName = aImplInfo.DisplayName().AllocL();
  1.1470 +	iVersion = aImplInfo.Version();
  1.1471 +
  1.1472 +	// Parse the opaque data...
  1.1473 +	TaggedDataParser::ParseTaggedDataL(aImplInfo.OpaqueData(), *this);
  1.1474 +	}
  1.1475 +
  1.1476 +void CMMFControllerImplementationInformation::ProcessTaggedDataL(const TDesC8& aTag, const TDesC8& aData)
  1.1477 +	{
  1.1478 +	if (aTag==KSupplier)
  1.1479 +		{
  1.1480 +		SetSupplierL(aData);
  1.1481 +		}
  1.1482 +	else if (aTag==KMediaId)
  1.1483 +		{
  1.1484 +		AddMediaIdL(aData);
  1.1485 +		}
  1.1486 +	else if (aTag==KUriScheme)
  1.1487 +		{
  1.1488 +		SetUriSchemeL(aData);
  1.1489 +		}
  1.1490 +	else if (aTag==KNonNetwork)
  1.1491 +		{
  1.1492 +		SetNetworkCapabilityL(aData);
  1.1493 +		}
  1.1494 +	else if (aTag==KPlayFormatCollectionUid)
  1.1495 +		{
  1.1496 +		SetPlayFormatCollectionUidL(aData);
  1.1497 +		}
  1.1498 +	else if (aTag==KRecordFormatCollectionUid)
  1.1499 +		{
  1.1500 +		SetRecordFormatCollectionUidL(aData);
  1.1501 +		}
  1.1502 +	else if(aTag==KHeapSize)
  1.1503 +		{
  1.1504 +		SetHeapSizeL(aData);
  1.1505 +		}
  1.1506 +	else if (aTag==KSecureDRMProcessMode)
  1.1507 +		{
  1.1508 +		iSupportsSecureDRMProcessMode = ETrue;
  1.1509 +		}
  1.1510 +	else if (aTag==KStackSize)
  1.1511 +		{
  1.1512 +		SetStackSizeL(aData);
  1.1513 +		}
  1.1514 +	else
  1.1515 +		{
  1.1516 +		User::Leave(KErrCorrupt);
  1.1517 +		}
  1.1518 +	}
  1.1519 +
  1.1520 +
  1.1521 +CMMFControllerImplementationInformation::~CMMFControllerImplementationInformation()
  1.1522 +	{
  1.1523 +	iPlayFormats.ResetAndDestroy();
  1.1524 +	iRecordFormats.ResetAndDestroy();
  1.1525 +	delete iUriSchemes;
  1.1526 +	}
  1.1527 +
  1.1528 +
  1.1529 +void CMMFControllerImplementationInformation::SetPlayFormatCollectionUidL(const TDesC8& aData)
  1.1530 +	{
  1.1531 +	TaggedDataParser::ConvertTextToUidL(aData, iPlayFormatCollectionUid);
  1.1532 +	}
  1.1533 +
  1.1534 +void CMMFControllerImplementationInformation::SetRecordFormatCollectionUidL(const TDesC8& aData)
  1.1535 +	{
  1.1536 +	TaggedDataParser::ConvertTextToUidL(aData, iRecordFormatCollectionUid);
  1.1537 +	}
  1.1538 +
  1.1539 +void CMMFControllerImplementationInformation::SetHeapSizeL(const TDesC8& aData)
  1.1540 +	{
  1.1541 +	TaggedDataParser::ConvertTextToTUintL(aData, iHeapSpaceRequired);
  1.1542 +	}
  1.1543 +
  1.1544 +void CMMFControllerImplementationInformation::SetStackSizeL(const TDesC8& aData)
  1.1545 +	{
  1.1546 +	TaggedDataParser::ConvertTextToTUintL(aData, iStackSize);
  1.1547 +	}
  1.1548 +
  1.1549 +
  1.1550 +void CMMFControllerImplementationInformation::AddFormatsSwallowCorruptL(RImplInfoPtrArray& aEcomArray, RMMFFormatImplInfoArray& aFormatArray)
  1.1551 +	{
  1.1552 +	for (TInt index=0; index<aEcomArray.Count(); index++)
  1.1553 +		{
  1.1554 +		CMMFFormatImplementationInformation* c = NULL;
  1.1555 +		TRAPD(error, c = CMMFFormatImplementationInformation::NewL(*(aEcomArray[index])));
  1.1556 +		if (error==KErrNone)
  1.1557 +			{
  1.1558 +			CleanupStack::PushL(c);
  1.1559 +			User::LeaveIfError(aFormatArray.Append(c));
  1.1560 +			CleanupStack::Pop(c);
  1.1561 +			}
  1.1562 +		else if (error != KErrCorrupt)// make sure we don't leave because of a corrupt resource file
  1.1563 +			User::Leave(error);
  1.1564 +		}
  1.1565 +	}
  1.1566 +
  1.1567 +
  1.1568 +void CMMFControllerImplementationInformation::GetFormatsL(TUid aFormatCollectionUid, TUid aFormatPluginCollectionUid, RMMFFormatImplInfoArray& aFormatArray)
  1.1569 +	{
  1.1570 +	RImplInfoPtrArray ecomArray;
  1.1571 +	CleanupResetAndDestroyPushL(ecomArray);
  1.1572 +	// If we have a valid play format collection uid, get the play formats defined by this plugin
  1.1573 +	if (aFormatCollectionUid != KNullUid)
  1.1574 +		{
  1.1575 +		MmPluginUtils::FindImplementationsL(aFormatCollectionUid, ecomArray);
  1.1576 +		// Create format implementation information for each entry
  1.1577 +		AddFormatsSwallowCorruptL(ecomArray, aFormatArray);
  1.1578 +		}
  1.1579 +
  1.1580 +	// Now get all the format plugins attached to this controller
  1.1581 +
  1.1582 +	// Create a descriptor and fill it with the uid of this controller plugin
  1.1583 +	TBuf8<10> controllerUid;
  1.1584 +	_LIT8(K0x, "0x");
  1.1585 +	controllerUid.Append(K0x);
  1.1586 +	controllerUid.AppendNumFixedWidth(iUid.iUid, EHex, 8);
  1.1587 +
  1.1588 +	MmPluginUtils::FindImplementationsL(aFormatPluginCollectionUid, ecomArray, controllerUid);
  1.1589 +	// Create format implementation information for each entry
  1.1590 +	AddFormatsSwallowCorruptL(ecomArray, aFormatArray);
  1.1591 +
  1.1592 +	CleanupStack::PopAndDestroy();//ecomArray
  1.1593 +	}
  1.1594 +
  1.1595 +void CMMFControllerImplementationInformation::GetPlayFormatsL()
  1.1596 +	{
  1.1597 +	GetFormatsL(iPlayFormatCollectionUid, KUidInterfaceFormatDecode, iPlayFormats);
  1.1598 +	}
  1.1599 +
  1.1600 +void CMMFControllerImplementationInformation::GetRecordFormatsL()
  1.1601 +	{
  1.1602 +	GetFormatsL(iRecordFormatCollectionUid, KUidInterfaceFormatEncode, iRecordFormats);
  1.1603 +	}
  1.1604 +
  1.1605 +/**
  1.1606 +	Sets the Uri Scheme found in opaque data
  1.1607 +	
  1.1608 +	@param  aUriScheme
  1.1609 +			Gives the uri scheme supported by the controller
  1.1610 +*/
  1.1611 +void CMMFControllerImplementationInformation::SetUriSchemeL(const TDesC8& aUriScheme)
  1.1612 +	{
  1.1613 +	//If No uri support already declared in the resource file, 
  1.1614 +	//then mentioning a particular schema support is illegal
  1.1615 +	if(!iIsNetworkCtrl)
  1.1616 +		{
  1.1617 +		User::Leave(KErrArgument);
  1.1618 +		}
  1.1619 +	
  1.1620 +	// Insert the new uri scheme into the array	
  1.1621 +	iUriSchemes->InsertIsqL(aUriScheme, ECmpFolded);//ensures there are no repeated entries
  1.1622 +	}
  1.1623 +
  1.1624 +/**
  1.1625 +	Sets the Network capability found in opaque data
  1.1626 +	
  1.1627 +	@param  aNetworkCapable
  1.1628 +			Declares the incapability to support uri if matches to 'yes'. 
  1.1629 +			If this is the case, iIsNetworkCtrl is set to EFalse
  1.1630 +*/
  1.1631 +void CMMFControllerImplementationInformation::SetNetworkCapabilityL(const TDesC8& aNetworkCapable)
  1.1632 +	{
  1.1633 +	//If a uri scheme is already declared in the resource file, 
  1.1634 +	//then mentioning no url support is illegal
  1.1635 +	if(iUriSchemes->Count() > 0)
  1.1636 +		{
  1.1637 +		User::Leave(KErrArgument);
  1.1638 +		}
  1.1639 +		
  1.1640 +	if (aNetworkCapable.CompareF(KTagYes) == KErrNone)
  1.1641 +		{
  1.1642 +		iIsNetworkCtrl = EFalse;
  1.1643 +		}
  1.1644 +	else
  1.1645 +		{
  1.1646 +		User::Leave(KErrBadName); // will leave if aNetworkCapable is anything other than 'yes'.
  1.1647 +		}
  1.1648 +	}
  1.1649 +
  1.1650 +
  1.1651 +
  1.1652 +
  1.1653 +CMMFFormatImplementationInformation* CMMFFormatImplementationInformation::NewL(const CImplementationInformation& aImplInfo)
  1.1654 +	{
  1.1655 +	CMMFFormatImplementationInformation* s = CMMFFormatImplementationInformation::NewLC(aImplInfo);
  1.1656 +	CleanupStack::Pop(s);
  1.1657 +	return s;
  1.1658 +	}
  1.1659 +
  1.1660 +CMMFFormatImplementationInformation* CMMFFormatImplementationInformation::NewLC(const CImplementationInformation& aImplInfo)
  1.1661 +	{
  1.1662 +	CMMFFormatImplementationInformation* s = new(ELeave) CMMFFormatImplementationInformation();
  1.1663 +	CleanupStack::PushL(s);
  1.1664 +	s->ConstructL(aImplInfo);
  1.1665 +	return s;
  1.1666 +	}
  1.1667 +
  1.1668 +CMMFFormatImplementationInformation::CMMFFormatImplementationInformation()
  1.1669 +	{
  1.1670 +	}
  1.1671 +
  1.1672 +void CMMFFormatImplementationInformation::ConstructL(const CImplementationInformation& aImplInfo)
  1.1673 +	{
  1.1674 +	iUid = aImplInfo.ImplementationUid();
  1.1675 +	iDisplayName = aImplInfo.DisplayName().AllocL();
  1.1676 +
  1.1677 +	iBody = CMMFFormatImplementationInformation::CBody::NewL();
  1.1678 +
  1.1679 +	// Extract the rest of the data from the opaque data field of aImplInfo...
  1.1680 +	// Parse the opaque data...
  1.1681 +	TaggedDataParser::ParseTaggedDataL(aImplInfo.OpaqueData(), *this);
  1.1682 +	}
  1.1683 +
  1.1684 +void CMMFFormatImplementationInformation::ProcessTaggedDataL(const TDesC8& aTag, const TDesC8& aTagData)
  1.1685 +	{
  1.1686 +	if (aTag == KSupplier)
  1.1687 +		SetSupplierL(aTagData);
  1.1688 +	else if (aTag == KMediaId)
  1.1689 +		AddMediaIdL(aTagData);
  1.1690 +	else if (aTag == KFormatFileExtension)
  1.1691 +		AddFileExtensionL(aTagData);
  1.1692 +	else if (aTag == KFormatMimeType)
  1.1693 +		AddMimeTypeL(aTagData);
  1.1694 +	else if (aTag == KFormatHeaderData)
  1.1695 +		AddHeaderDataL(aTagData);
  1.1696 +	else if ((aTag == KCustomInterfaceSupport) && (aTagData.CompareF(KTagYes) == 0))
  1.1697 +		iBody->SetSupportsCustomInterfaces(ETrue);
  1.1698 +	else
  1.1699 +		User::Leave(KErrCorrupt);
  1.1700 +	}
  1.1701 +
  1.1702 +void CMMFFormatImplementationInformation::AddFileExtensionL(const TDesC8& aData)
  1.1703 +	{
  1.1704 +	iBody->AddFileExtensionL(aData);
  1.1705 +	}
  1.1706 +
  1.1707 +void CMMFFormatImplementationInformation::AddMimeTypeL(const TDesC8& aData)
  1.1708 +	{
  1.1709 +	iBody->AddMimeTypeL(aData);
  1.1710 +	}
  1.1711 +
  1.1712 +void CMMFFormatImplementationInformation::AddHeaderDataL(const TDesC8& aData)
  1.1713 +	{
  1.1714 +	iBody->AddHeaderDataL(aData);
  1.1715 +	}
  1.1716 +
  1.1717 +CMMFFormatImplementationInformation::~CMMFFormatImplementationInformation()
  1.1718 +	{
  1.1719 +	delete iBody;
  1.1720 +	}
  1.1721 +
  1.1722 +EXPORT_C const CDesC8Array& CMMFFormatImplementationInformation::SupportedFileExtensions() const
  1.1723 +	{
  1.1724 +	return iBody->SupportedFileExtensions();
  1.1725 +	}
  1.1726 +
  1.1727 +EXPORT_C const CDesC8Array& CMMFFormatImplementationInformation::SupportedMimeTypes() const
  1.1728 +	{
  1.1729 +	return iBody->SupportedMimeTypes();
  1.1730 +	}
  1.1731 +
  1.1732 +EXPORT_C const CDesC8Array& CMMFFormatImplementationInformation::SupportedHeaderData() const
  1.1733 +	{
  1.1734 + 	return iBody->SupportedHeaderData();
  1.1735 +	}
  1.1736 +
  1.1737 +
  1.1738 +EXPORT_C TBool CMMFFormatImplementationInformation::SupportsFileExtension(const TDesC8& aFileExtension) const
  1.1739 +	{
  1.1740 +	return iBody->SupportsFileExtension(aFileExtension);
  1.1741 +	}
  1.1742 +
  1.1743 +EXPORT_C TBool CMMFFormatImplementationInformation::SupportsMimeType(const TDesC8& aMimeType) const
  1.1744 +	{
  1.1745 +	return iBody->SupportsMimeType(aMimeType);
  1.1746 +	}
  1.1747 +
  1.1748 +EXPORT_C TBool CMMFFormatImplementationInformation::SupportsHeaderDataL(const TDesC8& aHeaderData) const
  1.1749 +	{
  1.1750 +	return iBody->SupportsHeaderDataL(aHeaderData);
  1.1751 +	}
  1.1752 +
  1.1753 +EXPORT_C TBool CMMFFormatImplementationInformation::SupportsCustomInterfaces() const
  1.1754 +	{
  1.1755 +	return iBody->SupportsCustomInterfaces();
  1.1756 +	}
  1.1757 +
  1.1758 +CMatchData* CMatchData::CreateL()
  1.1759 +	{
  1.1760 +	return new (ELeave) CMatchData();
  1.1761 +	}
  1.1762 +	
  1.1763 +void CMatchData::SetMatchDataL(const TDesC8& aMatchData)
  1.1764 +	{
  1.1765 +	delete iMatchData;
  1.1766 +	iMatchData = NULL;
  1.1767 +		
  1.1768 +	iMatchData = aMatchData.AllocL();	
  1.1769 +	}
  1.1770 +
  1.1771 +void CMatchData::SetMatchUriSchemeL(const TDesC8& aMatchUriScheme)
  1.1772 +	{
  1.1773 +	delete iMatchUriScheme;
  1.1774 +	iMatchUriScheme = NULL;
  1.1775 +	
  1.1776 +	iMatchUriScheme = aMatchUriScheme.AllocL();	
  1.1777 +	}
  1.1778 +	
  1.1779 +const TDesC8& CMatchData::MatchData() const
  1.1780 +	{
  1.1781 +	if (iMatchData )
  1.1782 +		{
  1.1783 +		return *iMatchData;
  1.1784 +		}
  1.1785 +	else
  1.1786 +		{
  1.1787 +		return KNullDesC8;
  1.1788 +		}
  1.1789 +	}
  1.1790 +
  1.1791 +const TDesC8& CMatchData::MatchUriScheme() const
  1.1792 +	{
  1.1793 +	if (iMatchUriScheme )
  1.1794 +		{
  1.1795 +		return *iMatchUriScheme;
  1.1796 +		}
  1.1797 +	else
  1.1798 +		{
  1.1799 +		return KNullDesC8;
  1.1800 +		}
  1.1801 +	}
  1.1802 +
  1.1803 +CMatchData::~CMatchData()
  1.1804 +	{
  1.1805 +	delete iMatchData;
  1.1806 +	delete iMatchUriScheme;
  1.1807 +	}
  1.1808 +