|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <psetcontainer.h> |
|
19 #include <psetcallbarring.h> |
|
20 #include "psetcallbarringwrapper.h" |
|
21 #include "psetcallbarringwrapper_p.h" |
|
22 #include "logging.h" |
|
23 |
|
24 TServiceGroup convertServiceGroup(PsServiceGroup serviceGroup) |
|
25 { |
|
26 TServiceGroup convertedType = EServiceGroupVoice; |
|
27 switch (serviceGroup) { |
|
28 case ServiceGroupVoice: |
|
29 convertedType = EServiceGroupVoice; |
|
30 break; |
|
31 case ServiceGroupData: |
|
32 convertedType = EServiceGroupData; |
|
33 break; |
|
34 case ServiceGroupFax: |
|
35 convertedType = EServiceGroupFax; |
|
36 break; |
|
37 case ServiceGroupAllTeleservices: |
|
38 convertedType = EServiceGroupAllTeleservices; |
|
39 break; |
|
40 default: |
|
41 break; |
|
42 } |
|
43 |
|
44 return convertedType; |
|
45 } |
|
46 |
|
47 PSetCallBarringWrapper::BarringType convertBarringType( |
|
48 TBarringProgram barringType) |
|
49 { |
|
50 PSetCallBarringWrapper::BarringType convertedType = |
|
51 PSetCallBarringWrapper::BarringTypeAllBarrings; |
|
52 switch (barringType) { |
|
53 case EBarringTypeAllBarrings: |
|
54 convertedType = PSetCallBarringWrapper::BarringTypeAllBarrings; |
|
55 break; |
|
56 case EBarringTypeAllOutgoing: |
|
57 convertedType = PSetCallBarringWrapper::BarringTypeAllOutgoing; |
|
58 break; |
|
59 case EBarringTypeOutgoingInternational: |
|
60 convertedType = PSetCallBarringWrapper::BarringTypeOutgoingInternational; |
|
61 break; |
|
62 case EBarringTypeOutgoingInternationalExceptToHomeCountry: |
|
63 convertedType = PSetCallBarringWrapper:: |
|
64 BarringTypeOutgoingInternationalExceptToHomeCountry; |
|
65 break; |
|
66 case EBarringTypeAllIncoming: |
|
67 convertedType = PSetCallBarringWrapper::BarringTypeAllIncoming; |
|
68 break; |
|
69 case EBarringTypeIncomingWhenRoaming: |
|
70 convertedType = PSetCallBarringWrapper::BarringTypeIncomingWhenRoaming; |
|
71 break; |
|
72 case EBarringTypeAllServices: |
|
73 convertedType = PSetCallBarringWrapper::BarringTypeAllServices; |
|
74 break; |
|
75 case EBarringTypeAllOutgoingServices: |
|
76 convertedType = PSetCallBarringWrapper::BarringTypeAllOutgoingServices; |
|
77 break; |
|
78 case EBarringTypeAllIncomingServices: |
|
79 convertedType = PSetCallBarringWrapper::BarringTypeAllIncomingServices; |
|
80 break; |
|
81 default: |
|
82 break; |
|
83 } |
|
84 |
|
85 return convertedType; |
|
86 } |
|
87 |
|
88 TBarringProgram convertBarringType( |
|
89 PSetCallBarringWrapper::BarringType barringType) |
|
90 { |
|
91 TBarringProgram convertedType = EBarringTypeAllBarrings; |
|
92 switch (barringType) { |
|
93 case PSetCallBarringWrapper::BarringTypeAllBarrings: |
|
94 convertedType = EBarringTypeAllBarrings; |
|
95 break; |
|
96 case PSetCallBarringWrapper::BarringTypeAllOutgoing: |
|
97 convertedType = EBarringTypeAllOutgoing; |
|
98 break; |
|
99 case PSetCallBarringWrapper::BarringTypeOutgoingInternational: |
|
100 convertedType = EBarringTypeOutgoingInternational; |
|
101 break; |
|
102 case PSetCallBarringWrapper:: |
|
103 BarringTypeOutgoingInternationalExceptToHomeCountry: |
|
104 convertedType |
|
105 = EBarringTypeOutgoingInternationalExceptToHomeCountry; |
|
106 break; |
|
107 case PSetCallBarringWrapper::BarringTypeAllIncoming: |
|
108 convertedType = EBarringTypeAllIncoming; |
|
109 break; |
|
110 case PSetCallBarringWrapper::BarringTypeIncomingWhenRoaming: |
|
111 convertedType = EBarringTypeIncomingWhenRoaming; |
|
112 break; |
|
113 case PSetCallBarringWrapper::BarringTypeAllServices: |
|
114 convertedType = EBarringTypeAllServices; |
|
115 break; |
|
116 case PSetCallBarringWrapper::BarringTypeAllOutgoingServices: |
|
117 convertedType = EBarringTypeAllOutgoingServices; |
|
118 break; |
|
119 case PSetCallBarringWrapper::BarringTypeAllIncomingServices: |
|
120 convertedType = EBarringTypeAllIncomingServices; |
|
121 break; |
|
122 default: |
|
123 break; |
|
124 } |
|
125 |
|
126 return convertedType; |
|
127 } |
|
128 |
|
129 |
|
130 PSetCallBarringWrapper::BarringStatus convertBarringStatus( |
|
131 TBarringStatus status) |
|
132 { |
|
133 PSetCallBarringWrapper::BarringStatus convertedType = |
|
134 PSetCallBarringWrapper::BarringStatusUnknown; |
|
135 switch (status) { |
|
136 case EBarringStatusActive: |
|
137 convertedType = PSetCallBarringWrapper::BarringStatusActive; |
|
138 break; |
|
139 case EBarringStatusInactive: |
|
140 convertedType = PSetCallBarringWrapper::BarringStatusInactive; |
|
141 break; |
|
142 case EBarringStatusNotProvisioned: |
|
143 convertedType = |
|
144 PSetCallBarringWrapper::BarringStatusNotProvisioned; |
|
145 break; |
|
146 case EBarringStatusUnavailable: |
|
147 convertedType = PSetCallBarringWrapper::BarringStatusUnavailable; |
|
148 break; |
|
149 case EBarringStatusUnknown: |
|
150 default: |
|
151 convertedType = PSetCallBarringWrapper::BarringStatusUnknown; |
|
152 break; |
|
153 } |
|
154 |
|
155 return convertedType; |
|
156 } |
|
157 |
|
158 |
|
159 /*! |
|
160 PSetCallBarringWrapperPrivate::PSetCallBarringWrapperPrivate |
|
161 */ |
|
162 PSetCallBarringWrapperPrivate::PSetCallBarringWrapperPrivate( |
|
163 PSetCallBarringWrapper &owner, CPsetContainer &psetContainer) |
|
164 : |
|
165 m_owner(owner), |
|
166 m_callBarring(NULL), |
|
167 m_currentRequest(RequestNone), |
|
168 m_barringError(PSetCallBarringWrapper::BarringErrorNone), |
|
169 m_barringStatus(PSetCallBarringWrapper::BarringStatusUnknown), |
|
170 m_barringType(PSetCallBarringWrapper::BarringTypeAllBarrings), |
|
171 m_plural(false) |
|
172 { |
|
173 DPRINT; |
|
174 |
|
175 QT_TRAP_THROWING( |
|
176 m_callBarring = psetContainer.CreateCBObjectL(*this) |
|
177 ) |
|
178 |
|
179 m_callBarring->SetRequestObserver(this); |
|
180 } |
|
181 |
|
182 |
|
183 /*! |
|
184 PSetCallBarringWrapperPrivate::~PSetCallBarringWrapperPrivate |
|
185 */ |
|
186 PSetCallBarringWrapperPrivate::~PSetCallBarringWrapperPrivate() |
|
187 { |
|
188 DPRINT; |
|
189 |
|
190 delete m_callBarring; |
|
191 } |
|
192 |
|
193 |
|
194 /*! |
|
195 PSetCallBarringWrapperPrivate::barringStatus |
|
196 */ |
|
197 void PSetCallBarringWrapperPrivate::barringStatus( |
|
198 PsServiceGroup serviceGroup, |
|
199 PSetCallBarringWrapper::BarringType barringType) |
|
200 { |
|
201 DPRINT; |
|
202 |
|
203 TServiceGroup convertedServiceGroup = convertServiceGroup(serviceGroup); |
|
204 TBarringProgram convertedBarringType = convertBarringType(barringType); |
|
205 |
|
206 QT_TRAP_THROWING(m_callBarring->GetBarringStatusL( |
|
207 convertedServiceGroup, convertedBarringType) |
|
208 ) |
|
209 |
|
210 m_currentRequest = RequestBarringStatus; |
|
211 } |
|
212 |
|
213 |
|
214 /*! |
|
215 PSetCallBarringWrapperPrivate::enableBarring |
|
216 */ |
|
217 void PSetCallBarringWrapperPrivate::enableBarring( |
|
218 PsServiceGroup serviceGroup, |
|
219 PSetCallBarringWrapper::BarringType barringType, |
|
220 QString barringPassword) |
|
221 { |
|
222 DPRINT; |
|
223 |
|
224 TCallBarringSetting setting; |
|
225 setting.iType = convertBarringType(barringType); |
|
226 setting.iSetting = EActivateBarring; |
|
227 setting.iServiceGroup = convertServiceGroup(serviceGroup); |
|
228 setting.iPassword.Copy(barringPassword.utf16()); |
|
229 |
|
230 TBasicServiceGroups serviceGroups = EAllTeleAndBearer; |
|
231 QT_TRAP_THROWING( |
|
232 m_callBarring->SetBarringL(setting, serviceGroups); |
|
233 ) |
|
234 |
|
235 m_currentRequest = RequestEnableBarring; |
|
236 } |
|
237 |
|
238 |
|
239 /*! |
|
240 PSetCallBarringWrapperPrivate::disableBarring |
|
241 */ |
|
242 void PSetCallBarringWrapperPrivate::disableBarring( |
|
243 PsServiceGroup serviceGroup, |
|
244 PSetCallBarringWrapper::BarringType barringType, |
|
245 QString barringPassword) |
|
246 { |
|
247 DPRINT; |
|
248 |
|
249 TCallBarringSetting setting; |
|
250 setting.iType = convertBarringType(barringType); |
|
251 setting.iSetting = ECancelBarring; |
|
252 setting.iServiceGroup = convertServiceGroup(serviceGroup); |
|
253 setting.iPassword.Copy(barringPassword.utf16()); |
|
254 |
|
255 TBasicServiceGroups serviceGroups = EAllTeleAndBearer; |
|
256 QT_TRAP_THROWING( |
|
257 m_callBarring->SetBarringL(setting, serviceGroups); |
|
258 ) |
|
259 |
|
260 m_currentRequest = RequestDisableBarring; |
|
261 } |
|
262 |
|
263 |
|
264 /*! |
|
265 From MPsetBarringObserver. |
|
266 PSetCallBarringWrapperPrivate::HandleBarringModeChangedL |
|
267 */ |
|
268 void PSetCallBarringWrapperPrivate::HandleBarringModeChangedL( |
|
269 TBarringProgram aType, |
|
270 TBarringStatus aStatus, |
|
271 TBool aPlural ) |
|
272 { |
|
273 DPRINT; |
|
274 Q_ASSERT(RequestEnableBarring == m_currentRequest || |
|
275 RequestDisableBarring == m_currentRequest); |
|
276 |
|
277 m_barringType = convertBarringType(aType); |
|
278 m_barringError = PSetCallBarringWrapper::BarringErrorNone; |
|
279 m_barringStatus = convertBarringStatus(aStatus); |
|
280 m_plural = static_cast<bool>(aPlural); |
|
281 } |
|
282 |
|
283 |
|
284 /*! |
|
285 From MPsetBarringObserver. |
|
286 PSetCallBarringWrapperPrivate::HandleBarringModeStatusL |
|
287 */ |
|
288 void PSetCallBarringWrapperPrivate::HandleBarringModeStatusL( |
|
289 TUint8 aBsc[KPSetNumberOfBsc], |
|
290 TBarringStatus aStatus ) |
|
291 { |
|
292 DPRINT; |
|
293 Q_ASSERT(RequestBarringStatus == m_currentRequest); |
|
294 |
|
295 m_barringError = PSetCallBarringWrapper::BarringErrorNone; |
|
296 QT_TRYCATCH_LEAVING( |
|
297 int index = 0; |
|
298 unsigned char groupIdCandidate = aBsc[index]; |
|
299 while ((groupIdCandidate |
|
300 != static_cast<unsigned char>(KPSetUnusedValue))) { |
|
301 m_basicServiceGroupIds << groupIdCandidate; |
|
302 groupIdCandidate = aBsc[++index]; |
|
303 } |
|
304 ) |
|
305 m_barringStatus = convertBarringStatus(aStatus); |
|
306 } |
|
307 |
|
308 |
|
309 /*! |
|
310 From MPsetBarringObserver. |
|
311 PSetCallBarringWrapperPrivate::HandleBarringErrorL |
|
312 */ |
|
313 void PSetCallBarringWrapperPrivate::HandleBarringErrorL( |
|
314 TInt aReason ) |
|
315 { |
|
316 DPRINT; |
|
317 Q_UNUSED(aReason) |
|
318 |
|
319 m_barringError = aReason; |
|
320 m_basicServiceGroupIds.clear(); |
|
321 m_barringStatus = PSetCallBarringWrapper::BarringStatusUnknown; |
|
322 m_plural = false; |
|
323 } |
|
324 |
|
325 |
|
326 /*! |
|
327 From MPsetBarringObserver. |
|
328 PSetCallBarringWrapperPrivate::HandleCBRequestingL |
|
329 */ |
|
330 void PSetCallBarringWrapperPrivate::HandleCBRequestingL( |
|
331 TBool aTrue, |
|
332 TBool aInterrupted ) |
|
333 { |
|
334 DPRINT; |
|
335 |
|
336 Q_UNUSED(aTrue) |
|
337 Q_UNUSED(aInterrupted) |
|
338 } |
|
339 |
|
340 |
|
341 /*! |
|
342 From MPsetBarringObserver. |
|
343 PSetCallBarringWrapperPrivate::SetEngineContact |
|
344 */ |
|
345 void PSetCallBarringWrapperPrivate::SetEngineContact( |
|
346 MPsetCallBarring* aBarringEngine ) |
|
347 { |
|
348 DPRINT; |
|
349 |
|
350 Q_UNUSED(aBarringEngine) |
|
351 } |
|
352 |
|
353 |
|
354 /*! |
|
355 From MPsetBarringObserver. |
|
356 PSetCallBarringWrapperPrivate::CbPasswordChangedL |
|
357 */ |
|
358 void PSetCallBarringWrapperPrivate::CbPasswordChangedL( |
|
359 TBool aSuccess ) |
|
360 { |
|
361 DPRINT; |
|
362 |
|
363 Q_UNUSED(aSuccess) |
|
364 } |
|
365 |
|
366 |
|
367 /*! |
|
368 From MPsetRequestObserver. |
|
369 PSetCallBarringWrapperPrivate::RequestComplete |
|
370 */ |
|
371 void PSetCallBarringWrapperPrivate::RequestComplete() |
|
372 { |
|
373 DPRINT; |
|
374 Q_ASSERT(RequestNone != m_currentRequest); |
|
375 BarringRequest completedRequest = m_currentRequest; |
|
376 m_currentRequest = RequestNone; |
|
377 |
|
378 switch (completedRequest) |
|
379 { |
|
380 case RequestBarringStatus: |
|
381 { |
|
382 int errorCode = 0; |
|
383 QT_TRYCATCH_ERROR( errorCode, |
|
384 emit m_owner.barringStatusRequestCompleted( |
|
385 m_barringError, |
|
386 m_basicServiceGroupIds, |
|
387 m_barringStatus); |
|
388 ) |
|
389 DPRINT << "RequestBarringStatus ERROR:" << errorCode; |
|
390 break; |
|
391 } |
|
392 |
|
393 case RequestEnableBarring: |
|
394 { |
|
395 int errorCode = 0; |
|
396 QT_TRYCATCH_ERROR( errorCode, |
|
397 emit m_owner.enableBarringRequestCompleted( |
|
398 m_barringError, |
|
399 m_barringType, |
|
400 m_barringStatus, |
|
401 m_plural); |
|
402 ) |
|
403 DPRINT << "RequestEnableBarring ERROR:" << errorCode; |
|
404 break; |
|
405 } |
|
406 |
|
407 case RequestDisableBarring: |
|
408 { |
|
409 int errorCode = 0; |
|
410 QT_TRYCATCH_ERROR( errorCode, |
|
411 emit m_owner.disableBarringRequestCompleted( |
|
412 m_barringError, |
|
413 m_barringType, |
|
414 m_barringStatus, |
|
415 m_plural); |
|
416 ) |
|
417 DPRINT << "RequestDisableBarring ERROR:" << errorCode; |
|
418 break; |
|
419 } |
|
420 default: |
|
421 break; |
|
422 } |
|
423 } |
|
424 |
|
425 |
|
426 /*! |
|
427 From MPsetRequestObserver. |
|
428 PSetCallBarringWrapperPrivate::RequestStatusChanged |
|
429 */ |
|
430 void PSetCallBarringWrapperPrivate::RequestStatusChanged( |
|
431 TInt aNewStatus) |
|
432 { |
|
433 DPRINT; |
|
434 Q_UNUSED(aNewStatus) |
|
435 Q_ASSERT(RequestNone != m_currentRequest); |
|
436 } |
|
437 |
|
438 // End of File. |