Revision: 201003 RCL_3 PDK_3.0.h
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Feb 2010 22:59:18 +0200
branchRCL_3
changeset 6 6a29d5ad0713
parent 2 0b192a3a05a4
child 8 0707dd69d236
Revision: 201003 Kit: 201007
bluetoothappprofiles/avrcp/remconbeareravrcp/inc/bulkbearer.h
bluetoothappprofiles/avrcp/remconbeareravrcp/inc/controlbearer.h
bluetoothappprofiles/avrcp/remconbeareravrcp/inc/remconcommandinterface.h
bluetoothappprofiles/avrcp/remconbeareravrcp/src/bulkbearer.cpp
bluetoothappprofiles/avrcp/remconbeareravrcp/src/playerstatewatcher.cpp
bluetoothappprofiles/avrcp/remconbeareravrcp/src/remconbeareravrcp.cpp
bluetoothengine/btaudioman/btaccpanic.h
bluetoothengine/btaudioman/data/10208970.rss
bluetoothengine/btaudioman/group/btaudioman.mmp
bluetoothengine/btaudioman/inc/BTAccClient.h
bluetoothengine/btaudioman/inc/BTAccClientSrv.h
bluetoothengine/btaudioman/inc/BTAccServer.h
bluetoothengine/btaudioman/inc/BTAccSession.h
bluetoothengine/btaudioman/inc/basrvaccman.h
bluetoothengine/btaudioman/inc/basrvaccstate.h
bluetoothengine/btaudioman/inc/btaccpanic.h
bluetoothengine/btaudioman/inc/btaudiomanplugin.h
bluetoothengine/btaudioman/inc/debug.h
bluetoothengine/btaudioman/inc/debugconfig.h
bluetoothengine/btaudioman/src/BTAccClient.cpp
bluetoothengine/btaudioman/src/BTAccServer.cpp
bluetoothengine/btaudioman/src/BTAccSession.cpp
bluetoothengine/btaudioman/src/BTAccSession_accfw_var.cpp
bluetoothengine/btaudioman/src/basrvacc.cpp
bluetoothengine/btaudioman/src/basrvaccman.cpp
bluetoothengine/btaudioman/src/basrvaccstate.cpp
bluetoothengine/btaudioman/src/basrvaccstateattach.cpp
bluetoothengine/btaudioman/src/basrvaccstateattached.cpp
bluetoothengine/btaudioman/src/basrvaccstateconnect.cpp
bluetoothengine/btaudioman/src/basrvaccstatedetach.cpp
bluetoothengine/btaudioman/src/basrvaccstatedisconnect.cpp
bluetoothengine/btaudioman/src/basrvaccstatequery.cpp
bluetoothengine/btaudioman/src/basrvsdpquery.cpp
bluetoothengine/btaudioman/src/btaudiomanplugin.cpp
bluetoothengine/bteng/btfeatures/btfeatures.cpp
bluetoothengine/bthid/mouse/Sesame_client/data/cursormask.bmp
bluetoothengine/btmac/BWINS/BTMonoCmdHandlerU.DEF
bluetoothengine/btmac/eabi/BTMonoCmdHandleru.DEF
bluetoothengine/btmac/inc/btmonocmdhandler/btmcnumber.h
bluetoothengine/btmac/src/BTMonoCmdHandler/btmcnumber.cpp
bluetoothengine/btmac/src/btmac/btmrfcommsock.cpp
bluetoothengine/btnotif/ecom/BtnotifWrapper.cpp
bluetoothengine/btnotif/inc/BTNGenericInfoNotifier.h
bluetoothengine/btnotif/inc/BTNGenericQueryNotifier.h
bluetoothengine/btnotif/inc/btnotifier.h
bluetoothengine/btnotif/inc/btnotifuiutil.h
bluetoothengine/btnotif/inc/btnpaireddevsettnotifier.h
bluetoothengine/btnotif/inc/btnpairnotifier.h
bluetoothengine/btnotif/inc/btnpinnotifier.h
bluetoothengine/btnotif/inc/btnssppasskeyentrynotifier.h
bluetoothengine/btnotif/inc/btnumcmpnotifier.h
bluetoothengine/btnotif/src/BTNAuthNotifier.cpp
bluetoothengine/btnotif/src/BTNGenericInfoNotifier.cpp
bluetoothengine/btnotif/src/BTNGenericQueryNotifier.cpp
bluetoothengine/btnotif/src/BTNInqUI.cpp
bluetoothengine/btnotif/src/BTNObexPinNotifier.cpp
bluetoothengine/btnotif/src/BTNPBAPPinNotifier.cpp
bluetoothengine/btnotif/src/BTNPinNotifier.cpp
bluetoothengine/btnotif/src/BTNotifier.cpp
bluetoothengine/btnotif/src/btnenterpriseitsecurityinfonotifier.cpp
bluetoothengine/btnotif/src/btnotifuiutil.cpp
bluetoothengine/btnotif/src/btnpaireddevsettnotifier.cpp
bluetoothengine/btnotif/src/btnpairnotifier.cpp
bluetoothengine/btnotif/src/btnssppasskeyentrynotifier.cpp
bluetoothengine/btnotif/src/btnumcmpnotifier.cpp
bluetoothengine/btui/Ecom/group/bld.inf
bluetoothengine/btui/Ecom/inc/bluetoothuiutil.h
bluetoothengine/btui/Ecom/inc/bluetoothuiutil.inl
bluetoothengine/btui/Ecom/src/BTUIBlockedDevicesView.cpp
bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp
bluetoothengine/btui/Ecom/src/BTUISap.cpp
bluetoothengine/btui/group/bld.inf
--- a/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/bulkbearer.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/bulkbearer.h	Fri Feb 19 22:59:18 2010 +0200
@@ -46,6 +46,7 @@
 	void MrcciNewCommand(CAvrcpCommand& aCommand,const TRemConClientId& aClientId);
 	
 	TUint MrcciNewTransactionId();
+    void MrcciCommandExpired(TUint aTransactionId);
 	
 	TInt MrcbciSetAddressedClient(const TRemConAddress& aAddr, const TRemConClientId& aClient);
 	void MrcbciRemoveAddressing(const TRemConAddress& aAddr);
--- a/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/controlbearer.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/controlbearer.h	Fri Feb 19 22:59:18 2010 +0200
@@ -59,6 +59,8 @@
 	void MrccciNewNotifyResponse(CControlCommand& aCommand);
 	
 	TUint MrcciNewTransactionId();
+    void MrcciCommandExpired(TUint aTransactionId);
+    
 	void MrccciSetAddressedClient(const TRemConClientId& aClient);
 
 private: // MRemConBearerInterfaceV3 functions called from RemCon
--- a/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/remconcommandinterface.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/remconcommandinterface.h	Fri Feb 19 22:59:18 2010 +0200
@@ -31,6 +31,7 @@
 	virtual void MrcciNewCommand(CAvrcpCommand& aCommand, const TRemConClientId& aClientId) = 0;
 
 	virtual TUint MrcciNewTransactionId() = 0;
+	virtual void MrcciCommandExpired(TUint aTransactionId) = 0;
 	};
 
 NONSHARABLE_CLASS(MRemConBulkCommandInterface) : public MRemConCommandInterface
--- a/bluetoothappprofiles/avrcp/remconbeareravrcp/src/bulkbearer.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/bulkbearer.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -201,6 +201,12 @@
 	return iObserver->NewTransactionId();
 	}
 
+void CAvrcpBulkBearer::MrcciCommandExpired(TUint aTransactionId)
+    {
+    LOG_FUNC
+    iObserver->CommandExpired(aTransactionId);
+    }
+
 TInt CAvrcpBulkBearer::MrcbciSetAddressedClient(const TRemConAddress& aAddr, const TRemConClientId& aClient)
 	{
 	LOG_FUNC
--- a/bluetoothappprofiles/avrcp/remconbeareravrcp/src/playerstatewatcher.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/playerstatewatcher.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -40,6 +40,9 @@
 	CInternalCommand* command = *iCommands.Find(aClientId);
 	__ASSERT_DEBUG(command, AVRCP_PANIC(ENotWatchingPlayer));
 
+	TUint transId = command->RemConCommandId();
+	iCommandInterface.MrcciCommandExpired(transId);
+
 	iCommands.Remove(aClientId);
 	command->DecrementUsers();
 	}
--- a/bluetoothappprofiles/avrcp/remconbeareravrcp/src/remconbeareravrcp.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/remconbeareravrcp.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -858,10 +858,15 @@
 	return Observer().NewTransactionId();
 	}
 
+void CRemConBearerAvrcp::MrcciCommandExpired(TUint aTransactionId)
+    {
+    LOG_FUNC
+    Observer().CommandExpired(aTransactionId);
+    }
+
 void CRemConBearerAvrcp::MrccciSetAddressedClient(const TRemConClientId& aClientId)
 	{
 	LOG_FUNC
-
 	Observer().SetRemoteAddressedClient(TUid::Uid(KRemConBearerAvrcpImplementationUid), aClientId);
 	}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btaudioman/btaccpanic.h	Fri Feb 19 22:59:18 2010 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declares authorisation notifier class.
+*
+*/
+
+#ifndef BTACCPANIC_H
+#define BTACCPANIC_H
+
+_LIT(KBtAccPanicName, "BtAcc Panic");
+
+enum TBtAccPanic
+    {
+    ENoShutdownTimer = 0,
+    };
+
+template <typename XAny>
+struct TBtAccPanicCodeTypeChecker
+    {
+    inline static void Check(XAny) { }
+    };
+
+#define BTACC_PANIC(CODE) \
+    TBtAccPanicCodeTypeChecker<TBtAccPanic>::Check(CODE), \
+    User::Panic(KBtAccPanicName, CODE)
+
+
+#endif // BTACCPANIC_H
+
+
--- a/bluetoothengine/btaudioman/data/10208970.rss	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/data/10208970.rss	Fri Feb 19 22:59:18 2010 +0200
@@ -37,7 +37,7 @@
                     {
                     implementation_uid = 0x1020897C;
                     version_no         = 1;
-                    display_name       = "0x1020897B";
+                    display_name       = "0x10208970";
                     default_data       = KACCESSORYPLUGINAPIMAINSERVICE;      
                     opaque_data        = "Heap=0x1000|Stack=0x1000";
                     rom_only           = 1;      
@@ -46,7 +46,7 @@
                     {
                     implementation_uid = 0x1020897D;
                     version_no         = 1;
-                    display_name       = "0x1020897B";
+                    display_name       = "0x10208970";
                     default_data       = KACCESSORYPLUGINAPIHANDLER;      
                     opaque_data        = "";
                     rom_only           = 1;
--- a/bluetoothengine/btaudioman/group/btaudioman.mmp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/group/btaudioman.mmp	Fri Feb 19 22:59:18 2010 +0200
@@ -49,8 +49,6 @@
 SOURCE        BTAccSession.cpp
 SOURCE		  basrvpowercontrolagent.cpp
 SOURCE        basrvrvc.cpp
-SOURCE        BTAccSession_accfw_var.cpp
-SOURCE        basrvaccman_accfw_var.cpp
 SOURCE        basrvaccfwconn.cpp
 
 USERINCLUDE     ../inc
--- a/bluetoothengine/btaudioman/inc/BTAccClient.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/inc/BTAccClient.h	Fri Feb 19 22:59:18 2010 +0200
@@ -93,34 +93,6 @@
     */
     void GetInfoOfConnectedAcc(TPckg<TAccInfo>& aInfoPckg, TRequestStatus& aStatus ); 
     
-
-    /**
-    * Transfer audio to phone
-    * @param    None
-    * @return   TInt indicating the success of call.      
-    */
-    TInt AudioToPhone();
-
-    /**
-    * Routes the audio paths from the phone to the accessory from which they
-    * have been earlier on moved to the phone with the audio to phone 
-    * operation. In practice also reconnects to the accessory.
-    * @param aStatus            When the request completes contains the 
-    *                           success status of the operation.
-    * @return                   None.
-    */
-    void AudioToAccessory( TRequestStatus& aStatus );
-
-    /**
-    * Cancels the audio to accessory operation.
-    * Note that if this request is made after the point when it is not 
-    * possible to cancel the actual operation any more, the audio paths 
-    * might still be routed to the accessory again.
-    * @param                    TRequestStatus status to be cancelled.
-    * @return                   None.
-    */
-    void CancelAudioToAccessory();
-    
 public: // Functions from base classes
 
     /**
--- a/bluetoothengine/btaudioman/inc/BTAccClientSrv.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/inc/BTAccClientSrv.h	Fri Feb 19 22:59:18 2010 +0200
@@ -47,9 +47,6 @@
     EBTAccSrvCancelNotifyConnectionStatus,
     EBTAccSrvConnectionStatus,
     EBTAccSrvGetInfoOfConnectedAcc,
-    EBTAccSrvAudioToPhone,
-    EBTAccSrvAudioToAccessory,
-    EBTAccSrvCancelAudioToAccessory,
     EBTAccSrvInvalidIpc,
     };
 
--- a/bluetoothengine/btaudioman/inc/BTAccServer.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/inc/BTAccServer.h	Fri Feb 19 22:59:18 2010 +0200
@@ -49,7 +49,7 @@
     
     void StartShutdownTimerIfNoSessions();
     
-    void ClientOpened(CBTAccSession& aSession);
+    void ClientOpenedL(CBTAccSession& aSession);
         
     void ClientClosed(CBTAccSession& aSession);
         
--- a/bluetoothengine/btaudioman/inc/BTAccSession.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/inc/BTAccSession.h	Fri Feb 19 22:59:18 2010 +0200
@@ -58,13 +58,6 @@
 
     void NotifyClientNewProfile(TInt aProfile, const TBTDevAddr& aAddr);
     void NotifyClientNoProfile(TInt aProfile, const TBTDevAddr& aAddr);
-
-    // For DosServer version only
-    void AudioToPhone(const RMessage2& aMessage);
-    void AudioToAccessory(const RMessage2& aMessage);
-    void CancelAudioToAccessory();
-    void AudioToPhoneComplete();
-    void AudioToAccessoryComplete(TInt aErr);
         
 private:
     /**
@@ -114,10 +107,6 @@
     */
     CBTAccSession(CBasrvAccMan& aAccMan);
 
-    void HandleAudio4DosRequest(const RMessage2 &aMessage);
-
-    void DestructVariant();
-
     void UpdateProfileStatusCache(const TProfileStatus& aStatus);
 
 private:    // Data
--- a/bluetoothengine/btaudioman/inc/basrvaccman.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/inc/basrvaccman.h	Fri Feb 19 22:59:18 2010 +0200
@@ -16,7 +16,7 @@
 *  Name        : basrvaccman.h
 *  Part of     : BTEng / Bluetooth Accessory Server
 *  Description : 
-*  Version     : %version: 3.1.4.1.2.2.11 %
+*  Version     : %version: 3.1.4.1.2.2.13 %
 *
 */
 
@@ -100,10 +100,6 @@
 
     TBTEngConnectionStatus ConnectionStatus4Client(const TBTDevAddr& aAddr) const;
 
-    // For DosServer version only
-    void AudioToPhone(CBasrvAudio4Dos& aAudio4Dos);
-    void AudioToAccessory(CBasrvAudio4Dos& aAudio4Dos);
-
     TBool IsAvrcpVolCTSupported();
     TBool IsAbsoluteVolumeSupported(const TBTDevAddr& aAddr);
     TBool DisconnectIfAudioOpenFails();
@@ -153,6 +149,9 @@
      */
     void CancelRequest(CBasrvActive& aActive);
 
+private:
+    void DoShowNoteL(TBTGenericInfoNoteType aNote, const TBTDevAddr& aAddr);
+    
 protected:
     /**
     * Default constructor
@@ -164,8 +163,6 @@
     void HandleNewAudioRequestL();
 
     void DoAudioRequestL();
-    
-    void DestructVariant();
 
     TInt FindAcc(const TBTDevAddr& aRemote) const;
 
--- a/bluetoothengine/btaudioman/inc/basrvaccstate.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/inc/basrvaccstate.h	Fri Feb 19 22:59:18 2010 +0200
@@ -132,7 +132,7 @@
     /**
     * Default constructor
     */
-    CBasrvAccState(CBasrvAcc& aParent, TRequestStatus* aRequest);
+    CBasrvAccState(CBasrvAcc& aParent);
     
     /**
      * Gets the owner of the state machine
@@ -142,24 +142,6 @@
      */
     CBasrvAcc& Parent();
     
-    /**
-     * Completes the pending request in this state with specified error code 
-     * and then zero the pointer.
-     *
-     * @since S60 v3.1
-     * @param aErr the completion error code
-     */
-    void CompleteStateRequest(TInt aErr);
-    
-    /**
-     * Completes the give pending request with specified error code..
-     *
-     * @since S60 v3.1
-     * @param aRequest the request to be completed
-     * @param aErr the completion error code
-     */
-    void CompleteRequest(TRequestStatus* aRequest, TInt aErr);
-
     void StatePrint(const TDesC& aStateName);
 
     TAccInfo& AccInfo();
@@ -173,12 +155,6 @@
 protected:
 
     CBasrvAcc& iParent;
-
-    /**
-     * Possible to be NULL.
-     * The async request performed in this state if it is not NULL.
-     */
-    TRequestStatus* iRequest;
     };
 
 #endif      // C_BTASRVACCSTATE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btaudioman/inc/btaccpanic.h	Fri Feb 19 22:59:18 2010 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declares authorisation notifier class.
+*
+*/
+
+#ifndef BTACCPANIC_H
+#define BTACCPANIC_H
+
+_LIT(KBtAccPanicName, "BtAcc Panic");
+
+enum TBtAccPanic
+    {
+    ENoShutdownTimer = 0,
+    EMaxNumberOfConflictsExceeded = 1,
+    };
+
+template <typename XAny>
+struct TBtAccPanicCodeTypeChecker
+    {
+    inline static void Check(XAny) { }
+    };
+
+#define BTACC_PANIC(CODE) \
+    TBtAccPanicCodeTypeChecker<TBtAccPanic>::Check(CODE), \
+    User::Panic(KBtAccPanicName, CODE)
+
+
+#endif // BTACCPANIC_H
+
--- a/bluetoothengine/btaudioman/inc/btaudiomanplugin.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/inc/btaudiomanplugin.h	Fri Feb 19 22:59:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -171,7 +171,10 @@
 
     void ConstructL();
 
-    TInt HandleAsyncRequest(const TBTDevAddr& aAddr, TInt aRequestId);
+    TInt PrepareAsyncRequest(const TBTDevAddr& aAddr, TInt aRequestId);
+
+    void NotifyConnectionStatus();
+    TInt ReconnectIfNeccessary();
 
     void ReportProfileConnectionEvents(const TBTDevAddr& aAddr, const TInt aProfiles, TBool aConnected);
 
@@ -187,6 +190,7 @@
     CBasrvActive* iActive4ProfileStatus;
     TProfileStatus iProfileStatus;
     TProfileStatusPckg iProfileStatusPckg;
+    TInt iNotifyConnectionStatusFailure;
     };
 
 
