|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #ifndef CDLCUSTOMISATION_H |
|
18 #define CDLCUSTOMISATION_H |
|
19 |
|
20 #include "CdlLibrary.h" |
|
21 #include <badesca.h> |
|
22 #include "CdlPanic.h" |
|
23 |
|
24 /** |
|
25 * This is a CDL customisation instance implemented in a DLL |
|
26 */ |
|
27 NONSHARABLE_CLASS(CCdlDllInstance) : public CCdlInstance |
|
28 { |
|
29 public: |
|
30 CCdlDllInstance(const TCdlRef& aRef, const CCdlInstance* aSubLayer, CCdlEngine* aEngine, TInt* aLastApi); // all parameters are input parameters |
|
31 ~CCdlDllInstance(); |
|
32 void ConstructL(TBool aRomOnly, TInt aApiSize); |
|
33 const RCdlLibRef& Lib() const; |
|
34 |
|
35 private: |
|
36 void SetIsCompleteFlag(TInt aRequiredApiSize); |
|
37 |
|
38 // from CCdlInstance |
|
39 virtual TBool IsComplete() const; |
|
40 virtual TAny* Implementation(TInt aCdlApiId) const; |
|
41 virtual const SCdlInterface& Interface() const; |
|
42 |
|
43 private: |
|
44 TAny** iApi; // not owned, points to library contents |
|
45 RCdlLibRef iLib; |
|
46 TUint32 iFlags; |
|
47 const SCdlInterface* iInterface; // not owned, points to library contents |
|
48 }; |
|
49 |
|
50 |
|
51 /** |
|
52 * A CDL customisation instance implemented as a proxy for another instance |
|
53 */ |
|
54 NONSHARABLE_CLASS(CCdlInstanceProxy) : public CCdlInstance |
|
55 { |
|
56 public: |
|
57 CCdlInstanceProxy(CCdlEngine* aEngine, TInt* aLastApi); |
|
58 void Set(const CCdlInstance& aInst); |
|
59 |
|
60 private: |
|
61 // from CCdlInstance |
|
62 virtual TBool IsComplete() const; |
|
63 virtual TAny* Implementation(TInt aCdlApiId) const; |
|
64 virtual const SCdlInterface& Interface() const; |
|
65 |
|
66 private: |
|
67 const CCdlInstance* iInst; // not owned |
|
68 }; |
|
69 |
|
70 |
|
71 /** |
|
72 * A stack of customisation instances. Manages ownership and layering of customisation |
|
73 * instances for the server |
|
74 */ |
|
75 NONSHARABLE_CLASS(CCdlCustomisationStack) : public CBase |
|
76 { |
|
77 public: |
|
78 typedef CArrayPtrFlat<CCdlInstance> CStack; |
|
79 |
|
80 public: |
|
81 static CCdlCustomisationStack* NewLC(TUid aCdlUid, CCdlEngine* aEngine); |
|
82 ~CCdlCustomisationStack(); |
|
83 |
|
84 inline TUid Uid() const { return iUid; } |
|
85 void ClearOverrides(); |
|
86 void LoadCustomisationL(const TCdlRef& aRef); |
|
87 |
|
88 inline TAny* GetData(TInt aCdlApiId) const; |
|
89 inline TCdlEngineFunc* GetFunction(TInt aCdlApiId) const; |
|
90 |
|
91 const CCdlInstance* LastAccessedInstance() const; |
|
92 const CCdlInstance& Top() const; |
|
93 TInt* LastApiRef() const; |
|
94 inline TInt LastApiId() const; |
|
95 |
|
96 inline const CStack& Stack() const; |
|
97 inline TBool GlobalCustomisationEnabled() const; |
|
98 inline void EnableGlobalCustomisation(TBool aEnabled); |
|
99 |
|
100 void RequireCustomisationL(const SCdlInterface* aInterfaceParams); |
|
101 TBool IsCustomisationStarted(const SCdlInterface* aInterfaceParams) const; |
|
102 |
|
103 private: |
|
104 static TInt CompareInterfaces(const SCdlInterface* aLeft, const SCdlInterface* aRight); |
|
105 |
|
106 CCdlCustomisationStack(TUid aUid, CCdlEngine* aEngine); |
|
107 void ConstructL(); |
|
108 void PushCustL(CCdlInstance* aCust); |
|
109 void Delete(TInt aPos, TInt aCount); |
|
110 void NewBaseL(CCdlInstance* aBase); |
|
111 CCdlInstance* NewInstanceLC(const TCdlRef& aRef); |
|
112 TBool InstanceCanBeBase(CCdlInstance* aInst) const; |
|
113 |
|
114 private: |
|
115 friend class CdlEngine; // for optimised GetFunction() |
|
116 mutable TInt iLastApiId; |
|
117 TUid iUid; |
|
118 CStack iStack; // contained CCdlInstances are owned |
|
119 CCdlInstanceProxy* iTopProxy; // owned |
|
120 TBool iGlobalCustomisationEnabled; |
|
121 |
|
122 // not owned |
|
123 CCdlInstance* iTop; |
|
124 CCdlEngine* iEngine; |
|
125 const SCdlInterface* iInterfaceParams; |
|
126 }; |
|
127 |
|
128 |
|
129 inline TAny* CCdlCustomisationStack::GetData(TInt aCdlApiId) const |
|
130 { |
|
131 __ASSERT_ALWAYS(iTop, Panic(ECdlEngPanic_NoInstanceLoaded)); |
|
132 return iTop->GetData(aCdlApiId); |
|
133 } |
|
134 |
|
135 inline TCdlEngineFunc* CCdlCustomisationStack::GetFunction(TInt aCdlApiId) const |
|
136 { |
|
137 __ASSERT_ALWAYS(iTop, Panic(ECdlEngPanic_NoInstanceLoaded)); |
|
138 return iTop->GetFunction(aCdlApiId); |
|
139 } |
|
140 |
|
141 inline const CCdlCustomisationStack::CStack& CCdlCustomisationStack::Stack() const |
|
142 { |
|
143 return iStack; |
|
144 } |
|
145 |
|
146 inline TBool CCdlCustomisationStack::GlobalCustomisationEnabled() const |
|
147 { |
|
148 return iGlobalCustomisationEnabled; |
|
149 } |
|
150 |
|
151 inline void CCdlCustomisationStack::EnableGlobalCustomisation(TBool aEnabled) |
|
152 { |
|
153 iGlobalCustomisationEnabled = aEnabled; |
|
154 } |
|
155 |
|
156 inline TInt CCdlCustomisationStack::LastApiId() const |
|
157 { |
|
158 return iLastApiId; |
|
159 } |
|
160 |
|
161 |
|
162 #endif |