Revision: 201001 PDK_3.0.f
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 26 Jan 2010 12:06:42 +0200
changeset 1 6a1fe72036e3
parent 0 f63038272f30
child 2 0b192a3a05a4
Revision: 201001 Kit: 201004
bluetoothappprofiles/avrcp/bluetooth_avrcp.mrp
bluetoothappprofiles/avrcp/mediabrowseapi/src/remconmediabrowsetargetbase.cpp
bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpMetadataTransfer.cpp
bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpplayerinfomanager.cpp
bluetoothengine/btaudioman/src/BTAccServer.cpp
bluetoothengine/bteng/bttoggle/src/bttoggle.cpp
bluetoothengine/bteng/inc/btengprivatepskeys.h
bluetoothengine/bteng/src/btengincpair.cpp
bluetoothengine/bthid/bthidserver/src/bthidserver.cpp
bluetoothengine/bthid/mouse/Sesame_client/data/cursormask.bmp
bluetoothengine/btmac/inc/btmonobearer/bmbcmdlistener.h
bluetoothengine/btmac/inc/btmonocmdhandler/btmcactive.h
bluetoothengine/btmac/inc/btmonocmdhandler/btmccallinghandler.h
bluetoothengine/btmac/src/BTMonoCmdHandler/btmcactive.cpp
bluetoothengine/btmac/src/BTMonoCmdHandler/btmccallinghandler.cpp
bluetoothengine/btmac/src/BTMonoCmdHandler/btmcprotocol.cpp
bluetoothengine/btmac/src/btmac/btmsconnect.cpp
bluetoothengine/btmac/src/btmonobearer/bmbcmdlistener.cpp
bluetoothengine/btsac/inc/btsacStateConfigured.h
bluetoothengine/btsac/inc/btsacStateConfiguring.h
bluetoothengine/btsac/inc/btsacStateConnected.h
bluetoothengine/btsac/inc/btsacStateConnecting.h
bluetoothengine/btsac/inc/btsacStateListening.h
bluetoothengine/btsac/inc/btsacStateStreaming.h
bluetoothengine/btsac/inc/btsacStateSuspended.h
bluetoothengine/btsac/inc/btsacStreamerController.h
bluetoothengine/btsac/inc/btsacdefs.h
bluetoothengine/btsac/src/btsacState.cpp
bluetoothengine/btsac/src/btsacStateConfigured.cpp
bluetoothengine/btsac/src/btsacStateConfiguring.cpp
bluetoothengine/btsac/src/btsacStateConnected.cpp
bluetoothengine/btsac/src/btsacStateConnecting.cpp
bluetoothengine/btsac/src/btsacStateListening.cpp
bluetoothengine/btsac/src/btsacStateStreaming.cpp
bluetoothengine/btsac/src/btsacStateSuspended.cpp
bluetoothengine/btsac/src/btsacStreamerController.cpp
bluetoothengine/btui/Ecom/data/BtuiViewResources.rss
bluetoothengine/btui/Ecom/inc/BTUIPairedDevicesView.h
bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp
--- a/bluetoothappprofiles/avrcp/bluetooth_avrcp.mrp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothappprofiles/avrcp/bluetooth_avrcp.mrp	Tue Jan 26 12:06:42 2010 +0200
@@ -1,9 +1,9 @@
-# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
 # All rights reserved.
 # This component and the accompanying materials are made available
-# under the terms of the License "Symbian Foundation License v1.0"
+# under the terms of "Eclipse Public License v1.0"
 # which accompanies this distribution, and is available
-# at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
 #
 # Initial Contributors:
 # Nokia Corporation - initial contribution.
--- a/bluetoothappprofiles/avrcp/mediabrowseapi/src/remconmediabrowsetargetbase.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothappprofiles/avrcp/mediabrowseapi/src/remconmediabrowsetargetbase.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -660,13 +660,13 @@
 		SendGetFolderItemsResponse(KErrAvrcpAirInvalidParameter, KNullDesC8);
 		return;
 		}
-
+	
 	if(request.iScope == AvrcpBrowsing::KSearchScope && !iSearchSupported)
-	    {
-        request.Close();
-        SendGetFolderItemsResponse(KErrAvrcpAirSearchNotSupported, KNullDesC8);
-        return;
-        }
+		{
+		request.Close();
+		SendGetFolderItemsResponse(KErrAvrcpAirSearchNotSupported, KNullDesC8);
+		return;
+		}
 	
 	if (request.CopyAttributes(iMediaAttributeIds) != KErrNone)
 		{
@@ -685,9 +685,9 @@
 		iScope = ENowPlayingFolder;
 		}
 	else if(request.iScope == AvrcpBrowsing::KSearchScope)