--- a/bluetoothengine/btaudioman/inc/debug.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/inc/debug.h	Fri Feb 19 22:59:18 2010 +0200
@@ -22,6 +22,11 @@
 #include <e32base.h>
 #include "debugconfig.h"
 
+enum TPanic
+	{
+	EInvalidNullState = 1,
+	};
+
 #ifdef PRJ_ENABLE_TRACE
 
 #ifdef PRJ_FILE_TRACE
--- a/bluetoothengine/btaudioman/inc/debugconfig.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/inc/debugconfig.h	Fri Feb 19 22:59:18 2010 +0200
@@ -38,11 +38,12 @@
 _LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]");
 _LIT8(KFuncExitFormat8, "<%S");
 
-_LIT(KPanicCategory, "BTAccServer");    
 _LIT8(KPanicPrefix8, "PANIC code ");
 _LIT8(KLeavePrefix8, "LEAVE code ");
 #endif
 
+_LIT(KPanicCategory, "BTAccServer");	// need it also for release 
+
 const TInt KMaxLogLineLength = 512;
 
 #define KPRINTERROR        0x00000001 // Tracing level: error
--- a/bluetoothengine/btaudioman/src/BTAccClient.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/src/BTAccClient.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -164,32 +164,5 @@
     SendReceive(EBTAccSrvGetInfoOfConnectedAcc, TIpcArgs(&aInfoPckg),  aStatus);
     }
 
-// ---------------------------------------------------------
-// AudioToPhone
-// Dos Related functionality only. 
-// ---------------------------------------------------------
-//
-TInt RBTAccClient::AudioToPhone()
-    {
-    TRACE_FUNC
-    return SendReceive(EBTAccSrvAudioToPhone);
-    }
-
-// ---------------------------------------------------------
-// AudioToAccessory
-// Dos Related functionality only.
-// ---------------------------------------------------------
-//
-void RBTAccClient::AudioToAccessory( TRequestStatus& aStatus )
-    {
-    TRACE_FUNC
-    SendReceive(EBTAccSrvAudioToAccessory, aStatus);
-    }
-
-void RBTAccClient::CancelAudioToAccessory()
-    {
-    SendReceive(EBTAccSrvCancelAudioToAccessory);
-    }
-
     
 // End of File
--- a/bluetoothengine/btaudioman/src/BTAccServer.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/src/BTAccServer.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -30,6 +30,7 @@
 #include "btmanclient.h"         // TBTDevAddrPckgBug
 #include "basrvaccman.h"
 #include "BTAccInfo.h"
+#include "btaccpanic.h"
 
 /**  PubSub key read and write policies */
 _LIT_SECURITY_POLICY_C1( KBTEngPSKeyReadPolicy, 
@@ -78,33 +79,25 @@
     }
 
 void CBTAccServer::StartShutdownTimerIfNoSessions()
-	{
-	if (iSessions.Count() == 0 && (!iTimer || !iTimer->IsActive()))
-		{
-		if (!iTimer)
-		    {
-		    TRAP_IGNORE(iTimer = CPeriodic::NewL(CActive::EPriorityStandard));
-		    }
-		
-		if (iTimer)
-		    {
-		    iTimer->Start(KShutdownDelay, 0, TCallBack(CBTAccServer::TimerFired, this));
-		    }
-		
-	    TRACE_FUNC	
-		}
-	}
+    {
+    TRACE_FUNC	
+    __ASSERT_DEBUG(iTimer, BTACC_PANIC(ENoShutdownTimer));
+    if (iSessions.Count() == 0 && !iTimer->IsActive())
+        {
+        iTimer->Start(KShutdownDelay, 0, TCallBack(CBTAccServer::TimerFired, this));
+        }
+    }
 
-void CBTAccServer::ClientOpened(CBTAccSession& aSession)
-	{
-	TRACE_FUNC
-	
-	//cancel the timer to prevent the server from shutting down
+void CBTAccServer::ClientOpenedL(CBTAccSession& aSession)
+    {
+    TRACE_FUNC
+
+    //add the session to the array of sessions
+    iSessions.AppendL(&aSession);
+
+    //cancel the timer to prevent the server from shutting down
     CancelShutdownTimer();
-	
-	//add the session to the array of sessions
-	(void)iSessions.Append(&aSession);
-	}
+    }
 
 void CBTAccServer::ClientClosed(CBTAccSession& aSession)
 	{
@@ -148,8 +141,9 @@
 void CBTAccServer::ConstructL()
     {
     iAccMan = CBasrvAccMan::NewL();
-    iAccMan->LoadServicesL();
-    
+
+    iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+
     User::LeaveIfError(RProperty::Define(KPSUidBluetoothEnginePrivateCategory,
                                          KBTHfpATCommand, RProperty::EByteArray,
                                          KBTEngPSKeyReadPolicy,
@@ -162,8 +156,7 @@
 
 void CBTAccServer::CancelShutdownTimer()
     {
-    delete iTimer;
-    iTimer = NULL;
+    iTimer->Cancel();
     }
 
 TInt CBTAccServer::TimerFired(TAny* /*aThis*/)
--- a/bluetoothengine/btaudioman/src/BTAccSession.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/src/BTAccSession.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -27,6 +27,7 @@
 #include "BTAccServer.h"
 #include "basrvaccman.h"
 #include "BTAccInfo.h"
+#include "btaccpanic.h"
 
 typedef TPckgBuf<TBTDevAddr> TBTDevAddrPckgBuf;
 
@@ -64,7 +65,6 @@
         iNotifyProfileMsg.Complete(KErrAbort);
         }
     iProfileStatusCache.Close();
-    DestructVariant();
     
     //clear the accessory managers pointer to this session if it has one
     iAccMan.ClearProfileNotifySession(*this);
@@ -78,7 +78,7 @@
     TRACE_FUNC
     //use CreateL instead of NewSessionL when using Server() to ensure the
     //session has been created correctly and Server() returns a valid pointer
-    Server().ClientOpened(*this);
+    Server().ClientOpenedL(*this);
     }
 
 void CBTAccSession::ConnectCompleted(TInt aErr, TInt aProfile, const RArray<TBTDevAddr>* aConflicts)
@@ -89,10 +89,24 @@
         TRACE_INFO((_L("CBTAccSession::ConnectCompleted err %d"), aErr))
         if (aConflicts)
             {
-            TBuf8<KBTDevAddrSize * 2> buf;
+            if (aErr == KErrNone)
+                {
+                //we need to error so the client knows there are conflicts which need handling
+                aErr = KErrGeneral; 
+                }
+            
+            const TInt KMaxNumberOfConflicts = 2;
+            
+            TBuf8<KBTDevAddrSize * KMaxNumberOfConflicts> buf;
             TInt count = aConflicts->Count();
+            __ASSERT_DEBUG(count <= KMaxNumberOfConflicts, BTACC_PANIC(EMaxNumberOfConflictsExceeded));
+            
             for (TInt i = 0; i < count; i++)
                 {
+                if(i >= KMaxNumberOfConflicts)
+                    {
+                    break; //prevent descriptor overflow
+                    }
                 buf.Append((*aConflicts)[i].Des());
                 }
             
@@ -101,10 +115,10 @@
                 iConnectMsg.Write(1, buf);
                 }
             }
-        else if (!aErr)
+        else if (aErr == KErrNone)
             {
             TPckgBuf<TInt> buf(aProfile);
-            iConnectMsg.Write(1, buf);
+            aErr = iConnectMsg.Write(1, buf);
             }
         iConnectMsg.Complete(aErr);
         }
@@ -116,10 +130,10 @@
     if (iDisconnectMsg.Handle())
         {
         TRACE_FUNC
-        if (!aErr)
+        if (aErr == KErrNone)
             {
             TPckgBuf<TInt> buf(aProfile);
-            iDisconnectMsg.Write(1, buf);
+            aErr = iDisconnectMsg.Write(1, buf);
             }
         iDisconnectMsg.Complete(aErr);
         }
@@ -451,13 +465,6 @@
             GetInfoOfConnectedAcc(aMessage);
             break;
             }
-        case EBTAccSrvAudioToPhone:
-        case EBTAccSrvAudioToAccessory:
-        case EBTAccSrvCancelAudioToAccessory:
-            {
-            HandleAudio4DosRequest(aMessage);
-            break;
-            }
         default:
             {
             PanicClient(aMessage, EBTAccBadRequest);
--- a/bluetoothengine/btaudioman/src/BTAccSession_accfw_var.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
-* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Variants for Dos Server version
-* 
-*
-*/
-
-
-// INCLUDE FILES
-#include "BTAccSession.h"
-#include "debug.h"
-
-void CBTAccSession::HandleAudio4DosRequest(const RMessage2 &aMessage)
-    {
-    aMessage.Complete(KErrNotSupported);
-    }
-
-void CBTAccSession::DestructVariant()
-    {
-    }
-
-// End of File
--- a/bluetoothengine/btaudioman/src/basrvacc.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/src/basrvacc.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -107,30 +107,35 @@
 void CBasrvAcc::AccOpenedAudio(TProfiles aProfile)
     {
     TRACE_FUNC
+    __ASSERT_ALWAYS(iState, User::Panic(KPanicCategory, EInvalidNullState));
     iState->AccOpenedAudio(aProfile);
     }
 
 void CBasrvAcc::AccClosedAudio(TProfiles aProfile)
     {
     TRACE_FUNC
+    __ASSERT_ALWAYS(iState, User::Panic(KPanicCategory, EInvalidNullState));
     iState->AccClosedAudio(aProfile);
     }
     
 void CBasrvAcc::AccessoryDisconnectedL(TProfiles aProfile)
     {
     TRACE_FUNC
+    __ASSERT_ALWAYS(iState, User::Panic(KPanicCategory, EInvalidNullState));
     iState->AccessoryDisconnectedL(aProfile);
     }
 
 void CBasrvAcc::OpenAudioL(TAccAudioType aType)
     {
     TRACE_FUNC
+    __ASSERT_ALWAYS(iState, User::Panic(KPanicCategory, EInvalidNullState));
     iState->OpenAudioL(aType);
     }
 
 void CBasrvAcc::CloseAudioL(TAccAudioType aType)
     {
     TRACE_FUNC
+    __ASSERT_ALWAYS(iState, User::Panic(KPanicCategory, EInvalidNullState));
     iState->CloseAudioL(aType);
     }
 
--- a/bluetoothengine/btaudioman/src/basrvaccman.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/src/basrvaccman.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -12,13 +12,14 @@
 * Contributors:
 *
 * Description:  Implementation of an accessory management.
-*  Version     : %version:  14.1.8 %
+*  Version     : %version:  14.1.10 %
 *
 */
 
 
 // INCLUDE FILES
 #include <centralrepository.h>
+#include <btengdomaincrkeys.h>
 #include "basrvaccman.h"
 #include "BTAccSession.h"
 #include "BTAccClientSrv.h"
@@ -44,6 +45,28 @@
     return self;
     }
 
+void CBasrvAccMan::ConstructL()
+    {
+    iAsyncHandlingActive = 
+        CBasrvActive::NewL(*this, CActive::EPriorityStandard, KAsyncHandlingRequest);
+    
+    CRepository* cenrep = NULL;
+    TRAP_IGNORE(cenrep = CRepository::NewL(KCRUidBluetoothEngine));
+    TInt avrcpVol = EBTAvrcpVolCTNotSupported;
+    TInt autoDisconnect = EBTDisconnectIfAudioOpenFails;
+    if (cenrep)
+        {
+        cenrep->Get(KBTAvrcpVolCTLV, avrcpVol);
+        cenrep->Get(KBTDisconnectIfAudioOpenFailsLV, autoDisconnect);
+        delete cenrep;
+        }
+    iAvrcpVolCTSupported = (avrcpVol == EBTAvrcpVolCTSupported);
+    iDisconnectIfAudioOpenFails = (autoDisconnect == EBTDisconnectIfAudioOpenFails);
+    TRACE_INFO((_L("[AVRCP_Vol_CT] %d [DisconnectIfAudioOpenFails] %d"), 
+        iAvrcpVolCTSupported, iDisconnectIfAudioOpenFails))
+    LoadServicesL();
+    }
+
 CBasrvAccMan::~CBasrvAccMan()
     {
     delete iOpenListener;
@@ -77,7 +100,6 @@
     iNotifierArray.ResetAndDestroy();
     iNotifierArray.Close();
     iClientRequests.Close();
-    DestructVariant();
     TRACE_FUNC    
     }
 
@@ -152,7 +174,14 @@
         request.iRequest = EBTAccSrvDisconnectAccessory;
         request.iAddr = aAddr;
         iClientRequests.AppendL(request);
+        
+        //remove the last item from the RArray if a leave occurs later
+        TCleanupItem cleanupItem(CleanupLastItemFromClientRequestsArray, &iClientRequests);
+        CleanupStack::PushL(cleanupItem);
+        
         iAccs[idx]->DisconnectL();
+        
+        CleanupStack::Pop(&iClientRequests);
         }
     else
         {
@@ -416,14 +445,23 @@
 void CBasrvAccMan::ShowNote(TBTGenericInfoNoteType aNote, const TBTDevAddr& aAddr)
     {
     TRACE_INFO((_L("CBasrvAccMan::ShowNote %d"), aNote))
-    TRAPD(err, iNotifierArray.Append(CBasrvActiveNotifier::NewL(*this, CActive::EPriorityStandard, KShowNoteRequest, aAddr, aNote)));
-    if (err)
+    TRAPD(err, DoShowNoteL(aNote, aAddr));
+    if (err != KErrNone)
         {
         TRACE_ERROR((_L("could not construct active notifer object")))
         return;
         }
     }
 
+void CBasrvAccMan::DoShowNoteL(TBTGenericInfoNoteType aNote, const TBTDevAddr& aAddr)
+    {
+    CBasrvActiveNotifier* activeNotifier = CBasrvActiveNotifier::NewL(*this, CActive::EPriorityStandard, KShowNoteRequest, aAddr, aNote);
+    
+    CleanupStack::PushL(activeNotifier);
+    iNotifierArray.AppendL(activeNotifier);
+    CleanupStack::Pop(activeNotifier);
+    }
+
 void CBasrvAccMan::FilterProfileSupport(TAccInfo& aInfo)
     {
     TInt pluginbit = iPluginMan->AvailablePlugins();
@@ -729,8 +767,6 @@
         case KAsyncHandlingRequest:
             {
             DoAudioRequestL();
-            delete iAsyncHandlingActive;
-            iAsyncHandlingActive = NULL;
             break;
             }
         default:
@@ -760,7 +796,7 @@
 void CBasrvAccMan::DoAudioRequestL()
     {
     TRACE_FUNC
-    if (iAudioRequests.Count() && !iAudioRequests[0].iOngoing && (!iAsyncHandlingActive || !iAsyncHandlingActive->IsActive()))
+    if (iAudioRequests.Count() && !iAudioRequests[0].iOngoing && !iAsyncHandlingActive->IsActive())
         {
         iAudioRequests[0].iOngoing = ETrue;
         TInt err = KErrNotFound;
@@ -827,7 +863,7 @@
     req.iReqType = ERejectAudioOpenedByAcc;
     req.iOngoing = EFalse;
     TInt idx = 0;
-    if (iAudioRequests.Count() && iAudioRequests[0].iOngoing)
+    if (iAudioRequests.Count() && iAudioRequests[0].iOngoing && !iAsyncHandlingActive->IsActive())
         {
         idx = 1;
         }
@@ -839,18 +875,12 @@
         Trace(_L("[Audio Request buf] 2(Reject) %d at '%S', to index %d"), iCloseType, &buf, idx);
         });
 
-    if (!err && !iAsyncHandlingActive && !iAudioRequests[0].iOngoing)
+    if ((err == KErrNone) && !iAudioRequests[0].iOngoing)
         {
-        // Start rejection asynchronously
-        iAsyncHandlingActive = 
-            CBasrvActive::New(*this, CActive::EPriorityStandard, KAsyncHandlingRequest);
-        if (iAsyncHandlingActive)
-            {
-            iAsyncHandlingActive->iStatus = KRequestPending;
-            TRequestStatus* sta = &(iAsyncHandlingActive->iStatus);
-            User::RequestComplete(sta, KErrNone);
-            iAsyncHandlingActive->GoActive();
-            }
+        iAsyncHandlingActive->iStatus = KRequestPending;
+        TRequestStatus* sta = &(iAsyncHandlingActive->iStatus);
+        User::RequestComplete(sta, KErrNone);
+        iAsyncHandlingActive->GoActive();
         }
     }
 
--- a/bluetoothengine/btaudioman/src/basrvaccstate.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/src/basrvaccstate.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -27,7 +27,6 @@
 
 CBasrvAccState::~CBasrvAccState()
     {
-    CompleteStateRequest(KErrAbort);
     }
     
 CBasrvAccState* CBasrvAccState::ErrorOnEntry(TInt /*aReason*/)
@@ -102,8 +101,8 @@
     TRACE_FUNC
     }
 
-CBasrvAccState::CBasrvAccState(CBasrvAcc& aParent, TRequestStatus* aRequest)
-    : iParent(aParent), iRequest(aRequest)
+CBasrvAccState::CBasrvAccState(CBasrvAcc& aParent)
+    : iParent(aParent)
     {
     }
 
@@ -112,25 +111,6 @@
     return iParent;
     }
 
