1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/crypto/weakcryptospi/source/spi/cryptospisetup/cryptopluginsloader.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,230 @@
1.4 +/*
1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* crypto plugins loader
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +/**
1.24 + @file
1.25 + @internalComponent
1.26 + @released
1.27 +*/
1.28 +
1.29 +#ifndef __CRYPTOPlUGINSLOADER_H__
1.30 +#define __CRYPTOPlUGINSLOADER_H__
1.31 +
1.32 +#include <e32hashtab.h>
1.33 +#include <cryptospi/pluginentrydef.h>
1.34 +
1.35 +namespace CryptoSpi
1.36 + {
1.37 + /**
1.38 + The class holds the characteristics of an interface and DLL index,
1.39 + which is used for externalization.
1.40 + */
1.41 + class TCharacteristicsDll
1.42 + {
1.43 + public:
1.44 + /**
1.45 + Constructor that constructs a TCharacteristicsDll object
1.46 +
1.47 + @param aCharacteristics a pointer to the Characteristics.
1.48 + @param aIndex the index of the plugindll that contains the interface implemetation
1.49 + */
1.50 + TCharacteristicsDll(const TCharacteristics* aCharacteristics, TInt aIndex);
1.51 +
1.52 + /**
1.53 + Externalize this object to the supplied stream.
1.54 +
1.55 + @param aStream Stream to write TCharacteristicsDll to.
1.56 + */
1.57 + void ExternalizeL(RWriteStream& aStream);
1.58 +
1.59 + public:
1.60 + /**
1.61 + The pointer the characteristic of an interface
1.62 + */
1.63 + const TCharacteristics* iCharacteristics;
1.64 +
1.65 + /**
1.66 + The index of the plugin dll
1.67 + */
1.68 + TInt iDllIndex;
1.69 + };
1.70 +
1.71 + /**
1.72 + The class contains a list of characteristics-DllIndex pair.
1.73 + which is used for externalization.
1.74 + */
1.75 + NONSHARABLE_CLASS(CCharacteristicDllIndexList) : public CBase
1.76 + {
1.77 + public:
1.78 + /**
1.79 + Creates a new CCharacteristicDllIndexList.
1.80 + @return A pointer to the CCharacteristicDllIndexList instance
1.81 + */
1.82 + static CCharacteristicDllIndexList* NewL();
1.83 +
1.84 + /**
1.85 + Creates a new CCharacteristicDllIndexList.
1.86 + Leave the CCharacteristicDllIndexList pointer on the cleanup stack.
1.87 + @return A pointer to the CCharacteristicDllIndexList instance
1.88 + */
1.89 + static CCharacteristicDllIndexList* NewLC();
1.90 +
1.91 + /**
1.92 + Destructor
1.93 + */
1.94 + ~CCharacteristicDllIndexList();
1.95 +
1.96 + /**
1.97 + Externalize this object to the supplied stream.
1.98 +
1.99 + @param aStream Stream to write CCharacteristicDllIndexList to.
1.100 + */
1.101 + void ExternalizeL(RWriteStream& aStream);
1.102 +
1.103 + private:
1.104 + /**
1.105 + Constructor
1.106 + */
1.107 + CCharacteristicDllIndexList();
1.108 +
1.109 + public:
1.110 + /**
1.111 + The list of of characteristics-DllIndex pair.
1.112 + */
1.113 + RArray<TCharacteristicsDll> iCharacteristicList;
1.114 + };
1.115 +
1.116 +
1.117 + /**
1.118 + This subclass of MStreamBuf is used with
1.119 + RWriteStream to count how many bytes are
1.120 + required to externalize an object.
1.121 + */
1.122 + class TSizeStream : public MStreamBuf
1.123 + {
1.124 + public:
1.125 + inline TSizeStream();
1.126 + inline TInt Size() const;
1.127 +
1.128 + // override MStreamBuf
1.129 + virtual void DoWriteL(const TAny* /* aPtr */, TInt aLength);
1.130 +
1.131 + private:
1.132 + /**
1.133 + Accumulated stream length in bytes.
1.134 + */
1.135 + TInt iSize;
1.136 + };
1.137 +
1.138 + inline TSizeStream::TSizeStream()
1.139 + : iSize(0)
1.140 + {
1.141 + }
1.142 +
1.143 + inline TInt TSizeStream::Size() const
1.144 + {
1.145 + return iSize;
1.146 + }
1.147 +
1.148 + /**
1.149 + This class loads all the plugins, build all the characteristics,
1.150 + and publish the properties for crypto spi.
1.151 + */
1.152 + NONSHARABLE_CLASS(CCryptoPluginsLoader) : public CBase
1.153 + {
1.154 + public:
1.155 + /**
1.156 + Create a CCryptoPluginsLoader instance
1.157 + */
1.158 + static CCryptoPluginsLoader* NewL();
1.159 +
1.160 + /**
1.161 + Create a CCryptoPluginsLoader instance.
1.162 + Leave the pointer on the cleanup stack
1.163 + */
1.164 + static CCryptoPluginsLoader* NewLC();
1.165 +
1.166 + /**
1.167 + Destructor
1.168 + */
1.169 + ~CCryptoPluginsLoader();
1.170 +
1.171 + /**
1.172 + Create the properties of the plugin configurations.
1.173 + */
1.174 + void CreatePluginConfigPropertyL();
1.175 +
1.176 + /**
1.177 + Create the properties for the interfaces
1.178 + */
1.179 + void CreateInterfacePropertyL(TInt32 aInterface);
1.180 +
1.181 + private:
1.182 + /**
1.183 + Construtors
1.184 + */
1.185 + CCryptoPluginsLoader();
1.186 + void ConstructL();
1.187 +
1.188 + /**
1.189 + Build the plugins' characteristics lists
1.190 + */
1.191 + void BuildPluginCharacteristicsL();
1.192 +
1.193 + /**
1.194 + Build the plugin' characteristics list
1.195 + @param aInterfaceUid the interface UID
1.196 + @param aEnumerateFunc the entry pointer of enumeration function
1.197 + @param aDllIndex the index of the loaded plugin
1.198 + */
1.199 + void BuildInterfaceCharacteristicsL(TUid aInterfaceUid,
1.200 + EnumerateCharacteristicsFunc aEnumerateFunc,
1.201 + TInt aDllIndex);
1.202 + /**
1.203 + Loads the crypto plugins
1.204 + @param aOption the option to load all the plugins or one more plugins
1.205 + */
1.206 + void LoadPluginsL();
1.207 +
1.208 + /**
1.209 + Create the interfaces' properties and write to the stream
1.210 + @param aStream the stream to be written to
1.211 + @param aInterface the interface Uid
1.212 + */
1.213 + void DoCreateInterfacePropertyL(RWriteStream& aStream, TInt32 aInterface);
1.214 +
1.215 + private:
1.216 + /**
1.217 + The plugin DLL list, which holds all the plugin DLLs
1.218 + */
1.219 + RArray<RLibrary> iPluginDllList;
1.220 +
1.221 + /**
1.222 + The file name corresponding to the plugin DLLs.
1.223 + */
1.224 + RArray<TFileName> iPluginNames;
1.225 +
1.226 + /**
1.227 + The characteristic list, the length of the array is the number of the interfaces
1.228 + */
1.229 + RHashMap<TInt32, CCharacteristicDllIndexList*> iInterfaceCharacteristicsMap;
1.230 + };
1.231 + }
1.232 +#endif //__CRYPTOPlUGINSLOADER_H__
1.233 +