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