-        {
-        iScope = ESearchResultFolder;
-        }
+		{
+		iScope = ESearchResultFolder;
+		}
 	else
 		{
 		request.Close();
--- a/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpMetadataTransfer.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpMetadataTransfer.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -871,26 +871,30 @@
 TInt CControlCommand::GenerateMetadataGetCapabilitiesResponsePayloadL(MRemConBearerObserver& /* aObserver */, RBuf8& aFramePayload, const RBuf8& aResponseData)
 	{
 	LOG_FUNC
-	__ASSERT_DEBUG( iPlayerInfoManager != NULL, AvrcpUtils::Panic(EAvrcpNotFullyConstructed));
+	__ASSERT_DEBUG(iPlayerInfoManager, AVRCP_PANIC(EAvrcpNotFullyConstructed));
 	TPtr8 responseData = aResponseData.RightTPtr(aResponseData.Length() - KLengthErrorResponse);
 
 	if(responseData[KCapabilityIdOffset] == ECapabilityIdEventsSupported)
 		{
+		// Add supported events not handled in the player info API.
 		RBuf8 eventsBuf;
 		eventsBuf.CreateL(KNumberEventsNotInPlayerInfoApi);
 		CleanupClosePushL(eventsBuf);
 		TInt count = 0;
 		
-		// if ClientId has been set it means that we've told the remote that
-		// commands are being addressed to a particular player, so return
-		// player specific info.  Otherwise return generic support.
-		if(ClientId() == KNullClientId || iPlayerInfoManager->AbsoluteVolumeSupportedL(ClientId()))
+		// If a specific player (i.e. a specific client ID)  has been indicated then
+		// we add support for the event if supported by the specific player.
+		// If no specific player has been indicated (i.e. an invalid client ID), then
+		// general support for the event is added if supported by any player.
+		// The player info manager APIs handles these different "support" semantics.
+		
+		if(iPlayerInfoManager->AbsoluteVolumeSupportedL(ClientId()))
 			{
 			count++;
 			eventsBuf.Append(ERegisterNotificationVolumeChanged );
 			}
 		
-		if(ClientId() == KNullClientId || iPlayerInfoManager->BrowsingSupportedL(ClientId()))
+		if(iPlayerInfoManager->BrowsingSupportedL(ClientId()))
 			{
 			count += 2;
 			eventsBuf.Append(ERegisterNotificationNowPlayingContentChanged );
--- a/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpplayerinfomanager.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpplayerinfomanager.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -48,6 +48,20 @@
 	return (aId && *aId == aItem.iId);
 	}
 
+enum TFirstAbsVolSupport { EFirstAbsVolSupport };
+static TBool FirstAbsVolSupport(const TFirstAbsVolSupport*, const TAvrcpMediaPlayerItem& aItem)
+	{
+	LOG_STATIC_FUNC
+	return aItem.iId != KNullClientId && aItem.iAbsoluteVolumeSupport;
+	}
+
+enum TFirstBrowsingSupport { EFirstBrowsingSupport };
+static TBool FirstBrowsingSupport(const TFirstBrowsingSupport*, const TAvrcpMediaPlayerItem& aItem)
+	{
+	LOG_STATIC_FUNC
+	return aItem.iId != KNullClientId && (aItem.iSdpFeatures & AvrcpSdp::EBrowsing);
+	}
+
 CAvrcpPlayerInfoManager* CAvrcpPlayerInfoManager::NewL(MRemConBearerObserver& aObserver, MRemConCommandInterface& aCommandInterface)
 	{
 	LOG_STATIC_FUNC
@@ -176,8 +190,6 @@
 			}
 		}
 
-
-
 	if(!err)
 		{
 		for(TInt i = 0; i<iObservers.Count(); i++)
@@ -732,6 +744,15 @@
 		}
 	}
 
+/**
+If the client ID is set to a valid ID then we shall return the support
+status for the specific player referenced by the ID.
+Otherwise we shall return generic support which will indicate support across
+the device.
+@return whether absolute volume control is supported either by the specific player
+associated with a client ID, or generally by the device if an invalid client ID is
+provided.
+ */
 TBool CAvrcpPlayerInfoManager::AbsoluteVolumeSupportedL(const TRemConClientId& aClientId) const
 	{
 	LOG_FUNC
@@ -740,12 +761,25 @@
 	iLock.Wait();
 	CleanupSignalPushL(iLock);
 	
-	TInt index = iPlayers.Find(aClientId, PlayerCompare);
-	if(index < 0)
+	TBool supported = EFalse;
+	// If we receive a "NULL" client ID then it means that we should 
+	// return whether abs vol is generically supported by the device.
+	if(aClientId == KNullClientId)
 		{
-		LEAVEL(KErrNotFound);
+		// Try to find the first player supporting abs vol, if there is one then it is supported 
+		TInt index = iPlayers.Find(EFirstAbsVolSupport, FirstAbsVolSupport);
+		supported = (index >= 0);
 		}
-	TBool supported = iPlayers[index].iAbsoluteVolumeSupport;
+	else
+		{
+		// The abs vol support for a specific player is required, so return that.
+		TInt index = iPlayers.Find(aClientId, PlayerCompare);
+		if(index < 0)
+			{
+			LEAVEL(KErrNotFound);
+			}
+		supported = iPlayers[index].iAbsoluteVolumeSupport;
+		}
 	
 	CleanupStack::PopAndDestroy(&iLock);
 	
@@ -760,12 +794,25 @@
 	iLock.Wait();
 	CleanupSignalPushL(iLock);
 	
-	TInt index = iPlayers.Find(aClientId, PlayerCompare);
-	if(index < 0)
+	TBool supported = EFalse;
+	// If we receive a "NULL" client ID then it means that we should 
+	// return whether browsing is generically supported by the device.
+	if(aClientId == KNullClientId)
 		{
-		LEAVEL(KErrNotFound);
+		// Try to find the first player supporting browsing, if there is one then it is supported 
+		TInt index = iPlayers.Find(EFirstBrowsingSupport, FirstBrowsingSupport);
+		supported = (index >= 0);
 		}
-	TBool supported = iPlayers[index].iSdpFeatures & AvrcpSdp::EBrowsing;
+	else
+		{
+		// The browsing support for a specific player is required, so return that.
+		TInt index = iPlayers.Find(aClientId, PlayerCompare);
+		if(index < 0)
+			{
+			LEAVEL(KErrNotFound);
+			}
+		supported = iPlayers[index].iSdpFeatures & AvrcpSdp::EBrowsing;
+		}
 	
 	CleanupStack::PopAndDestroy(&iLock);
 	
--- a/bluetoothengine/btaudioman/src/BTAccServer.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btaudioman/src/BTAccServer.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-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"
@@ -58,9 +58,8 @@
     delete iAccMan;  
     delete iTimer;
     iSessions.Close();
-    
-    RProperty::Delete( KPSUidBluetoothEnginePrivateCategory, KBTATCodec );
-    
+    RProperty::Delete( KPSUidBluetoothEnginePrivateCategory, KBTHfpATCommand );
+    RProperty::Delete( KPSUidBluetoothEnginePrivateCategory, KBTHfpATResponse );
     TRACE_FUNC
     }
 
@@ -152,7 +151,11 @@
     iAccMan->LoadServicesL();
     
     User::LeaveIfError(RProperty::Define(KPSUidBluetoothEnginePrivateCategory,
-                                         KBTATCodec, RProperty::EByteArray,
+                                         KBTHfpATCommand, RProperty::EByteArray,
+                                         KBTEngPSKeyReadPolicy,
+                                         KBTEngPSKeyWritePolicy));
+    User::LeaveIfError(RProperty::Define(KPSUidBluetoothEnginePrivateCategory,
+                                         KBTHfpATResponse, RProperty::EByteArray,
                                          KBTEngPSKeyReadPolicy,
                                          KBTEngPSKeyWritePolicy));
     }
--- a/bluetoothengine/bteng/bttoggle/src/bttoggle.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/bteng/bttoggle/src/bttoggle.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -361,6 +361,5 @@
   {	  
   TRACE_INFO((_L("[BTENG][BTTOGGLE]RunL error %d"), aError ))		
   CActiveScheduler::Stop();
-
-  return aError;
+  return KErrNone;
   }
--- a/bluetoothengine/bteng/inc/btengprivatepskeys.h	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/bteng/inc/btengprivatepskeys.h	Tue Jan 26 12:06:42 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"
@@ -28,12 +28,12 @@
 
 
 /**
- * Publish and Subscribe key for passing serialized BT AT Codec 
- * between HFP RemCon Bearer and Command Handler.
+ * Publish and Subscribe key for passing BT HFP AT commands 
+ * from btmonocmdhandler to HFP RemCon Bearer.
  *
  * Default value (in binary format): ""
  */
-const TUint KBTATCodec = 0x01;
+const TUint KBTHfpATCommand = 0x01;
 
 
 /**
@@ -157,4 +157,12 @@
  */
 const TUint KBTNotifierLocks = 0x08;
 
+/**
+ * Publish and Subscribe key for the responses of BT HFP AT commands 
+ * from HFP RemCon Bearer to btmonocmdhandler.
+ *
+ * Default value (in binary format): ""
+ */
+const TUint KBTHfpATResponse = 0x09;
+
 #endif // BTENG_PRIVATE_PS_KEYS_H
--- a/bluetoothengine/bteng/src/btengincpair.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/bteng/src/btengincpair.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -80,8 +80,11 @@
     iPla.Close();
     iPairingOkTimer.Cancel();
     iPairingOkTimer.Close();
-    iActivePairingOk->CancelRequest();
-    delete iActivePairingOk;    
+    if(iActivePairingOk)
+        {
+        iActivePairingOk->CancelRequest();
+        delete iActivePairingOk;
+        }
     TRACE_FUNC_EXIT
     }
 
--- a/bluetoothengine/bthid/bthidserver/src/bthidserver.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/bthid/bthidserver/src/bthidserver.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -781,7 +781,10 @@
 
             // Get it to disconnect if its connected.
             connection->Disconnect();
-
+            
+            InformClientsOfStatusChange(connection->DeviceDetails(),
+                EBTDeviceDisconnected);
+            
             // Delete the connection object.
             iBTConnIndex->Remove(connection->ConnID());
 
@@ -818,7 +821,10 @@
 
                 // Get it to disconnect if its connected.
                 connection->Disconnect();
-
+                
+                InformClientsOfStatusChange(connection->DeviceDetails(),
+                    EBTDeviceDisconnected);
+                 
                 // Delete the connection object.
                 iBTConnIndex->Remove(connection->ConnID());
 
