bluetoothengine/btnotif/src/BTNotifier.cpp
branchRCL_3
changeset 6 6a29d5ad0713
parent 0 f63038272f30
child 10 b6f55cd40afd
equal deleted inserted replaced
2:0b192a3a05a4 6:6a29d5ad0713
    29 #include <btengutil.h>
    29 #include <btengutil.h>
    30 #include <StringLoader.h>    // Localisation stringloader
    30 #include <StringLoader.h>    // Localisation stringloader
    31 #include <BTNotif.rsg>       // Own resources
    31 #include <BTNotif.rsg>       // Own resources
    32 #include <featmgr.h>            // Feature Manager API
    32 #include <featmgr.h>            // Feature Manager API
    33 #include <utf.h>             // CnvUtfConverter
    33 #include <utf.h>             // CnvUtfConverter
    34 
    34 #include <bluetoothuiutil.h>
    35 #include "btnotifier.h"      // Own class definition
    35 #include "btnotifier.h"      // Own class definition
    36 #include "btNotifDebug.h"    // Debugging macros
    36 #include "btNotifDebug.h"    // Debugging macros
    37 #include "btnotiflock.h"
    37 #include "btnotiflock.h"
    38 #include "btnotif.hrh"       // define MaxNameLength
    38 #include "btnotif.hrh"       // define MaxNameLength
    39 #include "btnotifpanic.h"
    39 #include "btnotifpanic.h"
    83 //
    83 //
    84 void CBTNotifierBase::ConstructL()
    84 void CBTNotifierBase::ConstructL()
    85     {
    85     {
    86 	// Sets up TLS, must be done before FeatureManager is used.
    86 	// Sets up TLS, must be done before FeatureManager is used.
    87 	FeatureManager::InitializeLibL();
    87 	FeatureManager::InitializeLibL();
    88 	TBool isCoverUI = ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) 
    88 	iIsCoverUI = ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) 
    89                     ? ETrue : EFalse; 	
    89                     ? ETrue : EFalse; 	
    90 	// Frees the TLS. Must be done after FeatureManager is used.
    90 	// Frees the TLS. Must be done after FeatureManager is used.
    91     FeatureManager::UnInitializeLib(); 
    91     FeatureManager::UnInitializeLib(); 
    92 
    92 
    93     iBTEngSettings = CBTEngSettings::NewL();
    93     iBTEngSettings = CBTEngSettings::NewL();
    94     iDevMan = CBTEngDevMan::NewL( this );
    94     iDevMan = CBTEngDevMan::NewL( this );
    95     iNotifUiUtil = CBTNotifUIUtil::NewL( isCoverUI );
    95     iNotifUiUtil = CBTNotifUIUtil::NewL( iIsCoverUI );
    96     }
    96     }
    97 
    97 
    98 // ----------------------------------------------------------
    98 // ----------------------------------------------------------
    99 // Destructor.
    99 // Destructor.
   100 // ----------------------------------------------------------
   100 // ----------------------------------------------------------
   143 // Asynchronic notifier launch.
   143 // Asynchronic notifier launch.
   144 // ----------------------------------------------------------
   144 // ----------------------------------------------------------
   145 //
   145 //
   146 void CBTNotifierBase::StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage)
   146 void CBTNotifierBase::StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage)
   147     {
   147     {
       
   148     if( !iNotifUiUtil )
       
   149         {
       
   150         iNotifUiUtil = CBTNotifUIUtil::NewL( iIsCoverUI );    
       
   151         }
       
   152     
   148     TRAPD(err, GetParamsL(aBuffer, aReplySlot, aMessage));
   153     TRAPD(err, GetParamsL(aBuffer, aReplySlot, aMessage));
   149     if (err)
   154     if (err)
   150         {
   155         {
   151         CompleteMessage(err);
   156         CompleteMessage(err);
   152         }
   157         }
   421     __ASSERT_DEBUG(iDevice, BTNOTIF_PANIC(EiDeviceNullWhenCallingGetDeviceFromRegL));
   426     __ASSERT_DEBUG(iDevice, BTNOTIF_PANIC(EiDeviceNullWhenCallingGetDeviceFromRegL));
   422 
   427 
   423     TBTRegistrySearch mySearch;
   428     TBTRegistrySearch mySearch;
   424     mySearch.FindAddress( aAddr );
   429     mySearch.FindAddress( aAddr );
   425     iDeviceArray = new (ELeave) CBTDeviceArray(1);
   430     iDeviceArray = new (ELeave) CBTDeviceArray(1);
       
   431     if( !iDevMan )
       
   432         {
       
   433         iDevMan = CBTEngDevMan::NewL( this );    
       
   434         }
   426     TInt err = iDevMan->GetDevices( mySearch, iDeviceArray );
   435     TInt err = iDevMan->GetDevices( mySearch, iDeviceArray );
   427     if(err)
   436     if(err)
   428         {
   437         {
   429         FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifierBase::GetDeviceFromRegL iDevMan->GetDevices error = %d"), err));
   438         FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifierBase::GetDeviceFromRegL iDevMan->GetDevices error = %d"), err));
   430         DoHandleGetDevicesCompleteL(err, NULL);
   439         DoHandleGetDevicesCompleteL(err, NULL);
   447     HBufC* header= StringLoader::LoadLC( R_BT_BLOCK_DEVICE_HEADER );
   456     HBufC* header= StringLoader::LoadLC( R_BT_BLOCK_DEVICE_HEADER );
   448 
   457 
   449     TInt resId = IsUserAwarePaired( iDevice->AsNamelessDevice() ) ? 
   458     TInt resId = IsUserAwarePaired( iDevice->AsNamelessDevice() ) ? 
   450         R_BT_BLOCK_PAIRED_DEVICE_NOHELP : R_BT_BLOCK_DEVICE_NOHELP;
   459         R_BT_BLOCK_PAIRED_DEVICE_NOHELP : R_BT_BLOCK_DEVICE_NOHELP;
   451 	
   460 	
   452 	HBufC* stringHolder = StringLoader::LoadLC( resId, bName );
   461     RBuf stringholder;
   453 
   462     stringholder.CleanupClosePushL();
   454 	TInt keypress = iNotifUiUtil->ShowMessageQueryL( *stringHolder, *header, 
   463     BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, resId, bName, 0 );
       
   464 
       
   465 	TInt keypress = iNotifUiUtil->ShowMessageQueryL( stringholder, *header, 
   455 	        R_BT_GENERIC_MESSAGE_QUERY, CAknQueryDialog::EConfirmationTone );
   466 	        R_BT_GENERIC_MESSAGE_QUERY, CAknQueryDialog::EConfirmationTone );
   456     
   467     
   457     CleanupStack::PopAndDestroy(stringHolder);                   
   468     CleanupStack::PopAndDestroy(&stringholder);                   
   458     CleanupStack::PopAndDestroy(header);  
   469     CleanupStack::PopAndDestroy(header);  
   459 
   470 
   460     if( keypress )// user replied "Yes"
   471     if( keypress )// user replied "Yes"
   461         {
   472         {
   462         DoBlockDevice();
   473         DoBlockDevice();
   477     deviceSecurity.SetNoAuthorise(EFalse);
   488     deviceSecurity.SetNoAuthorise(EFalse);
   478     iDevice->SetGlobalSecurity(deviceSecurity);
   489     iDevice->SetGlobalSecurity(deviceSecurity);
   479     iDevice->DeleteLinkKey();
   490     iDevice->DeleteLinkKey();
   480  
   491  
   481     iBTRegistryQueryState = ESetDeviceBlocked;
   492     iBTRegistryQueryState = ESetDeviceBlocked;
       
   493     if( !iDevMan )
       
   494         {
       
   495         iDevMan = CBTEngDevMan::NewL( this );    
       
   496         }
   482     TInt devManErr = iDevMan->ModifyDevice( *iDevice );     
   497     TInt devManErr = iDevMan->ModifyDevice( *iDevice );     
   483             
   498             
   484     // if error, complete message, otherwise waiting for devman callback
   499     // if error, complete message, otherwise waiting for devman callback
   485     //
   500     //
   486     if(devManErr != KErrNone)
   501     if(devManErr != KErrNone)
   494     sec.SetBanned(EFalse);
   509     sec.SetBanned(EFalse);
   495     sec.SetNoAuthorise( ( aTrust ) ? ETrue : EFalse ) ;
   510     sec.SetNoAuthorise( ( aTrust ) ? ETrue : EFalse ) ;
   496     iDevice->SetGlobalSecurity(sec);
   511     iDevice->SetGlobalSecurity(sec);
   497  
   512  
   498     iBTRegistryQueryState = ESetDeviceAuthorizeState;
   513     iBTRegistryQueryState = ESetDeviceAuthorizeState;
       
   514     if( !iDevMan )
       
   515         {
       
   516         iDevMan = CBTEngDevMan::NewL( this );    
       
   517         }
   499     TInt devManErr = iDevMan->ModifyDevice( *iDevice );     
   518     TInt devManErr = iDevMan->ModifyDevice( *iDevice );     
   500             
   519             
   501     // if error, complete message, otherwise waiting for devman callback
   520     // if error, complete message, otherwise waiting for devman callback
   502     //
   521     //
   503     if(devManErr != KErrNone)
   522     if(devManErr != KErrNone)