37
|
1 |
/*
|
|
2 |
* Copyright (c) 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: Utility class for Voip-states.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <cphcltemergencycall.h>
|
|
19 |
#include <mpeengineinfo.h>
|
|
20 |
#include "cphonestateutilsvoip.h"
|
|
21 |
#include "cphonelogger.h"
|
|
22 |
#include "phoneconstants.h"
|
|
23 |
#include "mphonestatemachine.h"
|
|
24 |
#include "mphoneviewcommandhandle.h"
|
|
25 |
#include "phoneui.pan"
|
|
26 |
#include "tphonecmdparamstring.h"
|
|
27 |
#include "cphonekeys.h"
|
|
28 |
#include "tphonecmdparamselector.h"
|
|
29 |
#include "phonestatedefinitionsvoip.h"
|
|
30 |
|
|
31 |
const TInt KServiceId1 = 1;
|
|
32 |
|
|
33 |
// ======== MEMBER FUNCTIONS ========
|
|
34 |
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
// CPhoneStateUtilsVoip::CPhoneStateUtilsVoip
|
|
37 |
// C++ constructor.
|
|
38 |
// ---------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
CPhoneStateUtilsVoip::CPhoneStateUtilsVoip( MPhoneStateMachine& aStateMachine,
|
|
41 |
MPhoneViewCommandHandle& aViewCommandHandle )
|
|
42 |
:
|
|
43 |
iStateMachine( aStateMachine ),
|
|
44 |
iViewCommandHandle( aViewCommandHandle )
|
|
45 |
{
|
|
46 |
|
|
47 |
}
|
|
48 |
|
|
49 |
|
|
50 |
// ---------------------------------------------------------------------------
|
|
51 |
// CPhoneStateUtilsVoip::ConstructL
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
void CPhoneStateUtilsVoip::ConstructL()
|
|
55 |
{
|
|
56 |
iBuffer = HBufC::NewL( KPhoneNumberEntryBufferSize );
|
|
57 |
iEmergencyCall = CPhCltEmergencyCall::NewL( NULL );
|
|
58 |
}
|
|
59 |
|
|
60 |
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
// CPhoneStateUtilsVoip::NewL
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
//
|
|
65 |
CPhoneStateUtilsVoip* CPhoneStateUtilsVoip::NewL(
|
|
66 |
MPhoneStateMachine& aStateMachine,
|
|
67 |
MPhoneViewCommandHandle& aViewCommandHandle )
|
|
68 |
{
|
|
69 |
CPhoneStateUtilsVoip* self = CPhoneStateUtilsVoip::NewLC(
|
|
70 |
aStateMachine, aViewCommandHandle );
|
|
71 |
CleanupStack::Pop( self );
|
|
72 |
return self;
|
|
73 |
}
|
|
74 |
|
|
75 |
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
// CPhoneStateUtilsVoip::NewLC
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
CPhoneStateUtilsVoip* CPhoneStateUtilsVoip::NewLC(
|
|
81 |
MPhoneStateMachine& aStateMachine,
|
|
82 |
MPhoneViewCommandHandle& aViewCommandHandle )
|
|
83 |
{
|
|
84 |
CPhoneStateUtilsVoip* self = new( ELeave ) CPhoneStateUtilsVoip(
|
|
85 |
aStateMachine, aViewCommandHandle );
|
|
86 |
CleanupStack::PushL( self );
|
|
87 |
self->ConstructL();
|
|
88 |
return self;
|
|
89 |
}
|
|
90 |
|
|
91 |
|
|
92 |
// ---------------------------------------------------------------------------
|
|
93 |
// CPhoneStateUtilsVoip::~CPhoneStateUtilsVoip
|
|
94 |
// Destructor.
|
|
95 |
// ---------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
CPhoneStateUtilsVoip::~CPhoneStateUtilsVoip()
|
|
98 |
{
|
|
99 |
delete iBuffer;
|
|
100 |
delete iEmergencyCall;
|
|
101 |
}
|
|
102 |
|
|
103 |
|
|
104 |
// ---------------------------------------------------------------------------
|
|
105 |
// CPhoneStateUtilsVoip::DialVoIPL
|
|
106 |
// ---------------------------------------------------------------------------
|
|
107 |
//
|
|
108 |
void CPhoneStateUtilsVoip::DialVoIPL( const TDesC& aNumber, TUint aServiceId )
|
|
109 |
{
|
|
110 |
__LOGMETHODSTARTEND( PhoneUIVoIPExtension,
|
|
111 |
"CPhoneStateUtilsVoip::DialVoIPL" );
|
|
112 |
|
|
113 |
__ASSERT_DEBUG(
|
|
114 |
iStateMachine.PhoneEngineInfo(), Panic( EPhoneCtrlInvariant ) );
|
|
115 |
|
|
116 |
if ( 0 == aNumber.Compare( KNullDesC ) )
|
|
117 |
{
|
|
118 |
// Get the number entry contents
|
|
119 |
HBufC *phoneNumber = HBufC::NewLC( KPhoneNumberEntryBufferSize );
|
|
120 |
TPtr ptr( phoneNumber->Des() );
|
|
121 |
TPhoneCmdParamString stringParam;
|
|
122 |
stringParam.SetString( &ptr );
|
|
123 |
iViewCommandHandle.ExecuteCommand(
|
|
124 |
EPhoneViewGetNumberFromEntry,
|
|
125 |
&stringParam );
|
|
126 |
|
|
127 |
// Set the phone number
|
|
128 |
iStateMachine.PhoneEngineInfo()->SetPhoneNumber( ptr );
|
|
129 |
|
|
130 |
CleanupStack::PopAndDestroy( phoneNumber );
|
|
131 |
}
|
|
132 |
else
|
|
133 |
{
|
|
134 |
iStateMachine.PhoneEngineInfo()->SetPhoneNumber( aNumber );
|
|
135 |
}
|
|
136 |
|
|
137 |
// Make a call
|
|
138 |
iStateMachine.PhoneEngineInfo()->SetServiceIdCommand( aServiceId );
|
|
139 |
iStateMachine.PhoneEngineInfo()->SetCallTypeCommand( EPECallTypeVoIP );
|
|
140 |
iStateMachine.SendPhoneEngineMessage( MPEPhoneModel::EPEMessageDial );
|
|
141 |
}
|
|
142 |
|
|
143 |
|
|
144 |
// ---------------------------------------------------------------------------
|
|
145 |
// CPhoneStateUtilsVoip::IsVoipPreferredCall
|
|
146 |
// ---------------------------------------------------------------------------
|
|
147 |
//
|
|
148 |
TBool CPhoneStateUtilsVoip::IsVoipPreferredCall( TUint& aServiceId )
|
|
149 |
{
|
|
150 |
__LOGMETHODSTARTEND( PhoneUIVoIPExtension,
|
|
151 |
"CPhoneStateUtilsVoip::IsVoipPreferredCall" );
|
|
152 |
|
|
153 |
TBool isVoipPrefered( EFalse );
|
|
154 |
|
|
155 |
return isVoipPrefered;
|
|
156 |
}
|
|
157 |
|
|
158 |
|
|
159 |
// ---------------------------------------------------------------------------
|
|
160 |
// CPhoneStateUtilsVoip::IsVoipNumberL
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
//
|
|
163 |
TBool CPhoneStateUtilsVoip::IsVoipNumber()
|
|
164 |
{
|
|
165 |
__LOGMETHODSTARTEND( PhoneUIVoIPExtension,
|
|
166 |
"CPhoneStateUtilsVoip::IsVoipNumberL" );
|
|
167 |
|
|
168 |
TBool isVoipNumber = EFalse;
|
|
169 |
|
|
170 |
TPtr ptr( iBuffer->Des() );
|
|
171 |
TPhoneCmdParamString stringParam;
|
|
172 |
stringParam.SetString( &ptr );
|
|
173 |
iViewCommandHandle.ExecuteCommand(
|
|
174 |
EPhoneViewGetNumberFromEntry, &stringParam );
|
|
175 |
|
|
176 |
isVoipNumber = !CPhoneKeys::Validate( ptr );
|
|
177 |
|
|
178 |
return isVoipNumber;
|
|
179 |
}
|
|
180 |
|
|
181 |
|
|
182 |
// ---------------------------------------------------------------------------
|
|
183 |
// CPhoneStateUtilsVoip::SelectServiceAndDialL
|
|
184 |
// ---------------------------------------------------------------------------
|
|
185 |
//
|
|
186 |
void CPhoneStateUtilsVoip::SelectServiceAndDialL(
|
|
187 |
const TDesC& aNumber,
|
|
188 |
TUint aServiceId )
|
|
189 |
{
|
|
190 |
__LOGMETHODSTARTEND( PhoneUIVoIPExtension,
|
|
191 |
"CPhoneStateIdleVoIP::SelectServiceAndDialL" );
|
|
192 |
|
|
193 |
TPhoneCmdParamSelector params;
|
|
194 |
|
|
195 |
// Get the number entry contents
|
|
196 |
TPtr ptr( iBuffer->Des() );
|
|
197 |
TPhoneCmdParamString stringParam;
|
|
198 |
stringParam.SetString( &ptr );
|
|
199 |
iViewCommandHandle.ExecuteCommand(
|
|
200 |
EPhoneViewGetNumberFromEntry,
|
|
201 |
&stringParam );
|
|
202 |
|
|
203 |
// Check the string
|
|
204 |
TBool emergencyNumber = ( 0 == aNumber.Compare( KNullDesC ) ?
|
|
205 |
IsEmergencyNumber( ptr ) :
|
|
206 |
IsEmergencyNumber( aNumber ) );
|
|
207 |
|
|
208 |
if ( emergencyNumber )
|
|
209 |
{
|
|
210 |
if ( 0 == aNumber.Compare( KNullDesC ) )
|
|
211 |
{
|
|
212 |
// Set the phone number from number entry
|
|
213 |
iStateMachine.PhoneEngineInfo()->SetPhoneNumber( ptr );
|
|
214 |
}
|
|
215 |
else
|
|
216 |
{
|
|
217 |
iStateMachine.PhoneEngineInfo()->SetPhoneNumber( aNumber );
|
|
218 |
}
|
|
219 |
|
|
220 |
// Make a emergency call
|
|
221 |
iStateMachine.PhoneEngineInfo()->SetServiceIdCommand( KServiceId1 );
|
|
222 |
iStateMachine.PhoneEngineInfo()->SetCallTypeCommand(
|
|
223 |
EPECallTypeCSVoice );
|
|
224 |
iStateMachine.SendPhoneEngineMessage( MPEPhoneModel::EPEMessageDial );
|
|
225 |
}
|
|
226 |
else if ( 0 != aServiceId )
|
|
227 |
{
|
|
228 |
// Service id is known
|
|
229 |
DialVoIPL( aNumber, aServiceId );
|
|
230 |
}
|
|
231 |
else if ( EPhoneViewResponseSuccess == iViewCommandHandle.HandleCommandL(
|
|
232 |
EPhoneViewServiceSelection, ¶ms ) )
|
|
233 |
{
|
|
234 |
DialVoIPL( aNumber, params.ServiceId() );
|
|
235 |
}
|
|
236 |
}
|
|
237 |
|
|
238 |
|
|
239 |
// ---------------------------------------------------------------------------
|
|
240 |
// CPhoneStateUtilsVoip::IsEmergencyNumber
|
|
241 |
// ---------------------------------------------------------------------------
|
|
242 |
//
|
|
243 |
TBool CPhoneStateUtilsVoip::IsEmergencyNumber( const TDesC& aNumber ) const
|
|
244 |
{
|
|
245 |
__LOGMETHODSTARTEND( PhoneUIVoIPExtension,
|
|
246 |
"CPhoneStateUtilsVoip::IsEmergencyNumber" );
|
|
247 |
|
|
248 |
TBool emergencyNumber( EFalse );
|
|
249 |
TInt error = iEmergencyCall->IsEmergencyPhoneNumber( aNumber, emergencyNumber );
|
|
250 |
|
|
251 |
return ( KErrNone == error && emergencyNumber );
|
|
252 |
}
|