Binary file bluetoothengine/bthid/mouse/Sesame_client/data/cursormask.bmp has changed
--- a/bluetoothengine/btmac/inc/btmonobearer/bmbcmdlistener.h	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btmac/inc/btmonobearer/bmbcmdlistener.h	Tue Jan 26 12:06:42 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-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"
@@ -83,8 +83,11 @@
 	
         CBmbPlugin& iParent;
         
-        // for receiving AT commands from btmonocmdhandler and sending the responses
-		RProperty iProperty;
+        // for receiving AT commands from btmonocmdhandler
+		RProperty iATCmdProperty;
+		
+        // for sending AT responses to btmonocmdhandler
+        RProperty iATRespProperty;
 
 		// At command buffer
 		TBuf8<KMaxATSize> iAtCmdBuf;
--- a/bluetoothengine/btmac/inc/btmonocmdhandler/btmcactive.h	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcactive.h	Tue Jan 26 12:06:42 2010 +0200
@@ -73,6 +73,8 @@
         virtual void RunL();
         
         virtual void DoCancel();
+        
+        virtual TInt RunError(TInt aError);
 
     protected:
     
--- a/bluetoothengine/btmac/inc/btmonocmdhandler/btmccallinghandler.h	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmccallinghandler.h	Tue Jan 26 12:06:42 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-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"
@@ -81,9 +81,11 @@
     
     CBtmcActive* iActive;
     
+    // for sending AT commands to btmonobearer
     RProperty iCmdProperty;
-
-    TBool iBusy;
+    
+    // for receiving AT responses from btmonobearer
+    RProperty iRespProperty;
     
     TInt iCmdId; 
 };
--- a/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcactive.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcactive.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -81,7 +81,19 @@
     iObserver.RequestCompletedL(*this, iStatus.Int());
     TRACE_FUNC_EXIT
     }
-    
+
+// -------------------------------------------------------------------------------
+// CBtmcActive::RunError
+// This is really bad as we are just 'eating' the error not doing anything with it
+// This needs to re-evaluated and done better as later date.
+// -------------------------------------------------------------------------------
+TInt CBtmcActive::RunError(TInt aError)
+    {
+    TRACE_INFO((_L("Service %d RunError with %d"), iServiceId, aError))
+    (void) aError;
+    return KErrNone;
+    } 
+
 // -------------------------------------------------------------------------------
 // CBtmcActive::DoCancel
 // -------------------------------------------------------------------------------
--- a/bluetoothengine/btmac/src/BTMonoCmdHandler/btmccallinghandler.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmccallinghandler.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-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"
@@ -45,6 +45,7 @@
     {
     TRACE_FUNC_ENTRY
     delete iActive;
+    iRespProperty.Close();
     iCmdProperty.Close();
     TRACE_FUNC_EXIT
     }