-void CBasrvAccState::CompleteStateRequest(TInt aErr)
-    {
-    if (iRequest)
-        {
-        User::RequestComplete(iRequest, aErr);
-        TRACE_INFO((_L("Request 0x%08X completed with %d"), iRequest, aErr))
-        iRequest = NULL;
-        }
-    }
-    
-void CBasrvAccState::CompleteRequest(TRequestStatus* aStatus, TInt aErr)
-    {
-    if (aStatus)
-        {
-        User::RequestComplete(aStatus, aErr);
-        TRACE_INFO((_L("Request 0x%08X completed with %d"), aStatus, aErr))
-        }
-    }
-
 void CBasrvAccState::StatePrint(const TDesC& aStateName)
     {
     TRACE_INFO_SEG(
--- a/bluetoothengine/btaudioman/src/basrvaccstateattach.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/src/basrvaccstateattach.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -126,7 +126,7 @@
     }
 
 CBasrvAccStateAttach::CBasrvAccStateAttach(CBasrvAcc& aParent, TBool aConnecting)
-    : CBasrvAccState(aParent, NULL), iConnecting(aConnecting)
+    : CBasrvAccState(aParent), iConnecting(aConnecting)
     {
     }
  
--- a/bluetoothengine/btaudioman/src/basrvaccstateattached.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/src/basrvaccstateattached.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -12,7 +12,7 @@
 * Contributors:
 *
 * Description:  Implementation of Connected state.
-*  Version     : %version: 20 %
+*  Version     : %version: 21 %
 *
 */
 
@@ -385,7 +385,7 @@
     }
 
 CBasrvAccStateAttached::CBasrvAccStateAttached(CBasrvAcc& aParent, TBool aShowNote)
-    : CBasrvAccState(aParent, NULL), iShowNote(aShowNote)
+    : CBasrvAccState(aParent), iShowNote(aShowNote)
     {
     }
 
--- a/bluetoothengine/btaudioman/src/basrvaccstateconnect.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/src/basrvaccstateconnect.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -105,7 +105,7 @@
     }
 
 CBasrvAccStateConnect::CBasrvAccStateConnect(CBasrvAcc& aParent)
-    : CBasrvAccState(aParent, NULL)
+    : CBasrvAccState(aParent)
     {
     }
     
--- a/bluetoothengine/btaudioman/src/basrvaccstatedetach.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/src/basrvaccstatedetach.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -112,7 +112,7 @@
     }
 
 CBasrvAccStateDetach::CBasrvAccStateDetach(CBasrvAcc& aParent)
-    : CBasrvAccState(aParent, NULL)
+    : CBasrvAccState(aParent)
     {
     }
  
--- a/bluetoothengine/btaudioman/src/basrvaccstatedisconnect.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/src/basrvaccstatedisconnect.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -81,7 +81,7 @@
     }
 
 CBasrvAccStateDisconnect::CBasrvAccStateDisconnect(CBasrvAcc& aParent, TInt aConnErr)
-    : CBasrvAccState(aParent, NULL), iConnErr(aConnErr)
+    : CBasrvAccState(aParent), iConnErr(aConnErr)
     {
     }
  
--- a/bluetoothengine/btaudioman/src/basrvaccstatequery.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/src/basrvaccstatequery.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -192,7 +192,7 @@
     }
 
 CBasrvAccStateQuery::CBasrvAccStateQuery(CBasrvAcc& aParent, TBool aConnectingRequest)
-    : CBasrvAccState(aParent, NULL), iConnecting(aConnectingRequest)
+    : CBasrvAccState(aParent), iConnecting(aConnectingRequest)
     {
     }
 
--- a/bluetoothengine/btaudioman/src/basrvsdpquery.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/src/basrvsdpquery.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -67,23 +67,23 @@
     SF.iAttrValue = 0;
     SF.iUUID = KAudioSinkUUID;  
     SF.iAttrID = KSdpAttrIdSupportedFeatures;        
-    iServiceAttrs.Append(SF); // Advanced Audio Distribution Profile - BT Stereo Audio
+    iServiceAttrs.AppendL(SF); // Advanced Audio Distribution Profile - BT Stereo Audio
     
     SF.iUUID = 0x111e;   // HFP
     SF.iAttrID = KSdpAttrIdSupportedFeatures;
-    iServiceAttrs.Append(SF); // BT Handsfree Profile - BT Mono Audio
+    iServiceAttrs.AppendL(SF); // BT Handsfree Profile - BT Mono Audio
     
     SF.iUUID = 0x1108;   // HSP
     SF.iAttrID = 0x0302;  // Atti id of remote volume control
-    iServiceAttrs.Append(SF); // BT Headset Profile - BT Mono Audio 
+    iServiceAttrs.AppendL(SF); // BT Headset Profile - BT Mono Audio 
 
     SF.iUUID = KAVRemoteControlTargetUUID;
     SF.iAttrID = KSdpAttrIdSupportedFeatures;
-    iServiceAttrs.Append(SF);  // Audio Video Remote Control Profile
+    iServiceAttrs.AppendL(SF);  // Audio Video Remote Control Profile
     
     SF.iUUID = KAVRemoteControlTargetUUID;
     SF.iAttrID = KSdpAttrIdBluetoothProfileDescriptorList;
-    iServiceAttrs.Append(SF);  // Audio Video Remote Control Profile, to find out avrcp 1.4 support    
+    iServiceAttrs.AppendL(SF);  // Audio Video Remote Control Profile, to find out avrcp 1.4 support    
 
     
     /*****************************************************
@@ -100,7 +100,7 @@
     TUUID serviceUuid = TUUID((0x00005555),(0x00001000),(0x80000002),(0xEE000001)); // model number
     SF.iUUID = serviceUuid;  
     SF.iAttrID = 0x0300; // Attri id of device model number
-    iServiceAttrs.Append(SF); 
+    iServiceAttrs.AppendL(SF); 
     iCursor = 0;
     iTolerateSdpError = aTolerateSdpError;
     iSdpAgent = CSdpAgent::NewL(*this, iAddr);
@@ -134,13 +134,19 @@
         {
         case ECreateView:
             {
+            // if we're called with iResponse != NULL we're leaking memory.
+            __ASSERT_ALWAYS(!iResponse, User::Invariant());
+            
             iResponse = NULL;
             if (aActive.iStatus > KErrNone)
                 {
-    		    iResponse = CBTRegistryResponse::NewL(iReg);	
-    		    aActive.SetRequestId(EGetResponse);    
-    		    iResponse->Start(aActive.iStatus);
-        	    aActive.GoActive();
+                TRAP_IGNORE( iResponse = CBTRegistryResponse::NewL(iReg) ); 
+                if (iResponse)
+                    {
+                    aActive.SetRequestId(EGetResponse);    
+                    iResponse->Start(aActive.iStatus);
+                    aActive.GoActive();
+                    }
                 }
             else
                 {
@@ -172,15 +178,21 @@
 void CBasrvSdpQuery::QueryCompleteL(TInt aErr)
     {
     iSdpAgent->Cancel();
+
     delete iSdpAgent;
     iSdpAgent = NULL;
+
     delete iSdpSearchPattern;
     iSdpSearchPattern = NULL;
+
     TBTDeviceClass cod = TBTDeviceClass();
 	if ( iResponse && iResponse->Results().Count() > 0 )
     	{
     	cod = (iResponse->Results())[0]->DeviceClass();
     	}
+	delete iResponse;
+	iResponse = NULL;
+	
     if (!aErr)
         {
         TAccInfo info;
--- a/bluetoothengine/btaudioman/src/btaudiomanplugin.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btaudioman/src/btaudiomanplugin.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -70,23 +70,27 @@
 TInt CBtAudioManPlugin::Connect( const TBTDevAddr& aAddr )
     {
     TRACE_FUNC
-    return HandleAsyncRequest(aAddr, ERequestConnect);    
+    TInt err = PrepareAsyncRequest(aAddr, ERequestConnect);
+    if(!err)
+        {
+        iDiagnostic.Zero();
+        iClient.ConnectToAccessory(iActive4ClientReq->iStatus, iBTDevAddrPckgBuf, iDiagnostic);
+        iActive4ClientReq->GoActive();
+        }
+    return err;
     }
 
 void CBtAudioManPlugin::CancelConnect( const TBTDevAddr& aAddr )
     {
     if (iBTDevAddrPckgBuf() == aAddr &&
-        iActive4ClientReq &&
         iActive4ClientReq->IsActive() &&
         iActive4ClientReq->RequestId() == ERequestConnect )
         {
         TRACE_INFO(_L("CBtAudioManPlugin::CancelConnect KErrCancel"))
-        delete iActive4ClientReq;
-        iActive4ClientReq = NULL;
+        iActive4ClientReq->Cancel();
         if (iObserver)
             {
-            iObserver->ConnectComplete(iBTDevAddrPckgBuf(), 
-                EBTProfileHFP, KErrCancel);
+            iObserver->ConnectComplete(aAddr, EBTProfileHFP, KErrCancel);
             }
         }
     else
@@ -94,8 +98,7 @@
         TRACE_INFO(_L("CBtAudioManPlugin::CancelConnect KErrNotFound"))
         if (iObserver)
             {
-            iObserver->ConnectComplete(aAddr , 
-                EBTProfileHFP, KErrNotFound);
+            iObserver->ConnectComplete(aAddr, EBTProfileHFP, KErrNotFound);
             }
         }
 
@@ -107,8 +110,21 @@
     if (aAddr == TBTDevAddr())
         {
         req = ERequestDisconnectAll;
-        }    
-    return HandleAsyncRequest(aAddr, req);
+        }
+    TInt err = PrepareAsyncRequest(aAddr, req);
+    if (!err)
+        {
+        if (req == ERequestDisconnect)
+            {
+            iClient.DisconnectAccessory(iActive4ClientReq->iStatus, iBTDevAddrPckgBuf, iDiagnostic);
+            }
+        else // if (req == ERequestDisconnectAll)
+            {
+            iClient.DisconnectAllGracefully(iActive4ClientReq->iStatus);
+            }
+        iActive4ClientReq->GoActive();
+        }
+    return err;
     }
 
 void CBtAudioManPlugin::GetConnections( RBTDevAddrArray& aAddrArray, TBTProfile aConnectedProfile )
@@ -207,22 +223,45 @@
 void CBtAudioManPlugin::RequestCompletedL(CBasrvActive& aActive)
     {
     TRACE_FUNC
+    TInt result = aActive.iStatus.Int();
     switch (aActive.RequestId())
         {
         case ENotifyProfileStatusChange:
             {
-            if (aActive.iStatus == KErrNone && iObserver)
+            // Notify any observer if one is present, and we got valid data (i.e. no error)
+            if (result == KErrNone && iObserver)
+                {
+                ReportProfileConnectionEvents(iProfileStatus.iAddr, iProfileStatus.iProfiles, iProfileStatus.iConnected);
+                }
+            // Handle resubscribing for future notifications
+            static const TInt KMaxFailedNotifyConnectionStatusAttempts = 3;
+            if (result == KErrNone)
+                {
+                iNotifyConnectionStatusFailure = 0; // reset failure count
+                NotifyConnectionStatus();
+                }
+            else if (result != KErrServerTerminated && iNotifyConnectionStatusFailure < KMaxFailedNotifyConnectionStatusAttempts)
                 {
-                ReportProfileConnectionEvents(iProfileStatus.iAddr, iProfileStatus.iProfiles,
-                    iProfileStatus.iConnected);
-                iClient.NotifyConnectionStatus(iProfileStatusPckg, aActive.iStatus);
-                aActive.GoActive();
+                TRACE_ERROR((_L8("Connection Status Notification failed (transiently): %d"), result))
+                ++iNotifyConnectionStatusFailure;
+                NotifyConnectionStatus();
+                }
+            else
+                {
+                // The server has died unexpectedly, or we've failed a number of times in succession so we cannot re-subscribe. 
+                // The lack of state here makes it diffcult to know how to report (handle?) this.  However, we are in
+                // no worse situation than before, plus the issue is now logged.
+                TRACE_ERROR((_L8("Connection Status Notification failed (terminally): %d"), result))
+                iClient.Close(); // clean the handle, this might kill outstanding disconnect/connect requests
+                                 // but it looks like the server is hosed anyway...
+                // In keeping with the existing logic we don't attempt to re-start the server.  That will only happen when an
+                // active request is made.
                 }
             break;
             }
         case ERequestConnect:
             {
-            if (iActive4ClientReq->iStatus.Int() != KErrNone) // might have conflicts, decode iDiagnostic
+            if (result != KErrNone) // might have conflicts, decode iDiagnostic
                 {
                 if (iDiagnostic.Length() >= KBTDevAddrSize)
                     {
@@ -238,14 +277,12 @@
                         TRACE_INFO((_L8("conflict <%S>"), &myPtr))
                         ptr.Set(ptr.Mid(KBTDevAddrSize));
                         }
-                    iObserver->ConnectComplete(iBTDevAddrPckgBuf(), 
-                        EBTProfileHFP, iActive4ClientReq->iStatus.Int(), &array);
+                    iObserver->ConnectComplete(iBTDevAddrPckgBuf(), EBTProfileHFP, result, &array);
                     CleanupStack::PopAndDestroy(&array);
                     }
                 else
                     {
-                    iObserver->ConnectComplete(iBTDevAddrPckgBuf(), 
-                        EBTProfileHFP, iActive4ClientReq->iStatus.Int());
+                    iObserver->ConnectComplete(iBTDevAddrPckgBuf(), EBTProfileHFP, result);
                     }
                 }
             else
@@ -258,16 +295,13 @@
                     }
                 ReportProfileConnectionEvents(iBTDevAddrPckgBuf(), profile, ETrue);
                 }
-            delete iActive4ClientReq;
-            iActive4ClientReq = NULL;
             break;
             }
         case ERequestDisconnect:
             {
-            if (iActive4ClientReq->iStatus.Int() != KErrNone)
+            if (result != KErrNone)
                 {
-                iObserver->DisconnectComplete(iBTDevAddrPckgBuf(), 
-                        EBTProfileHFP, iActive4ClientReq->iStatus.Int());
+                iObserver->DisconnectComplete(iBTDevAddrPckgBuf(), EBTProfileHFP, result);
                 }
             else
                 {
@@ -278,27 +312,24 @@
                     pckg.Copy(iDiagnostic.Mid(0, sizeof(TInt))); 
                     }
                 ReportProfileConnectionEvents(iBTDevAddrPckgBuf(), profile, EFalse);
-                }            
-            delete iActive4ClientReq;
-            iActive4ClientReq = NULL;
+                }
             break;
             }
         case ERequestDisconnectAll:
             {
-            iObserver->DisconnectComplete(iBTDevAddrPckgBuf(), 
-                        EBTProfileHFP, iActive4ClientReq->iStatus.Int());
-			break;
+            iObserver->DisconnectComplete(iBTDevAddrPckgBuf(), EBTProfileHFP, result);
+            break;
             }
         }
     }
     
 void CBtAudioManPlugin::CancelRequest(CBasrvActive& aActive)
     {
-    if (aActive.RequestId() == ENotifyProfileStatusChange )
+    if (aActive.RequestId() == ENotifyProfileStatusChange)
         {
         iClient.CancelNotifyConnectionStatus();
         }
-    else if (aActive.RequestId() == ERequestConnect )
+    else if (aActive.RequestId() == ERequestConnect)
         {
         iClient.CancelConnectToAccessory();
         }
@@ -312,51 +343,49 @@
 void CBtAudioManPlugin::ConstructL()
     {
     LEAVE_IF_ERROR(iClient.Connect());
+    // Create the handler for profile notifications
     iActive4ProfileStatus = CBasrvActive::NewL(*this, CActive::EPriorityStandard, ENotifyProfileStatusChange);
+    NotifyConnectionStatus();
+    // Create the handler for active requests (connect, disconnect, etc.)
+    iActive4ClientReq = CBasrvActive::New(*this, CActive::EPriorityStandard, ERequestConnect);
+    }
+
+void CBtAudioManPlugin::NotifyConnectionStatus()
+    {
     iClient.NotifyConnectionStatus(iProfileStatusPckg, iActive4ProfileStatus->iStatus);
     iActive4ProfileStatus->GoActive();
     }
 
-TInt CBtAudioManPlugin::HandleAsyncRequest(const TBTDevAddr& aAddr, TInt aRequestId)
+TInt CBtAudioManPlugin::ReconnectIfNeccessary()
     {
     TInt err = KErrNone;
-    if (! iClient.Handle() )
+    if (iClient.Handle() == KNullHandle)
         {
+        TRACE_INFO((_L8("Handle to Audio Man Server is not valid, connecting again...")))
         err = iClient.Connect();
+        TRACE_INFO((_L8("... reconnection result = %d"), err))
+        if(!err)
+            {
+            // Now reconnected, we should start status notifications again...
+            NotifyConnectionStatus();
+            }
         }
-    if ( err )
+    return err;
+    }
+
+TInt CBtAudioManPlugin::PrepareAsyncRequest(const TBTDevAddr& aAddr, TInt aRequestId)
+    {
+    TInt err = KErrNone;
+    err = ReconnectIfNeccessary();
+    if (!err && iActive4ClientReq->IsActive())
         {
-        return err;
-        }
-    if ( iActive4ClientReq )
-        {
+        // I would normally expect KErrInUse, so as to distinguish this failure from running out of message slots
         err = KErrServerBusy;
         }
     if (!err)
         {
-        iActive4ClientReq = CBasrvActive::New(*this, CActive::EPriorityStandard, aRequestId);
-        if (iActive4ClientReq)
-            {
-            iBTDevAddrPckgBuf() = aAddr;
-            if (aRequestId == ERequestConnect)
-                {
-                iDiagnostic.Zero();
-                iClient.ConnectToAccessory(iActive4ClientReq->iStatus, iBTDevAddrPckgBuf, iDiagnostic);
-                }
-            else if (aRequestId == ERequestDisconnect)
-                {
-                iClient.DisconnectAccessory(iActive4ClientReq->iStatus, iBTDevAddrPckgBuf, iDiagnostic);
-                }
-            else // if (aRequestId == ERequestDisconnectAll)
-            	{
-            	iClient.DisconnectAllGracefully(iActive4ClientReq->iStatus);
-            	}
-            iActive4ClientReq->GoActive();
-            }
-        else
-            {
-            err = KErrNoMemory;
-            }
+        iBTDevAddrPckgBuf() = aAddr;
+        iActive4ClientReq->SetRequestId(aRequestId);
         }
     return err;    
     }
@@ -365,7 +394,7 @@
     {
     TRACE_FUNC
     TRACE_INFO((_L("status %d profiles 0x%04X"), aConnected, aProfiles))
-	TBTEngConnectionStatus status = IsConnected(aAddr);
+    TBTEngConnectionStatus status = IsConnected(aAddr);
     if (iObserver)
         {
         if (aConnected)
@@ -385,21 +414,21 @@
             }
         else
             {
-			if(	status != EBTEngConnected )
-				{
-	            if (aProfiles & EHFP)
-	                {
-	                iObserver->DisconnectComplete(aAddr, EBTProfileHFP, KErrNone);
-	                }
-	            if (aProfiles & EHSP)
-	                {
-	                iObserver->DisconnectComplete(aAddr, EBTProfileHSP, KErrNone);
-	                }
-	            if (aProfiles & EStereo)
-	                {
-	                iObserver->DisconnectComplete(aAddr, EBTProfileA2DP, KErrNone);
-	                }
-				}
+            if (status != EBTEngConnected)
+                {
+                if (aProfiles & EHFP)
+                    {
+                    iObserver->DisconnectComplete(aAddr, EBTProfileHFP, KErrNone);
+                    }
+                if (aProfiles & EHSP)
+                    {
+                    iObserver->DisconnectComplete(aAddr, EBTProfileHSP, KErrNone);
+                    }
+                if (aProfiles & EStereo)
+                    {
+                    iObserver->DisconnectComplete(aAddr, EBTProfileA2DP, KErrNone);
+                    }
+                }
             }
         }
     }
--- a/bluetoothengine/bteng/btfeatures/btfeatures.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/bteng/btfeatures/btfeatures.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -17,8 +17,8 @@
 
 
 #include <btfeaturescfg.h> 
-#include <featmgr/FeatureControl.h>
-#include <featmgr/FeatMgr.h>
+#include <featmgr/featurecontrol.h>
+#include <featmgr/featmgr.h>
 
 /**
 	Device supports bluetooth data profiles disabled.
Binary file bluetoothengine/bthid/mouse/Sesame_client/data/cursormask.bmp has changed
--- a/bluetoothengine/btmac/BWINS/BTMonoCmdHandlerU.DEF	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btmac/BWINS/BTMonoCmdHandlerU.DEF	Fri Feb 19 22:59:18 2010 +0200
@@ -1,10 +1,10 @@
 EXPORTS
-	??1CBtmcHandlerApi@@UAE@XZ @ 1 NONAME ; CBtmcHandlerApi::~CBtmcHandlerApi(void)
+	?NewL@CBtmcHandlerApi@@SAPAV1@AAVMBtmcObserver@@W4TBtmcProfileId@@ABVTDesC8@@H@Z @ 1 NONAME ; class CBtmcHandlerApi * CBtmcHandlerApi::NewL(class MBtmcObserver &, enum TBtmcProfileId, class TDesC8 const &, int)
 	?HandleNrecCompletedL@CBtmcHandlerApi@@QAEXH@Z @ 2 NONAME ; void CBtmcHandlerApi::HandleNrecCompletedL(int)
-	?HandleProtocolDataL@CBtmcHandlerApi@@QAEXABVTDesC8@@@Z @ 3 NONAME ; void CBtmcHandlerApi::HandleProtocolDataL(class TDesC8 const &)
-	?NewL@CBtmcHandlerApi@@SAPAV1@AAVMBtmcObserver@@W4TBtmcProfileId@@ABVTDesC8@@H@Z @ 4 NONAME ; class CBtmcHandlerApi * CBtmcHandlerApi::NewL(class MBtmcObserver &, enum TBtmcProfileId, class TDesC8 const &, int)
-	?ActivateRemoteVolumeControl@CBtmcHandlerApi@@QAEXXZ @ 5 NONAME ; void CBtmcHandlerApi::ActivateRemoteVolumeControl(void)
-	?DeActivateRemoteVolumeControl@CBtmcHandlerApi@@QAEXXZ @ 6 NONAME ; void CBtmcHandlerApi::DeActivateRemoteVolumeControl(void)
-	?GetRemoteSupportedFeature@CBtmcHandlerApi@@QAEHXZ @ 7 NONAME ; int CBtmcHandlerApi::GetRemoteSupportedFeature(void)
-	?SetHspRvcSupported@CBtmcHandlerApi@@QAEXH@Z @ 8 NONAME ; void CBtmcHandlerApi::SetHspRvcSupported(int)
+	?ActivateRemoteVolumeControl@CBtmcHandlerApi@@QAEXXZ @ 3 NONAME ; void CBtmcHandlerApi::ActivateRemoteVolumeControl(void)
+	?GetRemoteSupportedFeature@CBtmcHandlerApi@@QAEHXZ @ 4 NONAME ; int CBtmcHandlerApi::GetRemoteSupportedFeature(void)
+	?SetHspRvcSupported@CBtmcHandlerApi@@QAEXH@Z @ 5 NONAME ; void CBtmcHandlerApi::SetHspRvcSupported(int)
+	?HandleProtocolDataL@CBtmcHandlerApi@@QAEXABVTDesC8@@@Z @ 6 NONAME ; void CBtmcHandlerApi::HandleProtocolDataL(class TDesC8 const &)
+	?DeActivateRemoteVolumeControl@CBtmcHandlerApi@@QAEXXZ @ 7 NONAME ; void CBtmcHandlerApi::DeActivateRemoteVolumeControl(void)
+	??1CBtmcHandlerApi@@UAE@XZ @ 8 NONAME ; CBtmcHandlerApi::~CBtmcHandlerApi(void)
 
--- a/bluetoothengine/btmac/eabi/BTMonoCmdHandleru.DEF	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btmac/eabi/BTMonoCmdHandleru.DEF	Fri Feb 19 22:59:18 2010 +0200
@@ -1,12 +1,12 @@
 EXPORTS
-	_ZN15CBtmcHandlerApi19HandleProtocolDataLERK6TDesC8 @ 1 NONAME
-	_ZN15CBtmcHandlerApi20HandleNrecCompletedLEi @ 2 NONAME
-	_ZN15CBtmcHandlerApi4NewLER13MBtmcObserver14TBtmcProfileIdRK6TDesC8i @ 3 NONAME
-	_ZN15CBtmcHandlerApiD0Ev @ 4 NONAME
-	_ZN15CBtmcHandlerApiD1Ev @ 5 NONAME
-	_ZN15CBtmcHandlerApiD2Ev @ 6 NONAME
-	_ZN15CBtmcHandlerApi27ActivateRemoteVolumeControlEv @ 7 NONAME
-	_ZN15CBtmcHandlerApi29DeActivateRemoteVolumeControlEv @ 8 NONAME
-	_ZN15CBtmcHandlerApi25GetRemoteSupportedFeatureEv @ 9 NONAME
-	_ZN15CBtmcHandlerApi18SetHspRvcSupportedEi @ 10 NONAME
+	_ZN15CBtmcHandlerApi18SetHspRvcSupportedEi @ 1 NONAME
+	_ZN15CBtmcHandlerApi19HandleProtocolDataLERK6TDesC8 @ 2 NONAME
+	_ZN15CBtmcHandlerApi20HandleNrecCompletedLEi @ 3 NONAME
+	_ZN15CBtmcHandlerApi25GetRemoteSupportedFeatureEv @ 4 NONAME
+	_ZN15CBtmcHandlerApi27ActivateRemoteVolumeControlEv @ 5 NONAME
+	_ZN15CBtmcHandlerApi29DeActivateRemoteVolumeControlEv @ 6 NONAME
+	_ZN15CBtmcHandlerApi4NewLER13MBtmcObserver14TBtmcProfileIdRK6TDesC8i @ 7 NONAME
+	_ZN15CBtmcHandlerApiD0Ev @ 8 NONAME
+	_ZN15CBtmcHandlerApiD1Ev @ 9 NONAME
+	_ZN15CBtmcHandlerApiD2Ev @ 10 NONAME
 
--- a/bluetoothengine/btmac/inc/btmonocmdhandler/btmcnumber.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcnumber.h	Fri Feb 19 22:59:18 2010 +0200
@@ -34,6 +34,18 @@
     {
     public:
     
+    	/** CBtmcNumber states.
+    	*/
+    	enum BtmcNumberState
+    		{
+    		/** Not valid */
+    		EStateNull = 0,
+    		/** Getting the MSISDN - getting store info*/
+    		EStateGettingMsisdnStoreInfo = 1,
+    		/** Getting the MSISDN - getting store entry*/
+    		EStateGettingMsisdnStoreEntry = 2,
+    		};
+    	
         /**
         * Two-phased constructor.
         */
