|
1 /* |
|
2 * Copyright (c) 2006 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: Dialer feature |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <cvtlogger.h> |
|
20 #include <cvideodtmfdialer.h> |
|
21 #include <aknsdrawutils.h> |
|
22 #include <aknsutils.h> |
|
23 #include <aknlayoutscalable_apps.cdl.h> |
|
24 #include <aknlayoutscalable_avkon.cdl.h> |
|
25 #include <layoutmetadata.cdl.h> |
|
26 #include <featmgr.h> |
|
27 #include <aknsbasicbackgroundcontrolcontext.h> |
|
28 |
|
29 #include "VtUiUtility.h" |
|
30 #include "VtUiLayout.h" |
|
31 #include "mvtuicomponentmanager.h" |
|
32 #include "cvtuidialercontainer.h" |
|
33 #include "cvtuidialervideocontrol.h" |
|
34 #include "tvtuiwsevent.h" |
|
35 #include "tvtuistates.h" |
|
36 #include "cvtuidialerskmodifier.h" |
|
37 #include "cvtuifeaturemanager.h" |
|
38 #include "CVtUiAppUi.h" |
|
39 #include "mvtuicommandmanager.h" |
|
40 #include "cvtuidtmfbuffer.h" |
|
41 |
|
42 // Index of white color. |
|
43 const TInt KVtUiColorWhite = 0; |
|
44 |
|
45 // Implementation of TVtUiMiniDialerComponentState |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // TVtUiDialerComponentState::TVtUiDialerComponentState |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 TVtUiDialerComponentState::TVtUiDialerComponentState( |
|
52 MVtUiComponent& aComponent ) : |
|
53 TVtUiComponentState( aComponent, |
|
54 TVtUiBlockListBitField( |
|
55 MVtUiComponent::EComponentIdToolbar | |
|
56 MVtUiComponent::EComponentIdNumberEntry ) ) |
|
57 { |
|
58 } |
|
59 |
|
60 // Implementation of CVtUiDialerContainer |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CVtUiDialerContainer::NewL |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CVtUiDialerContainer* CVtUiDialerContainer::NewL( |
|
67 CVtUiFeatureManager& aFeatureManager ) |
|
68 { |
|
69 __VTPRINTENTER( "DialContainer.NewL" ) |
|
70 CVtUiDialerContainer* self = |
|
71 new ( ELeave ) CVtUiDialerContainer( aFeatureManager ); |
|
72 CleanupStack::PushL( self ); |
|
73 self->ConstructL( aFeatureManager.AppUi().BitmapManager() ); |
|
74 CleanupStack::Pop(); // self |
|
75 __VTPRINTEXIT( "DialContainer.NewL" ) |
|
76 return self; |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // CVtUiDialerContainer::~CVtUiDialerContainer |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 CVtUiDialerContainer::~CVtUiDialerContainer() |
|
84 { |
|
85 __VTPRINTENTER( "DialContainer.~" ) |
|
86 delete iAsyncDeactivate; |
|
87 delete iVideoControl; |
|
88 delete iDialer; |
|
89 delete iSKModifier; |
|
90 delete iInputBuffer; |
|
91 delete iBgContext; |
|
92 AknsUtils::DeregisterControlPosition( this ); |
|
93 __VTPRINTEXIT( "DialContainer.~" ) |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // CVtUiDialerContainer::HandleResourceChangeL |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 void CVtUiDialerContainer::HandleResourceChangeL( TInt aType ) |
|
101 { |
|
102 __VTPRINTENTER( "DialContainer.HandleResourceChangeL" ) |
|
103 switch ( aType ) |
|
104 { |
|
105 case KEikDynamicLayoutVariantSwitch: |
|
106 case KAknsMessageSkinChange: |
|
107 LayoutDialerContainer(); |
|
108 break; |
|
109 default: |
|
110 break; |
|
111 } |
|
112 __VTPRINTEXIT( "DialContainer.HandleResourceChangeL" ) |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // CVtUiDialerContainer::ComponentId |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 MVtUiComponent::TComponentId CVtUiDialerContainer::ComponentId() const |
|
120 { |
|
121 return EComponentIdDialer; |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CVtUiDialerContainer::ComponentAsControl |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 CCoeControl* CVtUiDialerContainer::ComponentAsControl() |
|
129 { |
|
130 return iVideoControl; |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CVtUiDialerContainer::DoActivateL |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 void CVtUiDialerContainer::DoActivateL() |
|
138 { |
|
139 __VTPRINTENTER( "DialContainer.DoActivateL" ) |
|
140 iUiStates.SetIsDialerActivating( EFalse ); |
|
141 LayoutDialerContainer(); |
|
142 Reset(); |
|
143 iVideoControl->MakeVisible( ETrue ); |
|
144 iDialer->MakeVisible( ETrue ); |
|
145 MakeVisible( ETrue ); |
|
146 User::LeaveIfError( iFeatureManager-> |
|
147 CommandManager().AddCommandModifier( *iSKModifier ) ); |
|
148 iInputBuffer->Activate(); |
|
149 iMode = CVtUiAppUi::ERenderingModeDialer; |
|
150 TVtUiWsEvent< CVtUiAppUi::TRenderingMode > renderingEvent( |
|
151 EVtUiWsEventBeginRenderingMode, &iMode ); |
|
152 iCoeEnv->WsSession().SendEventToWindowGroup( |
|
153 Window().WindowGroupId(), renderingEvent ); |
|
154 iUiStates.SetIsDialerOpen( ETrue ); |
|
155 iAsyncDeactivate->Cancel(); |
|
156 __VTPRINTEXIT( "DialContainer.DoActivateL" ) |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // CVtUiDialerContainer::DoDeactivateL |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 void CVtUiDialerContainer::DoDeactivateL() |
|
164 { |
|
165 __VTPRINTENTER( "DialContainer.DoDeactivateL" ) |
|
166 iFeatureManager->CommandManager(). |
|
167 RemoveCommandModifier( *iSKModifier ); |
|
168 iUiStates.SetIsDialerOpen( EFalse ); |
|
169 iVideoControl->MakeVisible( EFalse ); |
|
170 iDialer->MakeVisible( EFalse ); |
|
171 MakeVisible( EFalse ); |
|
172 Reset(); |
|
173 iInputBuffer->Deactivate(); |
|
174 iAsyncDeactivate->CallBack(); |
|
175 __VTPRINTEXIT( "DialContainer.DoDeactivateL" ) |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // CVtUiDialerContainer::GetContents |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 void CVtUiDialerContainer::GetContents( TDes& aContents ) const |
|
183 { |
|
184 __VTPRINTENTER( "DialContainer.GetContents" ) |
|
185 iInputBuffer->GetContents( aContents ); |
|
186 __VTPRINTEXIT( "DialContainer.GetContents" ) |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CVtUiDialerContainer::OfferKeyEventL |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 TKeyResponse CVtUiDialerContainer::OfferKeyEventL( const TKeyEvent& aEvent, |
|
194 TEventCode aType ) |
|
195 { |
|
196 __VTPRINTENTER( "DialContainer.OfferKeyEventL" ) |
|
197 TKeyResponse response( EKeyWasNotConsumed ); |
|
198 TChar dtmfTone; |
|
199 if ( VtUiUtility::IsDTMFEvent( aEvent, dtmfTone ) && |
|
200 ( aType == EEventKey ) ) |
|
201 { |
|
202 response = EKeyWasConsumed; |
|
203 AppendDigit( dtmfTone ); |
|
204 } |
|
205 __VTPRINTEXIT( "DialContainer.OfferKeyEventL" ) |
|
206 return response; |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // CVtUiDialerContainer::Draw |
|
211 // --------------------------------------------------------------------------- |
|
212 // |
|
213 void CVtUiDialerContainer::Draw( const TRect& ) const |
|
214 { |
|
215 __VTPRINTENTER( "DialContainer.Draw" ) |
|
216 CWindowGc& gc( SystemGc() ); |
|
217 gc.SetBrushStyle( CWindowGc::ESolidBrush ); |
|
218 gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
219 gc.SetBrushColor( AKN_LAF_COLOR( KVtUiColorWhite ) ); |
|
220 gc.Clear(); |
|
221 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
222 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
223 AknsDrawUtils::Background( skin, cc, this, gc, Rect() ); |
|
224 __VTPRINTEXIT( "DialContainer.Draw" ) |
|
225 } |
|
226 |
|
227 // --------------------------------------------------------------------------- |
|
228 // CVtUiDialerContainer::SizeChanged |
|
229 // --------------------------------------------------------------------------- |
|
230 // |
|
231 void CVtUiDialerContainer::SizeChanged() |
|
232 { |
|
233 __VTPRINTENTER( "DialContainer.SizeChanged" ) |
|
234 TRect bgRect; |
|
235 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, bgRect ); |
|
236 iBgContext->SetRect( bgRect ); |
|
237 |
|
238 AknsUtils::RegisterControlPosition( this ); |
|
239 CCoeControl::SizeChanged(); |
|
240 __VTPRINTEXIT( "DialContainer.SizeChanged" ) |
|
241 } |
|
242 |
|
243 // --------------------------------------------------------------------------- |
|
244 // CVtUiDialerContainer::PositionChanged |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 void CVtUiDialerContainer::PositionChanged() |
|
248 { |
|
249 __VTPRINTENTER( "DialContainer.PositionChanged" ) |
|
250 AknsUtils::RegisterControlPosition( this ); |
|
251 CCoeControl::PositionChanged(); |
|
252 __VTPRINTEXIT( "DialContainer.PositionChanged" ) |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------------------------- |
|
256 // CVtUiDialerContainer::CountComponentControls |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 TInt CVtUiDialerContainer::CountComponentControls() const |
|
260 { |
|
261 return iDialer ? 1 : 0; |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 // CVtUiDialerContainer::ComponentControl |
|
266 // --------------------------------------------------------------------------- |
|
267 // |
|
268 CCoeControl* CVtUiDialerContainer::ComponentControl( TInt aIndex ) const |
|
269 { |
|
270 CCoeControl* result = NULL; |
|
271 switch ( aIndex ) |
|
272 { |
|
273 case 0: |
|
274 result = iDialer; |
|
275 break; |
|
276 default: |
|
277 break; |
|
278 } |
|
279 return result; |
|
280 } |
|
281 |
|
282 // --------------------------------------------------------------------------- |
|
283 // CVtUiDialerContainer::CVtUiDialerContainer |
|
284 // --------------------------------------------------------------------------- |
|
285 // |
|
286 CVtUiDialerContainer::CVtUiDialerContainer( |
|
287 CVtUiFeatureManager& aFeatureManager ) : |
|
288 iComponentState( *this ), |
|
289 iFeatureManager( &aFeatureManager ), |
|
290 iComponentManager( &aFeatureManager.ComponentManager() ), |
|
291 iUiStates( aFeatureManager.UiStates() ) |
|
292 { |
|
293 __VTPRINTENTER( "DialContainer.ctor" ) |
|
294 __VTPRINTEXIT( "DialContainer.ctor" ) |
|
295 } |
|
296 |
|
297 // --------------------------------------------------------------------------- |
|
298 // CVtUiDialerContainer::ConstructL |
|
299 // --------------------------------------------------------------------------- |
|
300 // |
|
301 void CVtUiDialerContainer::ConstructL( CVtUiBitmapManager& aBitmapManager ) |
|
302 { |
|
303 __VTPRINTENTER( "DialContainer.ConstructL" ) |
|
304 iBgContext = CAknsBasicBackgroundControlContext::NewL( |
|
305 KAknsIIDQsnBgScreen, Rect(), ETrue ); |
|
306 CreateWindowL(); |
|
307 DrawableWindow()->SetPointerGrab( ETrue ); |
|
308 SetExtent( TPoint(), TSize() ); |
|
309 ActivateL(); |
|
310 MakeVisible( EFalse ); |
|
311 iInputBuffer = CVtUiDTMFBuffer::NewL( *iCoeEnv ); |
|
312 iVideoControl = CVtUiDialerVideoControl::NewL( aBitmapManager ); |
|
313 iDialer = CVideoDTMFDialer::NewL( *this, *iVideoControl, DialerRect() ); |
|
314 iSKModifier = CVtUiDialerSKModifier::NewL( *iFeatureManager ); |
|
315 // Disable fading when using DP (eliminates nasty color error) |
|
316 if ( FeatureManager::FeatureSupported( KFeatureIdDisplayPost ) ) |
|
317 { |
|
318 Window().SetNonFading( ETrue ); |
|
319 } |
|
320 iAsyncDeactivate = new ( ELeave ) CAsyncCallBack( |
|
321 TCallBack( ASyncDoDeactivate, this ), CActive::EPriorityLow ); |
|
322 __VTPRINTEXIT( "DialContainer.ConstructL" ) |
|
323 } |
|
324 |
|
325 // --------------------------------------------------------------------------- |
|
326 // CVtUiDialerContainer::RegisterComponentL |
|
327 // --------------------------------------------------------------------------- |
|
328 // |
|
329 void CVtUiDialerContainer::RegisterComponentL() |
|
330 { |
|
331 __VTPRINTENTER( "DialContainer.RegisterComponentL" ) |
|
332 User::LeaveIfError( iComponentManager->ChangeResourceChangeRegistration( |
|
333 *this, MVtUiComponentManager::ERegister ) ); |
|
334 User::LeaveIfError( |
|
335 iComponentManager->ChangeComponentRegistration( |
|
336 iComponentState, MVtUiComponentManager::ERegister ) ); |
|
337 User::LeaveIfError( iComponentManager->ChangeKeyEventRegistration( |
|
338 *this, MVtUiComponentManager::ERegister ) ); |
|
339 __VTPRINTEXIT( "DialContainer.RegisterComponentL" ) |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------------------------- |
|
343 // CVtUiDialerContainer::UnregisterComponent |
|
344 // --------------------------------------------------------------------------- |
|
345 // |
|
346 void CVtUiDialerContainer::UnregisterComponent() |
|
347 { |
|
348 __VTPRINTENTER( "DialContainer.UnregisterComponent" ) |
|
349 iComponentManager->ChangeComponentRegistration( |
|
350 iComponentState, MVtUiComponentManager::EUnregister ); |
|
351 iComponentManager->ChangeResourceChangeRegistration( |
|
352 *this, MVtUiComponentManager::EUnregister ); |
|
353 iComponentManager->ChangeKeyEventRegistration( |
|
354 *this, MVtUiComponentManager::EUnregister ); |
|
355 __VTPRINTEXIT( "DialContainer.UnregisterComponent" ) |
|
356 } |
|
357 |
|
358 // --------------------------------------------------------------------------- |
|
359 // CVtUiDialerContainer::UnregisterComponent |
|
360 // --------------------------------------------------------------------------- |
|
361 // |
|
362 MVtUiVideoWindow* CVtUiDialerContainer::ComponentAsVideoWindow() |
|
363 { |
|
364 __VTPRINTENTER( "DialContainer.ComponentAsVideoWindow" ) |
|
365 __VTPRINTEXIT( "DialContainer.ComponentAsVideoWindow" ) |
|
366 return iVideoControl; |
|
367 } |
|
368 |
|
369 // --------------------------------------------------------------------------- |
|
370 // CVtUiDialerContainer::LayoutDialerContainer |
|
371 // --------------------------------------------------------------------------- |
|
372 // |
|
373 void CVtUiDialerContainer::LayoutDialerContainer() |
|
374 { |
|
375 __VTPRINTENTER( "DialContainer.LayoutDialerContainer" ) |
|
376 |
|
377 TAknWindowLineLayout mainPaneLL; |
|
378 |
|
379 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
380 { |
|
381 // Landscape: Option11 (thin status pane, lsc) |
|
382 mainPaneLL = AknLayoutScalable_Avkon::main_pane( 9 ).LayoutLine(); |
|
383 } |
|
384 else |
|
385 { |
|
386 // Portrait: main pane with status pane off, control pane on |
|
387 mainPaneLL = AknLayoutScalable_Avkon::main_pane( 7 ).LayoutLine(); |
|
388 } |
|
389 |
|
390 TRect appWinRect; |
|
391 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, |
|
392 appWinRect ); |
|
393 |
|
394 // Layout container |
|
395 AknLayoutUtils::LayoutControl( this, appWinRect, mainPaneLL ); |
|
396 |
|
397 // Layout dialer |
|
398 const TInt variety( Layout_Meta_Data::IsLandscapeOrientation() ? |
|
399 1 : 0 ); |
|
400 TAknWindowLineLayout dialerLLout( |
|
401 AknLayoutScalable_Apps::main_video_tele_dialer_pane( |
|
402 variety ).LayoutLine() ); |
|
403 AknLayoutUtils::LayoutControl( iDialer, Rect(), dialerLLout ); |
|
404 |
|
405 // Layout video control |
|
406 AknLayoutUtils::LayoutControl( iVideoControl, iDialer->Rect(), |
|
407 AknLayoutScalable_Apps::video_down_pane_cp( |
|
408 variety ).LayoutLine() ); |
|
409 |
|
410 __VTPRINTEXIT( "DialContainer.LayoutDialerContainer" ) |
|
411 } |
|
412 |
|
413 // --------------------------------------------------------------------------- |
|
414 // CVtUiDialerContainer::DialerRect |
|
415 // --------------------------------------------------------------------------- |
|
416 // |
|
417 TRect CVtUiDialerContainer::DialerRect() const |
|
418 { |
|
419 __VTPRINTENTER( "DialContainer.DialerRect" ) |
|
420 TRect mainPaneRect; |
|
421 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
|
422 mainPaneRect ); |
|
423 __VTPRINTEXIT( "DialContainer.DialerRect" ) |
|
424 return mainPaneRect; |
|
425 } |
|
426 |
|
427 // --------------------------------------------------------------------------- |
|
428 // CVtUiDialerContainer::Reset |
|
429 // --------------------------------------------------------------------------- |
|
430 // |
|
431 void CVtUiDialerContainer::Reset() |
|
432 { |
|
433 __VTPRINTENTER( "DialContainer.Reset" ) |
|
434 iInputBuffer->Reset(); |
|
435 __VTPRINTEXIT( "DialContainer.Reset" ) |
|
436 } |
|
437 |
|
438 // --------------------------------------------------------------------------- |
|
439 // CVtUiDialerContainer::AppendDigit |
|
440 // --------------------------------------------------------------------------- |
|
441 // |
|
442 void CVtUiDialerContainer::AppendDigit( TChar aDigit ) |
|
443 { |
|
444 __VTPRINTENTER( "DialContainer.AppendDigit" ) |
|
445 iInputBuffer->Append( aDigit ); |
|
446 __VTPRINTEXIT( "DialContainer.AppendDigit" ) |
|
447 } |
|
448 |
|
449 // --------------------------------------------------------------------------- |
|
450 // CVtUiDialerContainer::MopSupplyObject |
|
451 // --------------------------------------------------------------------------- |
|
452 // |
|
453 TTypeUid::Ptr CVtUiDialerContainer::MopSupplyObject( TTypeUid aId ) |
|
454 { |
|
455 __VTPRINTENTER( "CVtUiDialerContainer.MopSupplyObject" ) |
|
456 // Required during rendering of the background skin in Draw() |
|
457 if (aId.iUid == MAknsControlContext::ETypeId) |
|
458 { |
|
459 __VTPRINTEXIT( "CVtUiDialerContainer.MopSupplyObject.1" ) |
|
460 return MAknsControlContext::SupplyMopObject( aId, iBgContext ); |
|
461 } |
|
462 __VTPRINTEXIT( "CVtUiDialerContainer.MopSupplyObject.2" ) |
|
463 return CCoeControl::MopSupplyObject( aId ); |
|
464 } |
|
465 |
|
466 // --------------------------------------------------------------------------- |
|
467 // CVtUiDialerContainer::ASyncDoDeactivate |
|
468 // --------------------------------------------------------------------------- |
|
469 // |
|
470 TInt CVtUiDialerContainer::ASyncDoDeactivate( TAny* aSelf ) |
|
471 { |
|
472 __VTPRINTENTER( "DialContainer.ASyncDoDeactivate" ) |
|
473 CVtUiDialerContainer* self = |
|
474 reinterpret_cast< CVtUiDialerContainer* >( aSelf ); |
|
475 self->iMode = CVtUiAppUi::ERenderingModeDialer; |
|
476 TVtUiWsEvent< CVtUiAppUi::TRenderingMode > renderingEvent( |
|
477 EVtUiWsEventEndRenderingMode, &self->iMode ); |
|
478 self->iCoeEnv->WsSession().SendEventToWindowGroup( |
|
479 self->Window().WindowGroupId(), renderingEvent ); |
|
480 __VTPRINTEXIT( "DialContainer.ASyncDoDeactivate" ) |
|
481 return KErrNone; |
|
482 } |