|
1 /* |
|
2 * Copyright (c) 2006 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: Class CCatalogsAccessPointManager implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "catalogsaccesspointmanagerimpl.h" |
|
20 |
|
21 #include <ApUtils.h> |
|
22 #include <ApSelect.h> |
|
23 #include <ApDataHandler.h> |
|
24 #include <badesca.h> |
|
25 |
|
26 #include "catalogsaccesspoint.h" |
|
27 #include "catalogsaccesspointsettings.h" |
|
28 #include "catalogsaccesspointmap.h" |
|
29 #include "catalogsclientaccesspointdata.h" |
|
30 #include "ncdstorage.h" |
|
31 #include "ncdstoragemanager.h" |
|
32 #include "ncdproviderdefines.h" |
|
33 #include "ncdstorageitem.h" |
|
34 #include "ncddatabasestorage.h" |
|
35 #include "ncd_cp_detail.h" |
|
36 #include "ncd_cp_clientconfiguration.h" |
|
37 #include "ncdprotocolutils.h" |
|
38 #include "ncdnodeidentifier.h" |
|
39 #include "ncdnodeimpl.h" |
|
40 #include "ncdnodelink.h" |
|
41 #include "ncdproviderdefines.h" |
|
42 #include "ncdnodeidentifiereditor.h" |
|
43 #include "ncdsearchnodefolder.h" |
|
44 #include "ncdutils.h" |
|
45 #include "ncdgeneralmanager.h" |
|
46 #include "catalogshttpsessionmanagerimpl.h" |
|
47 #include "catalogsnetworkmanager.h" |
|
48 #include "catalogsremoveaccesspointshutdownoperation.h" |
|
49 #include "catalogsclientserverserver.h" |
|
50 |
|
51 #include "catalogsdebug.h" |
|
52 |
|
53 // literals used in client configuration protocol |
|
54 _LIT(KAccessPoints, "accessPoints"); |
|
55 _LIT(KContentSources, "contentSources"); |
|
56 _LIT(KNamespace, "namespace"); |
|
57 _LIT(KId, "id"); |
|
58 _LIT(KCatalogBundle, "catalogBundle"); |
|
59 _LIT(KSubCatalogs, "subCatalogs"); |
|
60 _LIT(KDownloadAccessPoint, "downloadingAccessPoint"); |
|
61 _LIT(KBrowseAccessPoint, "browsingAccessPoint"); |
|
62 _LIT(KPurchaseAccessPoint, "purchasingAccessPoint"); |
|
63 |
|
64 // literals used for access point settings in client configuration protocol (in alphabetical order) |
|
65 _LIT(KApName, "name"); |
|
66 |
|
67 |
|
68 _LIT(KApCdmaDisablePlainTextAuth, "EApCdmaDisablePlainTextAuth"); |
|
69 _LIT(KApCdmaIfAuthName, "EApCdmaIfAuthName"); |
|
70 _LIT(KApCdmaIfAuthPassword, "EApCdmaIfAuthPassword"); |
|
71 _LIT(KApCdmaIfName, "EApCdmaIfName"); |
|
72 _LIT(KApCdmaIfNetworks, "EApCdmaIfNetworks"); |
|
73 _LIT(KApCdmaIpAddr, "EApCdmaIpAddr"); |
|
74 _LIT(KApCdmaIpAddrFromServer, "EApCdmaIpAddrFromServer"); |
|
75 _LIT(KApCdmaIpDnsAddrFromServer, "EApCdmaIpDnsAddrFromServer"); |
|
76 _LIT(KApCdmaIpGateway, "EApCdmaIpGateway"); |
|
77 _LIT(KApCdmaIPNameServer1, "EApCdmaIPNameServer1"); |
|
78 _LIT(KApCdmaIPNameServer2, "EApCdmaIPNameServer2"); |
|
79 _LIT(KApCdmaIpNetMask, "EApCdmaIpNetMask"); |
|
80 _LIT(KApGprsAccessPointName, "EApGprsAccessPointName"); |
|
81 _LIT(KApGprsDisablePlainTextAuth, "EApGprsDisablePlainTextAuth"); |
|
82 _LIT(KApGprsIfAuthName, "EApGprsIfAuthName"); |
|
83 _LIT(KApGprsIfAuthPassword, "EApGprsIfAuthPassword"); |
|
84 _LIT(KApGprsIfName, "EApGprsIfName"); |
|
85 _LIT(KApGprsIfNetworks, "EApGprsIfNetworks"); |
|
86 _LIT(KApGprsIfParams, "EApGprsIfParams"); |
|
87 _LIT(KApGprsIfPromptForAuth, "EApGprsIfPromptForAuth"); |
|
88 _LIT(KApGprsIpAddr, "EApGprsIpAddr"); |
|
89 _LIT(KApGprsIpAddrFromServer, "EApGprsIpAddrFromServer"); |
|
90 _LIT(KApGprsIpDnsAddrFromServer, "EApGprsIpDnsAddrFromServer"); |
|
91 _LIT(KApGprsIpGateway, "EApGprsIpGateway"); |
|
92 _LIT(KApGprsIPNameServer1, "EApGprsIPNameServer1"); |
|
93 _LIT(KApGprsIPNameServer2, "EApGprsIPNameServer2"); |
|
94 _LIT(KApGprsIpNetMask, "EApGprsIpNetMask"); |
|
95 _LIT(KApGprsPdpAddress, "EApGprsPdpAddress"); |
|
96 _LIT(KApHasProxySettings, "EApHasProxySettings"); |
|
97 _LIT(KApIapChargecard, "EApIapChargecard"); |
|
98 _LIT(KApIapName, "EApIapName"); |
|
99 _LIT(KApIapServiceId, "EApIapServiceId"); |
|
100 _LIT(KApIapServiceType, "EApIapServiceType"); |
|
101 _LIT(KApIP6NameServer1, "EApIP6NameServer1"); |
|
102 _LIT(KApIP6NameServer2, "EApIP6NameServer2"); |
|
103 _LIT(KApIspDefaultTelNumber, "EApIspDefaultTelNumber"); |
|
104 _LIT(KApIspDescription, "EApIspDescription"); |
|
105 _LIT(KApIspDisablePlainTextAuth, "EApIspDisablePlainTextAuth"); |
|
106 _LIT(KApIspIfAuthName, "EApIspIfAuthName"); |
|
107 _LIT(KApIspIfAuthPass, "EApIspIfAuthPass"); |
|
108 _LIT(KApIspIfCallbackInfo, "EApIspIfCallbackInfo"); |
|
109 _LIT(KApIspIfName, "EApIspIfName"); |
|
110 _LIT(KApIspIfNetworks, "EApIspIfNetworks"); |
|
111 _LIT(KApIspIfParams, "EApIspIfParams"); |
|
112 _LIT(KApIspInitString, "EApIspInitString"); |
|
113 _LIT(KApIspIPAddr, "EApIspIPAddr"); |
|
114 _LIT(KApIspIPAddrFromServer, "EApIspIPAddrFromServer"); |
|
115 _LIT(KApIspIPDnsAddrFromServer, "EApIspIPDnsAddrFromServer"); |
|
116 _LIT(KApIspIPGateway, "EApIspIPGateway"); |
|
117 _LIT(KApIspIPNameServer1, "EApIspIPNameServer1"); |
|
118 _LIT(KApIspIPNameServer2, "EApIspIPNameServer2"); |
|
119 _LIT(KApIspIPNetMask, "EApIspIPNetMask"); |
|
120 _LIT(KApIspIspType, "EApIspIspType"); |
|
121 _LIT(KApIspLoginName, "EApIspLoginName"); |
|
122 _LIT(KApIspLoginPass, "EApIspLoginPass"); |
|
123 _LIT(KApIspLoginScript, "EApIspLoginScript"); |
|
124 _LIT(KApIspName, "EApIspName"); |
|
125 _LIT(KApLanBearerName, "EApLanBearerName"); |
|
126 _LIT(KApNetworkName, " EApNetworkName"); |
|
127 _LIT(KApProxyExceptions, "EApProxyExceptions"); |
|
128 _LIT(KApProxyLoginName, "EApProxyLoginName"); |
|
129 _LIT(KApProxyLoginPass, "EApProxyLoginPass"); |
|
130 _LIT(KApProxyPortNumber, "EApProxyPortNumber"); |
|
131 _LIT(KApProxyProtocolName, "EApProxyProtocolName"); |
|
132 _LIT(KApProxyServerAddress, "EApProxyServerAddress"); |
|
133 _LIT(KApProxyUseProxy, "EApProxyUseProxy"); |
|
134 _LIT(KApWapAccessPointName, "EApWapAccessPointName"); |
|
135 _LIT(KApWapCurrentBearer, "EApWapCurrentBearer"); |
|
136 _LIT(KApWapGatewayAddress, "EApWapGatewayAddress"); |
|
137 _LIT(KApWapIap, "EApWapIap"); |
|
138 _LIT(KApWapProxyPort, "EApWapProxyPort"); |
|
139 _LIT(KApWapSecurity, "EApWapSecurity"); |
|
140 _LIT(KApWapStartPage, "EApWapStartPage"); |
|
141 _LIT(KApWapWspOption, "EApWapWspOption"); |
|
142 _LIT(KApWlanIfAuthName, "EApWlanIfAuthName"); |
|
143 _LIT(KApWlanIfAuthPassword, "EApWlanIfAuthPassword"); |
|
144 _LIT(KApWlanIfNetworks, "EApWlanIfNetworks"); |
|
145 _LIT(KApWlanIpAddr, "EApWlanIpAddr"); |
|
146 _LIT(KApWlanIpAddrFromServer, "EApWlanIpAddrFromServer"); |
|
147 _LIT(KApWlanIpDnsAddrFromServer, "EApWlanIpDnsAddrFromServer"); |
|
148 _LIT(KApWlanIpGateway, "EApWlanIpGateway"); |
|
149 _LIT(KApWlanIPNameServer1, "EApWlanIPNameServer1"); |
|
150 _LIT(KApWlanIPNameServer2, "EApWlanIPNameServer2"); |
|
151 _LIT(KApWlanIpNetMask, "EApWlanIpNetMask"); |
|
152 |
|
153 _LIT(KWapWspOptionConnectionless, "EWapWspOptionConnectionless"); |
|
154 _LIT(KWapWspOptionConnectionOriented, "EWapWspOptionConnectionOriented"); |
|
155 |
|
156 |
|
157 CCatalogsAccessPointManager::CCatalogsAccessPointManager( |
|
158 CNcdGeneralManager& aGeneralManager ) : |
|
159 iGeneralManager( aGeneralManager ), |
|
160 iStorageManager( aGeneralManager.StorageManager() ), |
|
161 iNodeManager( aGeneralManager.NodeManager() ), |
|
162 iCheckAp( ETrue ) |
|
163 { |
|
164 } |
|
165 |
|
166 CCatalogsAccessPointManager::~CCatalogsAccessPointManager() |
|
167 { |
|
168 DLTRACEIN(("")); |
|
169 |
|
170 TRAP_IGNORE( DestructL() ); |
|
171 |
|
172 delete iClientAccessPointData; |
|
173 delete iFixedAp; |
|
174 } |
|
175 |
|
176 CCatalogsAccessPointManager* CCatalogsAccessPointManager::NewL( |
|
177 CNcdGeneralManager& aGeneralManager ) |
|
178 { |
|
179 CCatalogsAccessPointManager* apMan = |
|
180 new (ELeave) CCatalogsAccessPointManager( aGeneralManager ); |
|
181 CleanupStack::PushL( apMan ); |
|
182 apMan->ConstructL(); |
|
183 CleanupStack::Pop( apMan ); |
|
184 return apMan; |
|
185 } |
|
186 |
|
187 void CCatalogsAccessPointManager::ConstructL() |
|
188 { |
|
189 DLTRACEIN(("")); |
|
190 CCatalogsHttpSessionManager::NetworkManagerL().AddObserverL( *this ); |
|
191 } |
|
192 |
|
193 void CCatalogsAccessPointManager::SetFixedApL( |
|
194 const RPointerArray<CNcdKeyValuePair>& aApDetails ) |
|
195 { |
|
196 DLTRACEIN(("")); |
|
197 DASSERT( !iFixedAp ); |
|
198 |
|
199 // Create CCatalogsAccessPoint object and set the details to it. |
|
200 CCatalogsAccessPoint* ap = CCatalogsAccessPoint::NewLC( KNullDesC, KNullDesC ); |
|
201 TInt detailCount = aApDetails.Count(); |
|
202 for ( TInt i = 0; i < detailCount; i++ ) |
|
203 { |
|
204 CNcdKeyValuePair* detail = aApDetails[ i ]; |
|
205 SetApDetailL( *ap, detail->Key(), detail->Value() ); |
|
206 } |
|
207 |
|
208 |
|
209 if ( !ap->Name().Length() ) |
|
210 { |
|
211 DLERROR(("No accesspoint name given")); |
|
212 User::Leave( KErrArgument ); |
|
213 } |
|
214 |
|
215 CreateAccessPointL( *ap ); |
|
216 iFixedAp = ap; |
|
217 CleanupStack::Pop( ap ); |
|
218 } |
|
219 |
|
220 |
|
221 void CCatalogsAccessPointManager::GetFixedApL( TUint32& aAccessPointId ) |
|
222 { |
|
223 DLTRACEIN(("")); |
|
224 if ( iFixedAp ) |
|
225 { |
|
226 // We need to check that the AP in Commsdb matches wanted settings |
|
227 if ( iCheckAp ) |
|
228 { |
|
229 DLTRACE(("Checking AP")); |
|
230 // iCheckAp is set to EFalse in HandleAccessPointEventL |
|
231 // when an AP has been raised |
|
232 |
|
233 // Only parameter that matters here is aAccessPointId |
|
234 AccessPointIdL( |
|
235 KNullDesC, |
|
236 EBrowse, |
|
237 TUid(), |
|
238 aAccessPointId ); |
|
239 } |
|
240 else |
|
241 { |
|
242 aAccessPointId = iFixedAp->AccessPointId(); |
|
243 DLTRACE(("AP ID: %u", aAccessPointId )); |
|
244 } |
|
245 } |
|
246 } |
|
247 |
|
248 |
|
249 void CCatalogsAccessPointManager::ParseAccessPointDataFromClientConfL( |
|
250 const MNcdConfigurationProtocolClientConfiguration& aConfiguration, |
|
251 const TUid& /*aClientUid*/, |
|
252 TBool aIgnoreFixedAp, |
|
253 RArray<TUint32>* aCreatedAps ) |
|
254 { |
|
255 DLTRACEIN(("Starting to parse access point data from client configuration")); |
|
256 |
|
257 if ( iFixedAp && !aIgnoreFixedAp ) |
|
258 { |
|
259 DLINFO(("Fixed AP used, no need to parse AP data")); |
|
260 return; |
|
261 } |
|
262 |
|
263 for( TInt i = 0 ; i < aConfiguration.DetailCount() ; i++ ) |
|
264 { |
|
265 const MNcdConfigurationProtocolDetail& detail = aConfiguration.DetailL( i ); |
|
266 if (detail.Id() == KAccessPoints) |
|
267 { |
|
268 // parse access point details |
|
269 CreateAccessPointsFromClientConfL( detail, aCreatedAps ); |
|
270 } |
|
271 else if (detail.Id() == KContentSources) |
|
272 { |
|
273 const RPointerArray<MNcdConfigurationProtocolDetail>& csDetails = detail.Details(); |
|
274 for (TInt i = 0; i < csDetails.Count(); i++) |
|
275 { |
|
276 MNcdConfigurationProtocolDetail* csDetail = csDetails[i]; |
|
277 |
|
278 if (csDetail->GroupId() == KNullDesC && csDetail->Id() == KNamespace) |
|
279 { |
|
280 const TDesC& nameSpace = csDetail->Value(); |
|
281 const TDesC* id = NULL; |
|
282 const RPointerArray<MNcdConfigurationProtocolContent>& nsContents = |
|
283 csDetail->Contents(); |
|
284 for (TInt i = 0; i < nsContents.Count(); i++) |
|
285 { |
|
286 MNcdConfigurationProtocolContent* content = nsContents[i]; |
|
287 if (content->Key() == KId) |
|
288 { |
|
289 id = &content->Value(); |
|
290 break; |
|
291 } |
|
292 } |
|
293 |
|
294 const RPointerArray<MNcdConfigurationProtocolDetail>& nsDetails = csDetail->Details(); |
|
295 |
|
296 if (nsDetails.Count() > 0) |
|
297 { |
|
298 MNcdConfigurationProtocolDetail* uriDetail = nsDetails[0]; |
|
299 const RPointerArray<MNcdConfigurationProtocolDetail>& apDetails = uriDetail->Details(); |
|
300 |
|
301 for (TInt i = 0; i < apDetails.Count(); i++) |
|
302 { |
|
303 MNcdConfigurationProtocolDetail* apDetail = apDetails[i]; |
|
304 const TDesC& accessPointId = apDetail->Value(); |
|
305 MCatalogsAccessPointManager::TAction action; |
|
306 TBool unknown = EFalse; |
|
307 if (apDetail->Id() == KDownloadAccessPoint) |
|
308 { |
|
309 action = MCatalogsAccessPointManager::EDownload; |
|
310 } |
|
311 else if (apDetail->Id() == KBrowseAccessPoint) |
|
312 { |
|
313 action = MCatalogsAccessPointManager::EBrowse; |
|
314 } |
|
315 else if (apDetail->Id() == KPurchaseAccessPoint) |
|
316 { |
|
317 action = MCatalogsAccessPointManager::EPurchase; |
|
318 } |
|
319 else |
|
320 { |
|
321 DLWARNING((_L("Unknown detail id: %S"),&apDetail->Id())); |
|
322 unknown = ETrue; |
|
323 } |
|
324 |
|
325 if (!unknown && id) |
|
326 { |
|
327 MapAccessPointL( |
|
328 nameSpace, *id, action, accessPointId ); |
|
329 } |
|
330 else if (!unknown) |
|
331 { |
|
332 MapAccessPointL( |
|
333 nameSpace, action, accessPointId ); |
|
334 } |
|
335 } |
|
336 } |
|
337 } |
|
338 |
|
339 else if (csDetail->GroupId() == KCatalogBundle) |
|
340 { |
|
341 const RPointerArray<MNcdConfigurationProtocolDetail>& bundleDetails = |
|
342 csDetail->Details(); |
|
343 for (TInt i = 0; i < bundleDetails.Count(); i++) |
|
344 { |
|
345 MNcdConfigurationProtocolDetail* bundleDetail = bundleDetails[i]; |
|
346 if (bundleDetail->GroupId() != KSubCatalogs) |
|
347 { |
|
348 continue; |
|
349 } |
|
350 |
|
351 // find the subcatalog ID |
|
352 const TDesC* id = NULL; |
|
353 const RPointerArray<MNcdConfigurationProtocolContent>& subCatalogContents = |
|
354 bundleDetail->Contents(); |
|
355 for (TInt i = 0; i < subCatalogContents.Count(); i++) |
|
356 { |
|
357 if (subCatalogContents[i]->Key() == KId) |
|
358 { |
|
359 id = &subCatalogContents[i]->Value(); |
|
360 break; |
|
361 } |
|
362 } |
|
363 |
|
364 const TDesC& nameSpace = bundleDetail->Value(); |
|
365 const RPointerArray<MNcdConfigurationProtocolDetail>& subCatalogDetails = |
|
366 bundleDetail->Details(); |
|
367 if (subCatalogDetails.Count() > 0) |
|
368 { |
|
369 MNcdConfigurationProtocolDetail* scDetail = subCatalogDetails[0]; |
|
370 const RPointerArray<MNcdConfigurationProtocolDetail>& apDetails = |
|
371 scDetail->Details(); |
|
372 for (TInt i = 0; i < apDetails.Count(); i++) |
|
373 { |
|
374 MNcdConfigurationProtocolDetail* apDetail = apDetails[i]; |
|
375 const TDesC& accessPointId = apDetail->Value(); |
|
376 MCatalogsAccessPointManager::TAction action; |
|
377 TBool unknown = EFalse; |
|
378 if (apDetail->Id() == KDownloadAccessPoint) |
|
379 { |
|
380 action = EDownload; |
|
381 } |
|
382 else if (apDetail->Id() == KBrowseAccessPoint) |
|
383 { |
|
384 action = EBrowse; |
|
385 } |
|
386 else if (apDetail->Id() == KPurchaseAccessPoint) |
|
387 { |
|
388 action = EPurchase; |
|
389 } |
|
390 else |
|
391 { |
|
392 DLWARNING((_L("Unknown detail id: %S"), &apDetail->Id())); |
|
393 unknown = ETrue; |
|
394 } |
|
395 |
|
396 if (!unknown && id) |
|
397 { |
|
398 MapAccessPointL( |
|
399 nameSpace, *id, action, accessPointId ); |
|
400 } |
|
401 else if (!unknown) |
|
402 { |
|
403 MapAccessPointL( |
|
404 nameSpace, action, accessPointId ); |
|
405 } |
|
406 } |
|
407 } |
|
408 } |
|
409 } |
|
410 } |
|
411 } |
|
412 } |
|
413 SaveToStorageL(); |
|
414 DLTRACEOUT(("Access point data from client configuration parsed")); |
|
415 } |
|
416 |
|
417 |
|
418 void CCatalogsAccessPointManager::CreateAccessPointsFromClientConfL( |
|
419 const MNcdConfigurationProtocolDetail& aDetail, |
|
420 RArray<TUint32>* aCreatedAps ) |
|
421 { |
|
422 DLTRACEIN(("Creating access points from client configuration")); |
|
423 const RPointerArray<MNcdConfigurationProtocolDetail>& apDetails = aDetail.Details(); |
|
424 TInt apCount = apDetails.Count(); |
|
425 |
|
426 for (TInt i = 0; i < apCount; i++) |
|
427 { |
|
428 MNcdConfigurationProtocolDetail* apDetail = apDetails[i]; |
|
429 CCatalogsAccessPoint* ap = CCatalogsAccessPoint::NewLC(apDetail->Id(), KNullDesC); |
|
430 |
|
431 const RPointerArray<MNcdConfigurationProtocolContent>& apContents = |
|
432 apDetail->Contents(); |
|
433 TInt contentCount = apContents.Count(); |
|
434 for (TInt i = 0; i < contentCount; i++) |
|
435 { |
|
436 MNcdConfigurationProtocolContent* content = apContents[i]; |
|
437 SetApDetailL( *ap, content->Key(), content->Value() ); |
|
438 } |
|
439 CreateAccessPointL( ap ); |
|
440 CleanupStack::Pop( ap ); |
|
441 |
|
442 if ( aCreatedAps ) |
|
443 { |
|
444 DLTRACE(("Adding accesspoint id to aCreatedAps")); |
|
445 aCreatedAps->AppendL( ap->AccessPointId() ); |
|
446 } |
|
447 |
|
448 } |
|
449 DLTRACEOUT(("Access points created from client configuration")); |
|
450 } |
|
451 |
|
452 |
|
453 void CCatalogsAccessPointManager::CreateAccessPointL( |
|
454 CCatalogsAccessPoint* aSettings ) |
|
455 { |
|
456 CreateAccessPointL( *aSettings ); |
|
457 |
|
458 if ( !iClientAccessPointData ) |
|
459 { |
|
460 iClientAccessPointData = CCatalogsClientAccessPointData::NewL(); |
|
461 } |
|
462 |
|
463 iClientAccessPointData->AddAccessPointL( aSettings ); |
|
464 } |
|
465 |
|
466 void CCatalogsAccessPointManager::CreateAccessPointL( CCatalogsAccessPoint& aSettings ) |
|
467 { |
|
468 DLTRACEIN(("Creating access point")); |
|
469 |
|
470 // Check if comms database already have access point with suitable settings. |
|
471 TUint32 iapId = 0; |
|
472 if( MatchInCommsDbL( aSettings, iapId ) ) |
|
473 { |
|
474 DLTRACE(("Matching AP found from comms DB, access point id: %d", iapId)); |
|
475 // There is no need to create own access point settings to the comms database. |
|
476 aSettings.SetAccessPointId( iapId ); |
|
477 } |
|
478 |
|
479 // Create new access point to the comms database |
|
480 else |
|
481 { |
|
482 DLTRACE(_L("Mathing AP not found from comms DB, creating new one")); |
|
483 CreateApToCommsDBL( aSettings, iapId ); |
|
484 aSettings.SetAccessPointId( iapId ); |
|
485 // Mark this access point for deletition at the manager's destructor. |
|
486 // Fix for [#PRECLI-1596]. |
|
487 aSettings.SetCreatedByManager(); |
|
488 DLTRACE(("Created access point: %d", iapId)); |
|
489 } |
|
490 DLTRACEOUT(("Access point created")); |
|
491 } |
|
492 |
|
493 |
|
494 void CCatalogsAccessPointManager::MapAccessPointL( |
|
495 const TDesC& aNameSpace, |
|
496 const CCatalogsAccessPointManager::TAction& aType, |
|
497 const TDesC& aApId ) |
|
498 { |
|
499 DLTRACEIN((_L("Namespace: %S, Action: %d, access point id: %S "), |
|
500 &aNameSpace, aType, &aApId )); |
|
501 |
|
502 if ( !iClientAccessPointData ) |
|
503 { |
|
504 iClientAccessPointData = CCatalogsClientAccessPointData::NewL(); |
|
505 } |
|
506 |
|
507 iClientAccessPointData->MapAccessPointL( aNameSpace, aType, aApId ); |
|
508 |
|
509 DLTRACEOUT(("")); |
|
510 } |
|
511 |
|
512 |
|
513 void CCatalogsAccessPointManager::MapAccessPointL( |
|
514 const TDesC& aNameSpace, |
|
515 const TDesC& aCatalogId, |
|
516 const CCatalogsAccessPointManager::TAction& aAction, |
|
517 const TDesC& aApId ) |
|
518 { |
|
519 DLTRACEIN((_L("Namespace: %S, CatalogId: %S, Action: %d, access point id: %S"), |
|
520 &aNameSpace, &aCatalogId, aAction, &aApId )); |
|
521 |
|
522 if ( !iClientAccessPointData ) |
|
523 { |
|
524 iClientAccessPointData = CCatalogsClientAccessPointData::NewL(); |
|
525 } |
|
526 |
|
527 iClientAccessPointData->MapAccessPointL( |
|
528 aNameSpace, aCatalogId, aAction, aApId ); |
|
529 DLTRACEOUT(("")); |
|
530 } |
|
531 |
|
532 |
|
533 TInt CCatalogsAccessPointManager::AccessPointIdL( |
|
534 const TDesC& aNameSpace, |
|
535 const MCatalogsAccessPointManager::TAction& aAction, |
|
536 const TUid& aClientUid, |
|
537 TUint32& aAccessPointId ) |
|
538 { |
|
539 DLTRACEIN((_L("Namespace: %S, Action: %d, clientUid: %d"), &aNameSpace, aAction, aClientUid.iUid)); |
|
540 |
|
541 CCatalogsAccessPoint* accessPoint( NULL ); |
|
542 CCatalogsClientAccessPointData* apData( NULL ); |
|
543 TInt err = GetAccessPoint( accessPoint, apData ); |
|
544 if ( err != KErrNone ) |
|
545 { |
|
546 DLERROR(("Error: %d", err)); |
|
547 return err; |
|
548 } |
|
549 |
|
550 if ( !accessPoint ) |
|
551 { |
|
552 DASSERT( apData ); |
|
553 accessPoint = apData->AccessPoint( aNameSpace, aAction ); |
|
554 } |
|
555 |
|
556 return ValidateOrCreateAccessPointL( accessPoint, aAccessPointId ); |
|
557 } |
|
558 |
|
559 |
|
560 TInt CCatalogsAccessPointManager::AccessPointIdL( |
|
561 const TDesC& aNameSpace, |
|
562 const TDesC& aCatalogId, |
|
563 const MCatalogsAccessPointManager::TAction& aAction, |
|
564 const TUid& aClientUid, |
|
565 TUint32& aAccessPointId) |
|
566 { |
|
567 DLTRACEIN((_L("Namespace: %S, CatalogId: %S, Action: %d, clientUid: %d"), &aNameSpace, &aCatalogId, aAction, aClientUid.iUid)); |
|
568 CCatalogsAccessPoint* accessPoint( NULL ); |
|
569 CCatalogsClientAccessPointData* apData( NULL ); |
|
570 TInt err = GetAccessPoint( accessPoint, apData ); |
|
571 if ( err != KErrNone ) |
|
572 { |
|
573 DLERROR(("Error: %d", err)); |
|
574 return err; |
|
575 } |
|
576 |
|
577 if ( !accessPoint ) |
|
578 { |
|
579 DASSERT( apData ); |
|
580 accessPoint = apData->AccessPointL( aNameSpace, aCatalogId, aAction ); |
|
581 } |
|
582 |
|
583 return ValidateOrCreateAccessPointL( accessPoint, aAccessPointId ); |
|
584 } |
|
585 |
|
586 |
|
587 TInt CCatalogsAccessPointManager::AccessPointIdL( |
|
588 const CNcdNodeIdentifier& aNodeIdentifier, |
|
589 const MCatalogsAccessPointManager::TAction& aAction, |
|
590 const TUid& aClientUid, |
|
591 TUint32& aAccessPointId) |
|
592 { |
|
593 DLTRACEIN((_L("Namespace: %S, NodeId: %S, Action: %d, clientUid: %d"), |
|
594 &aNodeIdentifier.NodeNameSpace(), &aNodeIdentifier.NodeId(), aAction, |
|
595 aClientUid.iUid)); |
|
596 |
|
597 CCatalogsAccessPoint* accessPoint( NULL ); |
|
598 CCatalogsClientAccessPointData* apData( NULL ); |
|
599 TInt err = GetAccessPoint( accessPoint, apData ); |
|
600 if ( err != KErrNone ) |
|
601 { |
|
602 DLERROR(("Error: %d", err)); |
|
603 return err; |
|
604 } |
|
605 |
|
606 if ( !accessPoint ) |
|
607 { |
|
608 DASSERT( apData ); |
|
609 accessPoint = FindAccessPointL( |
|
610 aNodeIdentifier, aAction, *apData ); |
|
611 } |
|
612 |
|
613 return ValidateOrCreateAccessPointL( accessPoint, aAccessPointId ); |
|
614 } |
|
615 |
|
616 |
|
617 void CCatalogsAccessPointManager::HandleAccessPointEventL( |
|
618 const TCatalogsConnectionMethod& /* aAp */, |
|
619 const TCatalogsAccessPointEvent& aEvent ) |
|
620 { |
|
621 DLTRACEIN(("")); |
|
622 |
|
623 if ( aEvent == ECatalogsAccessPointClosed || |
|
624 aEvent == ECatalogsAccessPointReallyClosed ) |
|
625 { |
|
626 DLTRACE(("Ap closed, need to check it when connecting")); |
|
627 // Connection has been closed, we want to ensure |
|
628 // that we use the correct AP settings even if |
|
629 // someone tampers with the existing AP |
|
630 iCheckAp = ETrue; |
|
631 } |
|
632 else |
|
633 { |
|
634 iCheckAp = EFalse; |
|
635 } |
|
636 } |
|
637 |
|
638 |
|
639 CCatalogsAccessPoint* CCatalogsAccessPointManager::FindAccessPointL( |
|
640 const CNcdNodeIdentifier& aNodeIdentifier, |
|
641 const MCatalogsAccessPointManager::TAction& aAction, |
|
642 const CCatalogsClientAccessPointData& aAccessPointData ) |
|
643 { |
|
644 DLTRACEIN(("")); |
|
645 CCatalogsAccessPoint* accessPoint = NULL; |
|
646 const CNcdNodeIdentifier* nodeIdentifier = &aNodeIdentifier; |
|
647 |
|
648 if( NcdNodeIdentifierEditor::IdentifiesSearchNodeL( *nodeIdentifier ) ) |
|
649 { |
|
650 // Search node, retrieve origin identifier. |
|
651 // Requesting ap for a search node so node should always exist and |
|
652 // it's safe to ask it from nodemanager. |
|
653 CNcdNode& node = iNodeManager.NodeL( *nodeIdentifier ); |
|
654 //const CNcdNodeIdentifier* originIdentifier = NULL; |
|
655 if( node.ClassId() == NcdNodeClassIds::ENcdSearchItemNodeClassId ) |
|
656 { |
|
657 // get the parent folder's origin identifier |
|
658 nodeIdentifier = |
|
659 &iNodeManager.SearchFolderL( node.NodeLinkL().ParentIdentifier() ) |
|
660 .OriginIdentifierL(); |
|
661 } |
|
662 else if( node.ClassId() == NcdNodeClassIds::ENcdSearchFolderNodeClassId ) |
|
663 { |
|
664 nodeIdentifier = |
|
665 &(static_cast<CNcdSearchNodeFolder&>(node).OriginIdentifierL()); |
|
666 } |
|
667 else |
|
668 { |
|
669 // search root or search budle, no origin identifier available |
|
670 return NULL; |
|
671 } |
|
672 } |
|
673 |
|
674 if ( nodeIdentifier->NodeId() == KNullDesC ) |
|
675 { |
|
676 accessPoint = aAccessPointData.AccessPoint( |
|
677 nodeIdentifier->NodeNameSpace(), aAction ); |
|
678 } |
|
679 else |
|
680 { |
|
681 accessPoint = aAccessPointData.AccessPointL( |
|
682 nodeIdentifier->NodeNameSpace(), nodeIdentifier->NodeId(), aAction ); |
|
683 } |
|
684 |
|
685 if ( !accessPoint && |
|
686 nodeIdentifier->NodeNameSpace() != NcdProviderDefines::KRootNodeNameSpace && |
|
687 !NcdNodeIdentifierEditor::IdentifiesTemporaryNodeL( *nodeIdentifier ) ) |
|
688 { |
|
689 |
|
690 // Get parent identifier from child identifier. |
|
691 // NOTE: Parent is not required to exist in cache/db for this to work. |
|
692 CNcdNodeIdentifier* parentIdentifier = NcdNodeIdentifierEditor::ParentOfLC( *nodeIdentifier ); |
|
693 |
|
694 if ( parentIdentifier->NodeNameSpace() == NcdProviderDefines::KRootNodeNameSpace ) |
|
695 { |
|
696 // already at root node |
|
697 CleanupStack::PopAndDestroy( parentIdentifier ); |
|
698 return NULL; |
|
699 } |
|
700 // Partial fix for PRECLI-1321 |
|
701 // This prevents missing parents from causing unwanted leaves |
|
702 else if ( !parentIdentifier->ContainsEmptyFields() ) |
|
703 { |
|
704 accessPoint = FindAccessPointL( *parentIdentifier, aAction, aAccessPointData ); |
|
705 } |
|
706 CleanupStack::PopAndDestroy( parentIdentifier ); |
|
707 return accessPoint; |
|
708 } |
|
709 |
|
710 return accessPoint; |
|
711 } |
|
712 |
|
713 |
|
714 TBool CCatalogsAccessPointManager::ValidateAccessPointL( CCatalogsAccessPoint* aAccessPoint ) |
|
715 { |
|
716 DLTRACEIN(("")); |
|
717 #ifdef __WINS__ |
|
718 // Comms database is not accessible in emulator. |
|
719 return EFalse; |
|
720 #endif |
|
721 CCommsDatabase *commdb = CCommsDatabase::NewL( /*EDatabaseTypeIAP*/ ); |
|
722 CleanupStack::PushL( commdb ); |
|
723 CApSelect* select; |
|
724 select = CApSelect::NewLC( |
|
725 *commdb, |
|
726 KEApIspTypeAll, |
|
727 EApBearerTypeAll, |
|
728 KEApSortUidAscending |
|
729 ); |
|
730 |
|
731 CApDataHandler* handler = CApDataHandler::NewLC( *commdb ); |
|
732 CApUtils* util = CApUtils::NewLC( *commdb ); |
|
733 |
|
734 // Loop through array and try to find the right access point. |
|
735 // After access point is found check that its parameters are still right. |
|
736 // If they aren't we have to create a new access point. |
|
737 TBool success = select->MoveToFirst(); |
|
738 while (success) |
|
739 { |
|
740 TUint32 wapId = 0; |
|
741 TRAPD( err, wapId = util->WapIdFromIapIdL( aAccessPoint->AccessPointId() ) ) |
|
742 if( err != KErrNone ) |
|
743 { |
|
744 // AccessPoint has propably been removed from the commsdatabase. |
|
745 CleanupStack::PopAndDestroy( 4 ); |
|
746 return EFalse; |
|
747 } |
|
748 |
|
749 if( select->Uid() != wapId ) |
|
750 { |
|
751 // This is not the right access point, proceed to the next one. |
|
752 success = select->MoveNext(); |
|
753 continue; |
|
754 } |
|
755 |
|
756 CApAccessPointItem* item = CApAccessPointItem::NewLC(); |
|
757 handler->AccessPointDataL( select->Uid(), *item ); |
|
758 |
|
759 // Check all the setting are similar in commsDb and in CCatalogsAccessPoint. |
|
760 TBool matching = MatchingSettingsL(*aAccessPoint, *item); |
|
761 |
|
762 CleanupStack::PopAndDestroy(5); |
|
763 return matching; |
|
764 } |
|
765 |
|
766 // Someone has altered the access point settings. |
|
767 CleanupStack::PopAndDestroy(4); |
|
768 return EFalse; |
|
769 } |
|
770 |
|
771 TBool CCatalogsAccessPointManager::MatchInCommsDbL( const CCatalogsAccessPointSettings& aSettings, TUint32& aId ) |
|
772 { |
|
773 DLTRACEIN(_L("Checking comms DB for matching access point")); |
|
774 #ifdef __WINS__ |
|
775 // Comms database is not accessible in emulator. |
|
776 return EFalse; |
|
777 #endif |
|
778 |
|
779 CCommsDatabase *commdb = CCommsDatabase::NewL( /*EDatabaseTypeIAP*/ ); |
|
780 CleanupStack::PushL( commdb ); |
|
781 CApSelect* select; |
|
782 select = CApSelect::NewLC( |
|
783 *commdb, |
|
784 KEApIspTypeAll, |
|
785 EApBearerTypeAll, |
|
786 KEApSortUidAscending |
|
787 ); |
|
788 |
|
789 CApDataHandler* handler = CApDataHandler::NewLC( *commdb ); |
|
790 CApUtils* util = CApUtils::NewLC( *commdb ); |
|
791 |
|
792 // Loop through array and check if there already exists an access poinst which settings |
|
793 // are suitable. |
|
794 TBool success = select->MoveToFirst(); |
|
795 while ( success ) |
|
796 { |
|
797 CApAccessPointItem* item = CApAccessPointItem::NewLC(); |
|
798 DLTRACE(("Loading access point data from comms DB")); |
|
799 handler->AccessPointDataL( select->Uid(), *item ); |
|
800 |
|
801 DLTRACE(("Access point data loaded from comms DB")); |
|
802 TBool matching = MatchingSettingsL(aSettings, *item); |
|
803 if ( !matching ) |
|
804 { |
|
805 success = select->MoveNext(); |
|
806 CleanupStack::PopAndDestroy(); // item |
|
807 continue; |
|
808 } |
|
809 |
|
810 // We have a match in all fields. |
|
811 aId = util->IapIdFromWapIdL( select->Uid() ); |
|
812 CleanupStack::PopAndDestroy( 5, commdb ); // item, util, handler, select, commdb |
|
813 DLTRACEOUT(("Matching AP found")); |
|
814 return ETrue; |
|
815 } |
|
816 |
|
817 CleanupStack::PopAndDestroy( 4, commdb ); // util, handler, select, commdb |
|
818 DLTRACEOUT(("Matching AP not found")); |
|
819 return EFalse; |
|
820 } |
|
821 |
|
822 void CCatalogsAccessPointManager::CreateApToCommsDBL( const CCatalogsAccessPoint& aSettings, TUint32& aId ) |
|
823 { |
|
824 DLTRACEIN(_L("Creating AP to comms DB")); |
|
825 #ifdef __WINS__ |
|
826 // Comms database is not accessible in emulator. |
|
827 return; |
|
828 #endif |
|
829 CCommsDatabase *commdb = CCommsDatabase::NewL( /*EDatabaseTypeIAP*/ ); |
|
830 CleanupStack::PushL( commdb ); |
|
831 |
|
832 CApDataHandler* handler = CApDataHandler::NewLC( *commdb ); |
|
833 CApAccessPointItem* newAp = CApAccessPointItem::NewLC(); |
|
834 |
|
835 newAp->SetNamesL( aSettings.Name() ); |
|
836 |
|
837 // write the settings to newAp |
|
838 TInt longTextCount = aSettings.LongTextParameterCount(); |
|
839 for (TInt i = 0; i < longTextCount; i++) |
|
840 { |
|
841 TApMember key; |
|
842 TPtrC value; |
|
843 aSettings.LongTextParameter(i, key, value); |
|
844 newAp->WriteLongTextL(key, value); |
|
845 } |
|
846 |
|
847 TInt text16Count = aSettings.Text16ParameterCount(); |
|
848 for (TInt i = 0; i < text16Count; i++) |
|
849 { |
|
850 TApMember key; |
|
851 TPtrC16 value; |
|
852 aSettings.Text16Parameter(i, key, value); |
|
853 newAp->WriteTextL(key, value); |
|
854 } |
|
855 |
|
856 TInt text8Count = aSettings.Text8ParameterCount(); |
|
857 for (TInt i = 0; i < text8Count; i++) |
|
858 { |
|
859 TApMember key; |
|
860 TPtrC8 value; |
|
861 aSettings.Text8Parameter(i, key, value); |
|
862 newAp->WriteTextL(key, value); |
|
863 } |
|
864 |
|
865 TInt uintCount = aSettings.UintParameterCount(); |
|
866 for (TInt i = 0; i < uintCount; i++) |
|
867 { |
|
868 TApMember key; |
|
869 TUint32 value; |
|
870 aSettings.UintParameter(i, key, value); |
|
871 newAp->WriteUint(key, value); |
|
872 } |
|
873 |
|
874 TInt boolCount = aSettings.BoolParameterCount(); |
|
875 for (TInt i = 0; i < boolCount; i++) |
|
876 { |
|
877 TApMember key; |
|
878 TBool value; |
|
879 aSettings.BoolParameter(i, key, value); |
|
880 newAp->WriteBool(key, value); |
|
881 } |
|
882 |
|
883 if( !newAp->SanityCheckOk() ) |
|
884 { |
|
885 User::Leave( KErrArgument ); |
|
886 } |
|
887 |
|
888 TUint32 wapId = 0; |
|
889 TRAPD( err, wapId = handler->CreateFromDataL( *newAp ) ); |
|
890 if (err != KErrNone) |
|
891 { |
|
892 DLERROR(("Unable to create access point to comms DB")); |
|
893 User::Leave(err); |
|
894 } |
|
895 |
|
896 CApUtils* util = CApUtils::NewLC( *commdb ); |
|
897 aId = util->IapIdFromWapIdL( wapId ); |
|
898 CleanupStack::PopAndDestroy( 4, commdb ); // commDb, handler, newAp, util |
|
899 DLTRACEOUT(("Access point created to comms DB")); |
|
900 } |
|
901 |
|
902 HBufC16* CCatalogsAccessPointManager::ReadText16L( CApAccessPointItem* aItem, const TApMember& aApMember ) |
|
903 { |
|
904 TInt length = aItem->ReadTextLengthL( aApMember ); |
|
905 if( length == 0 ) |
|
906 { |
|
907 return KNullDesC16().AllocL(); |
|
908 } |
|
909 HBufC16* buffer = HBufC16::NewLC( length ); |
|
910 TPtr16 ptr( buffer->Des()); |
|
911 aItem->ReadTextL( aApMember, ptr ); |
|
912 CleanupStack::Pop(); // buffer |
|
913 return buffer; |
|
914 } |
|
915 |
|
916 HBufC8* CCatalogsAccessPointManager::ReadText8L( CApAccessPointItem* aItem, const TApMember& aApMember ) |
|
917 { |
|
918 TInt length = aItem->ReadTextLengthL( aApMember ); |
|
919 if( length == 0 ) |
|
920 { |
|
921 return KNullDesC8().AllocL(); |
|
922 } |
|
923 HBufC8* buffer = HBufC8::NewLC( length ); |
|
924 TPtr8 ptr( buffer->Des()); |
|
925 aItem->ReadTextL( aApMember, ptr ); |
|
926 CleanupStack::Pop(); // buffer |
|
927 return buffer; |
|
928 } |
|
929 |
|
930 |
|
931 void CCatalogsAccessPointManager::RemoveAccessPointsFromCommsDbL( |
|
932 TBool aAddShutdownOperation ) |
|
933 { |
|
934 |
|
935 if ( !iClientAccessPointData ) |
|
936 { |
|
937 return; |
|
938 } |
|
939 TInt apCount = iClientAccessPointData->AccessPointCount(); |
|
940 |
|
941 // remove the access points from comms db |
|
942 for ( TInt i = 0; i < apCount; i++ ) |
|
943 { |
|
944 // remove access point only if it has been created by the manager |
|
945 // Fix for [#PRECLI-1596] |
|
946 if ( iClientAccessPointData->AccessPoint( i ).CreatedByManager() ) |
|
947 { |
|
948 TUint32 idInCommsDb = |
|
949 iClientAccessPointData->AccessPoint( i ).AccessPointId(); |
|
950 TRAPD( err, RemoveApFromCommsDatabaseL( idInCommsDb ) ); |
|
951 |
|
952 if ( err != KErrNone && |
|
953 err != KErrNotFound && |
|
954 err != KErrNoMemory && |
|
955 aAddShutdownOperation ) |
|
956 { |
|
957 CCatalogsRemoveAccesspointShutdownOperation* op = |
|
958 CCatalogsRemoveAccesspointShutdownOperation::NewL( |
|
959 iGeneralManager.FamilyId(), |
|
960 idInCommsDb ); |
|
961 // takes ownership, deletes the op if adding fails |
|
962 CCatalogsClientServerServer::AddShutdownOperation( op ); |
|
963 } |
|
964 // we can ignore other errors |
|
965 else if ( err == KErrNoMemory ) |
|
966 { |
|
967 User::Leave( err ); |
|
968 } |
|
969 } |
|
970 } |
|
971 } |
|
972 |
|
973 |
|
974 void CCatalogsAccessPointManager::RemoveAccessPointsL() |
|
975 { |
|
976 // remove from comms db |
|
977 RemoveAccessPointsFromCommsDbL( EFalse ); |
|
978 |
|
979 delete iClientAccessPointData; |
|
980 iClientAccessPointData = NULL; |
|
981 } |
|
982 |
|
983 void CCatalogsAccessPointManager::RemoveApFromCommsDatabaseL( const TUint32& aId ) |
|
984 { |
|
985 DLTRACEIN(("aId: %u", aId )); |
|
986 CCommsDatabase *commdb = CCommsDatabase::NewL( EDatabaseTypeIAP ); |
|
987 CleanupStack::PushL( commdb ); |
|
988 CApDataHandler* dataHandler = CApDataHandler::NewLC( *commdb ); |
|
989 CApUtils* util = CApUtils::NewLC( *commdb ); |
|
990 TUint32 wapId = util->WapIdFromIapIdL( aId ); |
|
991 dataHandler->RemoveAPL( wapId ); |
|
992 |
|
993 CleanupStack::PopAndDestroy( 3, commdb ); // util, dataHandler, commdb |
|
994 } |
|
995 |
|
996 |
|
997 void CCatalogsAccessPointManager::LoadFromStorageL() |
|
998 { |
|
999 // delete clients access point data |
|
1000 RemoveAccessPointsL(); |
|
1001 |
|
1002 MNcdStorage& storage = iStorageManager.ProviderStorageL( |
|
1003 iGeneralManager.FamilyName() ); |
|
1004 MNcdDatabaseStorage& database = storage.DatabaseStorageL( |
|
1005 NcdProviderDefines::KDefaultDatabaseUid); // not sure if this the correct db |
|
1006 |
|
1007 if( !database.ItemExistsInStorageL( iGeneralManager.FamilyName(), |
|
1008 NcdProviderDefines::ENcdAccessPointManager ) ) |
|
1009 { |
|
1010 DLTRACE( ( _L("Data: %S was not in provider storage"), |
|
1011 &iGeneralManager.FamilyName() ) ); |
|
1012 User::Leave( KErrNotFound ); |
|
1013 } |
|
1014 |
|
1015 // Get the storage item from which the access point data is loaded |
|
1016 // Note: database has the ownership of the item |
|
1017 MNcdStorageItem* item = database.StorageItemL( |
|
1018 iGeneralManager.FamilyName(), |
|
1019 NcdProviderDefines::ENcdAccessPointManager ); |
|
1020 |
|
1021 // Get data from database by using CCatalogsClientAccessPointData as the target so that |
|
1022 // internalize will be called for it |
|
1023 CCatalogsClientAccessPointData* data = CCatalogsClientAccessPointData::NewLC(); |
|
1024 item->SetDataItem(data); |
|
1025 |
|
1026 // Read data -> calls CCatalogsClientAccessPointData::InternalizeL |
|
1027 item->ReadDataL(); |
|
1028 |
|
1029 iClientAccessPointData = data; |
|
1030 CleanupStack::Pop(); //data |
|
1031 } |
|
1032 |
|
1033 void CCatalogsAccessPointManager::SaveToStorageL() |
|
1034 { |
|
1035 if ( !iClientAccessPointData ) |
|
1036 { |
|
1037 return; |
|
1038 } |
|
1039 |
|
1040 MNcdStorage& storage = iStorageManager.ProviderStorageL( |
|
1041 iGeneralManager.FamilyName() ); |
|
1042 MNcdDatabaseStorage& database = storage.DatabaseStorageL( |
|
1043 NcdProviderDefines::KDefaultDatabaseUid); |
|
1044 |
|
1045 // Get the storage item to which the access point manager is stored |
|
1046 // Note: database has the ownership of the item |
|
1047 MNcdStorageItem* item = database.StorageItemL( |
|
1048 iGeneralManager.FamilyName(), |
|
1049 NcdProviderDefines::ENcdAccessPointManager); |
|
1050 |
|
1051 item->SetDataItem( iClientAccessPointData ); |
|
1052 item->OpenL(); |
|
1053 |
|
1054 // Calls ExternalizeL for this |
|
1055 item->WriteDataL(); |
|
1056 item->SaveL(); |
|
1057 } |
|
1058 |
|
1059 |
|
1060 TBool CCatalogsAccessPointManager::MatchingSettingsL( |
|
1061 const CCatalogsAccessPointSettings& aSettings, CApAccessPointItem& aItem) |
|
1062 { |
|
1063 DLTRACEIN(("Checking for matching AP settings")); |
|
1064 |
|
1065 // Check long text settings. |
|
1066 DLTRACE(("Checking long text parameters")); |
|
1067 TInt longTextCount = aSettings.LongTextParameterCount(); |
|
1068 for (TInt i = 0; i < longTextCount; i++) |
|
1069 { |
|
1070 TApMember key; |
|
1071 TPtrC value; |
|
1072 DLTRACE(("Getting long text param data, i=%d", i)); |
|
1073 aSettings.LongTextParameter(i, key, value); |
|
1074 DLTRACE(("Reading const long text from CApAccessPointItem, member=%d", key)); |
|
1075 |
|
1076 const HBufC* buf = aItem.ReadConstLongTextL(key); |
|
1077 DLTRACE(("")); |
|
1078 if (*buf != value) |
|
1079 { |
|
1080 // Settings aren't correct. |
|
1081 DLTRACEOUT(("Not matching settings")); |
|
1082 return EFalse; |
|
1083 } |
|
1084 } |
|
1085 |
|
1086 // Check 16-bit text settings. |
|
1087 DLTRACE(("Checking 16-bit text parameters")); |
|
1088 TInt text16Count = aSettings.Text16ParameterCount(); |
|
1089 for (TInt i = 0; i < text16Count; i++) |
|
1090 { |
|
1091 TApMember key; |
|
1092 TPtrC16 value; |
|
1093 aSettings.Text16Parameter(i, key, value); |
|
1094 DLTRACE(( _L("Key: %d, value: %S"), key, &value )); |
|
1095 |
|
1096 // CApDataHandler changes all of these if it needs to create a new |
|
1097 // unique name for an accesspoint when it's created so we ignore |
|
1098 // them when trying to find a matching AP so that we don't end |
|
1099 // up creating new APs everytime we check if the correct AP |
|
1100 // exists |
|
1101 // See DLEB-179 |
|
1102 // CApAccessPointItem::SetNamesL sets these |
|
1103 if ( key == EApWapAccessPointName || |
|
1104 key == EApIapName || |
|
1105 key == EApIspName || |
|
1106 key == EApNetworkName ) |
|
1107 { |
|
1108 DLTRACE(( _L("Skipping name comparison, key: %d, value: %S"), |
|
1109 key, &value )); |
|
1110 continue; |
|
1111 } |
|
1112 |
|
1113 const HBufC16* buf = ReadText16L(&aItem, key); |
|
1114 if (*buf != value) |
|
1115 { |
|
1116 // Settings aren't correct. |
|
1117 delete buf; |
|
1118 DLTRACEOUT(("Not matching settings")); |
|
1119 return EFalse; |
|
1120 } |
|
1121 delete buf; |
|
1122 } |
|
1123 |
|
1124 // Check 8-bit text settings. |
|
1125 DLTRACE(("Checking 8-bit text parameters")); |
|
1126 TInt text8Count = aSettings.Text8ParameterCount(); |
|
1127 for (TInt i = 0; i < text8Count; i++) |
|
1128 { |
|
1129 TApMember key; |
|
1130 TPtrC8 value; |
|
1131 aSettings.Text8Parameter(i, key, value); |
|
1132 const HBufC8* buf = ReadText8L(&aItem, key); |
|
1133 if (*buf != value) |
|
1134 { |
|
1135 // Settings aren't correct. |
|
1136 delete buf; |
|
1137 DLTRACEOUT(("Not matching settings")); |
|
1138 return EFalse; |
|
1139 } |
|
1140 delete buf; |
|
1141 } |
|
1142 |
|
1143 // Check uint settings. |
|
1144 DLTRACE(("Checking uint parameters")); |
|
1145 TInt uintCount = aSettings.UintParameterCount(); |
|
1146 for (TInt i = 0; i < uintCount; i++) |
|
1147 { |
|
1148 TApMember key; |
|
1149 TUint32 value; |
|
1150 aSettings.UintParameter(i, key, value); |
|
1151 TUint32 dbValue; |
|
1152 aItem.ReadUint(key, dbValue); |
|
1153 if (dbValue != value) |
|
1154 { |
|
1155 // Settings aren't correct. |
|
1156 DLTRACEOUT(("Not matching settings")); |
|
1157 return EFalse; |
|
1158 } |
|
1159 } |
|
1160 |
|
1161 // Check bool settings. |
|
1162 DLTRACE(_L("Checking bool parameters")); |
|
1163 TInt boolCount = aSettings.BoolParameterCount(); |
|
1164 for (TInt i = 0; i < boolCount; i++) |
|
1165 { |
|
1166 TApMember key; |
|
1167 TBool value; |
|
1168 aSettings.BoolParameter(i, key, value); |
|
1169 TBool dbValue; |
|
1170 aItem.ReadBool(key, dbValue); |
|
1171 |
|
1172 // TBools should not be compared to each other because there's no |
|
1173 // guarantee that TBool contains only 0 or 1 because any non-zero |
|
1174 // value is considered as true. So, we have to use ! operator |
|
1175 // to limit the values to 0 and 1 |
|
1176 // |
|
1177 // Option B !( a && b || !a && !b ) |
|
1178 // Option C ( a && !b || !a && b ) |
|
1179 if ( !dbValue != !value ) |
|
1180 { |
|
1181 // Settings aren't correct. |
|
1182 DLTRACEOUT(("Not matching settings")); |
|
1183 return EFalse; |
|
1184 } |
|
1185 } |
|
1186 |
|
1187 // Setting are correct. |
|
1188 DLTRACEOUT(("Matching settings")); |
|
1189 return ETrue; |
|
1190 } |
|
1191 |
|
1192 |
|
1193 void CCatalogsAccessPointManager::SetApDetailL( |
|
1194 CCatalogsAccessPoint& aAp, const TDesC& aKey, const TDesC& aValue ) |
|
1195 { |
|
1196 DLTRACEIN(("")); |
|
1197 TBool value = EFalse; |
|
1198 |
|
1199 if (aKey == KApName) |
|
1200 { |
|
1201 aAp.SetNameL(aValue); |
|
1202 } |
|
1203 else if (aKey == KApCdmaDisablePlainTextAuth) |
|
1204 { |
|
1205 NcdProtocolUtils::DesToBool(value, aValue); |
|
1206 aAp.SetBoolParameterL(EApCdmaDisablePlainTextAuth, value); |
|
1207 } |
|
1208 else if (aKey == KApCdmaIfAuthName) |
|
1209 { |
|
1210 aAp.SetText16ParameterL(EApCdmaIfAuthName, aValue); |
|
1211 } |
|
1212 else if (aKey == KApCdmaIfAuthPassword) |
|
1213 { |
|
1214 aAp.SetText16ParameterL(EApCdmaIfAuthPassword, aValue); |
|
1215 } |
|
1216 else if (aKey == KApCdmaIfName) |
|
1217 { |
|
1218 aAp.SetText16ParameterL(EApCdmaIfName, aValue); |
|
1219 } |
|
1220 else if (aKey == KApCdmaIfNetworks) |
|
1221 { |
|
1222 aAp.SetText16ParameterL(EApCdmaIfNetworks, aValue); |
|
1223 } |
|
1224 else if (aKey == KApCdmaIpAddr) |
|
1225 { |
|
1226 aAp.SetText16ParameterL(EApCdmaIpAddr, aValue); |
|
1227 } |
|
1228 else if (aKey == KApCdmaIpAddrFromServer) |
|
1229 { |
|
1230 NcdProtocolUtils::DesToBool(value, aValue); |
|
1231 aAp.SetBoolParameterL(EApCdmaIpAddrFromServer, value); |
|
1232 } |
|
1233 else if (aKey == KApCdmaIpDnsAddrFromServer) |
|
1234 { |
|
1235 NcdProtocolUtils::DesToBool(value, aValue); |
|
1236 aAp.SetBoolParameterL(EApCdmaIpDnsAddrFromServer, value); |
|
1237 } |
|
1238 else if (aKey == KApCdmaIpGateway) |
|
1239 { |
|
1240 aAp.SetText16ParameterL(EApCdmaIpGateway, aValue); |
|
1241 } |
|
1242 else if (aKey == KApCdmaIPNameServer1) |
|
1243 { |
|
1244 aAp.SetText16ParameterL(EApCdmaIPNameServer1, aValue); |
|
1245 } |
|
1246 else if (aKey == KApCdmaIPNameServer2) |
|
1247 { |
|
1248 aAp.SetText16ParameterL(EApCdmaIPNameServer2, aValue); |
|
1249 } |
|
1250 else if (aKey == KApCdmaIpNetMask) |
|
1251 { |
|
1252 aAp.SetText16ParameterL(EApCdmaIpNetMask, aValue); |
|
1253 } |
|
1254 else if (aKey == KApGprsAccessPointName) |
|
1255 { |
|
1256 aAp.SetLongTextParameterL(EApGprsAccessPointName, aValue); |
|
1257 } |
|
1258 else if (aKey == KApGprsDisablePlainTextAuth) |
|
1259 { |
|
1260 NcdProtocolUtils::DesToBool(value, aValue); |
|
1261 aAp.SetBoolParameterL(EApGprsDisablePlainTextAuth, value); |
|
1262 } |
|
1263 else if (aKey == KApGprsIfAuthName) |
|
1264 { |
|
1265 aAp.SetText16ParameterL(EApGprsIfAuthName, aValue); |
|
1266 } |
|
1267 else if (aKey == KApGprsIfAuthPassword) |
|
1268 { |
|
1269 aAp.SetText16ParameterL(EApGprsIfAuthPassword, aValue); |
|
1270 } |
|
1271 else if (aKey == KApGprsIfName) |
|
1272 { |
|
1273 aAp.SetText16ParameterL(EApGprsIfName, aValue); |
|
1274 } |
|
1275 else if (aKey == KApGprsIfNetworks) |
|
1276 { |
|
1277 aAp.SetText16ParameterL(EApGprsIfNetworks, aValue); |
|
1278 } |
|
1279 else if (aKey == KApGprsIfParams) |
|
1280 { |
|
1281 aAp.SetText16ParameterL(EApGprsIfParams, aValue); |
|
1282 } |
|
1283 else if (aKey == KApGprsIfPromptForAuth) |
|
1284 { |
|
1285 NcdProtocolUtils::DesToBool(value, aValue); |
|
1286 aAp.SetBoolParameterL(EApGprsIfPromptForAuth, value); |
|
1287 } |
|
1288 else if (aKey == KApGprsIpAddr) |
|
1289 { |
|
1290 aAp.SetText16ParameterL(EApGprsIpAddr, aValue); |
|
1291 } |
|
1292 else if (aKey == KApGprsIpAddrFromServer) |
|
1293 { |
|
1294 NcdProtocolUtils::DesToBool(value, aValue); |
|
1295 aAp.SetBoolParameterL(EApGprsIpAddrFromServer, value); |
|
1296 } |
|
1297 else if (aKey == KApGprsIpDnsAddrFromServer) |
|
1298 { |
|
1299 NcdProtocolUtils::DesToBool(value, aValue); |
|
1300 aAp.SetBoolParameterL(EApGprsIpDnsAddrFromServer, value); |
|
1301 } |
|
1302 else if (aKey == KApGprsIpGateway) |
|
1303 { |
|
1304 aAp.SetText16ParameterL(EApGprsIpGateway, aValue); |
|
1305 } |
|
1306 else if (aKey == KApGprsIPNameServer1) |
|
1307 { |
|
1308 aAp.SetText16ParameterL(EApGprsIPNameServer1, aValue); |
|
1309 } |
|
1310 else if (aKey == KApGprsIPNameServer2) |
|
1311 { |
|
1312 aAp.SetText16ParameterL(EApGprsIPNameServer2, aValue); |
|
1313 } |
|
1314 else if (aKey == KApGprsIpNetMask) |
|
1315 { |
|
1316 aAp.SetText16ParameterL(EApGprsIpNetMask, aValue); |
|
1317 } |
|
1318 else if (aKey == KApGprsPdpAddress) |
|
1319 { |
|
1320 aAp.SetText16ParameterL(EApGprsPdpAddress, aValue); |
|
1321 } |
|
1322 else if (aKey == KApHasProxySettings) |
|
1323 { |
|
1324 NcdProtocolUtils::DesToBool(value, aValue); |
|
1325 aAp.SetBoolParameterL(EApHasProxySettings, value); |
|
1326 } |
|
1327 else if (aKey == KApIapChargecard) |
|
1328 { |
|
1329 TInt value = NcdProtocolUtils::DesDecToIntL(aValue); |
|
1330 aAp.SetUintParameterL(EApIapChargecard, value); |
|
1331 } |
|
1332 else if (aKey == KApIapName) |
|
1333 { |
|
1334 aAp.SetText16ParameterL(EApIapName, aValue); |
|
1335 } |
|
1336 else if (aKey == KApIapServiceId) |
|
1337 { |
|
1338 TInt value = NcdProtocolUtils::DesDecToIntL(aValue); |
|
1339 aAp.SetUintParameterL(EApIapServiceId, value); |
|
1340 } |
|
1341 else if (aKey == KApIapServiceType) |
|
1342 { |
|
1343 aAp.SetText16ParameterL(EApIapServiceType, aValue); |
|
1344 } |
|
1345 else if (aKey == KApIP6NameServer1) |
|
1346 { |
|
1347 aAp.SetText16ParameterL(EApIP6NameServer1, aValue); |
|
1348 } |
|
1349 else if (aKey == KApIP6NameServer2) |
|
1350 { |
|
1351 aAp.SetText16ParameterL(EApIP6NameServer2, aValue); |
|
1352 } |
|
1353 else if (aKey == KApIspDefaultTelNumber) |
|
1354 { |
|
1355 aAp.SetText16ParameterL(EApIspDefaultTelNumber, aValue); |
|
1356 } |
|
1357 else if (aKey == KApIspDescription) |
|
1358 { |
|
1359 aAp.SetText16ParameterL(EApIspDescription, aValue); |
|
1360 } |
|
1361 else if (aKey == KApIspDisablePlainTextAuth) |
|
1362 { |
|
1363 NcdProtocolUtils::DesToBool(value, aValue); |
|
1364 aAp.SetBoolParameterL(EApIspDisablePlainTextAuth, value); |
|
1365 } |
|
1366 else if (aKey == KApIspIfAuthName) |
|
1367 { |
|
1368 aAp.SetText16ParameterL(EApIspIfAuthName, aValue); |
|
1369 } |
|
1370 else if (aKey == KApIspIfAuthPass) |
|
1371 { |
|
1372 aAp.SetText16ParameterL(EApIspIfAuthPass, aValue); |
|
1373 } |
|
1374 else if (aKey == KApIspIfCallbackInfo) |
|
1375 { |
|
1376 const TDesC& value = aValue; |
|
1377 |
|
1378 // convert the descriptor to 8-bit |
|
1379 HBufC8* buf8 = HBufC8::NewLC(value.Length()); |
|
1380 buf8->Des().Copy(value); |
|
1381 aAp.SetText8ParameterL(EApIspIfCallbackInfo, *buf8); |
|
1382 CleanupStack::PopAndDestroy(); |
|
1383 } |
|
1384 else if (aKey == KApIspIfName) |
|
1385 { |
|
1386 aAp.SetText16ParameterL(EApIspIfName, aValue); |
|
1387 } |
|
1388 else if (aKey == KApIspIfNetworks) |
|
1389 { |
|
1390 aAp.SetText16ParameterL(EApIspIfNetworks, aValue); |
|
1391 } |
|
1392 else if (aKey == KApIspIfParams) |
|
1393 { |
|
1394 aAp.SetText16ParameterL(EApIspIfParams, aValue); |
|
1395 } |
|
1396 else if (aKey == KApIspInitString) |
|
1397 { |
|
1398 const TDesC& value = aValue; |
|
1399 |
|
1400 // convert the descriptor to 8-bit |
|
1401 HBufC8* buf8 = HBufC8::NewLC(value.Length()); |
|
1402 buf8->Des().Copy(value); |
|
1403 aAp.SetText8ParameterL(EApIspIfCallbackInfo, *buf8); |
|
1404 CleanupStack::PopAndDestroy(); |
|
1405 } |
|
1406 else if (aKey == KApIspIPAddr) |
|
1407 { |
|
1408 aAp.SetText16ParameterL(EApIspIPAddr, aValue); |
|
1409 } |
|
1410 else if (aKey == KApIspIPAddrFromServer) |
|
1411 { |
|
1412 NcdProtocolUtils::DesToBool(value, aValue); |
|
1413 aAp.SetBoolParameterL(EApIspIPAddrFromServer, value); |
|
1414 } |
|
1415 else if (aKey == KApIspIPDnsAddrFromServer) |
|
1416 { |
|
1417 NcdProtocolUtils::DesToBool(value, aValue); |
|
1418 aAp.SetBoolParameterL(EApIspIPAddrFromServer, value); |
|
1419 } |
|
1420 else if (aKey == KApIspIPGateway) |
|
1421 { |
|
1422 aAp.SetText16ParameterL(EApIspIPGateway, aValue); |
|
1423 } |
|
1424 else if (aKey == KApIspIPNameServer1) |
|
1425 { |
|
1426 aAp.SetText16ParameterL(EApIspIPNameServer1, aValue); |
|
1427 } |
|
1428 else if (aKey == KApIspIPNameServer2) |
|
1429 { |
|
1430 aAp.SetText16ParameterL(EApIspIPNameServer2, aValue); |
|
1431 } |
|
1432 else if (aKey == KApIspIPNetMask) |
|
1433 { |
|
1434 aAp.SetText16ParameterL(EApIspIPNetMask, aValue); |
|
1435 } |
|
1436 else if (aKey == KApIspIspType) |
|
1437 { |
|
1438 // |
|
1439 } |
|
1440 else if (aKey == KApIspLoginName) |
|
1441 { |
|
1442 aAp.SetText16ParameterL(EApIspLoginName, aValue); |
|
1443 } |
|
1444 else if (aKey == KApIspLoginPass) |
|
1445 { |
|
1446 aAp.SetText16ParameterL(EApIspLoginPass, aValue); |
|
1447 } |
|
1448 else if (aKey == KApIspLoginScript) |
|
1449 { |
|
1450 aAp.SetText16ParameterL(EApIspLoginScript, aValue); |
|
1451 } |
|
1452 else if (aKey == KApIspName) |
|
1453 { |
|
1454 aAp.SetText16ParameterL(EApIspName, aValue); |
|
1455 } |
|
1456 else if (aKey == KApLanBearerName) |
|
1457 { |
|
1458 aAp.SetText16ParameterL(EApLanBearerName, aValue); |
|
1459 } |
|
1460 else if (aKey == KApNetworkName) |
|
1461 { |
|
1462 aAp.SetText16ParameterL(EApNetworkName, aValue); |
|
1463 } |
|
1464 else if (aKey == KApProxyExceptions) |
|
1465 { |
|
1466 aAp.SetLongTextParameterL(EApProxyExceptions, aValue); |
|
1467 } |
|
1468 else if (aKey == KApProxyLoginName) |
|
1469 { |
|
1470 aAp.SetText16ParameterL(EApProxyLoginName, aValue); |
|
1471 } |
|
1472 else if (aKey == KApProxyLoginPass) |
|
1473 { |
|
1474 aAp.SetText16ParameterL(EApProxyLoginPass, aValue); |
|
1475 } |
|
1476 else if (aKey == KApProxyPortNumber) |
|
1477 { |
|
1478 TInt value = NcdProtocolUtils::DesDecToIntL(aValue); |
|
1479 aAp.SetUintParameterL(EApProxyPortNumber, value); |
|
1480 } |
|
1481 else if (aKey == KApProxyProtocolName) |
|
1482 { |
|
1483 aAp.SetText16ParameterL(EApProxyProtocolName, aValue); |
|
1484 } |
|
1485 else if (aKey == KApProxyServerAddress) |
|
1486 { |
|
1487 aAp.SetLongTextParameterL(EApProxyServerAddress, aValue); |
|
1488 } |
|
1489 else if (aKey == KApProxyUseProxy) |
|
1490 { |
|
1491 NcdProtocolUtils::DesToBool(value, aValue); |
|
1492 aAp.SetBoolParameterL(EApProxyUseProxy, value); |
|
1493 } |
|
1494 else if (aKey == KApWapAccessPointName) |
|
1495 { |
|
1496 aAp.SetText16ParameterL(EApWapAccessPointName, aValue); |
|
1497 } |
|
1498 else if (aKey == KApWapCurrentBearer) |
|
1499 { |
|
1500 aAp.SetText16ParameterL(EApWapCurrentBearer, aValue); |
|
1501 } |
|
1502 else if (aKey == KApWapGatewayAddress) |
|
1503 { |
|
1504 aAp.SetText16ParameterL(EApWapGatewayAddress, aValue); |
|
1505 } |
|
1506 else if (aKey == KApWapIap) |
|
1507 { |
|
1508 TInt value = NcdProtocolUtils::DesDecToIntL(aValue); |
|
1509 aAp.SetUintParameterL(EApWapIap, value); |
|
1510 } |
|
1511 else if (aKey == KApWapProxyPort) |
|
1512 { |
|
1513 TInt value = NcdProtocolUtils::DesDecToIntL(aValue); |
|
1514 aAp.SetUintParameterL(EApWapProxyPort, value); |
|
1515 } |
|
1516 else if (aKey == KApWapSecurity) |
|
1517 { |
|
1518 NcdProtocolUtils::DesToBool(value, aValue); |
|
1519 aAp.SetBoolParameterL(EApWapSecurity, value); |
|
1520 } |
|
1521 else if (aKey == KApWapStartPage) |
|
1522 { |
|
1523 aAp.SetLongTextParameterL(EApWapStartPage, aValue); |
|
1524 } |
|
1525 else if (aKey == KApWapWspOption) |
|
1526 { |
|
1527 if (aValue == KWapWspOptionConnectionless) |
|
1528 { |
|
1529 aAp.SetUintParameterL(EApWapWspOption, EWapWspOptionConnectionless); |
|
1530 } |
|
1531 else if (aValue == KWapWspOptionConnectionOriented) |
|
1532 { |
|
1533 aAp.SetUintParameterL(EApWapWspOption, EWapWspOptionConnectionOriented); |
|
1534 } |
|
1535 else |
|
1536 { |
|
1537 DLWARNING((_L("Unknown EApWapWspOption value: %S"), &aValue)); |
|
1538 } |
|
1539 } |
|
1540 else if (aKey == KApWlanIfAuthName) |
|
1541 { |
|
1542 aAp.SetText16ParameterL(EApWlanIfAuthName, aValue); |
|
1543 } |
|
1544 else if (aKey == KApWlanIfAuthPassword) |
|
1545 { |
|
1546 aAp.SetText16ParameterL(EApWlanIfAuthPassword, aValue); |
|
1547 } |
|
1548 else if (aKey == KApWlanIfNetworks) |
|
1549 { |
|
1550 aAp.SetText16ParameterL(EApWlanIfNetworks, aValue); |
|
1551 } |
|
1552 else if (aKey == KApWlanIpAddr) |
|
1553 { |
|
1554 aAp.SetText16ParameterL(EApWlanIpAddr, aValue); |
|
1555 } |
|
1556 else if (aKey == KApWlanIpAddrFromServer) |
|
1557 { |
|
1558 NcdProtocolUtils::DesToBool(value, aValue); |
|
1559 aAp.SetBoolParameterL(EApWlanIpAddrFromServer, value); |
|
1560 } |
|
1561 else if (aKey == KApWlanIpDnsAddrFromServer) |
|
1562 { |
|
1563 NcdProtocolUtils::DesToBool(value, aValue); |
|
1564 aAp.SetBoolParameterL(EApWlanIpDnsAddrFromServer, value); |
|
1565 } |
|
1566 else if (aKey == KApWlanIpGateway) |
|
1567 { |
|
1568 aAp.SetText16ParameterL(EApWlanIpGateway, aValue); |
|
1569 } |
|
1570 else if (aKey == KApWlanIPNameServer1) |
|
1571 { |
|
1572 aAp.SetText16ParameterL(EApWlanIPNameServer1, aValue); |
|
1573 } |
|
1574 else if (aKey == KApWlanIPNameServer2) |
|
1575 { |
|
1576 aAp.SetText16ParameterL(EApWlanIPNameServer2, aValue); |
|
1577 } |
|
1578 else if (aKey == KApWlanIpNetMask) |
|
1579 { |
|
1580 aAp.SetText16ParameterL(EApWlanIpNetMask, aValue); |
|
1581 } |
|
1582 else |
|
1583 { |
|
1584 DLWARNING(( _L("Unknown access point detail: %S"), &aKey)); |
|
1585 } |
|
1586 } |
|
1587 |
|
1588 |
|
1589 TInt CCatalogsAccessPointManager::GetAccessPoint( |
|
1590 CCatalogsAccessPoint*& aAccessPoint, |
|
1591 CCatalogsClientAccessPointData*& aApData ) |
|
1592 { |
|
1593 DLTRACEIN(("")); |
|
1594 #ifdef __WINS__ |
|
1595 // Comms database is not accessible in emulator |
|
1596 return KErrNotFound; |
|
1597 #endif |
|
1598 |
|
1599 if ( iFixedAp ) |
|
1600 { |
|
1601 // Use fixed AP if it is set. |
|
1602 aAccessPoint = iFixedAp; |
|
1603 } |
|
1604 else |
|
1605 { |
|
1606 aApData = iClientAccessPointData; |
|
1607 if ( !aApData ) |
|
1608 { |
|
1609 TRAPD( err, LoadFromStorageL() ); |
|
1610 |
|
1611 if ( err != KErrNone ) |
|
1612 { |
|
1613 return err; |
|
1614 } |
|
1615 |
|
1616 aApData = iClientAccessPointData; |
|
1617 } |
|
1618 |
|
1619 if ( !aApData ) |
|
1620 { |
|
1621 return KErrNotFound; |
|
1622 } |
|
1623 } |
|
1624 return KErrNone; |
|
1625 } |
|
1626 |
|
1627 |
|
1628 TInt CCatalogsAccessPointManager::ValidateOrCreateAccessPointL( |
|
1629 CCatalogsAccessPoint* aAccessPoint, |
|
1630 TUint32& aAccessPointId ) |
|
1631 { |
|
1632 DLTRACEIN(("")); |
|
1633 if ( !aAccessPoint ) |
|
1634 { |
|
1635 return KErrNotFound; |
|
1636 } |
|
1637 |
|
1638 // If we are using fixed AP and we don't need to check |
|
1639 // the existance of the AP, we can skip validation etc. |
|
1640 if ( aAccessPoint == iFixedAp && !iCheckAp ) |
|
1641 { |
|
1642 aAccessPointId = aAccessPoint->AccessPointId(); |
|
1643 return KErrNone; |
|
1644 } |
|
1645 |
|
1646 if ( ValidateAccessPointL( aAccessPoint ) ) |
|
1647 { |
|
1648 aAccessPointId = aAccessPoint->AccessPointId(); |
|
1649 } |
|
1650 else |
|
1651 { |
|
1652 // Somehow accesspoint settings has been altered |
|
1653 // in the commsdatabase. Recreate access point. |
|
1654 TUint32 id = 0; |
|
1655 CreateApToCommsDBL( *aAccessPoint, id ); |
|
1656 aAccessPoint->SetAccessPointId( id ); |
|
1657 if ( aAccessPoint != iFixedAp ) |
|
1658 { |
|
1659 // If not using fixed AP, client's AP settings were altered, save them. |
|
1660 SaveToStorageL(); |
|
1661 } |
|
1662 aAccessPointId = id; |
|
1663 } |
|
1664 return KErrNone; |
|
1665 } |
|
1666 |
|
1667 |
|
1668 void CCatalogsAccessPointManager::DestructL() |
|
1669 { |
|
1670 DLTRACEIN(("")); |
|
1671 CCatalogsHttpSessionManager::NetworkManagerL().RemoveObserver( *this ); |
|
1672 // remove access points from comms db |
|
1673 |
|
1674 RemoveAccessPointsFromCommsDbL( ETrue ); |
|
1675 |
|
1676 // Remove fixed ap too but only if it was created by us |
|
1677 if ( iFixedAp && iFixedAp->CreatedByManager() ) |
|
1678 { |
|
1679 CCatalogsRemoveAccesspointShutdownOperation* op = |
|
1680 CCatalogsRemoveAccesspointShutdownOperation::NewL( |
|
1681 iGeneralManager.FamilyId(), |
|
1682 iFixedAp->AccessPointId() ); |
|
1683 // takes ownership, deletes the op if adding fails |
|
1684 CCatalogsClientServerServer::AddShutdownOperation( op ); |
|
1685 } |
|
1686 } |
|
1687 |