wlanutilities/wlansniffer/apwizard/src/wsfwlaniapcreator.cpp
branchRCL_3
changeset 21 d9aaeb96a256
parent 0 56b72877c1cb
equal deleted inserted replaced
20:858c6c491d0e 21:d9aaeb96a256
   491 // ----------------------------------------------------------------------------
   491 // ----------------------------------------------------------------------------
   492 //
   492 //
   493 TUint32 CWsfWlanIapCreator::CreateConnectionMethodL( TWsfWlanInfo& aWlanInfo )
   493 TUint32 CWsfWlanIapCreator::CreateConnectionMethodL( TWsfWlanInfo& aWlanInfo )
   494     {
   494     {
   495     LOG_ENTERFN( "CWsfWlanIapCreator::CreateConnectionMethodL" );
   495     LOG_ENTERFN( "CWsfWlanIapCreator::CreateConnectionMethodL" );
   496     HBufC* ssid16 = HBufC::NewLC( aWlanInfo.iSsid.Length() );
   496     
   497     ssid16->Des().Copy( aWlanInfo.iSsid );
   497     HBufC* name16 = NULL;
   498 
   498     HBufC* ssid16 = NULL;
       
   499     
       
   500     if ( aWlanInfo.iRawSsid.Length() )
       
   501         {
       
   502         // ssid is from scan result store it as it is 
       
   503         // since the encoding of ssid is unknown
       
   504         name16 = HBufC::NewLC( aWlanInfo.iRawSsid.Length() );
       
   505         name16->Des().Copy( aWlanInfo.iRawSsid );
       
   506         ssid16 = HBufC::NewLC( aWlanInfo.iRawSsid.Length() );
       
   507         ssid16->Des().Copy( aWlanInfo.iRawSsid );
       
   508         }
       
   509     else
       
   510         {
       
   511         // user has inputted ssid store it to name as unicode since it is utf-8 
       
   512         name16 = aWlanInfo.GetSsidAsUnicodeLC();
       
   513         ssid16 = HBufC::NewLC( aWlanInfo.iSsid.Length() );
       
   514         ssid16->Des().Copy( aWlanInfo.iSsid );
       
   515         }
       
   516         
   499     TUint32 iapId( 0 );
   517     TUint32 iapId( 0 );
   500     
   518     
   501     if ( !iDestinationId )
   519     if ( !iDestinationId )
   502         {
   520         {
   503         // possibly temporary iap to uncategorized
   521         // possibly temporary iap to uncategorized
   505         
   523         
   506         RCmConnectionMethodExt cm = iCmManagerExt.CreateConnectionMethodL( 
   524         RCmConnectionMethodExt cm = iCmManagerExt.CreateConnectionMethodL( 
   507                                                          KUidWlanBearerType );
   525                                                          KUidWlanBearerType );
   508         CleanupClosePushL( cm );
   526         CleanupClosePushL( cm );
   509         
   527         
   510         cm.SetStringAttributeL( ECmName, *ssid16 );
   528         cm.SetStringAttributeL( ECmName, *name16 );
   511         cm.SetStringAttributeL( EWlanSSID, *ssid16 );
   529         cm.SetStringAttributeL( EWlanSSID, *ssid16 );
   512         cm.SetIntAttributeL( EWlanSecurityMode, aWlanInfo.iSecurityMode );
   530         cm.SetIntAttributeL( EWlanSecurityMode, aWlanInfo.iSecurityMode );
   513         cm.SetIntAttributeL( EWlanConnectionMode, aWlanInfo.iNetMode );
   531         cm.SetIntAttributeL( EWlanConnectionMode, aWlanInfo.iNetMode );
   514         cm.SetBoolAttributeL( EWlanScanSSID, !aWlanInfo.iVisibility );
   532         cm.SetBoolAttributeL( EWlanScanSSID, !aWlanInfo.iVisibility );
   515         
   533         
   520         iapId = cm.GetIntAttributeL( ECmId );
   538         iapId = cm.GetIntAttributeL( ECmId );
   521         
   539         
   522         // now retrieve the name again to see if it has been changed 
   540         // now retrieve the name again to see if it has been changed 
   523         // (ExistingCmName -> ExistingCmName(01) and alike)
   541         // (ExistingCmName -> ExistingCmName(01) and alike)
   524         HBufC* cmName = cm.GetStringAttributeL( ECmName );
   542         HBufC* cmName = cm.GetStringAttributeL( ECmName );
   525         aWlanInfo.iNetworkName.Copy( *cmName );
   543         
   526         
   544         TInt error = CnvUtfConverter::ConvertFromUnicodeToUtf8( 
       
   545                                                         aWlanInfo.iNetworkName, 
       
   546                                                         *cmName  );
       
   547         if ( error )
       
   548             {
       
   549             LOG_WRITE( "ConvertFromUnicodeToUtf8 failed");
       
   550             aWlanInfo.iNetworkName.Copy( *cmName );
       
   551             }
       
   552 
   527         delete cmName;
   553         delete cmName;
   528         
   554         
   529         CleanupStack::PopAndDestroy( &cm );
   555         CleanupStack::PopAndDestroy( &cm );
   530         }
   556         }
   531     else
   557     else
   539         
   565         
   540         RCmConnectionMethodExt cm = destination.CreateConnectionMethodL( 
   566         RCmConnectionMethodExt cm = destination.CreateConnectionMethodL( 
   541                                                          KUidWlanBearerType );
   567                                                          KUidWlanBearerType );
   542         CleanupClosePushL( cm );
   568         CleanupClosePushL( cm );
   543 
   569 
   544         cm.SetStringAttributeL( ECmName, *ssid16 );
   570         cm.SetStringAttributeL( ECmName, *name16 );
   545         cm.SetStringAttributeL( EWlanSSID, *ssid16 );
   571         cm.SetStringAttributeL( EWlanSSID, *ssid16 );
   546         cm.SetIntAttributeL( EWlanSecurityMode, aWlanInfo.iSecurityMode );
   572         cm.SetIntAttributeL( EWlanSecurityMode, aWlanInfo.iSecurityMode );
   547         cm.SetIntAttributeL( EWlanConnectionMode, aWlanInfo.iNetMode );
   573         cm.SetIntAttributeL( EWlanConnectionMode, aWlanInfo.iNetMode );
   548         cm.SetBoolAttributeL( EWlanScanSSID, !aWlanInfo.iVisibility );
   574         cm.SetBoolAttributeL( EWlanScanSSID, !aWlanInfo.iVisibility );
   549         
   575         
   554         iapId = cm.GetIntAttributeL( ECmId );
   580         iapId = cm.GetIntAttributeL( ECmId );
   555         
   581         
   556         // now retrieve the name again to see if it has been changed 
   582         // now retrieve the name again to see if it has been changed 
   557         // (ExistingCmName -> ExistingCmName(01) and alike)
   583         // (ExistingCmName -> ExistingCmName(01) and alike)
   558         HBufC* cmName = cm.GetStringAttributeL( ECmName );
   584         HBufC* cmName = cm.GetStringAttributeL( ECmName );
   559         aWlanInfo.iNetworkName.Copy( *cmName );
   585         TInt error = CnvUtfConverter::ConvertFromUnicodeToUtf8( 
       
   586                                                          aWlanInfo.iNetworkName, 
       
   587                                                          *cmName  );
       
   588         if ( error )
       
   589             {
       
   590             LOG_WRITE( "ConvertFromUnicodeToUtf8 failed");
       
   591             aWlanInfo.iNetworkName.Copy( *cmName );
       
   592             }
   560         
   593         
   561         delete cmName;
   594         delete cmName;
   562         
   595         
   563         CleanupStack::PopAndDestroy( &cm );
   596         CleanupStack::PopAndDestroy( &cm );
   564         CleanupStack::PopAndDestroy( &destination );
   597         CleanupStack::PopAndDestroy( &destination );
   565         }
   598         }
   566 
   599 
   567     CleanupStack::PopAndDestroy( ssid16 );
   600     CleanupStack::PopAndDestroy( ssid16 );
       
   601     CleanupStack::PopAndDestroy( name16 );
   568 
   602 
   569     aWlanInfo.iIapId = iapId;
   603     aWlanInfo.iIapId = iapId;
   570     LOG_WRITEF( "new iapId = %d", iapId );
   604     LOG_WRITEF( "new iapId = %d", iapId );
   571 
   605 
   572     return iapId;
   606     return iapId;