114
|
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 |
// System includes
|
|
19 |
#include <startupdomainpskeys.h>
|
|
20 |
#include <centralrepository.h>
|
|
21 |
#include <cenrepnotifyhandler.h>
|
|
22 |
|
|
23 |
// User includes
|
|
24 |
#include "aiuicontrollermanager.h"
|
|
25 |
#include "aiuicontroller.h"
|
|
26 |
#include "aieventhandler.h"
|
|
27 |
#include "aistatemanager.h"
|
|
28 |
#include "aistateprovider.h"
|
|
29 |
#include "aipluginfactory.h"
|
|
30 |
#include "aiwspluginmanager.h"
|
|
31 |
#include "aiidleappregister.h"
|
|
32 |
|
|
33 |
#include <activeidle2domaincrkeys.h>
|
|
34 |
#include <activeidle2domainpskeys.h>
|
|
35 |
#include <aipspropertyobserver.h>
|
|
36 |
#include <aisystemuids.hrh>
|
|
37 |
|
|
38 |
#include "aiutility.h"
|
|
39 |
#include "aifwpanic.h"
|
|
40 |
|
|
41 |
#include "aifw.h"
|
|
42 |
|
|
43 |
#include "debug.h"
|
|
44 |
|
|
45 |
// Constants
|
|
46 |
|
|
47 |
|
|
48 |
// ======== MEMBER FUNCTIONS ========
|
|
49 |
|
|
50 |
// ----------------------------------------------------------------------------
|
|
51 |
// CAiFw::CAiFw()
|
|
52 |
//
|
|
53 |
// ----------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
CAiFw::CAiFw()
|
|
56 |
{
|
|
57 |
}
|
|
58 |
|
|
59 |
// ----------------------------------------------------------------------------
|
|
60 |
// CAiFw::ConstructL()
|
|
61 |
//
|
|
62 |
// ----------------------------------------------------------------------------
|
|
63 |
//
|
|
64 |
void CAiFw::ConstructL()
|
|
65 |
{
|
|
66 |
__PRINTS( "*** CAiFw::ConstructL" );
|
|
67 |
__TIME_MARK( time );
|
|
68 |
#if 0
|
|
69 |
// For AI3_test
|
|
70 |
RProcess proc;
|
|
71 |
// 0x102750F0 in AI3, 0x2001CB4F in AI3_Test
|
|
72 |
TSecureId secId( proc.SecureId() );
|
|
73 |
|
|
74 |
if( secId == 0x2001CB4F )
|
|
75 |
{
|
|
76 |
iRepository = CRepository::NewL( TUid::Uid( 0x2001952B ) );
|
|
77 |
}
|
|
78 |
else
|
|
79 |
{
|
|
80 |
iRepository = CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) );
|
|
81 |
}
|
|
82 |
#else
|
|
83 |
iRepository = CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) );
|
|
84 |
#endif
|
|
85 |
|
|
86 |
TInt value( 0 );
|
|
87 |
|
|
88 |
iRepository->Get( KAiMainUIController, value );
|
|
89 |
|
|
90 |
if ( !( value == AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_XML ||
|
|
91 |
value == AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_NATIVE ||
|
|
92 |
value == AI3_UID_ECOM_IMPLEMENTATION_UICONTROLLER_XML ||
|
|
93 |
value == AI3_UID_ECOM_IMPLEMENTATION_UICONTROLLER_NATIVE ) )
|
|
94 |
{
|
|
95 |
// Someone wrote an invalid configuration! Reset repository.
|
|
96 |
iRepository->Reset( KAiMainUIController );
|
|
97 |
iRepository->Reset( KAiFirstUIController );
|
|
98 |
iRepository->Delete( KAiFirstUIController + 1 );
|
|
99 |
}
|
|
100 |
|
|
101 |
iUiControllerManager = CAiUiControllerManager::NewL( this );
|
|
102 |
|
|
103 |
iFactory = CAiPluginFactory::NewL( *iUiControllerManager );
|
|
104 |
|
|
105 |
iStateManager = CAiStateManager::NewL( *iFactory );
|
|
106 |
|
|
107 |
iStateProvider = CAiStateProvider::NewL( *iStateManager );
|
|
108 |
|
|
109 |
iEventHandler = CAiEventHandler::NewL( *iFactory );
|
|
110 |
|
|
111 |
iUiControllerManager->SetStateHandler( *iStateProvider );
|
|
112 |
|
|
113 |
__TIME_ENDMARK( "CAiFw::ConstructL, done", time );
|
|
114 |
}
|
|
115 |
|
|
116 |
// ----------------------------------------------------------------------------
|
|
117 |
// CAiFw::NewLC()
|
|
118 |
//
|
|
119 |
// ----------------------------------------------------------------------------
|
|
120 |
//
|
|
121 |
EXPORT_C CAiFw* CAiFw::NewLC()
|
|
122 |
{
|
|
123 |
__TICK( "CAiFw::NewLC" );
|
|
124 |
|
|
125 |
CAiFw* self = new ( ELeave ) CAiFw;
|
|
126 |
CleanupStack::PushL( self );
|
|
127 |
|
|
128 |
self->ConstructL();
|
|
129 |
|
|
130 |
__PRINTS( "*** CAiFw::NewLC - done" );
|
|
131 |
|
|
132 |
return self;
|
|
133 |
}
|
|
134 |
|
|
135 |
// ----------------------------------------------------------------------------
|
|
136 |
// CAiFw::~CAiFw()
|
|
137 |
//
|
|
138 |
// ----------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
CAiFw::~CAiFw()
|
|
141 |
{
|
|
142 |
if ( iNotifyHandler )
|
|
143 |
{
|
|
144 |
iNotifyHandler->StopListening();
|
|
145 |
}
|
|
146 |
|
|
147 |
delete iNotifyHandler;
|
|
148 |
iNotifyHandler = NULL;
|
|
149 |
|
|
150 |
if ( iNotifyHandlerESS )
|
|
151 |
{
|
|
152 |
iNotifyHandlerESS->StopListening();
|
|
153 |
}
|
|
154 |
|
|
155 |
delete iNotifyHandlerESS;
|
|
156 |
iNotifyHandlerESS = NULL;
|
|
157 |
|
|
158 |
delete iWsPluginManager;
|
|
159 |
iWsPluginManager = NULL;
|
|
160 |
|
|
161 |
delete iEventHandler;
|
|
162 |
iEventHandler = NULL;
|
|
163 |
|
|
164 |
delete iStateProvider;
|
|
165 |
iStateProvider = NULL;
|
|
166 |
|
|
167 |
delete iStateManager;
|
|
168 |
iStateManager = NULL;
|
|
169 |
|
|
170 |
delete iFactory;
|
|
171 |
iFactory = NULL;
|
|
172 |
|
|
173 |
delete iUiControllerManager;
|
|
174 |
iUiControllerManager = NULL;
|
|
175 |
|
|
176 |
delete iRepository;
|
|
177 |
iRepository = NULL;
|
|
178 |
|
|
179 |
iLibrary1.Close();
|
|
180 |
iLibrary2.Close();
|
|
181 |
iLibrary3.Close();
|
|
182 |
}
|
|
183 |
|
|
184 |
// ----------------------------------------------------------------------------
|
|
185 |
// CAiFw::RunL()
|
|
186 |
//
|
|
187 |
// ----------------------------------------------------------------------------
|
|
188 |
//
|
|
189 |
EXPORT_C void CAiFw::RunL()
|
|
190 |
{
|
|
191 |
__TICK( "CAiFw::RunL" );
|
|
192 |
|
|
193 |
__PRINTS( "*** CAiFw::RunL - CAiIdleAppRegister::NewLC" );
|
|
194 |
__TIME_MARK( time );
|
|
195 |
|
|
196 |
CAiIdleAppRegister* registry = CAiIdleAppRegister::NewLC();
|
|
197 |
registry->RegisterL();
|
|
198 |
CleanupStack::PopAndDestroy( registry );
|
|
199 |
|
|
200 |
__TIME_ENDMARK( "CAiFw::RunL - CAiIdleAppRegister::NewLC, done", time );
|
|
201 |
|
|
202 |
// Tell UI controller manager to start application framework and event loop.
|
|
203 |
// This function returns only when the application is shut down.
|
|
204 |
iUiControllerManager->RunApplicationL();
|
|
205 |
|
|
206 |
__PRINTS( "*** CAiFw::RunL - done" );
|
|
207 |
}
|
|
208 |
|
|
209 |
// ----------------------------------------------------------------------------
|
|
210 |
// CAiFw::AppEnvReadyL()
|
|
211 |
//
|
|
212 |
// ----------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
void CAiFw::AppEnvReadyL()
|
|
215 |
{
|
|
216 |
__TICK( "CAiFw::AppEnvReadyL" );
|
|
217 |
__TIME_MARK( time );
|
|
218 |
|
|
219 |
// Initialize members which need to be connected to the app environment's
|
|
220 |
// active scheduler or depend on the app environment being initialized.
|
|
221 |
|
|
222 |
CCoeEnv& env( iUiControllerManager->CoeEnv() );
|
|
223 |
|
|
224 |
// Create WS pluign manager
|
|
225 |
iWsPluginManager = CAiWsPluginManager::NewL( env );
|
|
226 |
|
|
227 |
// Finalise factory construction
|
|
228 |
iFactory->ConstructL();
|
|
229 |
|
|
230 |
// Start state provider
|
|
231 |
iStateProvider->StartL( env );
|
|
232 |
|
|
233 |
// CenRep notifier to listen key changes in cenrep.
|
|
234 |
// Application is restarted if key value is changed.
|
|
235 |
iNotifyHandler = CCenRepNotifyHandler::NewL( *this, *iRepository,
|
|
236 |
CCenRepNotifyHandler::EIntKey, KAiMainUIController );
|
|
237 |
|
|
238 |
iNotifyHandler->StartListeningL();
|
|
239 |
|
|
240 |
// Cenrep notifier to listen ESS changes in cenrep
|
|
241 |
iNotifyHandlerESS = CCenRepNotifyHandler::NewL( *this, *iRepository,
|
|
242 |
CCenRepNotifyHandler::EIntKey, KAIExternalStatusScreen );
|
|
243 |
|
|
244 |
iNotifyHandlerESS->StartListeningL();
|
|
245 |
|
|
246 |
__PRINTS( "*** CAiFw::AppEnvReadyL - done" );
|
|
247 |
}
|
|
248 |
|
|
249 |
// ----------------------------------------------------------------------------
|
|
250 |
// CAiFw::HandleUiReadyEventL()
|
|
251 |
//
|
|
252 |
// ----------------------------------------------------------------------------
|
|
253 |
//
|
|
254 |
void CAiFw::HandleUiReadyEventL( CAiUiController& aUiController )
|
|
255 |
{
|
|
256 |
__TICK( "CAiFw::HandleUiReadyEventL" );
|
|
257 |
|
|
258 |
if ( iUiControllerManager->IsMainUiController( aUiController ) )
|
|
259 |
{
|
|
260 |
TInt value( EIdlePhase1Ok );
|
|
261 |
|
|
262 |
RProperty::Get( KPSUidStartup, KPSIdlePhase1Ok, value );
|
|
263 |
|
|
264 |
if ( value == EIdlePhase1NOK )
|
|
265 |
{
|
|
266 |
__TICK( "CAiFw::HandleUiReadyEventL - Setting EIdlePhase1Ok" );
|
|
267 |
|
|
268 |
RProperty::Set( KPSUidStartup, KPSIdlePhase1Ok, EIdlePhase1Ok );
|
|
269 |
}
|
|
270 |
|
|
271 |
if ( !iLibrariesLoaded )
|
|
272 |
{
|
|
273 |
__PRINTS( "*** CAiFw::HandleUiReadyEventL - load libraries" );
|
|
274 |
__TIME_MARK( time );
|
|
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 |
__TIME_ENDMARK( "CAiFw::HandleUiReadyEventL - load libraries, done", time );
|
|
287 |
}
|
|
288 |
}
|
|
289 |
|
|
290 |
__PRINTS( "*** CAiFw::HandleUiReadyEventL - done" );
|
|
291 |
}
|
|
292 |
|
|
293 |
// ---------------------------------------------------------------------------
|
|
294 |
// CAiFw::HandleActivateUI()
|
|
295 |
//
|
|
296 |
// ----------------------------------------------------------------------------
|
|
297 |
//
|
|
298 |
void CAiFw::HandleActivateUI()
|
|
299 |
{
|
|
300 |
__PRINTS( "*** CAiFw::HandleActivateUI" );
|
|
301 |
__TIME_MARK( time );
|
|
302 |
|
|
303 |
iUiControllerManager->LoadUIDefinition();
|
|
304 |
|
|
305 |
iUiControllerManager->ActivateUI();
|
|
306 |
|
|
307 |
__TIME_ENDMARK( "CAiFw::HandleActivateUI, done", time );
|
|
308 |
}
|
|
309 |
|
|
310 |
// ---------------------------------------------------------------------------
|
|
311 |
// CAiFw::HandleUiShutdown()
|
|
312 |
//
|
|
313 |
// ----------------------------------------------------------------------------
|
|
314 |
//
|
|
315 |
void CAiFw::HandleUiShutdown( CAiUiController& aUiController )
|
|
316 |
{
|
|
317 |
if ( iUiControllerManager->IsMainUiController( aUiController ) )
|
|
318 |
{
|
|
319 |
if ( iNotifyHandler )
|
|
320 |
{
|
|
321 |
iNotifyHandler->StopListening();
|
|
322 |
}
|
|
323 |
|
|
324 |
delete iNotifyHandler;
|
|
325 |
iNotifyHandler = NULL;
|
|
326 |
|
|
327 |
if ( iNotifyHandlerESS )
|
|
328 |
{
|
|
329 |
iNotifyHandlerESS->StopListening();
|
|
330 |
}
|
|
331 |
|
|
332 |
delete iNotifyHandlerESS;
|
|
333 |
iNotifyHandlerESS = NULL;
|
|
334 |
|
|
335 |
iUiControllerManager->DestroySecondaryUiControllers();
|
|
336 |
|
|
337 |
delete iWsPluginManager;
|
|
338 |
iWsPluginManager = NULL;
|
|
339 |
|
|
340 |
iStateProvider->Stop();
|
|
341 |
|
|
342 |
delete iFactory;
|
|
343 |
iFactory = NULL;
|
|
344 |
}
|
|
345 |
}
|
|
346 |
|
|
347 |
// ----------------------------------------------------------------------------
|
|
348 |
// CAiFw::HandlePluginEvent()
|
|
349 |
//
|
|
350 |
// ----------------------------------------------------------------------------
|
|
351 |
//
|
|
352 |
void CAiFw::HandlePluginEvent( const TDesC& aParam )
|
|
353 |
{
|
|
354 |
iEventHandler->HandlePluginEvent( aParam );
|
|
355 |
}
|
|
356 |
|
|
357 |
// ----------------------------------------------------------------------------
|
|
358 |
// CAiFw::HandlePluginEventL()
|
|
359 |
//
|
|
360 |
// ----------------------------------------------------------------------------
|
|
361 |
//
|
|
362 |
void CAiFw::HandlePluginEventL( const THsPublisherInfo& aPublisherInfo,
|
|
363 |
const TDesC& aParam )
|
|
364 |
{
|
|
365 |
iEventHandler->HandlePluginEventL( aPublisherInfo, aParam );
|
|
366 |
}
|
|
367 |
|
|
368 |
// ----------------------------------------------------------------------------
|
|
369 |
// CAiFw::HasMenuItemL()
|
|
370 |
//
|
|
371 |
// ----------------------------------------------------------------------------
|
|
372 |
//
|
|
373 |
TBool CAiFw::HasMenuItemL( const THsPublisherInfo& aPublisherInfo,
|
|
374 |
const TDesC& aMenuItem )
|
|
375 |
{
|
|
376 |
return iEventHandler->HasMenuItemL( aPublisherInfo, aMenuItem );
|
|
377 |
}
|
|
378 |
|
|
379 |
// ----------------------------------------------------------------------------
|
|
380 |
// CAiFw::RefreshContent()
|
|
381 |
//
|
|
382 |
// ----------------------------------------------------------------------------
|
|
383 |
//
|
|
384 |
TBool CAiFw::RefreshContent( const TDesC& aContentCid )
|
|
385 |
{
|
|
386 |
return iEventHandler->RefreshContent( aContentCid );
|
|
387 |
}
|
|
388 |
|
|
389 |
// ----------------------------------------------------------------------------
|
|
390 |
// CAiFw::RefreshContent()
|
|
391 |
//
|
|
392 |
// ----------------------------------------------------------------------------
|
|
393 |
//
|
|
394 |
TBool CAiFw::RefreshContent( const THsPublisherInfo& aPublisherInfo,
|
|
395 |
const TDesC& aContentCid )
|
|
396 |
{
|
|
397 |
return iEventHandler->RefreshContent( aPublisherInfo, aContentCid );
|
|
398 |
}
|
|
399 |
|
|
400 |
// ----------------------------------------------------------------------------
|
|
401 |
// CAiFw::SuspendContent()
|
|
402 |
//
|
|
403 |
// ----------------------------------------------------------------------------
|
|
404 |
//
|
|
405 |
TBool CAiFw::SuspendContent( const THsPublisherInfo& aPublisherInfo,
|
|
406 |
const TDesC& aContentCid )
|
|
407 |
{
|
|
408 |
return iEventHandler->SuspendContent( aPublisherInfo, aContentCid );
|
|
409 |
}
|
|
410 |
|
|
411 |
// ----------------------------------------------------------------------------
|
|
412 |
// CAiFw::QueryIsMenuOpen()
|
|
413 |
//
|
|
414 |
// ----------------------------------------------------------------------------
|
|
415 |
//
|
|
416 |
TBool CAiFw::QueryIsMenuOpen()
|
|
417 |
{
|
|
418 |
return iUiControllerManager->MainUiController().IsMenuOpen();
|
|
419 |
}
|
|
420 |
|
|
421 |
// ----------------------------------------------------------------------------
|
|
422 |
// CAiFw::HandleNotifyInt()
|
|
423 |
//
|
|
424 |
// ----------------------------------------------------------------------------
|
|
425 |
//
|
|
426 |
void CAiFw::HandleNotifyInt( TUint32 aId, TInt aNewValue )
|
|
427 |
{
|
|
428 |
switch ( aId )
|
|
429 |
{
|
|
430 |
case KAiMainUIController:
|
|
431 |
if ( aNewValue == AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_XML ||
|
|
432 |
aNewValue == AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_NATIVE ||
|
|
433 |
aNewValue == AI3_UID_ECOM_IMPLEMENTATION_UICONTROLLER_XML ||
|
|
434 |
aNewValue == AI3_UID_ECOM_IMPLEMENTATION_UICONTROLLER_NATIVE )
|
|
435 |
{
|
|
436 |
iUiControllerManager->ExitMainController();
|
|
437 |
}
|
|
438 |
else
|
|
439 |
{
|
|
440 |
// Someone wrote an invalid configuration! Reset repository.
|
|
441 |
iRepository->Reset( KAiMainUIController );
|
|
442 |
iRepository->Reset( KAiFirstUIController );
|
|
443 |
iRepository->Delete( KAiFirstUIController + 1 );
|
|
444 |
}
|
|
445 |
break;
|
|
446 |
case KAIExternalStatusScreen:
|
|
447 |
if ( ( aNewValue & 0x7FFFFFFF ) != 0 )
|
|
448 |
{
|
|
449 |
TRAP_IGNORE( SwapUiControllerL( EFalse ) );
|
|
450 |
}
|
|
451 |
else
|
|
452 |
{
|
|
453 |
TRAP_IGNORE( SwapUiControllerL( ETrue ) );
|
|
454 |
}
|
|
455 |
break;
|
|
456 |
default:
|
|
457 |
break;
|
|
458 |
}
|
|
459 |
}
|
|
460 |
|
|
461 |
// ----------------------------------------------------------------------------
|
|
462 |
// CAiFw::SwapUiControllerL()
|
|
463 |
//
|
|
464 |
// ----------------------------------------------------------------------------
|
|
465 |
//
|
|
466 |
void CAiFw::SwapUiControllerL( TBool aToExtHS )
|
|
467 |
{
|
|
468 |
if( !aToExtHS ) // Switch to XML UI
|
|
469 |
{
|
|
470 |
iRepository->Create( KAiFirstUIController,
|
|
471 |
AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_NATIVE );
|
|
472 |
|
|
473 |
iRepository->Set( KAiFirstUIController,
|
|
474 |
AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_NATIVE );
|
|
475 |
|
|
476 |
iRepository->Delete( KAiFirstUIController + 1 );
|
|
477 |
|
|
478 |
iRepository->Set( KAiMainUIController,
|
|
479 |
AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_XML );
|
|
480 |
}
|
|
481 |
else // Switch to ExtHS
|
|
482 |
{
|
|
483 |
iRepository->Delete( KAiFirstUIController );
|
|
484 |
|
|
485 |
iRepository->Delete( KAiFirstUIController + 1 );
|
|
486 |
|
|
487 |
iRepository->Set( KAiMainUIController,
|
|
488 |
AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_NATIVE );
|
|
489 |
}
|
|
490 |
|
|
491 |
// Restart
|
|
492 |
iUiControllerManager->ExitMainController();
|
|
493 |
}
|
|
494 |
|
|
495 |
// ----------------------------------------------------------------------------
|
|
496 |
// CAiFw::Repository()
|
|
497 |
//
|
|
498 |
// ----------------------------------------------------------------------------
|
|
499 |
//
|
|
500 |
CRepository& CAiFw::Repository() const
|
|
501 |
{
|
|
502 |
return *iRepository;
|
|
503 |
}
|
|
504 |
|
|
505 |
// End of file
|