|
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 "hfpphonestatusinformation.h" |
|
20 #include "hfpcommand.h" |
|
21 #include "hfpsettings.h" |
|
22 #include "debug.h" |
|
23 |
|
24 CHsHFPPhoneStatusInformation* CHsHFPPhoneStatusInformation::NewL( |
|
25 MHsHFPFeatureProviderObserver* aObserver ) |
|
26 { |
|
27 CHsHFPPhoneStatusInformation* self = CHsHFPPhoneStatusInformation::NewLC( |
|
28 aObserver ); |
|
29 CleanupStack::Pop( self ); |
|
30 return self; |
|
31 } |
|
32 |
|
33 CHsHFPPhoneStatusInformation* CHsHFPPhoneStatusInformation::NewLC( |
|
34 MHsHFPFeatureProviderObserver* aObserver ) |
|
35 { |
|
36 CHsHFPPhoneStatusInformation* self = |
|
37 new ( ELeave ) CHsHFPPhoneStatusInformation( aObserver ); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 return self; |
|
41 } |
|
42 |
|
43 CHsHFPPhoneStatusInformation::~CHsHFPPhoneStatusInformation() |
|
44 { |
|
45 TRACE_FUNC_ENTRY |
|
46 if ( iSettings ) |
|
47 { |
|
48 iSettings->Release(); |
|
49 } |
|
50 TRACE_FUNC_ENTRY |
|
51 } |
|
52 |
|
53 TInt CHsHFPPhoneStatusInformation::ProcessCommand( |
|
54 const CHsHFPCommand &aInputCmd, CHsHFPCommand &aOutputCmd ) |
|
55 { |
|
56 TRACE_FUNC_ENTRY |
|
57 |
|
58 TInt res = KErrNone; |
|
59 if ( aInputCmd.FromAG() ) |
|
60 { |
|
61 if ( aInputCmd.Type() == EHFPCmdCIEV ) |
|
62 { |
|
63 TRAP( res, HandleIndicatorL( &aInputCmd ) ); |
|
64 } |
|
65 else if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdOK ) |
|
66 { |
|
67 iWaitingForOK = EFalse; |
|
68 iWaitingForCOPSFromAG = ETrue; |
|
69 aOutputCmd.SetType( EHFPCmdCOPS ); |
|
70 aOutputCmd.SetMode( ECmdModeRead ); |
|
71 |
|
72 } |
|
73 else if ( iWaitingForCOPSFromAG && aInputCmd.Type() == EHFPCmdCOPS ) |
|
74 { |
|
75 iWaitingForCOPSFromAG = EFalse; |
|
76 iObserver->HandleProcedureCompleted( KErrNone ); |
|
77 } |
|
78 |
|
79 else |
|
80 { |
|
81 res = KErrArgument; |
|
82 } |
|
83 } |
|
84 else |
|
85 { |
|
86 if ( aInputCmd.Type() == EHFPCmdCOPS ) |
|
87 { |
|
88 iWaitingForOK = ETrue; |
|
89 TRAP(res, CHsHFPCommand::CopyL( aInputCmd, aOutputCmd )); |
|
90 } |
|
91 else |
|
92 { |
|
93 res = KErrArgument; |
|
94 } |
|
95 } |
|
96 TRACE_FUNC_EXIT |
|
97 return res; |
|
98 } |
|
99 |
|
100 TBool CHsHFPPhoneStatusInformation::IsCallOngoing() |
|
101 { |
|
102 TRACE_FUNC_ENTRY |
|
103 TInt index = iSettings->FindIndicatorIndex( KHFPCallIndicatorDes ); |
|
104 TRACE_FUNC_EXIT |
|
105 if ( index != KErrNotFound ) |
|
106 { |
|
107 return ( iSettings->iSettingsArr[index].Int() == 1 ? ETrue : EFalse ); |
|
108 } |
|
109 else |
|
110 { |
|
111 return EFalse; |
|
112 } |
|
113 } |
|
114 |
|
115 CHsHFPPhoneStatusInformation::CHsHFPPhoneStatusInformation( |
|
116 MHsHFPFeatureProviderObserver* aObserver ) : |
|
117 iObserver( aObserver ) |
|
118 { |
|
119 } |
|
120 |
|
121 void CHsHFPPhoneStatusInformation::ConstructL() |
|
122 { |
|
123 TRACE_FUNC_ENTRY |
|
124 iSettings = CHsHFPSettings::InstanceL(); |
|
125 TRACE_FUNC_EXIT |
|
126 } |
|
127 |
|
128 void CHsHFPPhoneStatusInformation::HandleIndicatorL( |
|
129 const CHsHFPCommand* aCommand ) |
|
130 { |
|
131 TRACE_FUNC_ENTRY |
|
132 if ( aCommand->Params().Count() != 2 ) |
|
133 { |
|
134 User::Leave( KErrArgument ); |
|
135 } |
|
136 |
|
137 THFPIndicatorDes indicatorBuf = |
|
138 iSettings->iSettingsArr[aCommand->Params()[0].IntL()].Des(); |
|
139 |
|
140 TRACE_INFO( (_L8("INDICATOR before: %S - value: %d "), &indicatorBuf, |
|
141 iSettings->iSettingsArr[aCommand->Params()[0].IntL()].Int() ) ); |
|
142 TRACE_INFO( (_L8("INDICATOR after: %S - value: %d "), &indicatorBuf, |
|
143 aCommand->Params()[1].IntL() ) ); |
|
144 |
|
145 if ( indicatorBuf.Compare( KHFPCallIndicatorDes ) == 0 ) |
|
146 { |
|
147 TRACE_INFO(_L8("KHFPCallIndicatorDes")) |
|
148 HandleCallIndicatorL( aCommand ); |
|
149 } |
|
150 else if ( indicatorBuf.Compare( KHFPServiceIndicatorDes ) == 0 ) |
|
151 { |
|
152 TRACE_INFO(_L8("KHFPServiceIndicatorDes")) |
|
153 HandleServiceIndicatorL( aCommand ); |
|
154 } |
|
155 else if ( indicatorBuf.Compare( KHFPCallsetupIndicatorDes ) == 0 ) |
|
156 { |
|
157 TRACE_INFO(_L8("KHFPCallsetupIndicatorDes")) |
|
158 HandleCallsetupIndicatorL( aCommand ); |
|
159 } |
|
160 else if ( indicatorBuf.Compare( KHFPCall_setupIndicatorDes ) == 0 ) |
|
161 { |
|
162 TRACE_INFO(_L8("KHFPCall_setupIndicatorDes")) |
|
163 } |
|
164 else if ( indicatorBuf.Compare( KHFPCallheldIndicatorDes ) == 0 ) |
|
165 { |
|
166 TRACE_INFO(_L8("KHFPCallheldIndicatorDes")) |
|
167 HandleCallheldIndicatorL( aCommand ); |
|
168 } |
|
169 else if ( indicatorBuf.Compare( KHFPSignalIndicatorDes ) == 0 ) |
|
170 { |
|
171 TRACE_INFO(_L8("KHFPSignalIndicatorDes")) |
|
172 HandleSignalIndicatorL( aCommand ); |
|
173 } |
|
174 else if ( indicatorBuf.Compare( KHFPRoamIndicatorDes ) == 0 ) |
|
175 { |
|
176 TRACE_INFO(_L8("KHFPRoamIndicatorDes")) |
|
177 HandleRoamingIndicatorL( aCommand ); |
|
178 } |
|
179 else if ( indicatorBuf.Compare( KHFPBattchgIndicatorDes ) == 0 ) |
|
180 { |
|
181 TRACE_INFO(_L8("KHFPBattchgIndicatorDes")) |
|
182 HandleBatteryIndicatorL( aCommand ); |
|
183 } |
|
184 else |
|
185 { |
|
186 User::Leave( KErrArgument ); |
|
187 } |
|
188 |
|
189 TRACE_FUNC_EXIT |
|
190 } |
|
191 |
|
192 void CHsHFPPhoneStatusInformation::HandleCallIndicatorL( |
|
193 const CHsHFPCommand* aCommand ) |
|
194 { |
|
195 TRACE_FUNC_ENTRY |
|
196 iSettings->iSettingsArr[aCommand->Params()[0].IntL()].SetValueL( |
|
197 aCommand->Params()[1].Des() ); |
|
198 TRACE_FUNC_EXIT |
|
199 } |
|
200 |
|
201 void CHsHFPPhoneStatusInformation::HandleServiceIndicatorL( |
|
202 const CHsHFPCommand* aCommand ) |
|
203 { |
|
204 TRACE_FUNC_ENTRY |
|
205 iSettings->iSettingsArr[aCommand->Params()[0].IntL()].SetValueL( |
|
206 aCommand->Params()[1].Des() ); |
|
207 TRACE_FUNC_EXIT |
|
208 } |
|
209 |
|
210 void CHsHFPPhoneStatusInformation::HandleCallsetupIndicatorL( |
|
211 const CHsHFPCommand* aCommand ) |
|
212 { |
|
213 TRACE_FUNC_ENTRY |
|
214 iSettings->iSettingsArr[aCommand->Params()[0].IntL()].SetValueL( |
|
215 aCommand->Params()[1].Des() ); |
|
216 TRACE_FUNC_EXIT |
|
217 } |
|
218 |
|
219 void CHsHFPPhoneStatusInformation::HandleCallheldIndicatorL( |
|
220 const CHsHFPCommand* aCommand ) |
|
221 { |
|
222 TRACE_FUNC_ENTRY |
|
223 iSettings->iSettingsArr[aCommand->Params()[0].IntL()].SetValueL( |
|
224 aCommand->Params()[1].Des() ); |
|
225 TRACE_FUNC_EXIT |
|
226 } |
|
227 |
|
228 void CHsHFPPhoneStatusInformation::HandleSignalIndicatorL( |
|
229 const CHsHFPCommand* aCommand ) |
|
230 { |
|
231 TRACE_FUNC_ENTRY |
|
232 iSettings->iSettingsArr[aCommand->Params()[0].IntL()].SetValueL( |
|
233 aCommand->Params()[1].Des() ); |
|
234 TRACE_FUNC_EXIT |
|
235 } |
|
236 |
|
237 void CHsHFPPhoneStatusInformation::HandleRoamingIndicatorL( |
|
238 const CHsHFPCommand* aCommand ) |
|
239 { |
|
240 TRACE_FUNC_ENTRY |
|
241 iSettings->iSettingsArr[aCommand->Params()[0].IntL()].SetValueL( |
|
242 aCommand->Params()[1].Des() ); |
|
243 TRACE_FUNC_EXIT |
|
244 } |
|
245 |
|
246 void CHsHFPPhoneStatusInformation::HandleBatteryIndicatorL( |
|
247 const CHsHFPCommand* aCommand ) |
|
248 { |
|
249 TRACE_FUNC_ENTRY |
|
250 iSettings->iSettingsArr[aCommand->Params()[0].IntL()].SetValueL( |
|
251 aCommand->Params()[1].Des() ); |
|
252 TRACE_FUNC_EXIT |
|
253 } |