satengine/SatServer/Engine/src/CSatApnHandler.cpp
branchRCL_3
changeset 19 7d48bed6ce0c
parent 18 594d59766373
child 20 987c9837762f
equal deleted inserted replaced
18:594d59766373 19:7d48bed6ce0c
   274 
   274 
   275     cm.SetBoolAttributeL( CMManager::ECmWapIPSecurity, EFalse );
   275     cm.SetBoolAttributeL( CMManager::ECmWapIPSecurity, EFalse );
   276     cm.SetIntAttributeL( CMManager::ECmWapIPWSPOption, 
   276     cm.SetIntAttributeL( CMManager::ECmWapIPWSPOption, 
   277                          CMManager::ECmWapWspOptionConnectionOriented );
   277                          CMManager::ECmWapWspOptionConnectionOriented );
   278     cm.SetBoolAttributeL( CMManager::EPacketDataDisablePlainTextAuth, EFalse );
   278     cm.SetBoolAttributeL( CMManager::EPacketDataDisablePlainTextAuth, EFalse );
   279     cm.SetIntAttributeL( CMManager::ECmIFPromptForAuth, EFalse );
   279     cm.SetBoolAttributeL( CMManager::ECmIFPromptForAuth, EFalse );
   280 
   280 
   281     if ( aUserLogin != KNullDesC )
   281     if ( aUserLogin != KNullDesC )
   282         {
   282         {
   283         LOG2( NORMAL, "SATENGINE: CSatApnHandler::InsertRecordL, \
   283         LOG2( NORMAL, "SATENGINE: CSatApnHandler::InsertRecordL, \
   284             username is %S", &aUserLogin ) 
   284             username is %S", &aUserLogin ) 
   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( 0 );
   400     TInt pdpType;
   401 
   401     TBool isFound( EFalse );
   402     // create CMManager Session
   402 
       
   403     // create a network destination
       
   404     RCmDestination des;
       
   405     RCmConnectionMethod cm;
       
   406 
       
   407     // Create CMManager Session
   403     RCmManager cmManager;
   408     RCmManager cmManager;
   404     cmManager.OpenL();
   409     cmManager.OpenL();
   405     CleanupClosePushL( cmManager );
   410     CleanupClosePushL( cmManager );
   406 
   411 
   407     // create a network connection method
   412     // Get the Connection Method list from the open CMManager session
   408     RCmConnectionMethod cm;
   413     RArray<TUint32> array( KSatCMGranularity );
   409     CleanupClosePushL( cm );
   414     CleanupClosePushL( array );
   410     // get a default connection method
   415 
   411     GetDefConnMethodL( cmManager, cm );
   416     // list all available destinations' id
   412 
   417     cmManager.AllDestinationsL( array );
   413     // get pdp type
   418     for( TInt i = 0; ( i < array.Count() ) && !isFound; ++i )
   414     pdpType = cm.GetIntAttributeL( CMManager::EPacketDataPDPType );
   419         {
   415     if ( pdpType == aPdpType )
   420         des = cmManager.DestinationL( array[i] );
   416         {
   421         CleanupClosePushL( des );
   417         // get a default iap id
   422 
   418         defaultIap = cm.GetIntAttributeL( CMManager::ECmIapId );
   423         if ( CMManager::ESnapPurposeInternet ==
   419         LOG2( SIMPLE, "SATENGINE: CSatApnHandler::FindDefaultApL \
   424         des.MetadataL( CMManager::ESnapMetadataPurpose ) )
   420                   default iap had been found defaultIap = %d", defaultIap )
   425             {
   421         }
   426             LOG( SIMPLE, "SATENGINE: CSatApnHandler::FindDefaultApL \
   422 
   427             the fixed destination is identified as 'Internet'" );
   423     CleanupStack::PopAndDestroy( &cm );
   428             for( TInt j = 0; ( j < des.ConnectionMethodCount() ) &&
       
   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 );
   424     CleanupStack::PopAndDestroy( &cmManager );
   450     CleanupStack::PopAndDestroy( &cmManager );
   425 
   451 
   426     if ( !defaultIap )
   452     if ( !isFound )
   427         {
   453         {
   428         LOG( SIMPLE, "SATENGINE: CSatApnHandler: default AP not found" );
   454         LOG( SIMPLE, "SATENGINE: CSatApnHandler: default AP not found" );
   429         User::Leave( KErrNotFound );
   455         User::Leave( KErrNotFound );
   430         }
   456         }
   431 
   457 
   432     LOG( SIMPLE, "SATENGINE: CSatApnHandler::FindDefaultApL exit" )
   458     LOG( SIMPLE, "SATENGINE: CSatApnHandler::FindDefaultApL exit" )
   433     return defaultIap;
   459     return defaultIap;
   434     }
   460     }
   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     }
       
   479 //  End of File
   461 //  End of File