|
1 /* |
|
2 * Copyright (c) 2007 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 "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: PSM Plug-in loader |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ecom/ecom.h> |
|
20 #include <psmpluginbase.h> |
|
21 #include "psmpluginloader.h" |
|
22 #include "psmsrvplugin.h" |
|
23 #include "psmmanager.h" |
|
24 #include "psmtrace.h" |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CPsmPluginLoader::NewL |
|
28 // Two-phased constructor. |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CPsmPluginLoader* CPsmPluginLoader::NewL( CPsmManager& aManager ) |
|
32 { |
|
33 COMPONENT_TRACE( ( _L( "PSM Server - CPsmPluginLoader::NewL()" ) ) ); |
|
34 |
|
35 CPsmPluginLoader* self = CPsmPluginLoader::NewLC( aManager ); |
|
36 CleanupStack::Pop( self ); |
|
37 |
|
38 COMPONENT_TRACE( ( _L( "PSM Server - CPsmPluginLoader::NewL - return 0x%x" ), self ) ); |
|
39 |
|
40 return self; |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CPsmPluginLoader::NewLC |
|
45 // Two-phased constructor. |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CPsmPluginLoader* CPsmPluginLoader::NewLC( CPsmManager& aManager ) |
|
49 { |
|
50 COMPONENT_TRACE( ( _L( "PSM Server - CPsmPluginLoader::NewLC()" ) ) ); |
|
51 |
|
52 CPsmPluginLoader* self = new( ELeave ) CPsmPluginLoader( aManager ); |
|
53 |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL(); |
|
56 |
|
57 COMPONENT_TRACE( ( _L( "PSM Server - CPsmPluginLoader::NewLC - return 0x%x" ), self ) ); |
|
58 |
|
59 return self; |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CPsmPluginLoader::CPsmPluginLoader |
|
64 // C++ default constructor can NOT contain any code, that |
|
65 // might leave. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CPsmPluginLoader::CPsmPluginLoader( CPsmManager& aManager ) : |
|
69 iManager( aManager ) |
|
70 { |
|
71 // Nothing to do |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CPsmPluginLoader::ConstructL |
|
76 // Symbian 2nd phase constructor can leave. |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 void CPsmPluginLoader::ConstructL() |
|
80 { |
|
81 COMPONENT_TRACE( ( _L( "PSM Server - CPsmPluginLoader::ConstructL()" ) ) ); |
|
82 COMPONENT_TRACE( ( _L( "PSM Server - CPsmPluginLoader::ConstructL - return" ) ) ); |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // Destructor |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 CPsmPluginLoader::~CPsmPluginLoader() |
|
90 { |
|
91 COMPONENT_TRACE( ( _L( "PSM Server - CPsmPluginLoader::~CPsmPluginLoader()" ) ) ); |
|
92 |
|
93 iPluginArray.ResetAndDestroy(); |
|
94 |
|
95 REComSession::FinalClose(); |
|
96 |
|
97 COMPONENT_TRACE( ( _L( "PSM Server - CPsmPluginLoader::~CPsmPluginLoader - return") ) ); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CPsmPluginLoader::InitializePluginsL |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 static void ResetAndDestroyArray( TAny* aPtr ) |
|
105 { |
|
106 RImplInfoPtrArray* array = static_cast< RImplInfoPtrArray* >( aPtr ); |
|
107 array->ResetAndDestroy(); |
|
108 array->Close(); |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CPsmPluginLoader::InitializePluginsL |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void CPsmPluginLoader::InitializePluginsL() |
|
116 { |
|
117 COMPONENT_TRACE( ( _L( "PSM Server - CPsmPluginLoader::InitializePluginsL()" ) ) ); |
|
118 |
|
119 // List implementations |
|
120 RImplInfoPtrArray implInfoArray; |
|
121 TCleanupItem cleanupItem( ResetAndDestroyArray, &implInfoArray ); |
|
122 CleanupStack::PushL( cleanupItem ); |
|
123 |
|
124 REComSession::ListImplementationsL( KPsmPluginControlInterfaceUid, implInfoArray ); |
|
125 |
|
126 // Get number of implementations |
|
127 const TInt pluginCount( implInfoArray.Count() ); |
|
128 |
|
129 // Loop implementation info and create instances |
|
130 for ( TInt i = 0; i < pluginCount; i++ ) |
|
131 { |
|
132 // Get next implementation info |
|
133 CImplementationInformation* info = |
|
134 static_cast<CImplementationInformation*>( implInfoArray[i] ); |
|
135 |
|
136 COMPONENT_TRACE( ( _L( "PSM Server - CPsmPluginLoader::InitializePluginsL - create plugin 0x%x started" ), |
|
137 info->ImplementationUid().iUid) ); |
|
138 |
|
139 // Create new instance of the plugin |
|
140 CPsmSrvPlugin* plugin = NULL; |
|
141 TRAPD(err, plugin = CPsmSrvPlugin::NewL( iManager, info->ImplementationUid() )); |
|
142 if( err == KErrNone ) |
|
143 { |
|
144 // Add plugin to array |
|
145 CleanupStack::PushL( plugin ); |
|
146 User::LeaveIfError( iPluginArray.Append( plugin ) ); |
|
147 CleanupStack::Pop( plugin ); |
|
148 } |
|
149 COMPONENT_TRACE( ( _L( "PSM Server - CPsmPluginLoader::InitializePluginsL - create plugin 0x%x ended with code %d" ), |
|
150 info->ImplementationUid().iUid, err ) ); |
|
151 } |
|
152 |
|
153 // Reset and destroy implementations infos |
|
154 CleanupStack::PopAndDestroy(&implInfoArray); |
|
155 |
|
156 COMPONENT_TRACE( ( _L( "PSM Server - CPsmPluginLoader::InitializePluginsL - return plugin count: %d" ), pluginCount ) ); |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CPsmPluginLoader::NotifyPlugins |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 void CPsmPluginLoader::NotifyPlugins() |
|
164 { |
|
165 COMPONENT_TRACE( ( _L( "PSM Server - CPsmPluginLoader::NotifyPlugins()" ) ) ); |
|
166 |
|
167 // Current mode |
|
168 const TPsmsrvMode mode( iManager.SettingsProvider().Mode() ); |
|
169 |
|
170 // Loop plugins and notify |
|
171 for ( TInt i = 0; i < iPluginArray.Count(); i++ ) |
|
172 { |
|
173 iPluginArray[ i ]->NotifyModeChange( mode ); |
|
174 } |
|
175 |
|
176 COMPONENT_TRACE( ( _L( "PSM Server - CPsmPluginLoader::NotifyPlugins - return" ) ) ); |
|
177 } |
|
178 |
|
179 // End of file |