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 "hfpincomingcallacceptance.h"
|
|
20 |
#include "hfpcommand.h"
|
|
21 |
#include "hfpsettings.h"
|
|
22 |
#include "debug.h"
|
|
23 |
|
|
24 |
CHsHFPIncomingCallAcceptance* CHsHFPIncomingCallAcceptance::NewL(
|
|
25 |
MHsHFPFeatureProviderObserver* aObserver )
|
|
26 |
{
|
|
27 |
CHsHFPIncomingCallAcceptance* self = CHsHFPIncomingCallAcceptance::NewLC(
|
|
28 |
aObserver );
|
|
29 |
CleanupStack::Pop( self );
|
|
30 |
return self;
|
|
31 |
}
|
|
32 |
CHsHFPIncomingCallAcceptance* CHsHFPIncomingCallAcceptance::NewLC(
|
|
33 |
MHsHFPFeatureProviderObserver* aObserver )
|
|
34 |
{
|
|
35 |
CHsHFPIncomingCallAcceptance* self =
|
|
36 |
new ( ELeave ) CHsHFPIncomingCallAcceptance( aObserver );
|
|
37 |
CleanupStack::PushL( self );
|
|
38 |
self->ConstructL();
|
|
39 |
return self;
|
|
40 |
}
|
|
41 |
|
|
42 |
CHsHFPIncomingCallAcceptance::~CHsHFPIncomingCallAcceptance()
|
|
43 |
{
|
|
44 |
TRACE_FUNC_ENTRY
|
|
45 |
if ( iSettings )
|
|
46 |
{
|
|
47 |
iSettings->Release();
|
|
48 |
}
|
|
49 |
TRACE_FUNC_EXIT
|
|
50 |
}
|
|
51 |
|
|
52 |
TInt CHsHFPIncomingCallAcceptance::ProcessCommand(
|
|
53 |
const CHsHFPCommand &aInputCmd, CHsHFPCommand &aOutputCmd )
|
|
54 |
{
|
|
55 |
TRACE_FUNC_ENTRY
|
|
56 |
|
|
57 |
TInt res = KErrNone;
|
|
58 |
if ( aInputCmd.FromAG() )
|
|
59 |
{
|
|
60 |
if ( aInputCmd.Type() == EHFPCmdRING )
|
|
61 |
{
|
|
62 |
TInt ind =
|
|
63 |
iSettings->FindIndicatorIndex( KHFPCallsetupIndicatorDes );
|
|
64 |
if ( ind != KErrNotFound && iSettings->iSettingsArr[ind].Int() == 1 )
|
|
65 |
{
|
|
66 |
iWaitingForATA = ETrue;
|
|
67 |
}
|
|
68 |
}
|
|
69 |
else if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdOK )
|
|
70 |
{
|
|
71 |
iWaitingForOK = EFalse;
|
|
72 |
iWaitingForCIEVCall1 = ETrue;
|
|
73 |
}
|
|
74 |
else if ( iWaitingForCIEVCall1 && IsProperCIEV( &aInputCmd,
|
|
75 |
KHFPCallIndicatorDes, 1 ) )
|
|
76 |
{
|
|
77 |
iWaitingForCIEVCall1 = EFalse;
|
|
78 |
iWaitingForCIEVCallsetup0 = ETrue;
|
|
79 |
}
|
|
80 |
else if ( iWaitingForCIEVCallsetup0 && IsProperCIEV( &aInputCmd,
|
|
81 |
KHFPCallsetupIndicatorDes, 0 ) )
|
|
82 |
{
|
|
83 |
iWaitingForCIEVCallsetup0 = EFalse;
|
|
84 |
iObserver->HandleProcedureCompleted( KErrNone );
|
|
85 |
}
|
|
86 |
else
|
|
87 |
{
|
|
88 |
res = KErrArgument;
|
|
89 |
}
|
|
90 |
}
|
|
91 |
else
|
|
92 |
{
|
|
93 |
if ( iWaitingForATA && aInputCmd.Type() == EHFPCmdATA )
|
|
94 |
{
|
|
95 |
iWaitingForATA = EFalse;
|
|
96 |
iWaitingForOK = ETrue;
|
|
97 |
TRAP(res,CHsHFPCommand::CopyL( aInputCmd, aOutputCmd ));
|
|
98 |
}
|
|
99 |
else
|
|
100 |
{
|
|
101 |
res = KErrArgument;
|
|
102 |
}
|
|
103 |
}
|
|
104 |
|
|
105 |
TRACE_FUNC_EXIT
|
|
106 |
return res;
|
|
107 |
}
|
|
108 |
|
|
109 |
CHsHFPIncomingCallAcceptance::CHsHFPIncomingCallAcceptance(
|
|
110 |
MHsHFPFeatureProviderObserver* aObserver ) :
|
|
111 |
iObserver( aObserver )
|
|
112 |
{
|
|
113 |
}
|
|
114 |
|
|
115 |
void CHsHFPIncomingCallAcceptance::ConstructL()
|
|
116 |
{
|
|
117 |
iSettings = CHsHFPSettings::InstanceL();
|
|
118 |
}
|
|
119 |
|
|
120 |
TBool CHsHFPIncomingCallAcceptance::IsProperCIEV(
|
|
121 |
const CHsHFPCommand* aCommand, const TDesC8& aIndicatorDes,
|
|
122 |
const TInt aIndicatorValue )
|
|
123 |
{
|
|
124 |
TRACE_FUNC_ENTRY
|
|
125 |
TBool res = EFalse;
|
|
126 |
|
|
127 |
if ( aCommand->Params().Count() == 2 )
|
|
128 |
{
|
|
129 |
TInt expectedIdx = iSettings->FindIndicatorIndex( aIndicatorDes );
|
|
130 |
|
|
131 |
TInt retrievedIdx = KErrNotFound;
|
|
132 |
TRAPD(errRetrieveIdx, retrievedIdx = aCommand->Params()[0].IntL() )
|
|
133 |
|
|
134 |
TInt retrievedValue = KErrNotFound;
|
|
135 |
TRAPD(errRetrieveValue, retrievedValue = aCommand->Params()[1].IntL() )
|
|
136 |
TRACE_INFO((_L8(" Index retrieved = %d, expected = %d"),
|
|
137 |
expectedIdx, retrievedIdx))
|
|
138 |
|
|
139 |
if ( errRetrieveIdx == KErrNone && errRetrieveValue == KErrNone
|
|
140 |
&& aCommand->Type() == EHFPCmdCIEV && aCommand->FromAG()
|
|
141 |
&& expectedIdx == retrievedIdx && retrievedValue
|
|
142 |
== aIndicatorValue )
|
|
143 |
{
|
|
144 |
res = ETrue;
|
|
145 |
}
|
|
146 |
}
|
|
147 |
|
|
148 |
TRACE_FUNC_EXIT
|
|
149 |
return res;
|
|
150 |
}
|