@@ -76,6 +88,14 @@
             TInt aServiceId);
     
         void ConstructL();
+        /**
+        * Gets MSISDN store info to check how many numbers are stored on SIM
+        */
+        void GetMsisdnStoreInfo();
+        /**
+        * Gets single MSISDN store entry
+        */
+        void GetMsisdnStoreEntry();
 
     private:
         CBtmcProtocol& iProtocol;
@@ -84,7 +104,21 @@
         RMobileONStore iStore;
 		RMobileONStore::TMobileONEntryV1 iEntry;
 		RMobileONStore::TMobileONEntryV1Pckg iPckg;
+		RMobileONStore::TMobileONStoreInfoV1Pckg iOnStoreInfoPckg;
+		RMobileONStore::TMobileONStoreInfoV1 iOnStoreInfo;
+        /**
+        * Defines current CBtmcNumber state
+        */
+		BtmcNumberState iState;
+        /**
+        * Index which is used to get MSISDN entries
+        */
+		TInt iUsedEntriesCount;
+        /**
+        * Count of correct numbers returned by MSISDN
+        */
+		TInt iCorrectNumbersCount;
     };
 
 
-#endif
\ No newline at end of file
+#endif
--- a/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcnumber.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcnumber.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -57,10 +57,33 @@
 void CBtmcNumber::GoActive()
     {
     TRACE_ASSERT(!IsActive(), KErrGeneral);
-    iEntry.iIndex = 1;
+    GetMsisdnStoreInfo();
+    TRACE_FUNC
+    }
+
+// -------------------------------------------------------------------------------
+// CBtmcNumber::GetMsisdnStoreInfo
+// -------------------------------------------------------------------------------
+void CBtmcNumber::GetMsisdnStoreInfo()
+    {
+    TRACE_FUNC_ENTRY
+    iState = EStateGettingMsisdnStoreInfo;
+    iStore.GetInfo(iStatus, iOnStoreInfoPckg);
+    SetActive();
+    TRACE_FUNC_EXIT
+    }
+
+// -------------------------------------------------------------------------------
+// CBtmcNumber::GetMsisdnStoreEntry
+// -------------------------------------------------------------------------------
+void CBtmcNumber::GetMsisdnStoreEntry()
+    {
+    TRACE_FUNC_ENTRY
+    iState = EStateGettingMsisdnStoreEntry;
+    iEntry.iIndex = iUsedEntriesCount++;
     iStore.Read(iStatus, iPckg);
     SetActive();
-    TRACE_FUNC
+    TRACE_FUNC_EXIT
     }
 
 // -------------------------------------------------------------------------------
@@ -70,56 +93,104 @@
     {
     TRACE_FUNC_ENTRY
     
-    RATResultPtrArray resarr;
-    ATObjArrayCleanupResetAndDestroyPushL(resarr);
-    CATResult* okerr = NULL;
-    if (iStatus == KErrNone)
+    switch (iState)
         {
-        TBuf8<RMobileONStore::KOwnNumberTextSize> nameBuf;
-        nameBuf.Copy(iEntry.iNumber.iTelNumber);
-        
-        TRACE_INFO((_L8("ao status %d, phonebook returned %S"), iStatus.Int(), &nameBuf))
-        RATParamArray params;
-        CleanupClosePushL(params);
-        LEAVE_IF_ERROR(params.Append(TATParam()))
-        LEAVE_IF_ERROR(params.Append(TATParam(nameBuf, EATDQStringParam)))  
-         
-        TBTMonoATPhoneNumberType numType;
-        if (nameBuf.Length() == 0)
+        case EStateGettingMsisdnStoreEntry:
             {
-            numType = EBTMonoATPhoneNumberUnavailable;
-            }
-        else if(nameBuf.Locate('+') == 0)
-            {
-            numType = EBTMonoATPhoneNumberInternational;
+            if (iStatus == KErrNone)
+                {
+                if(iEntry.iNumber.iTelNumber.Length() == 0)
+                    {
+                    GetMsisdnStoreEntry();
+                    break;
+                    }
+              
+                iCorrectNumbersCount++;
+
+                RATResultPtrArray resarr;
+                ATObjArrayCleanupResetAndDestroyPushL(resarr);
+                
+                TBuf8<RMobileONStore::KOwnNumberTextSize> telnumberBuf;
+                telnumberBuf.Copy(iEntry.iNumber.iTelNumber);
+                
+                TRACE_INFO((_L8("ao status %d, phonebook returned %S"), iStatus.Int(), &telnumberBuf))
+                RATParamArray params;
+                CleanupClosePushL(params);
+                LEAVE_IF_ERROR(params.Append(TATParam()))
+                LEAVE_IF_ERROR(params.Append(TATParam(telnumberBuf, EATDQStringParam)))  
+                 
+                TBTMonoATPhoneNumberType numType;
+                if(telnumberBuf.Locate('+') == 0)
+                    {
+                    numType = EBTMonoATPhoneNumberInternational;
+                    }
+                else
+                    {
+                    numType = EBTMonoATPhoneNumberNational;
+                    }
+                LEAVE_IF_ERROR(params.Append(TATParam(numType)))
+                LEAVE_IF_ERROR(params.Append(TATParam()))
+                LEAVE_IF_ERROR(params.Append(TATParam(4)))
+                CATResult* code = CATResult::NewL(EATCNUM, EATActionResult, &params);
+                CleanupStack::PushL(code);
+                resarr.AppendL(code);
+                CleanupStack::Pop(code);
+                CleanupStack::PopAndDestroy(&params);
+                
+                if(iCorrectNumbersCount == iOnStoreInfo.iUsedEntries)
+                    {
+                    CATResult* okerr = CATResult::NewL(EATOK);
+                    CleanupStack::PushL(okerr);
+                    resarr.AppendL(okerr);
+                    CleanupStack::Pop(okerr);
+                    iProtocol.SendResponseL(resarr);
+                    CleanupStack::PopAndDestroy(&resarr);
+                    Observer().RequestCompletedL(*this, iStatus.Int());  
+                    }
+                else
+                    {
+                    iProtocol.SendResponseL(resarr);
+                    CleanupStack::PopAndDestroy(&resarr);
+                    GetMsisdnStoreEntry();
+                    }
+                }
+            else
+                {
+                CATResult* okerr = CATResult::NewL(EATERROR);
+                CleanupStack::PushL(okerr);
+                iProtocol.SendResponseL(*okerr);
+                CleanupStack::PopAndDestroy(okerr);
+                Observer().RequestCompletedL(*this, iStatus.Int());  
+                }
+
+            break;
             }
-        else
+        case EStateGettingMsisdnStoreInfo:
             {
-            numType = EBTMonoATPhoneNumberNational;
+            if(iStatus==KErrNone && iOnStoreInfo.iUsedEntries>0 && 
+                    (iOnStoreInfo.iCaps & RMobilePhoneStore::KCapsIndividualEntry))
+                {
+                GetMsisdnStoreEntry();
+                }
+            else
+                {
+                CATResult* okerr = CATResult::NewL(EATOK);
+                CleanupStack::PushL(okerr);
+                iProtocol.SendResponseL(*okerr);
+                CleanupStack::PopAndDestroy(okerr);
+                Observer().RequestCompletedL(*this, iStatus.Int());  
+                }
+            break;
             }
-        LEAVE_IF_ERROR(params.Append(TATParam(numType)))
-        LEAVE_IF_ERROR(params.Append(TATParam()))
-        LEAVE_IF_ERROR(params.Append(TATParam(4)))
-        CATResult* code = CATResult::NewL(EATCNUM, EATActionResult, &params);
-        CleanupStack::PushL(code);
-        resarr.AppendL(code);
-        CleanupStack::Pop(code);
-        CleanupStack::PopAndDestroy(&params);
-        okerr = CATResult::NewL(EATOK);
+            
+        default:
+            break;        
         }
-    else
-        {
-        okerr = CATResult::NewL(EATERROR);
-        }
-    CleanupStack::PushL(okerr);
-    resarr.AppendL(okerr);
-    CleanupStack::Pop(okerr);
-    iProtocol.SendResponseL(resarr);
-    CleanupStack::PopAndDestroy(&resarr);
-    Observer().RequestCompletedL(*this, iStatus.Int());    
+    
     TRACE_FUNC_EXIT
     }
 
+
 // -------------------------------------------------------------------------------
 // CBtmcNumber::DoCancel
 // -------------------------------------------------------------------------------
@@ -147,7 +218,8 @@
     CBtmcProtocol& aProtocol, 
     CActive::TPriority aPriority, 
     TInt aServiceId)
-    : CBtmcActive(aObserver, aPriority, aServiceId), iProtocol(aProtocol), iPckg(iEntry)
+    : CBtmcActive(aObserver, aPriority, aServiceId), iProtocol(aProtocol), iPckg(iEntry),
+    iOnStoreInfoPckg(iOnStoreInfo), iState(EStateNull), iUsedEntriesCount(1), iCorrectNumbersCount(0)
     {
     }
 
