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: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: @released sl@0: */ sl@0: sl@0: #ifndef PLUGINMANAGER_H sl@0: #define PLUGINMANAGER_H sl@0: sl@0: namespace UserPromptService sl@0: { sl@0: class CPolicyEvaluator; sl@0: class CDialogCreator; sl@0: class CPolicyEvaluatorPlugin; sl@0: class CDialogCreatorPlugin; sl@0: class CPluginManager; sl@0: sl@0: /** sl@0: Container class for a plug-in that notifies a manager object when sl@0: it is destroyed. sl@0: */ sl@0: template sl@0: class CPlugin : public CBase sl@0: { sl@0: public: sl@0: CPlugin(CPluginManager* aManager, T* aImp); sl@0: T& Imp(); sl@0: ~CPlugin(); sl@0: private: sl@0: CPluginManager* iManager; ///< The plug-in manager that tracks active plug-ins. sl@0: T* iImp; ///< The policy evaluator or dialog creator owned by this object. sl@0: }; sl@0: sl@0: /** sl@0: Plug-in manager that tracks the number of plug-ins enabling REComSession::FinalClose() sl@0: to be deferred (after calling Unload) once all the plug-ins have been unloaded. sl@0: sl@0: N.B. REComSession::FinalClose CANNOT be called from within an ECOM plug-in. sl@0: */ sl@0: NONSHARABLE_CLASS(CPluginManager) : public CBase sl@0: { sl@0: template friend class CPlugin; sl@0: public: sl@0: IMPORT_C static CPluginManager* NewL(); sl@0: IMPORT_C CPlugin* CreateEvaluatorL(const TUid& aEvaluatorId); sl@0: IMPORT_C CPlugin* CreateDialogCreatorL(const TUid& aDialogCreatorId); sl@0: IMPORT_C void Unload(); sl@0: sl@0: ~CPluginManager(); sl@0: public: sl@0: // For testing. Do not modify directly sl@0: TInt iPluginCount; ///< The number of active CPlugin objects. (do not modify) sl@0: private: sl@0: CPluginManager(); sl@0: IMPORT_C void ReleasePlugin(); sl@0: sl@0: TBool iUnload; ///< Indicates that a deferred call to REComSession::FinalClose is required sl@0: }; sl@0: sl@0: template sl@0: inline CPlugin::CPlugin(CPluginManager* aManager, T* aImp) : iManager(aManager), iImp(aImp) sl@0: /** sl@0: Constructor sl@0: @param aManager The plug-in manager that tracks the number of plug-ins in existance. sl@0: @param aImp The ECOM implementation that this class managers. sl@0: */ sl@0: { sl@0: } sl@0: sl@0: template sl@0: inline T& CPlugin::Imp() sl@0: /** sl@0: Gets a reference to the plug-in implementation sl@0: @return The plug-in implementation. sl@0: */ sl@0: { sl@0: return *iImp; sl@0: } sl@0: sl@0: template sl@0: inline CPlugin::~CPlugin() sl@0: /** sl@0: Destructor sl@0: */ sl@0: { sl@0: delete iImp; sl@0: iManager->ReleasePlugin(); sl@0: } sl@0: } sl@0: #endif // PLUGINMANAGER_H