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