--- a/bluetoothengine/btmac/src/btmac/btmrfcommsock.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btmac/src/btmac/btmrfcommsock.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -229,16 +229,20 @@
     {
     TRACE_FUNC_ENTRY
     TRACE_INFO((_L("err %d"), aErr))
-
+    
+    if (aErr == KErrNone)
+    	{
+		TBTSockAddr sockAddr;
+		iDataSocket->RemoteName(sockAddr);
+		iRemote = sockAddr.BTAddr();
+    	}
+    
     // Process the connect complete before issuing a receive request to ensure that
     // we are ready to process the data when it is received.
     iObserver->RfcommConnectCompletedL(aErr);
 
-    if (!aErr)
+    if (aErr == KErrNone)
         {
-        TBTSockAddr sockAddr;
-        iDataSocket->RemoteName(sockAddr);
-        iRemote = sockAddr.BTAddr();
         iInData.ReAllocL(256);
         RequestMasterRole();
         TInt err = iAda.Open(iServer, iRemote);
@@ -256,17 +260,20 @@
     {
     TRACE_FUNC_ENTRY
 
-    iRemoteHasConnected = ETrue;
+    if (aErr == KErrNone)
+    	{
+		iRemoteHasConnected = ETrue;
+		TBTSockAddr sockAddr;
+		iDataSocket->RemoteName(sockAddr);
+		iRemote = sockAddr.BTAddr();
+    	}
 
     // Process the accept complete before issuing a receive request to ensure that
     // we are ready to process the data when it is received.
     iObserver->RfcommAcceptCompletedL(aErr, iService);
 
-   if (!aErr)
+   if (aErr == KErrNone)
         {
-        TBTSockAddr sockAddr;
-        iDataSocket->RemoteName(sockAddr);
-        iRemote = sockAddr.BTAddr();
         iInData.ReAllocL(256);
         RequestMasterRole();
         TInt err = iAda.Open(iServer, iRemote);
--- a/bluetoothengine/btnotif/ecom/BtnotifWrapper.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/ecom/BtnotifWrapper.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -78,64 +78,101 @@
                                    KBTInquiryPriority,
                                    _L("BTNotif.dll"),
                                    KMaxSynchReplyBufLength);
-	  		   
+
+    CleanupStack::PushL( master );
     subjects->AppendL( master );
-    
-   // Notifiers using masters session 
-    subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, 
-                                                            KBTManAuthNotifierUid,
-                                   			 				KBTAuthorisationChannel,
-                                   			 				KBTAuthorisationPriority));
-    
-    subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, 
-                                                            KBTPinCodeEntryNotifierUid,
-                                   			 				KBTAuthenticationChannel,
-                                   			 				KBTAuthenticationPriority));
-                                   			 				                               
-	subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, 
-                                                            KBTObexPasskeyQueryNotifierUid,
-                                   			 				KBTObexPINChannel,
-                                   			 				KBTObexPinPriority));
-        
-    subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, 
-                                                            KPowerModeSettingNotifierUid,
-                                   			 				KBTPowerModeChannel,
-                                   			 				KBTPowerModePriority));                               			 				
-                                   			 				
-    subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, 
-                                                            KBTGenericInfoNotifierUid,
-                                   			 				KBTGenericInfoNotifierUid,
-                                   			 				KBTGenericInfoNotifierPriority));
+    CleanupStack::Pop( master );
+
+    // Notifiers using masters session
+    CAknNotifierWrapperLight* notif = NULL;
+    notif = new (ELeave) CAknNotifierWrapperLight(*master,
+                                                  KBTManAuthNotifierUid,
+                                                  KBTAuthorisationChannel,
+                                                  KBTAuthorisationPriority);
+    CleanupStack::PushL( notif );
+    subjects->AppendL( notif );
+    CleanupStack::Pop( notif );
+
+    notif = new (ELeave) CAknNotifierWrapperLight(*master,
+                                                  KBTPinCodeEntryNotifierUid,
+                                                  KBTAuthenticationChannel,
+                                                  KBTAuthenticationPriority);
+    CleanupStack::PushL( notif );
+    subjects->AppendL( notif );
+    CleanupStack::Pop( notif );
+
+    notif = new (ELeave) CAknNotifierWrapperLight(*master,
+                                                  KBTObexPasskeyQueryNotifierUid,
+                                                  KBTObexPINChannel,
+                                                  KBTObexPinPriority);
+    CleanupStack::PushL( notif );
+    subjects->AppendL( notif );
+    CleanupStack::Pop( notif );
+
+    notif = new (ELeave) CAknNotifierWrapperLight(*master,
+                                                  KPowerModeSettingNotifierUid,
+                                                  KBTPowerModeChannel,
+                                                  KBTPowerModePriority);
+    CleanupStack::PushL( notif );
+    subjects->AppendL( notif );
+    CleanupStack::Pop( notif );
+
+    notif = new (ELeave) CAknNotifierWrapperLight(*master,
+                                                  KBTGenericInfoNotifierUid,
+                                                  KBTGenericInfoNotifierUid,
+                                                  KBTGenericInfoNotifierPriority);
+    CleanupStack::PushL( notif );
+    subjects->AppendL( notif );
+    CleanupStack::Pop( notif );
 
-    subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, 
-                                                            KBTGenericQueryNotifierUid,
-                                   			 				KBTGenericQueryNotifierUid,
-                                   			 				KBTGenericQueryNotifierPriority));
-    
-    subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, 
-                                                            KPbapAuthNotifierUid,
-                                   			 				KBTObexPINChannel,
-                                   			 				KBTObexPinPriority));   
-    
-    subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, 
-                                                            KBTPairedDeviceSettingNotifierUid,
-                                                            KBTPairedDeviceSettingChannel,
-                                                            KBTPairedDeviceSettingPriority));   
+    notif = new (ELeave) CAknNotifierWrapperLight(*master,
+                                                  KBTGenericQueryNotifierUid,
+                                                  KBTGenericQueryNotifierUid,
+                                                  KBTGenericQueryNotifierPriority);
+    CleanupStack::PushL( notif );
+    subjects->AppendL( notif );
+    CleanupStack::Pop( notif );
+
+    notif = new (ELeave) CAknNotifierWrapperLight(*master,
+                                                  KPbapAuthNotifierUid,
+                                                  KBTObexPINChannel,
+                                                  KBTObexPinPriority);
+    CleanupStack::PushL( notif );
+    subjects->AppendL( notif );
+    CleanupStack::Pop( notif );
+
+    notif = new (ELeave) CAknNotifierWrapperLight(*master,
+                                                  KBTPairedDeviceSettingNotifierUid,
+                                                  KBTPairedDeviceSettingChannel,
+                                                  KBTPairedDeviceSettingPriority);
+    CleanupStack::PushL( notif );
+    subjects->AppendL( notif );
+    CleanupStack::Pop( notif );
 
-    subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, 
-                                                            KBTNumericComparisonNotifierUid,
-                                                            KBTNumericComparisonNotifierUid,
-                                                            KBTNumericComparisonPriority));       
-    
-    subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master,
-                                                            KBTPasskeyDisplayNotifierUid,
-                                                            KBTPasskeyDisplayNotifierUid,
-                                                            KBTPasskeyEntryNotifierPriority)); 
+    notif = new (ELeave) CAknNotifierWrapperLight(*master,
+                                                  KBTNumericComparisonNotifierUid,
+                                                  KBTNumericComparisonNotifierUid,
+                                                  KBTNumericComparisonPriority);
+    CleanupStack::PushL( notif );
+    subjects->AppendL( notif );
+    CleanupStack::Pop( notif );
 
-    subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, 
-                                                            KBTEnterpriseItSecurityInfoNotifierUid,
-                                   			 				KBTEnterpriseItSecurityInfoNotifierUid,
-                                   			 				KBTEnterpriseItSecurityInfoNotifierPriority));
+    notif = new (ELeave) CAknNotifierWrapperLight(*master,
+                                                  KBTPasskeyDisplayNotifierUid,
+                                                  KBTPasskeyDisplayNotifierUid,
+                                                  KBTPasskeyEntryNotifierPriority);
+    CleanupStack::PushL( notif );
+    subjects->AppendL( notif );
+    CleanupStack::Pop( notif );
+
+    notif = new (ELeave) CAknNotifierWrapperLight(*master,
+                                                  KBTEnterpriseItSecurityInfoNotifierUid,
+                                                  KBTEnterpriseItSecurityInfoNotifierUid,
+                                                  KBTEnterpriseItSecurityInfoNotifierPriority);
+
+    CleanupStack::PushL( notif );
+    subjects->AppendL( notif );
+    CleanupStack::Pop( notif );
 
     CleanupStack::Pop();	// array cleanup
     return(subjects);
--- a/bluetoothengine/btnotif/inc/BTNGenericInfoNotifier.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/inc/BTNGenericInfoNotifier.h	Fri Feb 19 22:59:18 2010 +0200
@@ -93,7 +93,7 @@
         void ShowNoteAndCompleteL();
         
     private:
-        HBufC*	iQueryMessage;
+        RBuf	iQueryMessage;
 	    TInt 	iMessageResourceId;
 	    TSecondaryDisplayBTnotifDialogs iSecondaryDisplayCommand;
     };
--- a/bluetoothengine/btnotif/inc/BTNGenericQueryNotifier.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/inc/BTNGenericQueryNotifier.h	Fri Feb 19 22:59:18 2010 +0200
@@ -95,14 +95,14 @@
                 
     private:
     	
-        HBufC*				iQueryMessage;
-		HBufC*				iQueryHeader;  		      
+        RBuf				iQueryMessage;
+		HBufC*				iQueryHeader;
         HBufC*				iName;
 
 	    TInt 		iMessageResourceId;
 	    TSecondaryDisplayBTnotifDialogs	iSecondaryDisplayCommand;
 		TBool 		iIsMessageQuery;
-		TBool 		iIsNameQuery; 
+		TBool 		iIsNameQuery;
     };
 
 #endif
--- a/bluetoothengine/btnotif/inc/btnotifier.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/inc/btnotifier.h	Fri Feb 19 22:59:18 2010 +0200
@@ -295,6 +295,7 @@
         CBTEngSettings*             iBTEngSettings;
     private:
         CBTEngDevMan*               iDevMan;  // for BT registry manipulation
+        TBool                       iIsCoverUI;
         
     };
 
--- a/bluetoothengine/btnotif/inc/btnotifuiutil.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/inc/btnotifuiutil.h	Fri Feb 19 22:59:18 2010 +0200
@@ -21,7 +21,7 @@
 #include <data_caging_path_literals.hrh> 
 #include <AknQueryDialog.h>
 #include <AknWaitDialog.h>
-#include <secondarydisplay/BTnotifSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
 
 // CONSTANTS
 // Literals for resource and bitmap files ( drive, directory, filename(s) )
--- a/bluetoothengine/btnotif/inc/btnpaireddevsettnotifier.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/inc/btnpaireddevsettnotifier.h	Fri Feb 19 22:59:18 2010 +0200
@@ -83,11 +83,6 @@
     private:
 
 		/**
-		 * Leave function called by non-leave btengdevman callback function HandleGetDevicesComplete().
-		 *@param aErr. Passed by caller.
-		 */
-
-		/**
         * Parse the data out of the message that is sent by the client of the notifier. 
 		* @param aBuffer A package buffer containing received parameters.
         * @return None.
--- a/bluetoothengine/btnotif/inc/btnpairnotifier.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/inc/btnpairnotifier.h	Fri Feb 19 22:59:18 2010 +0200
@@ -84,8 +84,9 @@
         
         /**
          * Generate prompt based on subclass's own needs.
+         * @param aRBuf the descriptor to which the prompt will be loaded.
          */
-        virtual HBufC* GenerateQueryPromoptLC();
+        virtual void GenerateQueryPromptL( RBuf& aRBuf );
         
     private:
         /**
--- a/bluetoothengine/btnotif/inc/btnpinnotifier.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/inc/btnpinnotifier.h	Fri Feb 19 22:59:18 2010 +0200
@@ -72,8 +72,9 @@
         /**
         * From CBTNPairNotifierBase
         * Generate prompt in Pin query dialog.
+        * @param aRBuf the descriptor to which the prompt will be loaded.
         */      
-        HBufC* GenerateQueryPromoptLC(); 
+        void GenerateQueryPromptL(RBuf& aRBuf); 
 
     private:
 
--- a/bluetoothengine/btnotif/inc/btnssppasskeyentrynotifier.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/inc/btnssppasskeyentrynotifier.h	Fri Feb 19 22:59:18 2010 +0200
@@ -77,10 +77,9 @@
     
         /**
         * Generate prompt for passkey entry query.
-        * @param None.
-        * @return None.
+        * @param aRBuf the descriptor to which the prompt will be loaded.
         */
-        HBufC* GenerateQueryPromoptLC();
+        void GenerateQueryPromptL( RBuf& aRBuf );
         
     private:
 
--- a/bluetoothengine/btnotif/inc/btnumcmpnotifier.h	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/inc/btnumcmpnotifier.h	Fri Feb 19 22:59:18 2010 +0200
@@ -75,10 +75,9 @@
         
         /**
         * From CBTNPairNotifierBase
-        * @param None.
-        * @return None.
+        * @param aRBuf the descriptor to which the prompt will be loaded.
         */
-        HBufC* GenerateQueryPromoptLC();
+        void GenerateQueryPromptL( RBuf& aRBuf );
 
     private:
 
--- a/bluetoothengine/btnotif/src/BTNAuthNotifier.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/src/BTNAuthNotifier.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -17,7 +17,6 @@
 
 
 // INCLUDE FILES
-#include <StringLoader.h>    // Localisation stringloader
 #include <BTNotif.rsg>       // Own resources
 #include "btnauthnotifier.h" // Own class definition
 #include "btNotifDebug.h"    // Debugging macros
@@ -39,6 +38,7 @@
 #include <hlplch.h>
 #include <csxhelp/bt.hlp.hrh> // The bt hrh info is needed, for help launching
 #endif
+#include <bluetoothuiutil.h>
 #include "btnotifnameutils.h"
 
 
@@ -120,30 +120,31 @@
         {
         User::Leave(KErrInUse);
         }
-    else if ( AutoLockOnL() )
+
+    iMessage = aMessage;
+    iReplySlot = aReplySlot;
+
+    if ( AutoLockOnL() )
         {
         // The phone is locked, access denied.
         // Write results back to caller and complete message.	
-		CompleteMessage(EFalse, KErrNone);	
+	CompleteMessage(EFalse, KErrNone);	
         return;
         }
     
-	TBTAuthorisationParams param;
- 	TPckgC<TBTAuthorisationParams> pckg(param);
- 	pckg.Set(aBuffer);
+    TBTAuthorisationParams param;
+    TPckgC<TBTAuthorisationParams> pckg(param);
+    pckg.Set(aBuffer);
 
- 	iServiceUid = pckg().iUid.iUid;  // Pick up service uid from message
- 	iBTAddr = pckg().iBDAddr;
- 	if ( OtherOutgoPairing( iBTAddr ) )
+    iServiceUid = pckg().iUid.iUid;  // Pick up service uid from message
+    iBTAddr = pckg().iBDAddr;
+    if ( OtherOutgoPairing( iBTAddr ) )
         {
         // We won't allow connection request from another device during outgoing pairing:
         FLOG(_L("[BTNOTIF]\t CBTAuthNotifier: outgoing pair in progress, reject request from other device"));
         CompleteMessage(KErrCancel);
         return;
-        }
- 	
-    iMessage = aMessage;
-    iReplySlot = aReplySlot;
+        }	
  	
     // create iDevice so that the name won't be lost if the device does
     // not exist in registry.
@@ -201,9 +202,12 @@
         if ( !iDevice->IsValidFriendlyName() && iDevice->IsValidDeviceName())
             {
             // Create new prompt string with new device name
-            HBufC* stringholder = StringLoader::LoadL( iStrResourceId, BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName()));
-            CleanupStack::PushL( stringholder );
-            iNotifUiUtil->UpdateQueryDlgL( *stringholder );
+            RBuf stringholder;
+            CleanupClosePushL( stringholder );
+            BluetoothUiUtil::LoadResourceAndSubstringL( 
+                    stringholder, iStrResourceId, 
+                    BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName()), 0 );
+            iNotifUiUtil->UpdateQueryDlgL( stringholder );
             iNotifUiUtil->UpdateCoverUiL( iDevice->DeviceName() );
             CleanupStack::PopAndDestroy();  // stringholder
             }
@@ -500,8 +504,11 @@
 
     TBTDeviceName tempDeviceName; 
     BtNotifNameUtils::GetDeviceDisplayName(tempDeviceName, iDevice);
-    HBufC* stringholder = StringLoader::LoadLC( iStrResourceId, tempDeviceName);
-    TInt keypress = iNotifUiUtil->ShowQueryL( *stringholder, R_BT_AUTHORISATION_QUERY, 
+    RBuf stringholder;
+    CleanupClosePushL( stringholder );
+    BluetoothUiUtil::LoadResourceAndSubstringL( 
+            stringholder, iStrResourceId, tempDeviceName, 0);
+    TInt keypress = iNotifUiUtil->ShowQueryL( stringholder, R_BT_AUTHORISATION_QUERY, 
             iCoverUiDlgId, tempDeviceName, CAknQueryDialog::EConfirmationTone );
     CleanupStack::PopAndDestroy();  // stringholder
     // If this notifier is cancelled by the caller, no need to perform the rest operation:
--- a/bluetoothengine/btnotif/src/BTNGenericInfoNotifier.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/src/BTNGenericInfoNotifier.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -24,6 +24,7 @@
 #include "btNotifDebug.h"       // Debugging macros
 #include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
 #include <e32cmn.h>
+#include <bluetoothuiutil.h>
 #include "btnotifnameutils.h"
 
 // ================= MEMBER FUNCTIONS =======================
@@ -59,7 +60,7 @@
 CBTGenericInfoNotifier::~CBTGenericInfoNotifier()
     {
     Cancel();   // Free own resources
-    delete iQueryMessage; 
+    iQueryMessage.Close(); 
     }
 
 // ----------------------------------------------------------
@@ -203,13 +204,20 @@
 			User::Leave(KErrNotFound);		
 		}
     
-	// if the logic string contains substitute indicator "%U", replace it with device name:	
-	iQueryMessage = StringLoader::LoadL( iMessageResourceId);
-	_LIT(PU,"%U");
-	if( iQueryMessage->Find(PU) != KErrNotFound)
+	// if the logic string contains substitute indicator "%U", replace it with device name:
+	HBufC* buf = StringLoader::LoadL( iMessageResourceId);
+	iQueryMessage.Assign( buf );
+	
+    TInt keyLen;
+    TInt pos = BluetoothUiUtil::GetStringSubstringKeyPos( 
+            iQueryMessage, 0, keyLen );
+    if( pos > KErrNotFound)
 		{
 		iBTAddr = TBTDevAddr( bPckg().iRemoteAddr );
-        iDevice = CBTDevice::NewL(iBTAddr);
+		if( !iDevice )
+		    {
+            iDevice = CBTDevice::NewL(iBTAddr);
+		    }
 	    GetDeviceFromRegL( iBTAddr );
 		}
 	else
@@ -225,7 +233,7 @@
 //
 void CBTGenericInfoNotifier::ShowNoteAndCompleteL()
 	{
-	iNotifUiUtil->ShowInfoNoteL( *iQueryMessage, iSecondaryDisplayCommand );
+	iNotifUiUtil->ShowInfoNoteL( iQueryMessage, iSecondaryDisplayCommand );
     CompleteMessage(KErrNone);
     FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::ShowNoteAndComplete() complete"));
 	}
@@ -234,12 +242,11 @@
     {
     FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::HandleGetDeviceCompleted()"));
     
-    delete iQueryMessage;
-    iQueryMessage=NULL;
-    
     TBTDeviceName name;
     BtNotifNameUtils::GetDeviceDisplayName(name, iDevice);
-    iQueryMessage = StringLoader::LoadL( iMessageResourceId, name);            
+    iQueryMessage.Zero();
+    BluetoothUiUtil::LoadResourceAndSubstringL( 
+            iQueryMessage, iMessageResourceId, name, 0);      
     
     ShowNoteAndCompleteL();
 
--- a/bluetoothengine/btnotif/src/BTNGenericQueryNotifier.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/src/BTNGenericQueryNotifier.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -23,6 +23,7 @@
 #include <e32cmn.h>
 #include <BTNotif.rsg>          // Own resources
 #include <btengsettings.h>
+#include <bluetoothuiutil.h>
 #include "BTNGenericQueryNotifier.h"      // Own class definition
 #include "btNotifDebug.h"       // Debugging macros
 
@@ -65,7 +66,7 @@
     {
     Cancel();   // Free own resources
     delete iName; 
-    delete iQueryMessage; 
+    iQueryMessage.Close(); 
 	delete iQueryHeader;
     }
 
@@ -226,14 +227,15 @@
 		}
 	
 	// if the logic string contains substitute indicator "%U", replace it with device name:
