sl@0: /* sl@0: * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * crypto plugins loader sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: @released sl@0: */ sl@0: sl@0: #ifndef __CRYPTOPlUGINSLOADER_H__ sl@0: #define __CRYPTOPlUGINSLOADER_H__ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: namespace CryptoSpi sl@0: { sl@0: /** sl@0: The class holds the characteristics of an interface and DLL index, sl@0: which is used for externalization. sl@0: */ sl@0: class TCharacteristicsDll sl@0: { sl@0: public: sl@0: /** sl@0: Constructor that constructs a TCharacteristicsDll object sl@0: sl@0: @param aCharacteristics a pointer to the Characteristics. sl@0: @param aIndex the index of the plugindll that contains the interface implemetation sl@0: */ sl@0: TCharacteristicsDll(const TCharacteristics* aCharacteristics, TInt aIndex); sl@0: sl@0: /** sl@0: Externalize this object to the supplied stream. sl@0: sl@0: @param aStream Stream to write TCharacteristicsDll to. sl@0: */ sl@0: void ExternalizeL(RWriteStream& aStream); sl@0: sl@0: public: sl@0: /** sl@0: The pointer the characteristic of an interface sl@0: */ sl@0: const TCharacteristics* iCharacteristics; sl@0: sl@0: /** sl@0: The index of the plugin dll sl@0: */ sl@0: TInt iDllIndex; sl@0: }; sl@0: sl@0: /** sl@0: The class contains a list of characteristics-DllIndex pair. sl@0: which is used for externalization. sl@0: */ sl@0: NONSHARABLE_CLASS(CCharacteristicDllIndexList) : public CBase sl@0: { sl@0: public: sl@0: /** sl@0: Creates a new CCharacteristicDllIndexList. sl@0: @return A pointer to the CCharacteristicDllIndexList instance sl@0: */ sl@0: static CCharacteristicDllIndexList* NewL(); sl@0: sl@0: /** sl@0: Creates a new CCharacteristicDllIndexList. sl@0: Leave the CCharacteristicDllIndexList pointer on the cleanup stack. sl@0: @return A pointer to the CCharacteristicDllIndexList instance sl@0: */ sl@0: static CCharacteristicDllIndexList* NewLC(); sl@0: sl@0: /** sl@0: Destructor sl@0: */ sl@0: ~CCharacteristicDllIndexList(); sl@0: sl@0: /** sl@0: Externalize this object to the supplied stream. sl@0: sl@0: @param aStream Stream to write CCharacteristicDllIndexList to. sl@0: */ sl@0: void ExternalizeL(RWriteStream& aStream); sl@0: sl@0: private: sl@0: /** sl@0: Constructor sl@0: */ sl@0: CCharacteristicDllIndexList(); sl@0: sl@0: public: sl@0: /** sl@0: The list of of characteristics-DllIndex pair. sl@0: */ sl@0: RArray iCharacteristicList; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: This subclass of MStreamBuf is used with sl@0: RWriteStream to count how many bytes are sl@0: required to externalize an object. sl@0: */ sl@0: class TSizeStream : public MStreamBuf sl@0: { sl@0: public: sl@0: inline TSizeStream(); sl@0: inline TInt Size() const; sl@0: sl@0: // override MStreamBuf sl@0: virtual void DoWriteL(const TAny* /* aPtr */, TInt aLength); sl@0: sl@0: private: sl@0: /** sl@0: Accumulated stream length in bytes. sl@0: */ sl@0: TInt iSize; sl@0: }; sl@0: sl@0: inline TSizeStream::TSizeStream() sl@0: : iSize(0) sl@0: { sl@0: } sl@0: sl@0: inline TInt TSizeStream::Size() const sl@0: { sl@0: return iSize; sl@0: } sl@0: sl@0: /** sl@0: This class loads all the plugins, build all the characteristics, sl@0: and publish the properties for crypto spi. sl@0: */ sl@0: NONSHARABLE_CLASS(CCryptoPluginsLoader) : public CBase sl@0: { sl@0: public: sl@0: /** sl@0: Create a CCryptoPluginsLoader instance sl@0: */ sl@0: static CCryptoPluginsLoader* NewL(); sl@0: sl@0: /** sl@0: Create a CCryptoPluginsLoader instance. sl@0: Leave the pointer on the cleanup stack sl@0: */ sl@0: static CCryptoPluginsLoader* NewLC(); sl@0: sl@0: /** sl@0: Destructor sl@0: */ sl@0: ~CCryptoPluginsLoader(); sl@0: sl@0: /** sl@0: Create the properties of the plugin configurations. sl@0: */ sl@0: void CreatePluginConfigPropertyL(); sl@0: sl@0: /** sl@0: Create the properties for the interfaces sl@0: */ sl@0: void CreateInterfacePropertyL(TInt32 aInterface); sl@0: sl@0: private: sl@0: /** sl@0: Construtors sl@0: */ sl@0: CCryptoPluginsLoader(); sl@0: void ConstructL(); sl@0: sl@0: /** sl@0: Build the plugins' characteristics lists sl@0: */ sl@0: void BuildPluginCharacteristicsL(); sl@0: sl@0: /** sl@0: Build the plugin' characteristics list sl@0: @param aInterfaceUid the interface UID sl@0: @param aEnumerateFunc the entry pointer of enumeration function sl@0: @param aDllIndex the index of the loaded plugin sl@0: */ sl@0: void BuildInterfaceCharacteristicsL(TUid aInterfaceUid, sl@0: EnumerateCharacteristicsFunc aEnumerateFunc, sl@0: TInt aDllIndex); sl@0: /** sl@0: Loads the crypto plugins sl@0: @param aOption the option to load all the plugins or one more plugins sl@0: */ sl@0: void LoadPluginsL(); sl@0: sl@0: /** sl@0: Create the interfaces' properties and write to the stream sl@0: @param aStream the stream to be written to sl@0: @param aInterface the interface Uid sl@0: */ sl@0: void DoCreateInterfacePropertyL(RWriteStream& aStream, TInt32 aInterface); sl@0: sl@0: private: sl@0: /** sl@0: The plugin DLL list, which holds all the plugin DLLs sl@0: */ sl@0: RArray iPluginDllList; sl@0: sl@0: /** sl@0: The file name corresponding to the plugin DLLs. sl@0: */ sl@0: RArray iPluginNames; sl@0: sl@0: /** sl@0: The characteristic list, the length of the array is the number of the interfaces sl@0: */ sl@0: RHashMap iInterfaceCharacteristicsMap; sl@0: }; sl@0: } sl@0: #endif //__CRYPTOPlUGINSLOADER_H__ sl@0: