1 /* |
|
2 * Copyright (c) 2006 - 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: Open state handle interfaces implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CVtEngStateOpen.h" |
|
21 #include "CVtEngOperation.h" |
|
22 #include "CVtEngAudioHandler.h" |
|
23 #include <cvtlogger.h> |
|
24 |
|
25 #include "CVtEngExtensions.h" |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CVtEngStateOpen::CVtEngStateOpen |
|
31 // C++ constructor can NOT contain any code, that |
|
32 // might leave. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CVtEngStateOpen::CVtEngStateOpen( |
|
36 CVtEngStateManager& aStateManager, |
|
37 CVtEngEventManager& aEventManager ) |
|
38 : CVtEngStateBase( aStateManager, aEventManager ) |
|
39 { |
|
40 } |
|
41 |
|
42 // Destructor |
|
43 CVtEngStateOpen::~CVtEngStateOpen() |
|
44 { |
|
45 __VTPRINT( DEBUG_DESTRUCT, "~StateOpen") |
|
46 } |
|
47 |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CVtEngStateOpen::UpdateL |
|
51 // Updates state |
|
52 // (other items were commented in a header). |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void CVtEngStateOpen::UpdateL() |
|
56 { |
|
57 __VTPRINTENTER( "StateOpen.Update" ) |
|
58 const MVtCtlCallControl::TVtCtlState bearerstate = |
|
59 SessionHandler().RealState(); |
|
60 |
|
61 const MVtProtocolCommand::TVtProtocolState protoState( MediaHandler().ProtoState() ); |
|
62 const TBool bearerIdle = ( bearerstate == MVtCtlCallControl::EIdle || |
|
63 bearerstate == MVtCtlCallControl::EUnknown ); |
|
64 const TBool bearerDisconnecting = |
|
65 ( bearerstate == MVtCtlCallControl::EDisconnecting ); |
|
66 |
|
67 CVtEngStateBase* newState = NULL; |
|
68 |
|
69 if ( protoState == MVtProtocolCommand::ESetup || |
|
70 protoState == MVtProtocolCommand::EIdle || |
|
71 bearerIdle ) |
|
72 { |
|
73 newState = NewStateL( MVtEngSessionInfo::EIdle ); |
|
74 } |
|
75 else if ( bearerDisconnecting || protoState == MVtProtocolCommand::EDisconnecting ) |
|
76 { |
|
77 newState = NewStateL( MVtEngSessionInfo::EClearing ); |
|
78 } |
|
79 if ( newState ) |
|
80 { |
|
81 newState->OpenL( this ); |
|
82 } |
|
83 __VTPRINTEXIT( "StateOpen.Update" ) |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CVtEngStateOpen::OpenL |
|
88 // State transition to open. |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CVtEngStateOpen::DoOpenL() |
|
92 { |
|
93 __VTPRINTENTER( "StateOpen.Open" ) |
|
94 |
|
95 // set audio routing (and ouput volume) |
|
96 RouteAudioL( NULL ); |
|
97 |
|
98 NotifyStateChange( MVtEngSessionInfo::EOpen ); |
|
99 __VTPRINTEXIT( "StateOpen.Open" ) |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CVtEngStateOpen::ValidateCommand |
|
104 // Returns if a command is valid in open state. |
|
105 // |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 TBool CVtEngStateOpen::ValidateCommand( |
|
109 const TVtEngCommandId aCommandId ) |
|
110 { |
|
111 __VTPRINT( DEBUG_DETAIL | DEBUG_GEN, "StateOpen.Validate") |
|
112 TBool okToPerform( EFalse ); |
|
113 switch ( aCommandId ) |
|
114 { |
|
115 case KVtEngInitializeEngine: // temporary |
|
116 case KVtEngPrepareCamera: |
|
117 case KVtEngSetZoomStep: |
|
118 case KVtEngStartViewFinder: |
|
119 case KVtEngPauseViewFinder: |
|
120 case KVtEngStopViewFinder: |
|
121 case KVtEngStartRenderRemote: |
|
122 case KVtEngStopRenderRemote: |
|
123 case KVtEngPauseRenderRemote: |
|
124 case KVtEngTerminateSession: |
|
125 case KVtEngStartDtmfTone: |
|
126 case KVtEngStopDtmfTone: |
|
127 // Handling of different UIIs, support is there |
|
128 case KVtEngSetUIIDtmfSupport: |
|
129 case KVtEngSetUIIBasicStringSupport: |
|
130 case KVtEngSetUIIIA5StringSupport: |
|
131 case KVtEngSetUIIGeneralStringSupport: |
|
132 case KVtEngSwitchToVoice: |
|
133 okToPerform = ETrue; |
|
134 break; |
|
135 |
|
136 // Extension commands |
|
137 case KVtEngSetContrast: |
|
138 case KVtEngSetBrightness: |
|
139 case KVtEngSetWhiteBalance: |
|
140 case KVtEngSetColorTone: |
|
141 #if defined ( RD_VT_RTF ) |
|
142 case KVtEngStartRecord: |
|
143 case KVtEngStopRecord: |
|
144 #endif // RD_VT_RTF |
|
145 { |
|
146 // Get extension handle from Utils |
|
147 __VTPRINT(DEBUG_GEN, "StateOpen extension->ValidateCommand") |
|
148 okToPerform = CVtEngUtility::Extensions()->ValidateCommand( |
|
149 aCommandId ); |
|
150 break; |
|
151 } |
|
152 |
|
153 default: |
|
154 okToPerform = CVtEngStateBase::ValidateCommand( aCommandId ); |
|
155 break; |
|
156 } |
|
157 return okToPerform; |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CVtEngStateOpen::State |
|
162 // Returns session state. |
|
163 // |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 MVtEngSessionInfo::TSessionState CVtEngStateOpen::State() const |
|
167 { |
|
168 return MVtEngSessionInfo::EOpen; |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // CVtEngStateOpen::HandleL |
|
173 // Handles an operation when behavior is state dependent. |
|
174 // |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 TBool CVtEngStateOpen::HandleL( CVtEngOperation& aOp ) |
|
178 { |
|
179 __VTPRINTENTER( "StateOpen.HandleL" ) |
|
180 TBool handled( CVtEngStateBase::HandleL( aOp ) ); |
|
181 switch ( aOp.Command() ) |
|
182 { |
|
183 case KVtEngTerminateSession: |
|
184 TerminateSessionL( aOp ); |
|
185 handled = ETrue; |
|
186 break; |
|
187 |
|
188 case KVtEngSwitchToVoice: |
|
189 { |
|
190 CVtEngStateBase* newState = |
|
191 NewStateL( MVtEngSessionInfo::EClearing ); |
|
192 CleanupStack::PushL( newState ); |
|
193 newState->OpenL( this ); |
|
194 CleanupStack::Pop(); |
|
195 // aOp is not passed to media handler because mediator command |
|
196 // sender signals completion, see |
|
197 // CVtEngMdtrCommandSender::HandleVtEventL |
|
198 } |
|
199 break; |
|
200 |
|
201 // Extension commands |
|
202 case KVtEngSetContrast: |
|
203 case KVtEngSetBrightness: |
|
204 case KVtEngSetWhiteBalance: |
|
205 case KVtEngSetColorTone: |
|
206 #if defined ( RD_VT_RTF ) |
|
207 case KVtEngStartRecord: |
|
208 case KVtEngStopRecord: |
|
209 #endif // RD_VT_RTF |
|
210 CallExtensionL( &aOp); |
|
211 break; |
|
212 default: |
|
213 break; |
|
214 } |
|
215 __VTPRINTEXITR( "StateOpen.HandleL %d", handled ) |
|
216 return handled; |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // CVtEngStateOpen::RouteAudioL |
|
221 // Handles audio routing operation. |
|
222 // |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 void CVtEngStateOpen::RouteAudioL( |
|
226 CVtEngOperation* aOp ) |
|
227 { |
|
228 __VTPRINTENTER( "StateOpen.RouteAudioL" ) |
|
229 CVtEngSettings& settings = CVtEngUtility::Settings(); |
|
230 const CVtEngSettings::TVtEngVideoCallConfig& config = settings.Config(); |
|
231 |
|
232 CVtEngAudioHandler& audioHandler = AudioHandler(); |
|
233 MVtEngAudio::TAudioRoutingState routingState( MVtEngAudio::EAudioWiredHeadset ); |
|
234 audioHandler.GetRoutingState( routingState ); |
|
235 |
|
236 TBool routeAudio( ETrue ); |
|
237 TInt volume( config.iAudio.iVolume.iHandsfreeVolume ); |
|
238 switch ( routingState ) |
|
239 { |
|
240 case MVtEngAudio::EAudioWiredHeadset: |
|
241 routeAudio = EFalse; |
|
242 // fall thru |
|
243 case MVtEngAudio::EAudioHandset: |
|
244 case MVtEngAudio::EAudioBT: |
|
245 volume = config.iAudio.iVolume.iHandsetVolume; |
|
246 break; |
|
247 // use default values |
|
248 case MVtEngAudio::EAudioLoudspeaker: |
|
249 default: |
|
250 break; |
|
251 } |
|
252 __VTPRINT3( DEBUG_GEN | DEBUG_DETAIL, |
|
253 "StateOpen.RouteAudioL route=%d,vol=%d", routeAudio,volume ) |
|
254 if ( aOp == NULL || ( aOp && routeAudio ) ) |
|
255 { |
|
256 // set volume if state was changed (called from DoOpenL) or |
|
257 // audio routing will be changed |
|
258 __VTPRINT( DEBUG_GEN | DEBUG_DETAIL, "StateOpen.RouteAudioL SetVol" ) |
|
259 MediaHandler().SetVolume( volume ); |
|
260 } |
|
261 |
|
262 // *** AUDIO && ( aOp != NULL ) *** |
|
263 if ( routeAudio && ( aOp != NULL ) ) |
|
264 { |
|
265 if ( aOp ) |
|
266 { |
|
267 audioHandler.HandleL( *aOp ); |
|
268 } |
|
269 } |
|
270 __VTPRINTEXIT( "StateOpen.RouteAudioL" ) |
|
271 } |
|
272 |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // CVtEngStateOpen::CallExtensionL |
|
276 // Handles extension operations. |
|
277 // |
|
278 // ----------------------------------------------------------------------------- |
|
279 // |
|
280 void CVtEngStateOpen::CallExtensionL( |
|
281 CVtEngOperation* aOp) |
|
282 { |
|
283 __VTPRINTENTER( "StateOpen.CallExtensionL" ) |
|
284 CVtEngUtility::Extensions()->OfferOperationL( aOp ); |
|
285 __VTPRINTEXIT( "StateOpen.CallExtensionL" ) |
|
286 } |
|
287 |
|
288 // End of File |
|