@@ -53,7 +54,8 @@
 void CBtmcCallingHandler::HandleCallingCmdL(const CATCommand& aCmd)
     {
     TRACE_FUNC_ENTRY
-    TRACE_ASSERT(!iBusy, KErrInUse)
+    TRACE_ASSERT(!iActive->IsActive(), KErrInUse)
+    // Delegate the command to btmonobearer for processing
     TInt err = iCmdProperty.Set(aCmd.Des());
     if (err)
     	{
@@ -65,10 +67,9 @@
     	}
     else
         {
-        iBusy = ETrue;
+        // wait for the response from btmonobearer
         iCmdId = aCmd.Id();
-        iActive = CBtmcActive::NewL(*this, CActive::EPriorityStandard, KCallingResponse);
-        iCmdProperty.Subscribe(iActive->iStatus);
+        iRespProperty.Subscribe(iActive->iStatus);
         iActive->GoActive();
         }
     TRACE_FUNC_EXIT
@@ -76,12 +77,12 @@
 
 TBool CBtmcCallingHandler::ActiveCmdHandling() const
     {
-    return iBusy;
+    return iActive->IsActive();
     }
 
 TBool CBtmcCallingHandler::ActiveChldHandling() const
     {
-    return iBusy && ( iCmdId == EATCHLD );
+    return ActiveCmdHandling() && ( iCmdId == EATCHLD );
     }
 
 void CBtmcCallingHandler::RequestCompletedL(CBtmcActive& aActive, TInt aErr)
@@ -90,18 +91,11 @@
         {
         case KCallingResponse:
             {
-            delete iActive;
-            iActive = NULL;
-            if (!iBusy)
-                {
-                break;
-                }
-            iBusy = EFalse;
             TInt result = KErrNone;
             if (!aErr)
                 {
                 TBuf8<KMaxATSize> buf;
-                aErr = iCmdProperty.Get(buf);
+                aErr = iRespProperty.Get(buf);
                 if (!aErr && buf.Length() >= sizeof(TInt))
                     {
                     const TUint8* ptr = buf.Ptr();
@@ -118,7 +112,6 @@
                     iProtocol.VoiceRecognitionError();
                     }
                 }
-            
             CATResult* nok = CATResult::NewLC(atid);
             iProtocol.SendResponseL(*nok);
             CleanupStack::PopAndDestroy(nok);
@@ -136,7 +129,7 @@
         {
         case KCallingResponse:
             {
-            iCmdProperty.Cancel();
+            iRespProperty.Cancel();
             break;    
             }
         default:
@@ -158,7 +151,9 @@
 void CBtmcCallingHandler::ConstructL()
     {
     TRACE_FUNC
-    iCmdProperty.Attach(KPSUidBluetoothEnginePrivateCategory, KBTATCodec);
+    LEAVE_IF_ERROR( iCmdProperty.Attach(KPSUidBluetoothEnginePrivateCategory, KBTHfpATCommand) );
+    LEAVE_IF_ERROR( iRespProperty.Attach(KPSUidBluetoothEnginePrivateCategory, KBTHfpATResponse) );
+    iActive = CBtmcActive::NewL(*this, CActive::EPriorityStandard, KCallingResponse);
     TRACE_FUNC_EXIT  
     }
     
--- a/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcprotocol.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcprotocol.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -838,8 +838,8 @@
     if (response)
         {
         RATResultPtrArray resarr;
+        CleanupStack::PushL(code);
         ATObjArrayCleanupResetAndDestroyPushL(resarr);        
-        CleanupStack::PushL(code);
         resarr.AppendL(code);
         CleanupStack::Pop(code);
         CATResult* ok = CATResult::NewL(EATOK);
@@ -1077,9 +1077,9 @@
             LEAVE_IF_ERROR(params.Append(TATParam(buf)))
             code = CATResult::NewL(EATCGSN, EATActionResult, &params);
             CleanupStack::PopAndDestroy(&params);
+            CleanupStack::PushL(code);
             RATResultPtrArray resarr;
             ATObjArrayCleanupResetAndDestroyPushL(resarr);        
-            CleanupStack::PushL(code);
             resarr.AppendL(code);
             CleanupStack::Pop(code);
             CATResult* ok = CATResult::NewL(EATOK);
@@ -1116,7 +1116,7 @@
         {
         TRACE_FUNC_ENTRY
         iTimerActive = CBtmcActive::NewL(*this, CActive::EPriorityStandard, aService);
-        iTimer.CreateLocal();
+        LEAVE_IF_ERROR(iTimer.CreateLocal());
         iTimer.After(iTimerActive->iStatus, aTimeout);
         iTimerActive->GoActive();
         TRACE_FUNC_EXIT
--- a/bluetoothengine/btmac/src/btmac/btmsconnect.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btmac/src/btmac/btmsconnect.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -121,7 +121,7 @@
                 CompleteStateRequest(aErr);
                 Parent().ChangeStateL(CBtmsCtrl::NewL(Parent(), SwapRfcommSock(iRfcomm), NULL));
                 }
-            else if (iRequestCat == ERequestConnect)
+            else if (iRequestCat == ERequestOpenAudio)
                 {
                 Parent().ChangeStateL(CBtmsOpenAudio::NewL(Parent(),SwapStateRequest(), SwapRfcommSock(iRfcomm), NULL));
                 }
--- a/bluetoothengine/btmac/src/btmonobearer/bmbcmdlistener.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btmac/src/btmonobearer/bmbcmdlistener.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-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"
@@ -33,7 +33,8 @@
 CBmbCmdListener::~CBmbCmdListener()
     {
    	Cancel();
-	iProperty.Close();
+   	iATCmdProperty.Close();
+   	iATRespProperty.Close();
     }
 
 // ---------------------------------------------------------------------------
@@ -44,11 +45,7 @@
 void CBmbCmdListener::HandlingDataCompleted( const TDesC8& aResp )
     {
     // No better error handling than ignoring it.
-    (void) iProperty.Set( aResp );
-    // Handling previous received command has completed, this object 
-    // is ready for picking up the next one, regardless of
-    // response sent successfully or not.
-    Subscribe();
+    (void) iATRespProperty.Set( aResp );
     TRACE_FUNC
     }
 
@@ -61,7 +58,8 @@
 void CBmbCmdListener::ConstructL()
     {
 	TRACE_FUNC
-    LEAVE_IF_ERROR(iProperty.Attach(KPSUidBluetoothEnginePrivateCategory, KBTATCodec));
+    LEAVE_IF_ERROR(iATCmdProperty.Attach(KPSUidBluetoothEnginePrivateCategory, KBTHfpATCommand));
+	LEAVE_IF_ERROR(iATRespProperty.Attach(KPSUidBluetoothEnginePrivateCategory, KBTHfpATResponse));
 	Subscribe();
     }
 
@@ -69,48 +67,34 @@
     {
     TRACE_FUNC
 	TInt err = iStatus.Int();
+    Subscribe();
     // Error could be received from Subscribe when the PS
     // key is deleted due to powering BT off. In
     // this case, we just re-subscribe.
 	if(err == KErrNone)
 		{
 	    iAtCmdBuf.Zero();
-    	err = iProperty.Get(iAtCmdBuf);
+    	err = iATCmdProperty.Get(iAtCmdBuf);
     	if ( !err && iAtCmdBuf.Length() > 0 )
     	    {
     	    // An AT command to be processed by iParent.
     	    // At command handling completion, iParent will call this object
-    	    // to send out response via HandlingDataCompleted()
-    	    // which will subscribe to PS key update after the response has been 
-    	    // sent.
+    	    // to send out response via HandlingDataCompleted().
     	    iParent.DataFromRemote(iAtCmdBuf);
     	    }
-    	else
-    	    {
-    	    // No valid command in the PS key, re-subscribe.
-    	    err = KErrArgument;
-    	    }
 	    }
 	TRACE_ERROR((_L8("listener Status %d"), err))
-	// If err is 0, this object shall not immediately listen to new commands via
-    // Subscribe() function while a command is under processing by iParent. 
-    // Btmonocmdhandler ensures not to deliver
-    // the next command to this bearer while a command is being processed.	
-	if(err != KErrNone)
-        {
-        Subscribe();
-        }
     }
 
 void CBmbCmdListener::DoCancel()
     {
-    iProperty.Cancel();
+    iATCmdProperty.Cancel();
     }
 
 void CBmbCmdListener::Subscribe()
     {
     __ASSERT_ALWAYS( !IsActive(), Panic(EBmbPanicCmdListenerBadState) );
-    iProperty.Subscribe(iStatus);
+    iATCmdProperty.Subscribe(iStatus);
     SetActive();
     TRACE_FUNC
     }
--- a/bluetoothengine/btsac/inc/btsacStateConfigured.h	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/inc/btsacStateConfigured.h	Tue Jan 26 12:06:42 2010 +0200
@@ -103,7 +103,7 @@
     void StartTimer(TTimeIntervalMicroSeconds32 aTimeout);
     void StopTimer();
  	
- 	void CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset);
+ 	void CancelActionL(TInt aError);
  	void HandleGavdpErrorL(TInt aError);
 
 private:    
--- a/bluetoothengine/btsac/inc/btsacStateConfiguring.h	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/inc/btsacStateConfiguring.h	Tue Jan 26 12:06:42 2010 +0200
@@ -81,7 +81,7 @@
 	TInt GAVDP_ConfigurationEndIndication();
 	TInt GAVDP_StartIndication(TSEID aLocalSEID);
 	
-	void CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset);
+	void CancelActionL(TInt aError);
 	void HandleGavdpErrorL(TInt aError);
 
 private:    
--- a/bluetoothengine/btsac/inc/btsacStateConnected.h	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/inc/btsacStateConnected.h	Tue Jan 26 12:06:42 2010 +0200
@@ -108,7 +108,7 @@
     void StartTimer(TTimeIntervalMicroSeconds32 aTimeout, TInt aRequestId);
     void StopTimer();
     
-    void CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset);
+    void CancelActionL(TInt aError);
     void HandleGavdpErrorL(TInt aError);
     
     void StartConfigurationL();
--- a/bluetoothengine/btsac/inc/btsacStateConnecting.h	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/inc/btsacStateConnecting.h	Tue Jan 26 12:06:42 2010 +0200
@@ -70,7 +70,7 @@
     
     void GAVDP_ConnectConfirm(const TBTDevAddr& aDeviceAddr);   
         
-    void CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset);
+    void CancelActionL(TInt aError);
     void HandleGavdpErrorL(TInt aError);
        
 
--- a/bluetoothengine/btsac/inc/btsacStateListening.h	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/inc/btsacStateListening.h	Tue Jan 26 12:06:42 2010 +0200
@@ -111,7 +111,7 @@
      */
 	virtual void CancelRequest(CBtsacActive& aActive);
 	
-	TInt ResetGavdp(TBTSACGavdpResetReason aReason);
+	TInt ResetGavdp();
 	void GoListen();
 	void DeleyedOpenAudioAndConnectL();
 
--- a/bluetoothengine/btsac/inc/btsacStateStreaming.h	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/inc/btsacStateStreaming.h	Tue Jan 26 12:06:42 2010 +0200
@@ -91,7 +91,7 @@
 	void GAVDP_SuspendStreamsConfirm();
  	
  	void StartRecording();
- 	void CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset);
+ 	void CancelActionL(TInt aError);
  	void HandleGavdpErrorL(TInt aError);
 
 private:    
--- a/bluetoothengine/btsac/inc/btsacStateSuspended.h	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/inc/btsacStateSuspended.h	Tue Jan 26 12:06:42 2010 +0200
@@ -80,7 +80,7 @@
    	TInt GAVDP_StartIndication(TSEID aSEID);
     void GAVDP_ReleaseIndication(TSEID aSEID);
  	
- 	void CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset);
+ 	void CancelActionL(TInt aError);
  	void HandleGavdpErrorL(TInt aError);
 
 private:    
--- a/bluetoothengine/btsac/inc/btsacStreamerController.h	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/inc/btsacStreamerController.h	Tue Jan 26 12:06:42 2010 +0200
@@ -55,7 +55,6 @@
 public:
 	TInt iMaxBitpoolValue;
 	TInt iMaxDeviation;
