void CTcBtManager::SetSecurityL( TInt aChannel, TBool aAuthentication, TBool aEncryption, TBool aAuthorisation ) { LOG( _L("CTcBtManager::SetSecurityL() start") ); RBTMan secManager; User::LeaveIfError( secManager.Connect() ); CleanupClosePushL( secManager ); RBTSecuritySettings secSession; User::LeaveIfError( secSession.Open( secManager ) ); CleanupClosePushL( secSession ); // Define security requirements for our application and RFCOMM. TBTServiceSecurity settings( TUid::Uid( 0x10001234 ), KSolBtRFCOMM, aChannel ); settings.SetAuthentication( aAuthentication ); settings.SetEncryption( aEncryption ); settings.SetAuthorisation( aAuthorisation ); // Register security settings, wait for async operation to complete TRequestStatus status; secSession.RegisterService( settings, status ); User::WaitForRequest( status ); // Report any errors User::LeaveIfError( status.Int() ); CleanupStack::PopAndDestroy( 2 ); // secSession, secManager LOG( _L("CTcBtManager::SetSecurityL() end") ); }
static void SetSecurityOnChannel(TBTSockAddr &addr, int aPort) { // I have to distinguish the old SDK from the new one: // _asm is only defined in the new one #if defined(_NEWBT) #define RBTSecuritySettings RBTSecuritySettingsB #define TBTServiceSecurity TBTServiceSecurityB #endif RBTMan secManager; // a security session RBTSecuritySettings secSettingsSession; // define the security on this port secManager.Connect(); secSettingsSession.Open(secManager); // the security settings TBTServiceSecurity serviceSecurity(TUid::Uid(0x101F7058), KSolBtRFCOMM, 0); //Define security requirements serviceSecurity.SetAuthentication(EFalse); serviceSecurity.SetEncryption(EFalse); serviceSecurity.SetAuthorisation(ETrue); serviceSecurity.SetChannelID(aPort); TRequestStatus status; secSettingsSession.RegisterService(serviceSecurity, status); User::WaitForRequest(status); // wait until the security settings are set }