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