|
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: Implementation of CPhoneSingleAndCallSetup class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include <featmgr.h> |
|
21 #include <cpephonemodelif.h> |
|
22 #include "cphonesingleandcallsetup.h" |
|
23 #include "mphonestatemachine.h" |
|
24 #include "phoneviewcommanddefinitions.h" |
|
25 #include "tphonecmdparamcallheaderdata.h" |
|
26 #include "tphonecmdparamcallstatedata.h" |
|
27 #include "tphonecmdparamboolean.h" |
|
28 #include "tphonecmdparaminteger.h" |
|
29 #include "phonestatedefinitionsgsm.h" |
|
30 #include "phonelogger.h" |
|
31 #include "phonerssbase.h" |
|
32 #include "phoneui.hrh" |
|
33 #include "tphonecmdparamglobalnote.h" |
|
34 #include "cphonemainresourceresolver.h" |
|
35 |
|
36 // ================= MEMBER FUNCTIONS ======================= |
|
37 |
|
38 // C++ default constructor can NOT contain any code, that |
|
39 // might leave. |
|
40 // |
|
41 CPhoneSingleAndCallSetup::CPhoneSingleAndCallSetup( |
|
42 MPhoneStateMachine* aStateMachine, |
|
43 MPhoneViewCommandHandle* aViewCommandHandle, |
|
44 MPhoneCustomization* aPhoneCustomization ) : |
|
45 CPhoneCallSetup( aStateMachine, aViewCommandHandle, aPhoneCustomization ) |
|
46 { |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------- |
|
50 // CPhoneSingleAndCallSetup::~CPhoneSingleAndCallSetup() |
|
51 // Destructor |
|
52 // (other items were commented in a header). |
|
53 // ----------------------------------------------------------- |
|
54 // |
|
55 CPhoneSingleAndCallSetup::~CPhoneSingleAndCallSetup() |
|
56 { |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------- |
|
60 // CPhoneSingleAndCallSetup::ConstructL() |
|
61 // Constructor |
|
62 // (other items were commented in a header). |
|
63 // ----------------------------------------------------------- |
|
64 // |
|
65 void CPhoneSingleAndCallSetup::ConstructL() |
|
66 { |
|
67 CPhoneCallSetup::ConstructL(); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------- |
|
71 // CPhoneSingleAndCallSetup::NewL() |
|
72 // Constructor |
|
73 // (other items were commented in a header). |
|
74 // ----------------------------------------------------------- |
|
75 // |
|
76 CPhoneSingleAndCallSetup* CPhoneSingleAndCallSetup::NewL( |
|
77 MPhoneStateMachine* aStateMachine, |
|
78 MPhoneViewCommandHandle* aViewCommandHandle, |
|
79 MPhoneCustomization* aPhoneCustomization ) |
|
80 { |
|
81 CPhoneSingleAndCallSetup* self = new( ELeave ) CPhoneSingleAndCallSetup( |
|
82 aStateMachine, aViewCommandHandle, aPhoneCustomization ); |
|
83 |
|
84 CleanupStack::PushL( self ); |
|
85 self->ConstructL(); |
|
86 CleanupStack::Pop( self ); |
|
87 |
|
88 return self; |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------- |
|
92 // CPhoneSingleAndCallSetup::HandlePhoneEngineMessageL |
|
93 // ----------------------------------------------------------- |
|
94 // |
|
95 void CPhoneSingleAndCallSetup::HandlePhoneEngineMessageL( |
|
96 const TInt aMessage, |
|
97 TInt aCallId ) |
|
98 { |
|
99 __LOGMETHODSTARTEND( EPhoneUIStates, |
|
100 "CPhoneSingleAndCallSetup::HandlePhoneEngineMessageL()"); |
|
101 switch ( aMessage ) |
|
102 { |
|
103 case MEngineMonitor::EPEMessageConnecting: |
|
104 HandleConnectingL( aCallId ); |
|
105 break; |
|
106 |
|
107 case MEngineMonitor::EPEMessageConnected: |
|
108 HandleConnectedL( aCallId ); |
|
109 break; |
|
110 |
|
111 case MEngineMonitor::EPEMessageIdle: |
|
112 HandleIdleL( aCallId ); |
|
113 break; |
|
114 |
|
115 default: |
|
116 CPhoneCallSetup::HandlePhoneEngineMessageL( aMessage, |
|
117 aCallId ); |
|
118 break; |
|
119 } |
|
120 } |
|
121 |
|
122 // -------------------------------------------------------------- |
|
123 // CPhoneSingleAndCallSetup::HandleKeyMessageL |
|
124 // -------------------------------------------------------------- |
|
125 // |
|
126 void CPhoneSingleAndCallSetup::HandleKeyMessageL( |
|
127 TPhoneKeyEventMessages aMessage, |
|
128 TKeyCode aCode ) |
|
129 { |
|
130 __LOGMETHODSTARTEND( EPhoneUIStates, |
|
131 "CPhoneSingleAndCallSetup::HandleKeyMessageL()"); |
|
132 switch ( aCode ) |
|
133 { |
|
134 // send-key |
|
135 case EKeyYes: |
|
136 if ( CPhoneState::IsNumberEntryUsedL() ) |
|
137 { |
|
138 // send a manual control sequence |
|
139 CPhoneState::CallFromNumberEntryL(); |
|
140 } |
|
141 else |
|
142 { |
|
143 // Show not allowed note |
|
144 CPhoneState::SendGlobalErrorNoteL( |
|
145 EPhoneNoteTextNotAllowed ); |
|
146 } |
|
147 break; |
|
148 |
|
149 // end-key |
|
150 case EKeyNo: |
|
151 if ( aMessage == EPhoneKeyLongPress ) |
|
152 { |
|
153 iStateMachine->SendPhoneEngineMessage( |
|
154 CPEPhoneModelIF::EPEMessageTerminateAllConnections ); |
|
155 } |
|
156 else |
|
157 { |
|
158 // Fetch active call's id from view |
|
159 TPhoneCmdParamCallStateData callStateData; |
|
160 // Find the dialing call |
|
161 callStateData.SetCallState( EPEStateDialing ); |
|
162 iViewCommandHandle->HandleCommandL( |
|
163 EPhoneViewGetCallIdByState, &callStateData ); |
|
164 |
|
165 if( callStateData.CallId() > KErrNotFound ) |
|
166 { |
|
167 // Release the call |
|
168 iStateMachine->SetCallId( |
|
169 callStateData.CallId() ); |
|
170 iStateMachine->SendPhoneEngineMessage( |
|
171 MPEPhoneModel::EPEMessageRelease ); |
|
172 } |
|
173 else |
|
174 { |
|
175 callStateData.SetCallState( EPEStateDisconnecting ); |
|
176 iViewCommandHandle->HandleCommandL( |
|
177 EPhoneViewGetCallIdByState, &callStateData ); |
|
178 |
|
179 if ( callStateData.CallId() > KErrNotFound ) |
|
180 { |
|
181 // Release the call |
|
182 iStateMachine->SetCallId( |
|
183 callStateData.CallId() ); |
|
184 iStateMachine->SendPhoneEngineMessage( |
|
185 MPEPhoneModel::EPEMessageRelease ); |
|
186 } |
|
187 } |
|
188 } |
|
189 break; |
|
190 |
|
191 default: |
|
192 // do base operation |
|
193 CPhoneCallSetup::HandleKeyMessageL( aMessage, aCode ); |
|
194 break; |
|
195 } |
|
196 } |
|
197 |
|
198 |
|
199 // ----------------------------------------------------------- |
|
200 // CPhoneSingleAndCallSetup::HandleConnectingL |
|
201 // ----------------------------------------------------------- |
|
202 // |
|
203 void CPhoneSingleAndCallSetup::HandleConnectingL( TInt aCallId ) |
|
204 { |
|
205 __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneSingleAndCallSetup::HandleConnectingL()"); |
|
206 |
|
207 BeginUiUpdateLC(); |
|
208 |
|
209 UpdateRemoteInfoDataL ( aCallId ); |
|
210 |
|
211 iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveGlobalNote ); |
|
212 |
|
213 // Re-enable global notes |
|
214 TPhoneCmdParamBoolean globalNotifierParam; |
|
215 globalNotifierParam.SetBoolean( EFalse ); |
|
216 iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled, |
|
217 &globalNotifierParam ); |
|
218 |
|
219 // Stop capturing keys |
|
220 CaptureKeysDuringCallNotificationL( EFalse ); |
|
221 |
|
222 // Remove the number entry if it isn't DTMF dialer |
|
223 if ( !iOnScreenDialer || !IsNumberEntryVisibleL() || !IsDTMFEditorVisibleL() ) |
|
224 { |
|
225 iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry ); |
|
226 } |
|
227 |
|
228 TPhoneCmdParamCallHeaderData callHeaderParam; |
|
229 callHeaderParam.SetCallState( EPEStateConnecting ); |
|
230 iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId, |
|
231 &callHeaderParam ); |
|
232 |
|
233 EndUiUpdate(); |
|
234 |
|
235 // Set Hold flag to view EFalse that dtmf menu item not delete |
|
236 TPhoneCmdParamBoolean holdFlag; |
|
237 holdFlag.SetBoolean( EFalse ); |
|
238 iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag ); |
|
239 |
|
240 // Go to alerting state |
|
241 UpdateCbaL( EPhoneCallHandlingInCallCBA ); |
|
242 iStateMachine->ChangeState( EPhoneStateAlertingInSingle ); |
|
243 } |
|
244 |
|
245 // ----------------------------------------------------------- |
|
246 // CPhoneSingleAndCallSetup::HandleConnectedL |
|
247 // ----------------------------------------------------------- |
|
248 // |
|
249 void CPhoneSingleAndCallSetup::HandleConnectedL( TInt aCallId ) |
|
250 { |
|
251 __LOGMETHODSTARTEND( EPhoneUIStates, |
|
252 "CPhoneSingleAndCallSetup::HandleConnectedL()"); |
|
253 |
|
254 BeginUiUpdateLC(); |
|
255 |
|
256 // Show bubble |
|
257 TPhoneCmdParamCallHeaderData callHeaderParam; |
|
258 callHeaderParam.SetCallState( EPEStateConnected ); |
|
259 iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId, |
|
260 &callHeaderParam ); |
|
261 |
|
262 // Capturing keys and number entry must be removed because some |
|
263 // networks jump over connecting state directly to connected state. |
|
264 CaptureKeysDuringCallNotificationL( EFalse ); |
|
265 |
|
266 // Remove the number entry if it isn't DTMF dialer |
|
267 if ( !iOnScreenDialer || !IsNumberEntryVisibleL() || !IsDTMFEditorVisibleL() ) |
|
268 { |
|
269 iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry ); |
|
270 } |
|
271 |
|
272 // Set Hold flag to view |
|
273 TPhoneCmdParamBoolean holdFlag; |
|
274 holdFlag.SetBoolean( EFalse ); |
|
275 iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag ); |
|
276 |
|
277 SetTouchPaneButtons( EPhoneTwoSinglesButtons ); |
|
278 |
|
279 EndUiUpdate(); |
|
280 |
|
281 // Go to two singles state |
|
282 UpdateCbaL( EPhoneCallHandlingNewCallSwapCBA ); |
|
283 iStateMachine->ChangeState( EPhoneStateTwoSingles ); |
|
284 |
|
285 } |
|
286 |
|
287 // ----------------------------------------------------------- |
|
288 // CPhoneSingleAndCallSetup::HandleIdleL |
|
289 // ----------------------------------------------------------- |
|
290 // |
|
291 void CPhoneSingleAndCallSetup::HandleIdleL( TInt aCallId ) |
|
292 { |
|
293 __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneSingleAndCallSetup::HandleIdleL()"); |
|
294 |
|
295 BeginTransEffectLC( ENumberEntryOpen ); |
|
296 BeginUiUpdateLC(); |
|
297 |
|
298 // Remove call |
|
299 iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveCallHeader, aCallId ); |
|
300 |
|
301 // Close menu bar, if it is displayed |
|
302 iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose ); |
|
303 |
|
304 // Find out do we have single or outgoing call left |
|
305 TPhoneCmdParamInteger activeCallCount; |
|
306 iViewCommandHandle->ExecuteCommandL( |
|
307 EPhoneViewGetCountOfActiveCalls, &activeCallCount ); |
|
308 |
|
309 if( activeCallCount.Integer() ) |
|
310 { |
|
311 CheckIfRestoreNEContentAfterDtmfDialer(); |
|
312 |
|
313 if ( IsNumberEntryUsedL() ) |
|
314 { |
|
315 // Show the number entry if it exists |
|
316 SetNumberEntryVisibilityL(ETrue); |
|
317 } |
|
318 else |
|
319 { |
|
320 // Set incall CBAs |
|
321 UpdateCbaL( EPhoneCallHandlingInCallCBA ); |
|
322 } |
|
323 |
|
324 SetTouchPaneButtons( EPhoneIncallButtons ); |
|
325 // UnCapture keys callsetup fails |
|
326 CaptureKeysDuringCallNotificationL( EFalse ); |
|
327 // Setup call was terminated |
|
328 iStateMachine->ChangeState( EPhoneStateSingle ); |
|
329 } |
|
330 else |
|
331 { |
|
332 // Display call termination note, if necessary |
|
333 DisplayCallTerminationNoteL(); |
|
334 |
|
335 // Single call was terminated |
|
336 SetTouchPaneButtons( EPhoneCallSetupButtons ); |
|
337 SetToolbarDimming( ETrue ); |
|
338 SetToolbarButtonLoudspeakerEnabled(); |
|
339 // Update call setup CBAs |
|
340 UpdateCbaL( EPhoneCallHandlingCallSetupCBA ); |
|
341 iStateMachine->ChangeState( EPhoneStateCallSetup ); |
|
342 } |
|
343 |
|
344 EndUiUpdate(); |
|
345 EndTransEffect(); |
|
346 } |
|
347 |
|
348 // ----------------------------------------------------------- |
|
349 // CPhoneSingleAndCallSetup::HandleCommandL |
|
350 // ----------------------------------------------------------- |
|
351 // |
|
352 TBool CPhoneSingleAndCallSetup::HandleCommandL( TInt aCommand ) |
|
353 { |
|
354 __LOGMETHODSTARTEND( EPhoneUIStates, |
|
355 "CPhoneSingleAndCallSetup::HandleCommandL()"); |
|
356 TBool commandStatus = ETrue; |
|
357 |
|
358 switch( aCommand ) |
|
359 { |
|
360 case EPhoneInCallCmdEndThisOutgoingCall: |
|
361 { |
|
362 // Fetch call's id from view |
|
363 TPhoneCmdParamCallStateData callStateData; |
|
364 callStateData.SetCallState( EPEStateDialing ); |
|
365 iViewCommandHandle->HandleCommandL( |
|
366 EPhoneViewGetCallIdByState, &callStateData ); |
|
367 |
|
368 if ( callStateData.CallId() > KErrNotFound ) |
|
369 { |
|
370 // Release the call |
|
371 iStateMachine->SetCallId( |
|
372 callStateData.CallId() ); |
|
373 iStateMachine->SendPhoneEngineMessage( |
|
374 MPEPhoneModel::EPEMessageRelease ); |
|
375 } |
|
376 else |
|
377 { |
|
378 callStateData.SetCallState( EPEStateDisconnecting ); |
|
379 iViewCommandHandle->HandleCommandL( |
|
380 EPhoneViewGetCallIdByState, &callStateData ); |
|
381 |
|
382 if ( callStateData.CallId() > KErrNotFound ) |
|
383 { |
|
384 // Release the call |
|
385 iStateMachine->SetCallId( |
|
386 callStateData.CallId() ); |
|
387 iStateMachine->SendPhoneEngineMessage( |
|
388 MPEPhoneModel::EPEMessageRelease ); |
|
389 } |
|
390 __PHONELOG( EOnlyFatal, EPhoneUIStates, |
|
391 "CPhoneSingleAndCallSetup::HandleCommandL EPhoneInCallCmdEndThisOutgoingCall has negative call id!" ); |
|
392 } |
|
393 } |
|
394 break; |
|
395 |
|
396 default: |
|
397 commandStatus = CPhoneStateCallSetup::HandleCommandL( aCommand ); |
|
398 break; |
|
399 } |
|
400 |
|
401 return commandStatus; |
|
402 } |
|
403 |
|
404 // End of File |
|
405 |