|
1 // Copyright (c) 2006-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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 */ |
|
19 #include "ss_tiermanagerutils.h" |
|
20 |
|
21 #include <comms-infras/ss_log.h> |
|
22 #include <comms-infras/ss_metaconnprov.h> |
|
23 #include <in_sock.h> //KAfInet |
|
24 #include <es_connpref.h> |
|
25 #include <commsdattypesv1_1.h> // CommsDat |
|
26 #include <comms-infras/commsdatschema.h> // CommsDat |
|
27 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
28 #include <commsdattypesv1_1_partner.h> |
|
29 #include <commsdattypesv1_1_internal.h> |
|
30 #include <es_sock_internal.h> |
|
31 #endif |
|
32 #include <commdbconnpref.h> //TCommDbConnPref |
|
33 #include <comms-infras/ss_thread.h> |
|
34 #include <comms-infras/esock_params.h> //TConnAPPref |
|
35 #include <comms-infras/ss_mcprnodemessages.h> //RConnPrefList |
|
36 #include <agentdialog.h> //TConnectionPrefs |
|
37 #include <elements/sd_std.h> //RTierThreadMap |
|
38 #include "ss_tierthreadmap.h" |
|
39 |
|
40 |
|
41 #ifdef _DEBUG |
|
42 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
|
43 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
|
44 _LIT(KSpecAssert_ESockSSockTrMngU, "ESockSSockTrMngU"); |
|
45 #endif |
|
46 |
|
47 using namespace ESock; |
|
48 using namespace CommsDat; |
|
49 using namespace Den; |
|
50 using namespace CommsFW; |
|
51 |
|
52 |
|
53 /** |
|
54 TierManagerUtils panic category |
|
55 */ |
|
56 _LIT(KTierManagerUtils, "TierManagerUtils"); |
|
57 |
|
58 const TInt KEsockLinkFlag = 0x80000000; |
|
59 |
|
60 /** Panics generated by the Comms Channels |
|
61 */ |
|
62 enum TTierManagerUtilsPanics |
|
63 { |
|
64 EInvalidTierId = 0, |
|
65 EInvalidAccessPointId = 1, |
|
66 EInvalidCprId = 2, |
|
67 EInvalidSCprId = 3, |
|
68 EInvalidIapId = 4, |
|
69 EInvalidProtocolId = 5, |
|
70 EInvalidAPSelPolId = 6 |
|
71 }; |
|
72 |
|
73 //private, not exported, used with legacy implicit flows only |
|
74 TUid TierManagerUtils::MapTierIdsForLegacyImplicitFlowsL(TUid aTierId, TUint aProtocol) |
|
75 { |
|
76 //If necessary, map the KAfInet to a default tier |
|
77 TUid mappedTier = MapTierIdsL(aTierId, aProtocol); |
|
78 |
|
79 //Now find the tier ID. |
|
80 CMDBSession* dbs = CMDBSession::NewLC(KCDVersion1_2); |
|
81 CCDTierRecord* tierRec = NULL; |
|
82 TRAP_IGNORE(tierRec = TierManagerUtils::LoadTierRecordL(mappedTier, *dbs)); |
|
83 if(tierRec==NULL) |
|
84 { |
|
85 if(aTierId.iUid != KAfInet) |
|
86 { |
|
87 // In the absence of a trier record for this address family try using the KAfInet one |
|
88 // This covers the case of legacy protocols such as SMS which only need the top tier |
|
89 // The protocol argument is irrelevent for this. |
|
90 mappedTier = TierManagerUtils::MapTierIdsL(TUid::Uid(KAfInet), 0); |
|
91 tierRec = TierManagerUtils::LoadTierRecordL(mappedTier, *dbs); |
|
92 } |
|
93 else |
|
94 { |
|
95 User::Leave(KErrNotFound); |
|
96 } |
|
97 } |
|
98 |
|
99 delete tierRec; |
|
100 CleanupStack::PopAndDestroy(dbs); |
|
101 return mappedTier; |
|
102 } |
|
103 |
|
104 //only called from functions which are returning AP fields. |
|
105 TInt TierManagerUtils::ResolveDefAPtoTagL(TInt aElementId, CommsDat::CMDBSession& aDbs ) |
|
106 { |
|
107 CMDBField<TInt>* iRecordTag = new (ELeave) CMDBField<TInt>(aElementId | KCDTIdRecordTag); |
|
108 CleanupStack::PushL(iRecordTag); |
|
109 |
|
110 iRecordTag->LoadL(aDbs); |
|
111 |
|
112 TInt temp = *iRecordTag; |
|
113 CleanupStack::PopAndDestroy(iRecordTag); |
|
114 return temp; |
|
115 } |
|
116 |
|
117 //Here we have an AccessPoint record Id. Based on that the TagId of the record |
|
118 //should be given back... |
|
119 EXPORT_C TInt TierManagerUtils::ConvertSNAPPrefToTagIdL(TUint aSNAPPref, CommsDat::CMDBSession& aDbs) |
|
120 { |
|
121 CMDBField<TInt>* apTag = new (ELeave) CMDBField<TInt>(KCDTIdAccessPointRecord | KCDTIdRecordTag); |
|
122 CleanupStack::PushL(apTag); |
|
123 apTag->SetRecordId(aSNAPPref); |
|
124 |
|
125 apTag->LoadL(aDbs); |
|
126 |
|
127 TInt temp = *apTag; |
|
128 CleanupStack::PopAndDestroy(apTag); |
|
129 return temp; |
|
130 } |
|
131 |
|
132 EXPORT_C TUid TierManagerUtils::MapElementIdToTagId(TUint aElementId, CommsDat::CMDBSession& aDbs) |
|
133 { |
|
134 CMDBField<TInt>* recordTag = new (ELeave) CMDBField<TInt>((aElementId & KCDMaskShowRecordType) | |
|
135 (aElementId & KCDMaskShowRecordId) | |
|
136 KCDTIdRecordTag); |
|
137 CleanupStack::PushL(recordTag); |
|
138 |
|
139 recordTag->LoadL(aDbs); |
|
140 |
|
141 TUid temp; |
|
142 temp.iUid = *recordTag; |
|
143 |
|
144 CleanupStack::PopAndDestroy(recordTag); |
|
145 |
|
146 return temp; |
|
147 } |
|
148 |
|
149 // |
|
150 //CTierManagerUtils - for commsdat manipulation |
|
151 EXPORT_C TUid TierManagerUtils::MapTierIdsL(TUid aTierId, TUint /*aProtocol*/) |
|
152 { |
|
153 // Defined here to avoid a dependency on SIP headers(sipconnpref.h) |
|
154 const TUint KAFSip = 0x10000; |
|
155 const TUint KAFSipTierMgrFactoryImplementionUid = 0x200041F7; |
|
156 |
|
157 //Maps legacy or other thier ids (like the old address family) to new tier ids. |
|
158 switch (aTierId.iUid) |
|
159 { |
|
160 case KAFSip: |
|
161 return TUid::Uid(KAFSipTierMgrFactoryImplementionUid); |
|
162 } |
|
163 |
|
164 return aTierId; |
|
165 } |
|
166 |
|
167 |
|
168 EXPORT_C CCDTierRecord* TierManagerUtils::LoadTierRecordL(TUid aTierId, CMDBSession& aDbs) |
|
169 { |
|
170 __ASSERT_ALWAYS(aTierId.iUid>0,User::Panic(KTierManagerUtils,EInvalidTierId)); |
|
171 |
|
172 CCDTierRecord* tierRec = static_cast<CCDTierRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdTierRecord)); |
|
173 CleanupStack::PushL(tierRec); |
|
174 tierRec->iRecordTag = aTierId.iUid; |
|
175 |
|
176 TBool found = tierRec->FindL(aDbs); |
|
177 |
|
178 if (!found) |
|
179 { |
|
180 User::Leave(KErrNotFound); |
|
181 } |
|
182 if (static_cast<TInt>(tierRec->iDefaultAccessPoint)!=0) |
|
183 { |
|
184 TInt defTierElemId = ResolveDefAPtoTagL(static_cast<TInt>(tierRec->iDefaultAccessPoint), aDbs ); |
|
185 tierRec->iDefaultAccessPoint = defTierElemId; |
|
186 } |
|
187 |
|
188 __ASSERT_DEBUG(tierRec->iTierManagerName.TypeId() == KCDTIdTierManagerName, User::Panic(KSpecAssert_ESockSSockTrMngU, 1)); // Panics if built against incorrect CommsDat. |
|
189 CleanupStack::Pop(tierRec); |
|
190 return tierRec; |
|
191 } |
|
192 |
|
193 |
|
194 EXPORT_C CCDTierRecord* TierManagerUtils::LoadTierRecordL(CommsDat::TMDBElementId aTierId, CommsDat::CMDBSession& aDbs) |
|
195 { |
|
196 __ASSERT_ALWAYS(aTierId>0,User::Panic(KTierManagerUtils,EInvalidTierId)); |
|
197 |
|
198 CCDTierRecord* tierRec = static_cast<CCDTierRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdTierRecord)); |
|
199 CleanupStack::PushL(tierRec); |
|
200 |
|
201 tierRec->SetRecordId(aTierId); |
|
202 |
|
203 tierRec->LoadL(aDbs); |
|
204 |
|
205 if (static_cast<TInt>(tierRec->iDefaultAccessPoint)!=0) |
|
206 { |
|
207 TInt defTierElemId = ResolveDefAPtoTagL(static_cast<TInt>(tierRec->iDefaultAccessPoint), aDbs ); |
|
208 tierRec->iDefaultAccessPoint = defTierElemId; |
|
209 } |
|
210 __ASSERT_DEBUG(tierRec->iTierManagerName.TypeId() == KCDTIdTierManagerName, User::Panic(KSpecAssert_ESockSSockTrMngU, 2)); // Panics if built against incorrect CommsDat. |
|
211 CleanupStack::Pop(tierRec); |
|
212 return tierRec; |
|
213 } |
|
214 |
|
215 EXPORT_C CCDAPPrioritySelectionPolicyRecord* TierManagerUtils::LoadAPPrioritySelRecordL(CommsDat::TMDBElementId aApSelId, CommsDat::CMDBSession& aDbs) |
|
216 { |
|
217 __ASSERT_ALWAYS(aApSelId>0,User::Panic(KTierManagerUtils,EInvalidAPSelPolId)); |
|
218 |
|
219 CCDAPPrioritySelectionPolicyRecord* apSelRec = static_cast<CCDAPPrioritySelectionPolicyRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdApPrioritySelectionPolicyRecord)); |
|
220 CleanupStack::PushL(apSelRec); |
|
221 |
|
222 apSelRec->SetRecordId(aApSelId); |
|
223 |
|
224 apSelRec->LoadL(aDbs); |
|
225 |
|
226 CleanupStack::Pop(apSelRec); |
|
227 return apSelRec; |
|
228 } |
|
229 |
|
230 |
|
231 EXPORT_C CCDAccessPointRecord* TierManagerUtils::LoadAccessPointRecordL(TUint aAccessPointId, CMDBSession& aDbs) |
|
232 { |
|
233 /** |
|
234 There are cases when ESock tries to load an access point record based on tag id but this id |
|
235 is got as a TUint parameter. The conversion is here. |
|
236 */ |
|
237 __ASSERT_ALWAYS(aAccessPointId>0,User::Panic(KTierManagerUtils,EInvalidAccessPointId)); |
|
238 |
|
239 TUid temp; |
|
240 temp.iUid = aAccessPointId; |
|
241 return LoadAccessPointRecordL(temp, aDbs); |
|
242 } |
|
243 |
|
244 |
|
245 EXPORT_C CCDAccessPointRecord* TierManagerUtils::LoadAccessPointRecordL(TUid aAccessPointId, CMDBSession& aDbs) |
|
246 { |
|
247 __ASSERT_ALWAYS(aAccessPointId.iUid>0,User::Panic(KTierManagerUtils,EInvalidAccessPointId)); |
|
248 |
|
249 CCDAccessPointRecord* apRec = static_cast<CCDAccessPointRecord*>(CCDTierRecord::RecordFactoryL(KCDTIdAccessPointRecord)); |
|
250 CleanupStack::PushL(apRec); |
|
251 apRec->iRecordTag = aAccessPointId.iUid; |
|
252 |
|
253 TBool found = apRec->FindL(aDbs); |
|
254 |
|
255 if (!found) |
|
256 { |
|
257 User::Leave(KErrNotFound); |
|
258 } |
|
259 __ASSERT_DEBUG(apRec->iTier.TypeId() == KCDTIdTier, User::Panic(KSpecAssert_ESockSSockTrMngU, 3)); // Panics if built against incorrect CommsDat. |
|
260 CleanupStack::Pop(apRec); |
|
261 return apRec; |
|
262 } |
|
263 |
|
264 |
|
265 EXPORT_C CCDAccessPointRecord* TierManagerUtils::LoadAccessPointRecordL(const TProviderInfo& aProviderInfo, CMDBSession& aDbs) |
|
266 { |
|
267 CCDAccessPointRecord* apRec = LoadAccessPointRecordL(aProviderInfo.APId(),aDbs); |
|
268 __ASSERT_DEBUG(aProviderInfo.TierId().iUid==apRec->iTier, User::Panic(KSpecAssert_ESockSSockTrMngU, 4)); |
|
269 return apRec; |
|
270 } |
|
271 |
|
272 EXPORT_C CMDBRecordSet<CCDAccessPointRecord>* TierManagerUtils::LoadAccessPointRecordsL( |
|
273 TUid aTierId, CMDBSession& aDbs) |
|
274 { |
|
275 __ASSERT_ALWAYS(aTierId.iUid>0,User::Panic(KTierManagerUtils,EInvalidTierId)); |
|
276 |
|
277 //Load all AP records that belong to this tier. |
|
278 CMDBRecordSet<CCDAccessPointRecord>* apSet = new(ELeave) CMDBRecordSet<CCDAccessPointRecord>(KCDTIdAccessPointRecord); |
|
279 CleanupStack::PushL(apSet); |
|
280 |
|
281 //Create first record for priming |
|
282 CCDAccessPointRecord* apRec = static_cast<CCDAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdAccessPointRecord)); |
|
283 CleanupStack::PushL(apRec); |
|
284 |
|
285 //Add record to record set |
|
286 apRec->iTier = aTierId.iUid | KEsockLinkFlag; |
|
287 apSet->iRecords.AppendL(apRec); |
|
288 CleanupStack::Pop(apRec); |
|
289 |
|
290 //Load set |
|
291 TBool returned = apSet->FindL(aDbs); |
|
292 |
|
293 //Check if apRec has been overwritten |
|
294 if( ! returned ) |
|
295 { |
|
296 User::Leave(KErrNotFound); |
|
297 } |
|
298 |
|
299 CleanupStack::Pop(apSet); |
|
300 return apSet; |
|
301 } |
|
302 |
|
303 EXPORT_C CMDBRecordSet<CCDAccessPointRecord>* TierManagerUtils::LoadAccessPointRecordsL( |
|
304 TUid aTierId, const RArray<TAccessPointInfo>& aApIdsToMatch, CMDBSession& aDbs) |
|
305 { |
|
306 if(aApIdsToMatch.Count()) |
|
307 { |
|
308 CMDBRecordSet<CCDAccessPointRecord>* apSet = new(ELeave) CMDBRecordSet<CCDAccessPointRecord>(KCDTIdAccessPointRecord); |
|
309 CleanupStack::PushL(apSet); |
|
310 |
|
311 CCDAccessPointRecord* apRec = 0; |
|
312 TInt i=0; |
|
313 for( ; i<aApIdsToMatch.Count() ; ++i ) |
|
314 { |
|
315 if(apRec == 0) |
|
316 { |
|
317 apRec = static_cast<CCDAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdAccessPointRecord)); |
|
318 CleanupStack::PushL(apRec); |
|
319 } |
|
320 apRec->iTier = aTierId.iUid | KEsockLinkFlag; |
|
321 |
|
322 apRec->iRecordTag = aApIdsToMatch[i].AccessPoint(); |
|
323 TBool returned = apRec->FindL(aDbs); |
|
324 if(returned) |
|
325 { |
|
326 apSet->iRecords.AppendL(apRec); |
|
327 CleanupStack::Pop(apRec); |
|
328 apRec = 0; // so a new one gets created on next iteration |
|
329 } |
|
330 } |
|
331 if(apRec) |
|
332 { |
|
333 CleanupStack::PopAndDestroy(apRec); |
|
334 } |
|
335 CleanupStack::Pop(apSet); |
|
336 return apSet; |
|
337 } |
|
338 else |
|
339 { |
|
340 // empty set means no filtering |
|
341 return LoadAccessPointRecordsL(aTierId,aDbs); |
|
342 } |
|
343 } |
|
344 |
|
345 EXPORT_C CCDMCprRecord* TierManagerUtils::LoadMCprRecordL(TUint aMCprId, CMDBSession& aDbs) |
|
346 { |
|
347 CCDMCprRecord* mcprRec = static_cast<CCDMCprRecord*>(CCDMCprRecord::RecordFactoryL(KCDTIdMCprRecord)); |
|
348 CleanupStack::PushL(mcprRec); |
|
349 |
|
350 mcprRec->SetRecordId(aMCprId); |
|
351 |
|
352 mcprRec->LoadL(aDbs); |
|
353 |
|
354 __ASSERT_DEBUG(mcprRec->iMCprUid.TypeId() == KCDTIdMCprUid, User::Panic(KSpecAssert_ESockSSockTrMngU, 5)); // Panics if built against incorrect CommsDat. |
|
355 CleanupStack::Pop(mcprRec); |
|
356 return mcprRec; |
|
357 } |
|
358 |
|
359 EXPORT_C CCDMCprRecord* TierManagerUtils::LoadMCprRecordL(TUid aMCprFactoryUid, CMDBSession& aDbs) |
|
360 { |
|
361 CCDMCprRecord* mcprRec = static_cast<CCDMCprRecord*>(CCDMCprRecord::RecordFactoryL(KCDTIdMCprRecord)); |
|
362 CleanupStack::PushL(mcprRec); |
|
363 mcprRec->iMCprUid = aMCprFactoryUid.iUid; |
|
364 TBool found = mcprRec->FindL(aDbs); |
|
365 |
|
366 if (!found) |
|
367 { |
|
368 User::Leave(KErrNotFound); |
|
369 } |
|
370 __ASSERT_DEBUG(mcprRec->iMCprUid.TypeId() == KCDTIdMCprUid, User::Panic(KSpecAssert_ESockSSockTrMngU, 6)); // Panics if built against incorrect CommsDat. |
|
371 CleanupStack::Pop(mcprRec); |
|
372 return mcprRec; |
|
373 } |
|
374 |
|
375 EXPORT_C CCDCprRecord* TierManagerUtils::LoadCprRecordL(TUint aCprId, CMDBSession& aDbs) |
|
376 { |
|
377 __ASSERT_ALWAYS(aCprId>0,User::Panic(KTierManagerUtils,EInvalidCprId)); |
|
378 |
|
379 CCDCprRecord* cprRec = static_cast<CCDCprRecord*>(CCDCprRecord::RecordFactoryL(KCDTIdCprRecord)); |
|
380 CleanupStack::PushL(cprRec); |
|
381 |
|
382 cprRec->SetRecordId(aCprId); |
|
383 |
|
384 cprRec->LoadL(aDbs); |
|
385 |
|
386 __ASSERT_DEBUG(cprRec->iCprUid.TypeId() == KCDTIdCprUid, User::Panic(KSpecAssert_ESockSSockTrMngU, 7)); // Panics if built against incorrect CommsDat. |
|
387 CleanupStack::Pop(cprRec); |
|
388 return cprRec; |
|
389 } |
|
390 |
|
391 EXPORT_C CCDSCprRecord* TierManagerUtils::LoadSCprRecordL(TUint aSCprId, CMDBSession& aDbs) |
|
392 { |
|
393 __ASSERT_ALWAYS(aSCprId>0,User::Panic(KTierManagerUtils,EInvalidSCprId)); |
|
394 |
|
395 CCDSCprRecord* scprRec = static_cast<CCDSCprRecord*>(CCDSCprRecord::RecordFactoryL(KCDTIdSCprRecord)); |
|
396 CleanupStack::PushL(scprRec); |
|
397 |
|
398 scprRec->SetRecordId(aSCprId); |
|
399 |
|
400 scprRec->LoadL(aDbs); |
|
401 |
|
402 __ASSERT_DEBUG(scprRec->iSCprUid.TypeId() == KCDTIdSCprUid, User::Panic(KSpecAssert_ESockSSockTrMngU, 8)); // Panics if built against incorrect CommsDat. |
|
403 CleanupStack::Pop(scprRec); |
|
404 return scprRec; |
|
405 } |
|
406 |
|
407 EXPORT_C CCDProtocolRecord* TierManagerUtils::LoadProtocolRecordL(TUint aProtocolId, CMDBSession& aDbs) |
|
408 { |
|
409 __ASSERT_ALWAYS(aProtocolId>0,User::Panic(KTierManagerUtils,EInvalidProtocolId)); |
|
410 |
|
411 CCDProtocolRecord* prtRec = static_cast<CCDProtocolRecord*>(CCDTierRecord::RecordFactoryL(KCDTIdProtocolRecord)); |
|
412 CleanupStack::PushL(prtRec); |
|
413 |
|
414 prtRec->SetRecordId(aProtocolId); |
|
415 |
|
416 prtRec->LoadL(aDbs); |
|
417 |
|
418 __ASSERT_DEBUG(prtRec->iProtocolUid.TypeId() == KCDTIdProtocolUid, User::Panic(KSpecAssert_ESockSSockTrMngU, 9)); // Panics if built against incorrect CommsDat. |
|
419 CleanupStack::Pop(prtRec); |
|
420 return prtRec; |
|
421 } |
|
422 |
|
423 EXPORT_C CCDGlobalSettingsRecord* TierManagerUtils::LoadGlobalSettingsRecordL(CMDBSession& aDbs) |
|
424 { |
|
425 CCDGlobalSettingsRecord* gsRec = static_cast<CCDGlobalSettingsRecord*>(CCDGlobalSettingsRecord::RecordFactoryL(KCDTIdGlobalSettingsRecord)); |
|
426 CleanupStack::PushL(gsRec); |
|
427 gsRec->SetRecordId(1); |
|
428 gsRec->LoadL(aDbs); |
|
429 __ASSERT_DEBUG(gsRec->iDefaultTier.TypeId() == KCDTIdDefaultTier, User::Panic(KSpecAssert_ESockSSockTrMngU, 10)); // Panics if built against incorrect CommsDat. |
|
430 CleanupStack::Pop(gsRec); |
|
431 return gsRec; |
|
432 } |
|
433 |
|
434 EXPORT_C CCDIAPRecord* TierManagerUtils::LoadIapRecordL(TUint aIapId, CMDBSession& aDbs) |
|
435 { |
|
436 __ASSERT_ALWAYS(aIapId>0,User::Panic(KTierManagerUtils,EInvalidIapId)); |
|
437 |
|
438 CCDIAPRecord* iapRec = static_cast<CCDIAPRecord*>(CCDIAPRecord::RecordFactoryL(KCDTIdIAPRecord)); |
|
439 CleanupStack::PushL(iapRec); |
|
440 iapRec->SetRecordId(aIapId); |
|
441 iapRec->LoadL(aDbs); |
|
442 CleanupStack::Pop(iapRec); |
|
443 return iapRec; |
|
444 } |
|
445 |
|
446 EXPORT_C CMDBRecordSet<CCDIAPRecord>* TierManagerUtils::LoadIapRecordsL(CMDBSession& aDbs) |
|
447 { |
|
448 //Load all IAP records |
|
449 CMDBRecordSet<CCDIAPRecord>* iapSet = new(ELeave) CMDBRecordSet<CCDIAPRecord>(KCDTIdIAPRecord); |
|
450 CleanupStack::PushL(iapSet); |
|
451 |
|
452 //Create first record for priming |
|
453 CCDIAPRecord* iapRec = static_cast<CCDIAPRecord*>(CCDIAPRecord::RecordFactoryL(KCDTIdIAPRecord)); |
|
454 CleanupStack::PushL(iapRec); |
|
455 |
|
456 //Add record to record set |
|
457 iapSet->iRecords.AppendL(iapRec); |
|
458 CleanupStack::Pop(iapRec); |
|
459 |
|
460 //Load set |
|
461 TBool returned = iapSet->FindL(aDbs); |
|
462 |
|
463 //Check if apRec has been overwritten |
|
464 if( ! returned ) |
|
465 { |
|
466 User::Leave(KErrNotFound); |
|
467 } |
|
468 |
|
469 CleanupStack::Pop(iapSet); |
|
470 return iapSet; |
|
471 } |
|
472 |
|
473 EXPORT_C TUint TierManagerUtils::ReadDefaultAccessPointL(TUid aTierId, CMDBSession& aDbs) |
|
474 { |
|
475 CCDTierRecord* tierRec = TierManagerUtils::LoadTierRecordL(aTierId,aDbs); |
|
476 TUint accessPoint = tierRec->iDefaultAccessPoint; |
|
477 delete tierRec; |
|
478 return accessPoint; |
|
479 } |
|
480 |
|
481 EXPORT_C TUid TierManagerUtils::ReadTierIdL(TUint aAccessPointId, CMDBSession& aDbs) |
|
482 { |
|
483 |
|
484 //it would be better to load 2 fields rather than load 2 record.... |
|
485 |
|
486 __ASSERT_ALWAYS(aAccessPointId>0,User::Panic(KTierManagerUtils,EInvalidAccessPointId)); |
|
487 |
|
488 CCDAccessPointRecord* apRec = TierManagerUtils::LoadAccessPointRecordL(aAccessPointId,aDbs); |
|
489 |
|
490 CleanupStack::PushL(apRec); |
|
491 |
|
492 //load the tag field for the given tier record |
|
493 CMDBField<TInt>* iRecordTag = new (ELeave) CMDBField<TInt>(static_cast<TInt>(apRec->iTier) | KCDTIdRecordTag); |
|
494 CleanupStack::PushL(iRecordTag); |
|
495 |
|
496 iRecordTag->LoadL(aDbs); |
|
497 |
|
498 TInt tempTag = *iRecordTag; |
|
499 CleanupStack::PopAndDestroy(iRecordTag); |
|
500 |
|
501 TUid tierId = TUid::Uid(tempTag); |
|
502 |
|
503 CleanupStack::PopAndDestroy(apRec); |
|
504 //delete apRec; |
|
505 User::LeaveIfError(tierId.iUid? KErrNone : KErrCorrupt); |
|
506 return tierId; |
|
507 } |
|
508 |
|
509 EXPORT_C TUid TierManagerUtils::ReadMCprUidL(TUint aAccessPointId, CMDBSession& aDbs) |
|
510 { |
|
511 __ASSERT_ALWAYS(aAccessPointId>0,User::Panic(KTierManagerUtils,EInvalidAccessPointId)); |
|
512 |
|
513 CCDAccessPointRecord* apRec = TierManagerUtils::LoadAccessPointRecordL(aAccessPointId,aDbs); |
|
514 CleanupStack::PushL(apRec); |
|
515 CCDMCprRecord* mcprRec = TierManagerUtils::LoadMCprRecordL(apRec->iMCpr,aDbs); |
|
516 TUid mCprUid = TUid::Uid(mcprRec->iMCprUid); |
|
517 delete mcprRec; |
|
518 CleanupStack::PopAndDestroy(apRec); |
|
519 return mCprUid; |
|
520 } |
|
521 |
|
522 EXPORT_C TUint TierManagerUtils::ReadSelectionPolicyIdL(TUint aAccessPointId, CMDBSession& aDbs) |
|
523 { |
|
524 __ASSERT_ALWAYS(aAccessPointId>0,User::Panic(KTierManagerUtils,EInvalidAccessPointId)); |
|
525 |
|
526 CCDAccessPointRecord* apRec = TierManagerUtils::LoadAccessPointRecordL(aAccessPointId,aDbs); |
|
527 TUint policyId = apRec->iSelectionPolicy; |
|
528 delete apRec; |
|
529 return policyId; |
|
530 } |
|
531 |
|
532 EXPORT_C TUint TierManagerUtils::ReadCustomSelectionPolicyIdL(TUint aAccessPointId, CommsDat::CMDBSession& aDbs) |
|
533 { |
|
534 __ASSERT_ALWAYS(aAccessPointId>0,User::Panic(KTierManagerUtils,EInvalidAccessPointId)); |
|
535 |
|
536 CCDAccessPointRecord* apRec = TierManagerUtils::LoadAccessPointRecordL(aAccessPointId,aDbs); |
|
537 TUint customSelPolicyId = apRec->iCustomSelectionPolicy; |
|
538 delete apRec; |
|
539 return customSelPolicyId; |
|
540 } |
|
541 |
|
542 EXPORT_C TUint TierManagerUtils::ReadCprConfigL(TUint aAccessPointId, CMDBSession& aDbs) |
|
543 { |
|
544 __ASSERT_ALWAYS(aAccessPointId>0,User::Panic(KTierManagerUtils,EInvalidAccessPointId)); |
|
545 |
|
546 CCDAccessPointRecord* apRec = TierManagerUtils::LoadAccessPointRecordL(aAccessPointId,aDbs); |
|
547 TUint cprconfig = apRec->iCprConfig; |
|
548 delete apRec; |
|
549 return cprconfig; |
|
550 } |
|
551 |
|
552 EXPORT_C ESock::RTierThreadMap* TierManagerUtils::BuildTierThreadMappingL(CMDBSession& aDbs) |
|
553 { |
|
554 RTierThreadMap* map = new (ELeave) RTierThreadMap; |
|
555 CleanupClosePushL(*map); |
|
556 CMDBRecordSet<CCDTierRecord>* recSet = new (ELeave) CMDBRecordSet<CCDTierRecord>(KCDTIdTierRecord); |
|
557 CleanupStack::PushL(recSet); |
|
558 recSet->LoadL(aDbs); |
|
559 CommsFW::TCFModuleName narrowThreadName; |
|
560 const TInt recCnt = recSet->iRecords.Count(); |
|
561 for(TInt i = 0; i < recCnt; ++i) |
|
562 { |
|
563 CCDTierRecord* rec = static_cast<CCDTierRecord*>(recSet->iRecords[i]); |
|
564 narrowThreadName.Copy(rec->iTierThreadName); |
|
565 TWorkerId worker; |
|
566 if(!CWorkerThread::ResolveWorkerNameToId(narrowThreadName, worker)) |
|
567 { |
|
568 LOG(ESockLog::Printf(KESockMetaConnectionTag, _L("TierManagerUtils::BuildTierThreadMappingL - worker name %S failed resolution"), &narrowThreadName)); |
|
569 continue; |
|
570 } |
|
571 map->AppendL(TTierMapEntry(rec->iRecordTag, worker)); |
|
572 } |
|
573 CleanupStack::PopAndDestroy(recSet); |
|
574 CleanupStack::Pop(map); |
|
575 return map; |
|
576 } |
|
577 |
|
578 //This function reads the IAP priority based selection policy table (CCDIAPPrioritySelectionPolicyRecord) |
|
579 //and fills the TConnIdList provided using the specified selectionPolicy (record id within the table). |
|
580 EXPORT_C void TierManagerUtils::FillListL(TConnIdList& aList, TUint selectionPolicy, CMDBSession& aDbs) |
|
581 { |
|
582 LOG(ESockLog::Printf(KESockMetaConnectionTag, _L("TierManagerUtils::FillListL()"))); |
|
583 |
|
584 //The provided list must be empty. |
|
585 __ASSERT_DEBUG(aList.Count()==0, User::Panic(KSpecAssert_ESockSSockTrMngU, 11)); |
|
586 |
|
587 CCDAPPrioritySelectionPolicyRecord* policyRec = static_cast<CCDAPPrioritySelectionPolicyRecord*> |
|
588 (CCDConnectionPrefsRecord::RecordFactoryL(KCDTIdApPrioritySelectionPolicyRecord)); |
|
589 CleanupStack::PushL(policyRec); |
|
590 policyRec->SetRecordId(selectionPolicy); |
|
591 policyRec->LoadL(aDbs); |
|
592 |
|
593 // CMDBField<TUint32>* theAp = &policyRec->iAp1; |
|
594 CMDBRecordLink<CCDAccessPointRecord>* theAp = &policyRec->iAp1; |
|
595 TUint32 theCount = policyRec->iApCount; |
|
596 __ASSERT_DEBUG(theCount <= CCDAPPrioritySelectionPolicyRecord::EMaxNrOfAps, User::Panic(KSpecAssert_ESockSSockTrMngU, 12)); |
|
597 |
|
598 for (TInt i = 0; i < theCount; i++, theAp++) |
|
599 { |
|
600 //TInt apId = static_cast<TInt>(*theAp); |
|
601 TInt apId = ResolveDefAPtoTagL((*theAp), aDbs ); |
|
602 __ASSERT_DEBUG(apId>0, User::Panic(KSpecAssert_ESockSSockTrMngU, 13)); |
|
603 LOG(ESockLog::Printf(KESockMetaConnectionTag, _L("ListCount[%d] Append(%d)"),aList.Count(),apId)); |
|
604 aList.Append(apId); |
|
605 } |
|
606 |
|
607 CleanupStack::PopAndDestroy(policyRec); |
|
608 } |
|
609 |
|
610 //This function reads the AP priority based selection policy table (CCDAPPrioritySelectionPolicyRecord) |
|
611 //and fills the RConnPrefList provided using the specified selectionPolicy (record id within the table). |
|
612 EXPORT_C void TierManagerUtils::FillListL(RConnPrefList& aList, TUint selectionPolicy, CMDBSession& aDbs) |
|
613 { |
|
614 LOG(ESockLog::Printf(KESockMetaConnectionTag, _L("TierManagerUtils::FillListL()"))); |
|
615 |
|
616 CCDAPPrioritySelectionPolicyRecord* policyRec = static_cast<CCDAPPrioritySelectionPolicyRecord*> |
|
617 (CCDConnectionPrefsRecord::RecordFactoryL(KCDTIdApPrioritySelectionPolicyRecord)); |
|
618 CleanupStack::PushL(policyRec); |
|
619 policyRec->SetRecordId(selectionPolicy); |
|
620 policyRec->LoadL(aDbs); |
|
621 |
|
622 CMDBRecordLink<CCDAccessPointRecord>* theAp = &policyRec->iAp1; |
|
623 TUint32 theCount = policyRec->iApCount; |
|
624 __ASSERT_DEBUG(theCount <= CCDAPPrioritySelectionPolicyRecord::EMaxNrOfAps, User::Panic(KSpecAssert_ESockSSockTrMngU, 14)); |
|
625 |
|
626 for (TInt i = 0; i < theCount; i++, theAp++) |
|
627 { |
|
628 TInt apId = ResolveDefAPtoTagL((*theAp), aDbs ); |
|
629 TConnAPPref* pref = TConnAPPref::NewL(apId); |
|
630 CleanupStack::PushL(pref); |
|
631 __ASSERT_DEBUG(apId>0, User::Panic(KSpecAssert_ESockSSockTrMngU, 15)); |
|
632 LOG(ESockLog::Printf(KESockMetaConnectionTag, _L("ListCount[%d] Append(%d)"),aList.Count(),apId)); |
|
633 aList.AppendL(pref); |
|
634 CleanupStack::Pop(); |
|
635 } |
|
636 |
|
637 CleanupStack::PopAndDestroy(policyRec); |
|
638 } |
|
639 |
|
640 EXPORT_C TUint TierManagerUtils::GetConnectionAttemptsL(CMDBSession& aDbs) |
|
641 { |
|
642 //it's enough to load the appropriate field... |
|
643 CCDGlobalSettingsRecord* glRec = TierManagerUtils::LoadGlobalSettingsRecordL(aDbs); |
|
644 CleanupStack::PushL(glRec); |
|
645 TUint connectionAttempts = glRec->iMaxConnectionAttempts; |
|
646 CleanupStack::PopAndDestroy(glRec); |
|
647 return connectionAttempts; |
|
648 } |
|
649 |
|
650 EXPORT_C void TierManagerUtils::MapRankingToPrefsL(TUint aRanking, TCommDbConnPref& aPrefs, CMDBSession& aDbs) |
|
651 { |
|
652 CCDConnectionPrefsRecord* cpRec = static_cast<CCDConnectionPrefsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord)); |
|
653 CleanupStack::PushL(cpRec); |
|
654 cpRec->iRanking = aRanking; |
|
655 TBool found = cpRec->FindL(aDbs); |
|
656 if (!found) |
|
657 { //CommsDat API is a widely known problem |
|
658 User::Leave(KErrNotFound); |
|
659 } |
|
660 |
|
661 //CommDat records do not like to be casted, this is why we have double cast here.. (!?!) |
|
662 aPrefs.SetIapId(cpRec->iDefaultIAP); |
|
663 aPrefs.SetDialogPreference(static_cast<TCommDbDialogPref>((TUint)cpRec->iDialogPref)); |
|
664 aPrefs.SetDirection(static_cast<TCommDbConnectionDirection>((TUint)cpRec->iDirection)); |
|
665 aPrefs.SetBearerSet(cpRec->iBearerSet); |
|
666 |
|
667 CleanupStack::PopAndDestroy(cpRec); |
|
668 } |
|
669 |
|
670 EXPORT_C void TierManagerUtils::ParseTLConfigAccessPointIdsL(RArray<TUint> &aIds, const TDesC& aIdList) |
|
671 { |
|
672 TLex lexer(aIdList); |
|
673 while (!lexer.Eos()) |
|
674 { |
|
675 TUint val = 0; |
|
676 TInt err = lexer.Val(val); |
|
677 if (err != KErrNone) |
|
678 User::Leave(KErrArgument); |
|
679 aIds.AppendL(val); |
|
680 |
|
681 lexer.SkipSpaceAndMark(); |
|
682 if (lexer.Peek() == ',') |
|
683 lexer.Inc(); |
|
684 } |
|
685 } |
|
686 |
|
687 EXPORT_C CCDConfigAccessPointRecord* TierManagerUtils::LoadConfigAccessPointRecordL(TUint aId, CommsDat::CMDBSession& aDBs) |
|
688 { |
|
689 CCDConfigAccessPointRecord* capRec = static_cast<CCDConfigAccessPointRecord*>(CCDConfigAccessPointRecord::RecordFactoryL(KCDTIdConfigAccessPointRecord)); |
|
690 |
|
691 CleanupStack::PushL(capRec); |
|
692 capRec->SetRecordId(aId); |
|
693 capRec->LoadL(aDBs); |
|
694 |
|
695 CleanupStack::Pop(capRec); |
|
696 return capRec; |
|
697 } |
|
698 |
|
699 EXPORT_C void TierManagerUtils::MapRankingAndDirectionToPrefsL(TUint aRanking, TCommDbConnectionDirection aDirection, TCommDbConnPref& aPrefs, CMDBSession& aDbs) |
|
700 { |
|
701 CCDConnectionPrefsRecord* cpRec = static_cast<CCDConnectionPrefsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord)); |
|
702 CleanupStack::PushL(cpRec); |
|
703 cpRec->iRanking = aRanking; |
|
704 cpRec->iDirection = aDirection; |
|
705 |
|
706 TBool found = cpRec->FindL(aDbs); |
|
707 if (!found) |
|
708 { |
|
709 User::Leave(KErrNotFound); |
|
710 } |
|
711 |
|
712 //CommDat records do not like to be casted, this is why we have double cast here.. (!?!) |
|
713 aPrefs.SetIapId(cpRec->iDefaultIAP); |
|
714 aPrefs.SetDialogPreference(static_cast<TCommDbDialogPref>((TUint)cpRec->iDialogPref)); |
|
715 aPrefs.SetDirection(static_cast<TCommDbConnectionDirection>((TUint)cpRec->iDirection)); |
|
716 aPrefs.SetBearerSet(cpRec->iBearerSet); |
|
717 |
|
718 CleanupStack::PopAndDestroy(cpRec); |
|
719 } |
|
720 |
|
721 EXPORT_C void TierManagerUtils::GetPrefsFromConnPrefRecL(TUint aConnPrefRecElemId, |
|
722 CommsDat::CMDBSession& aDbs, |
|
723 TConnectionPrefs& aConnPrefs) |
|
724 { |
|
725 CCDConnectionPrefsRecord* cpRec = static_cast<CCDConnectionPrefsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord)); |
|
726 CleanupStack::PushL(cpRec); |
|
727 cpRec->SetElementId(aConnPrefRecElemId); |
|
728 |
|
729 cpRec->LoadL(aDbs); |
|
730 |
|
731 aConnPrefs.iRank = cpRec->iRanking; |
|
732 aConnPrefs.iDirection = cpRec->iDirection; |
|
733 aConnPrefs.iBearerSet = cpRec->iBearerSet; |
|
734 |
|
735 CleanupStack::PopAndDestroy(cpRec); |
|
736 } |
|
737 |
|
738 EXPORT_C TUid TierManagerUtils::MapTierIdtoTierImplIdL(TUid aTierUid,CommsDat::CMDBSession& aDbs ) |
|
739 /** mapping TM Id to TM ImplId in Commsdat */ |
|
740 { |
|
741 TUid ImplUid; |
|
742 // if it does not exist, it returns tier id |
|
743 ImplUid = aTierUid; |
|
744 |
|
745 CMDBRecordSet<CCDTierRecord>* recSet = new (ELeave) CMDBRecordSet<CCDTierRecord>(KCDTIdTierRecord); |
|
746 CleanupStack::PushL(recSet); |
|
747 recSet->LoadL(aDbs); |
|
748 const TInt recCnt = recSet->iRecords.Count(); |
|
749 |
|
750 for(TInt i = 0; i < recCnt; i++) |
|
751 { |
|
752 CCDTierRecord* rec = static_cast<CCDTierRecord*>(recSet->iRecords[i]); |
|
753 if(rec->iRecordTag == aTierUid.iUid) |
|
754 { |
|
755 ImplUid.iUid = rec->iTierImplUid; |
|
756 } |
|
757 } |
|
758 |
|
759 CleanupStack::PopAndDestroy(recSet); |
|
760 return ImplUid; |
|
761 } |
|
762 // |
|
763 // CCommsDatIapView |
|
764 // |
|
765 // Class used to retrieve CommsDat values based on a view specific to an IAP. |
|
766 // |
|
767 |
|
768 EXPORT_C CCommsDatIapView* CCommsDatIapView::NewL(TUint aIapId) |
|
769 /** |
|
770 Create a new IAP view object based on the IAP number specified. |
|
771 |
|
772 @param aIapId IAP number |
|
773 @return IAP view object |
|
774 */ |
|
775 { |
|
776 CCommsDatIapView* self = new (ELeave) CCommsDatIapView(); |
|
777 CleanupStack::PushL(self); |
|
778 |
|
779 // Second phase construction |
|
780 self->iDbs = CMDBSession::NewL(KCDVersion1_2); |
|
781 |
|
782 // Reveal hidden or private IAP records if a licensee has chosen to protect a record |
|
783 // using one of these flags - the API to do this is public so internal components |
|
784 // have to support the use of such records. |
|
785 self->iDbs->SetAttributeMask( ECDHidden | ECDPrivate ); |
|
786 |
|
787 self->iIapRec = TierManagerUtils::LoadIapRecordL(aIapId, *self->iDbs); |
|
788 self->iUmtsR99QoSAndOnRecId = -1; |
|
789 |
|
790 CleanupStack::Pop(self); |
|
791 return self; |
|
792 } |
|
793 |
|
794 EXPORT_C CCommsDatIapView* CCommsDatIapView::NewLC(TUint aIapId) |
|
795 /** |
|
796 Create a new IAP view object based on the IAP number specified, and leave |
|
797 a cleanup item on the cleanup stack. |
|
798 |
|
799 @param aIapId IAP number |
|
800 @return IAP view object |
|
801 */ |
|
802 { |
|
803 CCommsDatIapView* self = NewL(aIapId); |
|
804 CleanupStack::PushL(self); |
|
805 return self; |
|
806 } |
|
807 |
|
808 EXPORT_C CCommsDatIapView::~CCommsDatIapView() |
|
809 { |
|
810 delete iBool; |
|
811 delete iUint; |
|
812 delete iInt; |
|
813 delete iText8; |
|
814 delete iText16; |
|
815 |
|
816 delete iIapRec; |
|
817 delete iDbs; |
|
818 } |
|
819 |
|
820 |
|
821 /** |
|
822 Retrieve an unsigned integer value from CommsDat. |
|
823 |
|
824 @param aElementId element id of the field required. The record id does not need to be specified. |
|
825 This field can take the special value KCDTIdIAPNetwork to retrieve the Network Id. |
|
826 @param aValue returned integer value |
|
827 */ |
|
828 EXPORT_C void CCommsDatIapView::GetIntL(TMDBElementId aElementId, TUint32& aValue) |
|
829 { |
|
830 if ((aElementId & KCDMaskShowRecordType) == KCDTIdIAPRecord) |
|
831 { |
|
832 GetIapRecordIntL(aElementId, aValue); |
|
833 return; |
|
834 } |
|
835 |
|
836 if (iUint == NULL) |
|
837 { |
|
838 iUint = new (ELeave) CMDBField<TUint32>(); |
|
839 } |
|
840 SetElementAndRecordIdL(iUint, aElementId); |
|
841 |
|
842 IntFieldTypeCheckL(iUint->ElementId()); |
|
843 |
|
844 iUint->LoadL(*iDbs); |
|
845 aValue = *iUint; |
|
846 } |
|
847 |
|
848 |
|
849 /** |
|
850 Retrieve an unsigned integer value from CommsDat (non-leaving) |
|
851 |
|
852 @param aElementId element id of the field required. The record id does not need to be specified. |
|
853 @param aValue returned integer value |
|
854 @return KErrNone or a system wide error code |
|
855 */ |
|
856 EXPORT_C TInt CCommsDatIapView::GetInt(TMDBElementId aElementId, TUint32& aValue) |
|
857 { |
|
858 TRAPD(err, GetIntL(aElementId, aValue)); |
|
859 return err; |
|
860 } |
|
861 |
|
862 |
|
863 /** |
|
864 Retrieve a signed integer value from CommsDat. |
|
865 |
|
866 @param aElementId element id of the field required. The record id does not need to be specified. |
|
867 This field can take the special value KCDTIdIAPNetwork to retrieve the Network Id. |
|
868 @param aValue returned integer value |
|
869 */ |
|
870 EXPORT_C void CCommsDatIapView::GetIntL(TMDBElementId aElementId, TInt& aValue) |
|
871 { |
|
872 if ((aElementId & KCDMaskShowRecordType) == KCDTIdIAPRecord) |
|
873 { |
|
874 GetIapRecordIntL(aElementId, aValue); |
|
875 return; |
|
876 } |
|
877 |
|
878 if (iInt == NULL) |
|
879 { |
|
880 iInt = new (ELeave) CMDBField<TInt>(); |
|
881 } |
|
882 SetElementAndRecordIdL(iInt, aElementId); |
|
883 |
|
884 IntFieldTypeCheckL(iInt->ElementId()); |
|
885 |
|
886 iInt->LoadL(*iDbs); |
|
887 aValue = *iInt; |
|
888 } |
|
889 |
|
890 |
|
891 /** |
|
892 Retrieve a signed integer value from CommsDat (non-leaving) |
|
893 |
|
894 @param aElementId element id of the field required. The record id does not need to be specified. |
|
895 @param aValue returned integer value |
|
896 @return KErrNone or a system wide error code |
|
897 */ |
|
898 EXPORT_C TInt CCommsDatIapView::GetInt(TMDBElementId aElementId, TInt& aValue) |
|
899 { |
|
900 TRAPD(err, GetIntL(aElementId, aValue)); |
|
901 return err; |
|
902 } |
|
903 |
|
904 |
|
905 /** |
|
906 Retrieve a boolean value from CommsDat |
|
907 |
|
908 @param aElementId element id of the field required. The record id does not need to be specified. |
|
909 @param aValue returned boolean value |
|
910 */ |
|
911 EXPORT_C void CCommsDatIapView::GetBoolL(TMDBElementId aElementId, TBool& aValue) |
|
912 { |
|
913 if (NULL == iBool) |
|
914 { |
|
915 iBool = new (ELeave) CMDBField<TBool>(); |
|
916 } |
|
917 SetElementAndRecordIdL(iBool, aElementId); |
|
918 |
|
919 BoolFieldTypeCheckL(iBool->ElementId()); |
|
920 |
|
921 iBool->LoadL(*iDbs); |
|
922 aValue = *iBool; |
|
923 } |
|
924 |
|
925 |
|
926 /** |
|
927 Retrieve a boolean value from CommsDat (non-leaving) |
|
928 |
|
929 @param aElementId element id of the field required. The record id does not need to be specified. |
|
930 @param aValue returned boolean value |
|
931 @return KErrNone or a system wide error code |
|
932 */ |
|
933 EXPORT_C TInt CCommsDatIapView::GetBool(TMDBElementId aElementId, TBool& aValue) |
|
934 { |
|
935 TRAPD(err, GetBoolL(aElementId, aValue)); |
|
936 return err; |
|
937 } |
|
938 |
|
939 |
|
940 /** |
|
941 Retrieve a text value from CommsDat |
|
942 |
|
943 @param aElementId element id of the field required. The record id does not need to be specified. |
|
944 @param aValue In this field the caller receives ownership of a HBufC containing the text value. |
|
945 The following function will read in 8 bit text and output 16 bit convertion to keep up with legacy behaviour |
|
946 */ |
|
947 EXPORT_C void CCommsDatIapView::GetTextL(TMDBElementId aElementId, HBufC8*& aValue) |
|
948 { |
|
949 aValue = NULL; |
|
950 if (NULL == iText8) |
|
951 { |
|
952 iText8 = new (ELeave) CMDBField<TDesC8>(); |
|
953 } |
|
954 SetElementAndRecordIdL(iText8, aElementId); |
|
955 |
|
956 TextOrBinFieldTypeCheckL(iText8->ElementId()); |
|
957 |
|
958 TRAPD(err, iText8->LoadL(*iDbs)); // trap first attempt for retry with larger buffer |
|
959 if (err == KErrOverflow) |
|
960 { |
|
961 iText8->SetMaxLengthL(1024); |
|
962 iText8->LoadL(*iDbs); |
|
963 err = KErrNone; |
|
964 } |
|
965 User::LeaveIfError(err); |
|
966 |
|
967 CMDBRecordBase* recordBase = CCDRecordBase::RecordFactoryL(iText8->TableId()); |
|
968 CleanupStack::PushL(recordBase); |
|
969 CMDBElement* el = recordBase->GetFieldByIdL(iText8->TypeId()); |
|
970 if (EText == el->Type()) |
|
971 { |
|
972 const TDesC8& des8 = iText8->GetL(); |
|
973 TPtrC ptr16(reinterpret_cast<const TUint16 *>(des8.Ptr()), des8.Length() / 2); |
|
974 // Create a HBufC to return to the caller, containing a copy of the field. |
|
975 aValue = HBufC8::NewMaxL(ptr16.Length()); |
|
976 aValue->Des().Copy(ptr16); |
|
977 } |
|
978 else |
|
979 { |
|
980 // Create a HBufC to return to the caller, containing a copy of the field. |
|
981 aValue = HBufC8::NewMaxL(static_cast<const TDesC8&>(*iText8).Length()); |
|
982 *aValue = *iText8; |
|
983 } |
|
984 |
|
985 CleanupStack::PopAndDestroy(recordBase); |
|
986 } |
|
987 |
|
988 |
|
989 /** |
|
990 Retrieve a text value from CommsDat (non-leaving) |
|
991 |
|
992 @param aElementId element id of the field required. The record id does not need to be specified. |
|
993 @param aValue In this field the caller receives ownership of a HBufC containing the text value. |
|
994 @return KErrNone or a system wide error code |
|
995 The following function will read in 16 bit text and output 8 bit convertion to keep up with legacy behaviour |
|
996 */ |
|
997 EXPORT_C TInt CCommsDatIapView::GetText(TMDBElementId aElementId, HBufC8*& aValue) |
|
998 { |
|
999 TRAPD(err, GetTextL(aElementId, aValue)); |
|
1000 return err; |
|
1001 } |
|
1002 |
|
1003 |
|
1004 /** |
|
1005 Retrieve a text value from CommsDat |
|
1006 |
|
1007 @param aElementId element id of the field required. The record id does not need to be specified. |
|
1008 @param aValue In this field the caller receives ownership of a HBufC containing the text value. |
|
1009 */ |
|
1010 |
|
1011 EXPORT_C void CCommsDatIapView::GetTextL(TMDBElementId aElementId, HBufC16*& aValue) |
|
1012 { |
|
1013 if ((aElementId & KCDMaskShowRecordType) == KCDTIdIAPRecord) |
|
1014 { |
|
1015 GetIapRecordTextL(aElementId, aValue); |
|
1016 return; |
|
1017 } |
|
1018 |
|
1019 aValue = NULL; |
|
1020 if (NULL == iText16) |
|
1021 { |
|
1022 iText16 = new (ELeave) CMDBField<TDesC16>(); |
|
1023 } |
|
1024 SetElementAndRecordIdL(iText16, aElementId); |
|
1025 |
|
1026 TextOrBinFieldTypeCheckL(iText16->ElementId()); |
|
1027 |
|
1028 TRAPD(err, iText16->LoadL(*iDbs)); // trap first attempt for retry with larger buffer |
|
1029 if (err == KErrOverflow) |
|
1030 { |
|
1031 iText16->SetMaxLengthL(1024); |
|
1032 iText16->LoadL(*iDbs); |
|
1033 err = KErrNone; |
|
1034 } |
|
1035 User::LeaveIfError(err); |
|
1036 |
|
1037 CMDBRecordBase* recordBase = CCDRecordBase::RecordFactoryL(iText16->TableId()); |
|
1038 CleanupStack::PushL(recordBase); |
|
1039 CMDBElement* el = recordBase->GetFieldByIdL(iText16->TypeId()); |
|
1040 if (EDesC8 == el->Type()) |
|
1041 { |
|
1042 const TDesC16& des16 = iText16->GetL(); |
|
1043 TPtrC8 ptr8(reinterpret_cast<const TUint8 *>(des16.Ptr()), des16.Size()); |
|
1044 |
|
1045 // Create a HBufC to return to the caller, containing a copy of the field. |
|
1046 aValue = HBufC16::NewMaxL(ptr8.Length()); |
|
1047 aValue->Des().Copy(ptr8); |
|
1048 } |
|
1049 else |
|
1050 { |
|
1051 // Create a HBufC to return to the caller, containing a copy of the field. |
|
1052 aValue = HBufC16::NewMaxL(static_cast<const TDesC16&>(*iText16).Length()); |
|
1053 *aValue = *iText16; |
|
1054 } |
|
1055 |
|
1056 CleanupStack::PopAndDestroy(recordBase); |
|
1057 } |
|
1058 |
|
1059 |
|
1060 /** |
|
1061 Retrieve a text value from CommsDat (non-leaving) |
|
1062 |
|
1063 @param aElementId element id of the field required. The record id does not need to be specified. |
|
1064 @param aValue In this field the caller receives ownership of a HBufC containing the text value. |
|
1065 @return KErrNone or a system wide error code |
|
1066 */ |
|
1067 EXPORT_C TInt CCommsDatIapView::GetText(TMDBElementId aElementId, HBufC16*& aValue) |
|
1068 { |
|
1069 TRAPD(err, GetTextL(aElementId, aValue)); |
|
1070 return err; |
|
1071 } |
|
1072 |
|
1073 |
|
1074 void CCommsDatIapView::GetIapRecordIntL(TMDBElementId aElementId, TUint32& aValue) |
|
1075 { |
|
1076 switch(aElementId) |
|
1077 { |
|
1078 case (KCDTIdIAPRecord | KCDTIdRecordTag): |
|
1079 aValue = iIapRec->iRecordTag; |
|
1080 break; |
|
1081 |
|
1082 case KCDTIdIAPService: |
|
1083 aValue = iIapRec->iService; |
|
1084 break; |
|
1085 |
|
1086 case KCDTIdIAPBearer: |
|
1087 aValue = iIapRec->iBearer; |
|
1088 break; |
|
1089 |
|
1090 case KCDTIdIAPNetwork: |
|
1091 aValue = iIapRec->iNetwork; |
|
1092 break; |
|
1093 |
|
1094 case KCDTIdIAPNetworkWeighting: |
|
1095 aValue = iIapRec->iNetworkWeighting; |
|
1096 break; |
|
1097 |
|
1098 case KCDTIdIAPLocation: |
|
1099 aValue = iIapRec->iLocation; |
|
1100 break; |
|
1101 |
|
1102 case KCDTIdIAPAppSid: |
|
1103 aValue = iIapRec->iAppSid; |
|
1104 break; |
|
1105 |
|
1106 case KCDTIdRealIAP: |
|
1107 { |
|
1108 const TDesC& serviceType = iIapRec->iServiceType; |
|
1109 if (serviceType.Compare(TPtrC(KCDTypeNameVPNService)) == 0) |
|
1110 { |
|
1111 GetIntL(KCDTIdVPNIAPRecord, aValue); |
|
1112 } |
|
1113 else |
|
1114 { |
|
1115 aValue = iIapRec->iRecordTag; |
|
1116 } |
|
1117 } |
|
1118 break; |
|
1119 |
|
1120 default: |
|
1121 { |
|
1122 User::Leave(KErrBadName); |
|
1123 } |
|
1124 } |
|
1125 } |
|
1126 |
|
1127 |
|
1128 void CCommsDatIapView::GetIapRecordIntL(TMDBElementId aElementId, TInt& aValue) |
|
1129 { |
|
1130 // Ok since this table only contains Uints, but none that |
|
1131 // tickle the top bit |
|
1132 TUint32 value; |
|
1133 GetIapRecordIntL(aElementId, value); |
|
1134 aValue = (TInt)value; |
|
1135 } |
|
1136 |
|
1137 |
|
1138 void CCommsDatIapView::GetIapRecordTextL(TMDBElementId aElementId, HBufC16*& aValue) |
|
1139 { |
|
1140 switch(aElementId) |
|
1141 { |
|
1142 case (KCDTIdIAPRecord | KCDTIdRecordName): |
|
1143 { |
|
1144 const TDesC16& record = iIapRec->iRecordName; |
|
1145 aValue = HBufC16::NewMaxL(record.Length()); |
|
1146 *aValue = record; |
|
1147 } |
|
1148 break; |
|
1149 |
|
1150 case KCDTIdIAPBearerType: |
|
1151 { |
|
1152 const TDesC16& record = iIapRec->iBearerType; |
|
1153 aValue = HBufC16::NewMaxL(record.Length()); |
|
1154 *aValue = record; |
|
1155 } |
|
1156 break; |
|
1157 |
|
1158 case KCDTIdIAPServiceType: |
|
1159 { |
|
1160 const TDesC16& record = iIapRec->iServiceType; |
|
1161 aValue = HBufC16::NewMaxL(record.Length()); |
|
1162 *aValue = record; |
|
1163 } |
|
1164 break; |
|
1165 |
|
1166 default: |
|
1167 { |
|
1168 User::Leave(KErrBadName); |
|
1169 } |
|
1170 } |
|
1171 } |
|
1172 |
|
1173 |
|
1174 EXPORT_C TUint CCommsDatIapView::IapId() |
|
1175 /** |
|
1176 Return the IAP number associated with this IAP view object. |
|
1177 */ |
|
1178 { |
|
1179 //normally iRecordTag will be empty and anyway is not intended to hold the record id. |
|
1180 // assuming the record id of the IAP is what is needed this call needs to be different |
|
1181 //return iIapRec->iRecordTag; |
|
1182 return iIapRec->RecordId(); |
|
1183 |
|
1184 } |
|
1185 |
|
1186 EXPORT_C CommsDat::TMDBElementId CCommsDatIapView::GetServiceTableType() const |
|
1187 { |
|
1188 CommsDat::TMDBElementId el; |
|
1189 TInt err = ConvertServiceTypeToTableId(iIapRec->iServiceType,el); |
|
1190 __ASSERT_DEBUG(err == KErrNone, User::Panic(KSpecAssert_ESockSSockTrMngU, 16)); |
|
1191 return el; |
|
1192 } |
|
1193 |
|
1194 EXPORT_C CommsDat::TMDBElementId CCommsDatIapView::GetBearerTableType() const |
|
1195 { |
|
1196 CommsDat::TMDBElementId el; |
|
1197 TInt err = ConvertBearerTypeToTableId(iIapRec->iBearerType, el); |
|
1198 __ASSERT_DEBUG(err == KErrNone, User::Panic(KSpecAssert_ESockSSockTrMngU, 17)); |
|
1199 return el; |
|
1200 } |
|
1201 |
|
1202 |
|
1203 EXPORT_C void CCommsDatIapView::GetTableCommonTextFieldL(CCommsDatIapView::TFieldId aField, HBufC*& aValue) |
|
1204 /** |
|
1205 Generalised routine for reading the value of a specified text field from the current bearer or |
|
1206 service table. |
|
1207 |
|
1208 The caller does not need to specify the particular CommsDat id. In some ways this is similar |
|
1209 functionality to the CommsDat ability to read a field by name, but that mechanism was considered |
|
1210 too inefficient as this routine is likely to be called on every connection startup. |
|
1211 |
|
1212 This routine does the work of determining the CommsDat id of the field with respect to the |
|
1213 current service or bearer table. |
|
1214 |
|
1215 @param aElementId element id of the field required. The record id does not need to be specified. |
|
1216 @param aValue In this field the caller receives ownership of a HBufC containing the text value. |
|
1217 */ |
|
1218 { |
|
1219 TMDBElementId el = 0; |
|
1220 |
|
1221 // Determine the CommsDat id of the field. |
|
1222 switch (aField) |
|
1223 { |
|
1224 case EIfNetworks: |
|
1225 switch (GetServiceTableType()) |
|
1226 { |
|
1227 case KCDTIdDialOutISPRecord: |
|
1228 el = KCDTIdIfNetworks; |
|
1229 break; |
|
1230 |
|
1231 case KCDTIdOutgoingGprsRecord: |
|
1232 case KCDTIdIncomingGprsRecord: |
|
1233 el = KCDTIdWCDMAIfNetworks | GetServiceTableType(); |
|
1234 break; |
|
1235 |
|
1236 case KCDTIdLANServiceRecord: |
|
1237 el = KCDTIdLANIfNetworks; |
|
1238 break; |
|
1239 |
|
1240 case KCDTIdDialInISPRecord: |
|
1241 el = KCDTIdDINIfNetworks; |
|
1242 break; |
|
1243 |
|
1244 default: |
|
1245 User::Leave(KErrCorrupt); |
|
1246 } // inner switch |
|
1247 break; |
|
1248 case EConfigDaemonManagerName: |
|
1249 switch (GetServiceTableType()) |
|
1250 { |
|
1251 case KCDTIdDialOutISPRecord: |
|
1252 el = KCDTIdConfigDaemonManagerName; |
|
1253 break; |
|
1254 |
|
1255 case KCDTIdOutgoingGprsRecord: |
|
1256 case KCDTIdIncomingGprsRecord: |
|
1257 el = KCDTIdWCDMAConfigDaemonManagerName | GetServiceTableType(); |
|
1258 break; |
|
1259 |
|
1260 case KCDTIdLANServiceRecord: |
|
1261 el = KCDTIdLANConfigDaemonManagerName; |
|
1262 break; |
|
1263 |
|
1264 default: |
|
1265 User::Leave(KErrCorrupt); |
|
1266 } // inner switch |
|
1267 break; |
|
1268 case EConfigDaemonName: |
|
1269 switch (GetServiceTableType()) |
|
1270 { |
|
1271 case KCDTIdDialOutISPRecord: |
|
1272 el = KCDTIdConfigDaemonName; |
|
1273 break; |
|
1274 |
|
1275 case KCDTIdOutgoingGprsRecord: |
|
1276 case KCDTIdIncomingGprsRecord: |
|
1277 el = KCDTIdWCDMAConfigDaemonName | GetServiceTableType(); |
|
1278 break; |
|
1279 |
|
1280 case KCDTIdLANServiceRecord: |
|
1281 el = KCDTIdLANConfigDaemonName; |
|
1282 break; |
|
1283 |
|
1284 default: |
|
1285 User::Leave(KErrCorrupt); |
|
1286 } // inner switch |
|
1287 break; |
|
1288 } // outer switch |
|
1289 |
|
1290 GetTextL(el, aValue); |
|
1291 } |
|
1292 |
|
1293 EXPORT_C void CCommsDatIapView::GetTimeoutValuesL(TUint32& aShortTimeout, TUint32& aMediumTimeout, TUint32& aLongTimeout) |
|
1294 /** |
|
1295 Retrieve the idle timeout values based on the current IAP view. |
|
1296 |
|
1297 @param aShortTimeout populated with LastSessionClosedTimeout field |
|
1298 @param aMediumTimeout populated with LastSocketClosedTimeout field |
|
1299 @param aLongTimeout populated with LastSocketActivityTimeout field |
|
1300 */ |
|
1301 { |
|
1302 TMDBElementId shortId = 0; |
|
1303 TMDBElementId mediumId = 0; |
|
1304 TMDBElementId longId = 0; |
|
1305 |
|
1306 // |
|
1307 // Check the bearer type and setup the correct elementId's for the timeout fields |
|
1308 // |
|
1309 const TDesC& bearerType = iIapRec->iBearerType; |
|
1310 if (bearerType.Compare(TPtrC(KCDTypeNameModemBearer)) == 0) |
|
1311 { |
|
1312 longId = KCDTIdLastSocketActivityTimeout; |
|
1313 shortId = KCDTIdLastSessionClosedTimeout; |
|
1314 mediumId = KCDTIdLastSocketClosedTimeout; |
|
1315 } |
|
1316 else |
|
1317 if (bearerType.Compare(TPtrC(KCDTypeNameLANBearer)) == 0) |
|
1318 { |
|
1319 longId = KCDTIdLANLastSocketActivityTimeout; |
|
1320 shortId = KCDTIdLANLastSessionClosedTimeout; |
|
1321 mediumId = KCDTIdLANLastSocketClosedTimeout; |
|
1322 } |
|
1323 else |
|
1324 if (bearerType.Compare(TPtrC(KCDTypeNameVirtualBearer)) == 0) |
|
1325 { |
|
1326 longId = KCDTIdVBLastSocketActivityTimeout; |
|
1327 shortId = KCDTIdVBLastSessionClosedTimeout; |
|
1328 mediumId = KCDTIdVBLastSocketClosedTimeout; |
|
1329 } |
|
1330 else |
|
1331 { |
|
1332 User::Leave(KErrCorrupt); |
|
1333 } |
|
1334 |
|
1335 // Retrieve the timeout fields |
|
1336 GetIntL(longId, aLongTimeout); |
|
1337 GetIntL(mediumId, aMediumTimeout); |
|
1338 GetIntL(shortId, aShortTimeout); |
|
1339 } |
|
1340 |
|
1341 void CCommsDatIapView::SetElementAndRecordIdL(CMDBElement* aElement, TMDBElementId aElementId) |
|
1342 /** |
|
1343 Set the elementid of an element based on the current IAP view. |
|
1344 |
|
1345 Essentially, this routine selects the service/bearer table entry to be retrieved, |
|
1346 based on the IAP specified. |
|
1347 */ |
|
1348 { |
|
1349 const TDesC& bearerType = iIapRec->iBearerType; |
|
1350 const TDesC& serviceType = iIapRec->iServiceType; |
|
1351 |
|
1352 aElement->SetElementId(aElementId); |
|
1353 TInt recordId = -1; |
|
1354 |
|
1355 if (aElementId == KCDTIdBearerAgent) |
|
1356 { |
|
1357 // Special case for reading the Agent name. We have to determine the tableId |
|
1358 // (by comparison of bearerType string) and then set the recordId from the |
|
1359 // bearer record number. |
|
1360 TMDBElementId tableId = 0; |
|
1361 User::LeaveIfError(ConvertBearerTypeToTableId(bearerType, tableId)); |
|
1362 aElement->SetTypeId(KCDTIdBearerAgent | tableId); |
|
1363 recordId = iIapRec->iBearer; |
|
1364 } |
|
1365 else |
|
1366 { |
|
1367 TInt elementId = aElement->TableId(); |
|
1368 switch (elementId) // note: relies on above SetElementId() having been called |
|
1369 { |
|
1370 case KCDTIdGlobalSettingsRecord: |
|
1371 recordId = 1; // only one record for global settings table |
|
1372 break; |
|
1373 |
|
1374 //Location Tables |
|
1375 case KCDTIdLocationRecord: |
|
1376 recordId = iIapRec->iLocation; |
|
1377 break; |
|
1378 |
|
1379 |
|
1380 // Service Tables |
|
1381 case KCDTIdDialOutISPRecord: |
|
1382 if (serviceType.Compare(TPtrC(KCDTypeNameDialOutISP)) == 0) |
|
1383 { |
|
1384 recordId = iIapRec->iService; |
|
1385 } |
|
1386 break; |
|
1387 |
|
1388 case KCDTIdDialInISPRecord: |
|
1389 if (serviceType.Compare(TPtrC(KCDTypeNameDialInISP)) == 0) |
|
1390 { |
|
1391 recordId = iIapRec->iService; |
|
1392 } |
|
1393 break; |
|
1394 |
|
1395 case KCDTIdLANServiceRecord: |
|
1396 if (serviceType.Compare(TPtrC(KCDTypeNameLANService)) == 0) |
|
1397 { |
|
1398 recordId = iIapRec->iService; |
|
1399 } |
|
1400 break; |
|
1401 |
|
1402 case KCDTIdVPNServiceRecord: |
|
1403 if (serviceType.Compare(TPtrC(KCDTypeNameVPNService)) == 0) |
|
1404 { |
|
1405 recordId = iIapRec->iService; |
|
1406 } |
|
1407 break; |
|
1408 |
|
1409 case KCDTIdOutgoingGprsRecord: |
|
1410 case KCDTIdIncomingGprsRecord: |
|
1411 if (serviceType.Compare(TPtrC(KCDTypeNameOutgoingWCDMA)) == 0 || |
|
1412 serviceType.Compare(TPtrC(KCDTypeNameIncomingWCDMA)) == 0 ) |
|
1413 { |
|
1414 recordId = iIapRec->iService; |
|
1415 } |
|
1416 break; |
|
1417 |
|
1418 // Bearer Tables |
|
1419 case KCDTIdModemBearerRecord: |
|
1420 if (bearerType.Compare(TPtrC(KCDTypeNameModemBearer)) == 0) |
|
1421 { |
|
1422 recordId = iIapRec->iBearer; |
|
1423 } |
|
1424 break; |
|
1425 |
|
1426 case KCDTIdLANBearerRecord: |
|
1427 if (bearerType.Compare(TPtrC(KCDTypeNameLANBearer)) == 0) |
|
1428 { |
|
1429 recordId = iIapRec->iBearer; |
|
1430 } |
|
1431 break; |
|
1432 |
|
1433 case KCDTIdVirtualBearerRecord: |
|
1434 if (bearerType.Compare(TPtrC(KCDTypeNameVirtualBearer)) == 0) |
|
1435 { |
|
1436 recordId = iIapRec->iBearer; |
|
1437 } |
|
1438 break; |
|
1439 |
|
1440 |
|
1441 // Other tables |
|
1442 case KCDTIdUmtsR99QoSAndOnTableRecord: |
|
1443 if (serviceType.Compare(TPtrC(KCDTypeNameOutgoingWCDMA)) == 0 || |
|
1444 serviceType.Compare(TPtrC(KCDTypeNameIncomingWCDMA)) == 0 ) |
|
1445 { |
|
1446 if (iUmtsR99QoSAndOnRecId == -1) |
|
1447 { |
|
1448 CCDOutgoingGprsRecord* packetRec = static_cast<CCDOutgoingGprsRecord*> |
|
1449 (CCDRecordBase::RecordFactoryL(KCDTIdOutgoingGprsRecord)); |
|
1450 CleanupStack::PushL(packetRec); |
|
1451 packetRec->SetRecordId(iIapRec->iService); |
|
1452 packetRec->LoadL(*iDbs); |
|
1453 iUmtsR99QoSAndOnRecId = packetRec->iUmtsR99QoSAndOnTable; |
|
1454 CleanupStack::PopAndDestroy(packetRec); |
|
1455 } |
|
1456 recordId = iUmtsR99QoSAndOnRecId; |
|
1457 } |
|
1458 break; |
|
1459 |
|
1460 default: |
|
1461 User::Leave(KErrNotFound); |
|
1462 } |
|
1463 } |
|
1464 |
|
1465 if (recordId != -1) |
|
1466 { |
|
1467 aElement->SetRecordId(recordId); |
|
1468 } |
|
1469 else |
|
1470 { |
|
1471 User::Leave(KErrNotFound); |
|
1472 } |
|
1473 } |
|
1474 |
|
1475 TInt CCommsDatIapView::ConvertBearerTypeToTableId(const TDesC& aBearerType, TMDBElementId& aElementId) |
|
1476 { |
|
1477 if (aBearerType.Compare(TPtrC(KCDTypeNameModemBearer)) == 0) |
|
1478 { |
|
1479 aElementId = KCDTIdModemBearerRecord; |
|
1480 return KErrNone; |
|
1481 } |
|
1482 else |
|
1483 if (aBearerType.Compare(TPtrC(KCDTypeNameLANBearer)) == 0) |
|
1484 { |
|
1485 aElementId = KCDTIdLANBearerRecord; |
|
1486 return KErrNone; |
|
1487 } |
|
1488 else |
|
1489 if (aBearerType.Compare(TPtrC(KCDTypeNameVirtualBearer)) == 0) |
|
1490 { |
|
1491 aElementId = KCDTIdVirtualBearerRecord; |
|
1492 return KErrNone; |
|
1493 } |
|
1494 else |
|
1495 { |
|
1496 return KErrNotFound; |
|
1497 } |
|
1498 } |
|
1499 |
|
1500 TInt CCommsDatIapView::ConvertServiceTypeToTableId(const TDesC& aServiceType, TMDBElementId& aElementId) |
|
1501 { |
|
1502 if (aServiceType.Compare(TPtrC(KCDTypeNameDialOutISP)) == 0) |
|
1503 { |
|
1504 aElementId = KCDTIdDialOutISPRecord; |
|
1505 return KErrNone; |
|
1506 } |
|
1507 else if (aServiceType.Compare(TPtrC(KCDTypeNameDialInISP)) == 0) |
|
1508 { |
|
1509 aElementId = KCDTIdDialInISPRecord; |
|
1510 return KErrNone; |
|
1511 } |
|
1512 else if (aServiceType.Compare(TPtrC(KCDTypeNameLANService)) == 0) |
|
1513 { |
|
1514 aElementId = KCDTIdLANServiceRecord; |
|
1515 return KErrNone; |
|
1516 } |
|
1517 else if (aServiceType.Compare(TPtrC(KCDTypeNameVPNService)) == 0) |
|
1518 { |
|
1519 aElementId = KCDTIdVPNServiceRecord; |
|
1520 return KErrNone; |
|
1521 } |
|
1522 else if (aServiceType.Compare(TPtrC(KCDTypeNameOutgoingWCDMA)) == 0) |
|
1523 { |
|
1524 aElementId = KCDTIdOutgoingGprsRecord; |
|
1525 return KErrNone; |
|
1526 } |
|
1527 else if (aServiceType.Compare(TPtrC(KCDTypeNameIncomingWCDMA)) == 0) |
|
1528 { |
|
1529 aElementId = KCDTIdIncomingGprsRecord; |
|
1530 return KErrNone; |
|
1531 } |
|
1532 |
|
1533 return KErrNotFound; |
|
1534 } |
|
1535 |
|
1536 void CCommsDatIapView::IntFieldTypeCheckL(TInt aElementId) |
|
1537 { |
|
1538 CommsDat::TCDFieldValueTypes commsdat_type = static_cast<CommsDat::TCDFieldValueTypes>( |
|
1539 CommsDat::CommsDatSchemaV1_1::GetFieldTypeInfoL(aElementId)); |
|
1540 |
|
1541 if (CommsDat::EUint32 != commsdat_type && |
|
1542 CommsDat::EInt != commsdat_type && |
|
1543 CommsDat::ELink != (commsdat_type & CommsDat::ELink)) |
|
1544 { |
|
1545 User::Leave(KErrBadName); |
|
1546 } |
|
1547 } |
|
1548 |
|
1549 void CCommsDatIapView::BoolFieldTypeCheckL(TInt aElementId) |
|
1550 { |
|
1551 CommsDat::TCDFieldValueTypes commsdat_type = static_cast<CommsDat::TCDFieldValueTypes>( |
|
1552 CommsDat::CommsDatSchemaV1_1::GetFieldTypeInfoL(aElementId)); |
|
1553 |
|
1554 if (CommsDat::EBool != commsdat_type) |
|
1555 { |
|
1556 User::Leave(KErrBadName); |
|
1557 } |
|
1558 } |
|
1559 |
|
1560 void CCommsDatIapView::TextOrBinFieldTypeCheckL(TInt aElementId) |
|
1561 { |
|
1562 CommsDat::TCDFieldValueTypes commsdat_type = static_cast<CommsDat::TCDFieldValueTypes>( |
|
1563 CommsDat::CommsDatSchemaV1_1::GetFieldTypeInfoL(aElementId)); |
|
1564 |
|
1565 if (CommsDat::EText != commsdat_type && |
|
1566 CommsDat::EMedText != commsdat_type && |
|
1567 CommsDat::ELongText != commsdat_type && |
|
1568 CommsDat::EDesC8 != commsdat_type) |
|
1569 { |
|
1570 User::Leave(KErrBadName); |
|
1571 } |
|
1572 } |
|
1573 |
|
1574 |