wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmplatformdata.cpp
branchRCL_3
changeset 42 a828660c511c
parent 3 6524e815f76f
child 43 d3d7683d16f5
equal deleted inserted replaced
40:5fb7af913dfd 42:a828660c511c
    14 * Description:  Interface class to CenRep and PubSub
    14 * Description:  Interface class to CenRep and PubSub
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 12 %
    19 * %version: 14 %
    20 */
    20 */
    21 
    21 
    22 // INCLUDE FILES
    22 // INCLUDE FILES
    23 #include <e32base.h>
    23 #include <e32base.h>
    24 #include <etelmm.h>
    24 #include <etelmm.h>
    25 #include <mmtsy_names.h>
    25 #include <mmtsy_names.h>
    26 #include <bt_subscribe.h>
    26 #include <bt_subscribe.h>
    27 #include <startupdomainpskeys.h>
    27 #include <startupdomainpskeys.h>
    28 #include <ctsydomainpskeys.h>
    28 #include <ctsydomainpskeys.h>
    29 #include "wlaninternalpskeys.h"
    29 #include "wlaninternalpskeys.h"
       
    30 #include "wlandevicesettingsinternalcrkeys.h"
    30 #include "wlmplatformdata.h"
    31 #include "wlmplatformdata.h"
    31 #include "am_debug.h"
    32 #include "am_debug.h"
    32 
    33 
    33 // ================= MEMBER FUNCTIONS =======================
    34 // ================= MEMBER FUNCTIONS =======================
    34 
    35 
    41     iSystemMode( EWlanSystemStartupInProgress ),
    42     iSystemMode( EWlanSystemStartupInProgress ),
    42     iBtConnectionCount( 0 ),
    43     iBtConnectionCount( 0 ),
    43     iCurrentIcon( EWlmIconStatusNotAvailable ),
    44     iCurrentIcon( EWlmIconStatusNotAvailable ),
    44     iIsStartupComplete( EFalse ),
    45     iIsStartupComplete( EFalse ),
    45     iIsInOffline( EFalse ),
    46     iIsInOffline( EFalse ),
    46     iIsEmergencyCall( EFalse )
    47     iIsEmergencyCall( EFalse ),
       
    48     iNotifiedWlanState( CWlmPlatformData::EWlanNotifiedNone )
    47     {
    49     {
    48     DEBUG( "CWlmPlatformData::CWlmPlatformData()" );
    50     DEBUG( "CWlmPlatformData::CWlmPlatformData()" );
    49     }
    51     }
    50 
    52 
    51 // Symbian 2nd phase constructor can leave.
    53 // Symbian 2nd phase constructor can leave.
    73     // Create subscriber for Emergency Call Info.
    75     // Create subscriber for Emergency Call Info.
    74     iEmergencyCall = CWlmPlatformSubscriber::NewL(
    76     iEmergencyCall = CWlmPlatformSubscriber::NewL(
    75         EWlmSubscribeTypePubSub, *this,
    77         EWlmSubscribeTypePubSub, *this,
    76         KPSUidCtsyEmergencyCallInfo, KCTSYEmergencyCallInfo );
    78         KPSUidCtsyEmergencyCallInfo, KCTSYEmergencyCallInfo );
    77     iEmergencyCall->IssueRequest();
    79     iEmergencyCall->IssueRequest();
       
    80 
       
    81 	// Create subscriber for WLAN master switch
       
    82 	iWlanOnOff = CWlmPlatformSubscriber::NewL(
       
    83 	    EWlmSubscribeTypeCenRep, *this,
       
    84 		KCRUidWlanDeviceSettingsRegistryId, KWlanOnOff );
       
    85 	iWlanOnOff->IssueRequest();
       
    86 	
       
    87 	// Create subscriber for WLAN force disable
       
    88 	iWlanForceDisable = CWlmPlatformSubscriber::NewL(
       
    89 	    EWlmSubscribeTypeCenRep, *this,
       
    90 		KCRUidWlanDeviceSettingsRegistryId, KWlanForceDisable );
       
    91 	iWlanForceDisable->IssueRequest();
    78 
    92 
    79     // Create PubSub property for publishing MAC address
    93     // Create PubSub property for publishing MAC address
    80     TInt ret( KErrNone );
    94     TInt ret( KErrNone );
    81     ret = RProperty::Define( KPSWlanMacAddress, KPSWlanMacAddressType,
    95     ret = RProperty::Define( KPSWlanMacAddress, KPSWlanMacAddressType,
    82         KWlmPSReadPolicy, KWlmPSWritePolicy, KPSWlanMacAddressLength );
    96         KWlmPSReadPolicy, KWlmPSWritePolicy, KPSWlanMacAddressLength );
   104         {
   118         {
   105         User::LeaveIfError( ret );
   119         User::LeaveIfError( ret );
   106         }
   120         }
   107     User::LeaveIfError( iPsBgScanInterval.Attach( KPSUidWlan,
   121     User::LeaveIfError( iPsBgScanInterval.Attach( KPSUidWlan,
   108         KPSWlanBgScanInterval, EOwnerThread ) );
   122         KPSWlanBgScanInterval, EOwnerThread ) );
       
   123     
       
   124     // Create PubSub property for publishing WLAN on/off state
       
   125     ret = RProperty::Define( KPSWlanOnOffState, KPSWlanOnOffStateType,
       
   126         KWlmPSReadPolicy, KWlmPSWritePolicy );
       
   127     if( ret != KErrAlreadyExists )
       
   128         {
       
   129         User::LeaveIfError( ret );
       
   130         }
       
   131     User::LeaveIfError( iPsOnOffState.Attach( KPSUidWlan,
       
   132         KPSWlanOnOffState, EOwnerThread ) );
       
   133     
       
   134     // Publish initial value for WLAN on/off as WLAN OFF
       
   135     PublishWlanOnOff( EPSWlanOff );
   109     }
   136     }
   110 
   137 
   111 // ---------------------------------------------------------
   138 // ---------------------------------------------------------
   112 // CWlmPlatformData::NewL
   139 // CWlmPlatformData::NewL
   113 // ---------------------------------------------------------
   140 // ---------------------------------------------------------
   133     RProperty::Delete( KPSUidWlan, KPSWlanIndicator );
   160     RProperty::Delete( KPSUidWlan, KPSWlanIndicator );
   134     iPsMacAddress.Close();
   161     iPsMacAddress.Close();
   135     RProperty::Delete( KPSUidWlan, KPSWlanMacAddress );
   162     RProperty::Delete( KPSUidWlan, KPSWlanMacAddress );
   136     iPsBgScanInterval.Close();
   163     iPsBgScanInterval.Close();
   137     RProperty::Delete( KPSUidWlan, KPSWlanBgScanInterval );
   164     RProperty::Delete( KPSUidWlan, KPSWlanBgScanInterval );
       
   165     iPsOnOffState.Close();
       
   166     RProperty::Delete( KPSUidWlan, KPSWlanOnOffState );
   138     delete iPropertySystemState;
   167     delete iPropertySystemState;
   139     delete iBtConnections;
   168     delete iBtConnections;
   140     delete iEmergencyCall;    
   169     delete iEmergencyCall;
       
   170     delete iWlanOnOff;
       
   171     delete iWlanForceDisable;    
   141     }
   172     }
   142 
   173 
   143 // ---------------------------------------------------------
   174 // ---------------------------------------------------------
   144 // CWlmPlatformData::SetIconState
   175 // CWlmPlatformData::SetIconState
   145 // Status : Draft
   176 // Status : Draft
   303                          iSystemMode, enumValue );
   334                          iSystemMode, enumValue );
   304                 iSystemMode = enumValue;
   335                 iSystemMode = enumValue;
   305                 }
   336                 }
   306             }
   337             }
   307         }
   338         }
       
   339     else if( aCategory == KCRUidWlanDeviceSettingsRegistryId ) // WLAN on/off
       
   340         {
       
   341         // Notify WLAN on/off observer
       
   342         NotifyWlanOnOffObserver();
       
   343         }
   308     }
   344     }
   309 
   345 
   310 // ---------------------------------------------------------
   346 // ---------------------------------------------------------
   311 // CWlmPlatformData::GetCurrentOperatorMccL
   347 // CWlmPlatformData::GetCurrentOperatorMccL
   312 // Status : Draft
   348 // Status : Draft
   376 
   412 
   377     TRAP_IGNORE( HandlePropertyChangedL( KPropertyUidBluetoothCategory,
   413     TRAP_IGNORE( HandlePropertyChangedL( KPropertyUidBluetoothCategory,
   378         KPropertyKeyBluetoothGetPHYCount ) );
   414         KPropertyKeyBluetoothGetPHYCount ) );
   379     TRAP_IGNORE( HandlePropertyChangedL( KPSUidStartup,
   415     TRAP_IGNORE( HandlePropertyChangedL( KPSUidStartup,
   380         KPSGlobalSystemState ) );
   416         KPSGlobalSystemState ) );
       
   417     // Call NotifyWlanOnOffObserver to inform observer WLAN on/off
       
   418     // state and to get it also published via P&S
       
   419     NotifyWlanOnOffObserver();
   381     }
   420     }
   382 
   421 
   383 // ---------------------------------------------------------
   422 // ---------------------------------------------------------
   384 // CWlmPlatformData::PublishMacAddress
   423 // CWlmPlatformData::PublishMacAddress
   385 // Status : Draft
   424 // Status : Draft
   406     DEBUG1( "CWlmPlatformData::PublishBgScanInterval( %u )",
   445     DEBUG1( "CWlmPlatformData::PublishBgScanInterval( %u )",
   407         aInterval );
   446         aInterval );
   408     
   447     
   409     return iPsBgScanInterval.Set( aInterval );
   448     return iPsBgScanInterval.Set( aInterval );
   410     }
   449     }
       
   450 
       
   451 
       
   452 // ---------------------------------------------------------
       
   453 // CWlmPlatformData::GetWlanOnOffState
       
   454 // Status : Draft
       
   455 // ---------------------------------------------------------
       
   456 //	
       
   457 TWlanOnOffState CWlmPlatformData::GetWlanOnOffState()
       
   458     {
       
   459 	DEBUG( "CWlmPlatformData::GetWlanOnOffState()" );
       
   460 	
       
   461 	TWlanOnOffState wlanState( EWlanOff );
       
   462 	
       
   463 	// Read WLAN master switch
       
   464 	TInt wlanOn( EFalse );
       
   465 	iWlanOnOff->Get( wlanOn );
       
   466 	
       
   467 	// Read WLAN force disable switch
       
   468 	TInt wlanForceDisable( EFalse );
       
   469 	iWlanForceDisable->Get( wlanForceDisable );
       
   470 	
       
   471 	DEBUG2( "CWlmPlatformData::GetWlanOnOffState() - WlanOnOff: %d, WlanForceDisable: %d",
       
   472 	    wlanOn, wlanForceDisable );
       
   473 	
       
   474 	// Check first if WLAN is forcibly disabled as it overrides all the other settings
       
   475 	if( wlanForceDisable )
       
   476 	    {
       
   477 		wlanState = EWlanForceOff;
       
   478 		}
       
   479 	// Check if WLAN master switch is ON
       
   480 	else if( wlanOn )
       
   481 	    {
       
   482 		wlanState = EWlanOn;
       
   483 		}
       
   484 	
       
   485 	DEBUG1( "CWlmPlatformData::GetWlanOnOffState() return value: %d",
       
   486 	    wlanState );
       
   487 	
       
   488 	return wlanState;
       
   489 	}
       
   490 	
       
   491 // ---------------------------------------------------------
       
   492 // CWlmPlatformData::NotifyWlanOnOffObserver
       
   493 // Status : Draft
       
   494 // ---------------------------------------------------------
       
   495 //
       
   496 void CWlmPlatformData::NotifyWlanOnOffObserver()
       
   497     {
       
   498 	DEBUG1( "CWlmPlatformData::NotifyWlanOnOffObserver() - last notified state=%d",
       
   499 	    iNotifiedWlanState );
       
   500 	
       
   501 	// Note that the observer is only notified if the
       
   502 	// state really changes 
       
   503 	
       
   504 	// If WLAN is set ON
       
   505 	if( GetWlanOnOffState() == EWlanOn &&    // WLAN set ON
       
   506 	    iNotifiedWlanState != CWlmPlatformData::EWlanNotifiedOn ) // WLAN ON not notified yet
       
   507 	    {
       
   508 		// Notify observer that WLAN is set ON
       
   509 		iCallback.WlanOn();
       
   510 		iNotifiedWlanState = CWlmPlatformData::EWlanNotifiedOn;
       
   511 		PublishWlanOnOff( EPSWlanOn );
       
   512 		// Note! P&S write operation return value is not checked
       
   513 		DEBUG( "CWlmPlatformData::NotifyWlanOnOffObserver() - WLAN ON notified, P&S updated" );
       
   514 		}
       
   515     // WLAN is set OFF
       
   516 	else if( iNotifiedWlanState != CWlmPlatformData::EWlanNotifiedOff ) // WLAN OFF not notified yet
       
   517 	    {
       
   518 		// Notify observer that WLAN is set OFF
       
   519 	    iCallback.WlanOff();
       
   520 	    iNotifiedWlanState = CWlmPlatformData::EWlanNotifiedOff;
       
   521 	    PublishWlanOnOff( EPSWlanOff );
       
   522 	    // Note! P&S write operation return value is not checked
       
   523 	    DEBUG( "CWlmPlatformData::NotifyWlanOnOffObserver() - WLAN OFF notified, P&S updated" );
       
   524 		}
       
   525     }
       
   526 
       
   527 // ---------------------------------------------------------
       
   528 // CWlmPlatformData::PublishWlanOnOff
       
   529 // Status : Draft
       
   530 // ---------------------------------------------------------
       
   531 //
       
   532 void CWlmPlatformData::PublishWlanOnOff( TPSWlanOnOff aWlanState )
       
   533     {
       
   534     DEBUG1( "CWlmPlatformData::PublishWlanOnOff( wlanState = %d )",
       
   535         aWlanState );
       
   536 
       
   537     TInt err( KErrNone );
       
   538     err = iPsOnOffState.Set( aWlanState );
       
   539     
       
   540     if( err != KErrNone )
       
   541         {
       
   542         DEBUG1( "CWlmPlatformData::PublishWlanOnOff() - ERROR: update failed, err=%d",
       
   543             err );
       
   544         }
       
   545     }