sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
#include "TestEComResolver.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
CTestEComResolver* CTestEComResolver::NewL(MPublicRegistry& aRegistry)
|
sl@0
|
23 |
{
|
sl@0
|
24 |
return new(ELeave) CTestEComResolver(aRegistry);
|
sl@0
|
25 |
}
|
sl@0
|
26 |
|
sl@0
|
27 |
CTestEComResolver::~CTestEComResolver()
|
sl@0
|
28 |
{
|
sl@0
|
29 |
if(iImplementationInfoArray)
|
sl@0
|
30 |
{
|
sl@0
|
31 |
iImplementationInfoArray->Reset();
|
sl@0
|
32 |
delete iImplementationInfoArray;
|
sl@0
|
33 |
}
|
sl@0
|
34 |
}
|
sl@0
|
35 |
|
sl@0
|
36 |
CTestEComResolver::CTestEComResolver(MPublicRegistry& aRegistry)
|
sl@0
|
37 |
: CResolver(aRegistry)
|
sl@0
|
38 |
{
|
sl@0
|
39 |
// Do nothing here
|
sl@0
|
40 |
}
|
sl@0
|
41 |
|
sl@0
|
42 |
TUid CTestEComResolver::IdentifyImplementationL(
|
sl@0
|
43 |
TUid aInterfaceUid,
|
sl@0
|
44 |
const TEComResolverParams& aAdditionalParameters
|
sl@0
|
45 |
) const
|
sl@0
|
46 |
{
|
sl@0
|
47 |
RImplInfoArray& fullList = iRegistry.ListImplementationsL(aInterfaceUid);
|
sl@0
|
48 |
|
sl@0
|
49 |
// Loop through the implementations matching on type
|
sl@0
|
50 |
TUid ret = KNullUid;
|
sl@0
|
51 |
const TDesC8& matchType = aAdditionalParameters.DataType();
|
sl@0
|
52 |
const TBool useWildcards = aAdditionalParameters.IsWildcardMatch();
|
sl@0
|
53 |
const TInt count = fullList.Count();
|
sl@0
|
54 |
for(TInt index = 0; (index<count) && (ret==KNullUid); ++index)
|
sl@0
|
55 |
{
|
sl@0
|
56 |
CImplementationInformation* impData = fullList[index];
|
sl@0
|
57 |
// As soon as we get a match on the datatype then return uid of the
|
sl@0
|
58 |
// implementation found.
|
sl@0
|
59 |
if (Match(impData->DataType(), matchType, useWildcards))
|
sl@0
|
60 |
{
|
sl@0
|
61 |
ret=impData->ImplementationUid();
|
sl@0
|
62 |
}
|
sl@0
|
63 |
}
|
sl@0
|
64 |
|
sl@0
|
65 |
return ret;
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
RImplInfoArray* CTestEComResolver::ListAllL(
|
sl@0
|
69 |
TUid aInterfaceUid,
|
sl@0
|
70 |
const TEComResolverParams& aAdditionalParameters
|
sl@0
|
71 |
) const
|
sl@0
|
72 |
{
|
sl@0
|
73 |
// Use the member var to create the array so that we get proper cleanup behaviour
|
sl@0
|
74 |
iImplementationInfoArray = new(ELeave) RImplInfoArray;
|
sl@0
|
75 |
RImplInfoArray* retList = iImplementationInfoArray;
|
sl@0
|
76 |
|
sl@0
|
77 |
RImplInfoArray& fullList = iRegistry.ListImplementationsL(aInterfaceUid);
|
sl@0
|
78 |
|
sl@0
|
79 |
const TDesC8& matchType = aAdditionalParameters.DataType();
|
sl@0
|
80 |
const TBool useWildcards = aAdditionalParameters.IsWildcardMatch();
|
sl@0
|
81 |
const TInt numImps = fullList.Count();
|
sl@0
|
82 |
for(TInt index = 0; index < numImps; ++index)
|
sl@0
|
83 |
{
|
sl@0
|
84 |
CImplementationInformation* impData = fullList[index];
|
sl@0
|
85 |
if(Match(impData->DataType(), matchType, useWildcards))
|
sl@0
|
86 |
{
|
sl@0
|
87 |
User::LeaveIfError(retList->Append(impData));
|
sl@0
|
88 |
}
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
// Reset the member variable because we are passing ownership back
|
sl@0
|
92 |
iImplementationInfoArray = NULL;
|
sl@0
|
93 |
return retList;
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
TBool CTestEComResolver::Match(
|
sl@0
|
97 |
const TDesC8& aImplementationType,
|
sl@0
|
98 |
const TDesC8& aMatchType,
|
sl@0
|
99 |
TBool aUseWildcards
|
sl@0
|
100 |
) const
|
sl@0
|
101 |
{
|
sl@0
|
102 |
_LIT8(dataSeparator, "||");
|
sl@0
|
103 |
const TInt separatorLength = dataSeparator().Length();
|
sl@0
|
104 |
|
sl@0
|
105 |
// Look for the section separator marker '||'
|
sl@0
|
106 |
TPtrC8 remainingData = aImplementationType;
|
sl@0
|
107 |
TInt separatorPos = remainingData.Find(dataSeparator);
|
sl@0
|
108 |
TInt matchPos=KErrNotFound;
|
sl@0
|
109 |
do
|
sl@0
|
110 |
{
|
sl@0
|
111 |
TPtrC8 dataSection;
|
sl@0
|
112 |
if (separatorPos==KErrNotFound)
|
sl@0
|
113 |
{
|
sl@0
|
114 |
dataSection.Set(remainingData);
|
sl@0
|
115 |
}
|
sl@0
|
116 |
else
|
sl@0
|
117 |
{
|
sl@0
|
118 |
dataSection.Set(remainingData.Left(separatorPos));
|
sl@0
|
119 |
remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
|
sl@0
|
120 |
}
|
sl@0
|
121 |
if(aUseWildcards)
|
sl@0
|
122 |
{
|
sl@0
|
123 |
matchPos=dataSection.Match(aMatchType);
|
sl@0
|
124 |
}
|
sl@0
|
125 |
else
|
sl@0
|
126 |
{
|
sl@0
|
127 |
matchPos=dataSection.Compare(aMatchType);
|
sl@0
|
128 |
}
|
sl@0
|
129 |
}
|
sl@0
|
130 |
while ((separatorPos!=KErrNotFound) && (matchPos==KErrNotFound));
|
sl@0
|
131 |
|
sl@0
|
132 |
return matchPos!=KErrNotFound;
|
sl@0
|
133 |
}
|