60
|
1 |
/*
|
|
2 |
*
|
|
3 |
* Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
|
|
4 |
* All rights reserved.
|
|
5 |
* This component and the accompanying materials are made available
|
|
6 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
7 |
* which accompanies this distribution, and is available
|
|
8 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
9 |
*
|
|
10 |
* Original Contributors:
|
|
11 |
* Comarch S.A. - original contribution.
|
|
12 |
*
|
|
13 |
* Contributors:
|
|
14 |
*
|
|
15 |
* Description:
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
#include "hfpfeaturemanager.h"
|
|
20 |
#include "hfpcalltermination.h"
|
|
21 |
#include "hfpconnectionmanagement.h"
|
|
22 |
#include "hfpincomingcallacceptance.h"
|
|
23 |
#include "hfpincomingcallrejection.h"
|
|
24 |
#include "hfpphonestatusinformation.h"
|
|
25 |
#include "hfpremoteaudiovolumecontrol.h"
|
|
26 |
#include "hfplastnumberredialing.h"
|
|
27 |
#include "hfpphonenumberdialing.h"
|
|
28 |
#include "hfpcallinglineidentification.h"
|
|
29 |
#include "hfpcommand.h"
|
|
30 |
#include "debug.h"
|
|
31 |
|
|
32 |
CHsHFPFeatureManager* CHsHFPFeatureManager::NewL()
|
|
33 |
{
|
|
34 |
CHsHFPFeatureManager *self = CHsHFPFeatureManager::NewLC();
|
|
35 |
CleanupStack::Pop( self );
|
|
36 |
|
|
37 |
return self;
|
|
38 |
}
|
|
39 |
|
|
40 |
CHsHFPFeatureManager* CHsHFPFeatureManager::NewLC()
|
|
41 |
{
|
|
42 |
|
|
43 |
CHsHFPFeatureManager *self = new ( ELeave ) CHsHFPFeatureManager();
|
|
44 |
CleanupStack::PushL( self );
|
|
45 |
self->ConstructL();
|
|
46 |
return self;
|
|
47 |
}
|
|
48 |
|
|
49 |
CHsHFPFeatureManager::~CHsHFPFeatureManager()
|
|
50 |
{
|
|
51 |
TRACE_FUNC_ENTRY
|
|
52 |
if ( iConnectionManagement )
|
|
53 |
{
|
|
54 |
delete iConnectionManagement;
|
|
55 |
}
|
|
56 |
if ( iCallTermProc )
|
|
57 |
{
|
|
58 |
delete iCallTermProc;
|
|
59 |
}
|
|
60 |
if ( iCallAcceptProc )
|
|
61 |
{
|
|
62 |
delete iCallAcceptProc;
|
|
63 |
}
|
|
64 |
if ( iCallRejectProc )
|
|
65 |
{
|
|
66 |
delete iCallRejectProc;
|
|
67 |
}
|
|
68 |
if ( iPhoneStatus )
|
|
69 |
{
|
|
70 |
delete iPhoneStatus;
|
|
71 |
}
|
|
72 |
if ( iVolumeControl )
|
|
73 |
{
|
|
74 |
delete iVolumeControl;
|
|
75 |
}
|
|
76 |
if ( iLastNumberRedialing )
|
|
77 |
{
|
|
78 |
delete iLastNumberRedialing;
|
|
79 |
}
|
|
80 |
if ( iPhoneNumberDialing )
|
|
81 |
{
|
|
82 |
delete iPhoneNumberDialing;
|
|
83 |
}
|
|
84 |
if ( iCallingLineIdentification )
|
|
85 |
{
|
|
86 |
delete iCallingLineIdentification;
|
|
87 |
}
|
|
88 |
TRACE_FUNC_EXIT
|
|
89 |
|
|
90 |
}
|
|
91 |
|
|
92 |
void CHsHFPFeatureManager::PerformDataProcessingL(
|
|
93 |
const CHsHFPCommand* aATCommandIn, CHsHFPCommand& aATCommandOut )
|
|
94 |
{
|
|
95 |
TRACE_FUNC_ENTRY
|
|
96 |
if ( iSrvLvlConnEstablished )
|
|
97 |
{
|
|
98 |
//decide which procedure should be used
|
|
99 |
switch ( aATCommandIn->Type() )
|
|
100 |
{
|
|
101 |
case EHFPCmdCHUP:
|
|
102 |
{
|
|
103 |
if ( iPhoneStatus->IsCallOngoing() )
|
|
104 |
{
|
|
105 |
//start releasing connection
|
|
106 |
User::LeaveIfNull( iCallTermProc );
|
|
107 |
User::LeaveIfError( iCallTermProc->ProcessCommand(
|
|
108 |
*aATCommandIn, aATCommandOut ) );
|
|
109 |
iProcedureStarted = EHFPCallTerminate;
|
|
110 |
}
|
|
111 |
else
|
|
112 |
{
|
|
113 |
//start call rejection
|
|
114 |
User::LeaveIfNull( iCallRejectProc );
|
|
115 |
User::LeaveIfError( iCallRejectProc->ProcessCommand(
|
|
116 |
*aATCommandIn, aATCommandOut ) );
|
|
117 |
iProcedureStarted = EHFPCallReject;
|
|
118 |
}
|
|
119 |
}
|
|
120 |
break;
|
|
121 |
|
|
122 |
case EHFPCmdOK:
|
|
123 |
{
|
|
124 |
HandleOKCommandL( aATCommandIn, aATCommandOut );
|
|
125 |
}
|
|
126 |
break;
|
|
127 |
case EHFPCmdERROR:
|
|
128 |
{
|
|
129 |
if ( iProcedureStarted == EHFPLastNumberRedialing )
|
|
130 |
{
|
|
131 |
User::LeaveIfNull( iLastNumberRedialing );
|
|
132 |
User::LeaveIfError( iLastNumberRedialing->ProcessCommand(
|
|
133 |
*aATCommandIn, aATCommandOut ) );
|
|
134 |
}
|
|
135 |
else if ( iProcedureStarted == EHFPPhoneNumberDialing )
|
|
136 |
{
|
|
137 |
User::LeaveIfNull( iPhoneNumberDialing );
|
|
138 |
User::LeaveIfError( iPhoneNumberDialing->ProcessCommand(
|
|
139 |
*aATCommandIn, aATCommandOut ) );
|
|
140 |
}
|
|
141 |
else
|
|
142 |
{
|
|
143 |
User::Leave( KErrArgument );
|
|
144 |
}
|
|
145 |
}
|
|
146 |
break;
|
|
147 |
case EHFPCmdCIEV:
|
|
148 |
{
|
|
149 |
HandleCIEVCommandL( aATCommandIn, aATCommandOut );
|
|
150 |
}
|
|
151 |
break;
|
|
152 |
case EHFPCmdRING:
|
|
153 |
{
|
|
154 |
User::LeaveIfNull( iCallAcceptProc );
|
|
155 |
User::LeaveIfError( iCallAcceptProc->ProcessCommand(
|
|
156 |
*aATCommandIn, aATCommandOut ) );
|
|
157 |
iProcedureStarted = EHFPCallAccept;
|
|
158 |
}
|
|
159 |
break;
|
|
160 |
case EHFPCmdATA:
|
|
161 |
{
|
|
162 |
if ( iProcedureStarted == EHFPCallAccept )
|
|
163 |
{
|
|
164 |
User::LeaveIfNull( iCallAcceptProc );
|
|
165 |
User::LeaveIfError( iCallAcceptProc->ProcessCommand(
|
|
166 |
*aATCommandIn, aATCommandOut ) );
|
|
167 |
}
|
|
168 |
else
|
|
169 |
{
|
|
170 |
User::Leave( KErrArgument );
|
|
171 |
}
|
|
172 |
}
|
|
173 |
break;
|
|
174 |
case EHFPCmdCOPS:
|
|
175 |
{
|
|
176 |
iProcedureStarted = EHFPOperatorSelection;
|
|
177 |
User::LeaveIfNull( iPhoneStatus );
|
|
178 |
User::LeaveIfError( iPhoneStatus->ProcessCommand(
|
|
179 |
*aATCommandIn, aATCommandOut ) );
|
|
180 |
}
|
|
181 |
break;
|
|
182 |
case EHFPCmdVGS: // fall-through intended here
|
|
183 |
case EHFPCmdVGM:
|
|
184 |
{
|
|
185 |
iProcedureStarted = EHFPVolumeControl;
|
|
186 |
User::LeaveIfNull( iVolumeControl );
|
|
187 |
User::LeaveIfError( iVolumeControl->ProcessCommand(
|
|
188 |
*aATCommandIn, aATCommandOut ) );
|
|
189 |
}
|
|
190 |
break;
|
|
191 |
case EHFPCmdBLDN:
|
|
192 |
{
|
|
193 |
iProcedureStarted = EHFPLastNumberRedialing;
|
|
194 |
User::LeaveIfNull( iLastNumberRedialing );
|
|
195 |
User::LeaveIfError( iLastNumberRedialing->ProcessCommand(
|
|
196 |
*aATCommandIn, aATCommandOut ) );
|
|
197 |
}
|
|
198 |
break;
|
|
199 |
case EHFPCmdATD:
|
|
200 |
{
|
|
201 |
iProcedureStarted = EHFPPhoneNumberDialing;
|
|
202 |
User::LeaveIfNull( iPhoneNumberDialing );
|
|
203 |
User::LeaveIfError( iPhoneNumberDialing->ProcessCommand(
|
|
204 |
*aATCommandIn, aATCommandOut ) );
|
|
205 |
}
|
|
206 |
break;
|
|
207 |
case EHFPCmdCLIP:
|
|
208 |
{
|
|
209 |
iProcedureStarted = EHFPCallingLineIdentification;
|
|
210 |
User::LeaveIfNull( iCallingLineIdentification );
|
|
211 |
User::LeaveIfError( iCallingLineIdentification->ProcessCommand(
|
|
212 |
*aATCommandIn, aATCommandOut ) );
|
|
213 |
}
|
|
214 |
break;
|
|
215 |
default:
|
|
216 |
User::Leave( KErrArgument );
|
|
217 |
}
|
|
218 |
}
|
|
219 |
else
|
|
220 |
{
|
|
221 |
//start ServiceLevelConnectionProcedure
|
|
222 |
User::LeaveIfNull( iConnectionManagement );
|
|
223 |
iProcedureStarted = EHFPServiceLevelConnectionEstablishment;
|
|
224 |
User::LeaveIfError(
|
|
225 |
iConnectionManagement->EstablishServiceLevelConnection(
|
|
226 |
*aATCommandIn, aATCommandOut ) );
|
|
227 |
}
|
|
228 |
|
|
229 |
TRACE_FUNC_EXIT
|
|
230 |
}
|
|
231 |
|
|
232 |
void CHsHFPFeatureManager::HandleClientDisconnected( TInt aErr )
|
|
233 |
{
|
|
234 |
TRACE_FUNC_ENTRY
|
|
235 |
iProcedureStarted = EHFPServiceLevelConnectionRelease;
|
|
236 |
iConnectionManagement->HandleServiceLevelConnectionRelease( aErr );
|
|
237 |
iVolumeControl->Reset();
|
|
238 |
TRACE_FUNC_EXIT
|
|
239 |
}
|
|
240 |
|
|
241 |
void CHsHFPFeatureManager::HandleClientConnectedL( TDes8& aCommandOut )
|
|
242 |
{
|
|
243 |
TRACE_FUNC_ENTRY
|
|
244 |
CHsHFPCommand* cmdIn = CHsHFPCommand::NewL();
|
|
245 |
CleanupStack::PushL( cmdIn );
|
|
246 |
CHsHFPCommand* cmdOut = CHsHFPCommand::NewL();
|
|
247 |
CleanupStack::Pop( cmdIn );
|
|
248 |
iProcedureStarted = EHFPServiceLevelConnectionEstablishment;
|
|
249 |
iConnectionManagement->EstablishServiceLevelConnection( *cmdIn, *cmdOut );
|
|
250 |
cmdOut->ToDes8( aCommandOut );
|
|
251 |
|
|
252 |
delete cmdIn;
|
|
253 |
delete cmdOut;
|
|
254 |
|
|
255 |
TRACE_FUNC_EXIT
|
|
256 |
}
|
|
257 |
|
|
258 |
void CHsHFPFeatureManager::HandleProcedureCompleted( TInt aErr )
|
|
259 |
{
|
|
260 |
TRACE_FUNC_ENTRY
|
|
261 |
switch ( iProcedureStarted )
|
|
262 |
{
|
|
263 |
case EHFPServiceLevelConnectionEstablishment:
|
|
264 |
if ( aErr == KErrNone )
|
|
265 |
{
|
|
266 |
TRACE_INFO(_L8("Connection established"))
|
|
267 |
iSrvLvlConnEstablished = ETrue;
|
|
268 |
iProcedureStarted = EHFPVolumeControl;
|
|
269 |
}
|
|
270 |
break;
|
|
271 |
case EHFPServiceLevelConnectionRelease:
|
|
272 |
if ( aErr == KErrNone )
|
|
273 |
{
|
|
274 |
TRACE_INFO(_L8("Connection released"))
|
|
275 |
iSrvLvlConnEstablished = EFalse;
|
|
276 |
iProcedureStarted = EHFPIdle;
|
|
277 |
}
|
|
278 |
break;
|
|
279 |
case EHFPCallTerminate:
|
|
280 |
iProcedureStarted = EHFPIdle;
|
|
281 |
TRACE_INFO(_L8("Call terminated"))
|
|
282 |
break;
|
|
283 |
case EHFPCallAccept:
|
|
284 |
TRACE_INFO(_L("Call answered"))
|
|
285 |
iProcedureStarted = EHFPIdle;
|
|
286 |
break;
|
|
287 |
case EHFPCallReject:
|
|
288 |
TRACE_INFO(_L("Call rejected"))
|
|
289 |
iProcedureStarted = EHFPIdle;
|
|
290 |
break;
|
|
291 |
case EHFPOperatorSelection:
|
|
292 |
TRACE_INFO(_L("Operator selection"))
|
|
293 |
iProcedureStarted = EHFPIdle;
|
|
294 |
break;
|
|
295 |
case EHFPVolumeControl:
|
|
296 |
TRACE_INFO(_L("Volume control"))
|
|
297 |
break;
|
|
298 |
case EHFPLastNumberRedialing:
|
|
299 |
TRACE_INFO(_L("Last number re-dial"))
|
|
300 |
iProcedureStarted = EHFPIdle;
|
|
301 |
break;
|
|
302 |
case EHFPPhoneNumberDialing:
|
|
303 |
TRACE_INFO(_L("Phone number dialing"))
|
|
304 |
iProcedureStarted = EHFPIdle;
|
|
305 |
break;
|
|
306 |
case EHFPCallingLineIdentification:
|
|
307 |
TRACE_INFO(_L("Calling line identification"))
|
|
308 |
iProcedureStarted = EHFPCallAccept;
|
|
309 |
break;
|
|
310 |
default:
|
|
311 |
iProcedureStarted = EHFPIdle;
|
|
312 |
}
|
|
313 |
TRACE_FUNC_EXIT
|
|
314 |
}
|
|
315 |
|
|
316 |
CHsHFPFeatureManager::CHsHFPFeatureManager()
|
|
317 |
{
|
|
318 |
|
|
319 |
}
|
|
320 |
|
|
321 |
void CHsHFPFeatureManager::ConstructL()
|
|
322 |
{
|
|
323 |
TRACE_FUNC_ENTRY
|
|
324 |
iConnectionManagement = CHsHFPConnectionManagement::NewL( this );
|
|
325 |
iCallTermProc = CHsHFPCallTerminationProc::NewL( this );
|
|
326 |
iCallAcceptProc = CHsHFPIncomingCallAcceptance::NewL( this );
|
|
327 |
iCallRejectProc = CHsHFPIncomingCallRejection::NewL( this );
|
|
328 |
iPhoneStatus = CHsHFPPhoneStatusInformation::NewL( this );
|
|
329 |
iVolumeControl = CHsHFPRemoteAudioVolumeControl::NewL( this );
|
|
330 |
iLastNumberRedialing = CHsHFPLastNumberRedialing::NewL( this );
|
|
331 |
iPhoneNumberDialing = CHsHFPPhoneNumberDialing::NewL( this );
|
|
332 |
iCallingLineIdentification = CHsHFPCallingLineIdentification::NewL( this );
|
|
333 |
TRACE_FUNC_EXIT
|
|
334 |
}
|
|
335 |
|
|
336 |
void CHsHFPFeatureManager::HandleOKCommandL( const CHsHFPCommand* aATCommandIn,
|
|
337 |
CHsHFPCommand& aATCommandOut )
|
|
338 |
{
|
|
339 |
TRACE_FUNC_ENTRY
|
|
340 |
if ( iProcedureStarted == EHFPCallTerminate )
|
|
341 |
{
|
|
342 |
User::LeaveIfNull( iCallTermProc );
|
|
343 |
User::LeaveIfError( iCallTermProc->ProcessCommand( *aATCommandIn,
|
|
344 |
aATCommandOut ) );
|
|
345 |
}
|
|
346 |
else if ( iProcedureStarted == EHFPCallAccept )
|
|
347 |
{
|
|
348 |
TRACE_INFO(_L("iProcedureStarted == EHFPCallAccept"))
|
|
349 |
User::LeaveIfNull( iCallAcceptProc );
|
|
350 |
User::LeaveIfError( iCallAcceptProc->ProcessCommand( *aATCommandIn,
|
|
351 |
aATCommandOut ) );
|
|
352 |
}
|
|
353 |
else if ( iProcedureStarted == EHFPCallReject )
|
|
354 |
{
|
|
355 |
TRACE_INFO(_L("iProcedureStarted == EHFPCallReject"))
|
|
356 |
User::LeaveIfNull( iCallRejectProc );
|
|
357 |
User::LeaveIfError( iCallRejectProc->ProcessCommand( *aATCommandIn,
|
|
358 |
aATCommandOut ) );
|
|
359 |
}
|
|
360 |
else if ( iProcedureStarted == EHFPOperatorSelection )
|
|
361 |
{
|
|
362 |
TRACE_INFO(_L("iProcedureStarted == EHFPOperatorSelection"))
|
|
363 |
User::LeaveIfNull( iPhoneStatus );
|
|
364 |
User::LeaveIfError( iPhoneStatus->ProcessCommand( *aATCommandIn,
|
|
365 |
aATCommandOut ) );
|
|
366 |
}
|
|
367 |
else if ( iProcedureStarted == EHFPVolumeControl )
|
|
368 |
{
|
|
369 |
TRACE_INFO(_L("iProcedureStarted == EHFPVolumeControl"))
|
|
370 |
User::LeaveIfNull( iVolumeControl );
|
|
371 |
User::LeaveIfError( iVolumeControl->ProcessCommand( *aATCommandIn,
|
|
372 |
aATCommandOut ) );
|
|
373 |
}
|
|
374 |
else if ( iProcedureStarted == EHFPLastNumberRedialing )
|
|
375 |
{
|
|
376 |
TRACE_INFO(_L("iProcedureStarted == EHFPLastNumberRedialing"))
|
|
377 |
User::LeaveIfNull( iLastNumberRedialing );
|
|
378 |
User::LeaveIfError( iLastNumberRedialing->ProcessCommand(
|
|
379 |
*aATCommandIn, aATCommandOut ) );
|
|
380 |
}
|
|
381 |
else if ( iProcedureStarted == EHFPPhoneNumberDialing )
|
|
382 |
{
|
|
383 |
TRACE_INFO(_L("iProcedureStarted == EHFPPhoneNumberDialing"))
|
|
384 |
User::LeaveIfNull( iPhoneNumberDialing );
|
|
385 |
User::LeaveIfError( iPhoneNumberDialing->ProcessCommand( *aATCommandIn,
|
|
386 |
aATCommandOut ) );
|
|
387 |
}
|
|
388 |
else if ( iProcedureStarted == EHFPCallingLineIdentification )
|
|
389 |
{
|
|
390 |
TRACE_INFO(_L("iProcedureStarted == EHFPCallingLineIdentification"))
|
|
391 |
User::LeaveIfNull( iCallingLineIdentification );
|
|
392 |
User::LeaveIfError( iCallingLineIdentification->ProcessCommand(
|
|
393 |
*aATCommandIn, aATCommandOut ) );
|
|
394 |
}
|
|
395 |
else
|
|
396 |
{
|
|
397 |
User::Leave( KErrArgument );
|
|
398 |
}
|
|
399 |
TRACE_FUNC_EXIT
|
|
400 |
}
|
|
401 |
|
|
402 |
void CHsHFPFeatureManager::HandleCIEVCommandL(
|
|
403 |
const CHsHFPCommand* aATCommandIn, CHsHFPCommand& aATCommandOut )
|
|
404 |
{
|
|
405 |
TRACE_FUNC_ENTRY
|
|
406 |
|
|
407 |
// refresh settings
|
|
408 |
iPhoneStatus->ProcessCommand( *aATCommandIn, aATCommandOut );
|
|
409 |
|
|
410 |
if ( iProcedureStarted == EHFPCallTerminate )
|
|
411 |
{
|
|
412 |
TRACE_INFO(_L8("CIEV : CALL TERMINATE"))
|
|
413 |
User::LeaveIfNull( iCallTermProc );
|
|
414 |
User::LeaveIfError( iCallTermProc->ProcessCommand( *aATCommandIn,
|
|
415 |
aATCommandOut ) );
|
|
416 |
}
|
|
417 |
else if ( iProcedureStarted == EHFPCallReject )
|
|
418 |
{
|
|
419 |
TRACE_INFO(_L("CIEV : CALL REJECT"))
|
|
420 |
User::LeaveIfNull( iCallRejectProc );
|
|
421 |
User::LeaveIfError( iCallRejectProc->ProcessCommand( *aATCommandIn,
|
|
422 |
aATCommandOut ) );
|
|
423 |
}
|
|
424 |
else if ( iProcedureStarted == EHFPCallAccept )
|
|
425 |
{
|
|
426 |
TRACE_INFO(_L("CIEV : CALL ACCEPT"))
|
|
427 |
User::LeaveIfNull( iCallAcceptProc );
|
|
428 |
User::LeaveIfError( iCallAcceptProc->ProcessCommand( *aATCommandIn,
|
|
429 |
aATCommandOut ) );
|
|
430 |
}
|
|
431 |
else if ( iProcedureStarted == EHFPLastNumberRedialing )
|
|
432 |
{
|
|
433 |
TRACE_INFO(_L("CIEV : LAST NUMBER REDIAL"))
|
|
434 |
User::LeaveIfNull( iLastNumberRedialing );
|
|
435 |
User::LeaveIfError( iLastNumberRedialing->ProcessCommand(
|
|
436 |
*aATCommandIn, aATCommandOut ) );
|
|
437 |
}
|
|
438 |
else if ( iProcedureStarted == EHFPPhoneNumberDialing )
|
|
439 |
{
|
|
440 |
TRACE_INFO(_L("CIEV : PHONE NUMBER DIALING"))
|
|
441 |
User::LeaveIfNull( iPhoneNumberDialing );
|
|
442 |
User::LeaveIfError( iPhoneNumberDialing->ProcessCommand( *aATCommandIn,
|
|
443 |
aATCommandOut ) );
|
|
444 |
}
|
|
445 |
else
|
|
446 |
{
|
|
447 |
User::Leave( KErrArgument );
|
|
448 |
}
|
|
449 |
|
|
450 |
TRACE_FUNC_EXIT
|
|
451 |
}
|