sl@0: /* sl@0: * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include "TestEComResolver.h" sl@0: sl@0: CTestEComResolver* CTestEComResolver::NewL(MPublicRegistry& aRegistry) sl@0: { sl@0: return new(ELeave) CTestEComResolver(aRegistry); sl@0: } sl@0: sl@0: CTestEComResolver::~CTestEComResolver() sl@0: { sl@0: if(iImplementationInfoArray) sl@0: { sl@0: iImplementationInfoArray->Reset(); sl@0: delete iImplementationInfoArray; sl@0: } sl@0: } sl@0: sl@0: CTestEComResolver::CTestEComResolver(MPublicRegistry& aRegistry) sl@0: : CResolver(aRegistry) sl@0: { sl@0: // Do nothing here sl@0: } sl@0: sl@0: TUid CTestEComResolver::IdentifyImplementationL( sl@0: TUid aInterfaceUid, sl@0: const TEComResolverParams& aAdditionalParameters sl@0: ) const sl@0: { sl@0: RImplInfoArray& fullList = iRegistry.ListImplementationsL(aInterfaceUid); sl@0: sl@0: // Loop through the implementations matching on type sl@0: TUid ret = KNullUid; sl@0: const TDesC8& matchType = aAdditionalParameters.DataType(); sl@0: const TBool useWildcards = aAdditionalParameters.IsWildcardMatch(); sl@0: const TInt count = fullList.Count(); sl@0: for(TInt index = 0; (indexDataType(), matchType, useWildcards)) sl@0: { sl@0: ret=impData->ImplementationUid(); sl@0: } sl@0: } sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: RImplInfoArray* CTestEComResolver::ListAllL( sl@0: TUid aInterfaceUid, sl@0: const TEComResolverParams& aAdditionalParameters sl@0: ) const sl@0: { sl@0: // Use the member var to create the array so that we get proper cleanup behaviour sl@0: iImplementationInfoArray = new(ELeave) RImplInfoArray; sl@0: RImplInfoArray* retList = iImplementationInfoArray; sl@0: sl@0: RImplInfoArray& fullList = iRegistry.ListImplementationsL(aInterfaceUid); sl@0: sl@0: const TDesC8& matchType = aAdditionalParameters.DataType(); sl@0: const TBool useWildcards = aAdditionalParameters.IsWildcardMatch(); sl@0: const TInt numImps = fullList.Count(); sl@0: for(TInt index = 0; index < numImps; ++index) sl@0: { sl@0: CImplementationInformation* impData = fullList[index]; sl@0: if(Match(impData->DataType(), matchType, useWildcards)) sl@0: { sl@0: User::LeaveIfError(retList->Append(impData)); sl@0: } sl@0: } sl@0: sl@0: // Reset the member variable because we are passing ownership back sl@0: iImplementationInfoArray = NULL; sl@0: return retList; sl@0: } sl@0: sl@0: TBool CTestEComResolver::Match( sl@0: const TDesC8& aImplementationType, sl@0: const TDesC8& aMatchType, sl@0: TBool aUseWildcards sl@0: ) const sl@0: { sl@0: _LIT8(dataSeparator, "||"); sl@0: const TInt separatorLength = dataSeparator().Length(); sl@0: sl@0: // Look for the section separator marker '||' sl@0: TPtrC8 remainingData = aImplementationType; sl@0: TInt separatorPos = remainingData.Find(dataSeparator); sl@0: TInt matchPos=KErrNotFound; sl@0: do sl@0: { sl@0: TPtrC8 dataSection; sl@0: if (separatorPos==KErrNotFound) sl@0: { sl@0: dataSection.Set(remainingData); sl@0: } sl@0: else sl@0: { sl@0: dataSection.Set(remainingData.Left(separatorPos)); sl@0: remainingData.Set(remainingData.Mid(separatorPos + separatorLength)); sl@0: } sl@0: if(aUseWildcards) sl@0: { sl@0: matchPos=dataSection.Match(aMatchType); sl@0: } sl@0: else sl@0: { sl@0: matchPos=dataSection.Compare(aMatchType); sl@0: } sl@0: } sl@0: while ((separatorPos!=KErrNotFound) && (matchPos==KErrNotFound)); sl@0: sl@0: return matchPos!=KErrNotFound; sl@0: }