|
1 /* |
|
2 * Copyright (c) 2002 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: Implementation of CActiveIAPListing |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "ActiveIAPListing.h" |
|
22 #include "ConnectionInfo.h" |
|
23 #include "ConnectionInfoKey.h" |
|
24 #include "ConnectionInfoArray.h" |
|
25 #include "ConnectionDialogsLogger.h" |
|
26 |
|
27 #include <commdb.h> |
|
28 #include <featmgr.h> |
|
29 #include <StringLoader.h> |
|
30 #include <centralrepository.h> |
|
31 #include <WlanCdbCols.h> |
|
32 #include <wlanmgmtcommon.h> |
|
33 #ifndef __WINS__ |
|
34 #include <wlanmgmtclient.h> |
|
35 #endif |
|
36 #include <AknWaitDialog.h> |
|
37 #include <AknUtils.h> |
|
38 #include <centralrepository.h> |
|
39 #include <ProfileEngineSDKCRKeys.h> |
|
40 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
41 #include <commsdat.h> |
|
42 #else |
|
43 #include <commsdat.h> |
|
44 #include <commsdat_partner.h> |
|
45 #endif |
|
46 |
|
47 |
|
48 |
|
49 // CONSTANTS |
|
50 |
|
51 /** |
|
52 * For iPeriodic Timer, 60 seconds |
|
53 */ |
|
54 LOCAL_D const TInt KTickDefaultInterval = 60000000; |
|
55 |
|
56 /** |
|
57 * Length of a string made of the MAX_INT and a tab character. |
|
58 */ |
|
59 LOCAL_D const TInt KLenMaxIntAndTab = 12; |
|
60 |
|
61 _LIT( KMrouterName, "mRouter" ); |
|
62 |
|
63 // Panic string |
|
64 #if defined(_DEBUG) |
|
65 _LIT( KErrNullPointer, "NULL pointer" ); |
|
66 #endif |
|
67 |
|
68 |
|
69 // TYPES |
|
70 |
|
71 /** |
|
72 * Indexes of the icons |
|
73 */ |
|
74 enum |
|
75 { |
|
76 EIconIndexGPRS, // Icon for GPRS access point |
|
77 EIconIndexCSD, // Icon for CSD access point |
|
78 EIconIndexHSCSD, // Icon for HSCSD access point |
|
79 EIconIndexEasyWLAN, // Icon for Easy WLan access point |
|
80 EIconIndexWLAN // Icon for WLan access point |
|
81 }; |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 /////////////////////////////////////////////////////////////////////////////// |
|
87 |
|
88 // --------------------------------------------------------- |
|
89 // CActiveIAPListing::CActiveIAPListing() |
|
90 // --------------------------------------------------------- |
|
91 // |
|
92 CActiveIAPListing::CActiveIAPListing( const TConnectionPrefs& aPrefs ) |
|
93 : CActive( EPriorityUserInput ), |
|
94 iDb( NULL ), |
|
95 iWaitDialog( NULL ), |
|
96 #ifndef __WINS__ |
|
97 iWlanMgmt( NULL ), |
|
98 #endif // !__WINS__ |
|
99 iPrefs( aPrefs ) |
|
100 { |
|
101 } |
|
102 |
|
103 |
|
104 // --------------------------------------------------------- |
|
105 // CActiveIAPListing::~CActiveIAPListing() |
|
106 // --------------------------------------------------------- |
|
107 // |
|
108 CActiveIAPListing::~CActiveIAPListing() |
|
109 { |
|
110 CLOG_ENTERFN( "~CActiveIAPListing " ); |
|
111 Cancel(); |
|
112 |
|
113 delete iDb; |
|
114 iDb = NULL; |
|
115 |
|
116 iAvailableIaps.Close(); |
|
117 |
|
118 if ( iIAPs ) |
|
119 { |
|
120 iIAPs->ResetAndDestroy(); |
|
121 } |
|
122 delete iIAPs; |
|
123 iIAPs = NULL; |
|
124 |
|
125 if ( iWlanIAPs ) |
|
126 { |
|
127 iWlanIAPs->ResetAndDestroy(); |
|
128 } |
|
129 delete iWlanIAPs; |
|
130 iWlanIAPs = NULL; |
|
131 |
|
132 delete iActIAPs; // do not destroy, gets items from iIAPs and iWlanIAPs |
|
133 iActIAPs = NULL; |
|
134 |
|
135 CLOG_LEAVEFN( "~CActiveIAPListing " ); |
|
136 } |
|
137 |
|
138 |
|
139 // --------------------------------------------------------- |
|
140 // CActiveIAPListing::ConstructL() |
|
141 // --------------------------------------------------------- |
|
142 // |
|
143 void CActiveIAPListing::BaseConstructL() |
|
144 { |
|
145 CLOG_ENTERFN( "CActiveIAPListing::ConstructL " ); |
|
146 |
|
147 CActiveScheduler::Add( this ); |
|
148 |
|
149 FeatureManager::InitializeLibL(); |
|
150 |
|
151 if ( iPrefs.iBearerSet & ECommDbBearerWLAN ) |
|
152 { |
|
153 iIsWLANFeatureSupported = |
|
154 FeatureManager::FeatureSupported( KFeatureIdProtocolWlan ); |
|
155 } |
|
156 else |
|
157 { |
|
158 iIsWLANFeatureSupported = EFalse; |
|
159 } |
|
160 |
|
161 FeatureManager::UnInitializeLib(); |
|
162 |
|
163 if ( iIsWLANFeatureSupported ) |
|
164 { |
|
165 #ifndef __WINS__ |
|
166 iWlanMgmt = CWlanMgmtClient::NewL(); |
|
167 #endif // !__WINS__ |
|
168 } |
|
169 |
|
170 iPeriodic = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
171 iDb = CCommsDatabase::NewL(); |
|
172 |
|
173 iActIAPs = new( ELeave ) CConnectionInfoArray(); |
|
174 |
|
175 CLOG_LEAVEFN( "CActiveIAPListing::ConstructL " ); |
|
176 } |
|
177 |
|
178 |
|
179 // --------------------------------------------------------- |
|
180 // CActiveIAPListing::Cancel() |
|
181 // --------------------------------------------------------- |
|
182 // |
|
183 void CActiveIAPListing::Cancel() |
|
184 { |
|
185 CLOG_ENTERFN( "CActiveIAPListing::Cancel " ); |
|
186 |
|
187 StopTimer(); |
|
188 |
|
189 delete iWaitDialog; |
|
190 iWaitDialog = NULL; |
|
191 |
|
192 #ifndef __WINS__ |
|
193 delete iWlanMgmt; |
|
194 iWlanMgmt = NULL; |
|
195 #endif // !__WINS__ |
|
196 |
|
197 CLOG_WRITEF( _L( "Cancel iStatus.Int: %d" ), iStatus.Int() ); |
|
198 CActive::Cancel(); |
|
199 |
|
200 CLOG_LEAVEFN( "CActiveIAPListing::Cancel " ); |
|
201 } |
|
202 |
|
203 |
|
204 // --------------------------------------------------------- |
|
205 // CActiveIAPListing::DoCancel() |
|
206 // --------------------------------------------------------- |
|
207 // |
|
208 void CActiveIAPListing::DoCancel() |
|
209 { |
|
210 } |
|
211 |
|
212 |
|
213 // --------------------------------------------------------- |
|
214 // CActiveIAPListing::RunL() |
|
215 // --------------------------------------------------------- |
|
216 // |
|
217 void CActiveIAPListing::RunL() |
|
218 { |
|
219 } |
|
220 |
|
221 |
|
222 // --------------------------------------------------------- |
|
223 // CActiveIAPListing::StartTimerL |
|
224 // --------------------------------------------------------- |
|
225 // |
|
226 void CActiveIAPListing::StartTimerL( TInt aTickInterval ) |
|
227 { |
|
228 CLOG_ENTERFN( "CActiveIAPListing::StartTimerL " ); |
|
229 |
|
230 if( !iPeriodic ) |
|
231 { |
|
232 iPeriodic = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
233 } |
|
234 |
|
235 iPeriodic->Start( aTickInterval, aTickInterval, TCallBack( Tick, this ) ); |
|
236 |
|
237 CLOG_LEAVEFN( "CActiveIAPListing::StartTimerL " ); |
|
238 } |
|
239 |
|
240 |
|
241 // --------------------------------------------------------- |
|
242 // CActiveIAPListing::StopTimer |
|
243 // --------------------------------------------------------- |
|
244 // |
|
245 void CActiveIAPListing::StopTimer() |
|
246 { |
|
247 CLOG_ENTERFN( "CActiveIAPListing::StopTimer " ); |
|
248 |
|
249 if( iPeriodic ) |
|
250 { |
|
251 CLOG_WRITE( "iPeriodic" ); |
|
252 iPeriodic->Cancel(); |
|
253 CLOG_WRITE( "Cancel" ); |
|
254 |
|
255 delete iPeriodic; |
|
256 CLOG_WRITE( "delete" ); |
|
257 |
|
258 iPeriodic = NULL; |
|
259 } |
|
260 |
|
261 CLOG_LEAVEFN( "CActiveIAPListing::StopTimer " ); |
|
262 } |
|
263 |
|
264 |
|
265 // --------------------------------------------------------- |
|
266 // CActiveIAPListing::Tick |
|
267 // --------------------------------------------------------- |
|
268 // |
|
269 TInt CActiveIAPListing::Tick( TAny* aObject ) |
|
270 { |
|
271 CLOG_ENTERFN( "CActiveIAPListing::Tick " ); |
|
272 |
|
273 CActiveIAPListing* myself = |
|
274 static_cast<CActiveIAPListing*>( aObject ); |
|
275 |
|
276 if ( myself->iStatus == KErrCancel ) |
|
277 { |
|
278 CLOG_WRITE( "iStatus == KErrCancel" ); |
|
279 myself->StopTimer(); |
|
280 } |
|
281 else |
|
282 { |
|
283 CLOG_WRITE( "iStatus != KErrCancel" ); |
|
284 |
|
285 myself->SetActive(); |
|
286 myself->iClientStatus = &( myself->iStatus ); |
|
287 *( myself->iClientStatus ) = KRequestPending; |
|
288 |
|
289 #ifndef __WINS__ |
|
290 if ( myself->iIsWLANFeatureSupported ) |
|
291 { |
|
292 myself->iWlanMgmt->GetAvailableIaps( *( myself->iClientStatus ), |
|
293 myself->iAvailableIaps ); |
|
294 } |
|
295 else |
|
296 { |
|
297 User::RequestComplete( myself->iClientStatus, KErrNone ); |
|
298 } |
|
299 #else |
|
300 User::RequestComplete( myself->iClientStatus, KErrNone ); |
|
301 #endif // !__WINS__ |
|
302 |
|
303 } |
|
304 |
|
305 CLOG_LEAVEFN( "CActiveIAPListing::Tick " ); |
|
306 |
|
307 return 1; |
|
308 } |
|
309 |
|
310 |
|
311 |
|
312 // --------------------------------------------------------- |
|
313 // CActiveIAPListing::CreateArraysL() |
|
314 // --------------------------------------------------------- |
|
315 // |
|
316 void CActiveIAPListing::CreateArraysL( TInt aResourceId, |
|
317 TBool aChangeConnection, |
|
318 TUint32 aIAPId ) |
|
319 { |
|
320 iIAPs = new( ELeave ) CConnectionInfoArray(); |
|
321 iWlanIAPs = new( ELeave ) CConnectionInfoArray(); |
|
322 BuildConnectionListL( aResourceId, aChangeConnection, aIAPId); |
|
323 SetActive(); |
|
324 iClientStatus = &iStatus; |
|
325 *iClientStatus = KRequestPending; |
|
326 |
|
327 #ifndef __WINS__ |
|
328 if ( iIsWLANFeatureSupported ) |
|
329 { |
|
330 iWlanMgmt->GetAvailableIaps( *iClientStatus, iAvailableIaps ); |
|
331 } |
|
332 else |
|
333 #endif // !__WINS__ |
|
334 { |
|
335 // send to runl |
|
336 User::RequestComplete( iClientStatus, KErrNone ); // send back to runl |
|
337 } |
|
338 } |
|
339 |
|
340 |
|
341 // --------------------------------------------------------- |
|
342 // CActiveIAPListing::StartSearchIAPsL() |
|
343 // --------------------------------------------------------- |
|
344 // |
|
345 void CActiveIAPListing::BaseStartSearchIAPsL( TInt aResourceId ) |
|
346 { |
|
347 CLOG_ENTERFN( "CActiveIAPListing::StartSearchIAPsL " ); |
|
348 |
|
349 if ( iIsWLANFeatureSupported ) |
|
350 { |
|
351 delete iWaitDialog; |
|
352 iWaitDialog = NULL; |
|
353 |
|
354 iWaitDialog = new( ELeave )CAknWaitDialog( REINTERPRET_CAST( |
|
355 CEikDialog**, &iWaitDialog ), ETrue ); |
|
356 iWaitDialog->ExecuteLD( aResourceId ); |
|
357 } |
|
358 |
|
359 SetActive(); |
|
360 iClientStatus = &iStatus; |
|
361 |
|
362 User::RequestComplete( iClientStatus, KErrNone ); // send to runl |
|
363 |
|
364 CLOG_LEAVEFN( "CActiveIAPListing::StartSearchIAPsL " ); |
|
365 } |
|
366 |
|
367 |
|
368 // --------------------------------------------------------- |
|
369 // CActiveIAPListing::GetRefreshInterval() |
|
370 // --------------------------------------------------------- |
|
371 // |
|
372 TInt CActiveIAPListing::GetRefreshInterval( const TUid aRepositoryUid, |
|
373 TUint32 aKey ) |
|
374 { |
|
375 CLOG_ENTERFN( "CActiveIAPListing::GetRefreshInterval" ); |
|
376 |
|
377 CRepository* repository = NULL; |
|
378 TInt err( KErrNone ); |
|
379 |
|
380 TRAP( err, |
|
381 repository = CRepository::NewL( aRepositoryUid ) ); |
|
382 |
|
383 TInt variant( 0 ); |
|
384 CLOG_WRITEF( _L( "err : %d" ), err ); |
|
385 |
|
386 if ( err == KErrNone ) |
|
387 { |
|
388 TInt retval = repository->Get( aKey, variant ); |
|
389 |
|
390 CLOG_WRITEF( _L( "retval : %d" ), retval ); |
|
391 |
|
392 if ( retval == KErrNotFound ) |
|
393 { |
|
394 variant = KTickDefaultInterval; |
|
395 } |
|
396 } |
|
397 else |
|
398 { |
|
399 variant = KTickDefaultInterval; |
|
400 } |
|
401 |
|
402 delete repository; |
|
403 |
|
404 CLOG_WRITEF( _L( "variant : %d" ), variant ); |
|
405 |
|
406 CLOG_LEAVEFN( "CActiveIAPListing::GetRefreshInterval" ); |
|
407 |
|
408 return variant; |
|
409 } |
|
410 |
|
411 |
|
412 // ---------------------------------------------------------------------------- |
|
413 // void CActiveIAPListing::MergeArraysL() |
|
414 // ---------------------------------------------------------------------------- |
|
415 // |
|
416 void CActiveIAPListing::MergeArraysL( TInt aResourceId ) |
|
417 { |
|
418 CLOG_ENTERFN( "CActiveIAPListing::MergeArraysL " ); |
|
419 |
|
420 iActIAPs->Reset(); |
|
421 |
|
422 TInt countIAPs = iIAPs->Count(); |
|
423 TInt i; |
|
424 |
|
425 for( i = 0; i < countIAPs; ++i ) |
|
426 { |
|
427 iActIAPs->AppendL( iIAPs->At( i ) ); |
|
428 } |
|
429 |
|
430 if ( iIsWLANFeatureSupported ) |
|
431 { |
|
432 TInt countWlanIAPs = iWlanIAPs->Count(); |
|
433 CLOG_WRITEF( _L( "iWlanIAPs count: %d" ), countWlanIAPs ); |
|
434 |
|
435 #ifdef __WINS__ |
|
436 |
|
437 for( i = 0; i < countWlanIAPs; ++i ) |
|
438 { |
|
439 iActIAPs->AppendL( iWlanIAPs->At( i ) ); |
|
440 } |
|
441 |
|
442 #else |
|
443 |
|
444 TInt countAvailIAPs = iAvailableIaps.Count(); |
|
445 CLOG_WRITEF( _L( "iAvailableIaps count: %d" ), countAvailIAPs ); |
|
446 |
|
447 CConnectionInfo* conInf = NULL; |
|
448 for( int j = 0; j < countAvailIAPs; ++j ) |
|
449 { |
|
450 TUint32 actIap = TUint32( iAvailableIaps[j] ); |
|
451 for( i = 0; i < countWlanIAPs; ++i ) |
|
452 { // Scan all the WlanIAPs, because there could be VPNs |
|
453 // that use the same network |
|
454 conInf = iWlanIAPs->At( i ); |
|
455 if ( ( conInf->IsVPN() && conInf->VPNIapId() == actIap ) || |
|
456 ( !conInf->IsVPN() && conInf->Id() == actIap ) ) |
|
457 { |
|
458 iActIAPs->AppendL( conInf ); |
|
459 } |
|
460 } |
|
461 } |
|
462 #endif // __WINS__ |
|
463 } |
|
464 |
|
465 SortNameListL( aResourceId ); |
|
466 |
|
467 CLOG_LEAVEFN( "CActiveIAPListing::MergeArraysL " ); |
|
468 } |
|
469 |
|
470 |
|
471 // --------------------------------------------------------- |
|
472 // CActiveIAPListing::SortNameListL |
|
473 // --------------------------------------------------------- |
|
474 // |
|
475 void CActiveIAPListing::SortNameListL( TInt aResourceId ) |
|
476 { |
|
477 CLOG_ENTERFN( "CActiveIAPListing::SortNameListL " ); |
|
478 |
|
479 CConnectionInfoKey* infoKey; |
|
480 |
|
481 HBufC *nameEasyWLAN = NULL; |
|
482 |
|
483 if ( iIsWLANFeatureSupported ) |
|
484 { |
|
485 nameEasyWLAN = StringLoader::LoadL( aResourceId ); |
|
486 CleanupStack::PushL( nameEasyWLAN ); |
|
487 |
|
488 infoKey = CConnectionInfoKey::NewL( *nameEasyWLAN ); |
|
489 } |
|
490 else |
|
491 { |
|
492 infoKey = CConnectionInfoKey::NewL(); |
|
493 } |
|
494 |
|
495 infoKey->SetPtr( iActIAPs ); |
|
496 |
|
497 CleanupStack::PushL( infoKey ); |
|
498 |
|
499 // Sort returns KErrGeneral if stack overflow, otherwise, returns |
|
500 // KErrNone. So we will Leave only if stack overflow, |
|
501 // but than that really does not matter... |
|
502 User::LeaveIfError( iActIAPs->Sort( *infoKey ) ); |
|
503 |
|
504 CleanupStack::Pop( infoKey ); |
|
505 delete infoKey; |
|
506 |
|
507 if ( iIsWLANFeatureSupported ) |
|
508 { |
|
509 CleanupStack::PopAndDestroy( nameEasyWLAN ); |
|
510 } |
|
511 |
|
512 CLOG_LEAVEFN( "CActiveIAPListing::SortNameListL " ); |
|
513 } |
|
514 |
|
515 |
|
516 |
|
517 // --------------------------------------------------------- |
|
518 // CActiveIAPListing::BuildConnectionListL() |
|
519 // --------------------------------------------------------- |
|
520 // |
|
521 void CActiveIAPListing::BuildConnectionListL( TInt aResourceId, |
|
522 TBool aChangeConnection, |
|
523 TUint32 aIAPId ) |
|
524 { |
|
525 CLOG_ENTERFN( "CActiveIAPListing::BuildConnectionListL " ); |
|
526 |
|
527 __ASSERT_DEBUG( iDb, User::Panic( KErrNullPointer, KErrNone ) ); |
|
528 |
|
529 CCommsDbTableView* table; |
|
530 |
|
531 TUint32 id; |
|
532 TUint32 serviceId; |
|
533 TLanType lanType = ELan; |
|
534 TBool isInfrastructure = ETrue; |
|
535 |
|
536 TBuf<CommsDat::KMaxTextLength+1> name; // +1 because it "Zero |
|
537 // terminates" the string |
|
538 TBuf<CommsDat::KMaxTextLength+1> nameIAP; // +1, as before |
|
539 TBuf<CommsDat::KMaxTextLength> serviceType; |
|
540 |
|
541 CCommsDbTableView* serviceTable; |
|
542 |
|
543 CLOG_WRITEF( _L( "iPrefs.iBearerSet: %x" ), iPrefs.iBearerSet ); |
|
544 CLOG_WRITEF( _L( "iPrefs.iDirection: %d" ), iPrefs.iDirection ); |
|
545 |
|
546 CRepository* cr = CRepository::NewLC( KCRUidProfileEngine ); |
|
547 |
|
548 TInt selectedProfile; |
|
549 |
|
550 TRAP_IGNORE( cr->Get( KProEngActiveProfile, selectedProfile ) ); |
|
551 |
|
552 // To get also VPN APs |
|
553 TUint bearerSet = iPrefs.iBearerSet | ECommDbBearerVirtual; |
|
554 |
|
555 TBool isOffLine = selectedProfile == 5; |
|
556 |
|
557 if ( isOffLine ) // testing if current profile is the offline profile |
|
558 { |
|
559 TUint mask=0; |
|
560 mask = ~mask ^ ECommDbBearerCSD ^ ECommDbBearerGPRS; |
|
561 bearerSet &= mask; |
|
562 } |
|
563 |
|
564 CleanupStack::PopAndDestroy(cr); //cr |
|
565 |
|
566 #ifdef __WINS__ |
|
567 bearerSet |= ECommDbBearerLAN; // To add Ethernet AP and WLan (in case) |
|
568 #else |
|
569 if ( iIsWLANFeatureSupported ) |
|
570 { |
|
571 bearerSet |= ECommDbBearerLAN; // To add WLan AP |
|
572 } |
|
573 #endif |
|
574 if ( ( bearerSet & ECommDbBearerLAN ) && |
|
575 ( bearerSet & ECommDbBearerWLAN ) ) |
|
576 { // Otherwise OpenIAPTableViewMatchingBearerSetLC returns two |
|
577 // records for each WLan AP |
|
578 bearerSet ^= ECommDbBearerWLAN; |
|
579 } |
|
580 |
|
581 CLOG_WRITEF( _L( "bearerSet1: %x" ), bearerSet ); |
|
582 |
|
583 if ( ( bearerSet & ECommDbBearerLAN ) && |
|
584 ( bearerSet & ECommDbBearerPAN ) ) |
|
585 { // Otherwise OpenIAPTableViewMatchingBearerSetLC returns two |
|
586 // records for each WLan AP |
|
587 bearerSet ^= ECommDbBearerPAN; |
|
588 } |
|
589 CLOG_WRITEF( _L( "bearerSet2: %x" ), bearerSet ); |
|
590 |
|
591 if ( ( bearerSet & ECommDbBearerPAN ) && |
|
592 ( bearerSet & ECommDbBearerWLAN ) ) |
|
593 { // Otherwise OpenIAPTableViewMatchingBearerSetLC returns two |
|
594 // records for each WLan AP |
|
595 bearerSet ^= ECommDbBearerPAN; |
|
596 } |
|
597 CLOG_WRITEF( _L( "bearerSet3: %x" ), bearerSet ); |
|
598 |
|
599 table = iDb->OpenIAPTableViewMatchingBearerSetLC( bearerSet, |
|
600 iPrefs.iDirection ); |
|
601 |
|
602 TInt errorCode = table->GotoFirstRecord(); |
|
603 TBool easyWLanRecordFound = EFalse; |
|
604 TInt iconNum = EIconIndexGPRS; |
|
605 TBool showAP; |
|
606 TUint32 vpn_iap_id; |
|
607 |
|
608 TBuf<CommsDat::KMaxTextLength+KLenMaxIntAndTab> temp; |
|
609 _LIT( KIconIdText, "%d\t%s" ); |
|
610 |
|
611 while ( errorCode == KErrNone ) |
|
612 { |
|
613 lanType = ENotDefined; |
|
614 isInfrastructure = ETrue; |
|
615 |
|
616 // Get type of IAP service |
|
617 table->ReadTextL( TPtrC( IAP_SERVICE_TYPE ), serviceType ); |
|
618 TBool isVPN = serviceType == TPtrC( VPN_SERVICE ); |
|
619 |
|
620 // Get name for IAP |
|
621 table->ReadTextL( TPtrC( COMMDB_NAME ), name ); |
|
622 name.ZeroTerminate(); |
|
623 |
|
624 // Get id for IAP |
|
625 table->ReadUintL( TPtrC( COMMDB_ID ), id ); |
|
626 |
|
627 // Get IAP service |
|
628 table->ReadUintL( TPtrC( IAP_SERVICE ), serviceId ); |
|
629 |
|
630 CLOG_WRITEF( _L( "IAP name: %S" ), &name ); |
|
631 CLOG_WRITEF( _L( "COMMDB_ID: %d" ), id ); |
|
632 CLOG_WRITEF( _L( "ServiceId: %d" ), serviceId ); |
|
633 |
|
634 if ( isVPN ) |
|
635 { |
|
636 // Get Ip/phone number from IAP service table |
|
637 serviceTable = iDb->OpenViewMatchingUintLC( serviceType, |
|
638 TPtrC( COMMDB_ID ), |
|
639 serviceId ); |
|
640 errorCode = serviceTable->GotoFirstRecord(); |
|
641 if ( errorCode == KErrNone ) |
|
642 { |
|
643 TRAPD (err, serviceTable->ReadUintL( TPtrC( VPN_SERVICE_IAP ), |
|
644 vpn_iap_id )); |
|
645 |
|
646 if ( err != KErrNone ) |
|
647 { |
|
648 CLOG_WRITEF( _L( "Put showAP as false: %d" ), err ); |
|
649 showAP = EFalse; |
|
650 } |
|
651 |
|
652 CCommsDbTableView* serviceTableIAP = |
|
653 iDb->OpenViewMatchingUintLC( TPtrC( IAP ), |
|
654 TPtrC( COMMDB_ID ), |
|
655 vpn_iap_id ); |
|
656 |
|
657 errorCode = serviceTableIAP->GotoFirstRecord(); |
|
658 if ( errorCode == KErrNone ) |
|
659 { |
|
660 // Get name for IAP |
|
661 serviceTableIAP->ReadTextL( TPtrC( COMMDB_NAME ), |
|
662 nameIAP ); |
|
663 nameIAP.ZeroTerminate(); |
|
664 |
|
665 serviceTableIAP->ReadTextL( TPtrC( IAP_SERVICE_TYPE ), |
|
666 serviceType ); |
|
667 serviceTableIAP->ReadUintL( TPtrC( IAP_SERVICE ), |
|
668 serviceId ); |
|
669 |
|
670 TUint32 bearermask; |
|
671 serviceTableIAP->ReadUintL(TPtrC( IAP_BEARER ), bearermask ); |
|
672 |
|
673 //this is for dealing with vpns using gprs and csd iaps while being offline |
|
674 if( ( ( bearermask & ECommDbBearerCSD ) || |
|
675 ( bearermask & ECommDbBearerGPRS ) ) |
|
676 && isOffLine ) |
|
677 { |
|
678 //do not add it and jump to the next record |
|
679 CleanupStack::PopAndDestroy( serviceTableIAP ); |
|
680 CleanupStack::PopAndDestroy( serviceTable ); |
|
681 errorCode = table->GotoNextRecord(); |
|
682 continue; |
|
683 } |
|
684 |
|
685 } |
|
686 CleanupStack::PopAndDestroy( serviceTableIAP ); |
|
687 } |
|
688 CleanupStack::PopAndDestroy( serviceTable ); |
|
689 } |
|
690 else |
|
691 { |
|
692 nameIAP = name; |
|
693 } |
|
694 |
|
695 lanType = ( serviceType == TPtrC( LAN_SERVICE ) /*|| isVPN*/ ) ? |
|
696 GetTypeOfLanL( serviceId, isInfrastructure ) : ENotDefined; |
|
697 |
|
698 if( !aChangeConnection || ( id != aIAPId ) || |
|
699 ( lanType == EEasyWLan && isVPN ) || |
|
700 ( lanType == EEasyWLan && !easyWLanRecordFound ) ) |
|
701 { |
|
702 // Filter out mRouter access points |
|
703 if ( errorCode == KErrNone && |
|
704 nameIAP.Left( KMrouterName().Length() ).CompareF( |
|
705 KMrouterName ) != 0 ) |
|
706 { |
|
707 showAP = ETrue; |
|
708 |
|
709 if ( serviceType == TPtrC( OUTGOING_GPRS ) || |
|
710 serviceType == TPtrC( INCOMING_GPRS ) ) |
|
711 { |
|
712 iconNum = EIconIndexGPRS; |
|
713 if ( isVPN && |
|
714 !( iPrefs.iBearerSet & ECommDbBearerVirtual ) && |
|
715 !( iPrefs.iBearerSet & ECommDbBearerWcdma ) ) |
|
716 { |
|
717 showAP = EFalse; |
|
718 } |
|
719 } |
|
720 else if ( serviceType == TPtrC( LAN_SERVICE ) ) |
|
721 { |
|
722 if ( ( isVPN && |
|
723 !( iPrefs.iBearerSet & ECommDbBearerVirtual ) ) || |
|
724 !isVPN ) |
|
725 { |
|
726 if ( lanType != ELan && !iIsWLANFeatureSupported ) |
|
727 { |
|
728 showAP = EFalse; |
|
729 } |
|
730 |
|
731 |
|
732 #ifndef __WINS__ |
|
733 else if ( lanType == ELan && |
|
734 !( iPrefs.iBearerSet & ECommDbBearerLAN ) ) |
|
735 { |
|
736 showAP = EFalse; |
|
737 } |
|
738 #endif // __WINS__ |
|
739 } |
|
740 |
|
741 // There is not an icon specific for LAN AP: |
|
742 // GPRS icon is used |
|
743 iconNum = EIconIndexGPRS; |
|
744 if ( showAP && iIsWLANFeatureSupported && lanType != ELan ) |
|
745 { |
|
746 if ( lanType == EEasyWLan && |
|
747 !easyWLanRecordFound && |
|
748 !isVPN ) |
|
749 { |
|
750 HBufC *msg = StringLoader::LoadL( aResourceId ); |
|
751 CleanupStack::PushL( msg ); |
|
752 |
|
753 name = *msg; |
|
754 name.ZeroTerminate(); |
|
755 |
|
756 CleanupStack::PopAndDestroy( msg ); |
|
757 |
|
758 iconNum = EIconIndexEasyWLAN; |
|
759 |
|
760 easyWLanRecordFound = ETrue; |
|
761 } |
|
762 else if ( lanType == EEasyWLan && isVPN ) |
|
763 { |
|
764 iconNum = EIconIndexEasyWLAN; |
|
765 } |
|
766 else |
|
767 { |
|
768 iconNum = EIconIndexWLAN; |
|
769 lanType = EWLan; |
|
770 } |
|
771 } |
|
772 } |
|
773 else |
|
774 { |
|
775 if ( isVPN && |
|
776 !( iPrefs.iBearerSet & ECommDbBearerVirtual ) && |
|
777 !( iPrefs.iBearerSet & ECommDbBearerCSD ) ) |
|
778 { |
|
779 showAP = EFalse; |
|
780 } |
|
781 else |
|
782 { |
|
783 // Get Ip/phone number from IAP service table |
|
784 serviceTable = iDb->OpenViewMatchingUintLC( |
|
785 serviceType, |
|
786 TPtrC( COMMDB_ID ), |
|
787 serviceId ); |
|
788 |
|
789 errorCode = serviceTable->GotoFirstRecord(); |
|
790 if ( errorCode == KErrNone ) |
|
791 { |
|
792 TUint32 bearer = EBearerTypeHSCSD; |
|
793 |
|
794 TRAPD( err, serviceTable->ReadUintL( |
|
795 TPtrC( ISP_BEARER_TYPE ), |
|
796 bearer ) ); |
|
797 |
|
798 if ( err != KErrNone ) |
|
799 { // don't leave if read value is not in table. |
|
800 if ( err == KErrUnknown ) |
|
801 { |
|
802 bearer = EBearerTypeCSD; |
|
803 } |
|
804 else |
|
805 { |
|
806 showAP = EFalse; |
|
807 //User::Leave( err ); |
|
808 } |
|
809 } |
|
810 |
|
811 iconNum = ( bearer == EBearerTypeHSCSD ) ? |
|
812 EIconIndexHSCSD : EIconIndexCSD; |
|
813 } |
|
814 else |
|
815 { |
|
816 showAP = EFalse; |
|
817 } |
|
818 |
|
819 CleanupStack::PopAndDestroy( serviceTable ); |
|
820 } |
|
821 } |
|
822 |
|
823 if ( showAP ) |
|
824 { |
|
825 AknTextUtils::LanguageSpecificNumberConversion( name ); |
|
826 |
|
827 temp.FillZ( CommsDat::KMaxTextLength+KLenMaxIntAndTab ); |
|
828 temp.Format( KIconIdText, iconNum, name.Ptr() ); |
|
829 |
|
830 CConnectionInfo* conIn; |
|
831 |
|
832 if ( isVPN ) |
|
833 { |
|
834 conIn = CConnectionInfo::NewL( name, id, vpn_iap_id, |
|
835 temp ); |
|
836 } |
|
837 else |
|
838 { |
|
839 conIn = CConnectionInfo::NewL( name, id, temp ); |
|
840 } |
|
841 |
|
842 CLOG_WRITEF( _L( "id: %d" ), id ); |
|
843 CLOG_WRITEF( _L( "lanType: %d" ), ( TInt )lanType ); |
|
844 CLOG_WRITEF( _L( "isInfrastructure: %d" ), ( TInt )isInfrastructure ); |
|
845 |
|
846 |
|
847 CleanupStack::PushL( conIn ); |
|
848 |
|
849 if ( lanType == EWLan && isInfrastructure ) |
|
850 { |
|
851 iWlanIAPs->AppendL( conIn ); |
|
852 } |
|
853 else |
|
854 { |
|
855 iIAPs->AppendL( conIn ); |
|
856 } |
|
857 |
|
858 CleanupStack::Pop( conIn ); |
|
859 } |
|
860 } |
|
861 } |
|
862 |
|
863 // Next IAP |
|
864 errorCode = table->GotoNextRecord(); |
|
865 } |
|
866 |
|
867 CleanupStack::PopAndDestroy( table ); |
|
868 |
|
869 CLOG_WRITEF( _L( "iIAPs count: %d" ), iIAPs->Count() ); |
|
870 CLOG_WRITEF( _L( "iWlanIAPs count: %d" ), iWlanIAPs->Count() ); |
|
871 |
|
872 CLOG_LEAVEFN( "CActiveIAPListing::BuildConnectionListL " ); |
|
873 } |
|
874 |
|
875 |
|
876 // ---------------------------------------------------------------------------- |
|
877 // TLanType CActiveIAPListing::GetTypeOfLanL() |
|
878 // ---------------------------------------------------------------------------- |
|
879 // |
|
880 TLanType CActiveIAPListing::GetTypeOfLanL( TUint32 aServiceId, |
|
881 TBool& aIsInfrastructure ) |
|
882 { |
|
883 CLOG_ENTERFN( "CActiveIAPListing::GetTypeOfLanL " ); |
|
884 |
|
885 TLanType lanType = ELan; |
|
886 |
|
887 aIsInfrastructure = ETrue; |
|
888 if ( iIsWLANFeatureSupported ) |
|
889 { |
|
890 __ASSERT_DEBUG( iDb, User::Panic( KErrNullPointer, KErrNone ) ); |
|
891 |
|
892 CCommsDbTableView* wLanServiceTable = NULL; |
|
893 |
|
894 TRAPD( err, |
|
895 { // this leaves if the table is empty.... |
|
896 wLanServiceTable = iDb->OpenViewMatchingUintLC( |
|
897 TPtrC( WLAN_SERVICE ), |
|
898 TPtrC( WLAN_SERVICE_ID ), |
|
899 aServiceId ); |
|
900 CleanupStack::Pop( wLanServiceTable ); // wLanServiceTable |
|
901 } ); |
|
902 |
|
903 CLOG_WRITEF( _L( "OpenViewMatchingUintLC returned %d" ), err ); |
|
904 CLOG_WRITEF( _L( "for ServiceId: %d" ), aServiceId ); |
|
905 |
|
906 if ( err == KErrNone ) |
|
907 { |
|
908 CleanupStack::PushL( wLanServiceTable ); |
|
909 |
|
910 TInt errorCode = wLanServiceTable->GotoFirstRecord(); |
|
911 |
|
912 CLOG_WRITEF( _L( "GotoFirstRecord returned %d" ), |
|
913 errorCode ); |
|
914 TWlanSsid sSID; |
|
915 |
|
916 if ( errorCode == KErrNone ) |
|
917 { |
|
918 wLanServiceTable->ReadTextL( TPtrC( NU_WLAN_SSID ), sSID ); |
|
919 lanType = sSID.Length() ? EWLan : EEasyWLan; |
|
920 |
|
921 TUint32 connMode; |
|
922 TRAP( err, wLanServiceTable->ReadUintL( |
|
923 TPtrC( WLAN_CONNECTION_MODE ), |
|
924 connMode ) ); |
|
925 if ( err == KErrNone && !connMode ) |
|
926 { |
|
927 aIsInfrastructure = EFalse; |
|
928 } |
|
929 } |
|
930 |
|
931 CleanupStack::PopAndDestroy( wLanServiceTable ); |
|
932 } |
|
933 else if ( err != KErrNotFound ) |
|
934 { |
|
935 User::LeaveIfError( err ); |
|
936 } |
|
937 } |
|
938 |
|
939 CLOG_LEAVEFN( "CActiveIAPListing::GetTypeOfLanL " ); |
|
940 |
|
941 return lanType; |
|
942 } |
|
943 |
|
944 |
|
945 // End of File |