|
1 /* |
|
2 * Copyright (c) 2007-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 the License "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 * crypto plugins loader |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent |
|
23 @released |
|
24 */ |
|
25 |
|
26 #ifndef __CRYPTOPlUGINSLOADER_H__ |
|
27 #define __CRYPTOPlUGINSLOADER_H__ |
|
28 |
|
29 #include <e32hashtab.h> |
|
30 #include <cryptospi/pluginentrydef.h> |
|
31 |
|
32 namespace CryptoSpi |
|
33 { |
|
34 /** |
|
35 The class holds the characteristics of an interface and DLL index, |
|
36 which is used for externalization. |
|
37 */ |
|
38 class TCharacteristicsDll |
|
39 { |
|
40 public: |
|
41 /** |
|
42 Constructor that constructs a TCharacteristicsDll object |
|
43 |
|
44 @param aCharacteristics a pointer to the Characteristics. |
|
45 @param aIndex the index of the plugindll that contains the interface implemetation |
|
46 */ |
|
47 TCharacteristicsDll(const TCharacteristics* aCharacteristics, TInt aIndex); |
|
48 |
|
49 /** |
|
50 Externalize this object to the supplied stream. |
|
51 |
|
52 @param aStream Stream to write TCharacteristicsDll to. |
|
53 */ |
|
54 void ExternalizeL(RWriteStream& aStream); |
|
55 |
|
56 public: |
|
57 /** |
|
58 The pointer the characteristic of an interface |
|
59 */ |
|
60 const TCharacteristics* iCharacteristics; |
|
61 |
|
62 /** |
|
63 The index of the plugin dll |
|
64 */ |
|
65 TInt iDllIndex; |
|
66 }; |
|
67 |
|
68 /** |
|
69 The class contains a list of characteristics-DllIndex pair. |
|
70 which is used for externalization. |
|
71 */ |
|
72 NONSHARABLE_CLASS(CCharacteristicDllIndexList) : public CBase |
|
73 { |
|
74 public: |
|
75 /** |
|
76 Creates a new CCharacteristicDllIndexList. |
|
77 @return A pointer to the CCharacteristicDllIndexList instance |
|
78 */ |
|
79 static CCharacteristicDllIndexList* NewL(); |
|
80 |
|
81 /** |
|
82 Creates a new CCharacteristicDllIndexList. |
|
83 Leave the CCharacteristicDllIndexList pointer on the cleanup stack. |
|
84 @return A pointer to the CCharacteristicDllIndexList instance |
|
85 */ |
|
86 static CCharacteristicDllIndexList* NewLC(); |
|
87 |
|
88 /** |
|
89 Destructor |
|
90 */ |
|
91 ~CCharacteristicDllIndexList(); |
|
92 |
|
93 /** |
|
94 Externalize this object to the supplied stream. |
|
95 |
|
96 @param aStream Stream to write CCharacteristicDllIndexList to. |
|
97 */ |
|
98 void ExternalizeL(RWriteStream& aStream); |
|
99 |
|
100 private: |
|
101 /** |
|
102 Constructor |
|
103 */ |
|
104 CCharacteristicDllIndexList(); |
|
105 |
|
106 public: |
|
107 /** |
|
108 The list of of characteristics-DllIndex pair. |
|
109 */ |
|
110 RArray<TCharacteristicsDll> iCharacteristicList; |
|
111 }; |
|
112 |
|
113 |
|
114 /** |
|
115 This subclass of MStreamBuf is used with |
|
116 RWriteStream to count how many bytes are |
|
117 required to externalize an object. |
|
118 */ |
|
119 class TSizeStream : public MStreamBuf |
|
120 { |
|
121 public: |
|
122 inline TSizeStream(); |
|
123 inline TInt Size() const; |
|
124 |
|
125 // override MStreamBuf |
|
126 virtual void DoWriteL(const TAny* /* aPtr */, TInt aLength); |
|
127 |
|
128 private: |
|
129 /** |
|
130 Accumulated stream length in bytes. |
|
131 */ |
|
132 TInt iSize; |
|
133 }; |
|
134 |
|
135 inline TSizeStream::TSizeStream() |
|
136 : iSize(0) |
|
137 { |
|
138 } |
|
139 |
|
140 inline TInt TSizeStream::Size() const |
|
141 { |
|
142 return iSize; |
|
143 } |
|
144 |
|
145 /** |
|
146 This class loads all the plugins, build all the characteristics, |
|
147 and publish the properties for crypto spi. |
|
148 */ |
|
149 NONSHARABLE_CLASS(CCryptoPluginsLoader) : public CBase |
|
150 { |
|
151 public: |
|
152 /** |
|
153 Create a CCryptoPluginsLoader instance |
|
154 */ |
|
155 static CCryptoPluginsLoader* NewL(); |
|
156 |
|
157 /** |
|
158 Create a CCryptoPluginsLoader instance. |
|
159 Leave the pointer on the cleanup stack |
|
160 */ |
|
161 static CCryptoPluginsLoader* NewLC(); |
|
162 |
|
163 /** |
|
164 Destructor |
|
165 */ |
|
166 ~CCryptoPluginsLoader(); |
|
167 |
|
168 /** |
|
169 Create the properties of the plugin configurations. |
|
170 */ |
|
171 void CreatePluginConfigPropertyL(); |
|
172 |
|
173 /** |
|
174 Create the properties for the interfaces |
|
175 */ |
|
176 void CreateInterfacePropertyL(TInt32 aInterface); |
|
177 |
|
178 private: |
|
179 /** |
|
180 Construtors |
|
181 */ |
|
182 CCryptoPluginsLoader(); |
|
183 void ConstructL(); |
|
184 |
|
185 /** |
|
186 Build the plugins' characteristics lists |
|
187 */ |
|
188 void BuildPluginCharacteristicsL(); |
|
189 |
|
190 /** |
|
191 Build the plugin' characteristics list |
|
192 @param aInterfaceUid the interface UID |
|
193 @param aEnumerateFunc the entry pointer of enumeration function |
|
194 @param aDllIndex the index of the loaded plugin |
|
195 */ |
|
196 void BuildInterfaceCharacteristicsL(TUid aInterfaceUid, |
|
197 EnumerateCharacteristicsFunc aEnumerateFunc, |
|
198 TInt aDllIndex); |
|
199 /** |
|
200 Loads the crypto plugins |
|
201 @param aOption the option to load all the plugins or one more plugins |
|
202 */ |
|
203 void LoadPluginsL(); |
|
204 |
|
205 /** |
|
206 Create the interfaces' properties and write to the stream |
|
207 @param aStream the stream to be written to |
|
208 @param aInterface the interface Uid |
|
209 */ |
|
210 void DoCreateInterfacePropertyL(RWriteStream& aStream, TInt32 aInterface); |
|
211 |
|
212 private: |
|
213 /** |
|
214 The plugin DLL list, which holds all the plugin DLLs |
|
215 */ |
|
216 RArray<RLibrary> iPluginDllList; |
|
217 |
|
218 /** |
|
219 The file name corresponding to the plugin DLLs. |
|
220 */ |
|
221 RArray<TFileName> iPluginNames; |
|
222 |
|
223 /** |
|
224 The characteristic list, the length of the array is the number of the interfaces |
|
225 */ |
|
226 RHashMap<TInt32, CCharacteristicDllIndexList*> iInterfaceCharacteristicsMap; |
|
227 }; |
|
228 } |
|
229 #endif //__CRYPTOPlUGINSLOADER_H__ |
|
230 |