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: #include sl@0: #include "pluginmanager.h" sl@0: #include sl@0: #include sl@0: sl@0: using namespace UserPromptService; sl@0: sl@0: // CPluginManager ----------------------------------------------------------- sl@0: CPluginManager::CPluginManager() sl@0: /** sl@0: Constructor sl@0: */ sl@0: { sl@0: } sl@0: sl@0: CPluginManager::~CPluginManager() sl@0: /** sl@0: Destructor sl@0: */ sl@0: { sl@0: REComSession::FinalClose(); sl@0: } sl@0: sl@0: EXPORT_C CPluginManager* CPluginManager::NewL() sl@0: /** sl@0: Factory function for plug-in managers. sl@0: @return A pointer to the new plug-in manager. sl@0: */ sl@0: { sl@0: CPluginManager* self = new(ELeave) CPluginManager(); sl@0: return self; sl@0: } sl@0: sl@0: EXPORT_C void CPluginManager::Unload() sl@0: /** sl@0: Schedules a deferred call to REComSession::FinalClose. This is sl@0: invoked once the last plug-in has been freed. sl@0: */ sl@0: { sl@0: if (iPluginCount == 0) sl@0: { sl@0: REComSession::FinalClose(); sl@0: iUnload = EFalse; sl@0: } sl@0: else sl@0: { sl@0: iUnload = ETrue; sl@0: } sl@0: } sl@0: sl@0: EXPORT_C void CPluginManager::ReleasePlugin() sl@0: /** sl@0: Called by CPlugin to decrement the count of active plug-ins. If sl@0: Unload has been called then REComSession::FinalClose is invoked when sl@0: the plug-in count reaches zero. sl@0: */ sl@0: { sl@0: if (--iPluginCount == 0 && iUnload) sl@0: { sl@0: iUnload = EFalse; sl@0: REComSession::FinalClose(); sl@0: } sl@0: } sl@0: sl@0: EXPORT_C CPlugin* CPluginManager::CreateEvaluatorL(const TUid& aEvaluatorId) sl@0: /** sl@0: Instantiates a new CPolicyEvaluator plug-in. sl@0: @param aEvaluatorId The ECOM implementation UID of the policy evaluator to instantiate. sl@0: @return A pointer to the new policy evaluator plug-in. sl@0: */ sl@0: { sl@0: CPolicyEvaluator* e = CPolicyEvaluator::NewL(aEvaluatorId); sl@0: CleanupStack::PushL(e); sl@0: CPlugin* p = new(ELeave) CPlugin(this, e); sl@0: CleanupStack::Pop(e); sl@0: ++iPluginCount; sl@0: return p; sl@0: } sl@0: sl@0: EXPORT_C CPlugin* CPluginManager::CreateDialogCreatorL(const TUid& aDialogCreatorId) sl@0: { sl@0: /** sl@0: Instantiates a new CDialogCreator plug-in. sl@0: @param aDialogCreatorId The ECOM implementation UID of the dialog creator to instantiate. sl@0: @return A pointer to the new dialog creator plug-in. sl@0: */ sl@0: CDialogCreator* d = CDialogCreator::NewL(aDialogCreatorId); sl@0: CleanupStack::PushL(d); sl@0: CPlugin* p = new(ELeave) CPlugin(this, d); sl@0: CleanupStack::Pop(d); sl@0: ++iPluginCount; sl@0: return p; sl@0: }