00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <ecom.h>
00018 #include <ecomerrorcodes.h>
00019 #include <ecomresolverparams.h>
00020 #include <implementationinformation.h>
00021 #include <publicregistry.h>
00022
00023 #include "ExampleResolver.h"
00024
00025 CExampleResolver* CExampleResolver::NewL(MPublicRegistry& aRegistry)
00026 {
00027 return new(ELeave) CExampleResolver(aRegistry);
00028 }
00029
00030 CExampleResolver::~CExampleResolver()
00031 {
00032 if(iImplementationInfoArray)
00033 {
00034 iImplementationInfoArray->Reset();
00035 delete iImplementationInfoArray;
00036 }
00037 }
00038
00039 CExampleResolver::CExampleResolver(MPublicRegistry& aRegistry)
00040 : CResolver(aRegistry)
00041 {
00042
00043 }
00044
00045 TUid CExampleResolver::IdentifyImplementationL(TUid aInterfaceUid,
00046 const TEComResolverParams& aAdditionalParameters) const
00047 {
00048 RImplInfoArray& implementationsInfo = iRegistry.ListImplementationsL(aInterfaceUid);
00049 TUid found = KNullUid;
00050 if(implementationsInfo.Count())
00051 {
00052 found = Resolve(implementationsInfo, aAdditionalParameters);
00053 }
00054 return found;
00055 }
00056
00057 TUid CExampleResolver::Resolve(const RImplInfoArray& aImplementationsInfo,
00058 const TEComResolverParams& aAdditionalParameters) const
00059 {
00060
00061 const TInt count = aImplementationsInfo.Count();
00062 for(TInt index = 0; index < count; ++index)
00063 {
00064 const CImplementationInformation& impData = *aImplementationsInfo[index];
00065
00066
00067 if (Match(impData.DataType(),
00068 aAdditionalParameters.DataType(),
00069 aAdditionalParameters.IsWildcardMatch()))
00070 return impData.ImplementationUid();
00071 }
00072
00073 return KNullUid;
00074 }
00075
00076 RImplInfoArray* CExampleResolver::ListAllL(TUid aInterfaceUid,
00077 const TEComResolverParams& aAdditionalParameters) const
00078 {
00079
00080 iImplementationInfoArray = new(ELeave) RImplInfoArray;
00081 RImplInfoArray* retList = iImplementationInfoArray;
00082
00083 RImplInfoArray& fullList = iRegistry.ListImplementationsL(aInterfaceUid);
00084
00085 const TBool useWildcards = aAdditionalParameters.IsWildcardMatch();
00086 const TDesC8& matchType = aAdditionalParameters.DataType();
00087 const TInt numImps = fullList.Count();
00088 for(TInt index = 0; index < numImps; ++index)
00089 {
00090 if(Match(fullList[index]->DataType(), matchType, useWildcards))
00091 {
00092 User::LeaveIfError(retList->Append(fullList[index]));
00093 }
00094 }
00095
00096
00097 iImplementationInfoArray = NULL;
00098 return retList;
00099 }
00100
00101 TBool CExampleResolver::Match(const TDesC8& aImplementationType,
00102 const TDesC8& aMatchType,
00103 TBool aUseWildcards) const
00104 {
00105 TInt matchPos = KErrNotFound;
00106
00107 _LIT8(dataSeparator, "||");
00108 const TInt separatorLength = dataSeparator().Length();
00109
00110
00111 TInt separatorPos = aImplementationType.Find(dataSeparator);
00112 if(separatorPos == KErrNotFound)
00113 {
00114
00115 if(aUseWildcards)
00116 matchPos = aImplementationType.Match(aMatchType);
00117 else
00118 matchPos = aImplementationType.Compare(aMatchType);
00119 }
00120 else
00121 {
00122
00123 TPtrC8 dataSection = aImplementationType.Left(separatorPos);
00124 TPtrC8 remainingData = aImplementationType.Mid(separatorPos + separatorLength);
00125
00126 while(separatorPos != KErrNotFound)
00127 {
00128
00129 if(aUseWildcards)
00130 matchPos = dataSection.Match(aMatchType);
00131 else
00132 matchPos = dataSection.Compare(aMatchType);
00133
00134
00135 if(matchPos != KErrNotFound)
00136 return ETrue;
00137
00138
00139 separatorPos = remainingData.Find(dataSeparator);
00140 if(separatorPos != KErrNotFound)
00141 {
00142 dataSection.Set(remainingData.Left(separatorPos));
00143 remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
00144 }
00145 else
00146 dataSection.Set(remainingData);
00147 }
00148
00149
00150 if(aUseWildcards)
00151 matchPos = dataSection.Match(aMatchType);
00152 else
00153 matchPos = dataSection.Compare(aMatchType);
00154
00155 }
00156 return matchPos != KErrNotFound;
00157 }