-	//TInt iUpgradeDelay;
 	TInt iIndex;
 	TInt iDownBitpoolIndex;
 	TInt iUpBitpoolIndex;
--- a/bluetoothengine/btsac/inc/btsacdefs.h	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/inc/btsacdefs.h	Tue Jan 26 12:06:42 2010 +0200
@@ -60,9 +60,7 @@
 enum TBTSACGavdpResetReason
     {
     EGavdpResetReasonNone,
-    EGavdpResetReasonGeneral,
-    EGavdpResetReasonCancelOpenAudio,
-    EGavdpResetReasonDisconnect  
+    EGavdpResetReasonGeneral  
     };
 
 //Panic codes
--- a/bluetoothengine/btsac/src/btsacState.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/src/btsacState.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -221,7 +221,7 @@
 	{
 	TRACE_INFO((_L("CBtsacState::GAVDP_AbortStreamConfirm(), state %d"), GetStateIndex()))
 	Parent().CompletePendingRequests(KCompleteAllReqs, KErrAbort);
-	TRAPD(err, Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonNone, KErrDisconnected)));
+	TRAPD(err, Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, KErrDisconnected)));
 	if (err)
 		{
 		TRACE_INFO((_L("CBtsacState::GAVDP_AbortStreamConfirm() Couldn't change state.")))
@@ -333,7 +333,7 @@
 	TRACE_INFO((_L("CBtsacState::GAVDP_AbortIndication(), state %d, SEID:%d"), GetStateIndex(), aSEID.SEID()))
 	(void)aSEID;
 	Parent().CompletePendingRequests(KCompleteAllReqs, KErrDisconnected);
-	TRAPD(err, Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonNone, KErrDisconnected)))
+	TRAPD(err, Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, KErrDisconnected)))
 	if(err)
 		{
 		TRACE_INFO((_L("CBtsacState::GAVDP_AbortIndication(), error! Couldn't change state")))
--- a/bluetoothengine/btsac/src/btsacStateConfigured.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/src/btsacStateConfigured.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -169,11 +169,11 @@
 // CBtsacConfigured::CancelActionL
 // -----------------------------------------------------------------------------
 //
-void CBtsacConfigured::CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset)
+void CBtsacConfigured::CancelActionL(TInt aError)
     {
     TRACE_FUNC
 	Parent().CompletePendingRequests(KOpenAudioReq, aError);
-	Parent().ChangeStateL(CBtsacListening::NewL(Parent(), aGavdpReset, aError));
+	Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, aError));
     }
 
 // -----------------------------------------------------------------------------
@@ -183,7 +183,7 @@
 void CBtsacConfigured::CancelConnectL()
     {
 	TRACE_FUNC	
-	CancelActionL(KErrCancel, EGavdpResetReasonGeneral);
+	CancelActionL(KErrCancel);
     }
 
 // -----------------------------------------------------------------------------
@@ -224,7 +224,7 @@
 void CBtsacConfigured::CancelOpenAudioLinkL()
     {
     TRACE_FUNC
-	CancelActionL(KErrCancel, EGavdpResetReasonGeneral);
+	CancelActionL(KErrCancel);
     }
 
 // -----------------------------------------------------------------------------
@@ -255,7 +255,7 @@
 			{
 			TRACE_INFO((_L("CBtsacConfigured::GAVDP_StartStreamsConfirm() [ERR] Couldn't abort stream.")))
 			}
-		TRAP_IGNORE(CancelActionL(KErrNotReady, EGavdpResetReasonGeneral));
+		TRAP_IGNORE(CancelActionL(KErrNotReady));
 	 	}
 	 else
 	 	{
@@ -366,7 +366,7 @@
 				}
 			else
 				{
-				CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral);
+				CancelActionL(KErrDisconnected);
 				}
 			break;
 			}
@@ -374,12 +374,12 @@
 		case KErrDisconnected: // -36
 			{
 			TRACE_INFO((_L("CBtsacConfigured::HandleGavdpErrorL() Signalling disconnected.")))
-			CancelActionL(aError, EGavdpResetReasonNone);
+			CancelActionL(aError);
 			break;
 			}
 		default:
 			{
-			CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral);
+			CancelActionL(KErrDisconnected);
 			break;
 			}
 		}
--- a/bluetoothengine/btsac/src/btsacStateConfiguring.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/src/btsacStateConfiguring.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -98,7 +98,7 @@
 		}
 	else // internal problem
 		{
-  		CancelActionL(KErrCancel, EGavdpResetReasonGeneral);
+  		CancelActionL(KErrCancel);
 		}
     }
 
@@ -106,11 +106,11 @@
 // CBtsacConfiguring::CancelActionL
 // -----------------------------------------------------------------------------
 //
-void CBtsacConfiguring::CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset)
+void CBtsacConfiguring::CancelActionL(TInt aError)
     {
     TRACE_FUNC
 	Parent().CompletePendingRequests((KConnectReq | KOpenAudioReq), aError);
-    Parent().ChangeStateL(CBtsacListening::NewL(Parent(), aGavdpReset, aError));
+    Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, aError));
     }
 
 // -----------------------------------------------------------------------------
@@ -120,7 +120,7 @@
 void CBtsacConfiguring::CancelConnectL()
     {
     TRACE_FUNC
-	CancelActionL(KErrCancel, EGavdpResetReasonGeneral); // do no cancel till gavdp_error call back recieved
+	CancelActionL(KErrCancel);
     }
 
 // -----------------------------------------------------------------------------
@@ -142,7 +142,7 @@
 	{
 	TRACE_FUNC
 	Parent().CompletePendingRequests(KDisconnectReq, KErrNone);
-	CancelActionL(KErrCancel, EGavdpResetReasonGeneral);
+	CancelActionL(KErrCancel);
 	}	
 
 // -----------------------------------------------------------------------------
@@ -198,7 +198,7 @@
 			{
 			TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() Couldn't retrieve Capabilities !")))
 		   	SEPCapabilities.Close();
-		   	TRAPD(err, CancelActionL(KErrCancel, EGavdpResetReasonGeneral));
+		   	TRAPD(err, CancelActionL(KErrCancel));
 		   	if(err)
 		   		{
 		   		return KErrNoMemory;
@@ -224,9 +224,7 @@
 				TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() Media Transport Caps retrieved.")))
 				}
 	   		}
-	   	SEPCapabilities.Close();
-		
-		//Parent().StoreAccInfo();  // stores iRemoteSEPs (SEPManager) into database
+	   	SEPCapabilities.Close();	
 		
 		// Check if headset's capabilities suits us			
 		TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() Accessory Sampling Frequencies: %d"), SBCCaps.SamplingFrequencies()))
@@ -239,7 +237,7 @@
 		if (Parent().iStreamer->ConfigureSEP(SBCCaps) )
 			{
 	   		TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() Streamer couldn't configure SEP !")))
-	        TRAPD(err, CancelActionL(KErrCancel, EGavdpResetReasonGeneral));
+	        TRAPD(err, CancelActionL(KErrCancel));
 	        if(err)
 	        	{
 	        	return KErrNoMemory;
@@ -292,7 +290,7 @@
 			{
 			TRACE_INFO((_L("CBtsacConfiguring::HandleGavdpErrorL() Request TIMEOUT")))
 			// Go to listening state, gavdp will be shutdown in listening state
-			CancelActionL(KErrDisconnected, EGavdpResetReasonNone);
+			CancelActionL(KErrDisconnected);
 			break;
 			}
 			
@@ -302,7 +300,7 @@
 			TRACE_INFO((_L("CBtsacConfiguring::HandleGavdpErrorL() Signalling disconnected.")))
 			// for both outgoing or incoming connection, if we have an error, 
 			// this means there is disconnection
-			CancelActionL(aError, EGavdpResetReasonNone);
+			CancelActionL(aError);
 			break;
 			}
 		
@@ -310,7 +308,7 @@
 		//case KErrNotReady: // -18
 		//case KErrInUse: // -14
 			{
-			CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral);
+			CancelActionL(KErrDisconnected);
 			break;
 			}
 		}
