|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include "CachedCustomResolver.h" |
|
22 #include <ecom/implementationproxy.h> |
|
23 #include <ecom/ecomerrorcodes.h> |
|
24 |
|
25 /** |
|
26 This function is used for cleanup support of ListAllL call. |
|
27 */ |
|
28 LOCAL_C void CleanupEComPtrArray(TAny* aArray) |
|
29 { |
|
30 RImplInfoArray* self = static_cast<RImplInfoArray*>(aArray); |
|
31 self->Reset(); |
|
32 delete self; |
|
33 } |
|
34 |
|
35 // static factory method to instantiate the resolver. |
|
36 CExampleResolver* CExampleResolver::NewL(MPublicRegistry& aRegistry) |
|
37 { |
|
38 CExampleResolver* self = new(ELeave) CExampleResolver(aRegistry); |
|
39 (void)self->GetSignature(); |
|
40 return self; |
|
41 } |
|
42 |
|
43 CExampleResolver::~CExampleResolver() |
|
44 { |
|
45 // nothing |
|
46 } |
|
47 |
|
48 CExampleResolver::CExampleResolver(MPublicRegistry& aRegistry) |
|
49 : CResolver(aRegistry) |
|
50 { |
|
51 // nothing to do |
|
52 } |
|
53 |
|
54 // stub for the IdentifyImplementationL pure virtual |
|
55 TUid CExampleResolver::IdentifyImplementationL(TUid aInterfaceUid, |
|
56 const TEComResolverParams&) const |
|
57 { |
|
58 RImplInfoArray& implementationsInfo = iRegistry.ListImplementationsL(aInterfaceUid); |
|
59 if (implementationsInfo.Count()) |
|
60 { |
|
61 return implementationsInfo[0]->ImplementationUid(); |
|
62 } |
|
63 return KNullUid; |
|
64 } |
|
65 |
|
66 // stub for the ListAllL pure virtual |
|
67 RImplInfoArray* CExampleResolver::ListAllL(TUid aInterfaceUid, |
|
68 const TEComResolverParams&) const |
|
69 { |
|
70 TBool checkMyVersion = (aInterfaceUid == KCustomResolverInterfaceUid); |
|
71 TBool foundMyself = EFalse; |
|
72 |
|
73 // Ownership of the returned pointer is passed back to the caller. |
|
74 // Hence need to new it. |
|
75 RImplInfoArray* retList = new(ELeave) RImplInfoArray; |
|
76 CleanupStack::PushL(TCleanupItem(CleanupEComPtrArray, retList)); |
|
77 |
|
78 RImplInfoArray& fullList = iRegistry.ListImplementationsL(aInterfaceUid); |
|
79 const TInt numImps = fullList.Count(); |
|
80 for(TInt index = 0; index < numImps; ++index) |
|
81 { |
|
82 if (checkMyVersion) |
|
83 { |
|
84 VerifyVersionL(fullList[index], foundMyself); |
|
85 } |
|
86 |
|
87 User::LeaveIfError(retList->Append(fullList[index])); |
|
88 } |
|
89 |
|
90 if (checkMyVersion && !foundMyself) |
|
91 { |
|
92 RDebug::Print(_L("ECOM: error cachedcustomresolver not in list\n")); |
|
93 User::Leave(KEComErrMismatchedTags); |
|
94 } |
|
95 |
|
96 // Reset the member variable because we are passing ownership back |
|
97 CleanupStack::Pop(retList); |
|
98 return retList; |
|
99 } |
|
100 |
|
101 // |
|
102 // Used by test code in list request where the i/f UID is KCustomResolverInterfaceUid. |
|
103 // This gives the custom resolver object a chance to check that the version listed |
|
104 // in ECOM registry matches the current running object. |
|
105 // |
|
106 // param aImplInfo - the implementation object to check |
|
107 // param aMe - output parameter to tell the call if 'this' is found |
|
108 void CExampleResolver::VerifyVersionL(const CImplementationInformation* aImplInfo, TBool& aMe) const |
|
109 { |
|
110 const TUid KMyImplUid = {0x10009E12}; |
|
111 if (aImplInfo->ImplementationUid() == KMyImplUid) |
|
112 { |
|
113 if (GetSignature() != aImplInfo->Version()) |
|
114 { |
|
115 RDebug::Print(_L("ECOM: error registry has ver %d, binary has %d\n"), aImplInfo->Version(), GetSignature()); |
|
116 // leave with un-used cwcode. But even if ECOM will use this in |
|
117 // the future, the code will not occur in a list request. |
|
118 User::Leave(KEComErrMismatchedTags); |
|
119 } |
|
120 aMe = ETrue; // found myself |
|
121 } |
|
122 } |
|
123 |
|
124 // __________________________________________________________________________ |
|
125 // Exported proxy for instantiation method resolution |
|
126 // Define the interface UIDs |
|
127 const TImplementationProxy ImplementationTable[] = |
|
128 { |
|
129 IMPLEMENTATION_PROXY_ENTRY(0x10009E12, CExampleResolver::NewL) |
|
130 }; |
|
131 |
|
132 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
133 { |
|
134 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
135 return ImplementationTable; |
|
136 } |