diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/BTNotifier.cpp --- a/bluetoothengine/btnotif/src/BTNotifier.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/BTNotifier.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -31,7 +31,7 @@ #include // Own resources #include // Feature Manager API #include // CnvUtfConverter - +#include #include "btnotifier.h" // Own class definition #include "btNotifDebug.h" // Debugging macros #include "btnotiflock.h" @@ -85,14 +85,14 @@ { // Sets up TLS, must be done before FeatureManager is used. FeatureManager::InitializeLibL(); - TBool isCoverUI = ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) + iIsCoverUI = ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) ? ETrue : EFalse; // Frees the TLS. Must be done after FeatureManager is used. FeatureManager::UnInitializeLib(); iBTEngSettings = CBTEngSettings::NewL(); iDevMan = CBTEngDevMan::NewL( this ); - iNotifUiUtil = CBTNotifUIUtil::NewL( isCoverUI ); + iNotifUiUtil = CBTNotifUIUtil::NewL( iIsCoverUI ); } // ---------------------------------------------------------- @@ -145,6 +145,11 @@ // void CBTNotifierBase::StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) { + if( !iNotifUiUtil ) + { + iNotifUiUtil = CBTNotifUIUtil::NewL( iIsCoverUI ); + } + TRAPD(err, GetParamsL(aBuffer, aReplySlot, aMessage)); if (err) { @@ -423,6 +428,10 @@ TBTRegistrySearch mySearch; mySearch.FindAddress( aAddr ); iDeviceArray = new (ELeave) CBTDeviceArray(1); + if( !iDevMan ) + { + iDevMan = CBTEngDevMan::NewL( this ); + } TInt err = iDevMan->GetDevices( mySearch, iDeviceArray ); if(err) { @@ -449,12 +458,14 @@ TInt resId = IsUserAwarePaired( iDevice->AsNamelessDevice() ) ? R_BT_BLOCK_PAIRED_DEVICE_NOHELP : R_BT_BLOCK_DEVICE_NOHELP; - HBufC* stringHolder = StringLoader::LoadLC( resId, bName ); + RBuf stringholder; + stringholder.CleanupClosePushL(); + BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, resId, bName, 0 ); - TInt keypress = iNotifUiUtil->ShowMessageQueryL( *stringHolder, *header, + TInt keypress = iNotifUiUtil->ShowMessageQueryL( stringholder, *header, R_BT_GENERIC_MESSAGE_QUERY, CAknQueryDialog::EConfirmationTone ); - CleanupStack::PopAndDestroy(stringHolder); + CleanupStack::PopAndDestroy(&stringholder); CleanupStack::PopAndDestroy(header); if( keypress )// user replied "Yes" @@ -479,12 +490,20 @@ iDevice->DeleteLinkKey(); iBTRegistryQueryState = ESetDeviceBlocked; - TInt devManErr = iDevMan->ModifyDevice( *iDevice ); - - // if error, complete message, otherwise waiting for devman callback - // - if(devManErr != KErrNone) - CompleteMessage(devManErr); + TInt err = KErrNone; + if( !iDevMan ) + { + TRAP(err, iDevMan = CBTEngDevMan::NewL( this )); + } + if( !err ) + { + err = iDevMan->ModifyDevice( *iDevice ); + } + if( err ) + { + // if error, complete message, otherwise waiting for devman callback + CompleteMessage(err); + } } void CBTNotifierBase::ChangeAuthorizeState( TBool aTrust ) @@ -496,13 +515,19 @@ iDevice->SetGlobalSecurity(sec); iBTRegistryQueryState = ESetDeviceAuthorizeState; - TInt devManErr = iDevMan->ModifyDevice( *iDevice ); - - // if error, complete message, otherwise waiting for devman callback - // - if(devManErr != KErrNone) + TInt err = KErrNone; + if( !iDevMan ) + { + TRAP(err, iDevMan = CBTEngDevMan::NewL( this )); + } + if( !err ) { - CompleteMessage(devManErr); + err = iDevMan->ModifyDevice( *iDevice ); + } + if( err ) + { + // if error, complete message, otherwise waiting for devman callback + CompleteMessage(err); TBTNotifLockPublish::DeleteNotifLocks( EBTNotiferLockPairedDeviceSetting, iDevice->BDAddr() ); }