--- a/bluetoothengine/btsac/src/btsacStateConnected.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/src/btsacStateConnected.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -179,12 +179,12 @@
 // CBtsacConnected::CancelActionL
 // -----------------------------------------------------------------------------
 //
-void CBtsacConnected::CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset)
+void CBtsacConnected::CancelActionL(TInt aError)
     {
     TRACE_FUNC
     StopTimer();
 	Parent().CompletePendingRequests((KConnectReq | KOpenAudioReq), aError);
-	Parent().ChangeStateL(CBtsacListening::NewL(Parent(), aGavdpReset, aError));
+	Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, aError));
     }
 
 // -----------------------------------------------------------------------------
@@ -198,7 +198,7 @@
 	if (Parent().GetRemoteAddr() != aAddr)
 		{
 		TRACE_INFO((_L("CBtsacConnected::OpenAudio, Error!")))
-		CancelActionL(KErrNotFound, EGavdpResetReasonGeneral);
+		CancelActionL(KErrNotFound);
 		return;
 		}
 	iAudioOpenedBy = EAudioOpenedByAFW;
@@ -224,7 +224,7 @@
 void CBtsacConnected::CancelOpenAudioLinkL()
     {
     TRACE_FUNC
-	CancelActionL(KErrCancel, EGavdpResetReasonGeneral);
+	CancelActionL(KErrCancel);
     }
 	
 // -----------------------------------------------------------------------------
@@ -235,7 +235,7 @@
 	{
 	TRACE_FUNC
 	Parent().CompletePendingRequests(KDisconnectReq, KErrNone);
-	CancelActionL(KErrCancel, EGavdpResetReasonDisconnect);
+	CancelActionL(KErrCancel);
 	}
 
 // -----------------------------------------------------------------------------
@@ -247,7 +247,7 @@
     TRACE_FUNC
     if(!iBearersQuery)
     	{
-		CancelActionL(KErrCancel, EGavdpResetReasonGeneral);
+		CancelActionL(KErrCancel);
     	}
     else
     	{
@@ -289,7 +289,7 @@
     if ((Parent().iRemoteSEPs->GetCaps(Parent().GetSEPIndex(), SEPCapabilities)) )
 		{
 		TRACE_INFO((_L("CBtsacConnected::Configure() Couldn't retrieve Capabilities !")))
-		CancelActionL(KErrCancel, EGavdpResetReasonGeneral);
+		CancelActionL(KErrCancel);
 	   	SEPCapabilities.Close();
 		return; 
 		}   
@@ -327,7 +327,7 @@
 	if (Parent().iStreamer->ConfigureSEP(SBCCaps) )
 		{
    		TRACE_INFO((_L("CBtsacConnected::Configure() Streamer couldn't configure SEP !")))
-        CancelActionL(KErrCancel, EGavdpResetReasonGeneral); 
+        CancelActionL(KErrCancel); 
         return;   // capabilites doesn't suit us
 		}
 		
@@ -335,7 +335,7 @@
 	if (Parent().iRemoteSEPs->GetInfo(Parent().GetSEPIndex(), SEPInfo))
 		{
 		TRACE_INFO((_L("CBtsacConnected::Configure() Couldn't retrieve SEP Info !")))
-		CancelActionL(KErrCancel, EGavdpResetReasonGeneral); 
+		CancelActionL(KErrCancel); 
         return;   // capabilites doesn't suit us
 		}
 	TSEID remoteSEPid = SEPInfo.SEID(); 	
@@ -346,7 +346,7 @@
 	if ( Parent().iGavdp->ConfigureSEP(localSEPid, remoteSEPid , SBCCaps, MedTransCaps ) )
 		{
 		TRACE_INFO((_L("CBtsacConnected::Configure() ConfigureSEP returned Error !!!")))
-		CancelActionL(KErrCancel, EGavdpResetReasonGeneral);
+		CancelActionL(KErrCancel);
 		}
     }
     
@@ -371,8 +371,6 @@
 	else // we have covered all SEPs
 		{
 		StopTimer();
-		// store all info in our db
-		//Parent().StoreAccInfo();  // stores iRemoteSEPs (SEPManager) into database
 		iSuitableSEPFoundAlready = EFalse;
 		
 		if ( iSEPFound == ESEPConfigure ) 
@@ -393,7 +391,7 @@
 			}
 		else // no audio sbc sink sep found
 			{
-			TRAP_IGNORE(CancelActionL(KErrCancel, EGavdpResetReasonGeneral));
+			TRAP_IGNORE(CancelActionL(KErrCancel));
 			}
 		}
 	}
@@ -417,7 +415,7 @@
 			}
 		else // internal problem
 			{
-  			TRAP_IGNORE(CancelActionL(KErrCancel, EGavdpResetReasonGeneral));
+  			TRAP_IGNORE(CancelActionL(KErrCancel));
 			}
      	}
 	}
@@ -438,7 +436,7 @@
 	else // remote A2DP has no 'audio' 'sink' SEPs ! naughty remote
 		{
 		TRACE_INFO((_L("CBtsacConnected::GAVDP_SEPDiscoveryComplete() Remote A2dP has no 'audio' 'sink' SEPs !")))
-		TRAP_IGNORE(CancelActionL(KErrCancel, EGavdpResetReasonGeneral));
+		TRAP_IGNORE(CancelActionL(KErrCancel));
 		}
 	}
 	
@@ -511,7 +509,7 @@
 	if (Parent().iRemoteSEPs->GetInfo(Parent().GetSEPIndex(), SEPInfo))
 		{
 		TRACE_INFO((_L("CBtsacConnected::GAVDP_ConfigurationConfirm Couldn't retrieve SEP Info !")))
-		TRAP_IGNORE(CancelActionL(KErrCancel, EGavdpResetReasonGeneral));
+		TRAP_IGNORE(CancelActionL(KErrCancel));
        	return;   // cannot get remote SEP capabilites 
 		}
 	TSEID remoteSEPid = SEPInfo.SEID();
@@ -566,7 +564,7 @@
 	{
 	TRACE_INFO((_L("CBtsacConnected::GAVDP_AbortIndication() SEID:%d"), aSEID.SEID()))
 	(void)aSEID;
-	TRAP_IGNORE(CancelActionL(KErrDisconnected, EGavdpResetReasonNone));
+	TRAP_IGNORE(CancelActionL(KErrDisconnected));
 	}
 
 // -----------------------------------------------------------------------------
@@ -594,8 +592,8 @@
 			{
 			if(!iBearersQuery)
 				{				
-			// Go to listening state, gavdp will be shutdown in listening state
-			CancelActionL(KErrCancel, EGavdpResetReasonNone);
+                // Go to listening state, gavdp will be shutdown in listening state
+                CancelActionL(KErrDisconnected);
 				}
 			else
 				{
@@ -608,7 +606,7 @@
 					}
 				else
 					{
-					CancelActionL(KErrCancel, EGavdpResetReasonGeneral);
+					CancelActionL(KErrDisconnected);
 					}
 				}
 			break;
@@ -653,7 +651,7 @@
 			{
 			TRACE_INFO((_L("CBtsacConnected::HandleGavdpErrorL() Request TIMEOUT")))
 			// Go to listening state, gavdp will be shutdown in listening state
-			CancelActionL(KErrDisconnected, EGavdpResetReasonNone);
+			CancelActionL(KErrDisconnected);
 			break;
 			}
 			
