|
1 /* |
|
2 * Copyright (c) 2005-2008 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 the License "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: Handles IAP selection and connection permissions.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 /* |
|
21 |
|
22 IAP selection procedure: |
|
23 ------------------------ |
|
24 |
|
25 Return iCurrentIap if it's feasible: |
|
26 |
|
27 1. If Service has EReadOnlyIaps flag set and iCurrentIap is not found from iService |
|
28 IAPs, set iCurrentIapIsFeasible to EFalse and jump to section 4. |
|
29 2. If iCiAiMatch exists, return it. [EXIT] |
|
30 3. If iCurrentIap is EGprs or ECsd type, return it. [EXIT] |
|
31 4. Run WLAN scan. |
|
32 5. If iCurrentIapIsFeasible is ETrue |
|
33 5.1 Calculate iCiSwiMatch |
|
34 5.2 If iCiSwiMatch exists, return it. [EXIT] |
|
35 |
|
36 iCurrentIap wasn't feasible, try to find from service IAPs list: |
|
37 |
|
38 6. Put service IAPs to iAvailableIaps list. |
|
39 7. Check if WLAN is available, (iActiveIaps has WLAN IAP which is not on service IAPs). |
|
40 7.1 If WLAN is not available remove all WLAN IAPS from iAvailableIaps list. |
|
41 7.2 Choose best from iAvailableIaps. [EXIT] |
|
42 8. Remove all WLAN IAPs from iAvailableIaps list. |
|
43 9. Add iSiSwiMatch to iAvailableIaps list. |
|
44 10. Choose highest priority from iAvailableIaps. [EXIT] |
|
45 |
|
46 Note1: In offline mode hidden WLAN IAPs from service IAPS and current iap |
|
47 are added to Scanned WLAN IAPs even if they are not found from the scan. |
|
48 |
|
49 Note2: If phone is in offline mode, then all EGprs and ECsd IAPs are filtered out |
|
50 from iService IAPs and iCurrentIap. |
|
51 |
|
52 Note3: iCurrentIap is not feasible if service has EReadOnlyIaps flag set and iCurrentIap |
|
53 is not found from service IAPs, ie iCiSiMatch does not contain value. |
|
54 */ |
|
55 |
|
56 // INCLUDE FILES |
|
57 #include "CIptvNetworkSelection.h" |
|
58 #include "CIptvServer.h" |
|
59 #include "CIptvServiceManager.h" |
|
60 #include <cdbcols.h> |
|
61 #include <WlanCdbCols.h> |
|
62 #include "IptvDebug.h" |
|
63 #include <commdb.h> |
|
64 #include <bldvariant.hrh> |
|
65 |
|
66 #include <es_enum.h> //TConnectionInfo |
|
67 #include <in_sock.h> |
|
68 #include <rconnmon.h> |
|
69 #include <wlanmgmtcommon.h> |
|
70 |
|
71 #include <CProfileChangeNotifyHandler.h> |
|
72 #include <Profile.hrh> |
|
73 |
|
74 #include <MProfileEngine.h> |
|
75 |
|
76 #include <cmdestinationext.h> |
|
77 #include <cmmanagerext.h> |
|
78 #include <centralrepository.h> |
|
79 #include <cmpluginwlandef.h> |
|
80 |
|
81 // EXTERNAL DATA STRUCTURES |
|
82 |
|
83 // EXTERNAL FUNCTION PROTOTYPES |
|
84 |
|
85 // CONSTANTS |
|
86 |
|
87 #ifdef __WINSCW__ |
|
88 const TInt KWlanScanSimulationTimerTime = 5000000; // 5 seconds |
|
89 #endif |
|
90 |
|
91 // MACROS |
|
92 |
|
93 // LOCAL CONSTANTS AND MACROS |
|
94 |
|
95 #if IPTV_LOGGING_METHOD != 0 |
|
96 |
|
97 _LIT(KIptvNsWlan, "EWlan"); |
|
98 _LIT(KIptvNsGprs, "EGprs"); |
|
99 _LIT(KIptvNsCsd, "ECsd"); |
|
100 _LIT(KIptvNsUnknown, "EUnknown"); |
|
101 |
|
102 #endif |
|
103 |
|
104 // MODULE DATA STRUCTURES |
|
105 |
|
106 // LOCAL FUNCTION PROTOTYPES |
|
107 |
|
108 // FORWARD DECLARATIONS |
|
109 |
|
110 // ============================= LOCAL FUNCTIONS =============================== |
|
111 |
|
112 // ============================ MEMBER FUNCTIONS =============================== |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CIptvNetworkSelection::CIptvNetworkSelection |
|
116 // C++ default constructor can NOT contain any code, that |
|
117 // might leave. |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 CIptvNetworkSelection::CIptvNetworkSelection( CIptvServer& aServer ) |
|
121 :CActive(EPriorityStandard), iServer(aServer) |
|
122 { |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CIptvNetworkSelection::ConstructL |
|
127 // Symbian 2nd phase constructor can leave. |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CIptvNetworkSelection::ConstructL() |
|
131 { |
|
132 |
|
133 #ifdef __WINSCW__ |
|
134 iWlanScanSimulationTimer = CIptvTimer::NewL( EPriorityStandard, *this ); |
|
135 #endif |
|
136 |
|
137 CActiveScheduler::Add( this ); |
|
138 iGetUsedIapReqs.Reset(); |
|
139 |
|
140 //Initialize iOffline |
|
141 MProfileEngine* engine = CreateProfileEngineL(); |
|
142 CleanupReleasePushL( *engine ); |
|
143 |
|
144 if ( engine ) |
|
145 { |
|
146 if ( engine->ActiveProfileId() == EProfileOffLineId ) |
|
147 { |
|
148 iOffline = ETrue; |
|
149 } |
|
150 else |
|
151 { |
|
152 iOffline = EFalse; |
|
153 } |
|
154 } |
|
155 |
|
156 CleanupStack::PopAndDestroy( engine ); |
|
157 |
|
158 iProfChangeHandler = CProfileChangeNotifyHandler::NewL( this ); |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CIptvNetworkSelection::NewL |
|
163 // Two-phased constructor. |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 CIptvNetworkSelection* CIptvNetworkSelection::NewL( CIptvServer& aServer ) |
|
167 { |
|
168 CIptvNetworkSelection* self = new( ELeave ) CIptvNetworkSelection( aServer ); |
|
169 |
|
170 CleanupStack::PushL( self ); |
|
171 self->ConstructL(); |
|
172 CleanupStack::Pop( self ); |
|
173 |
|
174 return self; |
|
175 } |
|
176 |
|
177 |
|
178 // Destructor |
|
179 CIptvNetworkSelection::~CIptvNetworkSelection() |
|
180 { |
|
181 Cancel(); |
|
182 delete iActiveIaps; |
|
183 delete iScannedWlanIaps; |
|
184 delete iAvailableIaps; |
|
185 iGetUsedIapReqs.Close(); |
|
186 iConnMon.Close(); |
|
187 #ifdef __WINSCW__ |
|
188 delete iWlanScanSimulationTimer; |
|
189 #endif |
|
190 delete iProfChangeHandler; |
|
191 delete iService; |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CIptvNetworkSelection::SetUsedIap |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 void CIptvNetworkSelection::SetUsedIapL( TUint32 aIapId, |
|
199 TUint32 aServiceId, |
|
200 TBool aSetToDefaultForService, |
|
201 TRespStatus& aRespStatus ) |
|
202 { |
|
203 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::SetUsedIapL() start"); |
|
204 |
|
205 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: setting %d as a current IAP in use.", aIapId); |
|
206 iCurrentIap.iId = aIapId; |
|
207 iCurrentIap.iValueExists = ETrue; |
|
208 |
|
209 if ( aSetToDefaultForService ) |
|
210 { |
|
211 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: adding to services' (%d) iap list too", aServiceId); |
|
212 CIptvService* service = iServer.iServiceManager->GetServiceL( aServiceId, ETrue /* do open/close */ ); |
|
213 if ( !service ) |
|
214 { |
|
215 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: service not found: %d", aServiceId); |
|
216 aRespStatus = EServiceNotFound; |
|
217 return; |
|
218 } |
|
219 |
|
220 CleanupStack::PushL( service ); // 1-> |
|
221 |
|
222 TInt i; |
|
223 TBool zeroPrioExists = EFalse; |
|
224 |
|
225 //try to delete iap if its there already |
|
226 TIptvIap iap; |
|
227 iap.iId = aIapId; |
|
228 iap.iPriority = 0; //0 = the highest priority (king), prio has no effect on delete |
|
229 TInt err = service->iIapList->DeleteIap( iap ); |
|
230 |
|
231 if ( err == KErrNone ) |
|
232 { |
|
233 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: There was already iap with id %d, deleted it", aIapId); |
|
234 } |
|
235 else |
|
236 { |
|
237 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: iap did not exist, didn't delete"); |
|
238 } |
|
239 |
|
240 //move up priorities if there is priority 0 iap already |
|
241 for ( i = 0; i < service->iIapList->Count(); i++ ) |
|
242 { |
|
243 if ( service->iIapList->IapL(i).iPriority == 0 ) |
|
244 { |
|
245 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: There was already prio 0"); |
|
246 zeroPrioExists = ETrue; |
|
247 break; |
|
248 } |
|
249 } |
|
250 if ( zeroPrioExists ) |
|
251 { |
|
252 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: adding +1 to all priorities"); |
|
253 for ( i = 0; i < service->iIapList->Count(); i++ ) |
|
254 { |
|
255 service->iIapList->IapL(i).iPriority += 1; |
|
256 } |
|
257 } |
|
258 |
|
259 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: adding new IAP with prio 0"); |
|
260 |
|
261 service->iIapList->AddIap( iap ); |
|
262 iServer.iServiceManager->UpdateServiceL( *service ); |
|
263 CleanupStack::PopAndDestroy( service ); // <-1 |
|
264 } |
|
265 |
|
266 aRespStatus = ESucceeded; |
|
267 |
|
268 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::SetUsedIapL() exit"); |
|
269 } |
|
270 |
|
271 // ----------------------------------------------------------------------------- |
|
272 // CIptvNetworkSelection::GetUsedIapReqL |
|
273 // Called by Network Selection client |
|
274 // ----------------------------------------------------------------------------- |
|
275 // |
|
276 void CIptvNetworkSelection::GetUsedIapReqL( TIptvGetUsedIapReq* aGetUsedIapReq ) |
|
277 { |
|
278 UpdateServiceL( aGetUsedIapReq->iServiceId ); |
|
279 if ( !iService ) |
|
280 { |
|
281 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: * No such service, aborting *"); |
|
282 aGetUsedIapReq->iRespStatus = EServiceNotFound; |
|
283 return; |
|
284 } |
|
285 |
|
286 TInt destId( 0 ); |
|
287 TBool invalidDest( EFalse ); |
|
288 |
|
289 CRepository* cenRep = CRepository::NewLC( KIptvAlrCenRepUid ); |
|
290 if ( cenRep->Get( KIptvCenRepUsedSnapIdKey, destId ) != KErrNone ) |
|
291 { |
|
292 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: * KIptvCenRepUsedSnapIdKey not found *"); |
|
293 aGetUsedIapReq->iRespStatus = static_cast<TUint8>( ENoSuitableIapFound ); |
|
294 invalidDest = ETrue; |
|
295 } |
|
296 else if ( destId == KIptvCenRepAPModeAlwaysAsk ) |
|
297 { |
|
298 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: * KIptvCenRepUsedSnapIdKey always ask"); |
|
299 aGetUsedIapReq->iRespStatus = static_cast<TUint8>( EFailedAlwaysAskSelected ); |
|
300 invalidDest = ETrue; |
|
301 } |
|
302 |
|
303 CleanupStack::PopAndDestroy( cenRep ); |
|
304 |
|
305 // Scan is useless, when always ask is selected. |
|
306 if ( invalidDest && !( (iService->GetFlags() & CIptvService::EReadOnlyIaps ) ) ) |
|
307 { |
|
308 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: ALR//Always ask mode on or key not found"); |
|
309 return; |
|
310 } |
|
311 |
|
312 if ( (iService->GetFlags() & CIptvService::EReadOnlyIaps) ) |
|
313 { |
|
314 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: * service has read only iaps *"); |
|
315 } |
|
316 |
|
317 aGetUsedIapReq->iRespStatus = EProcessing; |
|
318 UpdateAllButWlanListsL( *aGetUsedIapReq ); |
|
319 |
|
320 //informs client that response will arrive asyncrounously to callback function |
|
321 aGetUsedIapReq->iRespStatus = EDoingWlanScan; |
|
322 |
|
323 //add TIptvGetUsedIapReq to list |
|
324 iGetUsedIapReqs.AppendL( aGetUsedIapReq ); |
|
325 |
|
326 #ifdef __WINSCW__ |
|
327 |
|
328 //use timer to simulate event receiving |
|
329 iWlanScanSimulationTimer->Cancel(); |
|
330 iWlanScanSimulationTimer->After( KWlanScanSimulationTimerTime ); |
|
331 |
|
332 #else |
|
333 |
|
334 if ( !IsActive() ) |
|
335 { |
|
336 UpdateWlanScannedIapsL(); //async |
|
337 } |
|
338 #endif |
|
339 |
|
340 //Now we just wait call to RunL() (or TimerExpired() on WINSCW), |
|
341 //RunL() converts SSIDS to IAPS and calls HandleGetUsedIapRequests() |
|
342 |
|
343 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::GetUsedIapReqL() exit"); |
|
344 return; |
|
345 } |
|
346 |
|
347 // ----------------------------------------------------------------------------- |
|
348 // CIptvNetworkSelection::HandleGetUsedIapRequests |
|
349 // Called by RunL() when wlan scan has finished |
|
350 // ----------------------------------------------------------------------------- |
|
351 // |
|
352 void CIptvNetworkSelection::HandleGetUsedIapRequests() |
|
353 { |
|
354 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::HandleGetUsedIapRequests() start"); |
|
355 TInt i; |
|
356 for ( i = 0; i < iGetUsedIapReqs.Count(); i++ ) |
|
357 { |
|
358 TRAPD( err, GetUsedIapAfterWlanScanL( *(iGetUsedIapReqs[i]) ) ); |
|
359 if ( err == KErrNone ) |
|
360 { |
|
361 //inform the request owner |
|
362 iGetUsedIapReqs[i]->iNsObserver->GetUsedIapResp( iGetUsedIapReqs[i] ); |
|
363 } |
|
364 else |
|
365 { |
|
366 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: * failed to get used iap after wlan scan! *"); |
|
367 iGetUsedIapReqs[i]->iRespStatus = static_cast<TUint8>(EGeneralError); |
|
368 iGetUsedIapReqs[i]->iNsObserver->GetUsedIapResp( iGetUsedIapReqs[i] ); |
|
369 } |
|
370 } |
|
371 iGetUsedIapReqs.Close(); //delete request items |
|
372 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::HandleGetUsedIapRequests() exit"); |
|
373 } |
|
374 |
|
375 // ----------------------------------------------------------------------------- |
|
376 // CIptvNetworkSelection::CancelGetUsedIapReq |
|
377 // ----------------------------------------------------------------------------- |
|
378 // |
|
379 TInt CIptvNetworkSelection::CancelGetUsedIapReq( MIptvNetworkSelectionObserver* aObserver ) |
|
380 { |
|
381 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::CancelGetUsedIapReq() start"); |
|
382 TInt i; |
|
383 |
|
384 if ( iGetUsedIapReqs.Count() == 0 ) |
|
385 { |
|
386 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: no requests pending."); |
|
387 return KErrNotFound; |
|
388 } |
|
389 |
|
390 TBool found = EFalse; |
|
391 for ( i = 0; i < iGetUsedIapReqs.Count() && !found; i++ ) |
|
392 { |
|
393 if ( iGetUsedIapReqs[i]->iNsObserver == aObserver ) |
|
394 { |
|
395 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: request removed, cancel resp sent."); |
|
396 iGetUsedIapReqs[i]->iRespStatus = static_cast<TUint8>(ECancelled); |
|
397 iGetUsedIapReqs[i]->iNsObserver->GetUsedIapResp( iGetUsedIapReqs[i] ); |
|
398 iGetUsedIapReqs.Remove( i ); |
|
399 found = ETrue; |
|
400 } |
|
401 } |
|
402 |
|
403 if ( iGetUsedIapReqs.Count() == 0 ) |
|
404 { |
|
405 #ifdef __WINSCW__ |
|
406 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: this was the last request, cancel wlan scan simulation timer (WINSCW only)."); |
|
407 iWlanScanSimulationTimer->Cancel(); |
|
408 #else |
|
409 // Cancel wlan scan |
|
410 Cancel(); |
|
411 iGetUsedIapReqs.Close(); |
|
412 #endif |
|
413 } |
|
414 |
|
415 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::CancelGetUsedIapReq() exit"); |
|
416 |
|
417 if ( !found ) |
|
418 { |
|
419 return KErrNotFound; |
|
420 } |
|
421 else |
|
422 { |
|
423 return KErrNone; |
|
424 } |
|
425 } |
|
426 |
|
427 // ----------------------------------------------------------------------------- |
|
428 // CIptvNetworkSelection::GetUsedIapAfterWlanScanL |
|
429 // ----------------------------------------------------------------------------- |
|
430 // |
|
431 void CIptvNetworkSelection::GetUsedIapAfterWlanScanL( TIptvGetUsedIapReq& aGetUsedIapReq ) |
|
432 { |
|
433 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::GetUsedIapAfterWlanScanL() start"); |
|
434 |
|
435 //we update these again, AI might have changed |
|
436 UpdateAllButWlanListsL( aGetUsedIapReq ); |
|
437 |
|
438 #ifndef __WINSCW__ // wlan stuff is not needed in winscw |
|
439 // Note: This iOffLine check was added to fix the error TSIN-6YTDSJ |
|
440 // "Video Center tries to connect via unavailable WLAN when refreshing |
|
441 // video feed". In online mode the RConnectionMonitor does return the |
|
442 // correct status of hidden WLAN APs so there is no need to add them |
|
443 // manually. Manual addition is needed only in offline mode where platform |
|
444 // cannot sniff for hidden APs (user authorisation would be required). |
|
445 if ( iOffline ) |
|
446 { |
|
447 AddHiddenWlanSiIapsToSwiL(); |
|
448 } |
|
449 #endif |
|
450 // ALR defined |
|
451 // Used iap selected from SNAP with highest priority. |
|
452 RCmManagerExt manager; |
|
453 manager.OpenL(); |
|
454 CleanupClosePushL( manager ); |
|
455 |
|
456 TInt destId( 0 ); |
|
457 CRepository* cenRep = CRepository::NewLC( KIptvAlrCenRepUid ); |
|
458 if( cenRep->Get( KIptvCenRepUsedSnapIdKey, destId ) != KErrNone ) |
|
459 { |
|
460 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: * KIptvCenRepUsedSnapIdKey not found *"); |
|
461 CleanupStack::PopAndDestroy( cenRep ); |
|
462 CleanupStack::PopAndDestroy( &manager ); |
|
463 aGetUsedIapReq.iRespStatus = static_cast<TUint8>(ENoSuitableIapFound); |
|
464 return; |
|
465 } |
|
466 |
|
467 CleanupStack::PopAndDestroy( cenRep ); |
|
468 |
|
469 // Check if read only iaps |
|
470 if ( ( iService->GetFlags() & CIptvService::EReadOnlyIaps ) ) |
|
471 { |
|
472 delete iAvailableIaps; |
|
473 iAvailableIaps = NULL; |
|
474 iAvailableIaps = CIptvIapList::NewL(); |
|
475 |
|
476 TInt i; |
|
477 |
|
478 #ifndef __WINSCW__ |
|
479 for ( i = 0; i < iScannedWlanIaps->Count(); i++ ) |
|
480 { |
|
481 iAvailableIaps->AddIap( iScannedWlanIaps->IapL( i ) ); |
|
482 } |
|
483 #endif //__WINSCW__ |
|
484 |
|
485 for( i = 0; i < iActiveIaps->Count(); i++ ) |
|
486 { |
|
487 iAvailableIaps->AddIap( iActiveIaps->IapL( i ) ); |
|
488 } |
|
489 |
|
490 TInt t=0; |
|
491 while( t < iService->iIapList->Count() ) |
|
492 { |
|
493 TInt temp = iService->iIapList->IapL( t ).iId; |
|
494 |
|
495 RCmConnectionMethodExt conn; |
|
496 CleanupClosePushL( conn ); |
|
497 TRAPD( err, conn = |
|
498 manager.ConnectionMethodL( iService->iIapList->IapL( t ).iId ) ); |
|
499 if( err == KErrNone ) |
|
500 { |
|
501 if( KUidWlanBearerType != conn.GetIntAttributeL( CMManager::ECmBearerType ) ) |
|
502 { |
|
503 CleanupStack::PopAndDestroy( &conn ); |
|
504 CleanupStack::PopAndDestroy( &manager ); |
|
505 // Found read only iap other than wlan |
|
506 SelectL( aGetUsedIapReq, iService->iIapList->IapL( t ).iId ); |
|
507 return; |
|
508 } |
|
509 } |
|
510 TInt s=0; |
|
511 while( s < iAvailableIaps->Count() ) |
|
512 { |
|
513 if( iService->iIapList->IapL( t ).iId == iAvailableIaps->IapL( s ).iId ) |
|
514 { |
|
515 CleanupStack::PopAndDestroy( &conn ); |
|
516 CleanupStack::PopAndDestroy( &manager ); |
|
517 // Found suitable read only iap, select |
|
518 SelectL( aGetUsedIapReq, iService->iIapList->IapL( t ).iId ); |
|
519 return; |
|
520 } |
|
521 s++; |
|
522 } |
|
523 CleanupStack::PopAndDestroy( &conn ); |
|
524 t++; |
|
525 } |
|
526 } |
|
527 |
|
528 //Check destination key |
|
529 if( destId == KIptvCenRepAPModeAlwaysAsk ) |
|
530 { |
|
531 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: * KIptvCenRepUsedSnapIdKey always ask *"); |
|
532 CleanupStack::PopAndDestroy( &manager ); |
|
533 aGetUsedIapReq.iRespStatus = static_cast<TUint8>(EFailedAlwaysAskSelected); |
|
534 return; |
|
535 } |
|
536 |
|
537 RCmDestinationExt cmDest = manager.DestinationL( destId ); |
|
538 CleanupClosePushL( cmDest ); |
|
539 |
|
540 TInt cmCount = cmDest.ConnectionMethodCount(); |
|
541 TInt bestIap( 0 ); |
|
542 TInt alrIap( 0 ); |
|
543 TUint bearerType( 0 ); |
|
544 |
|
545 #ifdef __WINSCW__ |
|
546 if( cmCount ) |
|
547 { |
|
548 // In WINSW supposedly first priority can be used |
|
549 RCmConnectionMethodExt connMethod = cmDest.ConnectionMethodL( 0 ); |
|
550 CleanupClosePushL( connMethod ); |
|
551 bestIap = connMethod.GetIntAttributeL( CMManager::ECmIapId ); |
|
552 CleanupStack::PopAndDestroy( &connMethod ); |
|
553 } |
|
554 #else // __WINSCW__ |
|
555 |
|
556 delete iAvailableIaps; |
|
557 iAvailableIaps = NULL; |
|
558 iAvailableIaps = CIptvIapList::NewL(); |
|
559 |
|
560 TInt i; |
|
561 for ( i = 0; i < iScannedWlanIaps->Count(); i++ ) |
|
562 { |
|
563 iAvailableIaps->AddIap( iScannedWlanIaps->IapL( i ) ); |
|
564 } |
|
565 for( i = 0; i < iActiveIaps->Count(); i++ ) |
|
566 { |
|
567 iAvailableIaps->AddIap( iActiveIaps->IapL( i ) ); |
|
568 } |
|
569 |
|
570 TInt iapCount = iAvailableIaps->Count(); |
|
571 TBool gprsSelected( EFalse ); |
|
572 |
|
573 if( cmCount ) |
|
574 { |
|
575 IPTVLOGSTRING3_LOW_LEVEL("CIptvNetworkSelection:: %d %d", cmCount, iapCount ); |
|
576 TInt t=0; |
|
577 while( t<cmCount ) |
|
578 { |
|
579 RCmConnectionMethodExt connMethod = cmDest.ConnectionMethodL( t ); |
|
580 CleanupClosePushL( connMethod ); |
|
581 alrIap = connMethod.GetIntAttributeL( CMManager::ECmIapId ); |
|
582 bearerType = connMethod.GetIntAttributeL( CMManager::ECmBearerType ); |
|
583 CleanupStack::PopAndDestroy( &connMethod ); |
|
584 if( !iOffline && ( KUidWlanBearerType != bearerType ) ) |
|
585 { |
|
586 // Found gprs, select |
|
587 bestIap = alrIap; |
|
588 gprsSelected = ETrue; |
|
589 t = cmCount; |
|
590 } |
|
591 else |
|
592 { |
|
593 TInt s=0; |
|
594 while( s<iapCount ) |
|
595 { |
|
596 if( alrIap == iAvailableIaps->IapL( s ).iId ) |
|
597 { |
|
598 // Found usable wlan, select |
|
599 bestIap = alrIap; |
|
600 s = iapCount; |
|
601 t = cmCount; |
|
602 } |
|
603 s++; |
|
604 } |
|
605 } |
|
606 t++; |
|
607 } |
|
608 } |
|
609 |
|
610 // Check if wlan available when gprs already selected |
|
611 if( !iOffline ) |
|
612 { |
|
613 |
|
614 if( gprsSelected ) |
|
615 { |
|
616 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: check if WLAN available" ); |
|
617 // GPRS selected, check if WLAN available in other SNAPs |
|
618 |
|
619 // Get list of connection methods that do not belong to any destination |
|
620 RArray<TUint32> iapArray( 3 ); |
|
621 manager.ConnectionMethodL( iapArray ); |
|
622 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: not any dest: %d", iapArray.Count() ); |
|
623 |
|
624 TInt checkedId( 0 ); |
|
625 for( TInt t=0; t<iapArray.Count(); t++ ) |
|
626 { |
|
627 // Check if WLAN iap found |
|
628 RCmConnectionMethodExt cm = manager.ConnectionMethodL( iapArray[t] ); |
|
629 CleanupClosePushL( cm ); |
|
630 if( cm.GetIntAttributeL( CMManager::ECmBearerType ) == KUidWlanBearerType ) |
|
631 { |
|
632 checkedId = cm.GetIntAttributeL( CMManager::ECmIapId ); |
|
633 TInt s=0; |
|
634 while( s < iapCount ) |
|
635 { |
|
636 if( checkedId == iAvailableIaps->IapL( s ).iId ) |
|
637 { |
|
638 IPTVLOGSTRING_LOW_LEVEL( "CIptvNetworkSelection:: iWlanWhenGPRS = ETrue" ); |
|
639 iWlanWhenGPRS = ETrue; |
|
640 s = iapCount; |
|
641 } |
|
642 s++; |
|
643 } |
|
644 |
|
645 } |
|
646 CleanupStack::PopAndDestroy( &cm ); |
|
647 } |
|
648 |
|
649 if( !iWlanWhenGPRS ) |
|
650 { |
|
651 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: Still not found WLAN" ); |
|
652 // Still not found WLAN, check other snaps |
|
653 RArray<TUint32> destArray(3); |
|
654 manager.AllDestinationsL( destArray ); |
|
655 |
|
656 TInt selectedDest( 0 ); |
|
657 CRepository* cenRep = CRepository::NewLC( KIptvAlrCenRepUid ); |
|
658 cenRep->Get( KIptvCenRepUsedSnapIdKey, selectedDest ); |
|
659 CleanupStack::PopAndDestroy( cenRep ); |
|
660 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: dest count:%d", destArray.Count() ); |
|
661 |
|
662 for( TInt s=0; s<destArray.Count(); s++ ) |
|
663 { |
|
664 // Check all other destinations all iaps |
|
665 if( selectedDest != destArray[s] ) |
|
666 { |
|
667 RCmDestinationExt cmDest = manager.DestinationL( destArray[s] ); |
|
668 CleanupClosePushL( cmDest ); |
|
669 TInt methodCount = cmDest.ConnectionMethodCount(); |
|
670 |
|
671 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: methodCoun:%d", methodCount ); |
|
672 |
|
673 for( TInt t=0; t<methodCount; t++ ) |
|
674 { |
|
675 RCmConnectionMethodExt cm = cmDest.ConnectionMethodL( t ); |
|
676 if( cm.GetIntAttributeL( CMManager::ECmBearerType ) == KUidWlanBearerType ) |
|
677 { |
|
678 checkedId = cm.GetIntAttributeL( CMManager::ECmIapId ); |
|
679 TInt s=0; |
|
680 while( s < iapCount ) |
|
681 { |
|
682 if( checkedId == iAvailableIaps->IapL( s ).iId ) |
|
683 { |
|
684 IPTVLOGSTRING_LOW_LEVEL(" CIptvNetworkSelection:: iWlanWhenGPRS = ETrue" ); |
|
685 iWlanWhenGPRS = ETrue; |
|
686 s = iapCount; |
|
687 } |
|
688 s++; |
|
689 } |
|
690 } |
|
691 } |
|
692 CleanupStack::PopAndDestroy( &cmDest ); |
|
693 } |
|
694 } |
|
695 |
|
696 } |
|
697 } |
|
698 } |
|
699 |
|
700 #endif // __WINSCW__ |
|
701 |
|
702 CleanupStack::PopAndDestroy( &cmDest ); |
|
703 CleanupStack::PopAndDestroy( &manager ); |
|
704 |
|
705 if( bestIap ) |
|
706 { |
|
707 SelectL( aGetUsedIapReq, bestIap ); |
|
708 } |
|
709 else |
|
710 { |
|
711 aGetUsedIapReq.iRespStatus = static_cast<TUint8>(ENoSuitableIapFound); |
|
712 } |
|
713 |
|
714 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::GetUsedIapAfterWlanScanL() exit"); |
|
715 } |
|
716 |
|
717 // ----------------------------------------------------------------------------- |
|
718 // CIptvNetworkSelection::SetConnectionAllowed |
|
719 // ----------------------------------------------------------------------------- |
|
720 // |
|
721 void CIptvNetworkSelection::SetConnectionAllowedL(TBool aConnectionAllowed, |
|
722 TUint32 aIapId, |
|
723 TRespStatus& aRespStatus) |
|
724 { |
|
725 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::SetConnectionAllowedL() start"); |
|
726 |
|
727 if ( aConnectionAllowed ) |
|
728 { |
|
729 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: setting connection allowed for: %S type", |
|
730 &(ConnectionTypeDes( CIptvUtil::ConnectionTypeL( aIapId ) ) )); |
|
731 |
|
732 iConnectionAllowedMask |= CIptvUtil::ConnectionTypeL( aIapId ); |
|
733 |
|
734 } |
|
735 else |
|
736 { |
|
737 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: clearing connection allowed for: %S type", |
|
738 &(ConnectionTypeDes( CIptvUtil::ConnectionTypeL( aIapId ) ) )); |
|
739 |
|
740 iConnectionAllowedMask &= ~CIptvUtil::ConnectionTypeL(aIapId); |
|
741 } |
|
742 |
|
743 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: connection allowed mask is now: %x", iConnectionAllowedMask); |
|
744 |
|
745 aRespStatus = ESucceeded; |
|
746 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::SetConnectionAllowedL() exit"); |
|
747 } |
|
748 |
|
749 // ----------------------------------------------------------------------------- |
|
750 // CIptvNetworkSelection::GetIapNameL |
|
751 // Gets IAP name, if empty, tries to find SSID |
|
752 // ----------------------------------------------------------------------------- |
|
753 // |
|
754 void CIptvNetworkSelection::GetIapNameL( TUint32 aIapId, TDes& aIapName ) |
|
755 { |
|
756 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::GetIapNameL() start"); |
|
757 |
|
758 TInt leaveValue = KErrNotFound; |
|
759 |
|
760 aIapName.Zero(); |
|
761 |
|
762 CCommsDatabase* commsDb = CCommsDatabase::NewL( EDatabaseTypeUnspecified ); |
|
763 CleanupStack::PushL( commsDb ); //1-> |
|
764 |
|
765 CCommsDbTableView* iapTableView; |
|
766 |
|
767 //get iap table view |
|
768 iapTableView = commsDb->OpenTableLC( TPtrC(IAP) ); //2-> |
|
769 |
|
770 //Search correct iap and pick connection name |
|
771 TInt err = iapTableView->GotoFirstRecord(); |
|
772 |
|
773 while ( err == KErrNone ) |
|
774 { |
|
775 TUint32 iapId; |
|
776 iapTableView->ReadUintL( TPtrC(COMMDB_ID), iapId ); |
|
777 |
|
778 if ( aIapId == iapId ) |
|
779 { |
|
780 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: IAP found."); |
|
781 |
|
782 TUint32 iapService; |
|
783 |
|
784 iapTableView->ReadTextL( TPtrC(COMMDB_NAME), aIapName ); |
|
785 //IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: COMMDB_NAME: %S", &aIapName); |
|
786 |
|
787 iapTableView->ReadUintL( TPtrC(IAP_SERVICE), iapService ); |
|
788 //IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: IAP_SERVICE = %d", iapService); |
|
789 |
|
790 //Try to get SSID if IAP had no name |
|
791 if ( aIapName.Length() == 0 ) |
|
792 { |
|
793 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: IAP name was empty, trying to get SSID"); |
|
794 |
|
795 TBuf<KIptvUtilMaxTextFieldLengthInDb> colText; |
|
796 iapTableView->ReadTextL( TPtrC(IAP_SERVICE_TYPE), colText ); |
|
797 if ( colText == KIptvUtilLanService ) |
|
798 { |
|
799 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: was lan service, proceeding"); |
|
800 |
|
801 TInt err = GetSsidL( iapService, aIapName ); |
|
802 if ( err == KErrNone ) |
|
803 { |
|
804 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: SSID id found, returning it"); |
|
805 leaveValue = KErrNone; |
|
806 } |
|
807 else |
|
808 { |
|
809 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: Could not get SSID, wasn't WLAN service"); |
|
810 } |
|
811 } |
|
812 else |
|
813 { |
|
814 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: was not lan service, can't be wlan service."); |
|
815 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: giving up."); |
|
816 } |
|
817 } |
|
818 else |
|
819 { |
|
820 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: IAP name found, returning it"); |
|
821 leaveValue = KErrNone; |
|
822 } |
|
823 |
|
824 break; |
|
825 } |
|
826 err = iapTableView->GotoNextRecord(); |
|
827 } |
|
828 CleanupStack::PopAndDestroy( iapTableView ); //<-2 |
|
829 CleanupStack::PopAndDestroy( commsDb ); //<-1 |
|
830 |
|
831 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::GetIapNameL() exit"); |
|
832 User::LeaveIfError( leaveValue ); |
|
833 } |
|
834 |
|
835 // ----------------------------------------------------------------------------- |
|
836 // CIptvNetworkSelection::GetIapIdL |
|
837 // Gets IAP ID |
|
838 // ----------------------------------------------------------------------------- |
|
839 // |
|
840 TInt CIptvNetworkSelection::GetIapIdL(TUint32& aIapId, const TDesC& aIapName) |
|
841 { |
|
842 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::GetIapIdL() start"); |
|
843 |
|
844 TInt returnValue = KErrNotFound; |
|
845 |
|
846 CCommsDatabase* commsDb = CCommsDatabase::NewL(EDatabaseTypeUnspecified); |
|
847 CleanupStack::PushL(commsDb); //1-> |
|
848 |
|
849 CCommsDbTableView* iapTableView; |
|
850 |
|
851 //get iap table view |
|
852 iapTableView = commsDb->OpenTableLC(TPtrC(IAP)); //2-> |
|
853 |
|
854 //Search correct iap name and pick iap id |
|
855 TInt err = iapTableView->GotoFirstRecord(); |
|
856 |
|
857 while ( err == KErrNone ) |
|
858 { |
|
859 TBuf<KIptvUtilMaxTextFieldLengthInDb> iapName; |
|
860 |
|
861 iapTableView->ReadTextL(TPtrC(COMMDB_NAME), iapName); |
|
862 |
|
863 if ( aIapName == iapName ) |
|
864 { |
|
865 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: IAP found."); |
|
866 |
|
867 iapTableView->ReadUintL(TPtrC(COMMDB_ID), aIapId); |
|
868 //IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: COMMDB_ID: %d", aIapId); |
|
869 |
|
870 returnValue = KErrNone; |
|
871 break; |
|
872 } |
|
873 err = iapTableView->GotoNextRecord(); |
|
874 } |
|
875 CleanupStack::PopAndDestroy(iapTableView); //<-2 |
|
876 CleanupStack::PopAndDestroy(commsDb); //<-1 |
|
877 |
|
878 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::GetIapIdL() exit"); |
|
879 return returnValue; |
|
880 } |
|
881 |
|
882 // ----------------------------------------------------------------------------- |
|
883 // CIptvNetworkSelection::GetSsidL |
|
884 // ----------------------------------------------------------------------------- |
|
885 // |
|
886 TInt CIptvNetworkSelection::GetSsidL( TUint32 aWlanServiceId, TDes& aSsid ) |
|
887 { |
|
888 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::GetSsidL() start"); |
|
889 |
|
890 TInt returnValue = KErrNotFound; |
|
891 |
|
892 CCommsDatabase* commsDb = CCommsDatabase::NewL(EDatabaseTypeUnspecified); |
|
893 CleanupStack::PushL(commsDb); //1-> |
|
894 |
|
895 CCommsDbTableView* wlanTableView; |
|
896 |
|
897 //get wlan table view |
|
898 wlanTableView = commsDb->OpenTableLC(TPtrC(WLAN_SERVICE));//2-> |
|
899 |
|
900 TUint32 wlanServiceId; |
|
901 TInt err = wlanTableView->GotoFirstRecord(); |
|
902 TBuf<KWlanMaxSsidLength> ssid; |
|
903 |
|
904 while(err == KErrNone) |
|
905 { |
|
906 wlanTableView->ReadUintL(TPtrC(WLAN_SERVICE_ID), wlanServiceId); |
|
907 |
|
908 |
|
909 #if 1 // def __SERIES60_32__ |
|
910 wlanTableView->ReadTextL(TPtrC(NU_WLAN_SSID), ssid); |
|
911 #else |
|
912 wlanTableView->ReadTextL(TPtrC(WLAN_SSID), ssid); |
|
913 #endif // __SERIES60_32__ |
|
914 |
|
915 if(wlanServiceId == aWlanServiceId) |
|
916 { |
|
917 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: WLAN service ID found, returning SSID"); |
|
918 aSsid = ssid; |
|
919 returnValue = KErrNone; |
|
920 break; |
|
921 } |
|
922 err = wlanTableView->GotoNextRecord(); |
|
923 } |
|
924 CleanupStack::PopAndDestroy(wlanTableView); // <-2 |
|
925 CleanupStack::PopAndDestroy(commsDb); // <-1 |
|
926 |
|
927 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::GetSsidL() exit"); |
|
928 return returnValue; |
|
929 } |
|
930 |
|
931 // ----------------------------------------------------------------------------- |
|
932 // CIptvNetworkSelection::GetActiveIapsL |
|
933 // ----------------------------------------------------------------------------- |
|
934 // |
|
935 CIptvIapList* CIptvNetworkSelection::GetActiveIapsL() |
|
936 { |
|
937 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::GetActiveIaps() start"); |
|
938 |
|
939 CIptvIapList* iapList; |
|
940 iapList = CIptvIapList::NewL(); |
|
941 CleanupStack::PushL(iapList); // 1-> |
|
942 |
|
943 TUint count; |
|
944 RSocketServ serv; |
|
945 RConnection connection; |
|
946 |
|
947 |
|
948 if ( serv.Connect() == KErrNone ) |
|
949 { |
|
950 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: socket server open"); |
|
951 if ( connection.Open(serv, KAfInet ) == KErrNone) |
|
952 { |
|
953 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: connection open"); |
|
954 if ( connection.EnumerateConnections( count ) == KErrNone ) |
|
955 { |
|
956 //IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: connection count: %d", count); |
|
957 for (; count; --count ) |
|
958 { |
|
959 TPckgBuf<TConnectionInfo> connInfo; |
|
960 |
|
961 if ( connection.GetConnectionInfo( count, connInfo ) == KErrNone ) |
|
962 { |
|
963 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: connection: %d", count); |
|
964 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: IapId: %d", connInfo().iIapId); |
|
965 TIptvIap iap; |
|
966 iap.iId = connInfo().iIapId; |
|
967 iap.iPriority = 0; |
|
968 if ( iapList->AddIap( iap, ETrue ) != KErrNone ) |
|
969 { |
|
970 IPTVLOGSTRING_HIGH_LEVEL("CIptvNetworkSelection:: IAP list overflow, could not add all active IAPS!"); |
|
971 } |
|
972 } |
|
973 } |
|
974 } |
|
975 connection.Close(); |
|
976 } |
|
977 serv.Close(); |
|
978 } |
|
979 |
|
980 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::GetActiveIaps() exit"); |
|
981 |
|
982 CleanupStack::Pop(iapList); // <-1 |
|
983 return iapList; |
|
984 } |
|
985 |
|
986 // ----------------------------------------------------------------------------- |
|
987 // CIptvNetworkSelection::UpdateActiveIapsL |
|
988 // ----------------------------------------------------------------------------- |
|
989 // |
|
990 void CIptvNetworkSelection::UpdateActiveIapsL() |
|
991 { |
|
992 if ( iActiveIaps ) |
|
993 { |
|
994 delete iActiveIaps; |
|
995 iActiveIaps = NULL; |
|
996 } |
|
997 |
|
998 iActiveIaps = GetActiveIapsL(); |
|
999 } |
|
1000 |
|
1001 // ----------------------------------------------------------------------------- |
|
1002 // CIptvNetworkSelection::UpdateWlanScannedIapsL |
|
1003 // ----------------------------------------------------------------------------- |
|
1004 // |
|
1005 void CIptvNetworkSelection::UpdateWlanScannedIapsL() |
|
1006 { |
|
1007 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateWlanScannedIapsL() start"); |
|
1008 |
|
1009 User::LeaveIfError( iConnMon.ConnectL() ); |
|
1010 |
|
1011 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: iConnMon connected"); |
|
1012 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: starting async wlan scan"); |
|
1013 |
|
1014 iConnMon.GetPckgAttribute( EBearerIdWLAN, |
|
1015 0, |
|
1016 KIapAvailability, |
|
1017 iIapInfoBuf, |
|
1018 iStatus ); |
|
1019 |
|
1020 SetActive(); |
|
1021 |
|
1022 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateWlanScannedIapsL() exit"); |
|
1023 } |
|
1024 |
|
1025 // ----------------------------------------------------------------------------- |
|
1026 // CIptvNetworkSelection::RunL |
|
1027 // ----------------------------------------------------------------------------- |
|
1028 // |
|
1029 void CIptvNetworkSelection::RunL() |
|
1030 { |
|
1031 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::RunL() start"); |
|
1032 |
|
1033 delete iScannedWlanIaps; |
|
1034 iScannedWlanIaps = NULL; |
|
1035 iScannedWlanIaps = CIptvIapList::NewL(); |
|
1036 |
|
1037 if ( iStatus.Int() != KErrNone ) |
|
1038 { |
|
1039 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: wlan scan failed. iStatus: %d", iStatus.Int() ); |
|
1040 } |
|
1041 else |
|
1042 { |
|
1043 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: wlan scan successful."); |
|
1044 |
|
1045 TConnMonIapInfo iapInfo = iIapInfoBuf(); |
|
1046 TInt i; |
|
1047 for ( i = 0; i < iapInfo.iCount; i++ ) |
|
1048 { |
|
1049 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: wlan iap: %d", iapInfo.iIap[i].iIapId); |
|
1050 TIptvIap iap; |
|
1051 iap.iId = iapInfo.iIap[i].iIapId; |
|
1052 iap.iPriority = 0; |
|
1053 iap.iValueExists = ETrue; |
|
1054 iScannedWlanIaps->AddIap( iap, ETrue /* ignore max limit */ ); |
|
1055 } |
|
1056 } |
|
1057 |
|
1058 iConnMon.Close(); |
|
1059 |
|
1060 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: Scanned WLAN IAPs:"); |
|
1061 #if IPTV_LOGGING_METHOD != 0 |
|
1062 PrintIapList( *iScannedWlanIaps ); |
|
1063 #endif |
|
1064 |
|
1065 //wlan scan has been performed (successfully or not) |
|
1066 //Now handle all GetUsedIapReq:s we have pending |
|
1067 HandleGetUsedIapRequests(); |
|
1068 |
|
1069 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::RunL() exit"); |
|
1070 } |
|
1071 |
|
1072 // ----------------------------------------------------------------------------- |
|
1073 // CIptvNetworkSelection::RunError |
|
1074 // ----------------------------------------------------------------------------- |
|
1075 // |
|
1076 TInt CIptvNetworkSelection::RunError( TInt /*aError*/ ) |
|
1077 { |
|
1078 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::RunError() leave in RunL!"); |
|
1079 |
|
1080 iConnMon.Close(); |
|
1081 return KErrNone; |
|
1082 } |
|
1083 |
|
1084 // ----------------------------------------------------------------------------- |
|
1085 // CIptvNetworkSelection::FindCommonIapFromListsL |
|
1086 // ----------------------------------------------------------------------------- |
|
1087 // |
|
1088 TInt CIptvNetworkSelection::FindCommonIapFromListsL( CIptvIapList& aServiceIaps, |
|
1089 CIptvIapList& aCompareIaps, |
|
1090 TIptvIap& aIap ) |
|
1091 { |
|
1092 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::FindCommonIapFromListsL() start"); |
|
1093 |
|
1094 aServiceIaps.SortByPriorityL(); |
|
1095 |
|
1096 TInt i, j; |
|
1097 for ( j = 0; j < aServiceIaps.Count(); j++ ) |
|
1098 { |
|
1099 //IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: service iap = %d", aServiceIaps.IapL(j).iId); |
|
1100 for ( i = 0; i < aCompareIaps.Count(); i++ ) |
|
1101 { |
|
1102 //IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: compare iap = %d", aCompareIaps.IapL(i).iId); |
|
1103 |
|
1104 if ( aServiceIaps.IapL(j).iId == aCompareIaps.IapL(i).iId ) |
|
1105 { |
|
1106 //IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: common IAP found from service and compare lists: %d", aServiceIaps.IapL(j).iId); |
|
1107 aIap.iValueExists = ETrue; |
|
1108 aIap.iId = aServiceIaps.IapL(j).iId; |
|
1109 aIap.iPriority = aServiceIaps.IapL(j).iPriority; |
|
1110 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::FindCommonIapFromListsL() exit"); |
|
1111 return KErrNone; |
|
1112 } |
|
1113 } |
|
1114 |
|
1115 } |
|
1116 |
|
1117 aIap.iValueExists = EFalse; |
|
1118 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: common IAP not found from service and compare lists"); |
|
1119 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::FindCommonIapFromListsL() exit"); |
|
1120 return KErrNotFound; |
|
1121 } |
|
1122 |
|
1123 // ----------------------------------------------------------------------------- |
|
1124 // CIptvNetworkSelection::IsConnectionAllowedL |
|
1125 // ----------------------------------------------------------------------------- |
|
1126 // |
|
1127 CIptvNetworkSelection::TConnectionPermission CIptvNetworkSelection::IsConnectionAllowedL( |
|
1128 TUint32 aIapId ) |
|
1129 { |
|
1130 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::IsConnectionAllowed() start"); |
|
1131 |
|
1132 TConnectionPermission connectionPermission; |
|
1133 CIptvUtil::TConnectionType connectionType; |
|
1134 |
|
1135 connectionType = CIptvUtil::ConnectionTypeL( aIapId ); |
|
1136 |
|
1137 #if IPTV_LOGGING_METHOD != 0 |
|
1138 const TInt KMaxIapNameLength = 255; |
|
1139 TBuf<KMaxIapNameLength> iapName; |
|
1140 TRAP_IGNORE( GetIapNameL( aIapId, iapName ) ); //dont leave from debug code |
|
1141 |
|
1142 IPTVLOGSTRING3_LOW_LEVEL("CIptvNetworkSelection:: IAP Name = %S, connection type = %S", |
|
1143 &iapName, |
|
1144 &ConnectionTypeDes( connectionType )); |
|
1145 #endif |
|
1146 |
|
1147 if ( connectionType & iConnectionAllowedMask ) |
|
1148 { |
|
1149 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: Connection is allowed"); |
|
1150 connectionPermission = EAllowed; |
|
1151 } |
|
1152 else |
|
1153 { |
|
1154 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: Connection is not allowed"); |
|
1155 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: ->EMustAskConfirmation"); |
|
1156 connectionPermission = EMustAskConfirmation; |
|
1157 } |
|
1158 |
|
1159 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::IsConnectionAllowed() exit"); |
|
1160 return connectionPermission; |
|
1161 } |
|
1162 |
|
1163 // ----------------------------------------------------------------------------- |
|
1164 // CIptvNetworkSelection::CreateFilteredIapListL |
|
1165 // ----------------------------------------------------------------------------- |
|
1166 // |
|
1167 CIptvIapList* CIptvNetworkSelection::CreateFilteredIapListL(CIptvIapList& aIapList, |
|
1168 TUint32 aConnectionTypeMask) |
|
1169 { |
|
1170 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::CreateFilteredIapListL() start"); |
|
1171 |
|
1172 CIptvIapList* filteredIapList = CIptvIapList::NewL(); |
|
1173 CleanupStack::PushL( filteredIapList ); // 1-> |
|
1174 |
|
1175 TInt i; |
|
1176 for ( i = 0; i < aIapList.Count(); i++ ) |
|
1177 { |
|
1178 if((CIptvUtil::ConnectionTypeL( aIapList.IapL(i).iId ) & aConnectionTypeMask)) |
|
1179 { |
|
1180 //IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: Adding %d to filtered iap list.", aIapList.IapL(i).iId); |
|
1181 filteredIapList->AddIap( aIapList.IapL( i ), ETrue ); |
|
1182 } |
|
1183 } |
|
1184 CleanupStack::Pop( filteredIapList ); // <-1 |
|
1185 |
|
1186 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::CreateFilteredIapListL() exit"); |
|
1187 return filteredIapList; |
|
1188 } |
|
1189 |
|
1190 #ifdef ISIAIMATCH_USED |
|
1191 // ----------------------------------------------------------------------------- |
|
1192 // CIptvNetworkSelection::UpdateSiAiMatchL |
|
1193 // ----------------------------------------------------------------------------- |
|
1194 // |
|
1195 void CIptvNetworkSelection::UpdateSiAiMatchL() |
|
1196 { |
|
1197 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateSiAiMatchL() start"); |
|
1198 |
|
1199 if ( iService && iActiveIaps ) |
|
1200 { |
|
1201 TInt err = FindCommonIapFromListsL(*(iService->iIapList), |
|
1202 *iActiveIaps, |
|
1203 iSiAiMatch); |
|
1204 } |
|
1205 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateSiAiMatchL() exit"); |
|
1206 } |
|
1207 #endif |
|
1208 |
|
1209 // ----------------------------------------------------------------------------- |
|
1210 // CIptvNetworkSelection::UpdateSiSwiMatchL |
|
1211 // ----------------------------------------------------------------------------- |
|
1212 // |
|
1213 void CIptvNetworkSelection::UpdateSiSwiMatchL() |
|
1214 { |
|
1215 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateSiSwiMatchL() start"); |
|
1216 |
|
1217 if ( iService && iScannedWlanIaps ) |
|
1218 { |
|
1219 TInt err = FindCommonIapFromListsL(*(iService->iIapList), |
|
1220 *iScannedWlanIaps, |
|
1221 iSiSwiMatch); |
|
1222 } |
|
1223 |
|
1224 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateSiSwiMatchL() exit"); |
|
1225 } |
|
1226 |
|
1227 #ifdef ICISIMATCH_USED |
|
1228 // ----------------------------------------------------------------------------- |
|
1229 // CIptvNetworkSelection::UpdateCiSiMatch |
|
1230 // ----------------------------------------------------------------------------- |
|
1231 // |
|
1232 void CIptvNetworkSelection::UpdateCiSiMatch() |
|
1233 { |
|
1234 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateCiSiMatch() start"); |
|
1235 |
|
1236 TUint8 iapIndex; |
|
1237 |
|
1238 if ( !iCurrentIap.iValueExists ) |
|
1239 { |
|
1240 iCiSiMatch.iValueExists = EFalse; |
|
1241 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateCiSiMatch() exit"); |
|
1242 return; |
|
1243 } |
|
1244 TInt err( KErrNotReady ); |
|
1245 if ( iService && iService->iIapList ) |
|
1246 { |
|
1247 err = iService->iIapList->FindIap(iCurrentIap.iId, iapIndex); |
|
1248 } |
|
1249 |
|
1250 if ( err == KErrNone ) |
|
1251 { |
|
1252 iCiSiMatch.iValueExists = ETrue; |
|
1253 TRAP_IGNORE( //iapIndex is valid since FindIap didnt return error, we can ignore leave |
|
1254 iCiSiMatch.iId = iService->iIapList->IapL( iapIndex ).iId; |
|
1255 iCiSiMatch.iPriority = iService->iIapList->IapL( iapIndex ).iPriority; |
|
1256 ); |
|
1257 } |
|
1258 else |
|
1259 { |
|
1260 iCiSiMatch.iValueExists = EFalse; |
|
1261 } |
|
1262 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateCiSiMatch() exit"); |
|
1263 } |
|
1264 #endif |
|
1265 |
|
1266 // ----------------------------------------------------------------------------- |
|
1267 // CIptvNetworkSelection::UpdateCiAiMatch |
|
1268 // ----------------------------------------------------------------------------- |
|
1269 // |
|
1270 void CIptvNetworkSelection::UpdateCiAiMatch() |
|
1271 { |
|
1272 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateCiAiMatch() start"); |
|
1273 |
|
1274 TUint8 iapIndex; |
|
1275 |
|
1276 if ( !iCurrentIap.iValueExists ) |
|
1277 { |
|
1278 iCiAiMatch.iValueExists = EFalse; |
|
1279 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateCiAiMatch() exit"); |
|
1280 return; |
|
1281 } |
|
1282 |
|
1283 TInt err = iActiveIaps->FindIap(iCurrentIap.iId, iapIndex); |
|
1284 |
|
1285 if ( err == KErrNone ) |
|
1286 { |
|
1287 iCiAiMatch.iValueExists = ETrue; |
|
1288 TRAP_IGNORE( //iapIndex is valid, we can ignore leave |
|
1289 iCiAiMatch.iId = iActiveIaps->IapL(iapIndex).iId; |
|
1290 iCiAiMatch.iPriority = iActiveIaps->IapL(iapIndex).iPriority; //this is not valid |
|
1291 ); |
|
1292 } |
|
1293 else |
|
1294 { |
|
1295 iCiAiMatch.iValueExists = EFalse; |
|
1296 } |
|
1297 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateCiAiMatch() exit"); |
|
1298 } |
|
1299 |
|
1300 // ----------------------------------------------------------------------------- |
|
1301 // CIptvNetworkSelection::UpdateCiSwiMatchL |
|
1302 // ----------------------------------------------------------------------------- |
|
1303 // |
|
1304 void CIptvNetworkSelection::UpdateCiSwiMatchL() |
|
1305 { |
|
1306 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateCiSwiMatchL() start"); |
|
1307 |
|
1308 TUint8 iapIndex; |
|
1309 |
|
1310 if ( !iCurrentIap.iValueExists ) |
|
1311 { |
|
1312 iCiSwiMatch.iValueExists = EFalse; |
|
1313 return; |
|
1314 } |
|
1315 TInt err( KErrNotReady ); |
|
1316 if ( iScannedWlanIaps ) |
|
1317 { |
|
1318 err = iScannedWlanIaps->FindIap( iCurrentIap.iId, iapIndex ); |
|
1319 } |
|
1320 |
|
1321 if ( err == KErrNone ) |
|
1322 { |
|
1323 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: CiSwiMatch found."); |
|
1324 iCiSwiMatch.iValueExists = ETrue; |
|
1325 iCiSwiMatch.iId = iCurrentIap.iId; |
|
1326 iCiSwiMatch.iPriority = iCurrentIap.iPriority; |
|
1327 } |
|
1328 else |
|
1329 { |
|
1330 TBool isHiddenWlanIap = EFalse; |
|
1331 CIptvUtil::TConnectionType connType; |
|
1332 |
|
1333 connType = CIptvUtil::ConnectionTypeL( iCurrentIap.iId, isHiddenWlanIap ); |
|
1334 |
|
1335 if ( connType == CIptvUtil::EWlan && isHiddenWlanIap && iOffline ) |
|
1336 { |
|
1337 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: Current IAP was hidden wlan iap and we were in offline mode, setting to CiSwiMatch"); |
|
1338 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: even if it is not on scanned wlan iaps list."); |
|
1339 iCiSwiMatch.iValueExists = ETrue; |
|
1340 iCiSwiMatch.iId = iCurrentIap.iId; |
|
1341 iCiSwiMatch.iPriority = iCurrentIap.iPriority; |
|
1342 } |
|
1343 else |
|
1344 { |
|
1345 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: CiSwiMatch not found."); |
|
1346 iCiSwiMatch.iValueExists = EFalse; |
|
1347 } |
|
1348 } |
|
1349 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateCiSwiMatchL() exit"); |
|
1350 } |
|
1351 |
|
1352 // ----------------------------------------------------------------------------- |
|
1353 // CIptvNetworkSelection::DoCancel |
|
1354 // ----------------------------------------------------------------------------- |
|
1355 // |
|
1356 void CIptvNetworkSelection::DoCancel() |
|
1357 { |
|
1358 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::DoCancel() active object cancelled!"); |
|
1359 |
|
1360 iConnMon.CancelAsyncRequest( EConnMonGetPckgAttribute ); // From TConnMonAsyncRequest |
|
1361 iConnMon.Close(); |
|
1362 } |
|
1363 |
|
1364 // ----------------------------------------------------------------------------- |
|
1365 // CIptvNetworkSelection::TimerExpired |
|
1366 // ----------------------------------------------------------------------------- |
|
1367 // |
|
1368 #ifdef __WINSCW__ |
|
1369 void CIptvNetworkSelection::TimerExpired(CIptvTimer* aTimer) |
|
1370 #else |
|
1371 void CIptvNetworkSelection::TimerExpired(CIptvTimer* /*aTimer*/) |
|
1372 #endif |
|
1373 { |
|
1374 #ifdef __WINSCW__ |
|
1375 |
|
1376 if ( aTimer == iWlanScanSimulationTimer ) |
|
1377 { |
|
1378 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: iWlanScanSimulationTimer expired"); |
|
1379 HandleGetUsedIapRequests(); |
|
1380 return; |
|
1381 } |
|
1382 |
|
1383 #endif |
|
1384 |
|
1385 } |
|
1386 |
|
1387 // ----------------------------------------------------------------------------- |
|
1388 // CIptvNetworkSelection::GetWlanIapFromAiL |
|
1389 // ----------------------------------------------------------------------------- |
|
1390 // |
|
1391 void CIptvNetworkSelection::GetWlanIapFromAiL(TIptvIap& aIap) |
|
1392 { |
|
1393 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::GetWlanIapFromAiL() start"); |
|
1394 |
|
1395 aIap.iValueExists = EFalse; |
|
1396 |
|
1397 TInt i; |
|
1398 for ( i = 0; i < iActiveIaps->Count(); i++ ) |
|
1399 { |
|
1400 if ( CIptvUtil::ConnectionTypeL( iActiveIaps->IapL( i ).iId ) == CIptvUtil::EWlan ) |
|
1401 { |
|
1402 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: WLAN IAP found from Ai"); |
|
1403 aIap.iValueExists = ETrue; |
|
1404 aIap.iId = iActiveIaps->IapL( i ).iId; |
|
1405 aIap.iPriority = iActiveIaps->IapL( i ).iPriority; |
|
1406 return; //there can be only one wlan iap in Ai, no need to go further |
|
1407 } |
|
1408 } |
|
1409 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::GetWlanIapFromAiL() exit"); |
|
1410 } |
|
1411 |
|
1412 // ----------------------------------------------------------------------------- |
|
1413 // CIptvNetworkSelection::SelectCiL |
|
1414 // ----------------------------------------------------------------------------- |
|
1415 // |
|
1416 void CIptvNetworkSelection::SelectCiL(TIptvGetUsedIapReq& aGetUsedIapReq) |
|
1417 { |
|
1418 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: Selected iCurrentIap"); |
|
1419 SelectL(aGetUsedIapReq, iCurrentIap.iId); |
|
1420 } |
|
1421 |
|
1422 // ----------------------------------------------------------------------------- |
|
1423 // CIptvNetworkSelection::SelectL |
|
1424 // ----------------------------------------------------------------------------- |
|
1425 // |
|
1426 void CIptvNetworkSelection::SelectL(TIptvGetUsedIapReq& aGetUsedIapReq, TUint32 aIapId) |
|
1427 { |
|
1428 aGetUsedIapReq.iIapId = aIapId; |
|
1429 aGetUsedIapReq.iWLANWhenGPRS = iWlanWhenGPRS; |
|
1430 |
|
1431 TRAPD( err, GetIapNameL(aGetUsedIapReq.iIapId, aGetUsedIapReq.iIapName)); |
|
1432 |
|
1433 // If other than KErrNoMemory error occurs, we just give empty iap name and ignore leave |
|
1434 if ( err != KErrNone ) |
|
1435 { |
|
1436 if (err == KErrNoMemory ) |
|
1437 { |
|
1438 User::Leave( KErrNoMemory ); |
|
1439 } |
|
1440 else |
|
1441 { |
|
1442 aGetUsedIapReq.iIapName.Zero(); |
|
1443 } |
|
1444 } |
|
1445 |
|
1446 aGetUsedIapReq.iConnectionPermission = static_cast<TUint8>( IsConnectionAllowedL( |
|
1447 aGetUsedIapReq.iIapId ) ); |
|
1448 aGetUsedIapReq.iRespStatus = static_cast<TUint8>( ESucceeded ); |
|
1449 |
|
1450 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: Selected IAP ID: %d", aIapId); |
|
1451 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: Selected IAP name: %S", &(aGetUsedIapReq.iIapName)); |
|
1452 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: Selected conn perm: %d", aGetUsedIapReq.iConnectionPermission); |
|
1453 IPTVLOGSTRING2_LOW_LEVEL("CIptvNetworkSelection:: Selected resp status: %d", aGetUsedIapReq.iRespStatus); |
|
1454 } |
|
1455 |
|
1456 // ----------------------------------------------------------------------------- |
|
1457 // CIptvNetworkSelection::UpdateAllButWlanListsL |
|
1458 // ----------------------------------------------------------------------------- |
|
1459 // |
|
1460 void CIptvNetworkSelection::UpdateAllButWlanListsL(TIptvGetUsedIapReq& /*aGetUsedIapReq*/) |
|
1461 { |
|
1462 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateAllButWlanListsL() start"); |
|
1463 |
|
1464 if ( iOffline ) |
|
1465 { |
|
1466 ClearGprsAndCsdIapsL(); |
|
1467 } |
|
1468 |
|
1469 UpdateActiveIapsL(); |
|
1470 |
|
1471 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateAllButWlanListsL() exit"); |
|
1472 } |
|
1473 |
|
1474 // ----------------------------------------------------------------------------- |
|
1475 // CIptvNetworkSelection::UpdateServiceL |
|
1476 // ----------------------------------------------------------------------------- |
|
1477 // |
|
1478 void CIptvNetworkSelection::UpdateServiceL(TUint32 aServiceId) |
|
1479 { |
|
1480 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateServiceL() start"); |
|
1481 |
|
1482 delete iService; |
|
1483 iService = NULL; |
|
1484 |
|
1485 iService = iServer.iServiceManager->GetServiceL( aServiceId, ETrue /* do open/close */ ); |
|
1486 if ( iService ) |
|
1487 { |
|
1488 iService->iIapList->SortByPriorityL(); |
|
1489 |
|
1490 //convert iap name (if exists) to iap id |
|
1491 if ( iService->GetIapNameL().Length() > 0 ) |
|
1492 { |
|
1493 TUint32 iapId; |
|
1494 TInt err = GetIapIdL(iapId, iService->GetIapNameL()); |
|
1495 TIptvIap iap; |
|
1496 iap.iId = iapId; |
|
1497 iap.iPriority = 0; |
|
1498 iap.iValueExists = ETrue; |
|
1499 iService->GetIapList().AddIap(iap); |
|
1500 IPTVLOGSTRING3_LOW_LEVEL("CIptvNetworkSelection:: Converted %S iap name to iap id: %d", &(iService->GetIapNameL()), iapId); |
|
1501 iService->SetIapNameL(KIptvEmptyDes); |
|
1502 iServer.iServiceManager->UpdateServiceL(*iService); |
|
1503 } |
|
1504 } |
|
1505 |
|
1506 //IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::UpdateServiceL() exit"); |
|
1507 } |
|
1508 |
|
1509 #if IPTV_LOGGING_METHOD != 0 |
|
1510 // ----------------------------------------------------------------------------- |
|
1511 // CIptvNetworkSelection::PrintIapList |
|
1512 // ----------------------------------------------------------------------------- |
|
1513 // |
|
1514 void CIptvNetworkSelection::PrintIapList( CIptvIapList& aIapList ) |
|
1515 { |
|
1516 TUint8 i; |
|
1517 |
|
1518 if ( aIapList.Count() == 0 ) |
|
1519 { |
|
1520 IPTVLOGSTRING_HIGH_LEVEL("CIptvNetworkSelection:: * Iaplist empty. *"); |
|
1521 return; |
|
1522 } |
|
1523 |
|
1524 const TInt KMaxIapNameLength = 255; |
|
1525 TBuf<KMaxIapNameLength> iapName; |
|
1526 TUint32 iapId; |
|
1527 TUint16 iapPriority; |
|
1528 for ( i = 0; i < aIapList.Count(); i++ ) |
|
1529 { |
|
1530 TRAPD( err, GetIapNameL( aIapList.IapL(i).iId, iapName )); |
|
1531 if ( err != KErrNone ) |
|
1532 { |
|
1533 iapName.Zero(); |
|
1534 } |
|
1535 |
|
1536 TRAP( err, iapId = aIapList.IapL(i).iId ); |
|
1537 if ( err != KErrNone ) |
|
1538 { |
|
1539 iapId = KMaxTUint32; |
|
1540 } |
|
1541 |
|
1542 TRAP( err, iapPriority = aIapList.IapL(i).iPriority ); |
|
1543 if ( err != KErrNone ) |
|
1544 { |
|
1545 iapPriority = KMaxTUint16; |
|
1546 } |
|
1547 |
|
1548 IPTVLOGSTRING4_HIGH_LEVEL( |
|
1549 "CIptvNetworkSelection:: * IAP Name: %S, ID %d PRIO: %d *", |
|
1550 &iapName, iapId, iapPriority ); |
|
1551 } |
|
1552 } |
|
1553 #endif |
|
1554 |
|
1555 // ----------------------------------------------------------------------------- |
|
1556 // CIptvNetworkSelection::ClearUsedIap |
|
1557 // ----------------------------------------------------------------------------- |
|
1558 // |
|
1559 void CIptvNetworkSelection::ClearUsedIap() |
|
1560 { |
|
1561 IPTVLOGSTRING_HIGH_LEVEL("CIptvNetworkSelection:: current iap cleared."); |
|
1562 iCurrentIap.iValueExists = EFalse; |
|
1563 iCurrentIap.iId = 0; |
|
1564 } |
|
1565 |
|
1566 // ----------------------------------------------------------------------------- |
|
1567 // CIptvNetworkSelection::AddHiddenWlanSiIapsToSwiL |
|
1568 // ----------------------------------------------------------------------------- |
|
1569 // |
|
1570 void CIptvNetworkSelection::AddHiddenWlanSiIapsToSwiL() |
|
1571 { |
|
1572 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::AddHiddenWlanSiIapsToSwiL() start"); |
|
1573 |
|
1574 TInt i; |
|
1575 for ( i = 0; i < iService->iIapList->Count(); i++ ) |
|
1576 { |
|
1577 TIptvIap& iap = iService->iIapList->IapL( i ); |
|
1578 TBool isHiddenWlanIap; |
|
1579 CIptvUtil::TConnectionType connType; |
|
1580 |
|
1581 connType = CIptvUtil::ConnectionTypeL( iap.iId, isHiddenWlanIap ); |
|
1582 |
|
1583 if ( connType == CIptvUtil::EWlan && isHiddenWlanIap ) |
|
1584 { |
|
1585 IPTVLOGSTRING2_HIGH_LEVEL("CIptvNetworkSelection:: adding hidden service IAP (%d) to scanned wlan iaps list", iap.iId); |
|
1586 if ( iScannedWlanIaps ) |
|
1587 { |
|
1588 TInt err = iScannedWlanIaps->AddIap(iap, ETrue /* ignore max limit */); |
|
1589 if ( err != KErrNone ) |
|
1590 { |
|
1591 IPTVLOGSTRING2_LOW_LEVEL( "CIptvNetworkSelection::AddHiddenWlanSiIapsToSwiL: iScannedWlanIaps->AddIap failed: %d", err ); |
|
1592 } |
|
1593 } |
|
1594 } |
|
1595 } |
|
1596 |
|
1597 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::AddHiddenWlanSiIapsToSwiL() exit"); |
|
1598 } |
|
1599 |
|
1600 // ----------------------------------------------------------------------------- |
|
1601 // CIptvNetworkSelection::HandleActiveProfileEventL() |
|
1602 // ----------------------------------------------------------------------------- |
|
1603 // |
|
1604 void CIptvNetworkSelection::HandleActiveProfileEventL( TProfileEvent aProfileEvent, |
|
1605 TInt aProfileId ) |
|
1606 { |
|
1607 if ( aProfileEvent == EProfileNewActiveProfile ) //active profile has been changed |
|
1608 { |
|
1609 if ( aProfileId == EProfileOffLineId ) |
|
1610 { |
|
1611 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: phone changed to offline mode"); |
|
1612 iOffline = ETrue; |
|
1613 } |
|
1614 else |
|
1615 { |
|
1616 if (iOffline) |
|
1617 { |
|
1618 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: phone changed back to online mode."); |
|
1619 iOffline = EFalse; |
|
1620 } |
|
1621 } |
|
1622 } |
|
1623 } |
|
1624 |
|
1625 // ----------------------------------------------------------------------------- |
|
1626 // CIptvNetworkSelection::ClearGprsAndCsdIaps() |
|
1627 // ----------------------------------------------------------------------------- |
|
1628 // |
|
1629 void CIptvNetworkSelection::ClearGprsAndCsdIapsL() |
|
1630 { |
|
1631 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::ClearGprsAndCsdIaps() start"); |
|
1632 |
|
1633 //Clear iCurrentIap if it is EGprs or ECsd |
|
1634 if ( iCurrentIap.iValueExists ) |
|
1635 { |
|
1636 if ( CIptvUtil::ConnectionTypeL( iCurrentIap.iId ) == CIptvUtil::EGprs || |
|
1637 CIptvUtil::ConnectionTypeL( iCurrentIap.iId ) == CIptvUtil::ECsd ) |
|
1638 { |
|
1639 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: iCurrentIap (GPRS/CSD type) cleared"); |
|
1640 iCurrentIap.iValueExists = EFalse; |
|
1641 } |
|
1642 } |
|
1643 |
|
1644 //Clear EGprs and ECsd iaps from iService iaps |
|
1645 CIptvIapList* serviceIaps = CreateFilteredIapListL( iService->GetIapList(), CIptvUtil::EWlan ); |
|
1646 CleanupStack::PushL( serviceIaps ); // 1-> |
|
1647 iService->SetIapListL( *serviceIaps ); |
|
1648 CleanupStack::PopAndDestroy( serviceIaps ); // <-1 |
|
1649 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection:: iService GPRS and CSD IAPS cleared"); |
|
1650 |
|
1651 IPTVLOGSTRING_LOW_LEVEL("CIptvNetworkSelection::ClearGprsAndCsdIaps() exit"); |
|
1652 } |
|
1653 |
|
1654 #if IPTV_LOGGING_METHOD != 0 |
|
1655 // ----------------------------------------------------------------------------- |
|
1656 // CIptvNetworkSelection::ConnectionTypeDes() |
|
1657 // ----------------------------------------------------------------------------- |
|
1658 // |
|
1659 const TDesC& CIptvNetworkSelection::ConnectionTypeDes( CIptvUtil::TConnectionType aConnectionType ) |
|
1660 { |
|
1661 switch ( aConnectionType ) |
|
1662 { |
|
1663 case CIptvUtil::EWlan: |
|
1664 return KIptvNsWlan; |
|
1665 |
|
1666 case CIptvUtil::EGprs: |
|
1667 return KIptvNsGprs; |
|
1668 |
|
1669 case CIptvUtil::ECsd: |
|
1670 return KIptvNsCsd; |
|
1671 |
|
1672 default: |
|
1673 return KIptvNsUnknown; |
|
1674 } |
|
1675 } |
|
1676 #endif |