24
|
1 |
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// Implements the functionality required to provide clients with
|
|
15 |
// callBarring status and registration information.
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
/**
|
|
20 |
@file
|
|
21 |
*/
|
|
22 |
|
|
23 |
#include <testconfigfileparser.h>
|
|
24 |
#include "CSimCallBarring.h"
|
|
25 |
#include "CSimPhone.h"
|
|
26 |
#include "Simlog.h"
|
|
27 |
|
|
28 |
// The Mobile Basic Service Groups used - originally were magic numbers from 1 to 6 incl;
|
|
29 |
const TInt KMobServiceIndxStart = 1;
|
|
30 |
const TInt KMobServiceIndxEnd = 6;
|
|
31 |
|
|
32 |
|
|
33 |
CSimCallBarring* CSimCallBarring::NewL(CSimPhone* aPhone)
|
|
34 |
/**
|
|
35 |
* Standard two-phase constructor.
|
|
36 |
* @param aPhone The parent phone object.
|
|
37 |
* @return CSimNetworkStatus The new network status class.
|
|
38 |
*/
|
|
39 |
{
|
|
40 |
CSimCallBarring* self=new(ELeave) CSimCallBarring(aPhone);
|
|
41 |
CleanupStack::PushL(self);
|
|
42 |
self->ConstructL();
|
|
43 |
CleanupStack::Pop();
|
|
44 |
return self;
|
|
45 |
}
|
|
46 |
|
|
47 |
CSimCallBarring::CSimCallBarring(CSimPhone* aPhone)
|
|
48 |
: iPhone(aPhone)
|
|
49 |
/**
|
|
50 |
* Trivial first phase construction.
|
|
51 |
* @param aPhone The parent phone object.
|
|
52 |
*/
|
|
53 |
{
|
|
54 |
}
|
|
55 |
|
|
56 |
void CSimCallBarring::ConstructL()
|
|
57 |
/**
|
|
58 |
Second phase of 2-Phase Constructor
|
|
59 |
Retrieves all the Call Barring related tags from the config file
|
|
60 |
*/
|
|
61 |
{
|
|
62 |
LOGCALL1("Starting to parse Call Barring config parameters...");
|
|
63 |
|
|
64 |
iPassword.Copy(CfgFile()->ItemValue(KCBPassword,KCBDefaultPassword));
|
|
65 |
|
|
66 |
iGetCBStatus = new(ELeave) CArrayPtrFlat<CListReadAllAttempt>(1);
|
|
67 |
FindAndCreateCBListL();
|
|
68 |
LOGCALL1("...Finished parsing Call Barring config parameters...");
|
|
69 |
}
|
|
70 |
|
|
71 |
void CSimCallBarring::FindAndCreateCBListL()
|
|
72 |
{
|
|
73 |
/**
|
|
74 |
Retrieves all the Call barring tags that define the
|
|
75 |
original status of Call barring from the config file
|
|
76 |
*/
|
|
77 |
LOGCALL1("CSimPhone::FindAndCreateCBListL");
|
|
78 |
RMobilePhone::TMobilePhoneCBInfoEntryV1 entry;
|
|
79 |
|
|
80 |
iCBList = CMobilePhoneCBList::NewL();
|
|
81 |
TInt count=CfgFile()->ItemCount(KCBList);
|
|
82 |
const CTestConfigItem* item=NULL;
|
|
83 |
TInt ret=KErrNone;
|
|
84 |
|
|
85 |
LOGCALL1("Starting to Load and Parse CBList Config parameters");
|
|
86 |
TInt i;
|
|
87 |
for(i=0;i<count;i++)
|
|
88 |
{
|
|
89 |
item=CfgFile()->Item(KCBList,i);
|
|
90 |
if(!item)
|
|
91 |
break;
|
|
92 |
|
|
93 |
TInt condition, serviceGroup, status;
|
|
94 |
ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,condition);
|
|
95 |
if(ret!=KErrNone)
|
|
96 |
{
|
|
97 |
LOGPARSERR("condition",ret,0,&KCBList);
|
|
98 |
continue;
|
|
99 |
}
|
|
100 |
ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,serviceGroup);
|
|
101 |
if(ret!=KErrNone)
|
|
102 |
{
|
|
103 |
LOGPARSERR("serviceGroup",ret,1,&KCBList);
|
|
104 |
continue;
|
|
105 |
}
|
|
106 |
|
|
107 |
ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,status);
|
|
108 |
if(ret!=KErrNone)
|
|
109 |
{
|
|
110 |
LOGPARSERR("status",ret,2,&KCBList);
|
|
111 |
continue;
|
|
112 |
}
|
|
113 |
|
|
114 |
entry.iCondition=(RMobilePhone::TMobilePhoneCBCondition)condition;
|
|
115 |
entry.iServiceGroup=(RMobilePhone::TMobileService)serviceGroup;
|
|
116 |
entry.iStatus=(RMobilePhone::TMobilePhoneCBStatus)status;
|
|
117 |
|
|
118 |
iCBList->AddEntryL(entry);
|
|
119 |
}
|
|
120 |
}
|
|
121 |
|
|
122 |
CSimCallBarring::~CSimCallBarring()
|
|
123 |
{
|
|
124 |
delete iCBList;
|
|
125 |
if (iGetCBStatus)
|
|
126 |
iGetCBStatus->ResetAndDestroy();
|
|
127 |
delete iGetCBStatus;
|
|
128 |
}
|
|
129 |
|
|
130 |
TInt CSimCallBarring::ExtFunc(const TTsyReqHandle aReqHandle,const TInt aIpc, const TDataPackage& aPckg)
|
|
131 |
{
|
|
132 |
/**
|
|
133 |
Handles the phone based requests that apply to call barring
|
|
134 |
@param aReqHandle Handle to the request
|
|
135 |
@param aIpc request identifier
|
|
136 |
@param aPckg contains additional information for the requests
|
|
137 |
*/
|
|
138 |
|
|
139 |
TAny* dataPtr = aPckg.Ptr1();
|
|
140 |
TAny* dataPtr2 = aPckg.Ptr2();
|
|
141 |
// The following requests can be completed even if the completion of another request is pending.
|
|
142 |
switch(aIpc)
|
|
143 |
{
|
|
144 |
case EMobilePhoneSetCallBarringStatus:
|
|
145 |
return SetCallBarringStatus(aReqHandle,
|
|
146 |
reinterpret_cast<RMobilePhone::TMobilePhoneCBCondition*>(dataPtr),
|
|
147 |
reinterpret_cast<RMobilePhone::TMobilePhoneCBChangeV1*>(dataPtr2));
|
|
148 |
case EMobilePhoneSetCallBarringPassword:
|
|
149 |
return SetCallBarringPassword(aReqHandle,reinterpret_cast<RMobilePhone::TMobilePhonePasswordChangeV1*>(dataPtr));
|
|
150 |
case EMobilePhoneNotifyCallBarringStatusChange:
|
|
151 |
return NotifyCallBarringStatusChange(aReqHandle, reinterpret_cast<RMobilePhone::TMobilePhoneCBCondition*>(dataPtr));
|
|
152 |
case EMobilePhoneGetBarringStatusPhase1:
|
|
153 |
return GetCallBarringStatusPhase1(aReqHandle,
|
|
154 |
REINTERPRET_CAST(CRetrieveMobilePhoneCBList::TGetCallBarringRequest*, dataPtr),
|
|
155 |
REINTERPRET_CAST(TInt*, dataPtr2));
|
|
156 |
case EMobilePhoneGetBarringStatusPhase2:
|
|
157 |
return GetCallBarringStatusPhase2(aReqHandle,
|
|
158 |
REINTERPRET_CAST(RMobilePhone::TClientId*, dataPtr), aPckg.Des2n());
|
|
159 |
default:
|
|
160 |
break;
|
|
161 |
}
|
|
162 |
return KErrNotSupported;
|
|
163 |
}
|
|
164 |
|
|
165 |
TInt CSimCallBarring::CancelService(const TInt aIpc, const TTsyReqHandle aReqHandle)
|
|
166 |
{
|
|
167 |
/**
|
|
168 |
Cancels any phone based request regarding call barring
|
|
169 |
@param aIpc the IPC to cancel
|
|
170 |
@param aReqHandle handle to the request
|
|
171 |
*/
|
|
172 |
switch(aIpc)
|
|
173 |
{
|
|
174 |
case EMobilePhoneSetCallBarringStatus:
|
|
175 |
return SetCallBarringStatusCancel(aReqHandle);
|
|
176 |
case EMobilePhoneSetCallBarringPassword:
|
|
177 |
return SetCallBarringPasswordCancel(aReqHandle);
|
|
178 |
case EMobilePhoneNotifyCallBarringStatusChange:
|
|
179 |
return NotifyCallBarringStatusChangeCancel(aReqHandle);
|
|
180 |
default:
|
|
181 |
break;
|
|
182 |
}
|
|
183 |
return KErrNone;
|
|
184 |
}
|
|
185 |
|
|
186 |
TInt CSimCallBarring::NotifyCallBarringStatusChange(const TTsyReqHandle aReqHandle, RMobilePhone::TMobilePhoneCBCondition* aCB)
|
|
187 |
{
|
|
188 |
/**
|
|
189 |
Requests to be notified of change in the Call baring status
|
|
190 |
@param aReqHandle Handle to the request
|
|
191 |
@param aCB condition for which the client is interested in being notified
|
|
192 |
*/
|
|
193 |
__ASSERT_ALWAYS(!iCBNotification.iCBChangeInfoNotificationPending,SimPanic(ENotificationReqAlreadyOutstanding));
|
|
194 |
iCBNotification.iCBChangeInfoNotificationPending=ETrue;
|
|
195 |
iCBNotification.iCBChangeInfoReqHandle=aReqHandle;
|
|
196 |
iCBNotification.iCurrentCBCondition=aCB;
|
|
197 |
LOGCALL1("Finished CSimCallBarring::NotifyCallBarringStatusChange");
|
|
198 |
return KErrNone;
|
|
199 |
}
|
|
200 |
|
|
201 |
TInt CSimCallBarring::NotifyCallBarringStatusChangeCancel(const TTsyReqHandle aReqHandle)
|
|
202 |
{
|
|
203 |
/**
|
|
204 |
Cancels request to be notified of call barring status change
|
|
205 |
@param aReqHandle Handle to the request
|
|
206 |
*/
|
|
207 |
if(iCBNotification.iCBChangeInfoNotificationPending)
|
|
208 |
{
|
|
209 |
iCBNotification.iCBChangeInfoNotificationPending=EFalse;
|
|
210 |
iPhone->ReqCompleted(aReqHandle,KErrCancel);
|
|
211 |
}
|
|
212 |
return KErrNone;
|
|
213 |
}
|
|
214 |
|
|
215 |
TInt CSimCallBarring::SetCallBarringStatus(const TTsyReqHandle aReqHandle, RMobilePhone::TMobilePhoneCBCondition* aCB, RMobilePhone::TMobilePhoneCBChangeV1* aInfo)
|
|
216 |
{
|
|
217 |
/**
|
|
218 |
Sets the status for call barring
|
|
219 |
@param aReqHandle Handle to the request
|
|
220 |
@param aCB condition for which the client whishes to set the call barring status
|
|
221 |
@param aInfo additional parameters to set the call barring status
|
|
222 |
*/
|
|
223 |
//Password does not correspond, return KErrAccessDenied .. is that right ? Not specified in SDK!
|
|
224 |
if (iPassword != aInfo->iPassword)
|
|
225 |
{
|
|
226 |
iPhone->ReqCompleted(aReqHandle,KErrAccessDenied);
|
|
227 |
return KErrNone;
|
|
228 |
}
|
|
229 |
|
|
230 |
// make sure we know that the operation concluded sucessfully
|
|
231 |
TRAPD(ret,UpdateCBListL(aCB,aInfo));
|
|
232 |
if ( ret != KErrNone )
|
|
233 |
{
|
|
234 |
iPhone->ReqCompleted(aReqHandle,ret);
|
|
235 |
return KErrNone;
|
|
236 |
}
|
|
237 |
|
|
238 |
// otherwise proceed and notify all went well
|
|
239 |
// Notify change
|
|
240 |
if (iCBNotification.iCBChangeInfoNotificationPending)
|
|
241 |
{
|
|
242 |
*(iCBNotification.iCurrentCBCondition)=*aCB;
|
|
243 |
iCBNotification.iCBChangeInfoNotificationPending=EFalse;
|
|
244 |
iPhone->ReqCompleted(iCBNotification.iCBChangeInfoReqHandle,KErrNone);
|
|
245 |
}
|
|
246 |
|
|
247 |
iPhone->ReqCompleted(aReqHandle,KErrNone);
|
|
248 |
|
|
249 |
return KErrNone;
|
|
250 |
}
|
|
251 |
|
|
252 |
TInt CSimCallBarring::SetCallBarringStatusCancel(const TTsyReqHandle aReqHandle)
|
|
253 |
{
|
|
254 |
/**
|
|
255 |
Cancels the request to sets the status for call barring
|
|
256 |
@param aReqHandle Handle to the request
|
|
257 |
*/
|
|
258 |
|
|
259 |
iPhone->ReqCompleted(aReqHandle,KErrCancel);
|
|
260 |
return KErrNone;
|
|
261 |
}
|
|
262 |
|
|
263 |
TInt CSimCallBarring::SetCallBarringPassword(const TTsyReqHandle aReqHandle, RMobilePhone::TMobilePhonePasswordChangeV1* aInfo)
|
|
264 |
{
|
|
265 |
/**
|
|
266 |
Sets the password that prevents the call barring status to be modified
|
|
267 |
@param aReqHandle Handle to the request
|
|
268 |
@param aInfo The old and new password
|
|
269 |
*/
|
|
270 |
if (iPassword == aInfo->iOldPassword)
|
|
271 |
{
|
|
272 |
iPassword = aInfo->iNewPassword;
|
|
273 |
iPhone->ReqCompleted(aReqHandle,KErrNone);
|
|
274 |
}
|
|
275 |
else
|
|
276 |
{
|
|
277 |
iPhone->ReqCompleted(aReqHandle,KErrAccessDenied);
|
|
278 |
}
|
|
279 |
return KErrNone;
|
|
280 |
}
|
|
281 |
|
|
282 |
TInt CSimCallBarring::SetCallBarringPasswordCancel(const TTsyReqHandle aReqHandle)
|
|
283 |
{
|
|
284 |
/**
|
|
285 |
cancels a request to set the password that prevents the call barring status to be modified
|
|
286 |
@param aReqHandle Handle to the request
|
|
287 |
*/
|
|
288 |
iPhone->ReqCompleted(aReqHandle,KErrCancel);
|
|
289 |
return KErrNone;
|
|
290 |
}
|
|
291 |
|
|
292 |
|
|
293 |
const CTestConfigSection* CSimCallBarring::CfgFile()
|
|
294 |
/**
|
|
295 |
* Returns a pointer to the current configuration file section.
|
|
296 |
*
|
|
297 |
* @return CTestConfigSection A pointer to the current configuration file data section.
|
|
298 |
*/
|
|
299 |
{
|
|
300 |
return iPhone->CfgFile();
|
|
301 |
}
|
|
302 |
|
|
303 |
TInt CSimCallBarring::GetCallBarringStatusPhase1(const TTsyReqHandle aTsyReqHandle,
|
|
304 |
CRetrieveMobilePhoneCBList::TGetCallBarringRequest* aReqData,
|
|
305 |
TInt* aBufSize)
|
|
306 |
{
|
|
307 |
/**
|
|
308 |
1st phase retrieval of the the call barring status list
|
|
309 |
@param aReqHandle Handle to the request
|
|
310 |
@param aReqData information about the request
|
|
311 |
@param aBufSize Size of the buffer the client has to allocate for the 2nd pahase
|
|
312 |
*/
|
|
313 |
LOGCALL1("CSimPhone::GetCallBarringStatusPhase1");
|
|
314 |
|
|
315 |
TInt ret=KErrNone;
|
|
316 |
TInt leaveCode=KErrNone;
|
|
317 |
TRAP(leaveCode, ret=ProcessGetCallBarringStatusPhase1L(aTsyReqHandle, aReqData, aBufSize););
|
|
318 |
if (leaveCode != KErrNone)
|
|
319 |
iPhone->ReqCompleted(aTsyReqHandle,leaveCode);
|
|
320 |
|
|
321 |
LOGCALL1("CSimPhone::GetCallBarringStatusPhase1");
|
|
322 |
return ret;
|
|
323 |
}
|
|
324 |
|
|
325 |
TInt CSimCallBarring::ProcessGetCallBarringStatusPhase1L(const TTsyReqHandle aTsyReqHandle,
|
|
326 |
CRetrieveMobilePhoneCBList::TGetCallBarringRequest* aReqData,
|
|
327 |
TInt* aBufSize)
|
|
328 |
{
|
|
329 |
/** Retrieve call barring status of each line from phone,
|
|
330 |
store each CB status response as a list entry,
|
|
331 |
stream the list and then return size of this buffer to client
|
|
332 |
@param aReqHandle Handle to the request
|
|
333 |
@param aReqData information about the request
|
|
334 |
@param aBufSize Size of the buffer the client has to allocate for the 2nd pahase
|
|
335 |
*/
|
|
336 |
LOGCALL1("CSimCallBarring::ProcessGetCallBarringStatusPhase1L");
|
|
337 |
|
|
338 |
CMobilePhoneCBList* list=CMobilePhoneCBList::NewL();
|
|
339 |
CleanupStack::PushL(list);
|
|
340 |
|
|
341 |
|
|
342 |
TInt cnt=0;//Only interested by entries with a particular condition
|
|
343 |
TInt maxNum=iCBList->Enumerate();
|
|
344 |
//if testing all conditions and all CB are non-active
|
|
345 |
// then we have to return a single entry EBarAllCases and EAllServices
|
|
346 |
if ( maxNum )
|
|
347 |
{
|
|
348 |
for(TInt i=0;i<maxNum;i++)
|
|
349 |
{
|
|
350 |
if((iCBList->GetEntryL(i).iCondition == aReqData->iCondition)
|
|
351 |
||(aReqData->iCondition==RMobilePhone::EBarUnspecified))
|
|
352 |
{
|
|
353 |
list->AddEntryL(iCBList->GetEntryL(i));
|
|
354 |
cnt++;
|
|
355 |
}
|
|
356 |
}
|
|
357 |
}
|
|
358 |
else
|
|
359 |
{
|
|
360 |
// if the list is empty and the querry general then we have to return general info
|
|
361 |
if ( aReqData->iCondition == RMobilePhone::EBarUnspecified )
|
|
362 |
{
|
|
363 |
RMobilePhone::TMobilePhoneCBInfoEntryV1 entry;
|
|
364 |
|
|
365 |
// Check that the data structure is supported by the simulated TSY version
|
|
366 |
TInt err = iPhone->CheckSimTsyVersion(entry);
|
|
367 |
if(err != KErrNone)
|
|
368 |
{
|
|
369 |
iPhone->ReqCompleted(aTsyReqHandle, err);
|
|
370 |
return KErrNone;
|
|
371 |
}
|
|
372 |
|
|
373 |
entry.iCondition = RMobilePhone::EBarAllCases;
|
|
374 |
entry.iServiceGroup = RMobilePhone::EAllServices;
|
|
375 |
entry.iStatus = RMobilePhone::ECallBarringStatusNotActive;
|
|
376 |
list->AddEntryL( entry );
|
|
377 |
}
|
|
378 |
}
|
|
379 |
|
|
380 |
// Store the streamed list and the client ID
|
|
381 |
CListReadAllAttempt* read=CListReadAllAttempt::NewL(aReqData->iClient,aTsyReqHandle);
|
|
382 |
CleanupStack::PushL(read);
|
|
383 |
|
|
384 |
read->iListBuf = list->StoreLC();
|
|
385 |
CleanupStack::Pop(); // pop the CBufBase allocated by StoreLC
|
|
386 |
|
|
387 |
iGetCBStatus->AppendL(read);
|
|
388 |
CleanupStack::Pop(read); // pop the CListReadAllAttempt
|
|
389 |
|
|
390 |
// return the CBufBase’s size to client
|
|
391 |
*aBufSize=(read->iListBuf)->Size();
|
|
392 |
|
|
393 |
CleanupStack::PopAndDestroy(list); // pop&destroy list
|
|
394 |
|
|
395 |
// Complete first phase of list retrieval
|
|
396 |
iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
|
|
397 |
|
|
398 |
LOGCALL1("CSimCallBarring::ProcessGetCallBarringStatusPhase1L");
|
|
399 |
return KErrNone;
|
|
400 |
}
|
|
401 |
|
|
402 |
TInt CSimCallBarring::GetCallBarringStatusPhase2(const TTsyReqHandle aTsyReqHandle,
|
|
403 |
RMobilePhone::TClientId* aClient, TDes8* aBuf)
|
|
404 |
{
|
|
405 |
/**
|
|
406 |
2nd phase retrieval of the the call barring status list
|
|
407 |
@param aReqHandle Handle to the request
|
|
408 |
@param aClient Ponter to the client
|
|
409 |
@param aBuf Buffer containiong the call barring status list
|
|
410 |
*/
|
|
411 |
LOGCALL1("CSimCallBarring::GetCallBarringStatusPhase2");
|
|
412 |
CListReadAllAttempt* read=NULL;
|
|
413 |
// Find the get detected network attempt from this client
|
|
414 |
for (TInt i=0; i<iGetCBStatus->Count(); ++i)
|
|
415 |
{
|
|
416 |
read = iGetCBStatus->At(i);
|
|
417 |
if ((read->iClient.iSessionHandle==aClient->iSessionHandle) &&
|
|
418 |
(read->iClient.iSubSessionHandle==aClient->iSubSessionHandle))
|
|
419 |
{
|
|
420 |
TPtr8 bufPtr((read->iListBuf)->Ptr(0));
|
|
421 |
// Copy the streamed list to the client
|
|
422 |
aBuf->Copy(bufPtr);
|
|
423 |
delete read;
|
|
424 |
iGetCBStatus->Delete(i);
|
|
425 |
iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
|
|
426 |
return KErrNone;
|
|
427 |
}
|
|
428 |
}
|
|
429 |
// Should handle error case of not finding the matching client from read all phase 1
|
|
430 |
LOGCALL1("CSimCallBarring::GetCallBarringStatusPhase2");
|
|
431 |
return KErrNotFound;
|
|
432 |
}
|
|
433 |
|
|
434 |
TInt CSimCallBarring::GetCallBarringStatusCancel(const TTsyReqHandle aTsyReqHandle)
|
|
435 |
{
|
|
436 |
/*
|
|
437 |
Cancels a Request to retrieve the call barring status list
|
|
438 |
@param aReqHandle Handle to the request
|
|
439 |
*/
|
|
440 |
LOGCALL1("CSimCallBarring::GetCallBarringStatusCancel");
|
|
441 |
iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
|
|
442 |
// Remove the read all attempt from iGetCBStatus
|
|
443 |
CListReadAllAttempt* read=NULL;
|
|
444 |
for (TInt i=0; i<iGetCBStatus->Count(); ++i)
|
|
445 |
{
|
|
446 |
read = iGetCBStatus->At(i);
|
|
447 |
if (read->iReqHandle == aTsyReqHandle)
|
|
448 |
{
|
|
449 |
delete read;
|
|
450 |
iGetCBStatus->Delete(i);
|
|
451 |
break;
|
|
452 |
}
|
|
453 |
}
|
|
454 |
iPhone->ReqCompleted(aTsyReqHandle,KErrCancel);
|
|
455 |
LOGCALL1("CSimCallBarring::GetCallBarringStatusCancel");
|
|
456 |
return KErrNone;
|
|
457 |
}
|
|
458 |
|
|
459 |
// some useful functions for checking the type of conditions
|
|
460 |
inline TBool IsOutgoingCondition( RMobilePhone::TMobilePhoneCBCondition aCondition )
|
|
461 |
{
|
|
462 |
return ( (aCondition)==RMobilePhone::EBarAllOutgoing ||
|
|
463 |
(aCondition)==RMobilePhone::EBarOutgoingInternational ||
|
|
464 |
(aCondition)==RMobilePhone::EBarOutgoingInternationalExHC );
|
|
465 |
}
|
|
466 |
|
|
467 |
inline TBool IsIncomingCondition( RMobilePhone::TMobilePhoneCBCondition aCondition )
|
|
468 |
{
|
|
469 |
return ( (aCondition)==RMobilePhone::EBarAllIncoming ||
|
|
470 |
(aCondition)==RMobilePhone::EBarIncomingRoaming );
|
|
471 |
}
|
|
472 |
|
|
473 |
inline TBool IsDeactivationConditionOnly( RMobilePhone::TMobilePhoneCBCondition aCondition )
|
|
474 |
{
|
|
475 |
return ( (aCondition)==RMobilePhone::EBarAllCases ||
|
|
476 |
(aCondition)==RMobilePhone::EBarAllOutgoingServices ||
|
|
477 |
(aCondition)==RMobilePhone::EBarAllIncomingServices );
|
|
478 |
}
|
|
479 |
|
|
480 |
inline void SplitOneEntryIntoSeparateGroupsL(
|
|
481 |
CMobilePhoneCBList* aCBList,
|
|
482 |
RMobilePhone::TMobilePhoneCBInfoEntryV1 aOrigEntry,
|
|
483 |
RMobilePhone::TMobileService aExceptServiceGroup
|
|
484 |
)
|
|
485 |
{
|
|
486 |
/*
|
|
487 |
Splits one entry valid for all basic service groups into individual entries
|
|
488 |
and places them into a CMobilePhoneCBList. This excludes one service group.
|
|
489 |
@param aCBList The list to which to store the entries
|
|
490 |
@param aOrigEntry The original entry; details of which should be passed to individual group entries
|
|
491 |
@param aExceptServiceGroup The group which has to be avoided
|
|
492 |
*/
|
|
493 |
// we have to split the entry into entries
|
|
494 |
// per group with the same condition; excluding the specified service group
|
|
495 |
RMobilePhone::TMobilePhoneCBInfoEntryV1 anotherEntry = aOrigEntry;
|
|
496 |
|
|
497 |
// NOTE: A call to CheckSimTsyVersion must be inserted here if there is a
|
|
498 |
// change to the version of the structure declared above
|
|
499 |
|
|
500 |
//anotherEntry.iCondition = aOrigEntry.iCondition;
|
|
501 |
//anotherEntry.iStatus = RMobilePhone::ECallBarringStatusActive;
|
|
502 |
RMobilePhone::TMobileService service;
|
|
503 |
|
|
504 |
for (TInt i = KMobServiceIndxStart;i <= KMobServiceIndxEnd;i++)
|
|
505 |
{
|
|
506 |
service=static_cast<RMobilePhone::TMobileService>(i);
|
|
507 |
if( service != aExceptServiceGroup )
|
|
508 |
{
|
|
509 |
anotherEntry.iServiceGroup=service;
|
|
510 |
aCBList->AddEntryL(anotherEntry);
|
|
511 |
}
|
|
512 |
}//end for (another)
|
|
513 |
}
|
|
514 |
|
|
515 |
void CSimCallBarring::UpdateCBListL(RMobilePhone::TMobilePhoneCBCondition* aCB, RMobilePhone::TMobilePhoneCBChangeV1* aCBInfo )
|
|
516 |
{
|
|
517 |
/*
|
|
518 |
Updates the status of call barring.
|
|
519 |
@param aCB condition to set
|
|
520 |
@param aCBInfo details of the call barring status to set
|
|
521 |
*/
|
|
522 |
// no sense processing if either condition or change info are NULLS
|
|
523 |
User::LeaveIfNull(aCBInfo);
|
|
524 |
User::LeaveIfNull(aCB);
|
|
525 |
|
|
526 |
// check for more conditions as some of the combinations really do not make sense
|
|
527 |
// and no need to do processing in this case
|
|
528 |
if (*aCB == RMobilePhone::EBarUnspecified)
|
|
529 |
User::Leave(KErrArgument);
|
|
530 |
if ( IsDeactivationConditionOnly(*aCB)
|
|
531 |
&& ( !( (aCBInfo->iAction == RMobilePhone::EServiceActionDeactivate )
|
|
532 |
|| (aCBInfo->iAction == RMobilePhone::EServiceActionErase ))))
|
|
533 |
User::Leave(KErrArgument);
|
|
534 |
|
|
535 |
//Lets do some work then
|
|
536 |
RMobilePhone::TMobilePhoneCBInfoEntryV1 theNewEntry;
|
|
537 |
|
|
538 |
theNewEntry.iCondition = *aCB;
|
|
539 |
theNewEntry.iServiceGroup = aCBInfo->iServiceGroup;
|
|
540 |
switch (aCBInfo->iAction)
|
|
541 |
{
|
|
542 |
case RMobilePhone::EServiceActionRegister:
|
|
543 |
case RMobilePhone::EServiceActionActivate:
|
|
544 |
theNewEntry.iStatus= RMobilePhone::ECallBarringStatusActive;
|
|
545 |
break;
|
|
546 |
case RMobilePhone::EServiceActionDeactivate:
|
|
547 |
case RMobilePhone::EServiceActionErase:
|
|
548 |
theNewEntry.iStatus= RMobilePhone::ECallBarringStatusNotActive;
|
|
549 |
break;
|
|
550 |
case RMobilePhone::EServiceActionUnspecified:
|
|
551 |
default:
|
|
552 |
// no sense doing any further operation - leave
|
|
553 |
User::Leave(KErrArgument);
|
|
554 |
break;
|
|
555 |
}
|
|
556 |
|
|
557 |
// retain prev version of the list in local variable and in Cleanup stack
|
|
558 |
CMobilePhoneCBList* thePrevCBList = CMobilePhoneCBList::NewL();
|
|
559 |
CleanupStack::PushL(thePrevCBList);
|
|
560 |
// copy existing data into the temp storage
|
|
561 |
for (TInt indx=0; indx<iCBList->Enumerate(); indx++)
|
|
562 |
{
|
|
563 |
thePrevCBList->AddEntryL(iCBList->GetEntryL(indx));
|
|
564 |
}
|
|
565 |
delete iCBList;
|
|
566 |
iCBList = NULL;
|
|
567 |
// get a hold of it in a local variable
|
|
568 |
iCBList = CMobilePhoneCBList::NewL();
|
|
569 |
// get a hold of it in a local variable
|
|
570 |
CMobilePhoneCBList* theNewCBList = iCBList;
|
|
571 |
RMobilePhone::TMobilePhoneCBInfoEntryV1 entry;
|
|
572 |
|
|
573 |
TInt count = thePrevCBList->Enumerate();
|
|
574 |
|
|
575 |
if (theNewEntry.iStatus == RMobilePhone::ECallBarringStatusActive)
|
|
576 |
{
|
|
577 |
if (theNewEntry.iServiceGroup==RMobilePhone::EAllServices)
|
|
578 |
{
|
|
579 |
//Activate all conds
|
|
580 |
//action is to ActivateAllServices with a particular condition;
|
|
581 |
//Only copy entries with a different condition
|
|
582 |
for (TInt i = 0; i<count; i++)
|
|
583 |
{
|
|
584 |
entry = thePrevCBList->GetEntryL(i);
|
|
585 |
//check if the new entry will encompass conditions already defined
|
|
586 |
// if it does the existing entry is not needed
|
|
587 |
if (!(
|
|
588 |
theNewEntry.iCondition==entry.iCondition
|
|
589 |
||
|
|
590 |
( IsOutgoingCondition(entry.iCondition) && IsOutgoingCondition(theNewEntry.iCondition))
|
|
591 |
||
|
|
592 |
( IsIncomingCondition(entry.iCondition) && IsIncomingCondition(theNewEntry.iCondition))
|
|
593 |
))
|
|
594 |
theNewCBList->AddEntryL(entry);
|
|
595 |
}//end for
|
|
596 |
theNewCBList->AddEntryL(theNewEntry);
|
|
597 |
}
|
|
598 |
else
|
|
599 |
{
|
|
600 |
//ActivateOne;
|
|
601 |
// working under the assumption that if EBarOutgoingInternational is enabled
|
|
602 |
// for EAllServices then setting the fax group, for example to EBarOutgoingInternational
|
|
603 |
// specifically, will be ignored due to inclusion. Also setting the same condition
|
|
604 |
// for the same service group(s) again will be ignored.
|
|
605 |
TBool addNewElem = TRUE;
|
|
606 |
|
|
607 |
for (TInt i = 0; i<count; i++)
|
|
608 |
{
|
|
609 |
entry = thePrevCBList->GetEntryL(i);
|
|
610 |
// are in the same direction?
|
|
611 |
if ( (IsOutgoingCondition(theNewEntry.iCondition) && IsOutgoingCondition(entry.iCondition))
|
|
612 |
|| (IsIncomingCondition(theNewEntry.iCondition) && IsIncomingCondition(entry.iCondition)))
|
|
613 |
{
|
|
614 |
// they are in the same direction
|
|
615 |
// is the current entry specific to a group or not ?
|
|
616 |
if (entry.iServiceGroup != RMobilePhone::EAllServices)
|
|
617 |
{
|
|
618 |
if (theNewEntry.iServiceGroup != entry.iServiceGroup)
|
|
619 |
theNewCBList->AddEntryL(entry);
|
|
620 |
}
|
|
621 |
else
|
|
622 |
{
|
|
623 |
// the entry is for all groups
|
|
624 |
if (theNewEntry.iCondition == entry.iCondition)
|
|
625 |
{
|
|
626 |
// the group already precludes this condition;
|
|
627 |
// just add the existing
|
|
628 |
theNewCBList->AddEntryL(entry);
|
|
629 |
addNewElem = FALSE;
|
|
630 |
}
|
|
631 |
else
|
|
632 |
{
|
|
633 |
// we have to split the entry into entries
|
|
634 |
// per group with the same condition
|
|
635 |
SplitOneEntryIntoSeparateGroupsL(
|
|
636 |
theNewCBList, entry, theNewEntry.iServiceGroup
|
|
637 |
);
|
|
638 |
}// end split entry
|
|
639 |
}
|
|
640 |
}
|
|
641 |
else
|
|
642 |
{
|
|
643 |
// they are in different directions
|
|
644 |
// no need to check further; just add it
|
|
645 |
theNewCBList->AddEntryL(entry);
|
|
646 |
}//end are in the same direction?
|
|
647 |
}// for loop
|
|
648 |
if (addNewElem)
|
|
649 |
{
|
|
650 |
theNewCBList->AddEntryL(theNewEntry);
|
|
651 |
}
|
|
652 |
}//end else
|
|
653 |
}
|
|
654 |
else //deactivate
|
|
655 |
{
|
|
656 |
if (
|
|
657 |
(theNewEntry.iServiceGroup==RMobilePhone::EAllServices)
|
|
658 |
&&(theNewEntry.iCondition==RMobilePhone::EBarAllCases)
|
|
659 |
)
|
|
660 |
;//Deactivate all conditions: do nothing, list is empty.
|
|
661 |
else
|
|
662 |
{
|
|
663 |
for (TInt i = 0; i<count; i++)
|
|
664 |
{
|
|
665 |
entry = thePrevCBList->GetEntryL(i);
|
|
666 |
|
|
667 |
if (theNewEntry.iCondition == RMobilePhone::EBarAllCases
|
|
668 |
||
|
|
669 |
(( theNewEntry.iCondition == RMobilePhone::EBarAllOutgoingServices || IsOutgoingCondition(theNewEntry.iCondition))
|
|
670 |
&& IsOutgoingCondition(entry.iCondition))
|
|
671 |
||
|
|
672 |
((theNewEntry.iCondition == RMobilePhone::EBarAllIncomingServices || IsIncomingCondition(theNewEntry.iCondition))
|
|
673 |
&& IsIncomingCondition(entry.iCondition)))
|
|
674 |
{
|
|
675 |
if(theNewEntry.iServiceGroup!=RMobilePhone::EAllServices
|
|
676 |
&& entry.iServiceGroup==RMobilePhone::EAllServices)
|
|
677 |
{
|
|
678 |
SplitOneEntryIntoSeparateGroupsL(
|
|
679 |
theNewCBList, entry, theNewEntry.iServiceGroup
|
|
680 |
);
|
|
681 |
}//end if(create others)
|
|
682 |
else
|
|
683 |
{//action applies to different service group
|
|
684 |
if((theNewEntry.iServiceGroup!=RMobilePhone::EAllServices )
|
|
685 |
&& (theNewEntry.iServiceGroup!=entry.iServiceGroup))
|
|
686 |
theNewCBList->AddEntryL(entry);
|
|
687 |
}
|
|
688 |
|
|
689 |
}//end if
|
|
690 |
else
|
|
691 |
{//action applies to different condition
|
|
692 |
theNewCBList->AddEntryL(entry);
|
|
693 |
}//end else
|
|
694 |
}//end for (entries)
|
|
695 |
}//end else(all)
|
|
696 |
}//end else(deactivate)
|
|
697 |
|
|
698 |
//destroy the previous version, the local theNewCBList will be destroyed
|
|
699 |
CleanupStack::PopAndDestroy(thePrevCBList);
|
|
700 |
}
|