@@ -663,7 +661,7 @@
 			TRACE_INFO((_L("CBtsacConnected::HandleGavdpErrorL() Signalling disconnected.")))
 			// for both outgoing or incoming connection, if we have an error, 
 			// this means there is disconnection
-			CancelActionL(aError, EGavdpResetReasonGeneral);
+			CancelActionL(aError);
 			break;
 			}	
 
@@ -682,7 +680,7 @@
 		// KErrCorrupt -20
 		// (KErrAvdtpSignallingErrorBase - EAvdtpBadState) -18094
 			{
-			CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral);
+			CancelActionL(KErrDisconnected);
 			}
 		}
 	}
--- a/bluetoothengine/btsac/src/btsacStateConnecting.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/src/btsacStateConnecting.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -77,11 +77,11 @@
 // CBtsacConnecting::CancelActionL
 // -----------------------------------------------------------------------------
 //
-void CBtsacConnecting::CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset)
+void CBtsacConnecting::CancelActionL(TInt aError)
     {
 	TRACE_FUNC
 	Parent().CompletePendingRequests((KConnectReq | KOpenAudioReq), aError);
-    Parent().ChangeStateL(CBtsacListening::NewL(Parent(), aGavdpReset, aError));
+    Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, aError));
     }
 
 // -----------------------------------------------------------------------------
@@ -91,7 +91,7 @@
 void CBtsacConnecting::CancelOpenAudioL(const TBTDevAddr& /*aAddr*/)
     {
     TRACE_FUNC
-	CancelActionL(KErrCancel, EGavdpResetReasonGeneral);
+	CancelActionL(KErrCancel);
     }
 
 // -----------------------------------------------------------------------------
@@ -101,7 +101,7 @@
 void CBtsacConnecting::CancelConnectL()
     {
     TRACE_FUNC
-	CancelActionL(KErrCancel, EGavdpResetReasonGeneral);
+	CancelActionL(KErrCancel);
     }
     
 // -----------------------------------------------------------------------------
@@ -121,7 +121,7 @@
 		 // only possibility is that another accessory has made incoming connection, after we have sent a connect request
 		 // what a coincidence !
 		{
-		TRAP_IGNORE(CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral));
+		TRAP_IGNORE(CancelActionL(KErrDisconnected));
 		}
 	}
 
@@ -137,7 +137,7 @@
 	// KErrInUse  -14
 	// KErrCouldNotConnect -34
 	// KErrL2CAPRequestTimeout -6312
-	CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral);
+	CancelActionL(KErrDisconnected);
 	}
 
 //  End of File  
--- a/bluetoothengine/btsac/src/btsacStateListening.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/src/btsacStateListening.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -203,7 +203,7 @@
 	if (err)
 		{
 		TRACE_INFO((_L("CBtsacListening::GAVDP_ConfigurationConfirm() Listen returned error:%d."), err))
-		ResetGavdp(EGavdpResetReasonGeneral);
+		ResetGavdp();
 		return;
 		}
 	if(iInitializationProcedure == EInitProcedureWaitingConfConfirmed)
@@ -269,13 +269,14 @@
 				}
 			if(iGavdpResetReason != EGavdpResetReasonNone)
 				{
-				ResetGavdp(iGavdpResetReason);
+				ResetGavdp();
 				}
 			else
 				{
 				GoListen();
 				}				
-			if(iDisconnectReason == KErrDisconnected || iDisconnectReason == KErrHCILinkDisconnection)
+			if((iDisconnectReason == KErrDisconnected || iDisconnectReason == KErrHCILinkDisconnection) &&
+			    iPendingRequests == KRequestNone)
 				{
 				if(remoteAddr != TBTDevAddr())
 					{						
@@ -325,7 +326,7 @@
 		{
 		// Shutdown failed, reset gavdp
 		TRACE_INFO((_L("CBtsacListening::GoListen(), error = %d."), err))
-		ResetGavdp(EGavdpResetReasonGeneral);
+		ResetGavdp();
 		}		
 	}
 
@@ -333,21 +334,18 @@
 // CBtsacListening::ResetGavdp
 // -----------------------------------------------------------------------------
 //
-TInt CBtsacListening::ResetGavdp(TBTSACGavdpResetReason aReason)
+TInt CBtsacListening::ResetGavdp()
 	{
 	TRACE_FUNC
 	Parent().iGavdp->Close();
 	if( Parent().iGavdp->Open() == KErrNone )
 		{
 		iInitializationProcedure = EInitProcedureWaitingConfConfirmed;
-		if(aReason != EGavdpResetReasonCancelOpenAudio)
-			{
-			if(iPendingRequests == KRequestNone)
-				{
-				TRACE_INFO((_L("CBtsacListening::ResetGavdp() Remote Addr reseted.")))
-				Parent().SetRemoteAddr(TBTDevAddr());
-				}
-			}
+        if(iPendingRequests == KRequestNone)
+            {
+            TRACE_INFO((_L("CBtsacListening::ResetGavdp() Remote Addr reseted.")))
+            Parent().SetRemoteAddr(TBTDevAddr());
+            }
 		return Parent().iGavdp->RegisterSEPs(*Parent().iLocalSEPs, Parent().iStreamer->GetCaps());
 		}
 	else
@@ -432,7 +430,7 @@
 		// KErrDied -13
 		// KErrInUse -14
 			{
-			ResetGavdp(EGavdpResetReasonGeneral);			
+			ResetGavdp();			
 			break;
 			}
 		}
--- a/bluetoothengine/btsac/src/btsacStateStreaming.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/src/btsacStateStreaming.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -90,7 +90,7 @@
 // CBtsacStreaming::CancelActionL
 // -----------------------------------------------------------------------------
 //
-void CBtsacStreaming::CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset)
+void CBtsacStreaming::CancelActionL(TInt aError)
 	{
 	TRACE_FUNC
 	TInt ret = Parent().iStreamer->StopStream();
@@ -99,7 +99,7 @@
 		TRACE_INFO((_L("CBtsacStreaming::Cancel() iStreamer.StopStream() returned error(%d) !!!"), ret))
 		}
 	Parent().CompletePendingRequests(KCompleteAllReqs, aError);
-	Parent().ChangeStateL(CBtsacListening::NewL(Parent(), aGavdpReset, aError));
+	Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, aError));
 	}
 
 // -----------------------------------------------------------------------------
@@ -132,7 +132,7 @@
 	if ( ret )
 		{
 		TRACE_INFO((_L("CBtsacStreaming::CloseAudio() Couldn't retrieve SEP Info !")))
-		CancelActionL(KErrCancel, EGavdpResetReasonGeneral); 
+		CancelActionL(KErrCancel); 
  		return;   
 		}
 	// Suspend audio
@@ -171,7 +171,7 @@
 			{
 			TRACE_INFO((_L("CBtsacStreaming::StartRecording() Couldn't abort stream.")))	
 			}
-		TRAP_IGNORE(Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonNone, KErrDisconnected)));
+		TRAP_IGNORE(Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, KErrDisconnected)));
 	 	}
 	}
 
@@ -188,7 +188,7 @@
 		TRACE_INFO((_L("CBtsacStreaming::DisconnectL() StopStream() returned error: %d"), ret))	
 		}
 	Parent().CompletePendingRequests(KDisconnectReq, ret);
-	Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonDisconnect, KErrNone));
+	Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, KErrNone));
 	}
 
 // -----------------------------------------------------------------------------