-	//		
-	iQueryMessage = StringLoader::LoadL( iMessageResourceId);
-	_LIT(PU,"%U");
-	if( iQueryMessage->Find(PU) != KErrNotFound)
+	//
+	HBufC* buf = StringLoader::LoadL( iMessageResourceId);
+	iQueryMessage.Assign( buf );
+
+	TInt keyLen;
+	TInt pos = BluetoothUiUtil::GetStringSubstringKeyPos( 
+	        iQueryMessage, 0, keyLen );
+	if( pos > KErrNotFound)
 		{		
-		delete iQueryMessage;
-		iQueryMessage=NULL;
-		
 		//if no device name provided, default name will be used:
 		if( !bPckg().iNameExists )			
 			iName=StringLoader::LoadL(R_BT_DIALOG_DEF_NAME);
@@ -242,7 +244,8 @@
 			iName=HBufC::NewL(bPckg().iName.Length() );
 			iName->Des().Copy(bPckg().iName);
 			}
-		iQueryMessage = StringLoader::LoadL( iMessageResourceId,*iName);		
+		BluetoothUiUtil::LoadResourceAndSubstringL( 
+		        iQueryMessage, iMessageResourceId, *iName, 0);
 		}
 	else
 		{
@@ -258,18 +261,16 @@
 TPtrC8 CBTGenericQueryNotifier::UpdateL(const TDesC8& aBuffer)
 	{
    	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::UpdateL")); 
-    delete iQueryMessage;
-    iQueryMessage = NULL;
 	ProcessParamBufferL(aBuffer);
 	if( !iNotifUiUtil->IsQueryReleased() )
 		{
 		if(iIsMessageQuery )
 		    {
-		    iNotifUiUtil->UpdateMessageQueryDlgL(*iQueryMessage);
+		    iNotifUiUtil->UpdateMessageQueryDlgL(iQueryMessage);
 		    }
 		else
 		    {
-		    iNotifUiUtil->UpdateQueryDlgL(*iQueryMessage);
+		    iNotifUiUtil->UpdateQueryDlgL(iQueryMessage);
 		    }
 		}
    	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::UpdateL complete")); 	
@@ -325,12 +326,12 @@
     if( iIsMessageQuery	)
 		{
 		
-        keypress = iNotifUiUtil->ShowMessageQueryL(*iQueryMessage, *iQueryHeader, 
+        keypress = iNotifUiUtil->ShowMessageQueryL(iQueryMessage, *iQueryHeader, 
                         R_BT_GENERIC_MESSAGE_QUERY, CAknQueryDialog::EConfirmationTone );        
 		}
 	else
     	{
-    	keypress = iNotifUiUtil->ShowQueryL( *iQueryMessage, R_BT_GENERIC_QUERY, 
+    	keypress = iNotifUiUtil->ShowQueryL( iQueryMessage, R_BT_GENERIC_QUERY, 
     	        iSecondaryDisplayCommand, name, CAknQueryDialog::EConfirmationTone );
     	}
 	
--- a/bluetoothengine/btnotif/src/BTNInqUI.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/src/BTNInqUI.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -22,7 +22,6 @@
 #include <aknlists.h>
 #include <aknPopup.h>
 #include <avkon.mbg>
-#include <StringLoader.h>       // Localisation stringloader
 #include <wlaninternalpskeys.h> // For WLAN state checking
 #include <ctsydomainpskeys.h>
 #include <AknNotiferAppServerApplication.h> 
@@ -33,6 +32,7 @@
 #include <wlanplugin.mbg>       // Borrow WLan signal strenth bar to show RSSI  
 #include <devui_const.h>
 #include <btengutil.h>
+#include <bluetoothuiutil.h>
 #include "btninqui.h"           // Own class definition
 #include "btNotifDebug.h"       // Debugging macros
 #include "btnotifnameutils.h"
@@ -1047,21 +1047,14 @@
 TInt CBTInqUI::QueryUnblockDeviceL(CBTDevice* aDevice)
 	{
 	FLOG(_L("[BTNOTIF]\t CBTInqUI::QueryUnblockDeviceL()"));
-
-    HBufC* stringholder = NULL;
-
-    if (aDevice->IsValidFriendlyName())
-       	{
-        stringholder = StringLoader::LoadLC(R_BT_UNBLOCK_DEVICE, aDevice->FriendlyName());
-        }
-    else
-        {  	
-        stringholder = StringLoader::LoadLC(R_BT_UNBLOCK_DEVICE, BTDeviceNameConverter::ToUnicodeL(aDevice->DeviceName()));
-        }
-
-    TBTDeviceName name(KNullDesC);
+	RBuf stringholder;
+	stringholder.CleanupClosePushL();
+    TBTDeviceName name;
+    BtNotifNameUtils::GetDeviceDisplayName( name, aDevice );
+    BluetoothUiUtil::LoadResourceAndSubstringL( 
+            stringholder, R_BT_UNBLOCK_DEVICE, name, 0 );
     TInt keypress(0);
-    keypress = iUiUtil->ShowQueryL( *stringholder, R_BT_UNBLOCK_QUERY, 
+    keypress = iUiUtil->ShowQueryL( stringholder, R_BT_UNBLOCK_QUERY, 
             ECmdBTnotifUnavailable, name, CAknQueryDialog::EConfirmationTone );
     CleanupStack::PopAndDestroy();  // stringholder
     FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::QueryUnblockDeviceL()  keypress= %d"),keypress));    
--- a/bluetoothengine/btnotif/src/BTNObexPinNotifier.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/src/BTNObexPinNotifier.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -84,17 +84,18 @@
         {
         User::Leave(KErrInUse);
         }
-    else if ( AutoLockOnL() )
+
+    iMessage = aMessage;
+    iReplySlot = aReplySlot;
+
+    if ( AutoLockOnL() )
         {
         // The phone is locked, access denied.
         //
         CompleteMessage(KErrCancel);
         return;
         }
-        
-    iMessage = aMessage;
-    iReplySlot = aReplySlot;
-    
+ 
     ShowNoteCompleteMessageL();
 
     FLOG(_L("[BTNOTIF]\t CBTObexPinNotifier::GetParamsL() completed"));
--- a/bluetoothengine/btnotif/src/BTNPBAPPinNotifier.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/src/BTNPBAPPinNotifier.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -92,16 +92,17 @@
         {
         User::Leave(KErrInUse);
         }
-    else if ( AutoLockOnL() )
+    
+    iMessage = aMessage;
+    iReplySlot = aReplySlot;
+    
+    if ( AutoLockOnL() )
         {
         // The phone is locked, access denied.
         //
         CompleteMessage(KErrCancel);
         return;
         }
-        
-    iMessage = aMessage;
-    iReplySlot = aReplySlot;
 
     ShowNoteCompleteMessageL();
 
--- a/bluetoothengine/btnotif/src/BTNPinNotifier.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/src/BTNPinNotifier.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -24,6 +24,7 @@
 #include <btotgpairpub.inl>
 #include <btextnotifiers.h>
 #include <BTNotif.rsg>       // Own resources
+#include <bluetoothuiutil.h>
 #include "btnotif.hrh"       // Own resource header
 #include "btnpinnotifier.h"  // Own class definition
 #include "btNotifDebug.h"    // Debugging macros
@@ -167,11 +168,12 @@
  	FOREVER
 	 	{
 	    TBuf<KBTPassKeyMaxLength> tempResultBuffer;
-	    
-	    HBufC* prompt = GenerateQueryPromoptLC(); // prompt still in stack.
-        TInt keypress = iNotifUiUtil->ShowTextInputQueryL(tempResultBuffer, *prompt, R_BT_ENTER_PASSKEY_QUERY, 
+	    RBuf prompt;
+	    prompt.CleanupClosePushL();
+	    GenerateQueryPromptL( prompt );
+        TInt keypress = iNotifUiUtil->ShowTextInputQueryL(tempResultBuffer, prompt, R_BT_ENTER_PASSKEY_QUERY, 
                 ECmdShowBtOpenCoverNote, CAknQueryDialog::EConfirmationTone );
-        CleanupStack::PopAndDestroy( prompt );
+        CleanupStack::PopAndDestroy( &prompt );
 
         if( keypress ) // OK pressed
         	{
@@ -248,35 +250,32 @@
     }
 
 // ----------------------------------------------------------
-// CBTPinNotifier::GenerateQueryPromoptLC
+// CBTPinNotifier::GenerateQueryPromptL
 // ---------------------------------------------------------- 
-HBufC* CBTPinNotifier::GenerateQueryPromoptLC()
+void CBTPinNotifier::GenerateQueryPromptL( RBuf& aRBuf )
     {
-    FLOG(_L("[BTNOTIF]\t CBTPinNotifier::GenerateQueryPromoptLC() >>"));
-    HBufC* prompt = NULL;
-
+    FLOG(_L("[BTNOTIF]\t CBTPinNotifier::GenerateQueryPromptLC() >>"));
     TBTDeviceName devName;
-    BtNotifNameUtils::GetDeviceDisplayName( devName, iDevice );
+    BtNotifNameUtils::GetDeviceDisplayName( devName, iDevice ); 
     if (iPasskeyLength > 0)  //Minimum length passkey is defined
         {
-        CDesCArray* stringArray = new ( ELeave ) CDesCArrayFlat( 1 );
-        CleanupStack::PushL( stringArray );
-        CArrayFix<TInt>* indexArray = new(ELeave) CArrayFixFlat<TInt>(1);
-        CleanupStack::PushL( indexArray ); 
+        BluetoothUiUtil::LoadResourceAndSubstringL( 
+                aRBuf, R_BT_MIN_PASSKEY_PROMPT, devName, 1 );
 
-        stringArray->AppendL( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName()) );   
-        indexArray->AppendL( iPasskeyLength);   
-        prompt = StringLoader::LoadL( R_BT_MIN_PASSKEY_PROMPT, *stringArray, *indexArray );
-
-        CleanupStack::PopAndDestroy( indexArray );
-        CleanupStack::PopAndDestroy( stringArray );
-        CleanupStack::PushL( prompt );
+        RBuf tmpBuf;
+        tmpBuf.CleanupClosePushL();
+        tmpBuf.Swap( aRBuf );
+        aRBuf.ReAllocL( aRBuf.MaxLength() + sizeof(TUint));
+        aRBuf.Zero();
+        // Passkey length should be localized, hope StringLoader can make it:
+        StringLoader::Format( aRBuf, tmpBuf, 0, iPasskeyLength );
+        CleanupStack::PopAndDestroy( &tmpBuf );
         }
     else
         {
-        prompt = StringLoader::LoadLC( R_BT_PASSKEY_PROMPT, devName );
+        BluetoothUiUtil::LoadResourceAndSubstringL( 
+                aRBuf, R_BT_PASSKEY_PROMPT, devName, 0 );
         }
-    FLOG(_L("[BTNOTIF]\t CBTPinNotifier::GenerateQueryPromoptLC() <<"));
-    return prompt;
+    FLOG(_L("[BTNOTIF]\t CBTPinNotifier::GenerateQueryPromptLC() <<"));
     }
 // End of File
--- a/bluetoothengine/btnotif/src/BTNotifier.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/src/BTNotifier.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -31,7 +31,7 @@
 #include <BTNotif.rsg>       // Own resources
 #include <featmgr.h>            // Feature Manager API
 #include <utf.h>             // CnvUtfConverter
-
+#include <bluetoothuiutil.h>
 #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,6 +490,10 @@
     iDevice->DeleteLinkKey();
  
     iBTRegistryQueryState = ESetDeviceBlocked;
+    if( !iDevMan )
+        {
+        iDevMan = CBTEngDevMan::NewL( this );    
+        }
     TInt devManErr = iDevMan->ModifyDevice( *iDevice );     
             
     // if error, complete message, otherwise waiting for devman callback
@@ -496,6 +511,10 @@
     iDevice->SetGlobalSecurity(sec);
  
     iBTRegistryQueryState = ESetDeviceAuthorizeState;
+    if( !iDevMan )
+        {
+        iDevMan = CBTEngDevMan::NewL( this );    
+        }
     TInt devManErr = iDevMan->ModifyDevice( *iDevice );     
             
     // if error, complete message, otherwise waiting for devman callback
--- a/bluetoothengine/btnotif/src/btnenterpriseitsecurityinfonotifier.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/src/btnenterpriseitsecurityinfonotifier.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -18,7 +18,7 @@
 // INCLUDE FILES
 #include <BTNotif.rsg>								// Own resources
 #include "btnenterpriseitsecurityinfonotifier.h"	// Own class definition
-#include "BTNotifDebug.h"							// Debugging macros
+#include "btNotifDebug.h"							// Debugging macros
 #include <tulstringresourcereader.h>
 #include <e32cmn.h>
 #include <dcmo.rsg>
--- a/bluetoothengine/btnotif/src/btnotifuiutil.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/src/btnotifuiutil.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -17,12 +17,12 @@
 
 #include <bautils.h>         // BAFL utils (for language file)
 #include "btnotifuiutil.h"
-#include "BTNotifDebug.h"    // Debugging macros
-#include <stringloader.h>    // Localisation stringloader
-#include <AknNoteWrappers.h> // Information note
+#include "btNotifDebug.h"    // Debugging macros
+#include <StringLoader.h>    // Localisation stringloader
+#include <aknnotewrappers.h> // Information note
 #include <aknmessagequerydialog.h> // for the blocking query
-#include <aknmediatorfacade.h>  // CoverUI 
-#include <CoreApplicationUIsDomainPSKeys.h>  // Backlight control
+#include <AknMediatorFacade.h>  // CoverUI 
+#include <coreapplicationuisdomainpskeys.h>  // Backlight control
 #include <AknNotiferAppServerApplication.h>  // Application Key enable/disable
 
 CBTNotifUIUtil* CBTNotifUIUtil::NewL( TBool aCoverDisplayEnabled )
--- a/bluetoothengine/btnotif/src/btnpaireddevsettnotifier.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/src/btnpaireddevsettnotifier.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -18,22 +18,22 @@
 
 // INCLUDE FILES
 
-#include <stringloader.h>       // Localisation stringloader
 #include <BTNotif.rsg>          // Own resources
 #include <btnotif.h>
+#include <bluetoothuiutil.h>
 #include "btnotiflock.h"
-#include "btnpaireddevsettNotifier.h"      // Own class definition
-#include "BTNotifDebug.h"       // Debugging macros
+#include "btnpaireddevsettnotifier.h"      // Own class definition
+#include "btNotifDebug.h"       // Debugging macros
 #include <bluetooth/hci/hcierrors.h>
 #include "btnotifnameutils.h"
 
-#include <secondarydisplay/BTnotifSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
 
 #include <e32cmn.h>
-#include <aknmediatorfacade.h>  // CoverUI 
+#include <AknMediatorFacade.h>  // CoverUI 
 
 #ifdef __SERIES60_HELP
-#include <HLPLCH.H>
+#include <hlplch.h>
 #include <csxhelp/bt.hlp.hrh> // The bt hrh info is needed, for help launching
 #endif
 
@@ -127,26 +127,23 @@
     TBTDeviceName name;
     BtNotifNameUtils::GetDeviceDisplayName(name, iDevice);
     
+    RBuf stringholder;
+    stringholder.CleanupClosePushL();
+    
     // 1. Show pairing status note
     FTRACE(FPrint(_L("[BTNOTIF]\t CBTPairedDevSettNotifier iPairingStatus: %d"), iPairingStatus));
     TInt resourceId = ProcessPairingErrorCode( iPairingStatus );    
-    HBufC* stringholder = StringLoader::LoadLC( resourceId );
-    _LIT(PU,"%U");
-    if( stringholder->Find(PU) != KErrNotFound)
-        {
-        CleanupStack::PopAndDestroy( stringholder );
-        stringholder = StringLoader::LoadLC( resourceId, name );
-        }   
-    
+    BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, resourceId, name, 0 );
+
     if (!iPairingStatus)
         {
-        iNotifUiUtil->ShowConfirmationNoteL( ETrue, *stringholder, iSecondaryDisplayCommand, name );
+        iNotifUiUtil->ShowConfirmationNoteL( ETrue, stringholder, iSecondaryDisplayCommand, name );
         }
     else
         {
-        iNotifUiUtil->ShowErrorNoteL( ETrue, *stringholder, iSecondaryDisplayCommand, name );
+        iNotifUiUtil->ShowErrorNoteL( ETrue, stringholder, iSecondaryDisplayCommand, name );
         }
-    CleanupStack::PopAndDestroy( stringholder ); // stringholder
+    CleanupStack::PopAndDestroy( &stringholder );
       
     if( iPairingStatus || (iDevice && iDevice->GlobalSecurity().Banned() ) )
         {
--- a/bluetoothengine/btnotif/src/btnpairnotifier.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/src/btnpairnotifier.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -22,10 +22,10 @@
 #include <btextnotifierspartner.h> // new file introduced by xSymbian
 #endif
 
-#include <StringLoader.h>    // Localisation stringloader
 #include <utf.h>             // Unicode character conversion utilities
 #include <btengconnman.h>
 #include <BTNotif.rsg>       // Own resources
+#include <bluetoothuiutil.h>
 #include "btnpairnotifier.h"
 #include "btNotifDebug.h"
 #include "btnotifnameutils.h"
@@ -80,16 +80,17 @@
         {
         User::Leave(KErrInUse);
         }
-    else if ( AutoLockOnL() )
+
+    iMessage = (RMessage2)aMessage;
+    iReplySlot = aReplySlot;
+
+    if ( AutoLockOnL() )
         {
         // The phone is locked, access denied.
         //
         CompleteMessage(KErrCancel);
-        return;
         }
 
-    iMessage = (RMessage2)aMessage;
-    iReplySlot = aReplySlot;
     }
 
 // ----------------------------------------------------------
@@ -127,9 +128,11 @@
     // and user has not given a alias for device.   
         if( !iNotifUiUtil->IsQueryReleased() && !iDevice->IsValidFriendlyName() )
             {
-            HBufC* prompt = GenerateQueryPromoptLC();
-            iNotifUiUtil->UpdateQueryDlgL( *prompt );
-            CleanupStack::PopAndDestroy( prompt );
+            RBuf prompt;
+            prompt.CleanupClosePushL();
+            GenerateQueryPromptL( prompt );
+            iNotifUiUtil->UpdateQueryDlgL( prompt );
+            CleanupStack::PopAndDestroy( &prompt );
             }
         }
 
@@ -203,13 +206,16 @@
     
     TBTDeviceName devName;
     BtNotifNameUtils::GetDeviceDisplayName( devName, iDevice );
-    HBufC* prompt = StringLoader::LoadLC( R_BT_ACCEPT_PAIRING_REQUEST, devName );   
+    RBuf prompt;
+    prompt.CleanupClosePushL();
+    BluetoothUiUtil::LoadResourceAndSubstringL( 
+            prompt, R_BT_ACCEPT_PAIRING_REQUEST, devName, 0 );
 
-    TBTDeviceName nameCoverUi( KNullDesC );
+    devName.Zero();
     // Show query for use to accept/reject incoming pairing request
-    TInt keypress = iNotifUiUtil->ShowQueryL( *prompt, R_BT_GENERIC_QUERY, 
-             ECmdBTnotifUnavailable, nameCoverUi, CAknQueryDialog::EConfirmationTone );
-    CleanupStack::PopAndDestroy( prompt );
+    TInt keypress = iNotifUiUtil->ShowQueryL( prompt, R_BT_GENERIC_QUERY, 
+             ECmdBTnotifUnavailable, devName, CAknQueryDialog::EConfirmationTone );
+    CleanupStack::PopAndDestroy( &prompt );
 
     if( iMessage.IsNull() ) // cancelled by the stack
         {
@@ -236,11 +242,12 @@
     }
 
 // ----------------------------------------------------------
-// CBTNPairNotifierBase::GenerateQueryPromoptLC
+// CBTNPairNotifierBase::GenerateQueryPromptL
 // To be implemented in derived classes.
 // ----------------------------------------------------------
 //
-HBufC* CBTNPairNotifierBase::GenerateQueryPromoptLC()
+void CBTNPairNotifierBase::GenerateQueryPromptL(  RBuf& aRBuf )
     {
-    return NULL;
+    FLOG(_L("[BTNOTIF]\t CBTNPairNotifierBase::GenerateQueryPromptL WARNING "));
+    (void) aRBuf;
     }
--- a/bluetoothengine/btnotif/src/btnssppasskeyentrynotifier.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/src/btnssppasskeyentrynotifier.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -31,7 +31,7 @@
 #endif
 #include <BTNotif.rsg>       // Own resources
 #include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
-
+#include <bluetoothuiutil.h>
 #include "btnotif.hrh"       // Own resource header
 #include "btnssppasskeyentrynotifier.h"  // Own class definition
 #include "btNotifDebug.h"    // Debugging macros
@@ -184,9 +184,11 @@
         }
     if ( !iNotifUiUtil->IsQueryReleased() )
         {
-        HBufC* update = GenerateQueryPromoptLC();
-        iNotifUiUtil->UpdateQueryDlgL( *update );
-        CleanupStack::PopAndDestroy( update ); 
+        RBuf prompt;
+        prompt.CleanupClosePushL();
+        GenerateQueryPromptL( prompt );
+        iNotifUiUtil->UpdateQueryDlgL( prompt );
+        CleanupStack::PopAndDestroy( &prompt ); 
         }        
     
     FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::UpdateL() completed"));
@@ -226,11 +228,14 @@
     iBuf.Zero();
     iBuf.Append(iPasskey);
     iBuf.Append(_L("    "));
-    HBufC* prompt = GenerateQueryPromoptLC();
     
-    TInt answer = iNotifUiUtil->ShowQueryL( *prompt, R_BT_PASSKEY_QUERY, 
+    RBuf prompt;
+    prompt.CleanupClosePushL();
+    GenerateQueryPromptL( prompt );
+    
+    TInt answer = iNotifUiUtil->ShowQueryL( prompt, R_BT_PASSKEY_QUERY, 
             ECmdBTnotifUnavailable, nameCoverUi );    
-    CleanupStack::PopAndDestroy( prompt );  
+    CleanupStack::PopAndDestroy( &prompt );  
 
     if( iAnswer ) // user pressed entry key from remote keyboard.
         {
@@ -260,23 +265,18 @@
     }
 
 // ----------------------------------------------------------
-// CBTSSPPasskeyEntryNotifier::GenerateQueryPromoptLC
+// CBTSSPPasskeyEntryNotifier::GenerateQueryPromptL
 // ----------------------------------------------------------
 //
-HBufC* CBTSSPPasskeyEntryNotifier::GenerateQueryPromoptLC()
+void CBTSSPPasskeyEntryNotifier::GenerateQueryPromptL(  RBuf& aRBuf )
     {
-    FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::GenerateQueryPromoptLC()"));
+    FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::GenerateQueryPromptL()"));
     TBTDeviceName devName; 
     BtNotifNameUtils::GetDeviceDisplayName(devName, iDevice);   
-    
-    CPtrCArray* subsPrompt = new (ELeave) CPtrCArray(2);
-    CleanupStack::PushL( subsPrompt );
-    subsPrompt->AppendL( devName );
-    subsPrompt->AppendL( iBuf );
-    HBufC* prompt = StringLoader::LoadL( R_BT_SSP_PASSKEY_ENTRY , *subsPrompt );
-    CleanupStack::PopAndDestroy( subsPrompt );
-    CleanupStack::PushL( prompt );
-    FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::GenerateQueryPromoptLC() << "));
-    return prompt;
+    BluetoothUiUtil::LoadResourceAndSubstringL( 
+            aRBuf, R_BT_SSP_PASSKEY_ENTRY, devName, 0 );
+    BluetoothUiUtil::AddSubstringL( aRBuf, iBuf, 1 );
+    FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::GenerateQueryPromptL() << "));
+
     }
 // End of File
--- a/bluetoothengine/btnotif/src/btnumcmpnotifier.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btnotif/src/btnumcmpnotifier.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -33,6 +33,7 @@
 #include <btotgpairpub.inl>
 #include <btengconnman.h>
 #include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
+#include <bluetoothuiutil.h>
 #include "btnotifnameutils.h"
 
 #ifdef __SERIES60_HELP
@@ -154,9 +155,11 @@
 	// For outgoing pairing request or accepted incoming pairing request,
 	// ask user to compare the pincodes in two devices.
 	TBTDeviceName nameCoverUi( KNullDesC );
-	HBufC* prompt = GenerateQueryPromoptLC(); 
-    TInt answer = iNotifUiUtil->ShowQueryL( *prompt, R_BT_GENERIC_QUERY, ECmdShowBtOpenCoverNote, nameCoverUi );   
-	CleanupStack::PopAndDestroy( prompt ); 
+    RBuf prompt;
+    prompt.CleanupClosePushL();
+    GenerateQueryPromptL( prompt );
+    TInt answer = iNotifUiUtil->ShowQueryL( prompt, R_BT_GENERIC_QUERY, ECmdShowBtOpenCoverNote, nameCoverUi );   
+	CleanupStack::PopAndDestroy( &prompt ); 
 	
     if( answer )
         {
@@ -187,20 +190,18 @@
     }
 
 // ----------------------------------------------------------
-// CBTNumCmpNotifier::GenerateQueryPromoptLC
+// CBTNumCmpNotifier::GenerateQueryPromptL
 // Generate prompt for Numeric Comparison query and return.
 // ----------------------------------------------------------
 //
-HBufC* CBTNumCmpNotifier::GenerateQueryPromoptLC()
+void CBTNumCmpNotifier::GenerateQueryPromptL( RBuf& aRBuf )
     {
-    FLOG(_L("[BTNOTIF]\t CBTNumCmpNotifier::GenerateQueryPromoptLC()"));
+    FLOG(_L("[BTNOTIF]\t CBTNumCmpNotifier::GenerateQueryPromptL()"));
     TBTDeviceName devName;
     BtNotifNameUtils::GetDeviceDisplayName( devName, iDevice );
-    
-    CPtrCArray* subs = new (ELeave) CPtrCArray(2);
-    CleanupStack::PushL( subs );
     TBuf<KBTDeviceShortNameLength> shortName;
     
+    TPtrC namePtr;
     // Cut the name and put ellipsis in the middle if necessary
     // By example "SampleSymbianDevice" after this operation will be shown in
     // the dialog as "Sam...ice"(for 7 chars device name limit)
@@ -215,18 +216,20 @@
         //adding only end of the name to the final string
         shortName.Append( devName.Right( shortName.MaxLength() - 
                           shortName.Length() ) );
-        subs->AppendL( shortName );
+        namePtr.Set( shortName );
         }
     else
         {
-        subs->AppendL( devName );
+        namePtr.Set( devName );
         }
-    subs->AppendL( iPasskeyToShow );
-    HBufC* prompt = StringLoader::LoadL( R_BT_SSP_PASSKEY_COMPARISON_PROMPT, *subs );
-    CleanupStack::PopAndDestroy( subs );
-    CleanupStack::PushL( prompt );
-    FLOG(_L("[BTNOTIF]\t CBTNumCmpNotifier::GenerateQueryPromoptLC() <<"));
-    return prompt;
+
+    BluetoothUiUtil::LoadResourceAndSubstringL( 
+            aRBuf, R_BT_SSP_PASSKEY_COMPARISON_PROMPT, namePtr, 0 );
+    // Numeric comparison key shall not be localized either, use our own
+    // string loading:
+    BluetoothUiUtil::AddSubstringL( aRBuf, iPasskeyToShow, 1);
+    FLOG(_L("[BTNOTIF]\t CBTNumCmpNotifier::GenerateQueryPromptL() <<"));
+
     }
 
 // End of File
--- a/bluetoothengine/btui/Ecom/group/bld.inf	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btui/Ecom/group/bld.inf	Fri Feb 19 22:59:18 2010 +0200
@@ -20,10 +20,8 @@
 
 PRJ_PLATFORMS
 
-
 PRJ_EXPORTS
 
-
 PRJ_MMPFILES
 ./BtuiPlugin.mmp 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btui/Ecom/inc/bluetoothuiutil.h	Fri Feb 19 22:59:18 2010 +0200
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   This provides utility for loading a BT device name without
+* localised to a string to be shown in GUI.
+*
+*/
+#include <StringLoader.h>
+
+class BluetoothUiUtil
+    {
+public:
+
+/*
+ * Gets the starting position of a key whose pattern matches
+ * '%'{(0)*|<n>}<aKey> where 0 and <n> is the decimal value 
+ * of the specified position and <aKey> is the symbol of the key, 
+ * either 'U' or 'N'.
+ * 
+ * For example, if the specified position of a number key 
+ * is 0, both "%N" and "%0N" match, 
+ * but "%1N" doesn't. If the position n is greater than 0, 
+ * only "%<n>N" matches.
+ * @param aDes the descriptor where a key parameter will be searched.
+ * @param aKey the specified key, 'U' or 'N'
+ * @param aKeyPos the position of the key. position starts from 0.
+ * @param aKeyLength the length of the key at return if the key exists.
+ * @return the start position of the key in aDes. KErrNotFound if the key
+ *          is not available.
+ */
+inline static TInt GetSubstringKeyPos( const TDes& aDes, const TDesC& aKey, 
+        TInt aKeyPos, TInt& aKeyLength );
+
+/*
+ * Gets the starting position of a string key whose pattern matches
+ * '%'{(0)*|<n>}'U' where 0 and <n> is the decimal value 
+ * of the specified position. 
+ * 
+ * For example, if the specified position is 0, both "%U" and "%0U" match, 
+ * but "%1U" doesn't. If the position n is greater than 0, 
+ * only "%<n>U" matches.
+ * @param aDes the descriptor in which a string key will be searched.
+ * @param aKeyPos the position of the string key. position starts from 0.
+ * @param aKeyLength the length of the string key at return if the key exists.
+ * @return the start position of the string key in aDes. KErrNotFound if the key
+ *          is not available.
+ */
+inline static TInt GetStringSubstringKeyPos( const TDes& aDes, TInt aKeyPos, TInt& aKeyLength );
+
+/*
+ * Add a substring to the specified RBuf descriptor.
+ * ( Replace "%<n>U" at the specified position withe the given string.
+ * @param aBuf the RBuf descriptor in which a "%<n>U" will be replaced.
+ * @param aSub the substring that will replace a "%<n>U".
+ * @param aSubPos the position of the "%U" to be replaced. Position starts from 0.
+ */
+inline static void AddSubstringL( RBuf& aBuf, const TDesC& aSub, TInt aSubPos);
+
+/*
+ * Load a string specified by the given resource ID, 
+ * remove substrings that match "[" and ends with "]" and finally
+ * replace the "%U" or "%<n>U" at the specified position with the
+ * given substring.
+ * 
+ * This function is intended for adding a Bluetooth device name to a UI 
+ * string but without localizing this name.
+ * 
+ * (Using StringLoader will get the device name localized in some variants. 
+ * This is a workaround to tackle the unwanted localization.)
+ * 
+ * @param aBuf the RBuf descriptor in which a "%<n>U" will be replaced.
+ * @param aSub the substring that will replace a "%<n>U".
+ * @param aSubPos the position of the "%U" to be replaced. Position starts from 0.
+ */
+inline static void LoadResourceAndSubstringL(RBuf& aBuf,
+        TInt aResourceId, const TDesC& aSub, TInt aSubPos );
+    };
+
+#include "bluetoothuiutil.inl"
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btui/Ecom/inc/bluetoothuiutil.inl	Fri Feb 19 22:59:18 2010 +0200
@@ -0,0 +1,103 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   This provides utility for loading a BT device name without
+* localised to a string to be shown in GUI.
+*
+*/
+
+inline TInt BluetoothUiUtil::GetSubstringKeyPos( 
+        const TDes& aDes, const TDesC& aKey, 
+        TInt aKeyPos, TInt& aKeyLength )
+    {
+    ASSERT( aKeyPos > KErrNotFound );
+    _LIT(KPercentSymbol, "%" );
+    // 32 would be to fit any key substring in practice:
+    TBuf<32> key;
+    TInt pos( KErrNotFound );
+    // if the specified position is 0, check if "%<aKey>" (%U or %N) exists.
+    if ( aKeyPos == 0 )
+        {
+        key.Copy( KPercentSymbol );
+        key.Append(aKey);
+        pos = aDes.Find( key );
+        }
+    // Either the key is not found, or aKeyPos is not 0.
+    if ( pos == KErrNotFound )
+        {
+        key.Copy( KPercentSymbol );
+        key.AppendNum( aKeyPos );
+        key.Append( aKey );
+        pos = aDes.Find( key );
+        }
+    if ( pos > KErrNotFound )
+        {
+        aKeyLength = key.Length();
+        }
+    return pos;
+    }
+
+inline TInt BluetoothUiUtil::GetStringSubstringKeyPos( 
+        const TDes& aDes, TInt aKeyPos, TInt& aKeyLength )
+    {
+    _LIT(KStringKeyword,"U");
+    TPtrC ptr( KStringKeyword );
+    return GetSubstringKeyPos(aDes, ptr, aKeyPos, aKeyLength );
+    }
+
+inline void BluetoothUiUtil::AddSubstringL( 
+        RBuf& aBuf, const TDesC& aSub, TInt aSubPos)
+    {
+    // Find the position of the specified "%U" or %[0-9]U in aBuf.
+    TInt keyLength;
+    TInt pos = GetStringSubstringKeyPos( aBuf, aSubPos, keyLength );
+    if ( pos == KErrNotFound )
+        {
+        User::Leave( pos );
+        }
+    // Enlarge the max length of aBuf if needed:
+    TInt reqedLen = aBuf.Length() - keyLength + aSub.Length();
+    if ( aBuf.MaxLength() <  reqedLen )
+        {
+        aBuf.ReAllocL( reqedLen );
+        }
+    aBuf.Replace( pos, keyLength, aSub );
+    }
+
+inline void BluetoothUiUtil::LoadResourceAndSubstringL(RBuf& aBuf,
+        TInt aResourceId, const TDesC& aSub, TInt aSubPos )
+    {
+    HBufC* string = StringLoader::LoadL( aResourceId );
+    aBuf.Assign( string );
+    // Logical loc strings may contain redundant "[<chars>]" for some reason.
+    // This sub-string should be removed in our ad hoc parameter loading method.
+    _LIT( KLeftSquareBracket,"[" );
+    _LIT( KRightSquareBracket,"]" );
+    while ( 1 )
+        {
+        TInt lpos = aBuf.Find( KLeftSquareBracket );
+        TInt rpos = aBuf.Find( KRightSquareBracket );
+        if ( lpos > KErrNotFound && rpos > KErrNotFound && ( rpos > lpos ) )
+            {
+            aBuf.Delete(lpos, rpos - lpos + 1 );
+            continue;
+            }
+        // No sub-strings that match "[" and ends with "]". Done
+        break;
+        }
+    // Add the substring to this string loaded from resource:
+    AddSubstringL( aBuf,  aSub, aSubPos );
+    }
+
+// End of File
+
--- a/bluetoothengine/btui/Ecom/src/BTUIBlockedDevicesView.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btui/Ecom/src/BTUIBlockedDevicesView.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -36,7 +36,9 @@
 
 #include <gstabhelper.h>
 #include <btui.mbg>						// Tab icon for General Setting
+#include <bluetoothuiutil.h>
 #include "BTUIMainView.h" 				// base View.
+
 // ---------------------------------------------------------
 // CBTUIBlockedDevicesView::ConstructL
 // Symbian 2nd phase constructor can leave.
@@ -177,12 +179,16 @@
         	TBTDevice device;
             device.iIndex = bItemIndex;
         	iModel->GetDevice(device);
-        	        	
+        	
+        	RBuf s;
+        	CleanupClosePushL( s );
+        	BluetoothUiUtil::LoadResourceAndSubstringL(
+        	        s, R_BT_WARN_ERASE_BLOCKED, device.iName, 0);
+        	
         	CAknQueryDialog* dialog = CAknQueryDialog::NewL(CAknQueryDialog::EConfirmationTone);
-        	HBufC* s = StringLoader::LoadLC(R_BT_WARN_ERASE_BLOCKED,device.iName);
-			TInt keypress = dialog->ExecuteLD(R_BT_GENERIC_QUERY, *s);
+			TInt keypress = dialog->ExecuteLD(R_BT_GENERIC_QUERY, s);
 
-			CleanupStack::PopAndDestroy(s);
+			CleanupStack::PopAndDestroy(&s);
 
 			if(keypress)  // User has accepted the dialog
 			    {
--- a/bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -48,8 +48,10 @@
 
 #include <gstabhelper.h>
 #include <btui.mbg>						// Tab icon for General Setting
+#include <bluetoothuiutil.h>
 #include "BTUIMainView.h" 				// base View.
 
+
 const TInt KAutoConnect2ndTry = 1;
 const TUint32 SetExcludePairedDeviceMask = 0x800000;
 
@@ -620,20 +622,15 @@
     device.iIndex = index;
     iModel->GetDevice(device);
 
-    HBufC* stringholder = NULL;
+    RBuf stringholder;
+    CleanupClosePushL( stringholder );
 
 	TInt tmp=EStatusBtuiConnected|EStatusPhysicallyConnected;
     // Choose confirmation phrase
-    //
-    if ( device.iStatus & tmp )
-        {
-        stringholder = StringLoader::LoadLC(R_BT_WARN_ERASE_CONNECTED, 
-        	device.iName);
-        }
-    else
-        {
-        stringholder = StringLoader::LoadLC(R_BT_WARN_ERASE, device.iName );
-        }    
+    TInt resourceId = ( device.iStatus & tmp ) ? R_BT_WARN_ERASE_CONNECTED :
+        R_BT_WARN_ERASE;
+    BluetoothUiUtil::LoadResourceAndSubstringL( 
+            stringholder, resourceId, device.iName, 0 );
 
     // Create confirmation query
     //
@@ -653,9 +650,9 @@
 		    covercl->BufStream().CommitL(); // no more data to send so commit buf
 		    }  
 		}
-    TInt keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_QUERY, *stringholder);
+    TInt keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_QUERY, stringholder);
 
-    CleanupStack::PopAndDestroy(stringholder);  // stringholder
+    CleanupStack::PopAndDestroy(&stringholder);  // stringholder
 
     if(keypress)  // User has accepted the dialog
         {
@@ -772,19 +769,23 @@
 		
 	HBufC* header= iCoeEnv->AllocReadResourceLC(R_BT_OPTION_BLOCK_DEVICE_HEADER); 
 	
-	HBufC* stringHolder = NULL;
+	RBuf stringHolder;
+	CleanupClosePushL( stringHolder );
+	TInt resouseId;
 	if (device.iStatus & (EStatusBtuiConnected|EStatusPhysicallyConnected) )
-		 stringHolder = StringLoader::LoadLC(
-		 (iHelpEnabled? R_BT_OPTION_BLOCK_CONNECTED_PAIRED_DEVICES_HELP:
-		  R_BT_OPTION_BLOCK_CONNECTED_PAIRED_DEVICES_NOHELP ), 
-		 device.iName);
+	    {
+	    resouseId = iHelpEnabled? R_BT_OPTION_BLOCK_PAIRED_DEVICE_HELP : 
+            R_BT_OPTION_BLOCK_PAIRED_DEVICE_NOHELP;
+	    }
 	else
-		stringHolder = StringLoader::LoadLC(
-		 (iHelpEnabled?R_BT_OPTION_BLOCK_PAIRED_DEVICE_HELP:R_BT_OPTION_BLOCK_PAIRED_DEVICE_NOHELP),
-		 device.iName);
+	    {
+	    resouseId = iHelpEnabled ? R_BT_OPTION_BLOCK_PAIRED_DEVICE_HELP :
+            R_BT_OPTION_BLOCK_PAIRED_DEVICE_NOHELP;
+	    }
+	BluetoothUiUtil::LoadResourceAndSubstringL( 
+	        stringHolder, resouseId, device.iName, 0 );
 	
-	
-	CAknMessageQueryDialog *queryDialog = CAknMessageQueryDialog::NewL (*stringHolder, 
+	CAknMessageQueryDialog *queryDialog = CAknMessageQueryDialog::NewL (stringHolder, 
 	  CAknQueryDialog::EConfirmationTone);		
 	queryDialog->PrepareLC(R_BT_MESSAGE_QUERY);
 	
@@ -816,7 +817,7 @@
         keypress = queryDialog->RunLD();
         }
 	
-	CleanupStack::PopAndDestroy(stringHolder);  				 
+	CleanupStack::PopAndDestroy(&stringHolder);  				 
 	CleanupStack::PopAndDestroy(header);
 	        
 	if(keypress)
@@ -978,11 +979,14 @@
 		TSecondaryDisplayBtuiDialogs aSec,const TDesC& aDevName)
 	{
 	TRAPD(err,
-		HBufC* stringholder = StringLoader::LoadLC(aNoteTextResource , aDevName );
+	        RBuf stringholder;
+	        CleanupClosePushL( stringholder );
+	        BluetoothUiUtil::LoadResourceAndSubstringL( 
+	                stringholder, aNoteTextResource, aDevName, 0 );
 	    aWaitDialog = new (ELeave) CAknWaitDialog(
                     reinterpret_cast<CEikDialog**>(&aWaitDialog), ETrue);
 	    aWaitDialog->PrepareLC(aNoteResource);
-	    aWaitDialog->SetTextL(*stringholder);
+	    aWaitDialog->SetTextL(stringholder);
 
 	    if(iCoverDisplayEnabled)
 	        {
@@ -998,7 +1002,7 @@
 	    aWaitDialog->SetCallback(this); // for capturing Cancel keypress	            
 	    aWaitDialog->RunLD();
 	    
-    	CleanupStack::PopAndDestroy(stringholder); // stringholder
+    	CleanupStack::PopAndDestroy(&stringholder); // stringholder
     );
     // if the above functions leaves the iWaitNote is deleted, but
     // not set to NULL. This will cause a problem, when
@@ -1068,8 +1072,11 @@
 	iDisconnectQueryDevice = device;//remember device related with query dialog
 
     // Create confirmation query
-    HBufC* stringholder = StringLoader::LoadLC(R_BT_DISCONNECT_FROM, device.iName);
-    if (!iDisconnectQueryDlg)
+    RBuf stringholder;
+    CleanupClosePushL( stringholder );
+    BluetoothUiUtil::LoadResourceAndSubstringL( 
+            stringholder, R_BT_DISCONNECT_FROM, device.iName, 0 );
+    if ( !iDisconnectQueryDlg )
         {
         iDisconnectQueryDlg = CAknQueryDialog::NewL();
         }
@@ -1086,9 +1093,9 @@
 		    }  
 		}
 			
-    TInt keypress = iDisconnectQueryDlg->ExecuteLD(R_BT_DISCONNECT_FROM_QUERY, *stringholder);
+    TInt keypress = iDisconnectQueryDlg->ExecuteLD(R_BT_DISCONNECT_FROM_QUERY, stringholder);
 
-    CleanupStack::PopAndDestroy(stringholder);  // stringholder
+    CleanupStack::PopAndDestroy(&stringholder);  // stringholder
 
 	iDisconnectQueryDlg = NULL;
     if(keypress)  // User has accepted the dialog
@@ -1189,22 +1196,22 @@
             break;
         case KErrAlreadyExists:	// connection exists allready
         	{
-          	HBufC* stringholder = NULL;
+          	RBuf stringholder;
+          	CleanupClosePushL( stringholder );
           	if(aConflictingDeviceNames && aConflictingDeviceNames->Count()> 0)
         		{        		
         		if(aConflictingDeviceNames->Count() == 1)
         			{
-        			stringholder=StringLoader::LoadLC(R_BT_DISCONNECT_FIRST_PROMPT,
-        			  *(*aConflictingDeviceNames)[0],iCoeEnv );	
+        			BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, 
+        			        R_BT_DISCONNECT_FIRST_PROMPT, 
+        			        *(*aConflictingDeviceNames)[0], 0 );
         			}
         		else
         			{
-        			CPtrC16Array* aa=new(ELeave) CPtrC16Array(1+1);
-       				aa->InsertL(0, *(*aConflictingDeviceNames)[0] );
-        			aa->InsertL(1, *(*aConflictingDeviceNames)[1] );
-        			stringholder=StringLoader::LoadLC(R_BT_DISCONNECT_FIRST_STEREO_PROMPT ,
-        			  *aa,iCoeEnv);
-        			delete(aa);        					
+        			BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, 
+                        R_BT_DISCONNECT_FIRST_STEREO_PROMPT, 
+                        *(*aConflictingDeviceNames)[0], 0 );
+        			BluetoothUiUtil::AddSubstringL( stringholder, *(*aConflictingDeviceNames)[1], 1 );       					
         			}
         		TRACE_INFO(_L("KErrAllreadyExists"))      	  		  
           		}
