os/security/authorisation/userpromptservice/policies/source/pluginmanager.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
#include <ecom/ecom.h>
sl@0
    20
#include "pluginmanager.h"
sl@0
    21
#include <ups/dialogcreator.h>
sl@0
    22
#include <ups/policyevaluator.h>
sl@0
    23
sl@0
    24
using namespace UserPromptService;
sl@0
    25
sl@0
    26
// CPluginManager -----------------------------------------------------------
sl@0
    27
CPluginManager::CPluginManager()
sl@0
    28
/**
sl@0
    29
Constructor
sl@0
    30
*/
sl@0
    31
	{		
sl@0
    32
	}
sl@0
    33
	
sl@0
    34
CPluginManager::~CPluginManager()
sl@0
    35
/**
sl@0
    36
Destructor
sl@0
    37
*/
sl@0
    38
	{
sl@0
    39
	REComSession::FinalClose();	
sl@0
    40
	}
sl@0
    41
sl@0
    42
EXPORT_C CPluginManager* CPluginManager::NewL()
sl@0
    43
/**
sl@0
    44
Factory function for plug-in managers.
sl@0
    45
@return A pointer to the new plug-in manager.
sl@0
    46
*/
sl@0
    47
	{
sl@0
    48
	CPluginManager* self = new(ELeave) CPluginManager();
sl@0
    49
	return self;
sl@0
    50
	}
sl@0
    51
sl@0
    52
EXPORT_C void CPluginManager::Unload()
sl@0
    53
/**
sl@0
    54
Schedules a deferred call to REComSession::FinalClose. This is
sl@0
    55
invoked once the last plug-in has been freed.
sl@0
    56
*/
sl@0
    57
	{
sl@0
    58
	if (iPluginCount == 0)
sl@0
    59
		{
sl@0
    60
		REComSession::FinalClose();
sl@0
    61
		iUnload = EFalse;
sl@0
    62
		}
sl@0
    63
	else 
sl@0
    64
		{
sl@0
    65
		iUnload = ETrue;
sl@0
    66
		}
sl@0
    67
	}
sl@0
    68
	
sl@0
    69
EXPORT_C void CPluginManager::ReleasePlugin()
sl@0
    70
/**
sl@0
    71
Called by CPlugin to decrement the count of active plug-ins. If
sl@0
    72
Unload has been called then REComSession::FinalClose is invoked when 
sl@0
    73
the plug-in count reaches zero.
sl@0
    74
*/
sl@0
    75
	{
sl@0
    76
	if (--iPluginCount == 0 && iUnload)
sl@0
    77
		{
sl@0
    78
		iUnload = EFalse;
sl@0
    79
		REComSession::FinalClose();
sl@0
    80
		}
sl@0
    81
	}
sl@0
    82
	
sl@0
    83
EXPORT_C CPlugin<CPolicyEvaluator>* CPluginManager::CreateEvaluatorL(const TUid& aEvaluatorId)
sl@0
    84
/**
sl@0
    85
Instantiates a new CPolicyEvaluator plug-in.
sl@0
    86
@param aEvaluatorId	The ECOM implementation UID of the policy evaluator to instantiate.
sl@0
    87
@return				A pointer to the new policy evaluator plug-in.
sl@0
    88
*/
sl@0
    89
	{
sl@0
    90
	CPolicyEvaluator* e = CPolicyEvaluator::NewL(aEvaluatorId);
sl@0
    91
	CleanupStack::PushL(e);
sl@0
    92
	CPlugin<CPolicyEvaluator>* p = new(ELeave) CPlugin<CPolicyEvaluator>(this, e);
sl@0
    93
	CleanupStack::Pop(e);
sl@0
    94
	++iPluginCount;
sl@0
    95
	return p;
sl@0
    96
	}
sl@0
    97
sl@0
    98
EXPORT_C CPlugin<CDialogCreator>* CPluginManager::CreateDialogCreatorL(const TUid& aDialogCreatorId)
sl@0
    99
	{
sl@0
   100
/**
sl@0
   101
Instantiates a new CDialogCreator plug-in.
sl@0
   102
@param	aDialogCreatorId	The ECOM implementation UID of the dialog creator to instantiate.
sl@0
   103
@return						A pointer to the new dialog creator plug-in.
sl@0
   104
*/
sl@0
   105
	CDialogCreator* d = CDialogCreator::NewL(aDialogCreatorId);
sl@0
   106
	CleanupStack::PushL(d);
sl@0
   107
	CPlugin<CDialogCreator>* p = new(ELeave) CPlugin<CDialogCreator>(this, d);
sl@0
   108
	CleanupStack::Pop(d);
sl@0
   109
	++iPluginCount;
sl@0
   110
	return p;
sl@0
   111
	}