|
1 /* |
|
2 * Copyright (c) 2005-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: App ui |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <centralrepository.h> |
|
20 #include <avkon.rsg> // For status pane layout resource ids |
|
21 #include <startupdomainpskeys.h> |
|
22 #include <e32property.h> // For RProperty |
|
23 #include <activeidle2domainpskeys.h> |
|
24 #include <AknDlgShut.h> // Avkon dialog shutter. |
|
25 #include <aknview.h> |
|
26 |
|
27 // User includes |
|
28 #include <activeidle2domaincrkeys.h> |
|
29 #include <aifweventhandler.h> |
|
30 #include <ai3xmlui.rsg> |
|
31 |
|
32 #include "appui.h" |
|
33 #include "application.h" |
|
34 #include "xmluicontroller.h" |
|
35 #include "aixuikoneventhandler.h" |
|
36 #include "aiuiframeworkobserver.h" |
|
37 #include "aixmluiconstants.h" |
|
38 #include "contentrenderer.h" |
|
39 #include "psobserver.h" |
|
40 |
|
41 #include "aipropertyextension.h" |
|
42 #include "aicontentmodel.h" |
|
43 #include "aiuiidleintegration.h" |
|
44 #include "xmluicontrollerpanic.h" |
|
45 |
|
46 #include "debug.h" |
|
47 #include "ai3perf.h" |
|
48 #include "xndomnode.h" |
|
49 #include "xnproperty.h" |
|
50 #include "xnuiengineappif.h" |
|
51 #include "onlineofflinehelper.h" |
|
52 |
|
53 using namespace AiXmlUiController; |
|
54 |
|
55 // ======== MEMBER FUNCTIONS ======== |
|
56 |
|
57 // ---------------------------------------------------------------------------- |
|
58 // CAppUi::CAppUi |
|
59 // ---------------------------------------------------------------------------- |
|
60 // |
|
61 CAppUi::CAppUi( CXmlUiController& aUiCtl, TUid aAppUid ) |
|
62 : CXnAppUiAdapter( aAppUid ), iUiCtl( aUiCtl ) |
|
63 { |
|
64 } |
|
65 |
|
66 // ---------------------------------------------------------------------------- |
|
67 // CAppUi::ConstructL() |
|
68 // ---------------------------------------------------------------------------- |
|
69 // |
|
70 void CAppUi::ConstructL() |
|
71 { |
|
72 AI3_PERF_START(perfdata, "xmluicontroller: CAppUi::ConstructL") |
|
73 |
|
74 // Always reset the phoneforward P&S key on startup just in case |
|
75 RProperty::Set(KPSUidAiInformation, |
|
76 KActiveIdleForwardNumericKeysToPhone, |
|
77 EPSAiForwardNumericKeysToPhone); |
|
78 |
|
79 // Initialize with empty title pane so it's not shown on startup. |
|
80 __HEAP("XML UI: Init - Construct App UI") |
|
81 __TIME("XML UI: XnAppUiAdapted::ConstructL", |
|
82 CXnAppUiAdapter::ConstructL(); |
|
83 ) |
|
84 |
|
85 // Register for XML UI view activation & deactivation |
|
86 AddViewActivationObserverL( this ); |
|
87 |
|
88 // Disable CCoeEnv exit checks. |
|
89 // Active Idle Framework will perform the checks. |
|
90 iCoeEnv->DisableExitChecks(ETrue); |
|
91 |
|
92 __TIME("XML UI: Construct Content Renderer", |
|
93 iContentRenderer = CContentRenderer::NewL( *this ); |
|
94 ) |
|
95 __HEAP("XML UI: Construct Content Renderer"); |
|
96 |
|
97 TXnUiEngineAppIf* uiEngine = UiEngineL(); |
|
98 __ASSERT_ALWAYS( uiEngine, Panic(ECriticalPointerNull) ); |
|
99 |
|
100 iUiCtl.SetObserver( *iContentRenderer ); |
|
101 |
|
102 iContentRenderer->SetEventHandler( *iUiCtl.FwEventHandler() ); |
|
103 |
|
104 iUiCtl.SetAppUi( *this ); |
|
105 |
|
106 iEventHandler = iUiCtl.CreateXuikonEventHandlerL( *iContentRenderer ); |
|
107 |
|
108 iUiFwObserver = iUiCtl.UiFrameworkObserver(); |
|
109 |
|
110 TAiIdleKeySoundConfig keySoundConfig; |
|
111 keySoundConfig.iKeySounds = KeySounds(); |
|
112 keySoundConfig.iContextResId = R_XUI_DEFAULT_SKEY_LIST; |
|
113 |
|
114 iIdleIntegration = CAiUiIdleIntegration::NewL |
|
115 ( *iEikonEnv, keySoundConfig, iUiCtl.FwEventHandler() ); |
|
116 |
|
117 iHelper = COnlineOfflineHelper::NewL( iUiCtl ); |
|
118 |
|
119 iUiCtl.NotifyAppEnvReadyL(); |
|
120 |
|
121 LoadNativeDataPluginsL(); |
|
122 |
|
123 CAknAppUiBase::SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyShort | |
|
124 CAknAppUiBase::EDisableSendKeyLong ); |
|
125 |
|
126 iIsEditModeActive = EFalse; |
|
127 |
|
128 |
|
129 __HEAP("XML UI: Done - Construct App UI"); |
|
130 AI3_PERF_STOP(perfdata, "xmluicontroller: CAppUi::ConstructL") |
|
131 } |
|
132 |
|
133 // ---------------------------------------------------------------------------- |
|
134 // CAppUi::NewL() |
|
135 // ---------------------------------------------------------------------------- |
|
136 // |
|
137 CAppUi* CAppUi::NewL( CXmlUiController& aUiCtl ) |
|
138 { |
|
139 CAppUi* self = new ( ELeave ) CAppUi( aUiCtl, KUidXmlUiApp ); |
|
140 |
|
141 // ConstructL is called by the UI framework |
|
142 |
|
143 return self; |
|
144 } |
|
145 |
|
146 // ---------------------------------------------------------------------------- |
|
147 // CAppUi::~CAppUi() |
|
148 // ---------------------------------------------------------------------------- |
|
149 // |
|
150 CAppUi::~CAppUi() |
|
151 { |
|
152 delete iHelper; |
|
153 delete iEventHandler; |
|
154 delete iContentRenderer; |
|
155 delete iIdleIntegration; |
|
156 } |
|
157 |
|
158 // ---------------------------------------------------------------------------- |
|
159 // CAppUi::PrepareToExit() |
|
160 // ---------------------------------------------------------------------------- |
|
161 // |
|
162 void CAppUi::PrepareToExit() |
|
163 { |
|
164 iUiCtl.FwEventHandler()->HandleUiShutdown( iUiCtl ); |
|
165 |
|
166 CXnAppUiAdapter::PrepareToExit(); |
|
167 } |
|
168 |
|
169 // ---------------------------------------------------------------------------- |
|
170 // CAppUi::HandleForegroundEventL() |
|
171 // ---------------------------------------------------------------------------- |
|
172 // |
|
173 void CAppUi::HandleForegroundEventL( TBool aForeground ) |
|
174 { |
|
175 CXnAppUiAdapter::HandleForegroundEventL( aForeground ); |
|
176 |
|
177 if( iUiFwObserver ) |
|
178 { |
|
179 iUiFwObserver->HandleForegroundEvent( aForeground ); |
|
180 } |
|
181 } |
|
182 |
|
183 // ---------------------------------------------------------------------------- |
|
184 // CAppUi::HandleCommandL() |
|
185 // ---------------------------------------------------------------------------- |
|
186 // |
|
187 void CAppUi::HandleCommandL(TInt aCommand) |
|
188 { |
|
189 switch( aCommand ) |
|
190 { |
|
191 case EEikCmdExit: |
|
192 { |
|
193 Exit(); |
|
194 break; |
|
195 } |
|
196 case EAknSoftkeyExit: |
|
197 case EAknCmdExit: |
|
198 { |
|
199 #ifdef _DEBUG |
|
200 |
|
201 Exit(); |
|
202 break; |
|
203 #endif // _DEBUG |
|
204 } |
|
205 default: |
|
206 { |
|
207 break; |
|
208 } |
|
209 } |
|
210 } |
|
211 |
|
212 // ---------------------------------------------------------------------------- |
|
213 // CAppUi::HandleResourceChangeL() |
|
214 // ---------------------------------------------------------------------------- |
|
215 // |
|
216 void CAppUi::HandleResourceChangeL( TInt aType ) |
|
217 { |
|
218 CXnAppUiAdapter::HandleResourceChangeL( aType ); |
|
219 |
|
220 if( iUiFwObserver ) |
|
221 { |
|
222 iUiFwObserver->HandleResourceChange( aType ); |
|
223 } |
|
224 } |
|
225 |
|
226 // ---------------------------------------------------------------------------- |
|
227 // CAppUi::HandleWsEventL() |
|
228 // ---------------------------------------------------------------------------- |
|
229 // |
|
230 void CAppUi::HandleWsEventL( const TWsEvent& aEvent, |
|
231 CCoeControl* aDestination ) |
|
232 { |
|
233 if( aEvent.Type() == KAknUidValueEndKeyCloseEvent ) |
|
234 { |
|
235 // End key close event, run dialog shutter |
|
236 // to dismiss open dialogs |
|
237 if ( IsDisplayingMenuOrDialog() ) |
|
238 { |
|
239 AknDialogShutter::ShutDialogsL( |
|
240 *static_cast< CEikonEnv* >( CCoeEnv::Static() ) ); |
|
241 } |
|
242 else |
|
243 { |
|
244 TKeyEvent key; |
|
245 |
|
246 key.iScanCode = EStdKeyNo; |
|
247 key.iCode = EStdKeyNull; |
|
248 key.iModifiers = 0; |
|
249 key.iRepeats = 0; |
|
250 |
|
251 iCoeEnv->SimulateKeyEventL( key, EEventKey ); |
|
252 } |
|
253 } |
|
254 |
|
255 if( iIdleIntegration ) |
|
256 { |
|
257 // Forward window server events first to idle integration library |
|
258 iIdleIntegration->HandleWsEventL( aEvent, aDestination ); |
|
259 } |
|
260 |
|
261 // Call base class to let the UI framework handle the event |
|
262 // Don't trap here, because there could be leaves which need to |
|
263 // handled by base classes/UI framework like KLeaveExit, KErrNoMemory etc. |
|
264 CXnAppUiAdapter::HandleWsEventL( aEvent, aDestination ); |
|
265 } |
|
266 |
|
267 // ---------------------------------------------------------------------------- |
|
268 // CAppUi::HandleXuikonEventL() |
|
269 // ---------------------------------------------------------------------------- |
|
270 // |
|
271 void CAppUi::HandleXuikonEventL( CXnNodeAppIf& aOrigin, |
|
272 CXnNodeAppIf& aTrigger, |
|
273 CXnDomNode& aTriggerDefinition, |
|
274 CXnDomNode& aEvent ) |
|
275 { |
|
276 __PRINTS("*** UC: Init - Event Management ***"); |
|
277 |
|
278 if( iEventHandler ) |
|
279 { |
|
280 __TIME("UC: Event Management", |
|
281 iEventHandler->HandleXuikonEventL( aOrigin, |
|
282 aTrigger, |
|
283 aTriggerDefinition, |
|
284 aEvent ); |
|
285 ); |
|
286 } |
|
287 __PRINTS("*** UI: Done - Event Management"); |
|
288 } |
|
289 |
|
290 // ---------------------------------------------------------------------------- |
|
291 // CAppUi::LoadDataPluginsL() |
|
292 // ---------------------------------------------------------------------------- |
|
293 // |
|
294 void CAppUi::LoadDataPluginsL( RPointerArray< CXnNodeAppIf >& aList ) |
|
295 { |
|
296 for( TInt i = 0; i < aList.Count(); i++ ) |
|
297 { |
|
298 TAiPublisherInfo info; |
|
299 |
|
300 iUiCtl.PublisherInfoL( *aList[i], info ); |
|
301 |
|
302 iUiCtl.FwEventHandler()->HandleLoadPluginL( info ); |
|
303 } |
|
304 } |
|
305 |
|
306 // ---------------------------------------------------------------------------- |
|
307 // CAppUi::LoadNativeDataPluginsL() |
|
308 // ---------------------------------------------------------------------------- |
|
309 // |
|
310 void CAppUi::LoadNativeDataPluginsL() |
|
311 { |
|
312 if ( !iNativePluginsLoaded ) |
|
313 { |
|
314 RAiPublisherInfoArray plugins; |
|
315 CleanupClosePushL( plugins ); |
|
316 |
|
317 iUiCtl.PublisherInfoL( plugins ); |
|
318 |
|
319 for ( TInt i = 0; i < plugins.Count(); i++ ) |
|
320 { |
|
321 iUiCtl.FwEventHandler()->HandleLoadPluginL( plugins[i] ); |
|
322 } |
|
323 |
|
324 CleanupStack::PopAndDestroy( &plugins ); |
|
325 |
|
326 iNativePluginsLoaded = ETrue; |
|
327 } |
|
328 } |
|
329 |
|
330 // ---------------------------------------------------------------------------- |
|
331 // CAppUi::DestroyDataPluginsL() |
|
332 // ---------------------------------------------------------------------------- |
|
333 // |
|
334 void CAppUi::DestroyDataPluginsL( RPointerArray< CXnNodeAppIf >& aList ) |
|
335 { |
|
336 for( TInt i = 0; i < aList.Count(); i++ ) |
|
337 { |
|
338 TAiPublisherInfo info; |
|
339 |
|
340 iUiCtl.PublisherInfoL( *aList[i], info ); |
|
341 |
|
342 iUiCtl.FwEventHandler()->HandleDestroyPluginL( info ); |
|
343 } |
|
344 } |
|
345 |
|
346 // ---------------------------------------------------------------------------- |
|
347 // CAppUi::DestroyNativeDataPluginsL() |
|
348 // ---------------------------------------------------------------------------- |
|
349 // |
|
350 void CAppUi::DestroyNativeDataPluginsL() |
|
351 { |
|
352 if ( iNativePluginsLoaded ) |
|
353 { |
|
354 RAiPublisherInfoArray plugins; |
|
355 CleanupClosePushL( plugins ); |
|
356 |
|
357 iUiCtl.PublisherInfoL( plugins ); |
|
358 |
|
359 for ( TInt i = 0; i < plugins.Count(); i++ ) |
|
360 { |
|
361 iUiCtl.FwEventHandler()->HandleDestroyPluginL( plugins[i] ); |
|
362 } |
|
363 |
|
364 CleanupStack::PopAndDestroy( &plugins ); |
|
365 |
|
366 iNativePluginsLoaded = EFalse; |
|
367 } |
|
368 } |
|
369 |
|
370 // ---------------------------------------------------------------------------- |
|
371 // CAppUi::DynInitMenuItemL() |
|
372 // ---------------------------------------------------------------------------- |
|
373 // |
|
374 TBool CAppUi::DynInitMenuItemL( const TDesC& aItemType, |
|
375 RPointerArray< CXnNodeAppIf >* aList ) |
|
376 { |
|
377 _LIT( KOnline, "hs_online" ); |
|
378 _LIT( KOffline, "hs_offline" ); |
|
379 |
|
380 TBool retval( EFalse ); |
|
381 |
|
382 if( aItemType == KOnline ) |
|
383 { |
|
384 return iHelper->ShowOnlineItem(); |
|
385 } |
|
386 else if( aItemType == KOffline ) |
|
387 { |
|
388 return iHelper->ShowOfflineItem(); |
|
389 } |
|
390 else if( aList ) |
|
391 { |
|
392 RPointerArray< CXnNodeAppIf >& list( *aList ); |
|
393 |
|
394 for( TInt i = 0; !retval && i < list.Count(); i++ ) |
|
395 { |
|
396 TAiPublisherInfo info; |
|
397 |
|
398 iUiCtl.PublisherInfoL( *list[i], info ); |
|
399 |
|
400 retval = iUiCtl.FwEventHandler()->HasMenuItemL( info, aItemType ); |
|
401 } |
|
402 } |
|
403 |
|
404 return retval; |
|
405 } |
|
406 |
|
407 // ---------------------------------------------------------------------------- |
|
408 // CAppUi::SetOnlineStateL() |
|
409 // Called always by view manager when view is activated. |
|
410 // ---------------------------------------------------------------------------- |
|
411 // |
|
412 void CAppUi::SetOnlineStateL( RPointerArray< CXnNodeAppIf >& aList ) |
|
413 { |
|
414 iHelper->ProcessOnlineStateL( aList ); |
|
415 } |
|
416 |
|
417 // ---------------------------------------------------------------------------- |
|
418 // CAppUi::SetOnlineL() |
|
419 // Called always when user changed HS online/offline status from option menu. |
|
420 // ---------------------------------------------------------------------------- |
|
421 // |
|
422 void CAppUi::SetOnlineStateL( TBool aOnline ) |
|
423 { |
|
424 iHelper->ProcessOnlineStateL( aOnline ); |
|
425 } |
|
426 |
|
427 // ---------------------------------------------------------------------------- |
|
428 // CAppUi::HandleViewActivation() |
|
429 // ---------------------------------------------------------------------------- |
|
430 // |
|
431 void CAppUi::HandleViewActivation( const TVwsViewId& aNewlyActivatedViewId, |
|
432 const TVwsViewId& aViewIdToBeDeactivated ) |
|
433 { |
|
434 if ( iIsEditModeActive ) |
|
435 { |
|
436 return; |
|
437 } |
|
438 |
|
439 // Get Xml Ui view id |
|
440 TVwsViewId viewId( View().ViewId() ); |
|
441 |
|
442 if ( viewId == aNewlyActivatedViewId ) |
|
443 { |
|
444 // Xml Ui view became active |
|
445 TRAP_IGNORE( LoadNativeDataPluginsL() ); |
|
446 } |
|
447 else if ( viewId == aViewIdToBeDeactivated ) |
|
448 { |
|
449 // Xml Ui view became inactive |
|
450 TRAP_IGNORE( DestroyNativeDataPluginsL() ); |
|
451 } |
|
452 } |
|
453 |
|
454 // ---------------------------------------------------------------------------- |
|
455 // CAppUi::UiController() |
|
456 // ---------------------------------------------------------------------------- |
|
457 // |
|
458 CXmlUiController& CAppUi::UiController() const |
|
459 { |
|
460 return iUiCtl; |
|
461 } |
|
462 |
|
463 // ---------------------------------------------------------------------------- |
|
464 // CAppUi::HandlePageSwitch() |
|
465 // ---------------------------------------------------------------------------- |
|
466 // |
|
467 void CAppUi::HandlePageSwitch() |
|
468 { |
|
469 iUiCtl.FwEventHandler()->ProcessStateChange( EAifwPageSwitch ); |
|
470 } |
|
471 |
|
472 // ---------------------------------------------------------------------------- |
|
473 // CAppUi::HandleEnterEditModeL() |
|
474 // ---------------------------------------------------------------------------- |
|
475 // |
|
476 void CAppUi::HandleEnterEditModeL( TBool aEnter ) |
|
477 { |
|
478 if ( aEnter ) |
|
479 { |
|
480 DestroyNativeDataPluginsL(); |
|
481 iIsEditModeActive = ETrue; |
|
482 } |
|
483 else |
|
484 { |
|
485 LoadNativeDataPluginsL(); |
|
486 iIsEditModeActive = EFalse; |
|
487 } |
|
488 } |
|
489 |
|
490 // End of File. |