|
1 /* |
|
2 * Copyright (c) 2005-2008 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: Main AI framework class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <bautils.h> |
|
20 #include <coemain.h> |
|
21 #include <ConeResLoader.h> |
|
22 #include <e32property.h> |
|
23 #include <startupdomainpskeys.h> |
|
24 #include <activeidle2domainpskeys.h> |
|
25 #include <activeidle2internalpskeys.h> |
|
26 #include <cenrepnotifyhandler.h> |
|
27 #include <aipspropertyobserver.h> |
|
28 #include <aisystemuids.hrh> |
|
29 |
|
30 #include <AknWaitDialog.h> |
|
31 #include <AknGlobalNote.h> |
|
32 #include <StringLoader.h> |
|
33 |
|
34 |
|
35 #include <e32cmn.h> |
|
36 #include <e32def.h> |
|
37 |
|
38 #include "aifw.h" |
|
39 #include "aifwpanic.h" |
|
40 #include "aiutility.h" |
|
41 #include "aiuicontrollermanager.h" |
|
42 #include "aiuicontroller.h" |
|
43 #include "aicontentmodel.h" |
|
44 #include "aicontentpluginmanager.h" |
|
45 #include "aiwspluginmanager.h" |
|
46 #include "aipluginstatemanager.h" |
|
47 #include "aiidleappregister.h" |
|
48 #include "debug.h" |
|
49 |
|
50 #include <centralrepository.h> |
|
51 #include <activeidle2domaincrkeys.h> |
|
52 #include "ainetworklistener.h" |
|
53 |
|
54 |
|
55 #include <data_caging_path_literals.hrh> |
|
56 |
|
57 // ======== MEMBER FUNCTIONS ======== |
|
58 |
|
59 // ---------------------------------------------------------------------------- |
|
60 // CAiFw::NewL() |
|
61 // ---------------------------------------------------------------------------- |
|
62 // |
|
63 CAiFw::CAiFw() |
|
64 { |
|
65 } |
|
66 |
|
67 // ---------------------------------------------------------------------------- |
|
68 // CAiFw::ConstructL() |
|
69 // ---------------------------------------------------------------------------- |
|
70 // |
|
71 void CAiFw::ConstructL() |
|
72 { |
|
73 #if 0 |
|
74 // For AI3_test |
|
75 RProcess proc; |
|
76 // 0x102750F0 in AI3, 0x2001CB4F in AI3_Test |
|
77 TSecureId secId( proc.SecureId() ); |
|
78 |
|
79 if( secId == 0x2001CB4F ) |
|
80 { |
|
81 iAIRepository = CRepository::NewL( TUid::Uid( 0x2001952B ) ); |
|
82 } |
|
83 else |
|
84 { |
|
85 iAIRepository = CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) ); |
|
86 } |
|
87 #else |
|
88 iAIRepository = CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) ); |
|
89 #endif |
|
90 |
|
91 TInt value( 0 ); |
|
92 |
|
93 iAIRepository->Get( KAiMainUIController, value ); |
|
94 |
|
95 if( !( value == AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_XML || |
|
96 value == AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_NATIVE || |
|
97 value == AI3_UID_ECOM_IMPLEMENTATION_UICONTROLLER_XML || |
|
98 value == AI3_UID_ECOM_IMPLEMENTATION_UICONTROLLER_NATIVE ) ) |
|
99 { |
|
100 // Someone wrote an invalid configuration! Reset repository. |
|
101 iAIRepository->Reset( KAiMainUIController ); |
|
102 iAIRepository->Reset( KAiFirstUIController ); |
|
103 iAIRepository->Delete( KAiFirstUIController + 1 ); |
|
104 } |
|
105 |
|
106 iUiControllerManager = CAiUiControllerManager::NewL(); |
|
107 |
|
108 iPluginManager = CAiContentPluginManager::NewL(); |
|
109 |
|
110 // Hook framework as UI event observer |
|
111 iUiControllerManager->SetEventHandler( *this ); |
|
112 } |
|
113 |
|
114 // ---------------------------------------------------------------------------- |
|
115 // CAiFw::NewLC() |
|
116 // ---------------------------------------------------------------------------- |
|
117 // |
|
118 EXPORT_C CAiFw* CAiFw::NewLC() |
|
119 { |
|
120 CAiFw* self = new ( ELeave ) CAiFw; |
|
121 CleanupStack::PushL( self ); |
|
122 self->ConstructL(); |
|
123 |
|
124 __TICK( "FW: Core FW constructed" ); |
|
125 __HEAP( "FW: Core FW constructed" ); |
|
126 |
|
127 return self; |
|
128 } |
|
129 |
|
130 // ---------------------------------------------------------------------------- |
|
131 // CAiFw::~CAiFw() |
|
132 // ---------------------------------------------------------------------------- |
|
133 // |
|
134 CAiFw::~CAiFw() |
|
135 { |
|
136 if( iPluginManager ) |
|
137 { |
|
138 delete iPluginManager; |
|
139 iPluginManager = NULL; |
|
140 } |
|
141 |
|
142 if( iIdleRestartObserver ) |
|
143 { |
|
144 Release( iIdleRestartObserver ); |
|
145 iIdleRestartObserver = NULL; |
|
146 } |
|
147 |
|
148 if( iWsPluginManager ) |
|
149 { |
|
150 delete iWsPluginManager; |
|
151 iWsPluginManager = NULL; |
|
152 } |
|
153 |
|
154 if( iUiControllerManager ) |
|
155 { |
|
156 delete iUiControllerManager; |
|
157 iUiControllerManager = NULL; |
|
158 } |
|
159 |
|
160 if( iNotifyHandler ) |
|
161 { |
|
162 iNotifyHandler->StopListening(); |
|
163 delete iNotifyHandler; |
|
164 iNotifyHandler = NULL; |
|
165 } |
|
166 |
|
167 if( iNotifyHandlerESS ) |
|
168 { |
|
169 iNotifyHandlerESS->StopListening(); |
|
170 delete iNotifyHandlerESS; |
|
171 iNotifyHandlerESS = NULL; |
|
172 } |
|
173 |
|
174 if( iAIRepository ) |
|
175 { |
|
176 delete iAIRepository; |
|
177 iAIRepository = NULL; |
|
178 } |
|
179 |
|
180 iLibrary1.Close(); |
|
181 iLibrary2.Close(); |
|
182 iLibrary3.Close(); |
|
183 } |
|
184 |
|
185 // ---------------------------------------------------------------------------- |
|
186 // CAiFw::RunL() |
|
187 // ---------------------------------------------------------------------------- |
|
188 // |
|
189 EXPORT_C void CAiFw::RunL() |
|
190 { |
|
191 CAiIdleAppRegister* idleReg = CAiIdleAppRegister::NewLC(); |
|
192 idleReg->RegisterL(); |
|
193 CleanupStack::PopAndDestroy( idleReg ); |
|
194 |
|
195 // Tell UI controller manager to start application framework and event loop. |
|
196 // This function returns only when the application is shut down. |
|
197 // See in CAiFw::HandleUiReadyEventL how the framework initialization continues. |
|
198 iUiControllerManager->RunApplicationL(); |
|
199 } |
|
200 |
|
201 // ---------------------------------------------------------------------------- |
|
202 // CAiFw::AppEnvReadyL() |
|
203 // ---------------------------------------------------------------------------- |
|
204 // |
|
205 void CAiFw::AppEnvReadyL() |
|
206 { |
|
207 // Initialize members which need to be connected to the app environment's |
|
208 // active scheduler or depend on the app environment being initialized. |
|
209 |
|
210 // Create state managers system state observers |
|
211 CAiPluginStateManager& stateManager( iPluginManager->StateManager() ); |
|
212 |
|
213 stateManager.CreateSystemStateObserversL(); |
|
214 |
|
215 // Connect state managers UI observer to UI controllers |
|
216 MAiUiFrameworkObserver* fwObserver( stateManager.UiFwObserver() ); |
|
217 |
|
218 if ( fwObserver ) |
|
219 { |
|
220 iUiControllerManager->AddObserverL( *fwObserver ); |
|
221 } |
|
222 |
|
223 // Create WS pluign manager |
|
224 iWsPluginManager = CAiWsPluginManager::NewL |
|
225 ( iUiControllerManager->CoeEnv() ); |
|
226 |
|
227 // CenRep notifier to listen key changes in cenrep. Application is restarted |
|
228 // if key value is changed. |
|
229 iNotifyHandler = CCenRepNotifyHandler::NewL( *this, |
|
230 *iAIRepository, |
|
231 CCenRepNotifyHandler::EIntKey, |
|
232 KAiMainUIController ); |
|
233 iNotifyHandler->StartListeningL(); |
|
234 |
|
235 // Cenrep notifier to listen ESS changes in cenrep |
|
236 // |
|
237 iNotifyHandlerESS = CCenRepNotifyHandler::NewL( *this, |
|
238 *iAIRepository, |
|
239 CCenRepNotifyHandler::EIntKey, |
|
240 KAIExternalStatusScreen ); |
|
241 iNotifyHandlerESS->StartListeningL(); |
|
242 |
|
243 iIdleRestartObserver = AiUtility::CreatePSPropertyObserverL( |
|
244 TCallBack( HandleRestartEvent, this ), |
|
245 KPSUidAiInformation, |
|
246 KActiveIdleRestartAI2 ); |
|
247 |
|
248 stateManager.ReportStateChange( ESMAISystemBoot ); |
|
249 } |
|
250 |
|
251 // ---------------------------------------------------------------------------- |
|
252 // CAiFw::HandleUiReadyEventL() |
|
253 // ---------------------------------------------------------------------------- |
|
254 // |
|
255 void CAiFw::HandleUiReadyEventL( CAiUiController& aUiController ) |
|
256 { |
|
257 if( iUiControllerManager->IsMainUiController( aUiController ) ) |
|
258 { |
|
259 iUiControllerManager->LoadUIDefinition(); |
|
260 |
|
261 TInt value( EIdlePhase1Ok ); |
|
262 |
|
263 RProperty::Get( KPSUidStartup, |
|
264 KPSIdlePhase1Ok, |
|
265 value ); |
|
266 |
|
267 if( value == EIdlePhase1NOK ) |
|
268 { |
|
269 RProperty::Set( KPSUidStartup, |
|
270 KPSIdlePhase1Ok, |
|
271 EIdlePhase1Ok ); |
|
272 } |
|
273 |
|
274 if( !iLibrariesLoaded ) |
|
275 { |
|
276 _LIT( KAIVoiceUIDialer, "VoiceUiNameDialer.dll" ); |
|
277 _LIT( KAIVoiceUIRecog, "VoiceUiRecognition.dll" ); |
|
278 _LIT( KAIVCommandHandler, "vcommandhandler.dll" ); |
|
279 |
|
280 iLibrary1.Load( KAIVoiceUIDialer ); |
|
281 iLibrary2.Load( KAIVoiceUIRecog ); |
|
282 iLibrary3.Load( KAIVCommandHandler ); |
|
283 |
|
284 iLibrariesLoaded = ETrue; |
|
285 } |
|
286 |
|
287 } |
|
288 } |
|
289 |
|
290 // --------------------------------------------------------------------------- |
|
291 // CAiFw::HandleActivateUI() |
|
292 // ---------------------------------------------------------------------------- |
|
293 // |
|
294 void CAiFw::HandleActivateUI() |
|
295 { |
|
296 iUiControllerManager->ActivateUI(); |
|
297 } |
|
298 |
|
299 // --------------------------------------------------------------------------- |
|
300 // CAiFw::HandleUiShutdown() |
|
301 // ---------------------------------------------------------------------------- |
|
302 // |
|
303 void CAiFw::HandleUiShutdown( CAiUiController& aUiController ) |
|
304 { |
|
305 if( iUiControllerManager->IsMainUiController( aUiController ) ) |
|
306 { |
|
307 if( iNotifyHandler ) |
|
308 { |
|
309 iNotifyHandler->StopListening(); |
|
310 delete iNotifyHandler; |
|
311 iNotifyHandler = NULL; |
|
312 } |
|
313 |
|
314 if( iNotifyHandlerESS ) |
|
315 { |
|
316 iNotifyHandlerESS->StopListening(); |
|
317 delete iNotifyHandlerESS; |
|
318 iNotifyHandlerESS = NULL; |
|
319 } |
|
320 |
|
321 iPluginManager->PluginFactory().DestroyPlugins(); |
|
322 |
|
323 iPluginManager->StateManager().DestroySystemStateObservers(); |
|
324 |
|
325 iUiControllerManager->DestroySecondaryUiControllers(); |
|
326 |
|
327 iUiControllerManager->RemoveObserver( |
|
328 *iPluginManager->StateManager().UiFwObserver() ); |
|
329 |
|
330 if( iWsPluginManager ) |
|
331 { |
|
332 delete iWsPluginManager; |
|
333 iWsPluginManager = NULL; |
|
334 } |
|
335 |
|
336 if( iIdleRestartObserver ) |
|
337 { |
|
338 Release( iIdleRestartObserver ); |
|
339 iIdleRestartObserver = NULL; |
|
340 } |
|
341 } |
|
342 } |
|
343 |
|
344 // ---------------------------------------------------------------------------- |
|
345 // CAiFw::HandleLoadPluginL() |
|
346 // ---------------------------------------------------------------------------- |
|
347 // |
|
348 void CAiFw::HandleLoadPluginL( const TAiPublisherInfo& aPublisherInfo ) |
|
349 { |
|
350 iPluginManager->PluginFactory().CreatePluginL( |
|
351 aPublisherInfo, iUiControllerManager->UiControllers() ); |
|
352 } |
|
353 |
|
354 // ---------------------------------------------------------------------------- |
|
355 // CAiFw::HandleDestroyPluginL() |
|
356 // ---------------------------------------------------------------------------- |
|
357 // |
|
358 void CAiFw::HandleDestroyPluginL( const TAiPublisherInfo& aPublisherInfo ) |
|
359 { |
|
360 iPluginManager->PluginFactory().DestroyPluginL( |
|
361 aPublisherInfo, iUiControllerManager->UiControllers() ); |
|
362 } |
|
363 |
|
364 // ---------------------------------------------------------------------------- |
|
365 // CAiFw::HandlePluginEvent() |
|
366 // ---------------------------------------------------------------------------- |
|
367 // |
|
368 void CAiFw::HandlePluginEvent( const TDesC& aParam ) |
|
369 { |
|
370 iPluginManager->HandlePluginEvent( aParam ); |
|
371 } |
|
372 |
|
373 // ---------------------------------------------------------------------------- |
|
374 // CAiFw::HandlePluginEventL() |
|
375 // ---------------------------------------------------------------------------- |
|
376 // |
|
377 void CAiFw::HandlePluginEventL( const TAiPublisherInfo& aPublisherInfo, |
|
378 const TDesC& aParam ) |
|
379 { |
|
380 iPluginManager->HandlePluginEventL( aPublisherInfo, aParam ); |
|
381 } |
|
382 |
|
383 // ---------------------------------------------------------------------------- |
|
384 // CAiFw::HasMenuItemL() |
|
385 // ---------------------------------------------------------------------------- |
|
386 // |
|
387 TBool CAiFw::HasMenuItemL( const TAiPublisherInfo& aPublisherInfo, |
|
388 const TDesC& aMenuItem ) |
|
389 { |
|
390 return iPluginManager->HasMenuItemL( aPublisherInfo, aMenuItem ); |
|
391 } |
|
392 |
|
393 // ---------------------------------------------------------------------------- |
|
394 // CAiFw::RefreshContent() |
|
395 // ---------------------------------------------------------------------------- |
|
396 // |
|
397 TBool CAiFw::RefreshContent( const TDesC& aContentCid ) |
|
398 { |
|
399 return iPluginManager->RefreshContent( aContentCid ); |
|
400 } |
|
401 |
|
402 // ---------------------------------------------------------------------------- |
|
403 // CAiFw::ProcessStateChange() |
|
404 // ---------------------------------------------------------------------------- |
|
405 // |
|
406 void CAiFw::ProcessStateChange( TAifwStates aState ) |
|
407 { |
|
408 switch ( aState ) |
|
409 { |
|
410 case EAifwOnline : |
|
411 { |
|
412 iPluginManager->ProcessOnlineState( ETrue ); |
|
413 } |
|
414 break; |
|
415 case EAifwOffline : |
|
416 { |
|
417 iPluginManager->ProcessOnlineState( EFalse ); |
|
418 } |
|
419 break; |
|
420 case EAifwPageSwitch: |
|
421 { |
|
422 iPluginManager->StateManager().ReportStateChange( ESMAIPageSwitch ); |
|
423 } |
|
424 break; |
|
425 default : |
|
426 break; |
|
427 } |
|
428 |
|
429 } |
|
430 |
|
431 // ---------------------------------------------------------------------------- |
|
432 // CAiFw::QueryIsMenuOpen() |
|
433 // ---------------------------------------------------------------------------- |
|
434 // |
|
435 TBool CAiFw::QueryIsMenuOpen() |
|
436 { |
|
437 return iUiControllerManager->MainUiController().IsMenuOpen(); |
|
438 } |
|
439 |
|
440 // ---------------------------------------------------------------------------- |
|
441 // CAiFw::HandleNotifyInt() |
|
442 // ---------------------------------------------------------------------------- |
|
443 // |
|
444 void CAiFw::HandleNotifyInt( TUint32 aId, TInt aNewValue ) |
|
445 { |
|
446 switch( aId ) |
|
447 { |
|
448 case KAiMainUIController: |
|
449 if( aNewValue == AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_XML || |
|
450 aNewValue == AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_NATIVE || |
|
451 aNewValue == AI3_UID_ECOM_IMPLEMENTATION_UICONTROLLER_XML || |
|
452 aNewValue == AI3_UID_ECOM_IMPLEMENTATION_UICONTROLLER_NATIVE ) |
|
453 { |
|
454 iUiControllerManager->ExitMainController(); |
|
455 } |
|
456 else |
|
457 { |
|
458 // Someone wrote an invalid configuration! Reset repository. |
|
459 if( iAIRepository ) |
|
460 { |
|
461 iAIRepository->Reset( KAiMainUIController ); |
|
462 iAIRepository->Reset( KAiFirstUIController ); |
|
463 iAIRepository->Delete( KAiFirstUIController + 1 ); |
|
464 } |
|
465 } |
|
466 break; |
|
467 case KAIExternalStatusScreen: |
|
468 if( ( aNewValue & 0x7FFFFFFF ) != 0 ) |
|
469 { |
|
470 TRAP_IGNORE( SwapUiControllerL( EFalse ) ); |
|
471 } |
|
472 else |
|
473 { |
|
474 TRAP_IGNORE( SwapUiControllerL( ETrue ) ); |
|
475 } |
|
476 break; |
|
477 default: |
|
478 break; |
|
479 } |
|
480 } |
|
481 |
|
482 // ---------------------------------------------------------------------------- |
|
483 // CAiFw::SwapUiControllerL() |
|
484 // ---------------------------------------------------------------------------- |
|
485 // |
|
486 void CAiFw::SwapUiControllerL( TBool aToExtHS ) |
|
487 { |
|
488 TUid uid = { KCRUidActiveIdleLV }; |
|
489 CRepository* cenRep = CRepository::NewL( uid ); |
|
490 |
|
491 if( !aToExtHS ) // Switch to XML UI |
|
492 { |
|
493 cenRep->Create( KAiFirstUIController, |
|
494 AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_NATIVE ); |
|
495 |
|
496 cenRep->Set( KAiFirstUIController, |
|
497 AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_NATIVE ); |
|
498 cenRep->Delete( KAiFirstUIController + 1 ); |
|
499 |
|
500 cenRep->Set( KAiMainUIController, |
|
501 AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_XML ); |
|
502 } |
|
503 else // Switch to ExtHS |
|
504 { |
|
505 cenRep->Delete( KAiFirstUIController ); |
|
506 cenRep->Delete( KAiFirstUIController + 1 ); |
|
507 cenRep->Set( KAiMainUIController, |
|
508 AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_NATIVE ); |
|
509 } |
|
510 |
|
511 delete cenRep; |
|
512 |
|
513 // Restart |
|
514 iUiControllerManager->ExitMainController(); |
|
515 } |
|
516 |
|
517 // ---------------------------------------------------------------------------- |
|
518 // CAiFw::HandleRestartEvent() |
|
519 // ---------------------------------------------------------------------------- |
|
520 // |
|
521 TInt CAiFw::HandleRestartEvent( TAny* aSelf ) |
|
522 { |
|
523 CAiFw* self = static_cast<CAiFw*>( aSelf ); |
|
524 |
|
525 TInt value( 0 ); |
|
526 |
|
527 if( self->iIdleRestartObserver ) |
|
528 { |
|
529 TInt err( self->iIdleRestartObserver->Get( value ) ); |
|
530 |
|
531 // Check the PS keys value and call manager with approriate parameter. |
|
532 // Report either "idle foreground" or "idle background" |
|
533 if( value == KActiveIdleRestartCode ) |
|
534 { |
|
535 self->iUiControllerManager->ExitMainController(); |
|
536 } |
|
537 } |
|
538 |
|
539 return KErrNone; |
|
540 } |
|
541 |
|
542 // End of file |