|
1 /* |
|
2 * Copyright (c) 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: Xuikon view adapter source file |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <aknViewAppUi.h> |
|
20 #include <eikbtgpc.h> |
|
21 #include <avkon.rsg> |
|
22 |
|
23 // User includes |
|
24 #include "xnappuiadapter.h" |
|
25 #include "xnviewmanager.h" |
|
26 #include "xnviewdata.h" |
|
27 #include "xnuiengine.h" |
|
28 |
|
29 #include "xnkeyeventdispatcher.h" |
|
30 #include "xncontroladapter.h" |
|
31 |
|
32 #include "xndomdocument.h" |
|
33 #include "xndomnode.h" |
|
34 #include "xndomlist.h" |
|
35 #include "xnodt.h" |
|
36 #include "xnproperty.h" |
|
37 #include "xnnodeimpl.h" |
|
38 #include "xnnode.h" |
|
39 #include "xntype.h" |
|
40 #include "xnfocuscontrol.h" |
|
41 #include "xneditor.h" |
|
42 #include "xnbackgroundmanager.h" |
|
43 #include "xneffectmanager.h" |
|
44 #include "xnwallpaperview.h" |
|
45 |
|
46 #include "xnviewadapter.h" |
|
47 #include "xnmenu.h" |
|
48 #include "xneditmode.h" |
|
49 #include "xnrootdata.h" |
|
50 |
|
51 #include "debug.h" |
|
52 |
|
53 // Constants |
|
54 const TUid KXmlViewUid = { 1 }; |
|
55 |
|
56 _LIT8( KActivateDefaultView, "activatedefault" ); |
|
57 _LIT8( KSetWallpaper, "setwallpaper" ); |
|
58 |
|
59 _LIT8( KMenuBar, "menubar" ); |
|
60 |
|
61 // Data types |
|
62 enum |
|
63 { |
|
64 EIsActivated, |
|
65 EIsInCall, |
|
66 EIsLightsOn, |
|
67 EIsForeground, |
|
68 EIsControlsAwake, |
|
69 EIsDestructionRunning |
|
70 }; |
|
71 |
|
72 enum TAction |
|
73 { |
|
74 ENoAction = 0, |
|
75 EActivateDefault, |
|
76 ESetWallpaper |
|
77 }; |
|
78 |
|
79 // ============================= LOCAL FUNCTIONS =============================== |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CleanupEffect |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 static void CleanupEffect( TAny* aAny ) |
|
85 { |
|
86 static_cast< CXnEffectManager* >( aAny )->CleanupControlEffect(); |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // DetermineStatusPaneLayout |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 static TInt DetermineStatusPaneLayout( CXnProperty* aProperty ) |
|
94 { |
|
95 TInt spane( KErrNotFound ); |
|
96 |
|
97 if ( aProperty ) |
|
98 { |
|
99 const TDesC8& value( aProperty->StringValue() ); |
|
100 |
|
101 // Currently supported status pane layout |
|
102 if ( value == XnPropertyNames::view::statuspanelayout::KNone ) |
|
103 { |
|
104 spane = R_AVKON_STATUS_PANE_LAYOUT_EMPTY; |
|
105 } |
|
106 if ( value == XnPropertyNames::view::statuspanelayout::KBasic ) |
|
107 { |
|
108 spane = R_AVKON_STATUS_PANE_LAYOUT_IDLE; |
|
109 } |
|
110 else if ( value == XnPropertyNames::view::statuspanelayout::KBasicFlat ) |
|
111 { |
|
112 spane = R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT; |
|
113 } |
|
114 else if ( value == |
|
115 XnPropertyNames::view::statuspanelayout::KWideScreen ) |
|
116 { |
|
117 spane = R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE; |
|
118 } |
|
119 else if ( value == |
|
120 XnPropertyNames::view::statuspanelayout::KWideScreenFlat ) |
|
121 { |
|
122 spane = R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT; |
|
123 } |
|
124 else if ( value == |
|
125 XnPropertyNames::view::statuspanelayout:: |
|
126 KWideScreenFlat3Softkeys ) |
|
127 { |
|
128 spane = R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT_NO_SOFTKEYS; |
|
129 } |
|
130 } |
|
131 |
|
132 return spane; |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // BuildTriggerL |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 static CXnNode* BuildTriggerL( |
|
140 CXnUiEngine& aUiEngine, |
|
141 const TDesC8& aTriggerName ) |
|
142 { |
|
143 CXnNode* node = CXnNode::NewL(); |
|
144 CleanupStack::PushL( node ); |
|
145 CXnType* type = CXnType::NewL( XnPropertyNames::action::KTrigger ); |
|
146 CleanupStack::PushL( type ); |
|
147 CXnNodeImpl* impl = CXnNodeImpl::NewL( type ); |
|
148 CleanupStack::Pop( type ); |
|
149 node->SetImpl( impl ); |
|
150 node->SetUiEngine( aUiEngine ); |
|
151 |
|
152 CXnDomPropertyValue* nameValue = CXnDomPropertyValue::NewL( |
|
153 aUiEngine.ODT()->DomDocument().StringPool() ); |
|
154 CleanupStack::PushL( nameValue ); |
|
155 nameValue->SetStringValueL( CXnDomPropertyValue::EString, aTriggerName ); |
|
156 CXnProperty* name = CXnProperty::NewL( |
|
157 XnPropertyNames::action::trigger::KName, |
|
158 nameValue, |
|
159 *aUiEngine.ODT()->DomDocument().StringPool() ); |
|
160 CleanupStack::Pop( nameValue ); |
|
161 CleanupStack::PushL( name ); |
|
162 node->SetPropertyL( name ); |
|
163 CleanupStack::Pop( 2, node ); // name |
|
164 |
|
165 return node; |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // BuildActivateTriggerL |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 static CXnNode* BuildActivateTriggerL( CXnUiEngine& aUiEngine ) |
|
173 { |
|
174 return BuildTriggerL( |
|
175 aUiEngine, XnPropertyNames::action::trigger::name::KViewActivate ); |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // BuildDeactivateTriggerL |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 static CXnNode* BuildDeactivateTriggerL( CXnUiEngine& aUiEngine ) |
|
183 { |
|
184 return BuildTriggerL( |
|
185 aUiEngine, XnPropertyNames::action::trigger::name::KViewDeactivate ); |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // BuildEditStateTriggerL |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 static CXnNode* BuildEditStateTriggerL( CXnUiEngine& aUiEngine ) |
|
193 { |
|
194 CXnDomStringPool* sp( aUiEngine.ODT()->DomDocument().StringPool() ); |
|
195 |
|
196 CXnProperty* value = CXnProperty::NewL( |
|
197 XnPropertyNames::action::KValue, |
|
198 KNullDesC8, CXnDomPropertyValue::EString, *sp ); |
|
199 CleanupStack::PushL( value ); |
|
200 |
|
201 CXnNode* trigger( BuildTriggerL( |
|
202 aUiEngine, XnPropertyNames::action::trigger::name::KEditMode ) ); |
|
203 CleanupStack::PushL( trigger ); |
|
204 |
|
205 trigger->SetPropertyL( value ); |
|
206 CleanupStack::Pop( 2, value ); // trigger |
|
207 |
|
208 return trigger; |
|
209 } |
|
210 |
|
211 // ============================ MEMBER FUNCTIONS =============================== |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // CXnViewAdapter::CXnViewAdapter |
|
215 // C++ default constructor can NOT contain any code, that |
|
216 // might leave. |
|
217 // ----------------------------------------------------------------------------- |
|
218 // |
|
219 CXnViewAdapter::CXnViewAdapter( CXnAppUiAdapter& aAdapter ) |
|
220 : iAppUiAdapter( aAdapter ) |
|
221 { |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CXnViewAdapter::~CXnViewAdapter |
|
226 // Destructor. |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 CXnViewAdapter::~CXnViewAdapter() |
|
230 { |
|
231 delete iTimer; |
|
232 delete iActivate; |
|
233 delete iDeactivate; |
|
234 delete iEditState; |
|
235 delete iBgManager; |
|
236 delete iFocusControl; |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CXnViewAdapter::NewL |
|
241 // 2nd phase construction. |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 CXnViewAdapter* CXnViewAdapter::NewL( CXnAppUiAdapter& aAdapter ) |
|
245 { |
|
246 CXnViewAdapter* self = new ( ELeave ) CXnViewAdapter( aAdapter ); |
|
247 CleanupStack::PushL( self ); |
|
248 self->ConstructL(); |
|
249 CleanupStack::Pop( self ); |
|
250 return self; |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // CXnViewAdapter::ConstructL |
|
255 // 2nd phase construction. |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 void CXnViewAdapter::ConstructL() |
|
259 { |
|
260 BaseConstructL(); |
|
261 |
|
262 iTimer = CPeriodic::NewL( CActive::EPriorityIdle ); |
|
263 |
|
264 // Base class CAknViewAppUi takes ownership of iViewAdapter |
|
265 iAppUiAdapter.AddViewL( this ); |
|
266 iAppUiAdapter.SetDefaultViewL( *this ); |
|
267 |
|
268 iBgManager = CXnBackgroundManager::NewL( iAppUiAdapter.ViewManager(), |
|
269 iAppUiAdapter.ViewManager().Editor().HspsWrapper() ); |
|
270 |
|
271 iFocusControl = CXnFocusControl::NewL( iAppUiAdapter ); |
|
272 |
|
273 iEventDispatcher = |
|
274 CXnKeyEventDispatcher::NewL( iAppUiAdapter.UiEngine() ); |
|
275 |
|
276 iAppUiAdapter.UiEngine().SetEventDispatcher( iEventDispatcher ); |
|
277 |
|
278 iAppUiAdapter.UiStateListener().AddObserver( *this ); |
|
279 } |
|
280 |
|
281 // ----------------------------------------------------------------------------- |
|
282 // CXnViewAdapter::ReloadUiL |
|
283 // Called when application UI is reloaded |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 void CXnViewAdapter::ReloadUiL() |
|
287 { |
|
288 iTimer->Cancel(); |
|
289 iAction = ENoAction; |
|
290 |
|
291 DeactivateContainerL(); |
|
292 |
|
293 iAppUiAdapter.RemoveFromStack( iEventDispatcher ); |
|
294 |
|
295 delete iEventDispatcher; |
|
296 iEventDispatcher = NULL; |
|
297 |
|
298 delete iActivate; |
|
299 iActivate = NULL; |
|
300 |
|
301 delete iDeactivate; |
|
302 iDeactivate = NULL; |
|
303 |
|
304 delete iEditState; |
|
305 iEditState = NULL; |
|
306 |
|
307 iEventDispatcher = CXnKeyEventDispatcher::NewL( iAppUiAdapter.UiEngine() ); |
|
308 |
|
309 iAppUiAdapter.UiEngine().SetEventDispatcher( iEventDispatcher ); |
|
310 |
|
311 if ( iFlags.IsSet( EIsActivated ) ) |
|
312 { |
|
313 iAppUiAdapter.AddToStackL( *this, iEventDispatcher ); |
|
314 } |
|
315 } |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // CXnViewAdapter::PrepareToExit |
|
319 // Sets view to be destroyed |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 void CXnViewAdapter::PrepareToExit() |
|
323 { |
|
324 iAppUiAdapter.RemoveFromStack( iEventDispatcher ); |
|
325 |
|
326 delete iEventDispatcher; |
|
327 iEventDispatcher = NULL; |
|
328 |
|
329 iAppUiAdapter.UiEngine().SetEventDispatcher( NULL ); |
|
330 |
|
331 iContainer = NULL; |
|
332 |
|
333 iFlags.Set( EIsDestructionRunning ); |
|
334 } |
|
335 |
|
336 // ----------------------------------------------------------------------------- |
|
337 // CXnViewAdapter::EventDispatcher |
|
338 // Get event dispatcher |
|
339 // ----------------------------------------------------------------------------- |
|
340 // |
|
341 CXnKeyEventDispatcher* CXnViewAdapter::EventDispatcher() const |
|
342 { |
|
343 return iEventDispatcher; |
|
344 } |
|
345 |
|
346 // ----------------------------------------------------------------------------- |
|
347 // CXnViewAdapter::BgManager |
|
348 // Returns background manager. |
|
349 // ----------------------------------------------------------------------------- |
|
350 // |
|
351 CXnBackgroundManager& CXnViewAdapter::BgManager() const |
|
352 { |
|
353 return *iBgManager; |
|
354 } |
|
355 |
|
356 // ----------------------------------------------------------------------------- |
|
357 // CXnViewAdapter::FocusControl |
|
358 // Returns focus control. |
|
359 // ----------------------------------------------------------------------------- |
|
360 // |
|
361 CXnFocusControl& CXnViewAdapter::FocusControl() const |
|
362 { |
|
363 return *iFocusControl; |
|
364 } |
|
365 |
|
366 // ----------------------------------------------------------------------------- |
|
367 // CXnViewAdapter::Id |
|
368 // Returns view uid. |
|
369 // ----------------------------------------------------------------------------- |
|
370 // |
|
371 TUid CXnViewAdapter::Id() const |
|
372 { |
|
373 return KXmlViewUid; |
|
374 } |
|
375 |
|
376 // ----------------------------------------------------------------------------- |
|
377 // CXnViewAdapter::DoActivateL |
|
378 // Activates view. |
|
379 // ----------------------------------------------------------------------------- |
|
380 // |
|
381 void CXnViewAdapter::DoActivateL( const TVwsViewId& /*aPrevViewId*/, |
|
382 TUid /*aCustomMessageId*/, |
|
383 const TDesC8& aCustomMessage ) |
|
384 { |
|
385 if ( iFlags.IsSet( EIsDestructionRunning ) ) |
|
386 { |
|
387 return; |
|
388 } |
|
389 |
|
390 __TICK( "CXnViewAdapter::DoActivateL" ); |
|
391 __TIME_MARK( time ); |
|
392 |
|
393 TBool wasActive( iFlags.IsSet( EIsActivated ) ); |
|
394 |
|
395 iFlags.Set( EIsActivated ); |
|
396 |
|
397 iEventDispatcher->ClearStateL(); |
|
398 |
|
399 iAppUiAdapter.RemoveFromStack( iEventDispatcher ); |
|
400 iAppUiAdapter.AddToStackL( *this, iEventDispatcher ); |
|
401 |
|
402 CEikButtonGroupContainer* bgc( iAppUiAdapter.Cba() ); |
|
403 |
|
404 if ( bgc ) |
|
405 { |
|
406 // EventDispatcher will handle sotkey keyevents |
|
407 CEikCba* cba( |
|
408 static_cast< CEikCba* >( bgc->ButtonGroup() ) ); |
|
409 |
|
410 iAppUiAdapter.RemoveFromStack( cba ); |
|
411 } |
|
412 |
|
413 iBgManager->MakeVisible( ETrue ); |
|
414 |
|
415 CXnViewData& viewData( iAppUiAdapter.ViewManager().ActiveViewData() ); |
|
416 |
|
417 if ( !wasActive ) |
|
418 { |
|
419 // Set status pane layout |
|
420 CXnProperty* prop( viewData.Node()->LayoutNode()->GetPropertyL( |
|
421 XnPropertyNames::view::KStatusPaneLayout ) ); |
|
422 |
|
423 CEikStatusPane* sp( iAppUiAdapter.StatusPane() ); |
|
424 |
|
425 // Is there status pane declaration available |
|
426 TInt spane( DetermineStatusPaneLayout( prop ) ); |
|
427 |
|
428 if ( spane != KErrNotFound ) |
|
429 { |
|
430 if ( sp && sp->CurrentLayoutResId() != spane ) |
|
431 { |
|
432 sp->SwitchLayoutL( spane ); |
|
433 sp->ApplyCurrentSettingsL(); |
|
434 } |
|
435 } |
|
436 |
|
437 // enable statuspane transparancy |
|
438 if ( sp && !sp->IsTransparent() ) |
|
439 { |
|
440 sp->EnableTransparent( ETrue ); |
|
441 sp->DrawNow(); |
|
442 } |
|
443 } |
|
444 |
|
445 if ( aCustomMessage == KSetWallpaper ) |
|
446 { |
|
447 iAction = ESetWallpaper; |
|
448 |
|
449 iTimer->Cancel(); |
|
450 iTimer->Start( 1000, 1000, TCallBack( TimerCallback, this ) ); |
|
451 } |
|
452 |
|
453 // Set the active container |
|
454 if ( aCustomMessage == KActivateDefaultView ) |
|
455 { |
|
456 __PRINTS( "*** CXnViewAdapter::DoActivateL - activating default container" ); |
|
457 |
|
458 ActivateDefaultContainerL(); |
|
459 |
|
460 iAction = EActivateDefault; |
|
461 |
|
462 iTimer->Cancel(); |
|
463 iTimer->Start( 1000, 1000, TCallBack( TimerCallback, this ) ); |
|
464 } |
|
465 else |
|
466 { |
|
467 __PRINTS( "*** CXnViewAdapter::DoActivateL - activating container" ); |
|
468 |
|
469 ActivateContainerL( viewData ); |
|
470 } |
|
471 |
|
472 __TIME_ENDMARK( "CXnViewAdapter::DoActivateL, done", time ); |
|
473 |
|
474 __TICK( "CXnViewAdapter::DoActivateL - HS UI Ready" ); |
|
475 } |
|
476 |
|
477 // ----------------------------------------------------------------------------- |
|
478 // CXnViewAdapter::TimerCallback |
|
479 // |
|
480 // ----------------------------------------------------------------------------- |
|
481 // |
|
482 TInt CXnViewAdapter::TimerCallback( TAny *aPtr ) |
|
483 { |
|
484 __PRINTS( "*** CXnViewAdapter::TimerCallback" ); |
|
485 |
|
486 CXnViewAdapter* self = reinterpret_cast< CXnViewAdapter* >( aPtr ); |
|
487 self->iTimer->Cancel(); |
|
488 |
|
489 if ( self->iAction == EActivateDefault ) |
|
490 { |
|
491 self->iCoeEnv->WsSession().SetWindowGroupOrdinalPosition( |
|
492 self->iCoeEnv->RootWin().Identifier(), 0 ); |
|
493 } |
|
494 else if ( self->iAction == ESetWallpaper ) |
|
495 { |
|
496 CAknViewAppUi& appui = static_cast< CAknViewAppUi& >( self->iAppUiAdapter ); |
|
497 |
|
498 CXnWallpaperView* view = |
|
499 static_cast< CXnWallpaperView* >( appui.View( KWallpaperViewUid ) ); |
|
500 |
|
501 if ( view ) |
|
502 { |
|
503 TFileName filename( KNullDesC ); |
|
504 |
|
505 // Get selected wallpaper |
|
506 view->SelectedWallpaper( filename ); |
|
507 |
|
508 if ( filename != KNullDesC ) |
|
509 { |
|
510 if ( self->BgManager().SetWallpaper( filename ) ) |
|
511 { |
|
512 self->iAppUiAdapter.EffectManager()->BgAppearEffect( |
|
513 self->iBgManager, ETrue ); |
|
514 } |
|
515 } |
|
516 } |
|
517 } |
|
518 |
|
519 self->iAction = ENoAction; |
|
520 |
|
521 __PRINTS( "*** CXnViewAdapter::TimerCallback, done" ); |
|
522 |
|
523 return KErrNone; |
|
524 } |
|
525 |
|
526 // ----------------------------------------------------------------------------- |
|
527 // CXnViewAdapter::DoDeactivate |
|
528 // Deactivates view. |
|
529 // ----------------------------------------------------------------------------- |
|
530 // |
|
531 void CXnViewAdapter::DoDeactivate() |
|
532 { |
|
533 if ( iFlags.IsSet( EIsDestructionRunning ) ) |
|
534 { |
|
535 return; |
|
536 } |
|
537 |
|
538 __PRINTS( "*** CXnViewAdapter::DoDeactivate" ); |
|
539 __TIME_MARK( time ); |
|
540 |
|
541 iAppUiAdapter.RemoveFromStack( iEventDispatcher ); |
|
542 |
|
543 TRAP_IGNORE( DeactivateContainerL() ); |
|
544 |
|
545 iBgManager->MakeVisible( EFalse ); |
|
546 |
|
547 iFocusControl->MakeVisible( EFalse ); |
|
548 |
|
549 iFlags.Clear( EIsActivated ); |
|
550 |
|
551 __TIME_ENDMARK( "CXnViewAdapter::DoDeactivate, done", time ); |
|
552 } |
|
553 |
|
554 // ----------------------------------------------------------------------------- |
|
555 // CXnViewAdapter::ActivateContainerL |
|
556 // Activates container |
|
557 // ----------------------------------------------------------------------------- |
|
558 // |
|
559 void CXnViewAdapter::ActivateContainerL( CXnViewData& aContainer, |
|
560 TBool aEnterEditState, TUid aEffect ) |
|
561 { |
|
562 // Returns if the container remains the same and activation is not forced |
|
563 // Otherwise the old container is deactivated and the new is activated |
|
564 if ( iFlags.IsSet( EIsDestructionRunning ) || iContainer == &aContainer ) |
|
565 { |
|
566 return; |
|
567 } |
|
568 |
|
569 if ( iFlags.IsClear( EIsActivated ) ) |
|
570 { |
|
571 // Some other view than this in this appui is currently active, |
|
572 // postpone container activation |
|
573 return; |
|
574 } |
|
575 |
|
576 const CXnViewData& active( iAppUiAdapter.ViewManager().ActiveViewData() ); |
|
577 |
|
578 CXnEffectManager* mgr( iAppUiAdapter.EffectManager() ); |
|
579 |
|
580 CleanupStack::PushL( TCleanupItem( CleanupEffect, mgr ) ); |
|
581 |
|
582 TBool started( |
|
583 mgr->BeginActivateViewEffect( active, aContainer, aEffect ) ); |
|
584 |
|
585 DeactivateContainerL( EFalse ); |
|
586 |
|
587 // Update |
|
588 iContainer = &aContainer; |
|
589 |
|
590 // Disable layout and redraw until container activation is done |
|
591 iAppUiAdapter.UiEngine().DisableRenderUiLC(); |
|
592 |
|
593 // Try exit controls from powersave mode |
|
594 ChangeControlsStateL( ETrue ); |
|
595 |
|
596 if ( !iActivate ) |
|
597 { |
|
598 iActivate = BuildActivateTriggerL( iAppUiAdapter.UiEngine() ); |
|
599 } |
|
600 |
|
601 CXnNode* node( aContainer.Node()->LayoutNode() ); |
|
602 |
|
603 CXnDomStringPool* sp( node->DomNode()->StringPool() ); |
|
604 |
|
605 CXnProperty* prop = CXnProperty::NewL( |
|
606 XnPropertyNames::style::common::KDisplay, |
|
607 XnPropertyNames::style::common::display::KBlock, |
|
608 CXnDomPropertyValue::EString, *sp ); |
|
609 CleanupStack::PushL( prop ); |
|
610 |
|
611 node->SetPropertyWithoutNotificationL( prop ); |
|
612 CleanupStack::Pop( prop ); |
|
613 |
|
614 node->ReportXuikonEventL( *iActivate ); |
|
615 |
|
616 if ( iFlags.IsSet( EIsInCall ) ) |
|
617 { |
|
618 iFlags.Clear( EIsInCall ); |
|
619 |
|
620 // This container is in-call state |
|
621 NotifyInCallStateChaged( ETrue ); |
|
622 } |
|
623 |
|
624 if ( aEnterEditState || iAppUiAdapter.UiEngine().IsEditMode() ) |
|
625 { |
|
626 EnterEditStateL( aContainer, ETrue ); |
|
627 } |
|
628 else |
|
629 { |
|
630 EnterEditStateL( aContainer, EFalse ); |
|
631 } |
|
632 |
|
633 CXnControlAdapter* adapter( node->Control() ); |
|
634 adapter->MakeVisible( ETrue ); |
|
635 |
|
636 iAppUiAdapter.ViewManager().NotifyContainerChangedL( aContainer ); |
|
637 |
|
638 iBgManager->ChangeWallpaper( active, aContainer, !started ); |
|
639 |
|
640 iAppUiAdapter.UiEngine().RenderUIL(); |
|
641 |
|
642 CleanupStack::PopAndDestroy(); // DisableRenderUiLC |
|
643 |
|
644 mgr->EndActivateViewEffect( active, aContainer, aEffect ); |
|
645 |
|
646 CleanupStack::PopAndDestroy(); // cleanupitem |
|
647 |
|
648 iAppUiAdapter.ViewManager().UpdatePageManagementInformationL(); |
|
649 |
|
650 if ( iEventDispatcher ) |
|
651 { |
|
652 iEventDispatcher->SetMenuNodeL( |
|
653 iAppUiAdapter.UiEngine().MenuBarNode() ); |
|
654 } |
|
655 } |
|
656 |
|
657 // ----------------------------------------------------------------------------- |
|
658 // CXnViewAdapter::ActivateDefaultContainerL |
|
659 // Activates default container |
|
660 // ----------------------------------------------------------------------------- |
|
661 // |
|
662 void CXnViewAdapter::ActivateDefaultContainerL( TBool aEnterEditState ) |
|
663 { |
|
664 CXnRootData& rootData( iAppUiAdapter.ViewManager().ActiveAppData() ); |
|
665 |
|
666 RPointerArray< CXnPluginData >& views( rootData.PluginData() ); |
|
667 |
|
668 if ( !views.Count() ) |
|
669 { |
|
670 return; |
|
671 } |
|
672 |
|
673 // first view is default |
|
674 CXnViewData* viewData = static_cast<CXnViewData*>( views[0] ); |
|
675 |
|
676 if ( viewData ) |
|
677 { |
|
678 EnterEditStateL( *viewData, aEnterEditState ); |
|
679 // Deactivate container even though it hasn't changed to close all |
|
680 // popups and other windows |
|
681 ActivateContainerL( *viewData, aEnterEditState ); |
|
682 } |
|
683 } |
|
684 |
|
685 // ----------------------------------------------------------------------------- |
|
686 // CXnViewAdapter::EnterEditStateL |
|
687 // Sets edit state property |
|
688 // ----------------------------------------------------------------------------- |
|
689 // |
|
690 void CXnViewAdapter::EnterEditStateL( CXnViewData& aView, TBool aEnter ) |
|
691 { |
|
692 if ( !iEditState ) |
|
693 { |
|
694 iEditState = BuildEditStateTriggerL( iAppUiAdapter.UiEngine() ); |
|
695 } |
|
696 |
|
697 CXnProperty* prop( iEditState->GetPropertyL( |
|
698 XnPropertyNames::action::KValue ) ); |
|
699 |
|
700 if ( !prop ) |
|
701 { |
|
702 return; |
|
703 } |
|
704 |
|
705 if ( aEnter ) |
|
706 { |
|
707 static_cast< CXnDomPropertyValue* >( |
|
708 prop->Property()->PropertyValueList().Item( 0 ) ) |
|
709 ->SetStringValueL( CXnDomPropertyValue::EString, |
|
710 XnPropertyNames::action::trigger::name::editmode::KEnter() ); |
|
711 } |
|
712 else |
|
713 { |
|
714 static_cast< CXnDomPropertyValue* >( |
|
715 prop->Property()->PropertyValueList().Item( 0 ) ) |
|
716 ->SetStringValueL( CXnDomPropertyValue::EString, |
|
717 XnPropertyNames::action::trigger::name::editmode::KExit() ); |
|
718 } |
|
719 |
|
720 if ( aView.Node() && aView.Node()->LayoutNode() ) |
|
721 { |
|
722 aView.Node()->LayoutNode()->ReportXuikonEventL( *iEditState ); |
|
723 } |
|
724 } |
|
725 |
|
726 // ----------------------------------------------------------------------------- |
|
727 // CXnViewAdapter::DeactivateContainerL |
|
728 // Deactivates current container |
|
729 // ----------------------------------------------------------------------------- |
|
730 // |
|
731 void CXnViewAdapter::DeactivateContainerL( TBool aHide ) |
|
732 { |
|
733 if ( !iContainer || iFlags.IsSet( EIsDestructionRunning ) ) |
|
734 { |
|
735 return; |
|
736 } |
|
737 |
|
738 CloseAllPopupsL(); |
|
739 |
|
740 // Run controls to powersave mode |
|
741 ChangeControlsStateL( EFalse ); |
|
742 |
|
743 CXnNode* node( iContainer->Node()->LayoutNode() ); |
|
744 |
|
745 CXnDomStringPool* sp( node->DomNode()->StringPool() ); |
|
746 |
|
747 CXnProperty* prop = CXnProperty::NewL( |
|
748 XnPropertyNames::style::common::KDisplay, |
|
749 XnPropertyNames::style::common::display::KNone, |
|
750 CXnDomPropertyValue::EString, *sp ); |
|
751 CleanupStack::PushL( prop ); |
|
752 |
|
753 node->SetPropertyWithoutNotificationL( prop ); |
|
754 CleanupStack::Pop( prop ); |
|
755 |
|
756 if ( !iDeactivate ) |
|
757 { |
|
758 iDeactivate = BuildDeactivateTriggerL( iAppUiAdapter.UiEngine() ); |
|
759 } |
|
760 |
|
761 node->ReportXuikonEventL( *iDeactivate ); |
|
762 |
|
763 if ( aHide ) |
|
764 { |
|
765 node->Control()->MakeVisible( EFalse ); |
|
766 } |
|
767 |
|
768 iContainer = NULL; |
|
769 } |
|
770 |
|
771 // ----------------------------------------------------------------------------- |
|
772 // CXnViewAdapter::NotifyForegroundChanged |
|
773 // |
|
774 // ----------------------------------------------------------------------------- |
|
775 // |
|
776 void CXnViewAdapter::NotifyForegroundChanged( |
|
777 MXnUiStateObserver::TForegroundStatus aStatus ) |
|
778 { |
|
779 if ( aStatus == MXnUiStateObserver::EPartialForeground || |
|
780 aStatus == MXnUiStateObserver::EBackground ) |
|
781 { |
|
782 iFlags.Clear( EIsForeground ); |
|
783 |
|
784 CXnEditMode* editMode = iAppUiAdapter.UiEngine().EditMode(); |
|
785 if( editMode ) |
|
786 { |
|
787 TRAP_IGNORE( editMode->StopDraggingL() ); |
|
788 } |
|
789 |
|
790 iFocusControl->MakeVisible( EFalse ); |
|
791 |
|
792 TRAP_IGNORE( ChangeControlsStateL( EFalse ) ); |
|
793 } |
|
794 else |
|
795 { |
|
796 iFlags.Set( EIsForeground ); |
|
797 |
|
798 TRAP_IGNORE( ChangeControlsStateL( ETrue ) ); |
|
799 } |
|
800 } |
|
801 |
|
802 // ----------------------------------------------------------------------------- |
|
803 // CXnViewAdapter::NotifyLightStatusChanged |
|
804 // |
|
805 // ----------------------------------------------------------------------------- |
|
806 // |
|
807 void CXnViewAdapter::NotifyLightStatusChanged( TBool aLightsOn ) |
|
808 { |
|
809 if ( aLightsOn ) |
|
810 { |
|
811 iFlags.Set( EIsLightsOn ); |
|
812 |
|
813 TRAP_IGNORE( ChangeControlsStateL( ETrue ) ); |
|
814 } |
|
815 else |
|
816 { |
|
817 iFlags.Clear( EIsLightsOn ); |
|
818 |
|
819 TRAP_IGNORE( ChangeControlsStateL( EFalse ) ); |
|
820 } |
|
821 } |
|
822 |
|
823 // ----------------------------------------------------------------------------- |
|
824 // CXnViewAdapter::NotifyInCallStateChaged |
|
825 // |
|
826 // ----------------------------------------------------------------------------- |
|
827 // |
|
828 void CXnViewAdapter::NotifyInCallStateChaged( TBool aInCall ) |
|
829 { |
|
830 if ( !iContainer ) |
|
831 { |
|
832 return; |
|
833 } |
|
834 |
|
835 TBool incallNow( iFlags.IsSet( EIsInCall ) ? ETrue : EFalse ); |
|
836 |
|
837 if ( incallNow == aInCall ) |
|
838 { |
|
839 return; |
|
840 } |
|
841 |
|
842 if ( aInCall ) |
|
843 { |
|
844 iFlags.Set( EIsInCall ); |
|
845 } |
|
846 else |
|
847 { |
|
848 iFlags.Clear( EIsInCall ); |
|
849 } |
|
850 |
|
851 CXnViewData& view( iAppUiAdapter.ViewManager().ActiveViewData() ); |
|
852 |
|
853 TRAP_IGNORE( UpdateRskByUiStateL( view ) ); |
|
854 } |
|
855 |
|
856 // ----------------------------------------------------------------------------- |
|
857 // CXnViewAdapter::ChangeControlsStateL |
|
858 // |
|
859 // ----------------------------------------------------------------------------- |
|
860 // |
|
861 void CXnViewAdapter::ChangeControlsStateL( TBool aAwake ) |
|
862 { |
|
863 if ( !iContainer ) |
|
864 { |
|
865 return; |
|
866 } |
|
867 |
|
868 TBool awakeNow( iFlags.IsSet( EIsControlsAwake ) ? ETrue : EFalse ); |
|
869 |
|
870 if ( aAwake == awakeNow ) |
|
871 { |
|
872 // No change in the state |
|
873 return; |
|
874 } |
|
875 |
|
876 TBool changeState( EFalse ); |
|
877 |
|
878 if ( aAwake ) |
|
879 { |
|
880 if ( iFlags.IsSet( EIsForeground ) && iFlags.IsSet( EIsLightsOn ) ) |
|
881 { |
|
882 iFlags.Set( EIsControlsAwake ); |
|
883 changeState = ETrue; |
|
884 } |
|
885 } |
|
886 else |
|
887 { |
|
888 iFlags.Clear( EIsControlsAwake ); |
|
889 changeState = ETrue; |
|
890 } |
|
891 |
|
892 if( changeState ) |
|
893 { |
|
894 RPointerArray< CXnControlAdapter > controls; |
|
895 CleanupClosePushL( controls ); |
|
896 |
|
897 iContainer->ControlsL( controls ); |
|
898 |
|
899 for ( TInt i = 0; i < controls.Count(); i++ ) |
|
900 { |
|
901 if ( aAwake ) |
|
902 { |
|
903 controls[i]->ExitPowerSaveModeL(); |
|
904 } |
|
905 else |
|
906 { |
|
907 controls[i]->EnterPowerSaveModeL(); |
|
908 if ( controls[i]->LongTapDetector() && |
|
909 controls[i]->LongTapDetector()->IsActive() ) |
|
910 { |
|
911 controls[i]->LongTapDetector()->Cancel(); |
|
912 } |
|
913 } |
|
914 } |
|
915 |
|
916 CleanupStack::PopAndDestroy( &controls ); |
|
917 } |
|
918 } |
|
919 |
|
920 // ----------------------------------------------------------------------------- |
|
921 // CXnViewAdapter::UpdateRskByUiStateL() |
|
922 // |
|
923 // ----------------------------------------------------------------------------- |
|
924 // |
|
925 void CXnViewAdapter::UpdateRskByUiStateL( const CXnViewData& aViewData ) |
|
926 { |
|
927 CXnNode* menubar( NULL ); |
|
928 |
|
929 CXnDomNode* view( aViewData.Node() ); |
|
930 |
|
931 if ( view && view->LayoutNode() ) |
|
932 { |
|
933 RPointerArray< CXnNode >& children( view->LayoutNode()->Children() ); |
|
934 |
|
935 for ( TInt count = children.Count() - 1; count >= 0 ; --count ) |
|
936 { |
|
937 CXnNode* node( children[count] ); |
|
938 |
|
939 // Check that the given type of a control is parent |
|
940 // (or ancestor) of this control |
|
941 const TDesC8& type( node->Type()->Type() ); |
|
942 |
|
943 if ( type == KMenuBar ) |
|
944 { |
|
945 menubar = node; |
|
946 break; |
|
947 } |
|
948 } |
|
949 } |
|
950 |
|
951 if( menubar ) |
|
952 { |
|
953 const TDesC8* state( NULL ); |
|
954 |
|
955 if( iAppUiAdapter.UiEngine().IsEditMode() ) |
|
956 { |
|
957 state = &XnPropertyNames::softkey::mode::KModeEdit; |
|
958 } |
|
959 else if( iFlags.IsSet( EIsInCall ) ) |
|
960 { |
|
961 state = &XnPropertyNames::softkey::mode::KModeCallActive; |
|
962 } |
|
963 else |
|
964 { |
|
965 state = &XnPropertyNames::softkey::mode::KModeCallInactive; |
|
966 } |
|
967 |
|
968 XnMenuInterface::MXnMenuInterface* menuIf( NULL ); |
|
969 XnComponentInterface::MakeInterfaceL( menuIf, menubar->AppIfL() ); |
|
970 |
|
971 RPointerArray<CXnNode>& childrens( menubar->Children() ); |
|
972 |
|
973 for( TInt i=0; i < childrens.Count(); i++ ) |
|
974 { |
|
975 CXnNode* node = childrens[i]; |
|
976 |
|
977 if( node && node->Type()->Type() == XnPropertyNames::softkey::KNodeName ) |
|
978 { |
|
979 CXnProperty* mode = node->GetPropertyL( XnPropertyNames::softkey::KModeAttribute ); |
|
980 CXnProperty* type = node->GetPropertyL( XnPropertyNames::softkey::KTypeAttribute ); |
|
981 |
|
982 if( ( mode && *state == mode->StringValue() ) && |
|
983 ( type && type->StringValue().Compare( XnPropertyNames::softkey::type::KRight ) == 0 ) ) |
|
984 { |
|
985 menuIf->SetSoftKeyL( &node->PluginIfL() , XnMenuInterface::MXnMenuInterface::ERight ); |
|
986 node->SetDirtyL( XnDirtyLevel::ERender ); |
|
987 |
|
988 TRAP_IGNORE( iAppUiAdapter.UiEngine().RefreshMenuL() ); |
|
989 } |
|
990 } |
|
991 } |
|
992 } |
|
993 } |
|
994 |
|
995 // ----------------------------------------------------------------------------- |
|
996 // CXnViewAdapter::CloseAllPopupsL() |
|
997 // |
|
998 // ----------------------------------------------------------------------------- |
|
999 // |
|
1000 void CXnViewAdapter::CloseAllPopupsL() |
|
1001 { |
|
1002 if ( !iContainer ) |
|
1003 { |
|
1004 return; |
|
1005 } |
|
1006 |
|
1007 RPointerArray< CXnNode > popups; |
|
1008 CleanupClosePushL( popups ); |
|
1009 |
|
1010 iContainer->PopupNodesL( popups ); |
|
1011 |
|
1012 for ( TInt i = 0; i < popups.Count(); i++ ) |
|
1013 { |
|
1014 CXnProperty* display = CXnProperty::NewL( |
|
1015 XnPropertyNames::style::common::KDisplay, |
|
1016 XnPropertyNames::style::common::display::KNone, |
|
1017 CXnDomPropertyValue::EString, |
|
1018 *iAppUiAdapter.UiEngine().ODT()->DomDocument().StringPool() ); |
|
1019 |
|
1020 CleanupStack::PushL( display ); |
|
1021 popups[i]->SetPropertyL(display); |
|
1022 CleanupStack::Pop( display ); |
|
1023 } |
|
1024 |
|
1025 CleanupStack::PopAndDestroy( &popups ); |
|
1026 } |
|
1027 |
|
1028 |
|
1029 // End of file |