1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/authorisation/userpromptservice/policies/source/pluginmanager.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,111 @@
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 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include <ecom/ecom.h>
1.23 +#include "pluginmanager.h"
1.24 +#include <ups/dialogcreator.h>
1.25 +#include <ups/policyevaluator.h>
1.26 +
1.27 +using namespace UserPromptService;
1.28 +
1.29 +// CPluginManager -----------------------------------------------------------
1.30 +CPluginManager::CPluginManager()
1.31 +/**
1.32 +Constructor
1.33 +*/
1.34 + {
1.35 + }
1.36 +
1.37 +CPluginManager::~CPluginManager()
1.38 +/**
1.39 +Destructor
1.40 +*/
1.41 + {
1.42 + REComSession::FinalClose();
1.43 + }
1.44 +
1.45 +EXPORT_C CPluginManager* CPluginManager::NewL()
1.46 +/**
1.47 +Factory function for plug-in managers.
1.48 +@return A pointer to the new plug-in manager.
1.49 +*/
1.50 + {
1.51 + CPluginManager* self = new(ELeave) CPluginManager();
1.52 + return self;
1.53 + }
1.54 +
1.55 +EXPORT_C void CPluginManager::Unload()
1.56 +/**
1.57 +Schedules a deferred call to REComSession::FinalClose. This is
1.58 +invoked once the last plug-in has been freed.
1.59 +*/
1.60 + {
1.61 + if (iPluginCount == 0)
1.62 + {
1.63 + REComSession::FinalClose();
1.64 + iUnload = EFalse;
1.65 + }
1.66 + else
1.67 + {
1.68 + iUnload = ETrue;
1.69 + }
1.70 + }
1.71 +
1.72 +EXPORT_C void CPluginManager::ReleasePlugin()
1.73 +/**
1.74 +Called by CPlugin to decrement the count of active plug-ins. If
1.75 +Unload has been called then REComSession::FinalClose is invoked when
1.76 +the plug-in count reaches zero.
1.77 +*/
1.78 + {
1.79 + if (--iPluginCount == 0 && iUnload)
1.80 + {
1.81 + iUnload = EFalse;
1.82 + REComSession::FinalClose();
1.83 + }
1.84 + }
1.85 +
1.86 +EXPORT_C CPlugin<CPolicyEvaluator>* CPluginManager::CreateEvaluatorL(const TUid& aEvaluatorId)
1.87 +/**
1.88 +Instantiates a new CPolicyEvaluator plug-in.
1.89 +@param aEvaluatorId The ECOM implementation UID of the policy evaluator to instantiate.
1.90 +@return A pointer to the new policy evaluator plug-in.
1.91 +*/
1.92 + {
1.93 + CPolicyEvaluator* e = CPolicyEvaluator::NewL(aEvaluatorId);
1.94 + CleanupStack::PushL(e);
1.95 + CPlugin<CPolicyEvaluator>* p = new(ELeave) CPlugin<CPolicyEvaluator>(this, e);
1.96 + CleanupStack::Pop(e);
1.97 + ++iPluginCount;
1.98 + return p;
1.99 + }
1.100 +
1.101 +EXPORT_C CPlugin<CDialogCreator>* CPluginManager::CreateDialogCreatorL(const TUid& aDialogCreatorId)
1.102 + {
1.103 +/**
1.104 +Instantiates a new CDialogCreator plug-in.
1.105 +@param aDialogCreatorId The ECOM implementation UID of the dialog creator to instantiate.
1.106 +@return A pointer to the new dialog creator plug-in.
1.107 +*/
1.108 + CDialogCreator* d = CDialogCreator::NewL(aDialogCreatorId);
1.109 + CleanupStack::PushL(d);
1.110 + CPlugin<CDialogCreator>* p = new(ELeave) CPlugin<CDialogCreator>(this, d);
1.111 + CleanupStack::Pop(d);
1.112 + ++iPluginCount;
1.113 + return p;
1.114 + }