hotspotfw/hsserver/src/hssiapsettingshandler.cpp
branchRCL_3
changeset 24 63be7eb3fc78
parent 23 b852595f5cbe
child 25 f28ada11abbf
equal deleted inserted replaced
23:b852595f5cbe 24:63be7eb3fc78
    21 #include "hssiapsettingshandler.h"
    21 #include "hssiapsettingshandler.h"
    22 #include "hotspotclientserver.h"
    22 #include "hotspotclientserver.h"
    23 #include "am_debug.h"
    23 #include "am_debug.h"
    24 #include <es_enum.h>
    24 #include <es_enum.h>
    25 
    25 
    26 #include <cmconnectionmethodext.h>
    26 #include <cmconnectionmethod.h>
    27 #include <cmconnectionmethoddef.h>
    27 #include <cmconnectionmethoddef.h>
    28 #include <cmdestinationext.h>
    28 #include <cmdestination.h>
    29 #include <cmmanagerext.h>
    29 #include <cmmanager.h>
    30 
    30 
    31 using namespace CMManager;
    31 using namespace CMManager;
    32 
    32 
    33 // ============================ MEMBER FUNCTIONS ===============================
    33 // ============================ MEMBER FUNCTIONS ===============================
    34 
    34 
    80                                                TUint32& aIapId, 
    80                                                TUint32& aIapId, 
    81                                                const TDesC& aUid )
    81                                                const TDesC& aUid )
    82     {
    82     {
    83     DEBUG("CHssIapSettingsHandler::CreateClientIapL");
    83     DEBUG("CHssIapSettingsHandler::CreateClientIapL");
    84 
    84 
    85     RCmManagerExt cmManager;
    85     RCmManager cmManager;
    86     cmManager.OpenL();
    86     cmManager.OpenL();
    87     CleanupClosePushL( cmManager );
    87     CleanupClosePushL( cmManager );
    88     
    88     
    89     // Read all destination(SNAP) settings into an array
    89     // Read all destination(SNAP) settings into an array
    90     RArray<TUint32> destinations;
    90     RArray<TUint32> destinations;
    91     CleanupClosePushL( destinations );
    91     CleanupClosePushL( destinations );
    92     
    92     
    93     cmManager.AllDestinationsL( destinations );
    93     cmManager.AllDestinationsL( destinations );
    94     RCmDestinationExt destination;
    94     RCmDestination destination;
    95     // Loop through each destination
    95     // Loop through each destination
    96     for( TInt i = 0; i < destinations.Count(); i++ )
    96     for( TInt i = 0; i < destinations.Count(); i++ )
    97         {
    97         {
    98         destination = cmManager.DestinationL(destinations[i]);
    98         destination = cmManager.DestinationL(destinations[i]);
    99         CleanupClosePushL(destination); 
    99         CleanupClosePushL(destination); 
   100         // Internet destination will always exist in the system.
   100         // Internet destination will always exist in the system.
   101         // Internet destination will have ESnapPurposeInternet set in its metadata.
   101         // Internet destination will have ESnapPurposeInternet set in its metadata.
   102         if ( destination.MetadataL( CMManager::ESnapMetadataPurpose ) ==
   102         if (destination.MetadataL(CMManager::ESnapMetadataPurpose) == CMManager::ESnapPurposeInternet)
   103              CMManager::ESnapPurposeInternet )
       
   104             {
   103             {
   105             RCmConnectionMethodExt plugin = cmManager.CreateConnectionMethodL( KUidWlanBearerType );
   104             RCmConnectionMethod plugin = cmManager.CreateConnectionMethodL( KUidWlanBearerType );
   106             CleanupClosePushL( plugin );
   105             CleanupClosePushL( plugin );
   107                 
   106                 
   108             plugin.SetStringAttributeL( ECmName, aIapName );
   107             plugin.SetStringAttributeL( ECmName, aIapName );
   109             plugin.SetStringAttributeL( EWlanSSID, aIapName );
   108             plugin.SetStringAttributeL( EWlanSSID, aIapName );
   110             plugin.SetStringAttributeL( EWlanServiceExtensionTableName, aUid );
   109             plugin.SetStringAttributeL( EWlanServiceExtensionTableName, aUid );
   124 
   123 
   125     DEBUG("CHssIapSettingsHandler::CreateClientIapL Done");
   124     DEBUG("CHssIapSettingsHandler::CreateClientIapL Done");
   126     }
   125     }
   127 
   126 
   128 // -----------------------------------------------------------------------------
   127 // -----------------------------------------------------------------------------
   129 // CreateIapL
   128 // DeleteIapL
   130 // -----------------------------------------------------------------------------
   129 // -----------------------------------------------------------------------------
   131 //    
   130 //
   132 TInt CHssIapSettingsHandler::CreateIapL( TBool aHotspot )
   131 void CHssIapSettingsHandler::DeleteIapL( const TUint aIapId )
   133     {
   132     {
   134     DEBUG("CHssIapSettingsHandler::CreateIapL");
   133     DEBUG1("CHssIapSettingsHandler:::DeleteIapL aIapId=%d ", aIapId);
   135     TInt ret ( KErrNone );
   134 
   136     RCmManagerExt cmManager;
   135     RCmManager cmManager;
   137     cmManager.OpenL();
   136     cmManager.OpenL();
   138     CleanupClosePushL( cmManager );
   137     CleanupClosePushL( cmManager );
   139     
   138 
   140     // Read all destination(SNAP) settings into an array
   139     RCmConnectionMethod plugin = cmManager.ConnectionMethodL( aIapId );
   141     RArray<TUint32> destinations;
       
   142     CleanupClosePushL( destinations );
       
   143     
       
   144     cmManager.AllDestinationsL( destinations );
       
   145     RCmDestinationExt destination;
       
   146     // Loop through each destination
       
   147     for( TInt i = 0; i < destinations.Count(); i++ )
       
   148         {
       
   149         destination = cmManager.DestinationL( destinations[i] );
       
   150         CleanupClosePushL( destination ); 
       
   151         // Internet destination will always exist in the system.
       
   152         // Internet destination will have ESnapPurposeInternet 
       
   153         // set in its metadata.
       
   154         if ( destination.MetadataL( CMManager::ESnapMetadataPurpose ) == 
       
   155                                         CMManager::ESnapPurposeInternet )
       
   156             {
       
   157             CWlanMgmtClient* wlanMgmtClient = CWlanMgmtClient::NewL();
       
   158             CleanupStack::PushL( wlanMgmtClient );
       
   159             
       
   160             TWlanConnectionMode connMode;
       
   161             User::LeaveIfError( 
       
   162                     wlanMgmtClient->GetConnectionMode( connMode ) );
       
   163             
       
   164             TWlanConnectionSecurityMode secMode;
       
   165             User::LeaveIfError( 
       
   166                     wlanMgmtClient->GetConnectionSecurityMode( secMode ) );
       
   167                           
       
   168             HBufC* ssid( NULL );
       
   169             TWlanSsid ssidConn;
       
   170             
       
   171             User::LeaveIfError( 
       
   172                     wlanMgmtClient->GetConnectionSsid( ssidConn ) );
       
   173             ssid = HBufC::NewLC( ssidConn.Length() );
       
   174             ssid->Des().Copy( ssidConn ); 
       
   175             
       
   176             TUint32 serviceId(0);
       
   177             TUint32 easyWlanIapId(0);
       
   178             easyWlanIapId = cmManager.EasyWlanIdL();
       
   179                        
       
   180             RCmConnectionMethodExt easyWlanPlugin;
       
   181             easyWlanPlugin = cmManager.ConnectionMethodL( easyWlanIapId );
       
   182             CleanupClosePushL( easyWlanPlugin );
       
   183             TBool scanSsid = easyWlanPlugin.GetBoolAttributeL( EWlanScanSSID );
       
   184             TUint32 easyWlanServiceId = 
       
   185                     easyWlanPlugin.GetIntAttributeL( EWlanServiceId );
       
   186             CleanupStack::PopAndDestroy(); // easyWlanPlugin;
       
   187             
       
   188             RCmConnectionMethodExt plugin =
       
   189                 cmManager.CreateConnectionMethodL( KUidWlanBearerType );
       
   190             CleanupClosePushL( plugin );        
       
   191             plugin.SetStringAttributeL( ECmName, *ssid );
       
   192             plugin.SetStringAttributeL( EWlanSSID, *ssid );
       
   193             plugin.SetIntAttributeL( CMManager::EWlanSecurityMode,
       
   194                     ConvertConnectionSecurityModeToSecModeL( secMode ));
       
   195             plugin.SetIntAttributeL( EWlanConnectionMode, 
       
   196                     ConvertConnectionModeToNetModeL( connMode ) );
       
   197             plugin.SetBoolAttributeL( EWlanScanSSID, scanSsid );
       
   198             
       
   199             if ( aHotspot )
       
   200                 {
       
   201 				// A hotspot IAP. Mark it so it can be deleted after the use.
       
   202                 plugin.SetStringAttributeL( ECmConfigDaemonManagerName, 
       
   203                                             KHotSpotPlugin );
       
   204                 }
       
   205             
       
   206             destination.AddConnectionMethodL( plugin );
       
   207             destination.UpdateL();
       
   208             serviceId = plugin.GetIntAttributeL( EWlanServiceId );                
       
   209             ret = plugin.GetIntAttributeL( ECmIapId );  
       
   210             CleanupStack::PopAndDestroy( &plugin ); 
       
   211             if ( secMode == EWlanConnectionSecurityWep )
       
   212                 {
       
   213                 SaveWEPKeyL( easyWlanServiceId, serviceId );
       
   214                 }
       
   215                     
       
   216             if ( secMode == EWlanConnectionSecurityWpaPsk )
       
   217                 {
       
   218                 SaveWPAKeyL( easyWlanServiceId, serviceId );
       
   219                 }
       
   220             
       
   221             CleanupStack::PopAndDestroy( ssid ); 
       
   222             CleanupStack::PopAndDestroy( wlanMgmtClient );
       
   223             }
       
   224         CleanupStack::PopAndDestroy( &destination ); 
       
   225         }
       
   226     CleanupStack::PopAndDestroy( &destinations ); 
       
   227     CleanupStack::PopAndDestroy( &cmManager );
       
   228 
       
   229     DEBUG1("CHssIapSettingsHandler::CreateIapL Done iapId: %d", ret);
       
   230     return ret;
       
   231     }
       
   232 
       
   233 // -----------------------------------------------------------------------------
       
   234 // DeleteIapL
       
   235 // -----------------------------------------------------------------------------
       
   236 //
       
   237 void CHssIapSettingsHandler::DeleteIapL( const TUint aIapId )
       
   238     {
       
   239     DEBUG1("CHssIapSettingsHandler:::DeleteIapL aIapId=%d ", aIapId);
       
   240 
       
   241     RCmManagerExt cmManager;
       
   242     cmManager.OpenL();
       
   243     CleanupClosePushL( cmManager );
       
   244 
       
   245     RCmConnectionMethodExt plugin = cmManager.ConnectionMethodL( aIapId );
       
   246     CleanupClosePushL( plugin );
   140     CleanupClosePushL( plugin );
   247 
   141 
   248     cmManager.RemoveAllReferencesL( plugin );
   142     cmManager.RemoveAllReferencesL( plugin );
   249     TBool result = plugin.DeleteL();
   143     TBool result = plugin.DeleteL();
   250    
   144    
   251     DEBUG1("CHssIapSettingsHandler:::DeleteIapL result = %d ", result);
   145     DEBUG1("CHssIapSettingsHandler:::DeleteIapL result = %d ", result);
   252     CleanupStack::PopAndDestroy( &plugin );
   146     CleanupStack::PopAndDestroy( &plugin );
   253     CleanupStack::PopAndDestroy( &cmManager );
   147     CleanupStack::PopAndDestroy( &cmManager );
   254     }
       
   255 
       
   256 // ---------------------------------------------------------
       
   257 // MoveIapL()
       
   258 // ---------------------------------------------------------
       
   259 //
       
   260 void  CHssIapSettingsHandler::MoveIapL( const TUint aIapId )
       
   261     {
       
   262     DEBUG1("CHssIapSettingsHandler::MoveIapL aIapId=%d ", aIapId);
       
   263     // Now move to Internet SNAP
       
   264     RCmManagerExt cmManager;
       
   265     cmManager.OpenL();
       
   266     CleanupClosePushL( cmManager );
       
   267     
       
   268     // Read all destination(SNAP) settings into an array
       
   269     RArray<TUint32> destinations;
       
   270     CleanupClosePushL( destinations );
       
   271     
       
   272     cmManager.AllDestinationsL( destinations );
       
   273     RCmDestinationExt destination;
       
   274     // Loop through each destination
       
   275     for( TInt i = 0; i < destinations.Count(); i++ )
       
   276         {
       
   277         destination = cmManager.DestinationL( destinations[i] );
       
   278         CleanupClosePushL( destination ); 
       
   279         // Internet destination will always exist in the system.
       
   280         // Internet destination will have ESnapPurposeInternet 
       
   281         // set in its metadata.
       
   282         if ( destination.MetadataL( CMManager::ESnapMetadataPurpose ) == 
       
   283                                     CMManager::ESnapPurposeInternet )
       
   284             {
       
   285             RCmConnectionMethodExt iap = cmManager.ConnectionMethodL( aIapId );
       
   286             CleanupClosePushL( iap );
       
   287             iap.SetStringAttributeL( ECmConfigDaemonManagerName, KHotSpotPlugin );
       
   288             destination.AddConnectionMethodL( iap );
       
   289             CleanupStack::PopAndDestroy( &iap );
       
   290             destination.UpdateL();
       
   291             }
       
   292         CleanupStack::PopAndDestroy( &destination ); 
       
   293         }
       
   294     CleanupStack::PopAndDestroy( &destinations ); 
       
   295     CleanupStack::PopAndDestroy( &cmManager );
       
   296    
       
   297     DEBUG( "CHssIapSettingsHandler::MoveIapL Done" );
       
   298     }
   148     }
   299 
   149 
   300 // ---------------------------------------------------------
   150 // ---------------------------------------------------------
   301 // SaveWEPKeyL()
   151 // SaveWEPKeyL()
   302 // ---------------------------------------------------------
   152 // ---------------------------------------------------------