First public contribution.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
20 #include "TestEComResolver.h"
22 CTestEComResolver* CTestEComResolver::NewL(MPublicRegistry& aRegistry)
24 return new(ELeave) CTestEComResolver(aRegistry);
27 CTestEComResolver::~CTestEComResolver()
29 if(iImplementationInfoArray)
31 iImplementationInfoArray->Reset();
32 delete iImplementationInfoArray;
36 CTestEComResolver::CTestEComResolver(MPublicRegistry& aRegistry)
37 : CResolver(aRegistry)
42 TUid CTestEComResolver::IdentifyImplementationL(
44 const TEComResolverParams& aAdditionalParameters
47 RImplInfoArray& fullList = iRegistry.ListImplementationsL(aInterfaceUid);
49 // Loop through the implementations matching on type
51 const TDesC8& matchType = aAdditionalParameters.DataType();
52 const TBool useWildcards = aAdditionalParameters.IsWildcardMatch();
53 const TInt count = fullList.Count();
54 for(TInt index = 0; (index<count) && (ret==KNullUid); ++index)
56 CImplementationInformation* impData = fullList[index];
57 // As soon as we get a match on the datatype then return uid of the
58 // implementation found.
59 if (Match(impData->DataType(), matchType, useWildcards))
61 ret=impData->ImplementationUid();
68 RImplInfoArray* CTestEComResolver::ListAllL(
70 const TEComResolverParams& aAdditionalParameters
73 // Use the member var to create the array so that we get proper cleanup behaviour
74 iImplementationInfoArray = new(ELeave) RImplInfoArray;
75 RImplInfoArray* retList = iImplementationInfoArray;
77 RImplInfoArray& fullList = iRegistry.ListImplementationsL(aInterfaceUid);
79 const TDesC8& matchType = aAdditionalParameters.DataType();
80 const TBool useWildcards = aAdditionalParameters.IsWildcardMatch();
81 const TInt numImps = fullList.Count();
82 for(TInt index = 0; index < numImps; ++index)
84 CImplementationInformation* impData = fullList[index];
85 if(Match(impData->DataType(), matchType, useWildcards))
87 User::LeaveIfError(retList->Append(impData));
91 // Reset the member variable because we are passing ownership back
92 iImplementationInfoArray = NULL;
96 TBool CTestEComResolver::Match(
97 const TDesC8& aImplementationType,
98 const TDesC8& aMatchType,
102 _LIT8(dataSeparator, "||");
103 const TInt separatorLength = dataSeparator().Length();
105 // Look for the section separator marker '||'
106 TPtrC8 remainingData = aImplementationType;
107 TInt separatorPos = remainingData.Find(dataSeparator);
108 TInt matchPos=KErrNotFound;
112 if (separatorPos==KErrNotFound)
114 dataSection.Set(remainingData);
118 dataSection.Set(remainingData.Left(separatorPos));
119 remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
123 matchPos=dataSection.Match(aMatchType);
127 matchPos=dataSection.Compare(aMatchType);
130 while ((separatorPos!=KErrNotFound) && (matchPos==KErrNotFound));
132 return matchPos!=KErrNotFound;