@@ -1235,8 +1242,8 @@
 			    	}  
 				}
 		
-        	note->ExecuteLD(*stringholder);
-        	CleanupStack::PopAndDestroy(stringholder);
+        	note->ExecuteLD(stringholder);
+        	CleanupStack::PopAndDestroy(&stringholder);
         	}
         	break;	
 		case KErrServerBusy:
@@ -1261,68 +1268,28 @@
             //          
 			CAknInformationNote* notePtr = new (ELeave) CAknInformationNote();
 
-            HBufC* stringHolder = NULL;
+            RBuf stringHolder;
+            CleanupClosePushL( stringHolder );
+            
+            BluetoothUiUtil::LoadResourceAndSubstringL( stringHolder,
+                    R_BT_CONF_CONNECTED_PROMPT, aDevice.iName, 0 );
             
-			if (!FeatureManager::FeatureSupported(KFeatureIdAccessoryFw))
-				{
-            	if (CallOnGoing())
-                	{
-                	stringHolder = StringLoader::LoadLC(R_BT_AUDIOS_ACCESSORY_PROMPT); // qtn_bt_audio_accessory "Audio routed to BT handsfree"            
-                	
-                	if(iCoverDisplayEnabled)
-						{
-						CleanupStack::PushL(notePtr); 			
-				    	notePtr->PublishDialogL(ECmdBtuiShowBtAudioAccessory, KUidCoverUiCategoryBtui); // initializes cover support    
-						CleanupStack::Pop(notePtr); 
-						}
-					
-					notePtr->ExecuteLD(*stringHolder);
-	                }
-	            else
-	                {
-	                TRACE_INFO(_L("No call ongoing. Connected to"))
-	                stringHolder = StringLoader::LoadLC(R_BT_CONF_CONNECTED_PROMPT, aDevice.iName); // "Connected to %U"
-	                
-	                if(iCoverDisplayEnabled)
-						{
-						CleanupStack::PushL(notePtr); 			
-				    	notePtr->PublishDialogL(ECmdBtuiShowBtConfConnected, KUidCoverUiCategoryBtui); // initializes cover support    
-						CleanupStack::Pop(notePtr); 
+            if(iCoverDisplayEnabled)
+                    {
+                    CleanupStack::PushL(notePtr); 			
+                    notePtr->PublishDialogL(ECmdBtuiShowBtConfConnected, KUidCoverUiCategoryBtui); // initializes cover support    
+                    CleanupStack::Pop(notePtr); 
 
-						CAknMediatorFacade* covercl = AknMediatorFacade(notePtr); // uses MOP, so control provided 
-						if (covercl) // returns null if __COVER_DISPLAY is not defined
-					    	{	
-							  covercl->BufStream() <<  BTDeviceNameConverter::ToUTF8L(aDevice.iName);	
-							  covercl->BufStream().CommitL(); // no more data to send so commit buf
-					    	}  
-						}
-	                
-	                notePtr->ExecuteLD(*stringHolder);
-	                }           				
-                }
-            else
-                {
-                TRACE_INFO(_L("AccFW Supported. Connected to"))
-                stringHolder = StringLoader::LoadLC(R_BT_CONF_CONNECTED_PROMPT, aDevice.iName);
+                    CAknMediatorFacade* covercl = AknMediatorFacade(notePtr); // uses MOP, so control provided 
+                    if (covercl) // returns null if __COVER_DISPLAY is not defined
+                        {	
+                            covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName);	
+                          covercl->BufStream().CommitL(); // no more data to send so commit buf
+                        }  
+                    }
                 
