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