@@ -220,7 +220,7 @@
 	
 	// It is possible the remote disconnected while we have active close audio request.
 	Parent().CompletePendingRequests(KCompleteAllReqs, KErrNone);
-    TRAP_IGNORE(Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonNone, KErrDisconnected)));
+    TRAP_IGNORE(Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, KErrDisconnected)));
 	}
 
 // -----------------------------------------------------------------------------
@@ -347,7 +347,7 @@
 		case KErrDisconnected: // -36
 			{
 			Parent().CompletePendingRequests(KCompleteAllReqs, aError);
-			Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonNone, aError));
+			Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, aError));
 			break;
 			}
 		default:
--- a/bluetoothengine/btsac/src/btsacStateSuspended.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/src/btsacStateSuspended.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -83,11 +83,11 @@
 // CBtsacSuspended::CancelActionL
 // -----------------------------------------------------------------------------
 //
-void CBtsacSuspended::CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset)
+void CBtsacSuspended::CancelActionL(TInt aError)
 	{
 	TRACE_FUNC
 	Parent().CompletePendingRequests(KOpenAudioReq, aError);
-	Parent().ChangeStateL(CBtsacListening::NewL(Parent(), aGavdpReset, aError));
+	Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, aError));
 	}
     
 // -----------------------------------------------------------------------------
@@ -117,7 +117,7 @@
 void CBtsacSuspended::CancelOpenAudioL(const TBTDevAddr& /*aAddr*/)
     {
     TRACE_FUNC
-	CancelActionL(KErrCancel, EGavdpResetReasonGeneral);
+	CancelActionL(KErrCancel);
     }
     
 // -----------------------------------------------------------------------------
@@ -128,7 +128,7 @@
 	{
 	TRACE_FUNC
 	Parent().CompletePendingRequests(KDisconnectReq, KErrNone);
-	CancelActionL(KErrCancel, EGavdpResetReasonGeneral);
+	CancelActionL(KErrCancel);
 	}
 	
 // -----------------------------------------------------------------------------
@@ -146,7 +146,7 @@
 			{
 			TRACE_INFO((_L("CBtsacSuspended::GAVDP_StartStreamsConfirm() Couldn't abort stream.")))
 			}
-		TRAP_IGNORE(CancelActionL(KErrCancel, EGavdpResetReasonGeneral));
+		TRAP_IGNORE(CancelActionL(KErrDisconnected));
 	 	}
 	 else
 	 	{
@@ -210,7 +210,7 @@
 				}
 			else
 				{
-				CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral);
+				CancelActionL(KErrDisconnected);
 				}
 			break;
 			}
@@ -226,7 +226,7 @@
 					}
 				else
 					{
-					CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral);
+					CancelActionL(KErrDisconnected);
 					}
 				}
 			else
@@ -243,14 +243,14 @@
 		case KErrDisconnected: // -36
 			{
 			TRACE_INFO((_L("CBtsacSuspended::HandleGavdpErrorL() Signalling disconnected.")))
-			CancelActionL(aError, EGavdpResetReasonNone);
+			CancelActionL(aError);
 			break;
 			}
 		default:
 			{
 			// Unknown error. For safety's sake let's disconnect a2dp link and inform btaudioman
 			TRACE_INFO((_L("CBtsacSuspended::HandleGavdpErrorL() Unknown error, goes to listening")))
-			CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral);
+			CancelActionL(KErrDisconnected);
 			break;
 			}
 		}
--- a/bluetoothengine/btsac/src/btsacStreamerController.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btsac/src/btsacStreamerController.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -28,8 +28,7 @@
 
 // CONSTANTS
 _LIT(KBTAADLL, "btaudioadaptation.dll");
-
-//const TInt KUpgradeTimerDelay = 120000000;	// 2 minutes. How often we sill try to upgrade back to a better quality audio. 
+ 
 const TInt KRetryTimerDelay = 2000000;		// 2 seconds. If something fails, how soon should we retry. 
 const TInt KStabilizationDelay = 2000000;	// 2 seconds. Wait this long after bitpool change then start mononitor packet drops again
 const TInt KDataCollectDelay = 600000; 		// Time (600ms) to collect packet drop data
@@ -1270,7 +1269,6 @@
 		{
 		data.iMaxBitpoolValue = KMaxBitpoolValues[i];
 		data.iMaxDeviation = KDeviationValues[i];
-		//data.iUpgradeDelay = KUpgradeDelays[i];
 		data.iUpBitpoolIndex = (i == 0) ? i : i - 1;
 		data.iIndex = i;
 		data.iDownBitpoolIndex = (i == KNumOfBitpoolValues - 1) ? i : i + 1;
--- a/bluetoothengine/btui/Ecom/data/BtuiViewResources.rss	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btui/Ecom/data/BtuiViewResources.rss	Tue Jan 26 12:06:42 2010 +0200
@@ -766,7 +766,7 @@
 RESOURCE DIALOG r_bt_waiting
     {
     flags   = EAknWaitNoteFlags;
-    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    buttons = R_AVKON_SOFTKEYS_EMPTY; 
     items   =
         {
         DLG_LINE
--- a/bluetoothengine/btui/Ecom/inc/BTUIPairedDevicesView.h	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btui/Ecom/inc/BTUIPairedDevicesView.h	Tue Jan 26 12:06:42 2010 +0200
@@ -228,7 +228,7 @@
         * @param None.
         * @return None.
         */        
-        void CancelDisconnectQueryDlgL();
+        void CancelDisconnectQueryDlg();
         
         /**
         * Disconnects from the selected BT Accessory without query.
--- a/bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp	Mon Jan 18 20:28:57 2010 +0200
+++ b/bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp	Tue Jan 26 12:06:42 2010 +0200
@@ -181,6 +181,8 @@
 	if(iConstructAsGsPlugin)
 	    	delete iTabHelper;	
 	
+	CancelDisconnectQueryDlg();
+	
     TRACE_FUNC_EXIT
     }
 
@@ -1067,13 +1069,14 @@
 
     // Create confirmation query
     HBufC* stringholder = StringLoader::LoadLC(R_BT_DISCONNECT_FROM, device.iName);
-    iDisconnectQueryDlg = CAknQueryDialog::NewL();
+    if (!iDisconnectQueryDlg)
+        {
+        iDisconnectQueryDlg = CAknQueryDialog::NewL();
+        }
 
 	if(iCoverDisplayEnabled)
 		{
-	    CleanupStack::PushL(iDisconnectQueryDlg); 
 	    iDisconnectQueryDlg->PublishDialogL(ECmdShowDisconnectQuery, KUidCoverUiCategoryBtui); // initializes cover support    
-	    CleanupStack::Pop(iDisconnectQueryDlg); 
 	
 		CAknMediatorFacade* covercl = AknMediatorFacade(iDisconnectQueryDlg); // uses MOP, so control provided 
 		if (covercl) // returns null if __COVER_DISPLAY is not defined
@@ -1100,7 +1103,7 @@
 // CBTUIPairedDevicesView::CancelDisconnectQueryDlgL
 // ----------------------------------------------------------
 //
-void CBTUIPairedDevicesView::CancelDisconnectQueryDlgL()
+void CBTUIPairedDevicesView::CancelDisconnectQueryDlg()
 {
 	TRACE_FUNC_ENTRY
 	
@@ -1854,7 +1857,7 @@
         if(aErr == KErrDisconnected)
             {
             if(iDisconnectQueryDlg && aDevice.iAddr == iDisconnectQueryDevice.iAddr)
-                CancelDisconnectQueryDlgL();
+                CancelDisconnectQueryDlg();
             
             TRACE_FUNC_EXIT
             return;