|
1 /* |
|
2 * Copyright (c) 2008-2009 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 CPhoneVccHandler class. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDES |
|
19 #include <phoneui.rsg> |
|
20 #include <avkon.rsg> |
|
21 #include <phoneuivoip.rsg> |
|
22 #include <StringLoader.h> |
|
23 #include <avkon.rsg> |
|
24 #include <mpeengineinfo.h> |
|
25 #include <eikmenup.h> |
|
26 #include <vccuipsproperty.h> |
|
27 #include "cphonevcchandler.h" |
|
28 #include "cphonetimer.h" |
|
29 #include "cphonestate.h" |
|
30 #include "cphonemainresourceresolver.h" |
|
31 #include "phonelogger.h" |
|
32 #include "cphonelogger.h" |
|
33 #include "mphoneviewcommandhandle.h" |
|
34 #include "mphonestatemachine.h" |
|
35 #include "phonerssvoip.h" |
|
36 #include "phoneappvoipcommands.hrh" |
|
37 #include "tphonecmdparamglobalnote.h" |
|
38 |
|
39 // For HO notification tone setting read |
|
40 #include <spproperty.h> |
|
41 #include <spsettings.h> |
|
42 #include <spentry.h> |
|
43 #include <spdefinitions.h> |
|
44 |
|
45 |
|
46 // CONSTANTS |
|
47 // 1,5 Second in microseconds |
|
48 const TInt KPhoneShowNoteTime = 1500000; |
|
49 |
|
50 // ================= MEMBER FUNCTIONS ======================= |
|
51 |
|
52 // C++ default constructor can NOT contain any code, that |
|
53 // might leave. |
|
54 // |
|
55 CPhoneVccHandler::CPhoneVccHandler( |
|
56 MPhoneStateMachine& aStateMachine, |
|
57 MPhoneViewCommandHandle& aViewCommandHandle ) : |
|
58 iStateMachine( aStateMachine ), |
|
59 iViewCommandHandle( aViewCommandHandle ), iVccHoReady( ETrue ) |
|
60 { |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------- |
|
64 // CPhoneVccHandler::~CPhoneStateIdleVoIP() |
|
65 // Destructor |
|
66 // ----------------------------------------------------------- |
|
67 // |
|
68 CPhoneVccHandler::~CPhoneVccHandler() |
|
69 { |
|
70 delete iPropListener; |
|
71 TRAPD( err, CancelHandoverNoteTimerL() ); |
|
72 if ( err != KErrNone ) |
|
73 { |
|
74 __PHONELOG( EBasic, PhoneUIVoIPExtension, |
|
75 "CPhoneVccHandler::~CPhoneVccHandler, leave" ); |
|
76 } |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------- |
|
80 // CPhoneVccHandler::ConstructL() |
|
81 // Constructor |
|
82 // ----------------------------------------------------------- |
|
83 // |
|
84 void CPhoneVccHandler::ConstructL() |
|
85 { |
|
86 iPropListener = CVccUiPsPropertyListener::NewL( KVccPropKeyHoStatus ); |
|
87 iPropListener->AddObserverL( *this ); |
|
88 iPropListener->Start(); |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------- |
|
92 // CPhoneVccHandler::NewL() |
|
93 // Constructor |
|
94 // ----------------------------------------------------------- |
|
95 // |
|
96 CPhoneVccHandler* CPhoneVccHandler::NewL( |
|
97 MPhoneStateMachine& aStateMachine, |
|
98 MPhoneViewCommandHandle& aViewCommandHandle ) |
|
99 { |
|
100 CPhoneVccHandler* self = new (ELeave) CPhoneVccHandler( |
|
101 aStateMachine, |
|
102 aViewCommandHandle ); |
|
103 |
|
104 CleanupStack::PushL( self ); |
|
105 self->ConstructL(); |
|
106 CleanupStack::Pop( self ); |
|
107 |
|
108 return self; |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------- |
|
112 // CPhoneVccHandler::StartManualHandover |
|
113 // ----------------------------------------------------------- |
|
114 // |
|
115 void CPhoneVccHandler::StartManualHandoverL( TInt aCommand ) |
|
116 { |
|
117 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
118 "CPhoneVccHandler::StartManualHandoverL()" ) |
|
119 |
|
120 HandoverInProgressNoteL( aCommand ); |
|
121 |
|
122 CVccUiPsProperty* prop = CVccUiPsProperty::NewL(); |
|
123 CleanupStack::PushL( prop ); |
|
124 |
|
125 if ( aCommand == EPhoneVoIPWaitHandoverFromGsm ) |
|
126 { |
|
127 prop->NotifySubscriberL( EVccManualStartCsToPsHoRequest ); |
|
128 } |
|
129 else |
|
130 { |
|
131 prop->NotifySubscriberL( EVccManualStartPsToCsHoRequest ); |
|
132 } |
|
133 |
|
134 CleanupStack::PopAndDestroy(prop); |
|
135 iVccHoReady = EFalse; |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------- |
|
139 // CPhoneVccHandler::AddHandoverMenuItem |
|
140 // ----------------------------------------------------------- |
|
141 // |
|
142 void CPhoneVccHandler::AddHandoverMenuItemL( |
|
143 RArray<CTelMenuExtension::TCallInfo>& aArray, |
|
144 TInt /*aResourceId*/, |
|
145 CEikMenuPane& aMenuPane ) |
|
146 { |
|
147 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
148 "CPhoneVccHandler::AddHandoverMenuItemL()"); |
|
149 TInt activeCallId( KErrNotFound ); |
|
150 |
|
151 for( TInt i = 0; i < aArray.Count(); i++ ) |
|
152 { |
|
153 if( aArray[i].iCallState == CTelMenuExtension::EActive ) |
|
154 { |
|
155 activeCallId = aArray[i].iCallId; |
|
156 } |
|
157 } |
|
158 |
|
159 if ( activeCallId != KErrNotFound ) |
|
160 { |
|
161 // Vcc not available or Multicall not available |
|
162 if ( iVccUnavailable || aArray.Count() > 1 && iNoHoIfMultiCall ) |
|
163 { |
|
164 return; |
|
165 } |
|
166 |
|
167 TPECallType callType = |
|
168 iStateMachine.PhoneEngineInfo()->CallType( activeCallId ); |
|
169 |
|
170 CEikMenuPaneItem::SData data; |
|
171 data.iCascadeId=0; |
|
172 data.iFlags=0; |
|
173 HBufC* string = NULL; |
|
174 |
|
175 if ( callType == EPECallTypeVoIP && iVccHoAllowedToGsm ) |
|
176 { |
|
177 string = StringLoader::LoadLC( |
|
178 CPhoneMainResourceResolver::Instance()-> |
|
179 ResolveResourceID( EPhoneVoIPHandoverToGsmOption ) ); |
|
180 |
|
181 data.iCommandId = EPhoneCmdHandoverToGsm; |
|
182 |
|
183 } |
|
184 else if ( callType == EPECallTypeCSVoice && iVccHoAllowedToWlan ) |
|
185 { |
|
186 string = StringLoader::LoadLC( |
|
187 CPhoneMainResourceResolver::Instance()-> |
|
188 ResolveResourceID( EPhoneVoIPHandoverToWlanOption ) ); |
|
189 |
|
190 data.iCommandId = EPhoneCmdHandoverToWlan; |
|
191 } |
|
192 else |
|
193 { |
|
194 // Not add menu item |
|
195 return; |
|
196 } |
|
197 |
|
198 data.iText = *string; |
|
199 // Try to find index of EPhoneInCallCmdGoToIdle command |
|
200 // handover item will be placed above it if found |
|
201 |
|
202 TInt index( KErrNotFound ); |
|
203 |
|
204 if ( aMenuPane.MenuItemExists( EPhoneInCallCmdGoToIdle, index) ) |
|
205 { |
|
206 aMenuPane.InsertMenuItemL( data, index ); |
|
207 } |
|
208 else |
|
209 { |
|
210 aMenuPane.AddMenuItemL( data ); |
|
211 } |
|
212 |
|
213 CleanupStack::PopAndDestroy( string ); |
|
214 } |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------- |
|
218 // CPhoneVccHandler::StartHandoverNoteTimerL |
|
219 // --------------------------------------------------------- |
|
220 // |
|
221 void CPhoneVccHandler::StartHandoverNoteTimerL() |
|
222 { |
|
223 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
224 "CPhoneVccHandler::StartHandoverNoteTimerL()"); |
|
225 |
|
226 if( !iHandoverNoteTimer ) |
|
227 { |
|
228 iHandoverNoteTimer = CPhoneTimer::NewL(); |
|
229 } |
|
230 |
|
231 iHandoverNoteTimer->After( KPhoneShowNoteTime, |
|
232 TCallBack( HandoverNoteTimerCallbackL, this ) ); |
|
233 } |
|
234 |
|
235 // --------------------------------------------------------- |
|
236 // CPhoneVccHandler::CancelHandoverNoteTimerL |
|
237 // --------------------------------------------------------- |
|
238 // |
|
239 void CPhoneVccHandler::CancelHandoverNoteTimerL() |
|
240 { |
|
241 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
242 "CPhoneVccHandler::CancelHandoverNoteTimerL()"); |
|
243 if ( iHandoverNoteTimer ) |
|
244 { |
|
245 delete iHandoverNoteTimer; |
|
246 iHandoverNoteTimer = NULL; |
|
247 } |
|
248 RemoveHandoverNoteL(); |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------- |
|
252 // CPhoneVccHandler::HandoverNoteTimerCallbackL |
|
253 // --------------------------------------------------------- |
|
254 // |
|
255 TInt CPhoneVccHandler::HandoverNoteTimerCallbackL( TAny* aAny ) |
|
256 { |
|
257 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
258 "CPhoneVccHandler::HandoverNoteTimerCallbackL()"); |
|
259 |
|
260 reinterpret_cast<CPhoneVccHandler*>( aAny )-> |
|
261 CancelHandoverNoteTimerL(); |
|
262 |
|
263 return KErrNone; |
|
264 } |
|
265 |
|
266 // --------------------------------------------------------- |
|
267 // CPhoneVccHandler::RemoveHandoverNoteL |
|
268 // --------------------------------------------------------- |
|
269 // |
|
270 void CPhoneVccHandler::RemoveHandoverNoteL() |
|
271 { |
|
272 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
273 "CPhoneVccHandler::RemoveHandoverNoteL()"); |
|
274 |
|
275 if ( iVccHoReady && !iHandoverNoteTimer ) |
|
276 { |
|
277 iViewCommandHandle.ExecuteCommandL( EPhoneViewRemoveGlobalNote ); |
|
278 } |
|
279 } |
|
280 |
|
281 // ----------------------------------------------------------- |
|
282 // CPhoneVccHandler::HandoverInProgressNoteL |
|
283 // ----------------------------------------------------------- |
|
284 // |
|
285 void CPhoneVccHandler::HandoverInProgressNoteL( TInt aCommand ) |
|
286 { |
|
287 TPhoneCmdParamGlobalNote globalNoteParam; |
|
288 |
|
289 // Check notification tone user setting |
|
290 TInt tone = GetHoNotifToneModeL(); |
|
291 |
|
292 if ( tone == 1 ) |
|
293 { |
|
294 globalNoteParam.SetTone( EAvkonSIDConfirmationTone ); |
|
295 } |
|
296 else |
|
297 { |
|
298 globalNoteParam.SetTone( EAvkonSIDNoSound ); |
|
299 } |
|
300 |
|
301 globalNoteParam.SetType( EAknGlobalWaitNote ); |
|
302 globalNoteParam.SetSoftkeys( R_AVKON_SOFTKEYS_EMPTY ); |
|
303 globalNoteParam.SetTextResourceId( |
|
304 CPhoneMainResourceResolver::Instance()-> |
|
305 ResolveResourceID( aCommand ) ); |
|
306 |
|
307 iViewCommandHandle.ExecuteCommandL( |
|
308 EPhoneViewShowGlobalNote, &globalNoteParam ); |
|
309 |
|
310 StartHandoverNoteTimerL(); |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // CPhoneVccHandler::VccPropertyChangedL |
|
315 // Gets called when PS key is changed |
|
316 // ----------------------------------------------------------------------------- |
|
317 // |
|
318 void CPhoneVccHandler::VccPropertyChangedL( const TUint aKeyId, |
|
319 const TInt aValue ) |
|
320 { |
|
321 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
322 "CPhoneVccHandler::VccPropertyChangedL() "); |
|
323 |
|
324 __PHONELOG1( EBasic, EPhoneControl, |
|
325 "CPhoneVccHandler::VccPropertyChangedL - key: %d", aValue ); |
|
326 |
|
327 |
|
328 if( aKeyId == KVccPropKeyHoStatus ) |
|
329 { |
|
330 switch( aValue ) |
|
331 { |
|
332 case EVccCsToPsHoFailure: |
|
333 case EVccPsToCsHoFailure: |
|
334 { |
|
335 __PHONELOG( EBasic, PhoneUIVoIPExtension, |
|
336 "CPhoneVccHandler::VccPropertyChangedL VccPropertyChangedL -- HO fail" ); |
|
337 // Remove handover note if handover is in progress |
|
338 if( !iVccHoReady ) |
|
339 { |
|
340 iVccHoReady = ETrue; |
|
341 CPhoneState* phoneState = |
|
342 static_cast< CPhoneState* >( iStateMachine.State() ); |
|
343 CancelHandoverNoteTimerL(); |
|
344 phoneState->SendGlobalInfoNoteL( EPhoneVoIPHandoverFail ); |
|
345 } |
|
346 } |
|
347 break; |
|
348 case EVccCsToPsHoSuccessful: |
|
349 case EVccPsToCsHoSuccessful: |
|
350 { |
|
351 __PHONELOG( EBasic, PhoneUIVoIPExtension, |
|
352 "CPhoneVccHandler::VccPropertyChangedL VccPropertyChangedL -- HO Success" ); |
|
353 iVccHoReady = ETrue; |
|
354 RemoveHandoverNoteL(); |
|
355 } |
|
356 break; |
|
357 case EVccCsToPsHoStarted: |
|
358 { |
|
359 __PHONELOG( EBasic, PhoneUIVoIPExtension, |
|
360 "CPhoneVccHandler::VccPropertyChangedL VccPropertyChangedL -- CsToPsHoStarted" ); |
|
361 // Do not show if manually started since the wait note is |
|
362 // already visible |
|
363 if ( iVccHoReady ) |
|
364 { |
|
365 iVccHoReady = EFalse; |
|
366 HandoverInProgressNoteL( EPhoneVoIPWaitHandoverFromGsm ); |
|
367 } |
|
368 } |
|
369 break; |
|
370 case EVccPsToCsHoStarted: |
|
371 { |
|
372 __PHONELOG( EBasic, PhoneUIVoIPExtension, |
|
373 "CPhoneVccHandler::VccPropertyChangedL VccPropertyChangedL -- PsToCsHoStarted" ); |
|
374 // Do not show if manually started since the wait note is |
|
375 // already visible |
|
376 if ( iVccHoReady ) |
|
377 { |
|
378 iVccHoReady = EFalse; |
|
379 HandoverInProgressNoteL( EPhoneVoIPWaitHandoverFromWlan); |
|
380 } |
|
381 } |
|
382 break; |
|
383 case EVccPsToCsHoInprogress: |
|
384 case EVccCsToPsHoInprogress: |
|
385 __PHONELOG( EBasic, PhoneUIVoIPExtension, |
|
386 "CPhoneVccHandler::VccPropertyChangedL VccPropertyChangedL -- HoInprogress" ); |
|
387 // Do nothing |
|
388 break; |
|
389 case EVccHoUnavailable: |
|
390 { |
|
391 __PHONELOG( EBasic, PhoneUIVoIPExtension, |
|
392 "CPhoneVccHandler::VccPropertyChangedL VccPropertyChangedL -- HO Unavailable" ); |
|
393 iVccUnavailable = ETrue; |
|
394 break; |
|
395 } |
|
396 case EVccHoStateIdle: |
|
397 { |
|
398 __PHONELOG( EBasic, PhoneUIVoIPExtension, |
|
399 "CPhoneVccHandler::VccPropertyChangedL VccPropertyChangedL -- HO IDLE" ); |
|
400 iVccHoAllowedToGsm = ETrue; |
|
401 iVccHoAllowedToWlan = ETrue; |
|
402 iNoHoIfMultiCall = EFalse; |
|
403 iVccUnavailable = EFalse; |
|
404 break; |
|
405 } |
|
406 case EVccCsToPsNotAllowed: |
|
407 { |
|
408 __PHONELOG( EBasic, PhoneUIVoIPExtension, |
|
409 "CPhoneVccHandler::VccPropertyChangedL VccPropertyChangedL -- EVccCsToPsNotAllowed" ); |
|
410 iVccHoAllowedToWlan = EFalse; |
|
411 iVccHoAllowedToGsm = ETrue; |
|
412 iNoHoIfMultiCall = EFalse; |
|
413 iVccUnavailable = EFalse; |
|
414 break; |
|
415 } |
|
416 |
|
417 case EVccPsToCsNotAllowed: |
|
418 { |
|
419 __PHONELOG( EBasic, PhoneUIVoIPExtension, |
|
420 "CPhoneVccHandler::VccPropertyChangedL VccPropertyChangedL -- EVccPsToCsNotAllowed" ); |
|
421 iVccHoAllowedToGsm = EFalse; |
|
422 iVccHoAllowedToWlan = ETrue; |
|
423 iNoHoIfMultiCall = EFalse; |
|
424 iVccUnavailable = EFalse; |
|
425 break; |
|
426 } |
|
427 |
|
428 case EVccHoStateIdleIfSingleCall: |
|
429 { |
|
430 __PHONELOG( EBasic, PhoneUIVoIPExtension, |
|
431 "CPhoneVccHandler::VccPropertyChangedL VccPropertyChangedL -- EVccHoStateIdleIfSingleCall" ); |
|
432 iNoHoIfMultiCall = ETrue; |
|
433 iVccHoAllowedToGsm = ETrue; |
|
434 iVccHoAllowedToWlan = ETrue; |
|
435 iVccUnavailable = EFalse; |
|
436 break; |
|
437 } |
|
438 case EVccHoAllowedToCsIfSingleCall: |
|
439 { |
|
440 __PHONELOG( EBasic, PhoneUIVoIPExtension, |
|
441 "CPhoneVccHandler::VccPropertyChangedL VccPropertyChangedL -- EVccHoAllowedToCsIfSingleCall" ); |
|
442 iNoHoIfMultiCall = ETrue; |
|
443 iVccHoAllowedToWlan = EFalse; |
|
444 iVccHoAllowedToGsm = ETrue; |
|
445 iVccUnavailable = EFalse; |
|
446 break; |
|
447 } |
|
448 case EVccHoAllowedToPsIfSingleCall: |
|
449 { |
|
450 __PHONELOG( EBasic, PhoneUIVoIPExtension, |
|
451 "CPhoneVccHandler::VccPropertyChangedL VccPropertyChangedL -- EVccHoAllowedToPsIfSingleCall" ); |
|
452 iNoHoIfMultiCall = ETrue; |
|
453 iVccHoAllowedToGsm = EFalse; |
|
454 iVccHoAllowedToWlan = ETrue; |
|
455 iVccUnavailable = EFalse; |
|
456 break; |
|
457 } |
|
458 |
|
459 default: |
|
460 |
|
461 __PHONELOG( EBasic, PhoneUIVoIPExtension, |
|
462 "CPhoneVccHandler::VccPropertyChangedL VccPropertyChangedL -- default" ); |
|
463 break; |
|
464 } |
|
465 } |
|
466 } |
|
467 // --------------------------------------------------------------------------- |
|
468 // Gets HO notification tone setting value |
|
469 // --------------------------------------------------------------------------- |
|
470 // |
|
471 TInt CPhoneVccHandler::GetHoNotifToneModeL() |
|
472 { |
|
473 // Find out VCC service id |
|
474 CSPProperty* property = CSPProperty::NewLC(); |
|
475 |
|
476 CSPSettings* settings = CSPSettings::NewLC(); |
|
477 |
|
478 TInt vccServiceId = GetVccServiceIdL(); |
|
479 |
|
480 //get the VCC enabled VoIP service id. |
|
481 TInt err = settings->FindPropertyL( |
|
482 vccServiceId, ESubPropertyVccDtVoipServiceId, *property ); |
|
483 |
|
484 TInt voipId; |
|
485 TInt error = property->GetValue( voipId ); |
|
486 |
|
487 // Find and get the HO notification tone property |
|
488 TInt tone = 0; |
|
489 RBuf value; |
|
490 value.CreateL( 1 ); |
|
491 |
|
492 err = settings->FindPropertyL( |
|
493 voipId, ESubPropertyVccHoNotificationToneMode, *property ); |
|
494 |
|
495 if ( !err ) |
|
496 { |
|
497 HBufC* temp; |
|
498 property->GetValue( value ); |
|
499 temp = value.AllocL(); |
|
500 TLex temp2( *temp ); |
|
501 temp2.Val( tone ); |
|
502 delete temp; |
|
503 } |
|
504 value.Close(); |
|
505 |
|
506 // Set to default (0 = off) in case of invalid value |
|
507 if ( !( tone == 0 || tone == 1 )) |
|
508 { |
|
509 tone = 0; |
|
510 } |
|
511 |
|
512 CleanupStack::PopAndDestroy( settings ); |
|
513 CleanupStack::PopAndDestroy( property ); |
|
514 |
|
515 |
|
516 |
|
517 return tone; |
|
518 } |
|
519 |
|
520 // --------------------------------------------------------------------------- |
|
521 // For finding out VCC service id. |
|
522 // --------------------------------------------------------------------------- |
|
523 // |
|
524 TInt CPhoneVccHandler::GetVccServiceIdL() |
|
525 { |
|
526 TInt vccServiceId( KErrNotFound ); |
|
527 // Array of service provider IDs |
|
528 // is defined as: typedef RArray<TServiceId> RIdArray |
|
529 // in spdefinitions.h |
|
530 RIdArray serviceIdArray; |
|
531 CleanupClosePushL( serviceIdArray ); |
|
532 |
|
533 CSPSettings* settings = CSPSettings::NewLC(); |
|
534 settings->FindServiceIdsL( serviceIdArray ); |
|
535 |
|
536 TBool foundEntry( EFalse ); |
|
537 |
|
538 for ( TInt i( 0 ); i < serviceIdArray.Count() && !foundEntry; i++ ) |
|
539 { |
|
540 CSPProperty* property = CSPProperty::NewLC(); |
|
541 TInt error = settings->FindPropertyL( serviceIdArray[i], ESubPropertyVccVDI, *property ); |
|
542 |
|
543 if( error == KErrNone ) |
|
544 { |
|
545 vccServiceId = serviceIdArray[i]; |
|
546 foundEntry = ETrue; |
|
547 } |
|
548 CleanupStack::PopAndDestroy( property ); |
|
549 } |
|
550 CleanupStack::PopAndDestroy( settings ); |
|
551 CleanupStack::PopAndDestroy( &serviceIdArray ); |
|
552 |
|
553 return vccServiceId; |
|
554 } |
|
555 // End of File |