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