1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/authorisation/userpromptservice/inc_private/pluginmanager.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,108 @@
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 +/**
1.23 + @file
1.24 + @internalComponent
1.25 + @released
1.26 +*/
1.27 +
1.28 +#ifndef PLUGINMANAGER_H
1.29 +#define PLUGINMANAGER_H
1.30 +
1.31 +namespace UserPromptService
1.32 + {
1.33 + class CPolicyEvaluator;
1.34 + class CDialogCreator;
1.35 + class CPolicyEvaluatorPlugin;
1.36 + class CDialogCreatorPlugin;
1.37 + class CPluginManager;
1.38 +
1.39 + /**
1.40 + Container class for a plug-in that notifies a manager object when
1.41 + it is destroyed.
1.42 + */
1.43 + template <class T>
1.44 + class CPlugin : public CBase
1.45 + {
1.46 + public:
1.47 + CPlugin(CPluginManager* aManager, T* aImp);
1.48 + T& Imp();
1.49 + ~CPlugin();
1.50 + private:
1.51 + CPluginManager* iManager; ///< The plug-in manager that tracks active plug-ins.
1.52 + T* iImp; ///< The policy evaluator or dialog creator owned by this object.
1.53 + };
1.54 +
1.55 + /**
1.56 + Plug-in manager that tracks the number of plug-ins enabling REComSession::FinalClose()
1.57 + to be deferred (after calling Unload) once all the plug-ins have been unloaded.
1.58 +
1.59 + N.B. REComSession::FinalClose CANNOT be called from within an ECOM plug-in.
1.60 + */
1.61 + NONSHARABLE_CLASS(CPluginManager) : public CBase
1.62 + {
1.63 + template <class T> friend class CPlugin;
1.64 + public:
1.65 + IMPORT_C static CPluginManager* NewL();
1.66 + IMPORT_C CPlugin<CPolicyEvaluator>* CreateEvaluatorL(const TUid& aEvaluatorId);
1.67 + IMPORT_C CPlugin<CDialogCreator>* CreateDialogCreatorL(const TUid& aDialogCreatorId);
1.68 + IMPORT_C void Unload();
1.69 +
1.70 + ~CPluginManager();
1.71 + public:
1.72 + // For testing. Do not modify directly
1.73 + TInt iPluginCount; ///< The number of active CPlugin objects. (do not modify)
1.74 + private:
1.75 + CPluginManager();
1.76 + IMPORT_C void ReleasePlugin();
1.77 +
1.78 + TBool iUnload; ///< Indicates that a deferred call to REComSession::FinalClose is required
1.79 + };
1.80 +
1.81 + template <class T>
1.82 + inline CPlugin<T>::CPlugin(CPluginManager* aManager, T* aImp) : iManager(aManager), iImp(aImp)
1.83 + /**
1.84 + Constructor
1.85 + @param aManager The plug-in manager that tracks the number of plug-ins in existance.
1.86 + @param aImp The ECOM implementation that this class managers.
1.87 + */
1.88 + {
1.89 + }
1.90 +
1.91 + template <class T>
1.92 + inline T& CPlugin<T>::Imp()
1.93 + /**
1.94 + Gets a reference to the plug-in implementation
1.95 + @return The plug-in implementation.
1.96 + */
1.97 + {
1.98 + return *iImp;
1.99 + }
1.100 +
1.101 + template <class T>
1.102 + inline CPlugin<T>::~CPlugin()
1.103 + /**
1.104 + Destructor
1.105 + */
1.106 + {
1.107 + delete iImp;
1.108 + iManager->ReleasePlugin();
1.109 + }
1.110 + }
1.111 +#endif // PLUGINMANAGER_H