-                if(iCoverDisplayEnabled)
-						{
-						CleanupStack::PushL(notePtr); 			
-				    	notePtr->PublishDialogL(ECmdBtuiShowBtConfConnected, KUidCoverUiCategoryBtui); // initializes cover support    
-						CleanupStack::Pop(notePtr); 
-
-						CAknMediatorFacade* covercl = AknMediatorFacade(notePtr); // uses MOP, so control provided 
-						if (covercl) // returns null if __COVER_DISPLAY is not defined
-					    	{	
-								covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName);	
-							  covercl->BufStream().CommitL(); // no more data to send so commit buf
-					    	}  
-						}
-	                
-	            notePtr->ExecuteLD(*stringHolder);
-                }           
-                
-            CleanupStack::PopAndDestroy(stringHolder);
+            notePtr->ExecuteLD(stringHolder);        
+            CleanupStack::PopAndDestroy(&stringHolder);
             }
             
             TRAP_IGNORE(LaunchSettingViewL();)
@@ -1330,13 +1297,17 @@
 
         case KErrNotSupported:
             {
-            TRACE_INFO(_L("error = KErrNotSupported"))			
-			
+            TRACE_INFO(_L("error = KErrNotSupported"))
+            
+            RBuf stringHolder;
+            CleanupClosePushL( stringHolder );
+            
+            BluetoothUiUtil::LoadResourceAndSubstringL( stringHolder,
+                    R_BT_DEVICE_NOT_SUPPORTED, aDevice.iName, 0 );
 			
 			// create note
 			//
 			CAknInformationNote* note = new (ELeave) CAknInformationNote();
-            HBufC* stringHolder = StringLoader::LoadLC(R_BT_DEVICE_NOT_SUPPORTED,aDevice.iName);
             
 			if(iCoverDisplayEnabled)
 				{
@@ -1351,8 +1322,8 @@
 						covercl->BufStream().CommitL(); // no more data to send so commit buf
 			    	}  
 				}
-			note->ExecuteLD(*stringHolder);
-        	CleanupStack::PopAndDestroy(stringHolder);
+			note->ExecuteLD(stringHolder);
+        	CleanupStack::PopAndDestroy(&stringHolder);
             }
             break;
 
@@ -1613,14 +1584,17 @@
         }
 	TRACE_FUNC_EXIT		
 	}
+
+
 // ------------------------------------------------------
 // CBTUIPairedDevicesView::ShowDisconnecNote
 // ------------------------------------------------------	
 void CBTUIPairedDevicesView::ShowDisconnecNoteL(TBTDevice *aDevice)
     {
-    HBufC* stringholder = StringLoader::LoadLC(
-      R_BT_DISCONNECT_FIRST_PROMPT, aDevice->iName);
-
+    RBuf stringholder;
+    CleanupClosePushL( stringholder );
+    BluetoothUiUtil::LoadResourceAndSubstringL( 
+            stringholder, R_BT_DISCONNECT_FIRST_PROMPT, aDevice->iName, 0 );
     // Launch a waiting confirmation note
     //
     CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote(ETrue);
@@ -1639,9 +1613,9 @@
         CleanupStack::Pop(note); 				
     	}
 
-    note->ExecuteLD(*stringholder);
+    note->ExecuteLD(stringholder);
 
-    CleanupStack::PopAndDestroy(stringholder); // stringholder    
+    CleanupStack::PopAndDestroy(&stringholder); // stringholder    
     
     }
 
--- a/bluetoothengine/btui/Ecom/src/BTUISap.cpp	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btui/Ecom/src/BTUISap.cpp	Fri Feb 19 22:59:18 2010 +0200
@@ -18,7 +18,6 @@
 
 #include <aknnotewrappers.h>
 #include <aknradiobuttonsettingpage.h>
-#include <StringLoader.h>	// localisation stringloader
 #include <BtuiViewResources.rsg>		// Compiled resource ids
 #include <BTSapDomainPSKeys.h>	
 #include <centralrepository.h> 
@@ -29,13 +28,13 @@
 #include <SecondaryDisplay/BtuiSecondaryDisplayAPI.h>
 #include <btfeaturescfg.h>					// For EnterpriseEnablementL()
 #include <btnotif.h>
-
+#include <utf.h>
+#include <bluetoothuiutil.h>
 #include "btdevmodel.h"
 
 #include "debug.h"
 #include "BTUIMainView.h"
 
-#include <utf.h>
 // ----------------------------------------------------
 // CBTUIMainView::SetSapStatusL
 // ----------------------------------------------------
@@ -72,26 +71,28 @@
 				{
 
 				// Create confirmation query
-				HBufC* stringholder = StringLoader::LoadLC( R_BT_DISCONNECT_FROM, connectedSap );
+				RBuf stringholder;
+				CleanupClosePushL( stringholder );
+				BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, 
+				        R_BT_DISCONNECT_FROM, connectedSap, 0 );
 				CAknQueryDialog* dlg = CAknQueryDialog::NewL();
 
 				if(iCoverDisplayEnabled)
 					{
 					CleanupStack::PushL(dlg); 						
 				    dlg->PublishDialogL(ECmdShowDisconnectQuery, KUidCoverUiCategoryBtui); // initializes cover support    
-					CleanupStack::Pop(dlg); 						
-
 					CAknMediatorFacade* covercl = AknMediatorFacade(dlg); // uses MOP, so control provided 
 					if (covercl) // returns null if __COVER_DISPLAY is not defined
 					    {	    
 					    covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(connectedSap);// takes copy so consts are ok too
 					    covercl->BufStream().CommitL(); // no more data to send so commit buf
-					    }  
+					    }
+					CleanupStack::Pop(dlg);
 					}
 					
-				TInt keypress = dlg->ExecuteLD( R_BT_DISCONNECT_FROM_QUERY, *stringholder );
+				TInt keypress = dlg->ExecuteLD( R_BT_DISCONNECT_FROM_QUERY, stringholder );
 
-				CleanupStack::PopAndDestroy(stringholder);	// stringholder
+				CleanupStack::PopAndDestroy(&stringholder);	// stringholder
 
 				if( keypress )	// User has accepted the dialog
 					{
--- a/bluetoothengine/btui/group/bld.inf	Tue Feb 02 00:20:42 2010 +0200
+++ b/bluetoothengine/btui/group/bld.inf	Fri Feb 19 22:59:18 2010 +0200
@@ -28,6 +28,8 @@
 ../rom/BtuiResources.iby LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(BtuiResources.iby)
 ../inc/BtuiPluginInterface.h |../../inc/BtuiPluginInterface.h
 ../inc/BtuiPluginInterface.inl |../../inc/BtuiPluginInterface.inl
+../Ecom/inc/bluetoothuiutil.h   |../../inc/bluetoothuiutil.h
+../Ecom/inc/bluetoothuiutil.inl |../../inc/bluetoothuiutil.inl
 // Help exports
 #include "../help/group/bld.inf"