395 TUint32 CSatApnHandler::FindDefaultApL( |
395 TUint32 CSatApnHandler::FindDefaultApL( |
396 const RPacketContext::TProtocolType& aPdpType ) |
396 const RPacketContext::TProtocolType& aPdpType ) |
397 { |
397 { |
398 LOG( SIMPLE, "SATENGINE: CSatApnHandler::FindDefaultApL calling" ); |
398 LOG( SIMPLE, "SATENGINE: CSatApnHandler::FindDefaultApL calling" ); |
399 TUint32 defaultIap( 0 ); |
399 TUint32 defaultIap( 0 ); |
400 TInt pdpType; |
400 TInt pdpType( 0 ); |
401 TBool isFound( EFalse ); |
401 |
402 |
402 // create CMManager Session |
403 // create a network destination |
|
404 RCmDestination des; |
|
405 RCmConnectionMethod cm; |
|
406 |
|
407 // Create CMManager Session |
|
408 RCmManager cmManager; |
403 RCmManager cmManager; |
409 cmManager.OpenL(); |
404 cmManager.OpenL(); |
410 CleanupClosePushL( cmManager ); |
405 CleanupClosePushL( cmManager ); |
411 |
406 |
412 // Get the Connection Method list from the open CMManager session |
407 // create a network connection method |
413 RArray<TUint32> array = RArray<TUint32>( KSatCMGranularity ); |
408 RCmConnectionMethod cm; |
414 CleanupClosePushL( array ); |
409 CleanupClosePushL( cm ); |
415 |
410 // get a default connection method |
416 // list all available destinations' id |
411 GetDefConnMethodL( cmManager, cm ); |
417 cmManager.AllDestinationsL( array ); |
412 |
418 for( TInt i = 0; ( i < array.Count() ) && !isFound; ++i ) |
413 // get pdp type |
419 { |
414 pdpType = cm.GetIntAttributeL( CMManager::EPacketDataPDPType ); |
420 des = cmManager.DestinationL( array[i] ); |
415 if ( pdpType == aPdpType ) |
421 CleanupClosePushL( des ); |
416 { |
422 |
417 // get a default iap id |
423 if ( CMManager::ESnapPurposeInternet == |
418 defaultIap = cm.GetIntAttributeL( CMManager::ECmIapId ); |
424 des.MetadataL( CMManager::ESnapMetadataPurpose ) ) |
419 LOG2( SIMPLE, "SATENGINE: CSatApnHandler::FindDefaultApL \ |
425 { |
420 default iap had been found defaultIap = %d", defaultIap ) |
426 LOG( SIMPLE, "SATENGINE: CSatApnHandler::FindDefaultApL \ |
421 } |
427 the fixed destination is identified as 'Internet'" ); |
422 |
428 for( TInt j = 0; ( j < des.ConnectionMethodCount() ) && |
423 CleanupStack::PopAndDestroy( &cm ); |
429 !isFound; ++j ) |
|
430 { |
|
431 cm = des.ConnectionMethodL( j ); |
|
432 CleanupClosePushL( cm ); |
|
433 pdpType = cm.GetIntAttributeL( |
|
434 CMManager::EPacketDataPDPType ); |
|
435 LOG2( SIMPLE, "SATENGINE: CSatApnHandler::FindDefaultApL \ |
|
436 current protocol type is %d", pdpType ) |
|
437 if ( pdpType == aPdpType ) |
|
438 { |
|
439 defaultIap = cm.GetIntAttributeL( CMManager::ECmIapId ); |
|
440 isFound = ETrue; |
|
441 LOG2( SIMPLE, "SATENGINE: CSatApnHandler::FindDefaultApL \ |
|
442 default iap had been found %d", defaultIap ) |
|
443 } |
|
444 CleanupStack::PopAndDestroy( &cm ); |
|
445 } |
|
446 } |
|
447 CleanupStack::PopAndDestroy( &des ); |
|
448 } |
|
449 CleanupStack::PopAndDestroy( &array ); |
|
450 CleanupStack::PopAndDestroy( &cmManager ); |
424 CleanupStack::PopAndDestroy( &cmManager ); |
451 |
425 |
452 if ( !isFound ) |
426 if ( !defaultIap ) |
453 { |
427 { |
454 LOG( SIMPLE, "SATENGINE: CSatApnHandler: default AP not found" ); |
428 LOG( SIMPLE, "SATENGINE: CSatApnHandler: default AP not found" ); |
455 User::Leave( KErrNotFound ); |
429 User::Leave( KErrNotFound ); |
456 } |
430 } |
457 |
431 |
458 LOG( SIMPLE, "SATENGINE: CSatApnHandler::FindDefaultApL exit" ) |
432 LOG( SIMPLE, "SATENGINE: CSatApnHandler::FindDefaultApL exit" ) |
459 return defaultIap; |
433 return defaultIap; |
460 } |
434 } |
|
435 |
|
436 // -------------------------------------------------------------------------- |
|
437 // CSatApnHandler::GetDefConnMethodL |
|
438 // -------------------------------------------------------------------------- |
|
439 void CSatApnHandler::GetDefConnMethodL( RCmManager& aCmManager, |
|
440 RCmConnectionMethod& aDefCm ) |
|
441 { |
|
442 LOG( SIMPLE, "SATENGINE: CSatApnHandler::GetDefConnMethodL calling" ) |
|
443 |
|
444 // Go through the default connection methods to find |
|
445 // the one valid method |
|
446 TCmDefConnValue defConn; |
|
447 aCmManager.ReadDefConnL( defConn ); |
|
448 |
|
449 LOG3( SIMPLE, "SATENGINE: CSatApnHandler::\ |
|
450 GetDefConnMethodL DefConn type=%d, id=%d", |
|
451 defConn.iType, defConn.iId ) |
|
452 |
|
453 // Default setting is a connection method |
|
454 if ( ECmDefConnConnectionMethod == defConn.iType ) |
|
455 { |
|
456 LOG( SIMPLE, "SATENGINE: CSatApnHandler::\ |
|
457 GetDefConnMethodL ECmDefConnConnectionMethod" ) |
|
458 // get a default connection method |
|
459 aDefCm = aCmManager.ConnectionMethodL( defConn.iId ); |
|
460 } |
|
461 // Default setting is a destination method |
|
462 else if ( ECmDefConnDestination == defConn.iType ) |
|
463 { |
|
464 RCmDestination defDes; |
|
465 CleanupClosePushL( defDes ); |
|
466 |
|
467 LOG( SIMPLE, "SATENGINE: CSatApnHandler::\ |
|
468 GetDefConnMethodL ECmDefConnDestination" ) |
|
469 // get a default destination |
|
470 defDes = aCmManager.DestinationL( defConn.iId ); |
|
471 // get the first default connection method from destination |
|
472 aDefCm = defDes.ConnectionMethodL( 0 ); |
|
473 |
|
474 CleanupStack::PopAndDestroy( &defDes ); |
|
475 } |
|
476 |
|
477 LOG( SIMPLE, "SATENGINE: CSatApnHandler::GetDefConnMethodL exit" ) |
|
478 } |
461 // End of File |
479 // End of File |