|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <ecom/ecom.h> |
|
21 #include "featmgrpluginhandler.h" |
|
22 #include "featmgrclientserver.h" |
|
23 #include "featmgrdebug.h" |
|
24 #include "featmgrserver.h" |
|
25 |
|
26 // LOCAL CONSTANTS |
|
27 _LIT( KPanicCategory, "FeatMgrPluginHandler" ); |
|
28 |
|
29 // ============================= LOCAL FUNCTIONS =============================== |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CFeatMgrPluginHandler::CFeatMgrPluginHandler |
|
35 // C++ constructor |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CFeatMgrPluginHandler::CFeatMgrPluginHandler( CFeatMgrServer& aServer ) |
|
39 : iPlugin( NULL ), |
|
40 iServer( aServer ), |
|
41 iTransId( 0 ) // Is always 0 because there is only one transaction between handler and plugin. |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CFeatMgrPluginHandler::ConstructL |
|
47 // 2nd phase constructor gets plugin instance. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 void CFeatMgrPluginHandler::ConstructL( TUid aImplementationUid ) |
|
51 { |
|
52 FUNC_LOG |
|
53 |
|
54 // get plugin instance |
|
55 iPlugin = CFeatureInfoPlugin::NewL( aImplementationUid, *this ); |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CFeatMgrPluginHandler::NewL |
|
60 // Two-phased constructor. |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CFeatMgrPluginHandler* CFeatMgrPluginHandler::NewL( TUid aImplementationUid, |
|
64 CFeatMgrServer& aServer ) |
|
65 { |
|
66 CFeatMgrPluginHandler* self = new( ELeave ) CFeatMgrPluginHandler( aServer ); |
|
67 |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL( aImplementationUid ); |
|
70 CleanupStack::Pop( self ); |
|
71 |
|
72 return self; |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------- |
|
76 // Destructor |
|
77 // --------------------------------------------------------- |
|
78 // |
|
79 CFeatMgrPluginHandler::~CFeatMgrPluginHandler() |
|
80 { |
|
81 FUNC_LOG |
|
82 delete iPlugin; |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CFeatMgrPluginHandler::SendCommandL |
|
87 // Sends a command to plugin for processing. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CFeatMgrPluginHandler::SendCommandL( FeatureInfoCommand::TFeatureInfoCmd aCommandId ) |
|
91 { |
|
92 // Load feature info. |
|
93 iCommandId = aCommandId; |
|
94 iTransId++; |
|
95 TPtrC8 ptr(KNullDesC8); |
|
96 iPlugin->ProcessCommandL( iCommandId, iTransId, ptr ); |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CFeatMgrPluginHandler::ProcessResponseL |
|
101 // Routes response from plugin to server |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void CFeatMgrPluginHandler::ProcessResponseL( FeatureInfoCommand::TFeatureInfoCmd aCommandId, |
|
105 TUint8 aTransId, |
|
106 TDesC8& aData ) |
|
107 { |
|
108 FUNC_LOG |
|
109 |
|
110 INFO_LOG2( "CFeatMgrPluginHandler::ProcessResponseL( aCommandId 0x%x, aTransId 0x%x )", |
|
111 aCommandId, aTransId ); |
|
112 |
|
113 if ( iTransId == aTransId && |
|
114 ( aCommandId == FeatureInfoCommand::ELoadFeatureInfoCmdId || |
|
115 aCommandId == FeatureInfoCommand::ELoadEnhancedFeatureInfoCmdId ) && |
|
116 iCommandId == aCommandId ) |
|
117 { |
|
118 // Copy response and ask server to process it |
|
119 if( aCommandId == FeatureInfoCommand::ELoadFeatureInfoCmdId ) |
|
120 { |
|
121 RArray<FeatureInfoCommand::TFeature> featureList; |
|
122 CleanupClosePushL( featureList ); |
|
123 FeatureInfoCommand::TFeatureInfoRespPckg response; |
|
124 response.Copy( aData ); |
|
125 ProcessFeatureInfoL(featureList, response); |
|
126 CleanupStack::PopAndDestroy( &featureList ); |
|
127 } |
|
128 else if( aCommandId == FeatureInfoCommand::ELoadEnhancedFeatureInfoCmdId ) |
|
129 { |
|
130 RFeatureArray featureList; |
|
131 CleanupClosePushL( featureList ); |
|
132 FeatureInfoCommand::TEnhancedFeatureInfoRespPckg response; |
|
133 response.Copy( aData ); |
|
134 ProcessFeatureInfoL(featureList, response); |
|
135 CleanupStack::PopAndDestroy( &featureList ); |
|
136 } |
|
137 } |
|
138 else |
|
139 { |
|
140 ERROR_LOG2( "CFeatMgrPluginHandler::ProcessResponseL - Command ID , expected: 0x%x, got 0x%x", |
|
141 iCommandId, aCommandId ); |
|
142 ERROR_LOG2( "CFeatMgrPluginHandler::ProcessResponseL - Transaction ID , expected: 0x%x, got 0x%x", |
|
143 iTransId, aTransId ); |
|
144 User::Leave( KErrArgument ); |
|
145 } |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CFeatMgrPluginHandler::ProcessFeatureInfoL |
|
150 // Asks server to process specified response from plugin |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CFeatMgrPluginHandler::ProcessFeatureInfoL( |
|
154 RArray<FeatureInfoCommand::TFeature>& aList, |
|
155 FeatureInfoCommand::TFeatureInfoRespPckg aResponse ) |
|
156 { |
|
157 FUNC_LOG |
|
158 |
|
159 // Go through dynamic feature list. Possible multiple same entries resolved by server. |
|
160 TInt err( KErrNone ); |
|
161 TInt count = aResponse().iList.Count(); |
|
162 |
|
163 if ( aResponse().iErrorCode == KErrNone ) |
|
164 { |
|
165 for( TInt i = 0 ; i < count; i++) |
|
166 { |
|
167 INFO_LOG2( "CFeatMgrPluginHandler::ProcessFeatureInfoL - featureID %d, value %d", |
|
168 aResponse().iList[i].iFeatureID, aResponse().iList[i].iValue ); |
|
169 |
|
170 err = aList.Append( aResponse().iList[i] ); |
|
171 |
|
172 if ( err != KErrNone ) |
|
173 { |
|
174 ERROR_LOG1( "CFeatMgrPluginHandler::ProcessFeatureInfoL - Error %d when saving feature info", |
|
175 err ); |
|
176 break; |
|
177 } |
|
178 } |
|
179 |
|
180 if ( err == KErrNone ) |
|
181 { |
|
182 // Send feature info to the server |
|
183 iServer.FeatureInfoL( aList, this ); |
|
184 } |
|
185 else |
|
186 { |
|
187 INFO_LOG1( "CFeatMgrPluginHandler::ProcessFeatureInfoL - FeatureInfoL not called %d", err ); |
|
188 } |
|
189 } |
|
190 else |
|
191 { |
|
192 ERROR_LOG2( "CFeatMgrPluginHandler::ProcessFeatureInfoL - pluginhandler %x, error %d - going to panic", |
|
193 this, aResponse().iErrorCode ); |
|
194 // This is considered fatal enough reason to panic |
|
195 User::Panic( KPanicCategory, EPanicInvalidFeatureInfo ); |
|
196 } |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // CFeatMgrPluginHandler::ProcessFeatureInfoL |
|
201 // Asks server to process specified response from plugin |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 void CFeatMgrPluginHandler::ProcessFeatureInfoL( |
|
205 RFeatureArray& aList, |
|
206 FeatureInfoCommand::TEnhancedFeatureInfoRespPckg aResponse ) |
|
207 { |
|
208 FUNC_LOG |
|
209 |
|
210 // Go through dynamic feature list. Possible multiple same entries resolved by server. |
|
211 TInt err( KErrNone ); |
|
212 TInt count = aResponse().iList.Count(); |
|
213 |
|
214 if ( aResponse().iErrorCode == KErrNone ) |
|
215 { |
|
216 for( TInt i = 0 ; i < count; i++) |
|
217 { |
|
218 INFO_LOG2( "CFeatMgrPluginHandler::ProcessFeatureInfoL - featureID %d, data %d", |
|
219 aResponse().iList[i].FeatureUid(), aResponse().iList[i].FeatureData() ); |
|
220 |
|
221 err = aList.Append( aResponse().iList[i] ); |
|
222 |
|
223 if ( err != KErrNone ) |
|
224 { |
|
225 ERROR_LOG1( "CFeatMgrPluginHandler::ProcessFeatureInfoL - Error %d when saving feature info", |
|
226 err ); |
|
227 break; |
|
228 } |
|
229 } |
|
230 |
|
231 if ( err == KErrNone ) |
|
232 { |
|
233 // Send feature info to the server |
|
234 iServer.FeatureInfoL( aList, this ); |
|
235 } |
|
236 else |
|
237 { |
|
238 INFO_LOG1( "CFeatMgrPluginHandler::ProcessFeatureInfoL - FeatureInfoL not called %d", err ); |
|
239 } |
|
240 } |
|
241 else |
|
242 { |
|
243 ERROR_LOG2( "CFeatMgrPluginHandler::ProcessFeatureInfoL - pluginhandler %x, error %d - going to panic", |
|
244 this, aResponse().iErrorCode ); |
|
245 // This is considered fatal enough reason to panic |
|
246 User::Panic( KPanicCategory, EPanicInvalidFeatureInfo ); |
|
247 } |
|
248 } |
|
249 |
|
250 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
251 |
|
252 // End of File |