|
1 /* |
|
2 * Copyright (c) 2007-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: For CSC needed Aiw handling for ui extension plug-ins |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <eikenv.h> |
|
20 #include <bautils.h> |
|
21 #include <pathinfo.h> |
|
22 #include <SWInstApi.h> |
|
23 #include <SWInstDefs.h> |
|
24 #include <AiwCommon.hrh> |
|
25 #include <cscengine.rsg> |
|
26 #include <AiwServiceHandler.h> |
|
27 #include <data_caging_path_literals.hrh> |
|
28 |
|
29 #include "cscenglogger.h" |
|
30 #include "cscengstartuphandler.h" |
|
31 #include "mcscenguiextensionobserver.h" |
|
32 #include "cscenguiextensionpluginhandler.h" |
|
33 |
|
34 // Resource file location. |
|
35 _LIT( KCSCEngineResourceFile, "cscengine.rsc" ); // file |
|
36 |
|
37 // ======== MEMBER FUNCTIONS ======== |
|
38 |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 CCSCEngUiExtensionPluginHandler::CCSCEngUiExtensionPluginHandler( |
|
44 CEikonEnv& aEikEnv, |
|
45 MCSCEngUiExtensionObserver& aObserver, |
|
46 CCSCEngStartupHandler& aStartupHandler ): |
|
47 iEikEnv( aEikEnv ), |
|
48 iObserver( aObserver ), |
|
49 iStartupHandler( aStartupHandler ) |
|
50 { |
|
51 } |
|
52 |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 void CCSCEngUiExtensionPluginHandler::ConstructL() |
|
58 { |
|
59 CSCENGDEBUG( "CCSCEngUiExtensionPluginHandler::ConstructL - begin" ); |
|
60 |
|
61 // Attach to AIW Framework. |
|
62 iServiceHandler = CAiwServiceHandler::NewL(); |
|
63 |
|
64 // Load resource file to the memory. |
|
65 TFileName resourceFile = TParsePtrC( PathInfo::RomRootPath() ).Drive(); |
|
66 resourceFile.Append( KDC_RESOURCE_FILES_DIR ); |
|
67 resourceFile.Append( KCSCEngineResourceFile ); |
|
68 BaflUtils::NearestLanguageFile( iEikEnv.FsSession(), resourceFile ); |
|
69 iResourceOffset = iEikEnv.AddResourceFileL( resourceFile ); |
|
70 |
|
71 CSCENGDEBUG( "CCSCEngUiExtensionPluginHandler::ConstructL - end" ); |
|
72 } |
|
73 |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 EXPORT_C CCSCEngUiExtensionPluginHandler* |
|
79 CCSCEngUiExtensionPluginHandler::NewL( |
|
80 CEikonEnv& aEikEnv, |
|
81 MCSCEngUiExtensionObserver& aObserver, |
|
82 CCSCEngStartupHandler& aStartupHandler ) |
|
83 { |
|
84 CCSCEngUiExtensionPluginHandler* self = |
|
85 CCSCEngUiExtensionPluginHandler::NewLC( |
|
86 aEikEnv, aObserver, aStartupHandler ); |
|
87 CleanupStack::Pop( self ); |
|
88 return self; |
|
89 } |
|
90 |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 EXPORT_C CCSCEngUiExtensionPluginHandler* |
|
96 CCSCEngUiExtensionPluginHandler::NewLC( |
|
97 CEikonEnv& aEikEnv, |
|
98 MCSCEngUiExtensionObserver& aObserver, |
|
99 CCSCEngStartupHandler& aStartupHandler ) |
|
100 { |
|
101 CCSCEngUiExtensionPluginHandler* self = |
|
102 new ( ELeave ) CCSCEngUiExtensionPluginHandler( |
|
103 aEikEnv, aObserver, aStartupHandler ); |
|
104 |
|
105 CleanupStack::PushL( self ); |
|
106 self->ConstructL(); |
|
107 return self; |
|
108 } |
|
109 |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 CCSCEngUiExtensionPluginHandler::~CCSCEngUiExtensionPluginHandler() |
|
115 { |
|
116 CSCENGDEBUG( |
|
117 "CCSCEngUiExtensionPluginHandler::~CCSCEngUiExtensionPluginHandler - begin" ); |
|
118 |
|
119 iEikEnv.DeleteResourceFile( iResourceOffset ); |
|
120 iUiExtensionPluginInfoArray.Reset(); |
|
121 iUiExtensionPluginInfoArray.Close(); |
|
122 delete iServiceHandler; |
|
123 |
|
124 CSCENGDEBUG( |
|
125 "CCSCEngUiExtensionPluginHandler::~CCSCEngUiExtensionPluginHandler - end" ); |
|
126 } |
|
127 |
|
128 |
|
129 // --------------------------------------------------------------------------- |
|
130 // Initializes CSC supported ui extension plugins. |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 EXPORT_C void CCSCEngUiExtensionPluginHandler::InitializePluginsL() |
|
134 { |
|
135 CSCENGDEBUG( |
|
136 "CCSCEngUiExtensionPluginHandler::InitializePluginsL - begin" ); |
|
137 |
|
138 // Attach to CSC supported ui extension plugins and execute initalization. |
|
139 iServiceHandler->AttachL( R_CSCENG_INTEREST_UI_EXT_PLUGIN ); |
|
140 |
|
141 iServiceHandler->ExecuteServiceCmdL( |
|
142 KAiwCmdCSCUiExtensionPlugins, |
|
143 iServiceHandler->InParamListL(), |
|
144 iServiceHandler->OutParamListL(), |
|
145 EPluginInitialize, |
|
146 this ); |
|
147 |
|
148 CSCENGDEBUG( |
|
149 "CCSCEngUiExtensionPluginHandler::InitializePluginsL - end" ); |
|
150 } |
|
151 |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // Launches plugin provided setting view. |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 EXPORT_C void CCSCEngUiExtensionPluginHandler::LaunchUiExtensionL( |
|
158 const TUid& aPluginUid, const TUid& aViewUid, TBool aLaunchedFromAI ) |
|
159 { |
|
160 CSCENGDEBUG( |
|
161 "CCSCEngUiExtensionPluginHandler::LaunchUiExtensionL - begin" ); |
|
162 |
|
163 // Set plugins Uid to generic param data. |
|
164 CAiwGenericParamList& paramList = iServiceHandler->OutParamListL(); |
|
165 TAiwVariant variant( aPluginUid ); |
|
166 TAiwGenericParam genericParamUid( EGenericParamError, variant ); |
|
167 paramList.AppendL( genericParamUid ); |
|
168 |
|
169 // Set view id to be returned to generic param data. |
|
170 variant.Reset(); |
|
171 variant.Set( aViewUid ); |
|
172 TAiwGenericParam genericParamViewId( EGenericParamError, variant ); |
|
173 paramList.AppendL( genericParamViewId ); |
|
174 |
|
175 // Set URL to generic param data if set in CSC startup. |
|
176 TBuf<KMaxFileName> url; |
|
177 TInt err = iStartupHandler.GetParamUrl( url ); |
|
178 |
|
179 if ( !err ) |
|
180 { |
|
181 variant.Reset(); |
|
182 variant.Set( url ); |
|
183 TAiwGenericParam genericParamURL( EGenericParamError, variant ); |
|
184 paramList.AppendL( genericParamURL ); |
|
185 } |
|
186 |
|
187 // Execute service handler command. |
|
188 if ( aLaunchedFromAI ) |
|
189 { |
|
190 iServiceHandler->ExecuteServiceCmdL( KAiwCmdCSCUiExtensionPlugins, |
|
191 iServiceHandler->InParamListL(), |
|
192 paramList, |
|
193 EPluginOpenExtensionViewFromAI, |
|
194 this ); |
|
195 } |
|
196 else |
|
197 { |
|
198 iServiceHandler->ExecuteServiceCmdL( KAiwCmdCSCUiExtensionPlugins, |
|
199 iServiceHandler->InParamListL(), |
|
200 paramList, |
|
201 EPluginOpenExtensionView, |
|
202 this ); |
|
203 } |
|
204 |
|
205 |
|
206 CSCENGDEBUG( |
|
207 "CCSCEngUiExtensionPluginHandler::LaunchUiExtensionL - end" ); |
|
208 } |
|
209 |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // Returns item from UI Extension plug-in array |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 EXPORT_C TUiExtensionPluginInfo |
|
216 CCSCEngUiExtensionPluginHandler::ItemFromPluginInfoArray( TInt aIndex ) |
|
217 { |
|
218 CSCENGDEBUG( "CCSCEngUiExtensionPluginHandler::ItemFromPluginInfoArray" ); |
|
219 |
|
220 return iUiExtensionPluginInfoArray[ aIndex ]; |
|
221 } |
|
222 |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // Returns plugin counts from UiExtensionPluginsInfoArray. |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 EXPORT_C TInt CCSCEngUiExtensionPluginHandler::PluginCount() const |
|
229 { |
|
230 CSCENGDEBUG2( |
|
231 "CCSCEngUiExtensionPluginHandler::PluginCount: %d", |
|
232 iUiExtensionPluginInfoArray.Count() ); |
|
233 |
|
234 return iUiExtensionPluginInfoArray.Count(); |
|
235 } |
|
236 |
|
237 |
|
238 // --------------------------------------------------------------------------- |
|
239 // From class MAiwNotifyCallBack |
|
240 // Handles received callbacks from AIW plugin. |
|
241 // --------------------------------------------------------------------------- |
|
242 // |
|
243 TInt CCSCEngUiExtensionPluginHandler::HandleNotifyL( |
|
244 TInt /*aCmdId*/, |
|
245 TInt aEventId, |
|
246 CAiwGenericParamList& /*aEventParamList*/, |
|
247 const CAiwGenericParamList& aInParamList ) |
|
248 { |
|
249 CSCENGDEBUG( "CCSCEngUiExtensionPluginHandler::HandleNotifyL - begin"); |
|
250 |
|
251 TInt err( KErrNone ); |
|
252 |
|
253 switch ( aEventId ) |
|
254 { |
|
255 case KAiwEventStarted: |
|
256 { |
|
257 CSCENGDEBUG( |
|
258 "CCSCEngUiExtensionPluginHandler::HandleNotifyL KAiwEventStarted" ); |
|
259 |
|
260 SetPluginInitInfo( aInParamList ); |
|
261 |
|
262 TInt index( 0 ); |
|
263 TUid pluginUid( KNullUid ); |
|
264 |
|
265 GetPluginIndexAndUid( aInParamList, index, pluginUid ); |
|
266 |
|
267 iObserver.NotifyUiExtensionPluginResponse( |
|
268 EPluginInitialized, index, pluginUid ); |
|
269 break; |
|
270 } |
|
271 case KAiwEventStopped: |
|
272 { |
|
273 TInt index( 0 ); |
|
274 TUid pluginUid( KNullUid ); |
|
275 |
|
276 GetPluginIndexAndUid( aInParamList, index, pluginUid ); |
|
277 |
|
278 iObserver.NotifyUiExtensionPluginResponse( |
|
279 EPluginExited, index, pluginUid ); |
|
280 |
|
281 CSCENGDEBUG( |
|
282 "CCSCEngUiExtensionPluginHandler::HandleNotifyL KAiwEventStopped" ); |
|
283 break; |
|
284 } |
|
285 case KAiwEventError: |
|
286 { |
|
287 TInt index( 0 ); |
|
288 TUid pluginUid( KNullUid ); |
|
289 |
|
290 GetPluginIndexAndUid( aInParamList, index, pluginUid ); |
|
291 |
|
292 iObserver.NotifyUiExtensionPluginResponse( |
|
293 EPluginError, index, pluginUid ); |
|
294 |
|
295 CSCENGDEBUG( |
|
296 "CCSCEngUiExtensionPluginHandler::HandleNotifyL KAiwEventError" ); |
|
297 break; |
|
298 } |
|
299 default: |
|
300 CSCENGDEBUG( |
|
301 "CCSCEngUiExtensionPluginHandler::HandleNotifyL: !!DEFAULT!!" ); |
|
302 break; |
|
303 } |
|
304 |
|
305 CSCENGDEBUG( "CCSCEngUiExtensionPluginHandler::HandleNotifyL - end" ); |
|
306 |
|
307 return err; |
|
308 } |
|
309 |
|
310 |
|
311 // --------------------------------------------------------------------------- |
|
312 // For getting plug-ins index in plug-in info array and plug-ins uid. |
|
313 // --------------------------------------------------------------------------- |
|
314 // |
|
315 void CCSCEngUiExtensionPluginHandler::GetPluginIndexAndUid( |
|
316 const CAiwGenericParamList& aInParamList, |
|
317 TInt aIndex, |
|
318 TUid aPluginUid ) |
|
319 { |
|
320 const TAiwGenericParam* genericParam = NULL; |
|
321 |
|
322 // First and only generic value is plugins uid value. |
|
323 genericParam = aInParamList.FindFirst( aIndex, |
|
324 EGenericParamError, |
|
325 EVariantTypeTUid ); |
|
326 |
|
327 aPluginUid = genericParam->Value().AsTUid(); |
|
328 |
|
329 for ( TInt i = 0; i < iUiExtensionPluginInfoArray.Count(); i++ ) |
|
330 { |
|
331 if ( aPluginUid == iUiExtensionPluginInfoArray[ i ].iPluginsUid ) |
|
332 { |
|
333 aIndex = i; |
|
334 break; |
|
335 } |
|
336 } |
|
337 } |
|
338 |
|
339 |
|
340 // --------------------------------------------------------------------------- |
|
341 // For parsing and settings plug-in initialization info |
|
342 // --------------------------------------------------------------------------- |
|
343 // |
|
344 void CCSCEngUiExtensionPluginHandler::SetPluginInitInfo( |
|
345 const CAiwGenericParamList& aInParamList ) |
|
346 { |
|
347 CSCENGDEBUG( |
|
348 "CCSCEngUiExtensionPluginHandler::SetPluginInitInfoL - begin" ); |
|
349 |
|
350 TUiExtensionPluginInfo pluginInfo; |
|
351 |
|
352 TInt index = 0; |
|
353 |
|
354 if ( aInParamList.Count() ) |
|
355 { |
|
356 const TAiwGenericParam* genericParam = NULL; |
|
357 |
|
358 // First generic value is plugin Uid. |
|
359 genericParam = aInParamList.FindFirst( index, |
|
360 EGenericParamError, |
|
361 EVariantTypeTUid ); |
|
362 |
|
363 pluginInfo.iPluginsUid = genericParam->Value().AsTUid(); |
|
364 |
|
365 // Second generic value is UI extension´s name. |
|
366 genericParam = aInParamList.FindNext( index, |
|
367 EGenericParamError, |
|
368 EVariantTypeDesC ); |
|
369 |
|
370 pluginInfo.iUiExtensionName.Copy( genericParam->Value().AsDes() ); |
|
371 |
|
372 // Third generic value is ui extension´s placing info |
|
373 // 0 = listbox, 1 = options menu |
|
374 genericParam = aInParamList.FindNext( index, |
|
375 EGenericParamError, |
|
376 EVariantTypeTInt32 ); |
|
377 |
|
378 TInt32 place = genericParam->Value().AsTInt32(); |
|
379 pluginInfo.iPlace = place; |
|
380 |
|
381 CSCENGDEBUG2( |
|
382 "CCSCEngUiExtensionPluginHandler::SetPluginInitInfoL Place: %d", |
|
383 place ); |
|
384 } |
|
385 |
|
386 iUiExtensionPluginInfoArray.Append( pluginInfo ); |
|
387 |
|
388 CSCENGDEBUG( |
|
389 "CCSCEngUiExtensionPluginHandler::SetPluginInitInfoL - end" ); |
|
390 } |