source code commit headsetsimulator
authormichal.sulewski
Wed, 15 Sep 2010 15:59:44 +0200
branchheadsetsimulator
changeset 60 90dbfc0435e3
parent 59 02103bf20ee5
source code commit
bluetoothengine/headsetsimulator/core/eabi/headsetsimulatoru.def
bluetoothengine/headsetsimulator/core/group/bld.inf
bluetoothengine/headsetsimulator/core/group/headsetsimulator.mmp
bluetoothengine/headsetsimulator/core/inc/Plugin/hscodpluginbase.h
bluetoothengine/headsetsimulator/core/inc/Plugin/hscodpluginbase.inl
bluetoothengine/headsetsimulator/core/inc/Plugin/hsecompluginbase.h
bluetoothengine/headsetsimulator/core/inc/Plugin/hsprofilepluginbase.h
bluetoothengine/headsetsimulator/core/inc/Plugin/hsprofilepluginbase.inl
bluetoothengine/headsetsimulator/core/inc/Plugin/hssdppluginbase.h
bluetoothengine/headsetsimulator/core/inc/Plugin/hssdppluginbase.inl
bluetoothengine/headsetsimulator/core/inc/ProfileManager/hsprofilemanager.h
bluetoothengine/headsetsimulator/core/inc/RemoteControl/hsremotecontroldatahandler.h
bluetoothengine/headsetsimulator/core/inc/RemoteControl/hsremotecontrolserver.h
bluetoothengine/headsetsimulator/core/inc/RemoteControl/hsremotecontroltools.h
bluetoothengine/headsetsimulator/core/inc/RemoteControl/hsremoterequest.h
bluetoothengine/headsetsimulator/core/inc/Server/hsaudioserver.h
bluetoothengine/headsetsimulator/core/inc/Server/hsclient.h
bluetoothengine/headsetsimulator/core/inc/Server/hsclientmanager.h
bluetoothengine/headsetsimulator/core/inc/Server/hsserver.h
bluetoothengine/headsetsimulator/core/inc/Tools/hstools.h
bluetoothengine/headsetsimulator/core/inc/debug.h
bluetoothengine/headsetsimulator/core/inc/debugconfig.h
bluetoothengine/headsetsimulator/core/inc/hsclientobservers.h
bluetoothengine/headsetsimulator/core/inc/hscore.h
bluetoothengine/headsetsimulator/core/inc/hsobserver.h
bluetoothengine/headsetsimulator/core/inc/prjconfig.h
bluetoothengine/headsetsimulator/core/sis/headsetsimulator.pkg
bluetoothengine/headsetsimulator/core/src/ProfileManager/hsprofilemanager.cpp
bluetoothengine/headsetsimulator/core/src/RemoteControl/hsremotecontrolcommand.cpp
bluetoothengine/headsetsimulator/core/src/RemoteControl/hsremotecontroldatahandler.cpp
bluetoothengine/headsetsimulator/core/src/RemoteControl/hsremotecontrolparser.cpp
bluetoothengine/headsetsimulator/core/src/RemoteControl/hsremotecontrolserver.cpp
bluetoothengine/headsetsimulator/core/src/Server/hsaudioserver.cpp
bluetoothengine/headsetsimulator/core/src/Server/hsclient.cpp
bluetoothengine/headsetsimulator/core/src/Server/hsclientmanager.cpp
bluetoothengine/headsetsimulator/core/src/Server/hsserver.cpp
bluetoothengine/headsetsimulator/core/src/Tools/hsbtmanager.cpp
bluetoothengine/headsetsimulator/core/src/Tools/hsdevicediscoverer.cpp
bluetoothengine/headsetsimulator/core/src/hscore.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/data/E422E38B.rss
bluetoothengine/headsetsimulator/profiles/hfpprofile/group/bld.inf
bluetoothengine/headsetsimulator/profiles/hfpprofile/group/hfpprofileplugin.mmp
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/dataprocessing/hfpcommand.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/dataprocessing/hfpcommandparser.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/dataprocessing/hfpdatahandler.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/debug.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/debugconfig.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpcallinglineidentification.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpcalltermination.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpconnectionmanagement.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpfeaturecommons.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpfeaturemanager.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpincomingcallacceptance.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpincomingcallrejection.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfplastnumberredialing.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpphonenumberdialing.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpphonestatusinformation.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpremoteaudiovolumecontrol.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/hfpcod.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/hfpprofileplugin.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/hfpsdp.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/hfpsettings.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/prjconfig.h
bluetoothengine/headsetsimulator/profiles/hfpprofile/sis/hfpprofileplugin.pkg
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/dataprocessing/hfpcommand.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/dataprocessing/hfpcommandparser.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/dataprocessing/hfpdatahandler.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpcallinglineidentification.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpcalltermination.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpconnectionmanagement.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpfeaturemanager.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpincomingcallacceptance.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpincomingcallrejection.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfplastnumberredialing.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpphonenumberdialing.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpphonestatusinformation.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpremoteaudiovolumecontrol.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/hfpcod.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/hfpprofile.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/hfpsdp.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/hfpsettings.cpp
bluetoothengine/headsetsimulator/profiles/hfpprofile/src/proxy.cpp
bluetoothengine/headsetsimulator/profiles/hspprofile/data/E259E538.rss
bluetoothengine/headsetsimulator/profiles/hspprofile/group/bld.inf
bluetoothengine/headsetsimulator/profiles/hspprofile/group/hspprofile.mmp
bluetoothengine/headsetsimulator/profiles/hspprofile/inc/dataprocessing/hspcommand.h
bluetoothengine/headsetsimulator/profiles/hspprofile/inc/dataprocessing/hspcommandparser.h
bluetoothengine/headsetsimulator/profiles/hspprofile/inc/dataprocessing/hspdatahandler.h
bluetoothengine/headsetsimulator/profiles/hspprofile/inc/debug.h
bluetoothengine/headsetsimulator/profiles/hspprofile/inc/debugconfig.h
bluetoothengine/headsetsimulator/profiles/hspprofile/inc/features/hspcalltermination.h
bluetoothengine/headsetsimulator/profiles/hspprofile/inc/features/hspfeaturecommons.h
bluetoothengine/headsetsimulator/profiles/hspprofile/inc/features/hspfeaturemanager.h
bluetoothengine/headsetsimulator/profiles/hspprofile/inc/features/hspincomingcallacceptance.h
bluetoothengine/headsetsimulator/profiles/hspprofile/inc/features/hspremoteaudiovolumecontrol.h
bluetoothengine/headsetsimulator/profiles/hspprofile/inc/hspcod.h
bluetoothengine/headsetsimulator/profiles/hspprofile/inc/hspprofileplugin.h
bluetoothengine/headsetsimulator/profiles/hspprofile/inc/hspsdp.h
bluetoothengine/headsetsimulator/profiles/hspprofile/inc/hspsettings.h
bluetoothengine/headsetsimulator/profiles/hspprofile/inc/prjconfig.h
bluetoothengine/headsetsimulator/profiles/hspprofile/sis/hspprofile.pkg
bluetoothengine/headsetsimulator/profiles/hspprofile/src/dataprocessing/hspcommand.cpp
bluetoothengine/headsetsimulator/profiles/hspprofile/src/dataprocessing/hspcommandparser.cpp
bluetoothengine/headsetsimulator/profiles/hspprofile/src/dataprocessing/hspdatahandler.cpp
bluetoothengine/headsetsimulator/profiles/hspprofile/src/features/hspcalltermination.cpp
bluetoothengine/headsetsimulator/profiles/hspprofile/src/features/hspfeaturemanager.cpp
bluetoothengine/headsetsimulator/profiles/hspprofile/src/features/hspincomingcallacceptance.cpp
bluetoothengine/headsetsimulator/profiles/hspprofile/src/features/hspremoteaudiovolumecontrol.cpp
bluetoothengine/headsetsimulator/profiles/hspprofile/src/hspcod.cpp
bluetoothengine/headsetsimulator/profiles/hspprofile/src/hspprofile.cpp
bluetoothengine/headsetsimulator/profiles/hspprofile/src/hspsdp.cpp
bluetoothengine/headsetsimulator/profiles/hspprofile/src/hspsettings.cpp
bluetoothengine/headsetsimulator/profiles/hspprofile/src/proxy.cpp
bluetoothengine/headsetsimulator/remotecontroller/eabi/hsremotecontrolleru.def
bluetoothengine/headsetsimulator/remotecontroller/group/bld.inf
bluetoothengine/headsetsimulator/remotecontroller/group/hsremotecontroller.mmp
bluetoothengine/headsetsimulator/remotecontroller/inc/bttools/hsrcbttools.h
bluetoothengine/headsetsimulator/remotecontroller/inc/bttools/hsrcbttoolsobserver.h
bluetoothengine/headsetsimulator/remotecontroller/inc/debug.h
bluetoothengine/headsetsimulator/remotecontroller/inc/debugconfig.h
bluetoothengine/headsetsimulator/remotecontroller/inc/hsremotecontroller.h
bluetoothengine/headsetsimulator/remotecontroller/inc/prjconfig.h
bluetoothengine/headsetsimulator/remotecontroller/inc/remotecontrol/hsrcbttoolsobserver.h
bluetoothengine/headsetsimulator/remotecontroller/inc/remotecontrol/hsrccommand.h
bluetoothengine/headsetsimulator/remotecontroller/sis/hsremotecontroller.pkg
bluetoothengine/headsetsimulator/remotecontroller/src/bttools/hsrcbtmanager.cpp
bluetoothengine/headsetsimulator/remotecontroller/src/bttools/hsrcdevicediscoverer.cpp
bluetoothengine/headsetsimulator/remotecontroller/src/hsremotecontroller.cpp
bluetoothengine/headsetsimulator/remotecontroller/src/remotecontrol/hsrccommand.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/eabi/headsetsimulatoru.def	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,41 @@
+EXPORTS
+	_ZN7CHsCore11SetObserverER11MHsObserver @ 1 NONAME
+	_ZN7CHsCore14StopSimulationEv @ 2 NONAME
+	_ZN7CHsCore15ConnectWithNameERK7TDesC16 @ 3 NONAME
+	_ZN7CHsCore16CancelConnectingEv @ 4 NONAME
+	_ZN7CHsCore16StartSimulationLERK4TUidS2_S2_RK7TDesC16 @ 5 NONAME
+	_ZN7CHsCore16StartSimulationLERK6TDesC8S2_S2_RK7TDesC16 @ 6 NONAME
+	_ZN7CHsCore17DisconnectClientsEv @ 7 NONAME
+	_ZN7CHsCore18AcceptIncomingCallEv @ 8 NONAME
+	_ZN7CHsCore18ReleaseOngoingCallEv @ 9 NONAME
+	_ZN7CHsCore21ConnectWithDevAddressERK7TDesC16 @ 10 NONAME
+	_ZN7CHsCore25ConnectWithLastConnectedLEv @ 11 NONAME
+	_ZN7CHsCore4NewLERK5TUUID @ 12 NONAME
+	_ZN7CHsCore4SendERK6TDesC8i @ 13 NONAME
+	_ZN7CHsCore5NewLCERK5TUUID @ 14 NONAME
+	_ZN7CHsCoreD0Ev @ 15 NONAME
+	_ZN7CHsCoreD1Ev @ 16 NONAME
+	_ZN7CHsCoreD2Ev @ 17 NONAME
+	_ZTI12CHsBTManager @ 18 NONAME
+	_ZTI14CHsAudioServer @ 19 NONAME
+	_ZTI16CHsClientManager @ 20 NONAME
+	_ZTI16CHsControlServer @ 21 NONAME
+	_ZTI17CHsProfileManager @ 22 NONAME
+	_ZTI19CHsDeviceDiscoverer @ 23 NONAME
+	_ZTI22CHsRemoteControlParser @ 24 NONAME
+	_ZTI27CHsRemoteControlDataHandler @ 25 NONAME
+	_ZTI7CHsCore @ 26 NONAME
+	_ZTI9CHsClient @ 27 NONAME
+	_ZTI9CHsServer @ 28 NONAME
+	_ZTV12CHsBTManager @ 29 NONAME
+	_ZTV14CHsAudioServer @ 30 NONAME
+	_ZTV16CHsClientManager @ 31 NONAME
+	_ZTV16CHsControlServer @ 32 NONAME
+	_ZTV17CHsProfileManager @ 33 NONAME
+	_ZTV19CHsDeviceDiscoverer @ 34 NONAME
+	_ZTV22CHsRemoteControlParser @ 35 NONAME
+	_ZTV27CHsRemoteControlDataHandler @ 36 NONAME
+	_ZTV7CHsCore @ 37 NONAME
+	_ZTV9CHsClient @ 38 NONAME
+	_ZTV9CHsServer @ 39 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/group/bld.inf	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,34 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../inc/hscore.h headsetsimulator/hscore.h
+../inc/hsobserver.h headsetsimulator/hsobserver.h 
+../inc/hsclientobservers.h headsetsimulator/hsclientobservers.h
+../inc/RemoteControl/hsremoterequest.h headsetsimulator/hsremoterequest.h
+../inc/Plugin/hsecompluginbase.h headsetsimulator/hsecompluginbase.h
+../inc/Plugin/hscodpluginbase.h headsetsimulator/hscodpluginbase.h
+../inc/Plugin/hsprofilepluginbase.h headsetsimulator/hsprofilepluginbase.h
+../inc/Plugin/hssdppluginbase.h headsetsimulator/hssdppluginbase.h
+../inc/Plugin/hscodpluginbase.inl headsetsimulator/hscodpluginbase.inl
+../inc/Plugin/hsprofilepluginbase.inl headsetsimulator/hsprofilepluginbase.inl
+../inc/Plugin/hssdppluginbase.inl headsetsimulator/hssdppluginbase.inl
+
+
+PRJ_MMPFILES
+headsetsimulator.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/group/headsetsimulator.mmp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,59 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+TARGET		  headsetsimulator.dll
+TARGETTYPE	  dll
+UID			  0x1000008d 0xE026A1DD
+
+USERINCLUDE	 ../inc 
+USERINCLUDE	 ../inc/ProfileManager
+USERINCLUDE	 ../inc/Server
+USERINCLUDE	 ../inc/Tools
+USERINCLUDE  ../inc/RemoteControl 
+USERINCLUDE  ../inc/Plugin
+
+#include <platform_paths.hrh>
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE 	/epoc32/include/ecom
+SYSTEMINCLUDE	/epoc32/include/headsetsimulator
+
+LIBRARY		 euser.lib 
+LIBRARY		 ecom.lib 
+LIBRARY		 bluetooth.lib 
+LIBRARY		 btengconnman.lib 
+LIBRARY		 btengsettings.lib 
+LIBRARY		 esock.lib 
+LIBRARY		 sdpagent.lib 
+LIBRARY		 sdpdatabase.lib 
+LIBRARY		 btdevice.lib 
+LIBRARY		 btengdiscovery.lib 
+LIBRARY		 efsrv.lib 
+LIBRARY		 bafl.lib 
+
+SOURCEPATH ../src
+SOURCE hscore.cpp
+SOURCEPATH ../src/Tools
+SOURCE hsdevicediscoverer.cpp hsbtmanager.cpp
+SOURCEPATH ../src/Server
+SOURCE hsclient.cpp hsclientmanager.cpp hsserver.cpp
+SOURCEPATH ../src/ProfileManager
+SOURCE hsprofilemanager.cpp 
+SOURCEPATH ../src/RemoteControl
+SOURCE hsremotecontrolserver.cpp hsremotecontroldatahandler.cpp hsremotecontrolparser.cpp hsremotecontrolcommand.cpp
+SOURCEPATH ../src/Server
+SOURCE hsaudioserver.cpp
+
+CAPABILITY ALL -TCB
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/Plugin/hscodpluginbase.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,114 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSCODPLUGINBASE_H_
+#define HSCODPLUGINBASE_H_
+
+#include <ecom.h>
+#include <btdevice.h>
+#include <e32property.h>
+#include <bt_subscribe.h>
+#include <hsecompluginbase.h>
+
+/**
+ * CoD plugin UID
+ */
+const TUid KHsCoDBaseInterfaceDefinitionUid =
+    {
+    0xE0009DC2
+    };
+
+/**
+ * @brief Abstract methods for CoD plugin
+ */
+class MHsCoDBase
+{
+public:
+    /**
+     * Destructor
+     */
+    virtual ~MHsCoDBase() { };
+
+    /**
+     * Sets new Class of Device in properties registry
+     */
+    virtual void SetNewCodL() = 0;
+
+    /**
+     * Restores Class of Device  
+     * 
+     * @return error code value
+     */
+    virtual TInt RestoreOldCod() = 0;
+
+    /**
+     * Saves old CoD
+     * 
+     * @return error code value
+     */
+    virtual TInt SaveOldCod() = 0;
+};
+
+/**
+ * @brief Class allows to set new CoD. Each CoD plugin should derive from this class. 
+ */
+class CHsCoDBase : protected CHsEComPluginBase, public MHsCoDBase
+{
+public:
+
+    /**
+     * Two-phase constructor
+     * @param aUid plugin's UID
+     * @return instance of class
+     */
+    static CHsCoDBase* NewL( const TUid aUid );
+
+    /**
+     * Two-phase constructor
+     * @param aData plugin's name
+     * @return instance of class
+     */
+    static CHsCoDBase* NewL( const TDesC8 &aData );
+
+    /**
+     * Destructor.
+     */
+    virtual ~CHsCoDBase();
+
+public:
+    //Methods inherited from MHsCoDBase
+
+    virtual void SetNewCodL() = 0;
+
+    virtual TInt RestoreOldCod();
+
+    virtual TInt SaveOldCod();
+
+protected:
+    /**
+     * Restores Class of Device
+     * 
+     * @return error code value
+     */
+    TInt SetDefaultCod();
+
+    /** Default Class of Device */
+    TUint32 iDefaultDeviceClass;
+
+};
+
+#include "hscodpluginbase.inl"
+
+#endif /* HSCODPLUGINBASE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/Plugin/hscodpluginbase.inl	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,63 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+inline CHsCoDBase* CHsCoDBase::NewL( const TUid aUid )
+    {
+    TAny *impl = REComSession::CreateImplementationL( aUid, _FOFF( CHsCoDBase,
+            iDtor_ID_Key ) );
+    return (CHsCoDBase*) impl;
+    }
+
+inline CHsCoDBase* CHsCoDBase::NewL( const TDesC8 &aData )
+    {
+    TEComResolverParams params;
+
+    params.SetDataType( aData );
+    params.SetWildcardMatch( ETrue );
+
+    TAny *impl = REComSession::CreateImplementationL(
+            KHsCoDBaseInterfaceDefinitionUid,
+            _FOFF( CHsCoDBase, iDtor_ID_Key ), params );
+    return (CHsCoDBase*) impl;
+    }
+
+inline CHsCoDBase::~CHsCoDBase()
+    {
+    REComSession::DestroyedImplementation( iDtor_ID_Key );
+    }
+
+inline TInt CHsCoDBase::SetDefaultCod()
+    {
+    TBTDeviceClass defaultDeviceClass( iDefaultDeviceClass );
+    TInt err = RProperty::Set( KPropertyUidBluetoothCategory,
+            KPropertyKeyBluetoothSetDeviceClass,
+            defaultDeviceClass.DeviceClass() );
+    return err;
+    }
+
+inline TInt CHsCoDBase::RestoreOldCod()
+    {
+    return SetDefaultCod();
+    }
+
+inline TInt CHsCoDBase::SaveOldCod()
+    {
+    TInt defaultCoDasInt, err;
+    err = RProperty::Get( KPropertyUidBluetoothCategory,
+            KPropertyKeyBluetoothGetDeviceClass, defaultCoDasInt );
+    TBTDeviceClass defaultCoD( defaultCoDasInt );
+    iDefaultDeviceClass = defaultCoD.DeviceClass();
+    return err;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/Plugin/hsecompluginbase.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,31 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSECOMPLUGINBASE_H_
+#define HSECOMPLUGINBASE_H_
+
+#include <e32cmn.h>
+#include <e32base.h>
+
+/**
+ * @brief Base class for plugins.
+ */
+class CHsEComPluginBase : public CBase
+{
+protected:
+    TUid iDtor_ID_Key;
+};
+
+#endif /* HSECOMPLUGINBASE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/Plugin/hsprofilepluginbase.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,126 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSPROFILEBASE_H_
+#define HSPROFILEBASE_H_
+
+#include <e32cmn.h>
+#include <badesca.h>
+#include <ecom.h> 
+#include <hsecompluginbase.h>
+
+/**
+ * Profile plugin's UID
+ */
+const TUid KHsProfileBaseInterfaceDefinitionUid =
+    {
+    0xE0009DC1
+    };
+
+/**
+ * @brief Abstract methods for profile plugin
+ */
+class MHsProfileBase
+{
+public:
+    /**
+     * Destructor
+     */
+    virtual ~MHsProfileBase() {  };
+
+    /**
+     * Profile's method for handling AT Commands
+     * 
+     * @param aCommandsIn AT command received by HS
+     * @param aCommandsOut response
+     * @param aFromAG denotes if AT command was sent from AG
+     */
+    virtual void HandleCommandL( const TDesC8& aCommandsIn, TDes8& aCommandsOut,
+            const TBool aFromAG = ETrue ) = 0;
+
+    /**
+     * Profile's method for handling AG client disconnection
+     * 
+     * @param aErr disconnection reason
+     */
+    virtual void HandleClientDisconnected( TInt aErr ) = 0;
+
+    /**
+     * Profile's method for handling AG client connection
+     * 
+     * @param aCommandOut response
+     */
+    virtual void HandleClientConnected( TDes8& aCommandOut ) = 0;
+
+    /**
+     * Profile's method for accepting incoming call
+     * 
+     * @param aCommandOut response
+     */
+    virtual void HandleAcceptCallL( TDes8& aCommandOut ) = 0;
+
+    /**
+     * Profile's method for releasing ongoing call
+     * 
+     * @param aCommandOut response
+     */
+    virtual void HandleReleaseCallL( TDes8& aCommandOut ) = 0;
+
+};
+
+/**
+ * @brief Base class for profile plugins
+ */
+class CHsProfileBase : public CHsEComPluginBase, public MHsProfileBase
+{
+public:
+    /**
+     * Two-phase constructor
+     * @param aUid plugin's UID
+     * @return instance of class
+     */
+    static CHsProfileBase* NewL( const TUid aUid );
+
+    /**
+     * Two-phase constructor
+     * @param aProfileName plugin's name
+     * @return instance of class
+     */
+    static CHsProfileBase* NewL( const TDesC8 &aProfileName );
+
+public:
+    /**
+     * Destructor
+     */
+    virtual ~CHsProfileBase();
+
+public:
+    //Methods inherited  from MHsProfileBase
+
+    virtual void HandleCommandL( const TDesC8 &aCommandsIn, TDes8 &aCommandsOut,
+            const TBool aFromAG = ETrue ) = 0;
+
+    virtual void HandleClientDisconnected( TInt aErr ) = 0;
+
+    virtual void HandleClientConnected( TDes8& aCommandOut ) = 0;
+
+    virtual void HandleAcceptCallL( TDes8& aCommandOut ) = 0;
+
+    virtual void HandleReleaseCallL( TDes8& aCommandOut ) = 0;
+};
+
+#include "hsprofilepluginbase.inl"
+
+#endif /* HSPROFILEBASE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/Plugin/hsprofilepluginbase.inl	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,40 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+inline CHsProfileBase* CHsProfileBase::NewL( const TUid aUid )
+    {
+    TAny *any = REComSession::CreateImplementationL( aUid, _FOFF(
+            CHsProfileBase, iDtor_ID_Key ) );
+    return (CHsProfileBase*) any;
+    }
+
+inline CHsProfileBase* CHsProfileBase::NewL( const TDesC8 &aProfilName )
+    {
+    TEComResolverParams params;
+
+    params.SetDataType( aProfilName );
+    params.SetWildcardMatch( ETrue );
+
+    TAny *any = REComSession::CreateImplementationL(
+            KHsProfileBaseInterfaceDefinitionUid, _FOFF( CHsProfileBase,
+                    iDtor_ID_Key ), params );
+    return (CHsProfileBase*) any;
+    }
+
+inline CHsProfileBase::~CHsProfileBase()
+    {
+    REComSession::DestroyedImplementation( iDtor_ID_Key );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/Plugin/hssdppluginbase.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,104 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSSDPPLUGINBASE_H_
+#define HSSDPPLUGINBASE_H_
+
+#include <ecom.h> 
+#include <hsecompluginbase.h>
+
+/**
+ * SDP plugin's UID
+ */
+const TUid KHsSdpBaseInterfaceDefinitionUid =
+    {
+    0xE0009DC3
+    };
+
+/**
+ * @brief Abstract methods for SDP plugin
+ */
+class MHsSdpBase
+{
+public:
+    /**
+     * Destructor
+     */
+    virtual ~MHsSdpBase() {};
+
+    /**
+     * Setter for service's port
+     * 
+     * @param aPort port number
+     */
+    virtual void SetServicePort( TInt aPort ) = 0;
+
+    /**
+     * Creates SDP plugin's implementation
+     */
+    virtual void CreateSdpRecordL() = 0;
+
+    /**
+     * Deletes SDP plugin's implementation
+     */
+    virtual void DeleteSdpRecordL() = 0;
+};
+
+/**
+ * @brief Base class for SDP plugins
+ */
+class CHsSdpBase : public CHsEComPluginBase, public MHsSdpBase
+
+{
+public:
+    /**
+     * Two-phase constructor
+     * @param aUid plugin's UID
+     * @return instance of class
+     */
+    static CHsSdpBase* NewL( const TUid aUid );
+
+    /**
+     * Two-phase constructor
+     * @param aData plugin's name
+     * @return instance of class
+     */
+    static CHsSdpBase* NewL( const TDesC8 &aData );
+
+public:
+    /**
+     * Destructor
+     */
+    virtual ~CHsSdpBase();
+
+public:
+    //Methods inherited from MHsSdpBase
+
+    virtual void SetServicePort( TInt aPort );
+
+    virtual void CreateSdpRecordL() = 0;
+
+    virtual void DeleteSdpRecordL() = 0;
+
+protected:
+
+    /** Port of service */
+    TInt iServicePort;
+
+};
+
+#include "hssdppluginbase.inl"
+
+#endif /* HSSDPPLUGINBASE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/Plugin/hssdppluginbase.inl	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,45 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+inline CHsSdpBase* CHsSdpBase::NewL( const TUid aUid )
+    {
+    TAny *impl = REComSession::CreateImplementationL( aUid, _FOFF( CHsSdpBase,
+            iDtor_ID_Key ) );
+    return (CHsSdpBase*) impl;
+    }
+
+inline CHsSdpBase* CHsSdpBase::NewL( const TDesC8 &aData )
+    {
+
+    TEComResolverParams params;
+
+    params.SetDataType( aData );
+    params.SetWildcardMatch( ETrue );
+
+    TAny *impl = REComSession::CreateImplementationL(
+            KHsSdpBaseInterfaceDefinitionUid,
+            _FOFF( CHsSdpBase, iDtor_ID_Key ), params );
+    return (CHsSdpBase*) impl;
+    }
+
+inline CHsSdpBase::~CHsSdpBase()
+    {
+    REComSession::DestroyedImplementation( iDtor_ID_Key );
+    }
+
+inline void CHsSdpBase::SetServicePort( TInt aPort )
+    {
+    iServicePort = aPort;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/ProfileManager/hsprofilemanager.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,249 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSPROFILEMANAGER_H
+#define HSPROFILEMANAGER_H
+
+#include <hssdppluginbase.h>
+#include <hscodpluginbase.h>
+#include <hsprofilepluginbase.h>
+
+class CHsProfileBase;
+class CHsCoDBase;
+class CHsSdpBase;
+
+/**
+ * @brief Manages plugins loaded to Headset Simulator. 
+ */
+class CHsProfileManager : public CBase
+{
+public:
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @return class instance
+     */
+    static CHsProfileManager* NewL();
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @return class instance
+     */
+    static CHsProfileManager* NewLC();
+
+    /**
+     * Destructor.
+     */
+    ~CHsProfileManager();
+
+public:
+
+    /**
+     * Creates instance of profile's implementation
+     * 
+     * @param aProfileUid implementation's Uid
+     */
+    void LookupAndManageProfileL( const TUid aProfileUid );
+
+    /**
+     * Creates instance of profile's implementation
+     * 
+     * @param aProfileName implementation's name
+     */
+    void LookupAndManageProfileL( const TDesC8 &aProfileName );
+
+    /**
+     * Unloads profile implementation
+     */
+    void UnloadProfile();
+
+    /**
+     * Creates instance of SDP plugin's implementation
+     * 
+     * @pre call SetSdpServicePort()
+     * 
+     * @param aSdpUid implementation's Uid
+     */
+    void LookupAndManageSdpL( const TUid aSdpUid );
+
+    /**
+     * Creates instance of SDP plugin's implementation
+     * 
+     * @pre call SetSdpServicePort()
+     * 
+     * @param aSdpName implementation's name
+     */
+    void LookupAndManageSdpL( const TDesC8 &aSdpName );
+
+    /**
+     * Sets port number for SDP record
+     * 
+     * @param aPort port number
+     */
+    void SetSdpServicePort( TInt aPort );
+
+    /**
+     * Reloads SDP plugin's implementation
+     */
+    void RefreshSdp();
+
+    /**
+     * Loads SDP plugin's implementation
+     * @pre call LookupAndManageSdpL()
+     */
+    void LoadSdpL();
+
+    /**
+     * Unloads SDP plugin's implementation
+     */
+    void UnloadSdpL();
+
+    /**
+     * Creates instance of Class of Device plugin's implementation
+     * 
+     * @param aCoDUid implementation's Uid
+     */
+    void LookupAndManageCodL( const TUid aCoDUid );
+
+    /**
+     * Creates instance of Class of Device plugin's implementation
+     * 
+     * @param aCoDName implementation's name
+     */
+    void LookupAndManageCodL( const TDesC8 &aCoDName );
+
+    /**
+     * Loads Class of Device plugin
+     * 
+     * @pre call LookupAndManageCoDL() 
+     */
+    void LoadCodL();
+
+    /**
+     * Unloads Class of Device plugin
+     */
+    void UnloadCodL();
+
+    /**
+     * Checks if SDP plugin exists
+     * 
+     * @return ETrue if plugin's instance is loaded. Otherwise EFalse
+     */
+    TBool IsSdpPluginLoaded();
+
+    /**
+     * Checks if Profile plugin exists
+     * 
+     * @return ETrue if plugin's instance is loaded. Otherwise EFalse
+     */
+    TBool IsProfilePluginLoaded();
+
+    /**
+     * Checks if CoD plugin exists
+     * 
+     * @return ETrue if plugin's instance is loaded. Otherwise EFalse
+     */
+    TBool IsCoDPluginLoaded();
+
+    /**
+     * Handles AT commands passed to profile plugin
+     * 
+     * @param aCommandsIn data passed to profile's implementation
+     * @param aCommandOut response from profile's implementation
+     * @param aFromAG denotes if passed command should be treated as 
+     *                sent from AG
+     */
+    void HandleCommandL( const TDesC8 &aCommandsIn, TDes8 &aCommandOut,
+            TBool aFromAG = ETrue );
+
+    /**
+     * Handles client disconnection event
+     * 
+     * @param aErr disconnection reason
+     */
+    void HandleClientDisconnected( TInt aErr );
+
+    /**
+     * Handles client connection event.
+     * Profile may start initialization procedure if necessary.
+     * 
+     * @param aCommandOut response from profile's implementation
+     */
+    void HandleClientConnected( TDes8& aCommandOut );
+
+    /**
+     * Sends request to profile to accept incoming call.
+     * 
+     * @param aProfileResponse AT response
+     */
+    void AcceptIncomingCallL( TDes8& aProfileResponse );
+
+    /**
+     * Sends request to profile to release ongoing call.
+     * 
+     * @param aProfileResponse AT response
+     */
+    void ReleaseOngoingCallL( TDes8& aProfileResponse );
+    
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsProfileManager();
+
+    /**
+     * Default constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+
+    /**
+     * Destroys profile plugin
+     */
+    void DestroyProfile();
+
+    /**
+     * Destroys SDP plugin
+     */
+    void DestroySdpL();
+
+    /**
+     * Destroys CoD plugin
+     */
+    void DestroyCodL();
+
+private:
+
+    /** Port number */
+    TInt iSdpServicePort;
+
+    /** Denotes if SDP plugin exists */
+    TBool iSdpSet;
+
+    /** Pointer to profile plugin */
+    CHsProfileBase *iProfilePlugin;
+
+    /** Pointer to CoD plugin */
+    CHsCoDBase *iCoDPlugin;
+
+    /** Pointer to SDP plugin */
+    CHsSdpBase *iSdpPlugin;
+
+};
+
+#endif // HSPROFILMENAGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/RemoteControl/hsremotecontroldatahandler.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,94 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSREMOTECONTROLDATAHANDLER_H
+#define HSREMOTECONTROLDATAHANDLER_H
+
+#include <e32base.h>
+
+class THsRemoteControlCommand;
+class CHsRemoteControlParser;
+
+/**
+ * @brief Manages remote requests
+ */
+class CHsRemoteControlDataHandler : public CBase
+{
+
+public:
+    /**
+     * Two-phased constructor.
+     * 
+     * @return class instance
+     */
+    static CHsRemoteControlDataHandler* NewL();
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @return class instance
+     */
+    static CHsRemoteControlDataHandler* NewLC();
+
+    /**
+     * Destructor
+     */
+    ~CHsRemoteControlDataHandler();
+
+public:
+
+    /**
+     * Transforms remote requests into THsRemoteControlCommand objects
+     * 
+     * @param aDataIn remote request read from socket
+     * @param aCmd THsRemoteControlCommand object
+     * 
+     * @return error code.
+     *      KErrNone if OK
+     *      KErrArgument if command not valid or not supported
+     *      KErrGeneral, KErrOverflow if error in parsing
+     */
+    TInt RecognizeCommand( const TDesC8& aDataIn, 
+            THsRemoteControlCommand& aCmd );
+
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsRemoteControlDataHandler();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+
+    /**
+     * Checks if command is supported
+     * 
+     * @param aCmd command to be checked
+     * @return ETrue if OK, otherwise EFalse
+     */
+    TBool IsCommandValid( THsRemoteControlCommand& aCmd );
+
+private:
+
+    /** Pointer to parser. Owned */
+    CHsRemoteControlParser* iParser;
+
+};
+#endif // HSREMOTECONTROLDATAHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/RemoteControl/hsremotecontrolserver.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,258 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSREMOTECONTROLSERVER_H
+#define HSREMOTECONTROLSERVER_H
+
+#include <bt_sock.h> 
+#include <e32base.h>
+#include <es_sock.h>
+#include <btsdp.h>
+#include <hsclientobservers.h>
+
+class CHsCore;
+class CHsRemoteControlDataHandler;
+
+/**  
+ * The id used for advertising and discovering the remote control service. 
+ */
+const TUint32 KHsRemoteControlServiceID = 0xfabc234f;
+
+/** Avalaible service state */
+const TInt KServicAvailable = 0xFF;
+
+/** Unavalaible service state */
+const TInt KServiceUnavailable = 0x00;
+
+/** Buffer size */
+const TInt KHsRemoteControlBufferSize = 256;
+
+/** The number of connections allowed in the queue */
+const TInt KHsSizeOfListenQueue = 5;
+
+/** Useful constants */
+_LIT(KHsRFComm,"RFCOMM");
+_LIT(KServiceName, "HSControlServer");
+_LIT(KServiceDesc, "HSControlServer");
+
+/** Buffer for remote control */
+typedef TBuf8 <KHsRemoteControlBufferSize> THsRemoteControlBuffer;
+
+/**
+ * @brief Server for remote control requests
+ */
+class CHsControlServer : public CBase, public MBluetoothSocketNotifier
+{
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aSocketServ sesion to socket server
+     * @param aHsCore pointer to CHsCore
+     * @return class instance
+     */
+    static CHsControlServer* NewL( RSocketServ& aSocketServ, CHsCore* aHsCore );
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aSocketServ session to socket server
+     * @param aHsCore pointer to CHsCore
+     * @return class instance
+     */
+    static CHsControlServer* NewLC( RSocketServ& aSocketServ, 
+            CHsCore* aHsCore );
+
+    /**
+     * Destructor.
+     */
+    ~CHsControlServer();
+
+public:
+
+    /**
+     * Turns on server for remote control
+     */
+    void StartRemoteControlServerL();
+
+    /**
+     * Stops remote control server. Cancels receiving and sending data, destroys
+     * all CBluetoothSockets
+     */
+    void CancelListen();
+
+    /**
+     * Setter for observer
+     * 
+     * @param aConnectionObserver observer
+     */
+    void SetConnectionObserver(
+            MRemoteControllerConnectionObserver &aConnectionObserver );
+
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aSocketServ sesion to socket server
+     * @param aHsCore pointer to CHsCore
+     */
+    CHsControlServer( RSocketServ& aSocketServ, CHsCore* aHsCore );
+
+    /**
+     * Default constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+    /**
+     * Sends data to client.
+     * 
+     * @param aData message to be send
+     *  
+     * @return error code
+     */
+    TInt Send( const TDesC8& aData );
+
+    /**
+     * Receives data from listening socket.
+     */
+    void Receive();
+
+    /**
+     * Registers service in SDP database
+     *  
+     * @param aChannel port number
+     * @return error code. KErrNone if success
+     */
+    void RegisterSdpL( TInt aChannel );
+
+    /**
+     * Updates availability of service registered in SDP database
+     * 
+     * @param aAvailable service availability
+     */
+    void UpdateAvailabilityL( TBool aAvailable );
+
+    /**
+     * Deletes service record from SDP database
+     */
+    void DeleteRecordSdp();
+
+    /**
+     * Handles incoming remote control request
+     * 
+     * @param aRequest 8-bit desciptor containing request
+     */
+    void HandleRequestL( TDes8& aRequest );
+
+    /**
+     * Retrieves 'HsTurnOn' command's data needed for HS's initialization
+     * 
+     * @param aParams command's data
+     * @param aPluginCod Cod plugin's name
+     * @param aPluginSdp Sdp plugin's name
+     * @param aPluginName profile plugin's name
+     */
+    void RetrieveStartupParamsL( const TDesC8& aParams, RBuf8& aPluginCod,
+            RBuf8& aPluginSdp, RBuf8& aPluginProfile );
+
+private:
+    //Methods inherited from MBluetoothSocketNotifier
+
+    void HandleConnectCompleteL( TInt aErr );
+
+    void HandleAcceptCompleteL( TInt aErr );
+
+    void HandleShutdownCompleteL( TInt aErr );
+
+    void HandleSendCompleteL( TInt aErr );
+
+    void HandleReceiveCompleteL( TInt aErr );
+
+    void HandleIoctlCompleteL( TInt aErr );
+
+    void HandleActivateBasebandEventNotifierCompleteL( TInt aErr,
+            TBTBasebandEventNotification& aEventNotification );
+
+private:
+
+    /** States of the Remote control server */
+    enum THsRemoteControlState
+    {
+        /** Not initialized */
+        ENone = 1,
+        /** Connection attempt ongoing */
+        EConnecting,
+        /** Ready for clients */
+        EWaiting
+    };
+
+    /** Current state */
+    THsRemoteControlState iState;
+
+    /** Listening status */
+    TBool iInitialized;
+
+    /** Server port */
+    TInt iServerPort;
+
+    /** Service record state */
+    TInt iRecordState;
+
+    /** Data length */
+    TSockXfrLength iDataLength;
+
+    /** Holds received data */
+    THsRemoteControlBuffer iReceiveDataBuffer;
+
+    /** Used for buffering data */
+    THsRemoteControlBuffer iTempDataBuffer;
+
+    /** Holds data to be send */
+    THsRemoteControlBuffer iSendDataBuffer;
+
+    /** Service record */
+    TSdpServRecordHandle iSdpRecordHandle;
+
+    /** Service discovery database session */
+    RSdp iSdpServer;
+
+    /** Service discovery database subsession */
+    RSdpDatabase iSdpDB;
+
+    /** Creates subsession to socket server */
+    RSocketServ &iSocketServ;
+
+    /** Socket for listening for new connections */
+    CBluetoothSocket *iListenSocket;
+
+    /** Socket */
+    CBluetoothSocket *iSocket;
+
+    /** Pointer to CHsCore */
+    CHsCore *iHsCore;
+
+    /** Pointer to CHsRemoteControlDataHandler */
+    CHsRemoteControlDataHandler* iDataHandler;
+
+    /** Pointer to observer */
+    MRemoteControllerConnectionObserver *iConnectionObserver;
+
+};
+
+#endif // HSREMOTECONTROLSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/RemoteControl/hsremotecontroltools.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,160 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSREMOTECONTROLTOOLS_H
+#define HSREMOTECONTROLTOOLS_H
+
+#include <e32base.h>
+
+#include "hsremoterequest.h"
+
+/** Request package length */
+const TInt KHsRemoteControlPackageLength = 128;
+
+/** Request package header length */
+const TInt KHsRemoteControlPackageTypeMaxLength = 2;
+
+_LIT8(KHsRemoteControllerPackageDelim, ":");
+
+/** Request package data */
+typedef TBuf8 <KHsRemoteControlPackageLength> THsControlCommandData;
+
+/**
+ * @brief Represents remote control request
+ */
+class THsRemoteControlCommand
+{
+public:
+    /**
+     * Constructor
+     * 
+     * @param aData data
+     * @param aCommandType type of command
+     */
+    THsRemoteControlCommand( THsControlCommandData& aData,
+            THsRemoteControlCommandType aCommandType );
+
+public:
+
+    /**
+     * Getter for type of command
+     * 
+     * @param aCmdType type  
+     */
+    void GetType( THsRemoteControlCommandType &aCmdType );
+
+    /**
+     * Getter for command's data
+     * 
+     * @param aCmdData data
+     * 
+     */
+    void GetData( TDes8 &aCmdData );
+
+    /**
+     * Clones THsRemoteControlCommand object
+     * 
+     * @param aCmdFrom source
+     * @param aCmdTo destination 
+     */
+    static void Copy( const THsRemoteControlCommand& aCmdFrom,
+            THsRemoteControlCommand& aCmdTo );
+private:
+
+    /** Data */
+    THsControlCommandData &iData;
+
+    /** Type */
+    THsRemoteControlCommandType iType;
+};
+
+/**
+ * @brief Parser for remote control packages
+ */
+class CHsRemoteControlParser : public CBase
+{
+public:
+    /**
+     * Two-phased constructor.
+     * 
+     * @return class instance
+     */
+    static CHsRemoteControlParser* NewL();
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @return class instance
+     */
+    static CHsRemoteControlParser* NewLC();
+
+    /** 
+     * Destructor
+     */
+    ~CHsRemoteControlParser();
+
+public:
+    /**
+     * Parses and transforms data into THsRemoteControlCommand object
+     * 
+     * @param aText remote request package
+     * @param aCommand created command
+     */
+    void ParseL( const TDesC8 &aText, THsRemoteControlCommand &aCommand );
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsRemoteControlParser();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+
+    /**
+     * Checks if package is proper
+     * 
+     * @aData remote request package
+     * @return ETrue if OK, otherwise EFalse
+     */
+    TBool IsPackageValid( const TDesC8 &aData );
+
+    /**
+     * Retrieves header part and data part of remote request package
+     * 
+     * @param aData remote request package
+     * @param aTypePart header of the package
+     * @param aDataPart package's data
+     * @return error code value
+     */
+    TInt SplitPackage( const TDesC8 &aData, TDes8 &aTypePart, TDes8 &aDataPart );
+
+    /**
+     * Transforms header of the package into THsRemoteControlCommandType
+     *
+     * @param aTypePart header of the package
+     * @param aCommandType header tranformed into THsRemoteControlCommandType object
+     * @return error code value
+     */
+    TInt RecognizeType( const TDesC8 &aTypePart,
+            THsRemoteControlCommandType &aCommandType );
+
+};
+
+#endif // HSREMOTECONTROLTOOLS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/RemoteControl/hsremoterequest.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,50 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSREMOTEREQUEST_H_
+#define HSREMOTEREQUEST_H_
+
+_LIT8(KHsRemoteRequestParamSeparator,"::");
+
+/** Types of request packages */
+enum THsRemoteControlCommandType
+{
+    /** Requests turning HS on (i.e. provide headset service) */
+    EHsTurnOn = 0,
+    /** Requests turning HS off (i.e. stop providing headset service */
+    EHsTurnOff,
+    /** Connect with bluetooth AG address */
+    EHsConnectDevAddress,
+    /** Connect with bluetooth AG name */
+    EHsConnectName,
+    /** Connect with last-connected AG */
+    EHsConnectLastconnected,
+    /** Disconnect AG */
+    EHsDisconnectAGs,
+    /** Accept incoming call */
+    EHsAcceptCall,
+    /** Release call */
+    EHsReleaseCall,
+    /** Set microphone volume */
+    EHsSetMicVolume,
+    /** Set speaker volume */
+    EHsSetSpeakerVolume,
+    /** Sends AT command */
+    EHsSendAnyAt,
+    /** Not used */
+    EHsLast
+};
+
+#endif /* HSREMOTEREQUEST_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/Server/hsaudioserver.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,155 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSAUDIOSERVER_H_
+#define HSAUDIOSERVER_H_
+
+#include <e32std.h>
+#include <bt_sock.h>
+
+/** Buffer size */
+const TInt KHsSynchronousBufferLength = 128;
+
+/**
+ * @brief Server for SCO connections
+ */
+class CHsAudioServer : public CBase, public MBluetoothSynchronousLinkNotifier
+{
+public:
+    /**
+     * Two-phase constructor
+     * @param aSocketServ socket server session
+     * @param aPullAudio denotes if audio should be pulled
+     * @return instance of class
+     */
+    static CHsAudioServer* NewL( RSocketServ& aSocketServ, TBool aPullAudio );
+
+    /**
+     * Two-phase constructor
+     * @param aSocketServ socket server session
+     * @param aPullAudio denotes if audio should be pulled
+     * @return instance of class
+     */
+    static CHsAudioServer* NewLC( RSocketServ& aSocketServ, TBool aPullAudio );
+
+    /**
+     * Destructor
+     */
+    ~CHsAudioServer();
+
+public:
+
+    /**
+     * Prepares audio server for incoming connections
+     */
+    void ListenL();
+
+    /**
+     * Connects audio server to the specified device
+     * 
+     * @param aAddr device's bluetooth address
+     */
+    void ConnectL( const TBTDevAddr &aAddr );
+
+    /**
+     * Closes current connections and prepares the server for the new one
+     */
+    void Disconnect();
+
+    /**
+     * Turns off audio server
+     */
+    void Shutdown();
+
+    /**
+     * Method allows to accept \ reject SCO connection establishment 
+     * 
+     * @param aPullAudio ETrue if SCO connection is supposed to be accepted 
+     */
+    void SetPullAudio( TBool aPullAudio );
+
+    /**
+     * Checks if client is connected
+     * 
+     * @return ETrue if client connected
+     */
+    TBool IsConnected();
+
+    /**
+     * Checks if server is ready for incoming requests
+     * 
+     * @return ETrue if server is ready
+     */
+    TBool IsListen();
+
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aSocketServ socket server session
+     * @param aPullAudio denotes if audio should be pulled
+     */
+    CHsAudioServer( RSocketServ& aSocketServ, TBool aPullAudio );
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+    // Methods derived from MBluetoothSynchronousLinkNotifier
+
+    void HandleSetupConnectionCompleteL( TInt aErr );
+
+    void HandleDisconnectionCompleteL( TInt aErr );
+
+    void HandleAcceptConnectionCompleteL( TInt aErr );
+
+    void HandleSendCompleteL( TInt aErr );
+
+    void HandleReceiveCompleteL( TInt aErr );
+
+private:
+
+    /** Session of socket server */
+    RSocketServ& iSServ;
+
+    /** SCO socket */
+    CBluetoothSynchronousLink* iSCOSocket;
+
+    /** Buffer for received data */
+    TBuf8 <KHsSynchronousBufferLength> iReceiveBuffer;
+
+    /** Buffer for data to be send */
+    TBuf8 <KHsSynchronousBufferLength> iSendBuffer;
+
+    /** Types of accepted SCO packets */
+    TBTSyncPackets iAcceptedPackets;
+
+    /** DevAddr of connected device */
+    TBTDevAddr iAddr;
+
+    /** Denotes if server is ready for incoming connections */
+    TBool iListening;
+
+    /** Denotes if client is connected */
+    TBool iConnected;
+
+    /** Denotes if audio should be transferred */
+    TBool iPullAudio;
+};
+
+#endif /* HSAUDIOSERVER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/Server/hsclient.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,212 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSCLIENT_H_
+#define HSCLIENT_H_
+
+#include <bt_sock.h>
+
+class MHsClientObserver;
+class MHsClientStateNotifier;
+
+/** Length of AG's receive and send data buffer */
+const TInt32 KHsClientBufferLength = 0x800;
+
+/** Buffer for communication with AG */
+typedef TBuf8 <KHsClientBufferLength> THsClientBuffer;
+
+/**
+ * @brief Class represents AG client.
+ */
+class CHsClient : public CBase, public MBluetoothSocketNotifier
+{
+public:
+
+    /**
+     * Two-phase constructor
+     * 
+     * @param aClient socket which AG is connected
+     * @param aClientStateNotifier pointer to AG state observer
+     * @param aClientDisconnectNotifier pointer to AG disconnection observer
+     * @return instance of class
+     */
+    static CHsClient* NewL( CBluetoothSocket* aClient,
+            MHsClientStateNotifier* aClientStateNotifier = NULL,
+            MHsClientObserver* aClientDisconnectNotifier = NULL );
+
+    /**
+     * Two-phase constructor
+     * 
+     * @param aClient socket which AG is connected
+     * @param aClientStateNotifier pointer to AG state observer
+     * @param aClientDisconnectNotifier pointer to AG disconnection observer
+     * @return instance of class
+     */
+    static CHsClient* NewLC( CBluetoothSocket* aClient,
+            MHsClientStateNotifier* aClientStateNotifier = NULL,
+            MHsClientObserver* aClientDisconnectNotifier = NULL );
+
+    /**
+     * Destructor
+     */
+    ~CHsClient();
+
+public:
+    /**
+     * Sends data to AG.
+     * 
+     * @pre AG client is connected
+     * 
+     * @param aData data to be send
+     */
+    void Send( const TDesC8& aData );
+
+    /**
+     * Sets observer of AG's disconnection.
+     * 
+     * @param aNotifier reference to MHsClientObserver
+     */
+    void SetClientDisconnectNotfier( MHsClientObserver& aNotifier );
+
+    /**
+     * Sets observer of AG's states.
+     * 
+     * @param aNotifier reference to MHsClientStateNotifier
+     */
+    void SetClientStateNotfier( MHsClientStateNotifier& aNotifier );
+
+    /**
+     * Returns pointer to AG's states observer.
+     */
+    MHsClientStateNotifier* GetClientStateNotifer();
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aClient socket which AG is connected
+     * @param aClientStateNotifier pointer to AG state observer
+     * @param aClientDisconnectNotifier pointer to AG disconnection observer
+     */
+    CHsClient( CBluetoothSocket& aClient,
+            MHsClientStateNotifier* aClientStateNotifier = NULL,
+            MHsClientObserver* aClientDisconnectNotifier = NULL );
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+
+    /**
+     * Receives data from AG.
+     * 
+     * @param aData received data buffer
+     * 
+     * @leave KErrNoMemory if AG socket is NULL
+     * @leave KErrDisconnected if AG is not connected
+     */
+    void RawRecvL( TDes8& aData );
+
+    /**
+     * Sends data to AG.
+     * 
+     * @param aData data to be send
+     * 
+     * @leave KErrNoMemory if AG socket is NULL
+     * @leave KErrDisconnected if AG is not connected
+     * @leave KErrWrite if parameter is empty
+     */
+    void RawSendL( const TDesC8& aData );
+
+    /**
+     * Sends data to AG with double buffering and init receiving when there 
+     * is no data to be send.
+     * 
+     * @param aData data to be send
+     */
+    void BufferedProcessL( const TDesC8& aData = KNullDesC8 );
+
+    /**
+     * Swaps sending buffers.
+     */
+    void SwapBuffers();
+
+private:
+    //Methods derived from MBluetoothSocketNotifier
+    void HandleConnectCompleteL( TInt aErr );
+
+    void HandleAcceptCompleteL( TInt aErr );
+
+    void HandleShutdownCompleteL( TInt aErr );
+
+    void HandleSendCompleteL( TInt aErr );
+
+    void HandleReceiveCompleteL( TInt aErr );
+
+    void HandleIoctlCompleteL( TInt aErr );
+
+    void HandleActivateBasebandEventNotifierCompleteL( TInt aErr,
+            TBTBasebandEventNotification& aEventNotification );
+
+private:
+
+    /** AG client state enum */
+    enum THsClientState
+    {
+        /** Idle state */
+        EIdle = 0,
+        /** Sending state */
+        ESending,
+        /** Receiving state */
+        EReceiving
+    };
+
+    /** AG client's state */
+    THsClientState iState;
+
+    /** Bluetooth information receive flags */
+    TInt iReceiveFlag;
+
+    /** Bluetooth information send flags */
+    TInt iSendFlag;
+
+    /** Denotes if AG is connected */
+    TBool iConnected;
+
+    /** Length indicating how much data was read */
+    TSockXfrLength iReceiveMessageLength;
+
+    /** Receive data buffer */
+    THsClientBuffer iReceiveMessageBuffer;
+
+    /** Send data buffer */
+    THsClientBuffer iSendBuf;
+
+    /** Temporary send data buffer */
+    THsClientBuffer iTempSendBuf;
+
+    /** Bluetooth socket */
+    CBluetoothSocket* iSocket;
+
+    /** Pointer to MHsClientStateNotifier. Not owned */
+    MHsClientStateNotifier* iStateNotifier;
+
+    /** Pointer to MHsClientObserver. Not owned */
+    MHsClientObserver* iClientObserver;
+};
+
+#endif /* HSCLIENT_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/Server/hsclientmanager.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,117 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSCLIENTMANAGER_H_
+#define HSCLIENTMANAGER_H_
+
+#include <e32base.h>
+#include <hsclientobservers.h>
+
+class CHsClient;
+class MHsClientStateNotifier;
+
+/** Array of AG clients */
+typedef RPointerArray <CHsClient> RClientArray;
+/** Array of AG clients' observers */
+typedef RPointerArray <MHsClientStateNotifier> RClientObserverArray;
+
+/** Size of arrays used by Client Manager */
+const TInt KHsClientManagerArrayMinSize = 0x10;
+/** Default AG client index */
+const TInt KHsDefaultClientNumber = 0;
+
+/**
+ * @brief Class manages AG clients connected with Headset Simulator.
+ */
+class CHsClientManager : public CBase, public MHsClientObserver
+{
+public:
+    /**
+     * Two-phase constructor
+     * @return instance of class
+     */
+    static CHsClientManager* NewL();
+
+    /**
+     * Two-phase constructor
+     * @return instance of class
+     */
+    static CHsClientManager* NewLC();
+
+    /**
+     * Destructor
+     */
+    ~CHsClientManager();
+
+public:
+
+    /**
+     * Sets observer of AG's states.
+     * 
+     * @param aClientStateNotifier reference to MHsClientStateNotifier
+     * @param aNumber index of AG client
+     * 
+     * @leave KErrUnderflow if aNumber parameter is negative
+     * @leave KErrOverflow if aNumber parameter is greater than size of 
+     * clients' array
+     */
+    void SetClientStateNotfierL( MHsClientStateNotifier &aClientStateNotifier,
+            TInt aNumber = 0 );
+
+    /**
+     * Sends AT command to AG.
+     * 
+     * @param aAt data to be send
+     * @param aNumber specified to which AG data should be send
+     * 
+     * @return KErrNone if successful, KErrNotFound if aNumber parameter is
+     * not correct index in AG clients' array
+     */
+    TInt Send( const TDesC8 &aAt, TInt aNumber = KHsDefaultClientNumber );
+
+    /**
+     * Disconnects from AGs.
+     * 
+     * When request completes notification is sent to 
+     * MHsObserver::HandleDisconnectedFromClient().
+     */
+    void DisconnectClients();
+
+public:
+    //Methods inherited from MHsClientObserver
+    void HandleNewClientL( CHsClient *aClient, TInt aErr );
+
+    void HandleClientDisconnect( CHsClient *aClient, TInt aErr );
+
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsClientManager();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+    /** Array of AG clients */
+    RClientArray iClientArray;
+    /** Array of AG clients' observers */
+    RClientObserverArray iObserverArray;
+};
+
+#endif /* HSCLIENTMANAGER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/Server/hsserver.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,164 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSSERVER_H
+#define HSSERVER_H
+
+#include <bt_sock.h>
+#include <bttypes.h>
+
+class CBluetoothSocket;
+class RSocketServ;
+class MHsAcceptNewClientObserver;
+
+/** The number of connections allowed in the queue */
+const TUint KListenQueueSize = 10;
+
+/** Buffer size */
+const TInt KMaxTHSConnectionBufferSize = 1024;
+
+/**
+ * @brief Server that listens and handles physical link connection with AG device.
+ */
+class CHsServer : public CBase, public MBluetoothSocketNotifier
+{
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aSocketServ session of socket server
+     * @return instance of class
+     */
+    static CHsServer* NewL( RSocketServ &aSocketServ );
+
+    /**
+     * Two-phased constructor.
+     * @param aSocketServ session of socket server
+     * @return instance of class
+     */
+    static CHsServer* NewLC( RSocketServ &aSocketServ );
+
+    /**
+     * Destructor
+     */
+    ~CHsServer();
+
+public:
+
+    /**
+     * Turns on server. Method listens (RFCOMM protocol) and accepts ongoing 
+     * connections. Server gets the first free port number in system.
+     * 
+     * @return KErrNone if successful, 
+     * KErrAlreadyExists if server is already running,
+     * otherwise one of the system-wide error codes                                      
+     */
+    TInt Listen();
+
+    /**
+     * Returns server listening status.
+     * 
+     * @return ETrue if server listens, otherwise EFalse
+     */
+    TBool IsReady();
+
+    /**
+     * Shutdowns server. Cancels receiving and sending data, disconnects 
+     * clients and destroys all bluetooth sockets.
+     */
+    void Shutdown();
+
+    /**
+     * Sets new client observer.
+     * 
+     * @param aNewClientObserv reference to observer
+     */
+    void SetNewClientObserver( MHsAcceptNewClientObserver &aNewClientObserv );
+
+    /**
+     * Returns listening server port.
+     * 
+     * @return port number
+     */
+    TInt GetPort();
+
+    /**
+     * Connects to AG client's socket.
+     * 
+     * @param aAddr socket address
+     * 
+     * @leave KErrInUse if the device is already being used
+     */
+    void GetSocketAndTryToConnectL( const TBTSockAddr &aAddr );
+
+protected:
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aSocketServ session of socket server
+     */
+    CHsServer( RSocketServ &aSocketServ );
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+    //Methods inhertited from MBluetoothSocketNotifier
+    void HandleConnectCompleteL( TInt aErr );
+
+    void HandleAcceptCompleteL( TInt aErr );
+
+    void HandleShutdownCompleteL( TInt aErr );
+
+    void HandleSendCompleteL( TInt aErr );
+
+    void HandleReceiveCompleteL( TInt aErr );
+
+    void HandleIoctlCompleteL( TInt aErr );
+
+    void HandleActivateBasebandEventNotifierCompleteL( TInt aErr,
+            TBTBasebandEventNotification& aEventNotification );
+private:
+
+    /** Listening status */
+    TBool iListen;
+
+    /** Server port */
+    TInt iPort;
+
+    /** Service security */
+    TBTServiceSecurity iServerSecurity;
+
+    /** Session of socket server */
+    RSocketServ &iSServ;
+
+    /** Socket for listening for new connections */
+    CBluetoothSocket *iSocketServer;
+
+    /** Client socket */
+    CBluetoothSocket *iBlankSocket;
+
+    /** Second client socket */
+    CBluetoothSocket *iBlankSocket2;
+
+    /** Pointer to observer */
+    MHsAcceptNewClientObserver *iNewClientObserver;
+};
+
+#endif // HSSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/Tools/hstools.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,384 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSTOOLS_H
+#define HSTOOLS_H
+#include <btsdp.h> 
+#include <btengconnman.h> 
+#include <btengsettings.h>
+#include <btengdiscovery.h>
+#include <hsclientobservers.h>
+
+class CBTEngSettings;
+class CBTEngConnMan;
+class CBTEngDiscovery;
+class RSocketServ;
+
+/** Default bluetooth name */
+_LIT(KHsDefaultName,"HS_Name");
+
+/** Headset protocol name */
+_LIT(KHsProtocolName,"BTLinkManager");
+
+/** Length of device bluetooth address */
+const TInt KDevAddrLength = KBTDevAddrSize * 2;
+
+/**
+ * @brief Observer to notify about found devices during inquiry.
+ */
+class MHsDeviceDiscovererObserver
+{
+public:
+    /**
+     * Informs that device was found during inquiry
+     * 
+     * @param aDevAddress 8-bit descriptor containing bluetooth address
+     * @param aDevName  8-bit descriptor containing bluetooth name
+     * @param aMajServClass major service class - part of Class of Device
+     * @param aMajDeviceClass major device class - part of Class of Device
+     * @param aMinDeviceClass minor device class - part of Class of Device
+     */
+    virtual void HandleDeviceFindSuccessL( TDesC8 & aDevAddress,
+            TDesC8 & aDevName, TUint16 aMajServClass, TUint aMajDeviceClass,
+            TUint8 aMinDeviceClass ) = 0;
+
+    /**
+     * Informs that inquiry finished
+     * 
+     * @param aErr system-wide error code
+     */
+    virtual void HandleDeviceFindFailed( TInt aErr ) = 0;
+};
+
+/**
+ * @brief Class asynchronously finds devices equipped with bluetooth.
+ */
+class CHsDeviceDiscoverer : public CActive
+{
+public:
+    /**
+     * Two-phase constructor
+     * @param aDeviceObserver inquiry observer
+     * @param aSocketServ session of socket server
+     * @return instance of class
+     */
+    static CHsDeviceDiscoverer* NewL(
+            MHsDeviceDiscovererObserver *aDeviceObserver,
+            RSocketServ &aSocketServ );
+
+    /**
+     * Two-phase constructor
+     * @param aDeviceObserver inquiry observer
+     * @param aSocketServ session of socket server
+     * @return instance of class
+     */
+    static CHsDeviceDiscoverer* NewLC(
+            MHsDeviceDiscovererObserver *aDeviceObserver,
+            RSocketServ &aSocketServ );
+
+    /**
+     * Destructor
+     */
+    ~CHsDeviceDiscoverer();
+
+public:
+    /**
+     * Asynchronous method for searching devices.
+     */
+    void DeviceSearchL();
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aDeviceObserver pointer to inquiry observer 
+     * @param aSocketServ session of socket server 
+     */
+    CHsDeviceDiscoverer( MHsDeviceDiscovererObserver *aDeviceObserver,
+            RSocketServ &aSocketServ );
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+    /**
+     * Initializes and connects host resolver.
+     */
+    void ConnectHostResolverL();
+
+private:
+    /**
+     * CActive method. 
+     * When request of searching devices completes with success, notification
+     * is sent to MHsDeviceDiscovererObserver::HandleDeviceFindSuccessL(), 
+     * otherwise to MHsDeviceDiscovererObserver::HandleDeviceFindFailed().
+     */
+    void RunL();
+
+    /**
+     * CActive method. Cancels of an outstanding request of searching devices.
+     */
+    void DoCancel();
+
+private:
+
+    /** Denotes if searching is in progress*/
+    TBool iSearching;
+
+    /** Socket address used for inquiry */
+    TInquirySockAddr iSockAddr;
+
+    /** Wrapps bluetooth device name */
+    TNameEntry iEntry;
+
+    /** Session of socket server */
+    RSocketServ &iSocketServ;
+
+    /**Provides methods to find devices*/
+    RHostResolver iHostResolver;
+
+    /** Pointer to observer to notify about founded devices. Not owned. */
+    MHsDeviceDiscovererObserver *iDeviceObserver;
+};
+
+/**
+ * @brief Provides handling of bluetooth. Manages searching for and connection with AG.
+ */
+class CHsBTManager : public CBase, public MBTEngSettingsObserver,
+        public MBTEngConnObserver, public MHsDeviceDiscovererObserver,
+        public MBTEngSdpResultReceiver
+{
+
+public:
+
+    /**
+     * Two-phased constructor
+     * 
+     * @param aSocketServ socket server subsession
+     * @param aBTManagerObserver pointer to observer
+     * 
+     * @return instance of class
+     */
+    static CHsBTManager* NewL( RSocketServ& aSocketServ,
+            MHsBTManagerObserver* aBTManagerObserver );
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aSocketServ socket server subsession
+     * @param aBTManagerObserver pointer to observer
+     * 
+     * @return instance of class
+     */
+    static CHsBTManager* NewLC( RSocketServ& aSocketServ,
+            MHsBTManagerObserver* aBTManagerObserver );
+
+    /**
+     * Destructor.
+     */
+    ~CHsBTManager();
+
+public:
+    /*
+     * Sets bluetooth name
+     * @param aBTName new bluetooth name
+     */
+    void SetBTNameL( const TDesC& aBTName );
+
+    /**
+     * Turns on bluetooth on device.
+     * @param aName new bluetooth name
+     */
+    void TurnBtOnL( const TDesC& aName = KHsDefaultName );
+
+    /**
+     * Turns off bluetooth on device.
+     */
+    void TurnBtOffL();
+
+    /**
+     * Connects with AG by bluetooth address
+     * 
+     * @pre SetService() should be called
+     * 
+     * @param aDevAddress bluetooth address
+     */
+    void FindDevL( const TDesC& aDevAddress );
+
+    /**
+     * Connects with AG by bluetooth name
+     * 
+     * @pre SetService() should be called
+     * 
+     * @param aDeviceName bluetooth name
+     */
+    void FindNameL( const TDesC& aDeviceName );
+
+    /**
+     * Sets Headset Simulator's service
+     * 
+     * @param aService service Uuid
+     */
+    void SetService( const TUUID& aService );
+
+    /**
+     * Cancels ongoing attempt to connect with AG.
+     */
+    void CancelConnecting();
+
+    /**
+     * Sets bluetooth visibility mode.
+     * 
+     * @param aVisibilityMode mode
+     * 
+     * @return error value. KErrNotFound in case of failure, otherwise KErrNone
+     */
+    TInt SetVisible( TBTVisibilityMode aVisibilityMode );
+
+public:
+    // Methods derived from  MHsDeviceDiscovererObserver
+    void HandleDeviceFindSuccessL( TDesC8& aDevAddress, TDesC8& aDevName,
+            TUint16 aMajServClass, TUint aMajDeviceClass,
+            TUint8 aMinDeviceClass );
+
+    void HandleDeviceFindFailed( TInt aErr );
+
+public:
+    // Methods derived from MBTEngSettingsObserver
+    void PowerStateChanged( TBTPowerStateValue aState );
+
+    void VisibilityModeChanged( TBTVisibilityMode aState );
+
+public:
+    // Methods derived from MBTEngConnObserver
+
+    void ConnectComplete( TBTDevAddr& aAddr, TInt aErr,
+            RBTDevAddrArray* aConflicts = NULL );
+
+    void DisconnectComplete( TBTDevAddr& aAddr, TInt aErr );
+
+    void PairingComplete( TBTDevAddr& aAddr, TInt aErr );
+
+public:
+    // Methods derived from MBTEngSdpResultReceiver
+    void ServiceSearchComplete( const RSdpRecHandleArray& aResult,
+            TUint aTotalRecordsCount, TInt aErr );
+
+    void AttributeSearchComplete( TSdpServRecordHandle aHandle,
+            const RSdpResultArray& aAttr, TInt aErr );
+
+    void ServiceAttributeSearchComplete( TSdpServRecordHandle aHandle,
+            const RSdpResultArray& aAttr, TInt aErr );
+
+    void DeviceSearchComplete( CBTDevice* aDevice, TInt aErr );
+
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsBTManager( RSocketServ& aSocketServ,
+            MHsBTManagerObserver* aBTManagerObserver );
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+    /*
+     * Restores local name and power state to initial values.
+     */
+    void RestoreInitialSettings();
+
+    /*
+     * Finds service on a specified device.
+     * 
+     * @param aDevAddr  bluetooth address
+     * @param aService  service UUID
+     */
+    void FindServiceL( const TBTDevAddr& aDevAddr, const TUUID& aService );
+
+    /**
+     * Finds port on AG.
+     * 
+     * @param aAttr Sdp result array
+     * @param aPort on return, port number
+     * 
+     * @return error value. KErrNotFound in case of failure, otherwise KErrNone
+     */
+    TInt FindPort( const RSdpResultArray& aAttr, TInt &aPort );
+
+private:
+    /** Searching type enum */
+    enum TLookingFor
+    {
+        /** Search device by bluetooth name*/
+        EName,
+        /** Search device by bluetooth address*/
+        EDevAddress
+    };
+
+    /** Searching type */
+    TLookingFor iLookingFor;
+
+    /** Service */
+    TUUID iService;
+
+    /** Denotes if service is set */
+    TBool iServiceSet;
+
+    /** Bluetooth address */
+    TBTDevAddr iDevAddr;
+
+    /** Needed for restoring bluetooth power state */
+    TBTPowerStateValue iBTInitialPowerState;
+
+    /** Needed for restoring bluetooth visibility mode */
+    TBTVisibilityMode iBTInitialVisibilityMode;
+
+    /** Needed for restoring bluetooth name */
+    RBuf iBTInitialName;
+
+    /** Bluetooth name */
+    RBuf iBTName;
+
+    /** Bluetooth name to be searched */
+    RBuf iDesiredName;
+
+    /** Bluetooth address to be searched */
+    RBuf8 iDesiredDevAdrress;
+
+    /** Session of socket server */
+    RSocketServ& iSocketServ;
+
+    /** Pointer to bluetooth settings (power state, local name). Owned */
+    CBTEngSettings* iBTSettings;
+
+    /** Pointer to bluetooth connection manager. Owned */
+    CBTEngConnMan* iBTConnection;
+
+    /** Pointer to class responsible SDP queries */
+    CBTEngDiscovery* iBTDiscovery;
+
+    /** Pointer to class responsible for device discovery */
+    CHsDeviceDiscoverer* iDiscoverer;
+
+    /** Pointer to observer */
+    MHsBTManagerObserver* iBTManagerObserver;
+};
+
+#endif // HSTOOLS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/debug.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,187 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HS_LOGGING_H
+#define HS_LOGGING_H
+
+#include <e32base.h>
+#include "debugconfig.h"
+
+enum TPanic
+{
+    EInvalidNullState = 1,
+};
+
+#ifdef PRJ_ENABLE_TRACE
+
+#ifdef PRJ_FILE_TRACE
+#include <flogger.h>
+#else
+#include <e32debug.h>
+#endif
+
+NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow
+{
+public:
+    void Overflow( TDes16& /*aDes*/)
+        {
+        }
+};
+
+NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow
+{
+public:
+    void Overflow( TDes8& /*aDes*/)
+        {
+        }
+};
+
+inline void Trace( TRefByValue <const TDesC16> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    RBuf16 theFinalString;
+    theFinalString.Create( KMaxLogLineLength );
+    theFinalString.Append( KTracePrefix16 );
+    TOverflowTruncate16 overflow;
+    theFinalString.AppendFormatList( aFmt, list, &overflow );
+    RDebug::Print( theFinalString );
+    theFinalString.Close();
+#endif
+    }
+
+inline void Trace( TRefByValue <const TDesC8> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START(list, aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    TOverflowTruncate8 overflow;
+    RBuf8 buf8;
+    buf8.Create( KMaxLogLineLength );
+    buf8.Append( KTracePrefix8 );
+    buf8.AppendFormatList( aFmt, list, &overflow );
+
+    RBuf16 buf16;
+    buf16.Create( KMaxLogLineLength );
+    buf16.Copy( buf8 );
+    TRefByValue <const TDesC> tmpFmt( _L("%S") );
+    RDebug::Print( tmpFmt, &buf16 );
+    buf8.Close();
+    buf16.Close();
+#endif
+    }
+
+inline void TracePanic( char* aFile, TInt aLine, TInt aPanicCode,
+        const TDesC& aPanicCategory )
+    {
+    TPtrC8 fullFileName( (const TUint8*) aFile );
+    TPtrC8 fileName( fullFileName.Ptr() + fullFileName.LocateReverse( '\\' )
+            + 1 );
+    RBuf8 buf;
+    buf.Create( KMaxLogLineLength );
+    buf.Append( KPanicPrefix8 );
+    buf.AppendFormat( _L8("%d at line %d in file %S"), aPanicCode, aLine,
+            &fileName );
+    Trace( buf );
+    buf.Close();
+    User::Panic( aPanicCategory, aPanicCode );
+    }
+
+inline void TraceLeave( char* aFile, TInt aLine, TInt aReason )
+    {
+    TPtrC8 fullFileName( (const TUint8*) aFile );
+    TPtrC8 fileName( fullFileName.Ptr() + fullFileName.LocateReverse( '\\' )
+            + 1 );
+    RBuf8 buf;
+    buf.Create( KMaxLogLineLength );
+    buf.Append( KLeavePrefix8 );
+    buf.AppendFormat( _L8("%d at line %d in file %S"), aReason, aLine,
+            &fileName );
+    Trace( buf );
+    buf.Close();
+    User::Leave( aReason );
+    }
+
+#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;}
+
+#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;}
+
+#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;}
+
+#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;}
+
+#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;}
+
+#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);}
+
+#define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory)
+
+#define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define LEAVE_IF_NULL(PTR) {if (!PTR) TraceLeave(__FILE__, __LINE__, KErrGeneral);}
+
+#define LEAVE(REASON) {TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define TRACE_STATIC_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}}
+
+#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}}
+
+#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncExitFormat8, &ptr8);}}
+
+#define TRACE_STATIC_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncFormat8, &ptr8);}}
+
+#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncThisFormat8, &ptr8, this);}}
+
+#define RETURN_IF_ERR(ERR) {if(ERR) {TPtrC8 ptr8((TUint8*)__FILE__); Trace(_L8(" RETURN %d at file %S line %d"), ERR, &ptr8, __LINE__); return ERR;}}
+
+#else // PRJ_ENABLE_TRACE not defined
+#define TRACE_INFO(p)
+
+#define TRACE_ERROR(p)
+
+#define TRACE_STATE(p)
+
+#define TRACE_WARNING(p)
+
+#define TRACE_INFO_SEG(p)
+
+#define TRACE_ASSERT(GUARD, CODE)
+
+#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);}
+
+#define LEAVE_IF_ERROR(REASON) {static_cast<void>(User::LeaveIfError(REASON));}
+
+#define LEAVE_IF_NULL(PTR) {static_cast<void>(User::LeaveIfNull(PTR));}
+
+#define LEAVE(REASON) {static_cast<void>(User::Leave(REASON));}
+
+#define TRACE_STATIC_FUNC_ENTRY
+
+#define TRACE_FUNC_ENTRY
+
+#define TRACE_FUNC_EXIT
+
+#define TRACE_STATIC_FUNC
+
+#define TRACE_FUNC
+
+#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;}
+#endif // PRJ_ENABLE_TRACE
+#endif // HS_LOGGING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/debugconfig.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,53 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HS_DEBUGCONFIG_H
+#define HS_DEBUGCONFIG_H
+
+#include "prjconfig.h"
+
+/**
+ * Custom logging variations.
+ */
+#ifdef PRJ_FILE_TRACE
+_LIT(KLogFile,"HS.txt");
+_LIT(KLogDir,"HeadsetSimulator");
+#endif
+
+#ifdef PRJ_ENABLE_TRACE
+_LIT(KTracePrefix16, "[ HS ] ");
+_LIT8(KTracePrefix8, "[ HS ] ");
+_LIT8(KFuncFormat8, "><%S");
+_LIT8(KFuncThisFormat8, "><%S, [0x%08X]");
+_LIT8(KFuncEntryFormat8, ">%S");
+_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]");
+_LIT8(KFuncExitFormat8, "<%S");
+
+_LIT8(KPanicPrefix8, "PANIC code ");
+_LIT8(KLeavePrefix8, "LEAVE code ");
+#endif
+
+//needed??
+_LIT(KPanicCategory, "HeadsetSimulator"); // need it also for release 
+
+const TInt KMaxLogLineLength = 512;
+
+#define KPRINTERROR        0x00000001 // Tracing level: error
+#define KPRINTINFO        0x00000002 // Tracing level: function trace
+#define KPRINTSTATE        0x00000004 // Tracing level: state machine info
+#define KPRINTWARNING   0x00000008 // Tracing level: warning
+const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING;
+
+#endif // HS_DEBUGCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/hsclientobservers.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,183 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSCLIENTOBSERVERS_H
+#define HSCLIENTOBSERVERS_H
+
+class CHsClient;
+class CBluetoothSocket;
+class TBTDevAddr;
+
+/**
+ * @brief Observer to notify about new AG client connection and disconnection.
+ */
+class MHsClientObserver
+{
+public:
+    /**
+     * Informs about disconnection from AG.
+     * 
+     * @param aClient AG client
+     * @param aErr KErrNone if successful, otherwise one of the system-wide 
+     *        error codes
+     */
+    virtual void HandleClientDisconnect( CHsClient *aClient, TInt aErr ) = 0;
+
+    /**
+     * Informs about connection with AG.
+     * 
+     * @param aClient AG client
+     * @param aErr KErrNone if successful, otherwise one of the system-wide 
+     *        error codes
+     */
+    virtual void HandleNewClientL( CHsClient *aClient, TInt aErr ) = 0;
+};
+
+/**
+ * @brief Observer to notify about AG client states.
+ */
+class MHsClientStateNotifier
+{
+public:
+
+    /**
+     * Informs about connection with AG.
+     * 
+     * @param aErr KErrNone if successful, otherwise one of the system-wide 
+     *        error codes
+     */
+    virtual void HandleClientConnectL( TInt aErr ) = 0;
+
+    /**
+     * Informs about disconnection from AG.
+     * 
+     * @param aErr KErrNone if successful, otherwise one of the system-wide 
+     *        error codes
+     */
+    virtual void HandleClientDisconnectL( TInt aErr ) = 0;
+
+    /**
+     * Informs about status of received data from AG.
+     * 
+     * @param aData received data
+     * @param aErr KErrNone if successful, otherwise one of the system-wide 
+     *        error codes
+     */
+    virtual void HandleClientReceiveCompleteL( const TDesC8 &aData,
+            TInt aErr ) = 0;
+
+    /**
+     * Informs about status of sent data from AG.
+     * 
+     * @param aErr KErrNone if successful, otherwise one of the system-wide 
+     *        error codes
+     */
+    virtual void HandleClientSendCompleteL( TInt aErr ) = 0;
+
+    /**
+     * Informs about problem with AG.
+     * 
+     * @param aErr system-wide error codes
+     */
+    virtual void HandleClientOtherProblemL( TInt aErr ) = 0;
+};
+
+/**
+ * @brief Observer to notify about new AG client.
+ */
+class MHsAcceptNewClientObserver
+{
+public:
+    /**
+     * Informs about connection with AG.
+     * 
+     * @param aClient socket which AG is connected, if NULL see aErr code
+     * @param aErr KErrNone if successful, otherwise one of the system-wide 
+     *        error codes
+     */
+    virtual void HandleNewClientL( CBluetoothSocket *aClient, TInt aErr ) = 0;
+};
+
+/**
+ * @brief Observes remote control clients
+ */
+class MRemoteControllerConnectionObserver
+{
+
+public:
+    /**
+     * Handles remote control client connection
+     * 
+     * @param aErr error value 
+     */
+    virtual void HandleRemoteControllerConnected( TInt aErr ) = 0;
+
+    /**
+     * Handles remote control client disconnection
+     * 
+     * @param aErr error value 
+     */
+    virtual void HandleRemoteControllerDisconnected( TInt aErr ) = 0;
+
+};
+
+/**
+ * @brief Observer to notify about status of searching service and port on 
+ *        device.
+ */
+class MHsBTManagerObserver
+{
+public:
+    /** 
+     * Called when port on desired device found 
+     * 
+     * @param aDevName bluetooth name of found device
+     * @param aDevAddr bluetooth address of found device
+     * @param aPort found port number
+     */
+    virtual void HandleDesiredDeviceFound( const TDesC &aDevName,
+            const TBTDevAddr &aDevAddr, const TInt aPort ) = 0;
+
+    /** 
+     * Called when desired device not found 
+     *
+     * @param aErr error code 
+     */
+    virtual void HandleDesiredDeviceNotFound( TInt aErr ) = 0;
+
+    /** 
+     * Called when sdp query error happened 
+     *
+     * @param aErr error code 
+     */
+    virtual void HandleSdpQueryError( TInt aErr ) = 0;
+
+    /** 
+     * Called when service on device not found 
+     *
+     * @param aErr error code 
+     */
+    virtual void HandleServiceNotFound( TInt aErr ) = 0;
+
+    /** 
+     * Called when port number on device not found 
+     *
+     * @param aErr error code 
+     */
+    virtual void HandlePortNotFound( TInt aErr ) = 0;
+
+};
+
+#endif /* HSCLIENTOBSERVERS_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/hscore.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,510 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSCORE_H
+#define HSCORE_H
+
+#include <es_sock.h>
+#include <btdevice.h>
+#include <bttypes.h>
+#include <hsobserver.h>
+#include <hsclientobservers.h>
+
+class CHsProfileManager;
+class CHsControlServer;
+class CHsServer;
+class CHsClientManager;
+class CHsBTManager;
+class CHsAudioServer;
+
+/** Index of AG to which data should be send */
+const TInt KHsClientSendNumber = 0;
+
+/** Length of plugin identificator data */
+const TInt KHsIdentificationFieldBufSize = 128;
+
+/** Length of command data */
+const TInt32 KHsBufferLength = 0x800;
+
+/** Headset property Uid */
+const TUid KHSProperty =
+    {
+    0x1000008d
+    };
+
+/** Length of last-connected device bluetooth address */
+const TInt KLastDevAddrLength = KBTDevAddrSize * 2;
+
+/** Headset property key enum */
+enum THSPropertyKey
+{
+    /** Last-connected AG*/
+    ELastDevice
+};
+
+/** Bluetooth friendly name of device */
+typedef TBuf <KMaxFriendlyNameLen> TBTFriendlyName;
+
+/** Data buffer from profile to be send to client */
+typedef TBuf8 <KHsBufferLength> TBufferFromProfileToClient;
+
+/**
+ * @brief Class responsible for main functionality of Headset Simulator.
+ */
+class CHsCore : public CBase, public MHsClientStateNotifier,
+        public MHsAcceptNewClientObserver, public MHsBTManagerObserver,
+        public MRemoteControllerConnectionObserver
+{
+public:
+    /**
+     * Two-phase constructor
+     * @param aService service UUID
+     * @return instance of class
+     */
+    IMPORT_C static CHsCore* NewL( const TUUID &aService );
+
+    /**
+     * Two-phase constructor
+     * @param aService service UUID
+     * @return instance of class
+     */
+    IMPORT_C static CHsCore* NewLC( const TUUID &aService );
+
+    /**
+     * Destructor
+     */
+    IMPORT_C ~CHsCore();
+
+public:
+    /**
+     * Starts simulation of Headset.
+     * Turns bluetooth on and sets local name, starts Headset server, loads 
+     * CoD, Sdp and profile plugins.
+     * 
+     * @param aCoDUid Class of Device Uid
+     * @param aSdpUid Sdp Uid
+     * @param aProfileUid profile Uid
+     * @param aBTName bluetooth name
+     */
+    IMPORT_C void StartSimulationL( const TUid &aCoDUid, const TUid &aSdpUid,
+            const TUid &aProfileUid, const TDesC &aBTName = KNullDesC );
+
+    /**
+     * Starts simulation of Headset.
+     * Turns bluetooth on and sets local name, starts Headset server, loads 
+     * CoD, Sdp and profile plugins.
+     * 
+     * @param aCoDUid Class of Device Uid as descriptor
+     * @param aSdpUid Sdp Uid as descriptor
+     * @param aProfileUid profile Uid as descriptor
+     * @param aBTName bluetooth name
+     */
+    IMPORT_C void StartSimulationL( const TDesC8 &aCoDUid,
+            const TDesC8 &aSdpUid, const TDesC8 &aProfileUid,
+            const TDesC &aBTName = KNullDesC );
+
+    /**
+     * Stops simulation of Headset.
+     * Disconnects from AGs, Remote Controller, restores initial bluetooth 
+     * settings.
+     */
+    IMPORT_C void StopSimulation();
+
+    /**
+     * Connects AG by its bluetooth name.
+     * 
+     * When request completes with success notification is sent to 
+     * MHsObserver::HandleConnectedToClient(), otherwise to 
+     * MHsObserver::HandleUnableToConnectClient().
+     * 
+     * @param aName AG's bluetooth name
+     */
+    IMPORT_C void ConnectWithName( const TDesC &aName );
+
+    /**
+     * Connects AG by its bluetooth address.
+     * 
+     * When request completes with success notification is sent to 
+     * MHsObserver::HandleConnectedToClient(), otherwise to 
+     * MHsObserver::HandleUnableToConnectClient().
+     * 
+     * @param aDevAddress AG's bluetooth address
+     */
+    IMPORT_C void ConnectWithDevAddress( const TDesC &aDevAddress );
+
+    /**
+     * Connects last-connected AG.
+     * 
+     * When request completes with success notification is sent to 
+     * MHsObserver::HandleConnectedToClient(), otherwise to 
+     * MHsObserver::HandleUnableToConnectClient().
+     * 
+     * @pre Invocation of this method must be after at least one call of 
+     * ConnectWithName or ConnectWithDevAddress which saves connection 
+     * parameters.
+     */
+    IMPORT_C void ConnectWithLastConnectedL();
+
+    /**
+     * Cancels attempt of connection with AG.
+     */
+    IMPORT_C void CancelConnecting();
+
+    /**
+     * Disconnects from AGs.
+     *
+     * When request completes notification is sent to 
+     * MHsObserver::HandleDisconnectedFromClient().
+     */
+    IMPORT_C void DisconnectClients();
+
+    /**
+     * Sends command to AG. Data is handled by profile manager before.
+     * 
+     * @param aData data to be handled and response send
+     * @param aNumber specifies to which AG response command should be send
+     * @return KErrNone if successful, otherwise one of the system-wide 
+     *          error codes
+     */
+    IMPORT_C TInt Send( const TDesC8 &aData, 
+            TInt aNumber = KHsClientSendNumber );
+
+    /**
+     * Sets observer of Headset actions.
+     * 
+     * @param aObserver reference to MHsObserver
+     */
+    IMPORT_C void SetObserver( MHsObserver &aObserver );
+
+    /**
+     * Accepts incoming call. If call is not pending, nothing happens.
+     * 
+     * @return error value
+     */
+    IMPORT_C TInt AcceptIncomingCall();
+
+    /**
+     * Releases ongoing call. If call does not exist, nothing happens.
+     * 
+     * @return error value
+     */
+    IMPORT_C TInt ReleaseOngoingCall();
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aService service UUID
+     */
+    CHsCore( const TUUID &aService );
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+
+    /**
+     * Simulation initialization. Starts bluetooth with optionally 
+     * specified name and server
+     * 
+     * @param aBTName bluetooth name 
+     */
+    void InitializeSimulationL( const TDesC &aBTName = KNullDesC );
+
+    /**
+     * Registers Headset property.
+     */
+    void RegisterProperty();
+
+    /**
+     * Creates Headset components.
+     * 
+     * @leave system-wide error codes if any component's creation fails.
+     */
+    void CreateComponentsL();
+
+    /**
+     * Destroys Headset components.
+     */
+    void DestroyComponents();
+
+    /**
+     * Creates Headset server.
+     * 
+     * @return KErrNone if successful, otherwise one of the system-wide 
+     *         error codes
+     */
+    TInt CreateHSServer();
+
+    /**
+     * Starts Headset server.
+     * 
+     * @return KErrNone if successful, otherwise one of the system-wide 
+     *         error codes
+     */
+    TInt StartHSServer();
+
+    /**
+     * Stops Headset server.
+     */
+    void StopHSServer();
+
+    /**
+     * Destroys Headset server.
+     */
+    void DestroyHSServer();
+
+    /**
+     * Creates audio server.
+     * 
+     * @return KErrNone if successful, otherwise one of the system-wide 
+     *         error code
+     */
+    TInt CreateAudioServer( TBool aPullAudio = EFalse );
+
+    /**
+     * Starts audio server.
+     * 
+     * @param aPullAudio denotes if SCO should be accepted
+     * @return KErrNone if successful, otherwise one of the system-wide 
+     *         error code
+     * 
+     */
+    TInt StartAudioServer( TBool aPullAudio = EFalse );
+
+    /**
+     * Stops audio server.
+     */
+    void StopAudioServer();
+
+    /**
+     * Destroys audio server.
+     */
+    void DestroyAudioServer();
+
+    /**
+     * Creates AG clients manager.
+     * 
+     * @return KErrNone if successful, otherwise one of the system-wide
+     *         error codes
+     */
+    TInt CreateClientManager();
+
+    /**
+     * Destroys AG clients manager.
+     */
+    void DestroyClientManager();
+
+    /**
+     * Creates plugin manager.
+     * 
+     * @return KErrNone if successful, otherwise one of the system-wide 
+     *         error codes
+     */
+    TInt CreatePluginManager();
+
+    /**
+     * Destroys plugin manager.
+     */
+    void DestroyPluginManager();
+
+    /**
+     * Creates bluetooth manager.
+     * 
+     * @return KErrNone if successful, otherwise one of the system-wide 
+     *         error codes
+     */
+    TInt CreateBTManager();
+
+    /**
+     * Destroys bluetooth manager.
+     */
+    void DestroyBTManager();
+
+    /**
+     * Creates Remote Control server.
+     * 
+     * @return KErrNone if successful, otherwise one of the system-wide 
+     *         error codes
+     */
+    TInt CreateControlServer();
+
+    /**
+     * Destroys Remote Control server.
+     */
+    void DestroyControlServer();
+
+    /**
+     * Sets Headset bluetooth friendly name.
+     * 
+     * @param aBTName bluetooth name
+     */
+    void SetBTName( const TBTFriendlyName &aBTName );
+
+    /**
+     * Gets last-connected AG's bluetooth address.
+     * 
+     * @param aBTDevAddr on return, the value of bluetooth address 
+     * @return KErrNone if successful, otherwise one of the system-wide 
+     *         error codes
+     */
+    TInt GetLastConnected( TBTDevAddr &aBTDevAddr );
+
+    /**
+     * Saves connection parameter - bluetooth address of last-connected AG.
+     * 
+     * @param aSocket socket which AG is connected
+     * @return KErrNone if successful, otherwise one of the system-wide 
+     *         error codes
+     */
+    TInt SaveClient( CBluetoothSocket* aSocket );
+
+    /**
+     * Sets listening Headset server port to be used in settings of Sdp record.
+     */
+    void SetSdpRecordServicePortFromServer();
+
+    /**
+     * Loads profile.
+     * 
+     * @param aProfileName profile name
+     * @pre CoD and Sdp plugins loaded.
+     */
+    void LoadProfileL( const TDesC8 &aProfileName );
+
+    /**
+     * Loads profile.
+     * 
+     * @param aProfileUid profile Uid
+     * @pre CoD and Sdp plugins loaded.
+     */
+    void LoadProfileL( const TUid &aProfileUid );
+
+    /**
+     * Loads Sdp.
+     * 
+     * @param aSdpName Sdp name
+     */
+    void LoadSdpL( const TDesC8 &aSdpName );
+
+    /**
+     * Loads Sdp.
+     * 
+     * @param aSdpUid Sdp Uid
+     */
+    void LoadSdpL( const TUid &aSdpUid );
+
+    /**
+     * Loads CoD plugin
+     * 
+     * @param aCodName CoD name
+     */
+    void LoadCodL( const TDesC8 &aCoDName );
+
+    /**
+     * Loads CoD plugin
+     * 
+     * @param aCodUid CoD Uid
+     */
+    void LoadCodL( const TUid &aCoDUid );
+
+private:
+    //Methods inherited from MHsClientStateNotifier
+    void HandleClientConnectL( TInt aErr );
+    
+    void HandleClientDisconnectL( TInt aErr );
+    
+    void HandleClientReceiveCompleteL( const TDesC8 &aData, TInt aErr );
+    
+    void HandleClientSendCompleteL( TInt aErr );
+    
+    void HandleClientOtherProblemL( TInt aErr );
+
+private:
+    //Methods inherited from MHsAcceptNewClientObserver
+    void HandleNewClientL( CBluetoothSocket *aClientSocket, TInt aErr );
+
+private:
+    //Methods inherited from MHsBTManagerObserver
+    void HandleDesiredDeviceFound( const TDesC &aDevName,
+            const TBTDevAddr &aDevAddr, const TInt aPort );
+    
+    void HandleDesiredDeviceNotFound( TInt aErr );
+    
+    void HandleSdpQueryError( TInt aErr );
+    
+    void HandleServiceNotFound( TInt aErr );
+    
+    void HandlePortNotFound( TInt aErr );
+
+private:
+    //Methods inherited from MRemoteControllerConnectionObserver
+    void HandleRemoteControllerConnected( TInt aErr );
+    
+    void HandleRemoteControllerDisconnected( TInt aErr );
+
+private:
+
+    /** Plugin types */
+    enum TPluginType
+    {
+        /** CoD plugin */
+        ECoDPlugin,
+        /** Sdp plugin */
+        ESdpPlugin,
+        /** Profile plugin */
+        EProfilePlugin,
+        /** Number of plugins */
+        EEnd,
+    };
+
+    /** Service UUID */
+    TUUID iService;
+
+    /** Bluetooth friendly name of device */
+    TBTFriendlyName iBTFriendlyName;
+
+    /** Data buffer from profile to be send to AG */
+    TBufferFromProfileToClient iBufferFromProfileToClient;
+
+    /** Session of socket server */
+    RSocketServ iSocketServ;
+
+    /** Pointer to CHsServer. Owned */
+    CHsServer* iHSServer;
+
+    /** Pointer to CHsAudioServer. Owned */
+    CHsAudioServer* iAudioServer;
+
+    /** Pointer to CHsControlServer. Owned */
+    CHsControlServer *iHSControlServer;
+
+    /** Pointer to CHsClientManager. Owned */
+    CHsClientManager *iHSClientManager;
+
+    /** Pointer to CHsProfileManager. Owned */
+    CHsProfileManager *iHSProfileManager;
+
+    /** Pointer to CHsBTManager. Owned */
+    CHsBTManager *iHsBTManager;
+
+    /** Pointer to MHsObserver. Not owned */
+    MHsObserver *iObserver;
+
+};
+
+#endif  // HSCORE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/hsobserver.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,61 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSOBSERVER_H
+#define HSOBSERVER_H
+
+/**
+ * @brief Observer to notify about Headset Simulator AG client and Remote 
+ * Controller's states.
+ */
+class MHsObserver
+{
+
+public:
+    /**
+     * Informs about established connection with AG.
+     */
+    virtual void HandleConnectedToClient() = 0;
+
+    /**
+     * Informs about released connection with AG.
+     */
+    virtual void HandleDisconnectedFromClient() = 0;
+
+    /**
+     * Informs that connection with  AG cannot be established.
+     */
+    virtual void HandleUnableToConnectClient() = 0;
+
+    /**
+     * Informs that connection with  AG is being established.
+     */
+    virtual void HandleConnectingToClient() = 0;
+
+    /**
+     * Informs about established connection with Headset Simulator's 
+     * Remote Controller.
+     */
+    virtual void HandleConnectedToRemoteController() = 0;
+
+    /**
+     * Informs about released connection with Headset Simulator's 
+     * Remote Controller.
+     */
+    virtual void HandleDisconnectedFromRemoteController() = 0;
+
+};
+
+#endif //HSOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/inc/prjconfig.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,43 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HS_PRJCONFIG_H
+#define HS_PRJCONFIG_H
+
+/**
+ * Traces are enabled in _DEBUG build, by default.
+ */
+#ifdef _DEBUG
+#define PRJ_ENABLE_TRACE
+#endif
+
+/**
+ * traces to file if this is defined.
+ */
+//#define PRJ_FILE_TRACE
+
+
+/**
+ * build the project for module test purpose if this is defined
+ */
+//#define PRJ_MODULETEST_BUILD
+
+/**
+ * build the project using stubs to replace the dependencies if this is defined
+ */
+//#define PRJ_USE_STUB
+
+
+#endif // HS_PRJCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/sis/headsetsimulator.pkg	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,26 @@
+;
+; Component Name: Headset Simulator
+; Author: Comarch S.A.
+; Version: 1.0
+; Copyright (c) 2010 Comarch S.A.
+;  
+; This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+; the basis of the Member Contribution Agreement entered between Comarch S.A. 
+; and Symbian Foundation Limited on 5th June 2009 ("Agreement") and may be 
+; used only in accordance with the terms and conditions of the Agreement. 
+; Any other usage, duplication or redistribution of this Software is not 
+; allowed without written permission of Comarch S.A.
+;
+
+; UID is the dll's UID
+;
+#{"Headset Simulator DLL"},(0xE026A1DD),1,0,0
+
+
+;Localised Vendor name
+%{"Vendor-EN"}
+
+;Unique Vendor name
+:"Vendor"
+
+"\epoc32\release\armv5\udeb\headsetsimulator.dll"		  -"!:\sys\bin\headsetsimulator.dll"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/src/ProfileManager/hsprofilemanager.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,317 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#include "hsprofilemanager.h"
+#include "debug.h"
+
+CHsProfileManager::CHsProfileManager()
+    {
+    }
+
+CHsProfileManager::~CHsProfileManager()
+    {
+    TRACE_FUNC_ENTRY
+    DestroyProfile();
+    DestroyCodL();
+    DestroySdpL();
+    REComSession::FinalClose();
+
+    TRACE_FUNC_EXIT
+    }
+
+CHsProfileManager* CHsProfileManager::NewLC()
+    {
+    CHsProfileManager* self = new ( ELeave ) CHsProfileManager();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsProfileManager* CHsProfileManager::NewL()
+    {
+    CHsProfileManager* self = CHsProfileManager::NewLC();
+    CleanupStack::Pop( self ); // self;
+    return self;
+    }
+
+void CHsProfileManager::ConstructL()
+    {
+
+    }
+
+void CHsProfileManager::LookupAndManageProfileL( const TUid aProfileUid )
+    {
+    TRACE_FUNC_ENTRY
+
+    DestroyProfile();
+    iProfilePlugin = CHsProfileBase::NewL( aProfileUid );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::LookupAndManageProfileL( const TDesC8 &aProfileName )
+    {
+    TRACE_FUNC_ENTRY
+
+    DestroyProfile();
+    iProfilePlugin = CHsProfileBase::NewL( aProfileName );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::UnloadProfile()
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iProfilePlugin )
+        {
+        delete iProfilePlugin;
+        iProfilePlugin = NULL;
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::LookupAndManageSdpL( const TUid aSdpUid )
+    {
+    TRACE_FUNC_ENTRY
+
+    DestroySdpL();
+
+    iSdpPlugin = CHsSdpBase::NewL( aSdpUid );
+    iSdpPlugin->SetServicePort( iSdpServicePort );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::LookupAndManageSdpL( const TDesC8 &aSdpName )
+    {
+    TRACE_FUNC_ENTRY
+
+    DestroySdpL();
+
+    iSdpPlugin = CHsSdpBase::NewL( aSdpName );
+    iSdpPlugin->SetServicePort( iSdpServicePort );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::LoadSdpL()
+    {
+    TRACE_FUNC_ENTRY
+
+    User::LeaveIfNull( iSdpPlugin );
+    if ( iSdpSet )
+        {
+        TRAP_IGNORE( iSdpPlugin->DeleteSdpRecordL() );
+        iSdpSet = EFalse;
+        }
+    iSdpPlugin->SetServicePort( iSdpServicePort );
+    iSdpPlugin->CreateSdpRecordL();
+    iSdpSet = ETrue;
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::UnloadSdpL()
+    {
+    TRACE_FUNC_ENTRY
+
+    User::LeaveIfNull( iSdpPlugin );
+    if ( iSdpSet )
+        {
+        iSdpPlugin->DeleteSdpRecordL();
+        iSdpSet = EFalse;
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::SetSdpServicePort( TInt aPort )
+    {
+    TRACE_FUNC_ENTRY
+    if ( iSdpPlugin )
+        {
+        iSdpPlugin->SetServicePort( aPort );
+        }
+    iSdpServicePort = aPort;
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::RefreshSdp()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iSdpPlugin )
+        {
+        TRAP_IGNORE( iSdpPlugin->DeleteSdpRecordL() );
+        iSdpSet = EFalse;
+        TRAPD( err, iSdpPlugin->CreateSdpRecordL() );
+        if ( KErrNone == err )
+            {
+            iSdpSet = ETrue;
+            }
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::LookupAndManageCodL( const TUid aCoDUid )
+    {
+    TRACE_FUNC_ENTRY
+
+    DestroyCodL();
+    iCoDPlugin = CHsCoDBase::NewL( aCoDUid );
+    User::LeaveIfError( iCoDPlugin->SaveOldCod() );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::LookupAndManageCodL( const TDesC8 &aCoDName )
+    {
+    TRACE_FUNC_ENTRY
+
+    DestroyCodL();
+    iCoDPlugin = CHsCoDBase::NewL( aCoDName );
+    User::LeaveIfError( iCoDPlugin->SaveOldCod() );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::LoadCodL()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iCoDPlugin )
+        {
+        iCoDPlugin->SetNewCodL();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::UnloadCodL()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iCoDPlugin )
+        {
+        User::LeaveIfError( iCoDPlugin->RestoreOldCod() );
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::DestroyProfile()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iProfilePlugin )
+        {
+        delete iProfilePlugin;
+        iProfilePlugin = NULL;
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::DestroySdpL()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iSdpPlugin )
+        {
+        iSdpPlugin->DeleteSdpRecordL();
+        delete iSdpPlugin;
+        iSdpPlugin = NULL;
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::DestroyCodL()
+    {
+    TRACE_FUNC_ENTRY
+    TInt err;
+    if ( iCoDPlugin )
+        {
+        err = iCoDPlugin->RestoreOldCod();
+        TRACE_INFO((_L("RestoreOldCoD method returned value %d"), err))
+        delete iCoDPlugin;
+        iCoDPlugin = NULL;
+        User::LeaveIfError( err );
+        }
+    TRACE_FUNC_EXIT
+    }
+
+TBool CHsProfileManager::IsSdpPluginLoaded()
+    {
+    return iSdpPlugin ? ETrue : EFalse;
+    }
+
+TBool CHsProfileManager::IsProfilePluginLoaded()
+    {
+    return iProfilePlugin ? ETrue : EFalse;
+    }
+
+TBool CHsProfileManager::IsCoDPluginLoaded()
+    {
+    return iCoDPlugin ? ETrue : EFalse;
+    }
+
+void CHsProfileManager::HandleCommandL( const TDesC8 &aCommandsIn,
+        TDes8 &aCommandOut, TBool aFromAG )
+    {
+    TRACE_FUNC_ENTRY
+    User::LeaveIfNull( iProfilePlugin );
+
+    iProfilePlugin->HandleCommandL( aCommandsIn, aCommandOut, aFromAG );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::HandleClientDisconnected( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    if ( iProfilePlugin )
+        {
+        iProfilePlugin->HandleClientDisconnected( aErr );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::HandleClientConnected( TDes8& aCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+    if ( iProfilePlugin )
+        {
+        iProfilePlugin->HandleClientConnected( aCommandOut );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::AcceptIncomingCallL( TDes8& aProfileResponse )
+    {
+    TRACE_FUNC_ENTRY
+    if ( iProfilePlugin )
+        {
+        iProfilePlugin->HandleAcceptCallL( aProfileResponse );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsProfileManager::ReleaseOngoingCallL( TDes8& aProfileResponse )
+    {
+    TRACE_FUNC_ENTRY
+    if ( iProfilePlugin )
+        {
+        iProfilePlugin->HandleReleaseCallL( aProfileResponse );
+        }
+    TRACE_FUNC_EXIT
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/src/RemoteControl/hsremotecontrolcommand.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,46 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#include "hsremotecontroltools.h"
+#include "debug.h"
+
+THsRemoteControlCommand::THsRemoteControlCommand( THsControlCommandData& aData,
+        THsRemoteControlCommandType aCmdType ) :
+    iData( aData ), iType( aCmdType )
+    {
+
+    }
+
+void THsRemoteControlCommand::GetType( THsRemoteControlCommandType& aCmdType )
+    {
+    TRACE_FUNC_ENTRY
+    aCmdType = iType;
+    TRACE_FUNC_EXIT
+    }
+
+void THsRemoteControlCommand::GetData( TDes8 &aCmdData )
+    {
+    TRACE_FUNC_ENTRY
+    aCmdData.Copy( iData );
+    TRACE_FUNC_EXIT
+    }
+
+void THsRemoteControlCommand::Copy( const THsRemoteControlCommand& aCmdFrom,
+        THsRemoteControlCommand& aCmdTo )
+    {
+    TRACE_STATIC_FUNC
+    aCmdTo.iData.Copy( aCmdFrom.iData );
+    aCmdTo.iType = aCmdFrom.iType;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/src/RemoteControl/hsremotecontroldatahandler.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,87 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#include "hsremotecontroldatahandler.h"
+#include "hsremotecontroltools.h"
+#include "debug.h"
+
+CHsRemoteControlDataHandler* CHsRemoteControlDataHandler::NewL()
+    {
+    CHsRemoteControlDataHandler *self = CHsRemoteControlDataHandler::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CHsRemoteControlDataHandler* CHsRemoteControlDataHandler::NewLC()
+    {
+    CHsRemoteControlDataHandler *self =
+            new ( ELeave ) CHsRemoteControlDataHandler;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsRemoteControlDataHandler::CHsRemoteControlDataHandler()
+    {
+
+    }
+
+CHsRemoteControlDataHandler::~CHsRemoteControlDataHandler()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iParser )
+        {
+        delete iParser;
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsRemoteControlDataHandler::ConstructL()
+    {
+    iParser = CHsRemoteControlParser::NewL();
+    }
+
+TInt CHsRemoteControlDataHandler::RecognizeCommand( const TDesC8 &aDataIn,
+        THsRemoteControlCommand& aCmd )
+    {
+    TRACE_FUNC_ENTRY
+    TRAPD(err,iParser->ParseL(aDataIn, aCmd));
+
+    if ( KErrNone != err )
+        {
+        TRACE_FUNC_EXIT
+        return err;
+        }
+
+    if ( !IsCommandValid( aCmd ) )
+        {
+        TRACE_FUNC_EXIT
+        return KErrArgument;
+        }
+
+    TRACE_FUNC_EXIT
+    return KErrNone;
+    }
+
+TBool CHsRemoteControlDataHandler::IsCommandValid(
+        THsRemoteControlCommand& aCmd )
+    {
+    TRACE_FUNC_ENTRY
+    THsRemoteControlCommandType type = EHsLast;
+    aCmd.GetType( type );
+    TRACE_FUNC_EXIT
+    return ( type < EHsLast );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/src/RemoteControl/hsremotecontrolparser.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,114 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#include "hsremotecontroltools.h"
+#include "debug.h"
+
+CHsRemoteControlParser* CHsRemoteControlParser::NewL()
+    {
+    CHsRemoteControlParser *self = CHsRemoteControlParser::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CHsRemoteControlParser* CHsRemoteControlParser::NewLC()
+    {
+    CHsRemoteControlParser *self = new ( ELeave ) CHsRemoteControlParser;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsRemoteControlParser::~CHsRemoteControlParser()
+    {
+
+    }
+
+void CHsRemoteControlParser::ConstructL()
+    {
+
+    }
+
+CHsRemoteControlParser::CHsRemoteControlParser()
+    {
+
+    }
+
+void CHsRemoteControlParser::ParseL( const TDesC8 &aText,
+        THsRemoteControlCommand &aCommand )
+    {
+    TRACE_FUNC_ENTRY
+    if ( !IsPackageValid( aText ) )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    TBuf8 <KHsRemoteControlPackageTypeMaxLength> typeBuf;
+    TBuf8 <KHsRemoteControlPackageLength - KHsRemoteControlPackageTypeMaxLength>
+            dataBuf;
+
+    User::LeaveIfError( SplitPackage( aText, typeBuf, dataBuf ) );
+
+    THsRemoteControlCommandType cmdType = EHsLast;
+    User::LeaveIfError( RecognizeType( typeBuf, cmdType ) );
+
+    THsControlCommandData cmdData( dataBuf );
+
+    THsRemoteControlCommand tmpCommand( cmdData, cmdType );
+
+    THsRemoteControlCommand::Copy( tmpCommand, aCommand );
+    TRACE_FUNC_EXIT
+    }
+
+TBool CHsRemoteControlParser::IsPackageValid( const TDesC8 &aData )
+    {
+    return ( aData.Size() <= KHsRemoteControlPackageLength ) && ( aData.Find(
+            KHsRemoteControllerPackageDelim ) != KErrNotFound );
+    }
+
+TInt CHsRemoteControlParser::SplitPackage( const TDesC8 &aData,
+        TDes8 &aTypePart, TDes8 &aDataPart )
+    {
+    TRACE_FUNC_ENTRY
+    TInt err = KErrNone;
+
+    TInt delimPos = aData.Find( KHsRemoteControllerPackageDelim );
+    if ( delimPos != KErrNotFound )
+        {
+        aTypePart.Copy( aData.Left( delimPos ) );
+        aDataPart.Copy( aData.Right( aData.Length() - delimPos - 1 ) );
+        }
+    else
+        {
+        err = KErrNotFound;
+        }
+
+    TRACE_FUNC_EXIT
+    return err;
+    }
+
+TInt CHsRemoteControlParser::RecognizeType( const TDesC8 &aTypePart,
+        THsRemoteControlCommandType& aCommandType )
+    {
+    TRACE_FUNC_ENTRY
+    TLex8 lex( aTypePart );
+    TInt val;
+    TInt err = lex.Val( val );
+
+    aCommandType = (THsRemoteControlCommandType) val;
+    TRACE_FUNC_EXIT
+    return err;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/src/RemoteControl/hsremotecontrolserver.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,534 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+#include "hsremotecontrolserver.h"
+#include "hscore.h" 
+#include "hsremotecontroldatahandler.h"
+#include "hsremotecontroltools.h"
+#include "debug.h"
+
+_LIT8(KHsATVGS,"AT+VGS=");
+_LIT8(KHsATCommandEnding,"\r\n");
+_LIT8(KHsATVGM,"AT+VGM=");
+
+CHsControlServer* CHsControlServer::NewL( RSocketServ& aSocketServ,
+        CHsCore* aHsCore )
+    {
+    CHsControlServer* self = CHsControlServer::NewLC( aSocketServ, aHsCore );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CHsControlServer* CHsControlServer::NewLC( RSocketServ& aSocketServ,
+        CHsCore* aHsCore )
+    {
+    CHsControlServer* self = new ( ELeave ) CHsControlServer( aSocketServ,
+            aHsCore );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsControlServer::CHsControlServer( RSocketServ& aSocketServ, CHsCore* aHsCore ) :
+    iState( ENone ), iSocketServ( aSocketServ ), iHsCore( aHsCore )
+    {
+    }
+
+void CHsControlServer::ConstructL()
+    {
+    iDataHandler = CHsRemoteControlDataHandler::NewL();
+    }
+
+CHsControlServer::~CHsControlServer()
+    {
+    TRACE_FUNC_ENTRY
+    CancelListen();
+    if ( iSocket )
+        {
+        delete iSocket;
+        }
+    if ( iListenSocket )
+        {
+        delete iListenSocket;
+        }
+    if ( iDataHandler )
+        {
+        delete iDataHandler;
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsControlServer::StartRemoteControlServerL()
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iState != ENone )
+        {
+        TRACE_INFO (_L("ControlServer is already listening"))
+        TRACE_FUNC_EXIT
+        User::Leave( KErrInUse );
+        }
+
+    iState = EConnecting;
+    TProtocolDesc ProtocolDesc;
+    User::LeaveIfError( iSocketServ.FindProtocol( KHsRFComm(), ProtocolDesc ) );
+
+    if ( iListenSocket )
+        {
+        // Return value may be ignored
+        iListenSocket->Shutdown( RSocket::EImmediate );
+        delete iListenSocket;
+        iListenSocket = NULL;
+        }
+    iListenSocket = CBluetoothSocket::NewL( *this, iSocketServ,
+            ProtocolDesc.iSockType, ProtocolDesc.iProtocol );
+
+    User::LeaveIfError( iListenSocket->GetOpt(
+            KRFCOMMGetAvailableServerChannel, KSolBtRFCOMM, iServerPort ) );
+
+    TBTSockAddr btSockAddr;
+    btSockAddr.SetPort( iServerPort );
+
+    RegisterSdpL( iServerPort );
+    User::LeaveIfError( iListenSocket->Bind( btSockAddr ) );
+
+    TRACE_INFO( ( _L("Control Server port =  %d"), iServerPort) )
+    User::LeaveIfError( iListenSocket->Listen( KHsSizeOfListenQueue ) );
+
+    TBTServiceSecurity secSettings;
+    TUid settingsUID = TUid::Uid( (TInt) KHsRemoteControlServiceID );
+    secSettings.SetUid( settingsUID );
+    secSettings.SetAuthentication( EFalse );
+    secSettings.SetAuthorisation( EFalse );
+    secSettings.SetEncryption( EFalse );
+
+    btSockAddr.SetSecurity( secSettings );
+
+    if ( iSocket )
+        {
+        // Return value may be ignored
+        iSocket->Shutdown( RSocket::EImmediate );
+        delete iSocket;
+        iSocket = NULL;
+        }
+    iSocket = CBluetoothSocket::NewL( *this, iSocketServ );
+    User::LeaveIfError( iListenSocket->Accept( *iSocket ) );
+    iInitialized = ETrue;
+    TRACE_INFO( _L("CHSControlServer::Listen() status = OK" ) )
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsControlServer::CancelListen()
+    {
+    TRACE_FUNC_ENTRY
+   
+    if ( iState == EWaiting )//Client is connected to socket
+        {
+        iSocket->CancelAll();
+        // Return value may be ignored
+        iSocket->Shutdown( RSocket::EImmediate );
+        delete iSocket;
+        iSocket = NULL;
+        iListenSocket->CancelAll();
+
+        // Return value may be ignored
+        iListenSocket->Shutdown( RSocket::EImmediate );
+        delete iListenSocket;
+        iListenSocket = NULL;
+        }
+    else
+        { //Sockets are ready, but client is not connected
+        delete iSocket;
+        iSocket = NULL;
+        delete iListenSocket;
+        iListenSocket = NULL;
+        }
+
+    DeleteRecordSdp();
+
+    iInitialized = EFalse;
+    iState = ENone;
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsControlServer::SetConnectionObserver(
+        MRemoteControllerConnectionObserver &aRemoteControllerObserver )
+    {
+    iConnectionObserver = &aRemoteControllerObserver;
+    }
+
+void CHsControlServer::HandleConnectCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsControlServer::HandleAcceptCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+    iState = EWaiting;
+    Receive();
+    if ( iConnectionObserver )
+        {
+        iConnectionObserver->HandleRemoteControllerConnected( aErr );
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsControlServer::HandleShutdownCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsControlServer::HandleSendCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+
+    TRACE_INFO( ( _L8("ControlServer sent %d bytes of data: [%S] with err [%d]")
+            ,iSendDataBuffer.Length(), &iSendDataBuffer, aErr) )
+    
+    TInt error = KErrNone;
+
+    if ( aErr == KErrNone )
+        {
+        iSendDataBuffer.Zero();
+        if ( iTempDataBuffer.Length() > 0 )
+            {
+            iSendDataBuffer.Append( iTempDataBuffer );
+            iTempDataBuffer.Zero();
+            error = iSocket->Write( iSendDataBuffer );
+            }
+        }
+    Receive();
+
+    User::LeaveIfError( error );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsControlServer::HandleReceiveCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L8("[ControlServer] received %d bytes of data: [%S]"
+            "with err [%d]"), iReceiveDataBuffer.Length(), &iReceiveDataBuffer,
+            aErr) )
+
+    if ( aErr == KErrNone )
+        {
+        TInt error = KErrNone;
+
+        if ( iSendDataBuffer.Length() > 0 )
+            {
+            error = iSocket->Write( iSendDataBuffer );
+            }
+        else if ( iTempDataBuffer.Length() > 0 )
+            {
+            iSendDataBuffer.Append( iTempDataBuffer );
+            iTempDataBuffer.Zero();
+            error = iSocket->Write( iSendDataBuffer );
+            }
+
+        TRAP_IGNORE( HandleRequestL( iReceiveDataBuffer ) );
+
+        Receive();
+
+        User::LeaveIfError( error );
+        }
+    else
+        {
+        TRACE_INFO( _L("ControlClient is disconnected") )
+
+        if ( iConnectionObserver )
+            {
+            iConnectionObserver->HandleRemoteControllerDisconnected( aErr );
+            }
+        CancelListen();
+        StartRemoteControlServerL();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsControlServer::HandleIoctlCompleteL( TInt /*aErr*/)
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_FUNC_EXIT
+    }
+
+void CHsControlServer::HandleActivateBasebandEventNotifierCompleteL(
+        TInt /*aErr*/, TBTBasebandEventNotification& /*aEventNotification*/)
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsControlServer::Send( const TDesC8& aData )
+    {
+    TRACE_FUNC_ENTRY
+    TInt error = KErrNone;
+    if ( iState != EWaiting )
+        {
+        error = KErrNotReady;
+        TRACE_INFO( _L("ControlServer not ready") )
+
+        return error;
+        }
+
+    if ( iSendDataBuffer.Length() == 0 )
+        {
+        iSendDataBuffer.Append( iTempDataBuffer );
+        iTempDataBuffer.Zero();
+        iSendDataBuffer.Append( aData );
+        }
+    else
+        {
+        iTempDataBuffer.Append( aData );
+        }
+
+    if ( iSendDataBuffer.Length() > 0 )
+        {
+        iSocket->CancelRecv();
+        error = iSocket->Write( iSendDataBuffer );
+        Receive();
+        }
+    else
+        {
+        Receive();
+        }
+    TRACE_FUNC_EXIT
+    return error;
+    }
+
+void CHsControlServer::Receive()
+    {
+    TRACE_FUNC_ENTRY
+    // Return value may be ignored, 
+    // error will be notified to HandleReceiveCompleteL
+    iSocket->RecvOneOrMore( iReceiveDataBuffer, 0, iDataLength );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsControlServer::RegisterSdpL( TInt aChannel )
+    {
+    TRACE_FUNC_ENTRY
+
+    User::LeaveIfError( iSdpServer.Connect() );
+    User::LeaveIfError( iSdpDB.Open( iSdpServer ) );
+
+    TUUID serviceUUID( KHsRemoteControlServiceID );
+    iSdpDB.CreateServiceRecordL( serviceUUID, iSdpRecordHandle );
+
+    CSdpAttrValueDES* valDES = CSdpAttrValueDES::NewDESL( NULL );
+    CleanupStack::PushL( valDES );
+    valDES->StartListL()->BuildDESL()->StartListL()->BuildUUIDL( TUUID(
+            KL2CAPUUID ) )->EndListL()->BuildDESL()->StartListL()->BuildUUIDL(
+            TUUID( KRFCommUUID ) )->BuildUintL(
+            TSdpIntBuf <TUint8> ( aChannel ) )->EndListL()->EndListL();
+    
+    iSdpDB.UpdateAttributeL( iSdpRecordHandle,
+            KSdpAttrIdProtocolDescriptorList, *valDES );
+    
+    CleanupStack::PopAndDestroy( valDES );
+
+    iSdpDB.UpdateAttributeL( iSdpRecordHandle, KSdpAttrIdBasePrimaryLanguage
+            + KSdpAttrIdOffsetServiceName, KServiceName );
+    
+    iSdpDB.UpdateAttributeL( iSdpRecordHandle, KSdpAttrIdBasePrimaryLanguage
+            + KSdpAttrIdOffsetServiceDescription, KServiceDesc );
+    
+    UpdateAvailabilityL( ETrue );
+    
+    TRACE_INFO ( _L("CHsControlServer::RegisterSdpL, status = OK") )
+    TRACE_FUNC_EXIT
+    }
+
+void CHsControlServer::UpdateAvailabilityL( TBool aAvailable )
+    {
+    TInt state = ( aAvailable ? KServicAvailable : KServiceUnavailable );
+    // Set availability
+    iSdpDB.UpdateAttributeL( iSdpRecordHandle, KSdpAttrIdServiceAvailability,
+            state );
+    // Mark record changed
+    iSdpDB.UpdateAttributeL( iSdpRecordHandle, KSdpAttrIdServiceRecordState,
+            ++iRecordState );
+    }
+
+void CHsControlServer::DeleteRecordSdp()
+    {
+    TRACE_FUNC_ENTRY
+
+    iSdpDB.DeleteRecord( iSdpRecordHandle );
+    iSdpRecordHandle = 0;
+    iSdpDB.Close();
+    iSdpServer.Close();
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsControlServer::HandleRequestL( TDes8 &aRequest )
+    {
+    TRACE_FUNC_ENTRY
+
+    TBuf8 <KHsRemoteControlPackageLength> buf;
+
+    THsControlCommandData dummyBuf( KNullDesC8 );
+    THsRemoteControlCommand command( dummyBuf, EHsLast );
+    if ( iDataHandler )
+        {
+        TInt err = iDataHandler->RecognizeCommand( aRequest, command );
+        if ( KErrNone != err )
+            {
+            User::Leave( KErrArgument );
+            }
+        }
+
+    THsRemoteControlCommandType type = EHsLast;
+    command.GetType( type );
+
+    switch ( type )
+        {
+        case EHsTurnOn:
+            {
+            command.GetData( buf );
+
+            RBuf8 cod;
+            RBuf8 sdp;
+            RBuf8 plugin;
+
+            cod.CleanupClosePushL();
+            sdp.CleanupClosePushL();
+            plugin.CleanupClosePushL();
+
+            RetrieveStartupParamsL( buf, cod, sdp, plugin );
+
+            iHsCore->StartSimulationL( cod, sdp, plugin );
+
+            CleanupStack::PopAndDestroy( 3 );
+            }
+            break;
+
+        case EHsTurnOff:
+            {
+            iHsCore->StopSimulation();
+            }
+            break;
+        case EHsConnectLastconnected:
+            {
+            iHsCore->ConnectWithLastConnectedL();
+            }
+            break;
+        case EHsConnectDevAddress:
+            {
+            command.GetData( buf );
+            iHsCore->ConnectWithDevAddress( buf.Expand() );
+            }
+            break;
+        case EHsConnectName:
+            {
+            command.GetData( buf );
+            iHsCore->ConnectWithName( buf.Expand() );
+            }
+            break;
+        case EHsDisconnectAGs:
+            {
+            iHsCore->DisconnectClients();
+            }
+            break;
+        case EHsAcceptCall:
+            {
+            User::LeaveIfError( iHsCore->AcceptIncomingCall() );
+            }
+            break;
+        case EHsReleaseCall:
+            {
+            User::LeaveIfError( iHsCore->ReleaseOngoingCall() );
+            }
+            break;
+
+        case EHsSetSpeakerVolume:
+            {
+            command.GetData( buf );
+            RBuf8 tempBuf;
+            tempBuf.CreateL( buf.Length() + KHsATCommandEnding().Length()
+                    + KHsATVGS().Length() );
+            tempBuf.Copy( KHsATVGS );
+            tempBuf.Append( buf );
+            tempBuf.Append( KHsATCommandEnding );
+
+            iHsCore->Send( tempBuf );
+            tempBuf.Close();
+
+            }
+            break;
+        case EHsSetMicVolume:
+            {
+            command.GetData( buf );
+            RBuf8 tempBuf;
+            tempBuf.CreateL( buf.Length() + KHsATCommandEnding().Length()
+                    + KHsATVGM().Length() );
+            tempBuf.Copy( KHsATVGM );
+            tempBuf.Append( buf );
+            tempBuf.Append( KHsATCommandEnding );
+
+            iHsCore->Send( tempBuf );
+            tempBuf.Close();
+            }
+            break;
+        case EHsSendAnyAt:
+            {
+            command.GetData( buf );
+            User::LeaveIfError( iHsCore->Send( buf ) );
+            }
+            break;
+        default:
+            User::Leave( KErrArgument );
+
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsControlServer::RetrieveStartupParamsL( const TDesC8& aParams,
+        RBuf8& aPluginCod, RBuf8& aPluginSdp, RBuf8& aPluginProfile )
+
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt sepPos = aParams.Find( KHsRemoteRequestParamSeparator );
+
+    User::LeaveIfError( sepPos );
+
+    aPluginCod.CreateL( aParams.Left( sepPos ) );
+
+    sepPos += 2;
+
+    TInt sepPos2 = aParams.Mid( sepPos, aParams.Length() - sepPos ).Find(
+            KHsRemoteRequestParamSeparator );
+
+    User::LeaveIfError( sepPos2 );
+
+    aPluginSdp.CreateL( aParams.Mid( sepPos, sepPos2 ) );
+
+    sepPos += 2;
+    sepPos += sepPos2;
+
+    aPluginProfile.CreateL( aParams.Mid( sepPos, aParams.Length() - sepPos ) );
+
+    TRACE_FUNC_EXIT
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/src/Server/hsaudioserver.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,227 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#include "hsaudioserver.h"
+#include "debug.h"
+
+CHsAudioServer* CHsAudioServer::NewL( RSocketServ& aSocketServ,
+        TBool aPullAudio )
+    {
+    CHsAudioServer* self = CHsAudioServer::NewLC( aSocketServ, aPullAudio );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CHsAudioServer* CHsAudioServer::NewLC( RSocketServ& aSocketServ,
+        TBool aPullAudio )
+    {
+    CHsAudioServer* self = new ( ELeave ) CHsAudioServer( aSocketServ,
+            aPullAudio );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsAudioServer::~CHsAudioServer()
+    {
+
+    if ( iSCOSocket )
+        {
+        delete iSCOSocket;
+        }
+    }
+
+void CHsAudioServer::ListenL()
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iListening )
+        {
+        User::Leave( KErrInUse );
+        }
+    if ( iSCOSocket )
+        {
+        delete iSCOSocket;
+        iSCOSocket = NULL;
+        }
+    iSCOSocket = CBluetoothSynchronousLink::NewL( *this, iSServ );
+
+    User::LeaveIfNull( iSCOSocket );
+
+    User::LeaveIfError( iSCOSocket->AcceptConnection( iAcceptedPackets ) );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsAudioServer::ConnectL( const TBTDevAddr &aAddr )
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iConnected )
+        {
+        User::Leave( KErrInUse );
+        }
+    if ( iSCOSocket )
+        {
+        delete iSCOSocket;
+        iSCOSocket = NULL;
+        }
+    iSCOSocket = CBluetoothSynchronousLink::NewL( *this, iSServ );
+
+    User::LeaveIfNull( iSCOSocket );
+
+    iAddr = aAddr;
+    iSCOSocket->SetupConnection( aAddr, iAcceptedPackets );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsAudioServer::Disconnect()
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iSCOSocket && iConnected )
+        {
+        iSCOSocket->CancelReceive();
+        iSCOSocket->CancelSend();
+        iSCOSocket->Disconnect();
+        delete iSCOSocket;
+        iSCOSocket = NULL;
+        iConnected = EFalse;
+        iListening = EFalse;
+
+        ListenL();
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsAudioServer::Shutdown()
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iSCOSocket )
+        {
+        if ( iListening )
+            {
+            iSCOSocket->CancelAccept();
+            }
+        delete iSCOSocket;
+        iSCOSocket = NULL;
+        iListening = EFalse;
+        iConnected = EFalse;
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsAudioServer::SetPullAudio( TBool aPullAudio )
+    {
+    iPullAudio = aPullAudio;
+    }
+
+TBool CHsAudioServer::IsConnected()
+    {
+    return iConnected;
+    }
+
+TBool CHsAudioServer::IsListen()
+    {
+    return iListening;
+    }
+
+CHsAudioServer::CHsAudioServer( RSocketServ& aSocketServ, TBool aPullAudio ) :
+    iSServ( aSocketServ ), iAcceptedPackets( EAnySCOPacket ), iListening(
+            EFalse ), iPullAudio( aPullAudio )
+    {
+
+    }
+
+void CHsAudioServer::ConstructL()
+    {
+
+    }
+
+void CHsAudioServer::HandleSetupConnectionCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+    iConnected = ETrue;
+    iListening = EFalse;
+    iSCOSocket->AcceptConnection( TBTSyncPackets( iAcceptedPackets ) );
+
+    if ( aErr == KErrNone && iPullAudio )
+        {
+        User::LeaveIfError( iSCOSocket->Receive( iReceiveBuffer ) );
+        }
+
+    TRACE_FUNC_EXIT
+
+    }
+
+void CHsAudioServer::HandleDisconnectionCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+    iConnected = EFalse;
+    iListening = ETrue;
+    iSCOSocket->AcceptConnection( TBTSyncPackets( iAcceptedPackets ) );
+
+    TRACE_FUNC_EXIT
+    }
+void CHsAudioServer::HandleAcceptConnectionCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+    iConnected = ETrue;
+    iListening = EFalse;
+
+    if ( aErr == KErrNone && iPullAudio && iSCOSocket )
+        {
+        User::LeaveIfError( iSCOSocket->Receive( iReceiveBuffer ) );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsAudioServer::HandleSendCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+
+    if ( iPullAudio )
+        {
+        User::LeaveIfError( iSCOSocket->Receive( iReceiveBuffer ) );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+void CHsAudioServer::HandleReceiveCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+
+    if ( iPullAudio && aErr != KErrNone )
+        {
+        User::LeaveIfError( iSCOSocket->Receive( iReceiveBuffer ) );
+
+        }
+    if ( aErr == KErrDisconnected )
+        {
+        Disconnect();
+        }
+
+    TRACE_FUNC_EXIT
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/src/Server/hsclient.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,300 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#include "hsclient.h"
+#include "hsclientobservers.h"
+#include "debug.h"
+
+CHsClient* CHsClient::NewL( CBluetoothSocket *aClient,
+        MHsClientStateNotifier *aClientStateNotifier,
+        MHsClientObserver *aClientDisconnectNotifier )
+    {
+    User::LeaveIfNull( aClient );
+
+    CHsClient *self = CHsClient::NewLC( aClient, aClientStateNotifier,
+            aClientDisconnectNotifier );
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+CHsClient* CHsClient::NewLC( CBluetoothSocket *aClient,
+        MHsClientStateNotifier *aClientStateNotifier,
+        MHsClientObserver *aClientDisconnectNotifier )
+    {
+
+    User::LeaveIfNull( aClient );
+
+    CHsClient *self = new ( ELeave ) CHsClient( *aClient, aClientStateNotifier,
+            aClientDisconnectNotifier );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+
+    return self;
+    }
+
+CHsClient::~CHsClient()
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iSocket )
+        {
+        iSocket->CancelAll();
+        delete iSocket;
+        }
+
+    if ( iConnected )
+        {
+        if ( iStateNotifier )
+            {
+            TRAP_IGNORE( iStateNotifier->HandleClientDisconnectL(KErrNone) );
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClient::Send( const TDesC8 &aData )
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iSocket && iConnected )
+        {
+        TRAP_IGNORE( BufferedProcessL(aData) );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClient::SetClientDisconnectNotfier( MHsClientObserver &aNotifier )
+    {
+    TRACE_FUNC_ENTRY
+
+    iClientObserver = &aNotifier;
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClient::SetClientStateNotfier( MHsClientStateNotifier &aNotifier )
+    {
+    TRACE_FUNC_ENTRY
+
+    iStateNotifier = &aNotifier;
+
+    TRACE_FUNC_EXIT
+    }
+
+MHsClientStateNotifier* CHsClient::GetClientStateNotifer()
+    {
+    TRACE_FUNC_ENTRY
+
+    TRACE_FUNC_EXIT
+    return iStateNotifier;
+    }
+
+CHsClient::CHsClient( CBluetoothSocket &aClient,
+        MHsClientStateNotifier *aClientStateNotifier,
+        MHsClientObserver *aClientDisconnectNotifier )
+    {
+    TRACE_FUNC_ENTRY
+
+    iSocket = &aClient;
+    iStateNotifier = aClientStateNotifier;
+    iState = CHsClient::EIdle;
+    iConnected = ETrue;
+    iClientObserver = aClientDisconnectNotifier;
+    iSocket->SetNotifier( *this );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClient::ConstructL()
+    {
+    TRACE_FUNC_ENTRY
+    BufferedProcessL();
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClient::RawRecvL( TDes8 &aData )
+    {
+    TRACE_FUNC_ENTRY
+
+    User::LeaveIfNull( iSocket );
+    if ( !iConnected )
+        {
+        TRACE_INFO( _L(" Client is no longer connected" ) )
+        User::LeaveIfError( KErrDisconnected );
+        }
+    iState = CHsClient::EReceiving;
+    User::LeaveIfError( iSocket->RecvOneOrMore( aData, iReceiveFlag,
+            iReceiveMessageLength ) );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClient::RawSendL( const TDesC8 &aData )
+    {
+    TRACE_FUNC_ENTRY
+
+    User::LeaveIfNull( iSocket );
+    if ( !iConnected )
+        {
+        User::LeaveIfError( KErrDisconnected );
+        }
+    if ( aData.Length() == 0 )
+        {
+        User::Leave( KErrWrite );
+        }
+    iState = CHsClient::ESending;
+    User::LeaveIfError( iSocket->Send( aData, iSendFlag ) );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClient::BufferedProcessL( const TDesC8 &aData )
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iState != CHsClient::ESending )
+        {
+        iTempSendBuf.Append( aData );
+        SwapBuffers();
+        if ( iSendBuf.Length() > 0 )
+            {
+            iSocket->CancelRecv();
+            RawSendL( iSendBuf );
+            }
+        else if ( iState != CHsClient::ESending )
+            {
+            RawRecvL( iReceiveMessageBuffer );
+            }
+        }
+    else
+        {
+
+        iTempSendBuf.Append( aData );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClient::SwapBuffers()
+    {
+    TRACE_FUNC_ENTRY
+
+    iSendBuf.Copy( iTempSendBuf );
+    iTempSendBuf.Zero();
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClient::HandleConnectCompleteL( TInt aErr )
+    {
+
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) )
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClient::HandleAcceptCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) )
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClient::HandleShutdownCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) )
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClient::HandleSendCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) )
+
+    iState = CHsClient::EIdle;
+    iSendBuf.Zero();
+    if ( aErr != KErrDisconnected )
+        {
+        BufferedProcessL( KNullDesC8 );
+        }
+    if ( iStateNotifier )
+        {
+        if ( aErr != KErrDisconnected )
+            {
+            iStateNotifier->HandleClientSendCompleteL( aErr );
+            }
+        else
+            {
+            iConnected = EFalse;
+            iStateNotifier->HandleClientDisconnectL( aErr );
+            iClientObserver->HandleClientDisconnect( this, aErr );
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClient::HandleReceiveCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) )
+
+    iState = CHsClient::EIdle;
+    if ( iStateNotifier )
+        {
+        if ( aErr == KErrNone )
+            {
+            TRAP_IGNORE( iStateNotifier->HandleClientReceiveCompleteL(
+                            iReceiveMessageBuffer, aErr ) );
+
+            }
+        else
+            {
+            iConnected = EFalse;
+            iStateNotifier->HandleClientDisconnectL( aErr );
+            iClientObserver->HandleClientDisconnect( this, aErr );
+            }
+        }
+
+    if ( aErr == KErrNone )
+        {
+        BufferedProcessL( KNullDesC8 );
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClient::HandleIoctlCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClient::HandleActivateBasebandEventNotifierCompleteL( TInt aErr,
+        TBTBasebandEventNotification& aEventNotification )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+
+    TRACE_FUNC_EXIT
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/src/Server/hsclientmanager.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,139 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#include "hsclientmanager.h"
+#include "hsclientobservers.h"
+#include "hsclient.h"
+#include "debug.h"
+
+CHsClientManager* CHsClientManager::NewL()
+    {
+
+    CHsClientManager *self = CHsClientManager::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CHsClientManager* CHsClientManager::NewLC()
+    {
+    CHsClientManager *self = new ( ELeave ) CHsClientManager;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsClientManager::~CHsClientManager()
+    {
+    TRACE_FUNC_ENTRY
+
+    iClientArray.ResetAndDestroy();
+    iObserverArray.Close();
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClientManager::SetClientStateNotfierL(
+        MHsClientStateNotifier &aClientStateNotifier, TInt aNumber )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aNumber = %d"), aNumber) );
+
+    if ( aNumber < 0 )
+        {
+        User::Leave( KErrUnderflow );
+        }
+    else if ( aNumber >= iClientArray.Count() )
+        {
+        User::Leave( KErrOverflow );
+        }
+    iClientArray[aNumber]->SetClientStateNotfier( aClientStateNotifier );
+    iObserverArray.InsertL( &aClientStateNotifier, aNumber );
+
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsClientManager::Send( const TDesC8 &aAt, TInt aNumber )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO((_L8("Data to be send: %S"), &aAt))
+
+    TInt err = KErrNone;
+
+    if ( aNumber >= 0 && aNumber < iClientArray.Count() )
+        {
+        iClientArray[aNumber]->Send( aAt );
+        }
+    else
+        {
+        err = KErrNotFound;
+        }
+
+    TRACE_INFO( ( _L("Returned value = %d"), err) );
+    TRACE_FUNC_EXIT
+    return err;
+    }
+
+void CHsClientManager::DisconnectClients()
+    {
+    TRACE_FUNC_ENTRY
+    //free memory
+    iClientArray.ResetAndDestroy();
+    iObserverArray.Reset();
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClientManager::HandleNewClientL( CHsClient *aClient, TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+
+    if ( aClient && aErr == KErrNone )
+        {
+        iClientArray.AppendL( aClient );
+        aClient->SetClientDisconnectNotfier( *this );
+        iObserverArray.AppendL( aClient->GetClientStateNotifer() );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsClientManager::HandleClientDisconnect( CHsClient *aClient, 
+        TInt /** aErr */)
+    {
+    TRACE_FUNC_ENTRY
+    TInt idx = iClientArray.Find( aClient );
+    if ( KErrNotFound != idx )
+        {
+        iClientArray.Remove( idx );
+        iObserverArray.Remove( idx );
+        }
+
+    delete aClient;
+
+    TRACE_FUNC_EXIT
+    }
+
+CHsClientManager::CHsClientManager() :
+    iClientArray( KHsClientManagerArrayMinSize ), iObserverArray(
+            KHsClientManagerArrayMinSize )
+    {
+
+    }
+
+void CHsClientManager::ConstructL()
+    {
+
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/src/Server/hsserver.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,278 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#include "hsserver.h"
+#include "hsclientobservers.h"
+#include "debug.h"
+
+CHsServer* CHsServer::NewL( RSocketServ &aSocketServ )
+    {
+    CHsServer* self = CHsServer::NewLC( aSocketServ );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CHsServer* CHsServer::NewLC( RSocketServ &aSocketServ )
+    {
+    CHsServer* self = new ( ELeave ) CHsServer( aSocketServ );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsServer::~CHsServer()
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iSocketServer )
+        {
+        delete iSocketServer;
+        }
+
+    if ( iBlankSocket )
+        {
+        delete iBlankSocket;
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsServer::Listen()
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt error = KErrNone;
+    TProtocolDesc protDesc;
+    TBTSockAddr addr;
+    TProtocolName protName( KRFCOMMDesC );
+
+    if ( iListen )
+        {
+        TRACE_FUNC_EXIT
+        return KErrAlreadyExists;
+        }
+
+    error = iSServ.FindProtocol( protName, protDesc );
+    if ( error != KErrNone )
+        {
+        TRACE_FUNC_EXIT
+        return error;
+        }
+
+    TRAP(error, iSocketServer = CBluetoothSocket::NewL(*this, iSServ, 
+            protDesc.iSockType, protDesc.iProtocol));
+    
+    if ( error != KErrNone )
+        {
+        TRACE_FUNC_EXIT
+        return error;
+        }
+
+    error = iSocketServer->GetOpt( KRFCOMMGetAvailableServerChannel,
+            KSolBtRFCOMM, iPort );
+    if ( error != KErrNone )
+        {
+        TRACE_FUNC_EXIT
+        return error;
+        }
+
+    addr.SetPort( iPort );
+    addr.SetSecurity( iServerSecurity );
+
+    error = iSocketServer->Bind( addr );
+    if ( error != KErrNone )
+        {
+        TRACE_FUNC_EXIT
+        return error;
+        }
+
+    error = iSocketServer->Listen( KListenQueueSize );
+    if ( error != KErrNone )
+        {
+        TRACE_FUNC_EXIT
+        return error;
+        }
+
+    if ( !iBlankSocket )
+        {
+        TRAP(error, iBlankSocket=CBluetoothSocket::NewL(*this, iSServ));
+        }
+
+    if ( error != KErrNone )
+        {
+        TRACE_FUNC_EXIT
+        return error;
+        }
+
+    error = iSocketServer->Accept( *iBlankSocket );
+
+    iListen = ETrue;
+
+    TRACE_INFO( ( _L("Returned value = %d"), error) );
+    TRACE_FUNC_EXIT
+
+    return error;
+    }
+
+TBool CHsServer::IsReady()
+    {
+    return iListen;
+    }
+
+void CHsServer::Shutdown()
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iSocketServer )
+        {
+        if ( iListen )
+            {
+            iSocketServer->CancelAccept();
+            iListen = EFalse;
+            }
+
+        // Return value may be ignored
+        iSocketServer->Shutdown( RSocket::EImmediate );
+        delete iSocketServer;
+        iSocketServer = NULL;
+        }
+    else
+        {
+        TRAP_IGNORE( HandleShutdownCompleteL(KErrNone) );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsServer::SetNewClientObserver(
+        MHsAcceptNewClientObserver &aNewClientObserv )
+    {
+    iNewClientObserver = &aNewClientObserv;
+    }
+
+TInt CHsServer::GetPort()
+    {
+    return iPort;
+    }
+
+void CHsServer::GetSocketAndTryToConnectL( const TBTSockAddr &aAddr )
+    {
+    TRACE_FUNC_ENTRY
+    TBTSockAddr sockaddr( aAddr );
+    TProtocolName protocolName( KRFCOMMDesC );
+    TProtocolDesc protocolDesc;
+
+    if ( iBlankSocket2 != NULL )
+        {
+        delete iBlankSocket2;
+        iBlankSocket2 = NULL;
+        }
+
+    User::LeaveIfError( iSServ.FindProtocol( protocolName, protocolDesc ) );
+    iBlankSocket2 = CBluetoothSocket::NewL( *this, iSServ,
+            protocolDesc.iSockType, protocolDesc.iProtocol );
+    User::LeaveIfError( iBlankSocket2->Connect( sockaddr ) );
+    TRACE_FUNC_EXIT
+    }
+
+CHsServer::CHsServer( RSocketServ &aSocketServ ) :
+    iSServ( aSocketServ )
+    {
+    iServerSecurity.SetUid( TUid::Uid( 0x10ff ) );
+    iServerSecurity.SetAuthentication( EFalse );
+    iServerSecurity.SetAuthorisation( EFalse );
+    iServerSecurity.SetEncryption( EFalse );
+    }
+
+void CHsServer::ConstructL()
+    {
+
+    }
+
+void CHsServer::HandleConnectCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+
+    iNewClientObserver->HandleNewClientL( aErr == KErrNone ? iBlankSocket2
+            : NULL, aErr );
+    if ( aErr != KErrNone )
+        {
+        delete iBlankSocket2;
+        }
+    iBlankSocket2 = NULL;
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsServer::HandleAcceptCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+
+    if ( iNewClientObserver )
+        {
+        iNewClientObserver->HandleNewClientL( iBlankSocket, aErr );
+        }
+    else
+        {
+        iNewClientObserver->HandleNewClientL( NULL, KErrBadHandle );
+        delete iBlankSocket;
+        }
+    iBlankSocket = NULL;
+    iBlankSocket = CBluetoothSocket::NewL( *this, iSServ );
+    User::LeaveIfError( iSocketServer->Accept( *iBlankSocket ) );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsServer::HandleShutdownCompleteL( TInt /** aErr */)
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iBlankSocket )
+        {
+        delete iBlankSocket;
+        iBlankSocket = NULL;
+        }
+    if ( iSocketServer )
+        {
+        delete iSocketServer;
+        iSocketServer = NULL;
+        }
+    iListen = EFalse;
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsServer::HandleSendCompleteL( TInt /** aErr */)
+    {
+
+    }
+
+void CHsServer::HandleReceiveCompleteL( TInt /** aErr */)
+    {
+
+    }
+
+void CHsServer::HandleIoctlCompleteL( TInt /** aErr */)
+    {
+    }
+
+void CHsServer::HandleActivateBasebandEventNotifierCompleteL( TInt /** aErr */,
+        TBTBasebandEventNotification& /** aEventNotification */)
+    {
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/src/Tools/hsbtmanager.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,398 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#include "debug.h"
+#include "hstools.h"
+
+CHsBTManager* CHsBTManager::NewL( RSocketServ& aSocketServ,
+        MHsBTManagerObserver* aBTManagerObserver )
+    {
+    CHsBTManager* self = CHsBTManager::NewLC( aSocketServ, aBTManagerObserver );
+    CleanupStack::Pop( self ); // self;
+    return self;
+    }
+
+CHsBTManager* CHsBTManager::NewLC( RSocketServ& aSocketServ,
+        MHsBTManagerObserver* aBTManagerObserver )
+    {
+    CHsBTManager* self = new ( ELeave ) CHsBTManager( aSocketServ,
+            aBTManagerObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsBTManager::CHsBTManager( RSocketServ& aSocketServ,
+        MHsBTManagerObserver* aBTManagerObserver ) :
+    iSocketServ( aSocketServ ), iBTManagerObserver( aBTManagerObserver )
+    {
+
+    }
+
+CHsBTManager::~CHsBTManager()
+    {
+    TRACE_FUNC_ENTRY
+    RestoreInitialSettings();
+
+    if ( iBTSettings )
+        {
+        delete iBTSettings;
+        }
+    if ( iBTConnection )
+        {
+        delete iBTConnection;
+        }
+
+    if ( iDiscoverer )
+        {
+        delete iDiscoverer;
+        }
+    if ( iBTDiscovery )
+        {
+        delete iBTDiscovery;
+        }
+
+    iDesiredDevAdrress.Close();
+    iDesiredName.Close();
+
+    iBTInitialName.Close();
+    iBTName.Close();
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::ConstructL()
+    {
+    TRACE_FUNC_ENTRY
+    iBTSettings = CBTEngSettings::NewL( this );
+    iBTConnection = CBTEngConnMan::NewL( this );
+    iDiscoverer = CHsDeviceDiscoverer::NewL( this, iSocketServ );
+    iBTDiscovery = CBTEngDiscovery::NewL( this );
+
+    iDesiredName.CreateL( KMaxBluetoothNameLen );
+    iDesiredDevAdrress.CreateL( KMaxBluetoothNameLen );
+    iBTInitialName.CreateL( KMaxBluetoothNameLen );
+    iBTName.CreateL( KMaxBluetoothNameLen );
+
+    User::LeaveIfError( iBTSettings->GetLocalName( iBTInitialName ) );
+    iBTName.Copy( iBTInitialName );
+
+    User::LeaveIfError( iBTSettings->GetVisibilityMode(
+            iBTInitialVisibilityMode ) );
+    iServiceSet = EFalse;
+
+    User::LeaveIfError( iBTSettings->GetPowerState( iBTInitialPowerState ) );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::SetBTNameL( const TDesC& aBTName )
+    {
+    TRACE_FUNC_ENTRY
+    iBTName.Copy( aBTName );
+    User::LeaveIfError( iBTSettings->SetLocalName( iBTName ) );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::TurnBtOnL( const TDesC& aName )
+    {
+    TRACE_FUNC_ENTRY
+    User::LeaveIfError( iBTSettings->SetPowerState( EBTPowerOn ) );
+    SetBTNameL( aName );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::TurnBtOffL()
+    {
+    TRACE_FUNC_ENTRY
+    User::LeaveIfError( iBTSettings->SetPowerState( EBTPowerOff ) );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::FindDevL( const TDesC& aDevAddress )
+    {
+    TRACE_FUNC_ENTRY
+    iDesiredDevAdrress.Zero();
+    iDesiredName.Zero();
+
+    iLookingFor = EDevAddress;
+    iDesiredDevAdrress.Copy( aDevAddress );
+
+    TBTPowerStateValue powerState;
+    User::LeaveIfError( iBTSettings->GetPowerState( powerState ) );
+    if ( powerState == EBTPowerOff )
+        {
+        TurnBtOnL();
+        }
+    iDiscoverer->DeviceSearchL();
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::FindNameL( const TDesC& aDeviceName )
+    {
+    TRACE_FUNC_ENTRY
+    iDesiredDevAdrress.Zero();
+    iDesiredName.Zero();
+
+    iLookingFor = EName;
+    iDesiredName.Copy( aDeviceName );
+
+    TBTPowerStateValue powerState;
+    User::LeaveIfError( iBTSettings->GetPowerState( powerState ) );
+    if ( powerState == EBTPowerOff )
+        {
+        TurnBtOnL();
+        }
+    iDiscoverer->DeviceSearchL();
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::SetService( const TUUID& aService )
+    {
+    TRACE_FUNC_ENTRY
+    iServiceSet = ETrue;
+    iService = aService;
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::CancelConnecting()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iDiscoverer )
+        iDiscoverer->Cancel();
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsBTManager::SetVisible( TBTVisibilityMode aVisibilityMode )
+    {
+    TRACE_FUNC
+    return iBTSettings->SetVisibilityMode( aVisibilityMode );
+    }
+
+void CHsBTManager::HandleDeviceFindSuccessL( TDesC8& aDevAddress,
+        TDesC8& aDevName, TUint16 /*aMajServClass*/, TUint /*aMajDeviceClass*/,
+        TUint8 /*aMinDeviceClass*/)
+    {
+
+    TRACE_FUNC_ENTRY
+
+    RBuf bufDevAddr;
+    RBuf bufDevName;
+
+    bufDevAddr.CleanupClosePushL();
+    bufDevName.CleanupClosePushL();
+
+    bufDevAddr.CreateL( aDevAddress.Length() );
+    bufDevName.CreateL( aDevName.Length() );
+
+    bufDevAddr.Copy( aDevAddress );
+    bufDevName.Copy( aDevName );
+
+    TRACE_INFO( (_L("DevName: %S :: DevAddr: %S") , &bufDevName, &bufDevAddr) )
+
+    if ( ( iLookingFor == EDevAddress )
+          && ( aDevAddress == iDesiredDevAdrress ) )
+        {
+        TRACE_INFO( (_L("Desired DevAddr [%S] found"), &bufDevAddr) )
+        iDiscoverer->Cancel();
+
+        if ( KDevAddrLength != iDevAddr.SetReadable( bufDevAddr ) )
+            {
+            iBTManagerObserver->HandleDesiredDeviceNotFound( KErrNotFound );
+            }
+        iDesiredName.Copy( bufDevName );
+        TRAPD(err,FindServiceL(iDevAddr, iService));
+
+        if ( err != KErrNone )
+            {
+            TRACE_INFO( (_L("FindService error: %d"), err) )
+            iBTManagerObserver->HandleServiceNotFound( err );
+            }
+        }
+    else if ( ( iLookingFor == EName ) && ( bufDevName == iDesiredName ) )
+        {
+        TRACE_INFO( (_L("Desired DevName [%S] found"), &bufDevName) )
+        iDiscoverer->Cancel();
+
+        if ( KDevAddrLength != iDevAddr.SetReadable( bufDevAddr ) )
+            {
+            iBTManagerObserver->HandleDesiredDeviceNotFound( KErrNotFound );
+            }
+        TRAPD(err,FindServiceL(iDevAddr, iService));
+
+        if ( err != KErrNone )
+            {
+            TRACE_INFO( (_L("FindService error: %d"), err) )
+            iBTManagerObserver->HandleServiceNotFound( err );
+            }
+        }
+
+    CleanupStack::PopAndDestroy( 2 );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::HandleDeviceFindFailed( TInt aErr )
+    {
+
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+    iDiscoverer->Cancel();
+
+    iBTManagerObserver->HandleDesiredDeviceNotFound( aErr );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::PowerStateChanged( TBTPowerStateValue /*aState*/)
+    {
+    TRACE_FUNC_ENTRY
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::VisibilityModeChanged( TBTVisibilityMode /*aState*/)
+    {
+    TRACE_FUNC_ENTRY
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::ConnectComplete( TBTDevAddr& /*aAddr*/, TInt aErr,
+        RBTDevAddrArray* /*aConflicts*/)
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::DisconnectComplete( TBTDevAddr& /*aAddr*/, TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::PairingComplete( TBTDevAddr& /*aAddr*/, TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::ServiceSearchComplete(
+        const RSdpRecHandleArray& /*aResult*/, TUint /*aTotalRecordsCount*/,
+        TInt /*aErr*/)
+    {
+    TRACE_FUNC_ENTRY
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::AttributeSearchComplete( TSdpServRecordHandle /*aHandle*/,
+        const RSdpResultArray& /*aAttr*/, TInt /*aErr*/)
+    {
+    TRACE_FUNC_ENTRY
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::ServiceAttributeSearchComplete(
+        TSdpServRecordHandle /*aHandle*/, const RSdpResultArray& aAttr,
+        TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+
+    TInt port;
+
+    TInt err = FindPort( aAttr, port );
+    iDiscoverer->Cancel();
+
+    if ( err == KErrNone )
+        {
+        iBTManagerObserver->HandleDesiredDeviceFound( iDesiredName, iDevAddr,
+                port );
+        }
+    else
+        {
+        iBTManagerObserver->HandlePortNotFound( err );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::DeviceSearchComplete( CBTDevice* /*aDevice*/, TInt /*aErr*/)
+    {
+    TRACE_FUNC_ENTRY
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::RestoreInitialSettings()
+    {
+    TRACE_FUNC_ENTRY
+    // Return values may be ignored, no influence on Headset functionality
+    iBTSettings->SetLocalName( iBTInitialName );
+    iBTSettings->SetPowerState( iBTInitialPowerState );
+    iBTSettings->SetVisibilityMode( iBTInitialVisibilityMode );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsBTManager::FindServiceL( const TBTDevAddr& aDevAddr,
+        const TUUID& aService )
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( !iServiceSet )
+        {
+        User::Leave( KErrNotReady );
+        }
+    TInt err = iBTDiscovery->RemoteSdpQuery( aDevAddr, aService,
+            KSdpAttrIdProtocolDescriptorList );
+
+    if ( err != KErrNone )
+        {
+        iBTManagerObserver->HandleSdpQueryError( err );
+        }
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsBTManager::FindPort( const RSdpResultArray& aAttr, TInt& aPort )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt err = KErrNotFound;
+
+    for ( TInt i = 0; i < aAttr.Count(); i++ )
+        {
+        TBTEngSdpAttrValue attr = aAttr[i];
+
+        if ( attr.iAttrType == ETypeUint )
+            {
+            aPort = attr.iAttrValue.iValNumeric;
+            err = KErrNone;
+            TRACE_INFO( (_L("Found port: %d"), aPort) )
+            break;
+            }
+        }
+
+    TRACE_INFO( ( _L("Returned value = %d"), err) );
+    TRACE_FUNC_EXIT
+    return err;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/src/Tools/hsdevicediscoverer.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,134 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#include "debug.h"
+#include "hstools.h"
+
+CHsDeviceDiscoverer* CHsDeviceDiscoverer::NewL(
+        MHsDeviceDiscovererObserver* aDeviceObserver, RSocketServ& aSocketServ )
+    {
+    CHsDeviceDiscoverer *self = CHsDeviceDiscoverer::NewLC( aDeviceObserver,
+            aSocketServ );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CHsDeviceDiscoverer* CHsDeviceDiscoverer::NewLC(
+        MHsDeviceDiscovererObserver* aDeviceObserver, RSocketServ& aSocketServ )
+    {
+    CHsDeviceDiscoverer *self = new ( ELeave ) CHsDeviceDiscoverer(
+            aDeviceObserver, aSocketServ );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsDeviceDiscoverer::CHsDeviceDiscoverer(
+        MHsDeviceDiscovererObserver* aDeviceObserver, 
+        RSocketServ& aSocketServ ) : CActive( EPriorityNormal ), 
+        iSocketServ( aSocketServ ), iDeviceObserver(
+            aDeviceObserver )
+    {
+    CActiveScheduler::Add( this );
+    iSearching = EFalse;
+    }
+
+CHsDeviceDiscoverer::~CHsDeviceDiscoverer()
+    {
+    TRACE_FUNC_ENTRY
+    Cancel();
+    iHostResolver.Close();
+    TRACE_FUNC_EXIT
+    }
+
+void CHsDeviceDiscoverer::ConstructL()
+    {
+    }
+
+void CHsDeviceDiscoverer::DeviceSearchL()
+    {
+    TRACE_FUNC_ENTRY
+    Cancel();
+
+    ConnectHostResolverL();
+    iSearching = ETrue;
+    iHostResolver.GetByAddress( iSockAddr, iEntry, iStatus );
+    SetActive();
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsDeviceDiscoverer::ConnectHostResolverL()
+    {
+    TRACE_FUNC_ENTRY
+    TProtocolDesc protDesc;
+    TProtocolName protName( KHsProtocolName );
+
+    User::LeaveIfError( iSocketServ.FindProtocol( protName, protDesc ) );
+    User::LeaveIfError( iHostResolver.Open( iSocketServ, protDesc.iAddrFamily,
+            protDesc.iProtocol ) );
+    iSockAddr.SetIAC( KGIAC );
+    iSockAddr.SetAction( KHostResInquiry | KHostResName );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsDeviceDiscoverer::RunL()
+    {
+    TRACE_FUNC_ENTRY
+
+    TRACE_INFO( (_L("Status value = %d"), iStatus.Int() ) )
+    if ( iStatus.Int() == KErrNone )
+        {
+
+        TInquirySockAddr& sa = TInquirySockAddr::Cast( iEntry().iAddr );
+        TBuf <KDevAddrLength> devAddrBuf;
+        sa.BTAddr().GetReadable( devAddrBuf );
+        TBuf8 <KDevAddrLength> devAddrBuf8;
+        devAddrBuf8.Copy( devAddrBuf );
+
+        TBuf8 <KMaxBluetoothNameLen> devNameBuf;
+        devNameBuf.Copy( iEntry().iName );
+        iDeviceObserver->HandleDeviceFindSuccessL( devAddrBuf8, devNameBuf,
+                sa.MajorServiceClass(), sa.MajorClassOfDevice(),
+                sa.MinorClassOfDevice() );
+        // Get next device if no previous errors
+        iHostResolver.Next( iEntry, iStatus );
+        SetActive();
+        }
+    else
+        {
+        Cancel();
+        iHostResolver.Close();
+        iSearching = EFalse;
+        if ( iDeviceObserver )
+            {
+            iDeviceObserver->HandleDeviceFindFailed( iStatus.Int() );
+            }
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsDeviceDiscoverer::DoCancel()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iSearching )
+        {
+        iHostResolver.Cancel();
+        iHostResolver.Close();
+        }
+    TRACE_FUNC_EXIT
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/core/src/hscore.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,909 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#include "hscore.h"
+#include "hsprofilemanager.h"
+#include "hsobserver.h"
+#include "hsserver.h"
+#include "hsaudioserver.h"
+#include "hsclientmanager.h"
+#include "hsclient.h"
+#include "hstools.h"
+#include "hsremotecontrolserver.h"
+#include "debug.h"
+
+EXPORT_C CHsCore* CHsCore::NewL( const TUUID& aService )
+    {
+    CHsCore* self = CHsCore::NewLC( aService );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+EXPORT_C CHsCore* CHsCore::NewLC( const TUUID& aService )
+    {
+    CHsCore* self = new ( ELeave ) CHsCore( aService );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+EXPORT_C CHsCore::~CHsCore()
+    {
+    TRACE_FUNC_ENTRY
+
+    DestroyComponents();
+    iSocketServ.Close();
+
+    TRACE_FUNC_EXIT
+    }
+
+CHsCore::CHsCore( const TUUID& aService ) :
+    iService( aService )
+    {
+
+    }
+
+void CHsCore::ConstructL()
+    {
+    TRACE_FUNC_ENTRY
+
+    User::LeaveIfError( iSocketServ.Connect() );
+    CreateComponentsL();
+    RegisterProperty();
+    InitializeSimulationL();
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsCore::StartSimulationL( const TUid& aCoDUid,
+        const TUid& aSdpUid, const TUid& aProfileUid, const TDesC& aBTName )
+    {
+    TRACE_FUNC_ENTRY
+
+    InitializeSimulationL( aBTName );
+
+    LoadSdpL( aSdpUid );
+    LoadCodL( aCoDUid );
+    LoadProfileL( aProfileUid );
+
+    User::LeaveIfError( StartHSServer() );
+    User::LeaveIfError( StartAudioServer( ETrue ) );
+
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsCore::StartSimulationL( const TDesC8& aCoDName,
+        const TDesC8& aSdpName, const TDesC8& aProfileName,
+        const TDesC& aBTName )
+    {
+    TRACE_FUNC_ENTRY
+
+    InitializeSimulationL( aBTName );
+
+    LoadSdpL( aSdpName );
+    LoadCodL( aCoDName );
+    LoadProfileL( aProfileName );
+
+    User::LeaveIfError( StartHSServer() );
+    User::LeaveIfError( StartAudioServer( ETrue ) );
+
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsCore::StopSimulation()
+    {
+    TRACE_FUNC_ENTRY
+    DestroyPluginManager();
+    DestroyClientManager();
+    DestroyHSServer();
+    DestroyAudioServer();
+
+    CreateHSServer();
+    CreateAudioServer( ETrue );
+    CreateClientManager();
+    CreatePluginManager();
+
+    TRAP_IGNORE(InitializeSimulationL());
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsCore::ConnectWithName( const TDesC &aName )
+    {
+    TRACE_FUNC_ENTRY
+    if ( iObserver )
+        {
+        iObserver->HandleConnectingToClient();
+        }
+    if ( iHsBTManager )
+        {
+        TRAPD(err, iHsBTManager->FindNameL(aName));
+        if ( err != KErrNone && iObserver )
+            {
+            iObserver->HandleUnableToConnectClient();
+            }
+        TRACE_INFO((_L("Connect with name: %S, error = %d"), &aName, err))
+        }
+    else if ( iObserver )
+        {
+        iObserver->HandleUnableToConnectClient();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsCore::ConnectWithDevAddress( const TDesC& aDevAddress )
+    {
+    TRACE_FUNC_ENTRY
+    if ( iObserver )
+        {
+        iObserver->HandleConnectingToClient();
+        }
+    if ( iHsBTManager )
+        {
+        TRAPD(err, iHsBTManager->FindDevL(aDevAddress));
+        if ( err != KErrNone && iObserver )
+            {
+            iObserver->HandleUnableToConnectClient();
+            }
+        }
+    else if ( iObserver )
+        {
+        iObserver->HandleUnableToConnectClient();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsCore::ConnectWithLastConnectedL()
+    {
+    TRACE_FUNC_ENTRY
+
+    TBTDevAddr addr;
+    User::LeaveIfError( GetLastConnected( addr ) );
+
+    RBuf lastDevAddrBuf;
+
+    lastDevAddrBuf.CreateL( KMaxBluetoothNameLen );
+    addr.GetReadable( lastDevAddrBuf );
+
+    ConnectWithDevAddress( lastDevAddrBuf );
+
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsCore::CancelConnecting()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iHsBTManager )
+        {
+        iHsBTManager->CancelConnecting();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsCore::DisconnectClients()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iHSClientManager )
+        {
+        iHSClientManager->DisconnectClients();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C TInt CHsCore::Send( const TDesC8 &aData, TInt aNumber )
+    {
+    TRACE_FUNC_ENTRY
+    TInt ret = KErrNone;
+    if ( iHSClientManager && iHSProfileManager )
+        {
+        TBuf8 <KHsClientBufferLength> tmp;
+
+        TRAP(ret, iHSProfileManager->HandleCommandL(aData, tmp, EFalse));
+        if ( KErrNone == ret )
+            {
+            ret = iHSClientManager->Send( tmp, aNumber );
+            }
+        }
+    else
+        {
+        ret = KErrNotReady;
+        }
+    TRACE_FUNC_EXIT
+    return ret;
+    }
+
+EXPORT_C void CHsCore::SetObserver( MHsObserver& aObserver )
+    {
+    TRACE_FUNC_ENTRY
+    iObserver = &aObserver;
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C TInt CHsCore::AcceptIncomingCall()
+    {
+    TRACE_FUNC_ENTRY
+
+    TBuf8 <KHsClientBufferLength> tmp;
+    TRAPD(ret,iHSProfileManager->AcceptIncomingCallL(tmp));
+
+    if ( KErrNone == ret )
+        {
+        ret = iHSClientManager->Send( tmp );
+        }
+
+    TRACE_FUNC_EXIT
+    return ret;
+    }
+
+EXPORT_C TInt CHsCore::ReleaseOngoingCall()
+    {
+    TBuf8 <KHsClientBufferLength> tmp;
+    TRAPD(ret,iHSProfileManager->ReleaseOngoingCallL(tmp));
+
+    if ( KErrNone == ret )
+        {
+        ret = iHSClientManager->Send( tmp );
+        }
+
+    TRACE_FUNC_EXIT
+    return ret;
+    }
+
+void CHsCore::InitializeSimulationL( const TDesC& aBTName )
+    {
+    TRACE_FUNC_ENTRY
+
+    User::LeaveIfNull( iHsBTManager );
+    if ( aBTName != KNullDesC )
+        {
+        SetBTName( aBTName );
+        iHsBTManager->TurnBtOnL( aBTName );
+        }
+    else
+        {
+        iHsBTManager->TurnBtOnL();
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::RegisterProperty()
+    {
+    TRACE_FUNC_ENTRY
+    // Return value may be ignored, no influence on main Headset functionality
+    RProperty::Define( KHSProperty, ELastDevice, RProperty::EByteArray,
+            KLastDevAddrLength );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::CreateComponentsL()
+    {
+    TRACE_FUNC_ENTRY
+    User::LeaveIfError( CreateControlServer() );
+    User::LeaveIfError( CreateHSServer() );
+    User::LeaveIfError( CreateAudioServer( ETrue ) );
+    User::LeaveIfError( CreateClientManager() );
+    User::LeaveIfError( CreatePluginManager() );
+    User::LeaveIfError( CreateBTManager() );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::DestroyComponents()
+    {
+    TRACE_FUNC_ENTRY
+
+    DestroyControlServer();
+    DestroyPluginManager();
+    DestroyClientManager();
+    DestroyHSServer();
+    DestroyAudioServer();
+    DestroyBTManager();
+
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsCore::CreateHSServer()
+    {
+    TRACE_FUNC_ENTRY
+    TInt ret = KErrNone;
+
+    if ( !iHSServer )
+        {
+        TRAP(ret, iHSServer = CHsServer::NewL(iSocketServ));
+
+        if ( ret == KErrNone )
+            {
+            iHSServer->SetNewClientObserver( *this );
+            }
+        }
+    else
+        {
+        ret = KErrAlreadyExists;
+        }
+
+    TRACE_FUNC_EXIT
+    return ret;
+    }
+
+TInt CHsCore::StartHSServer()
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt ret = KErrNone;
+    if ( !iHSServer )
+        {
+        ret = KErrNotReady;
+        }
+    else
+        {
+        if ( !iHSServer->IsReady() )
+            {
+            ret = iHSServer->Listen();
+            }
+        else
+            {
+            ret = KErrInUse;
+            }
+        }
+
+    if ( ret == KErrNone && iHSProfileManager )
+        {
+        iHSProfileManager->SetSdpServicePort( iHSServer->GetPort() );
+        iHSProfileManager->RefreshSdp();
+        }
+
+    TRACE_FUNC_EXIT
+    return ret;
+    }
+
+void CHsCore::StopHSServer()
+    {
+    TRACE_FUNC_ENTRY
+    if ( ( iHSServer ) && ( iHSServer->IsReady() ) )
+        {
+        iHSServer->Shutdown();
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::DestroyHSServer()
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iHSServer )
+        {
+        delete iHSServer;
+        iHSServer = NULL;
+        }
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsCore::CreateAudioServer( TBool aPullAudio )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt ret = KErrNone;
+
+    if ( iAudioServer )
+        {
+        ret = KErrAlreadyExists;
+        }
+    else
+        {
+        TRAP(ret, iAudioServer = CHsAudioServer::NewL(iSocketServ, aPullAudio));
+        }
+
+    TRACE_FUNC_EXIT
+
+    return ret;
+    }
+
+TInt CHsCore::StartAudioServer( TBool aPullAudio )
+    {
+    TRACE_FUNC_ENTRY
+    TInt ret = KErrNone;
+
+    if ( iAudioServer && !iAudioServer->IsListen()
+            && !iAudioServer->IsConnected() )
+        {
+        iAudioServer->SetPullAudio( aPullAudio );
+        TRAP(ret, iAudioServer->ListenL());
+        }
+    else
+        {
+        ret = KErrNotReady;
+        }
+
+    TRACE_FUNC_EXIT
+
+    return ret;
+
+    }
+
+void CHsCore::StopAudioServer()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iAudioServer )
+        {
+        if ( iAudioServer->IsConnected() )
+            {
+            iAudioServer->Disconnect();
+            }
+        if ( iAudioServer->IsListen() )
+            {
+            iAudioServer->Shutdown();
+            }
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::DestroyAudioServer()
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iAudioServer )
+        {
+        delete iAudioServer;
+        iAudioServer = NULL;
+        }
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsCore::CreateClientManager()
+    {
+    TRACE_FUNC_ENTRY
+    TInt err = KErrNone;
+
+    if ( iHSClientManager )
+        {
+        err = KErrAlreadyExists;
+        }
+    else
+        {
+        TRAP(err, iHSClientManager = CHsClientManager::NewL());
+        }
+    TRACE_FUNC_EXIT
+    return err;
+    }
+
+void CHsCore::DestroyClientManager()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iHSClientManager )
+        {
+        delete iHSClientManager;
+        iHSClientManager = NULL;
+        }
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsCore::CreatePluginManager()
+    {
+    TRACE_FUNC_ENTRY
+    TInt err = KErrNone;
+    if ( iHSProfileManager )
+        {
+        err = KErrAlreadyExists;
+        }
+    else
+        {
+        TRAP(err, iHSProfileManager = CHsProfileManager::NewL());
+        }
+    TRACE_FUNC_EXIT
+    return err;
+    }
+
+void CHsCore::DestroyPluginManager()
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iHSProfileManager )
+        {
+        delete iHSProfileManager;
+        iHSProfileManager = NULL;
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsCore::CreateBTManager()
+    {
+    TRACE_FUNC_ENTRY
+    TInt err = KErrNone;
+
+    if ( !iHsBTManager )
+        {
+        TRAP(err, iHsBTManager = CHsBTManager::NewL(iSocketServ, this));
+        if ( err == KErrNone )
+            {
+            iHsBTManager->SetService( iService );
+            }
+        }
+    else
+        {
+        err = KErrAlreadyExists;
+        }
+
+    TRACE_FUNC_EXIT
+    return err;
+    }
+
+void CHsCore::DestroyBTManager()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iHsBTManager )
+        {
+        delete iHsBTManager;
+        iHsBTManager = NULL;
+        }
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsCore::CreateControlServer()
+    {
+    TRACE_FUNC_ENTRY
+    TInt err = KErrNone;
+    if ( !iHSControlServer )
+        {
+        TRAP(err, iHSControlServer = CHsControlServer::NewL(iSocketServ, this);
+                iHSControlServer->SetConnectionObserver( *this );
+                iHSControlServer->StartRemoteControlServerL());
+        }
+    else
+        {
+        err = KErrAlreadyExists;
+        }
+    TRACE_FUNC_EXIT
+    return err;
+    }
+
+void CHsCore::DestroyControlServer()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iHSControlServer )
+        {
+        delete iHSControlServer;
+        iHSControlServer = NULL;
+        }
+    TRACE_FUNC_EXIT
+
+    }
+
+void CHsCore::SetBTName( const TBTFriendlyName &aBTName )
+    {
+    iBTFriendlyName = aBTName;
+    }
+
+TInt CHsCore::GetLastConnected( TBTDevAddr &aBTDevAddr )
+    {
+    TRACE_FUNC_ENTRY
+    RBuf bufAddr;
+    TInt error = bufAddr.Create( KLastDevAddrLength );
+    if ( KErrNone != error )
+        {
+
+        return error;
+        }
+
+    error = RProperty::Get( KHSProperty, ELastDevice, bufAddr );
+    TRACE_INFO( (_L("Last-connected dev addr: %S"), &bufAddr) )
+    if ( error == KErrNone )
+        {
+        error = aBTDevAddr.SetReadable( bufAddr );
+
+        }
+    bufAddr.Close();
+    TRACE_FUNC_EXIT
+    return error;
+    }
+
+TInt CHsCore::SaveClient( CBluetoothSocket* aSocket )
+    {
+    TRACE_FUNC_ENTRY
+    TInt error = KErrNone;
+    TBTSockAddr sockAddr;
+    aSocket->RemoteName( sockAddr );
+
+    TBTDevAddr devAddr = sockAddr.BTAddr();
+
+    RBuf bufAddr;
+
+    error = bufAddr.Create( KLastDevAddrLength );
+    if ( KErrNone == error )
+        {
+        devAddr.GetReadable( bufAddr );
+        TRACE_INFO( (_L("Read address:: %S"), &bufAddr) );
+        error = RProperty::Set( KHSProperty, ELastDevice, bufAddr );
+        bufAddr.Close();
+        }
+
+    TRACE_FUNC_EXIT
+    return error;
+    }
+
+void CHsCore::SetSdpRecordServicePortFromServer()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iHSServer && iHSProfileManager )
+        {
+        iHSProfileManager->SetSdpServicePort( iHSServer->GetPort() );
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::LoadProfileL( const TDesC8& aProfileName )
+    {
+    TRACE_FUNC_ENTRY
+
+    User::LeaveIfNull( iHSProfileManager );
+    iHSProfileManager->LookupAndManageProfileL( aProfileName );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::LoadProfileL( const TUid& aProfileUid )
+    {
+    TRACE_FUNC_ENTRY
+
+    User::LeaveIfNull( iHSProfileManager );
+    iHSProfileManager->LookupAndManageProfileL( aProfileUid );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::LoadSdpL( const TDesC8& aSdpName )
+    {
+    TRACE_FUNC_ENTRY
+
+    User::LeaveIfNull( iHSProfileManager );
+
+    SetSdpRecordServicePortFromServer();
+    iHSProfileManager->LookupAndManageSdpL( aSdpName );
+    TRACE_INFO(_L("iHSProfileManager lookup and manage SDP success") );
+
+    iHSProfileManager->LoadSdpL();
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::LoadSdpL( const TUid& aSdpUid )
+    {
+    TRACE_FUNC_ENTRY
+    User::LeaveIfNull( iHSProfileManager );
+
+    SetSdpRecordServicePortFromServer();
+    iHSProfileManager->LookupAndManageSdpL( aSdpUid );
+    TRACE_INFO(_L("iHSProfileManager lookup and manage SDP success") );
+
+    iHSProfileManager->LoadSdpL();
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::LoadCodL( const TDesC8& aCoDName )
+    {
+    TRACE_FUNC_ENTRY
+
+    User::LeaveIfNull( iHSProfileManager );
+
+    iHSProfileManager->LookupAndManageCodL( aCoDName );
+    iHSProfileManager->LoadCodL();
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::LoadCodL( const TUid& aCoDUid )
+    {
+    TRACE_FUNC_ENTRY
+
+    User::LeaveIfNull( iHSProfileManager );
+
+    iHSProfileManager->LookupAndManageCodL( aCoDUid );
+    iHSProfileManager->LoadCodL();
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::HandleNewClientL( CBluetoothSocket* aClientSocket, TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( ( KErrNone == aErr ) && ( iHSClientManager ) )
+        {
+        CHsClient *clientTmp = NULL;
+        if ( aClientSocket )
+            {
+            clientTmp = CHsClient::NewL( aClientSocket, this, iHSClientManager );
+
+            //Return value may be ignored
+            SaveClient( aClientSocket );
+            iHSClientManager->HandleNewClientL( clientTmp, aErr );
+
+            TBuf8 <KHsClientBufferLength> tmp;
+
+            iHSProfileManager->HandleClientConnected( tmp );
+            if ( tmp.Compare( KNullDesC8 ) != 0 )
+                {
+                iHSClientManager->Send( tmp, KHsDefaultClientNumber );
+                }
+
+            if ( iObserver )
+                {
+                iObserver->HandleConnectedToClient();
+                }
+            }
+        }
+    else
+        {
+        if ( iHsBTManager )
+            {
+            iHsBTManager->CancelConnecting();
+            }
+        if ( iObserver )
+            {
+            iObserver->HandleUnableToConnectClient();
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::HandleClientConnectL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( (_L("aErr = %d"), aErr))
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::HandleClientDisconnectL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( (_L("aErr = %d"), aErr))
+
+    if ( iObserver )
+        {
+        iObserver->HandleDisconnectedFromClient();
+        }
+    if ( iAudioServer )
+        {
+        iAudioServer->ListenL();
+        }
+    if ( iHSProfileManager )
+        {
+        iHSProfileManager->HandleClientDisconnected( aErr );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::HandleClientReceiveCompleteL( const TDesC8 &aData, TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( (_L("aErr = %d"), aErr))
+
+    if ( iHSProfileManager )
+        {
+        iBufferFromProfileToClient.Zero();
+
+        TRACE_INFO( (_L8(" Received data from AG client [%S]") , &aData) )
+        iHSProfileManager->HandleCommandL( aData, iBufferFromProfileToClient,
+                ETrue );
+
+        if ( iHSClientManager )
+            {
+            iHSClientManager->Send( iBufferFromProfileToClient );
+            }
+        }
+    TRACE_FUNC_EXIT
+    }
+void CHsCore::HandleClientSendCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( (_L("aErr = %d"), aErr))
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::HandleClientOtherProblemL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( (_L("aErr = %d"), aErr))
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::HandleDesiredDeviceFound( const TDesC& /*aDevName*/,
+        const TBTDevAddr& aDevAddr, const TInt aPort )
+    {
+    TRACE_FUNC_ENTRY
+    TBTSockAddr sockaddr;
+    sockaddr.SetBTAddr( aDevAddr );
+    sockaddr.SetPort( aPort );
+    TRAPD(err, iHSServer->GetSocketAndTryToConnectL(sockaddr));
+    if ( err != KErrNone )
+        {
+        TRACE_INFO( (_L("CHsServer::GetSocketAndTryToConnectL() error = %d"), err) )
+        TRAP_IGNORE( HandleNewClientL(NULL, err));
+
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::HandleSdpQueryError( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( (_L("aErr = %d"), aErr))
+    if ( iObserver )
+        {
+        iObserver->HandleUnableToConnectClient();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::HandleServiceNotFound( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( (_L("aErr = %d"), aErr))
+    if ( iObserver )
+        {
+        iObserver->HandleUnableToConnectClient();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::HandlePortNotFound( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( (_L("aErr = %d"), aErr))
+    if ( iObserver )
+        {
+        iObserver->HandleUnableToConnectClient();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::HandleDesiredDeviceNotFound( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( (_L("aErr = %d"), aErr))
+    if ( iObserver )
+        {
+        iObserver->HandleUnableToConnectClient();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::HandleRemoteControllerConnected( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    if ( iObserver && aErr == KErrNone )
+        {
+        iObserver->HandleConnectedToRemoteController();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsCore::HandleRemoteControllerDisconnected( TInt /** aErr */)
+    {
+    TRACE_FUNC_ENTRY
+    if ( iObserver )
+        {
+        iObserver->HandleDisconnectedFromRemoteController();
+        }
+    TRACE_FUNC_EXIT
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/data/E422E38B.rss	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,63 @@
+#include "RegistryInfoV2.rh"
+
+RESOURCE REGISTRY_INFO theInfo
+    {
+
+    resource_format_version = RESOURCE_FORMAT_VERSION_2;
+    
+    dll_uid = 0xE422E38B;
+
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = 0xE0009DC1;
+
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0xE0009DD3;
+                    version_no = 1;
+                    display_name = "HFP implementation";
+                    default_data = "hfp";
+                    opaque_data = "";
+                    }
+                };
+            },
+
+        INTERFACE_INFO
+            {
+            interface_uid = 0xE0009DC2;
+
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0xE0009DD1;
+                    version_no = 1;
+                    display_name = "HFP CoD implementation";
+                    default_data = "hfp_cod";
+                    opaque_data = "";
+                    }
+                };
+            },
+        INTERFACE_INFO
+            {
+            interface_uid = 0xE0009DC3;
+
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0xE0009DD2;
+                    version_no = 1;
+                    display_name = "HFP SDP implementation";
+                    default_data = "hfp_sdp";
+                    opaque_data = "";
+                    }
+                };
+            }
+
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/group/bld.inf	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,23 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+hfpprofileplugin.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/group/hfpprofileplugin.mmp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,73 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+TARGET		  hfpprofileplugin.dll
+TARGETTYPE	  PLUGIN
+UID			  0x10009D8D 0xE422E38B
+
+CAPABILITY CAP_ECOM_PLUGIN
+
+SOURCEPATH ../src
+SOURCE hfpcod.cpp
+SOURCE hfpsdp.cpp
+SOURCE hfpprofile.cpp
+SOURCE hfpsettings.cpp
+SOURCE proxy.cpp
+
+SOURCEPATH ../src/features
+SOURCE hfpfeaturemanager.cpp
+SOURCE hfpconnectionmanagement.cpp
+SOURCE hfpcalltermination.cpp
+SOURCE hfpincomingcallacceptance.cpp
+SOURCE hfpincomingcallrejection.cpp
+SOURCE hfpphonestatusinformation.cpp
+SOURCE hfpremoteaudiovolumecontrol.cpp
+SOURCE hfplastnumberredialing.cpp
+SOURCE hfpphonenumberdialing.cpp
+SOURCE hfpcallinglineidentification.cpp
+
+SOURCEPATH ../src/dataprocessing
+SOURCE hfpdatahandler.cpp
+SOURCE hfpcommand.cpp
+SOURCE hfpcommandparser.cpp
+
+SOURCEPATH ../data
+START RESOURCE E422E38B.rss
+	TARGET hfpprofileplugin.rsc
+	TARGETPATH /resource/plugins
+END
+
+USERINCLUDE ../inc
+USERINCLUDE ../inc/features
+USERINCLUDE ../inc/dataprocessing
+
+SYSTEMINCLUDE   /epoc32/include
+SYSTEMINCLUDE   /epoc32/include/ecom
+SYSTEMINCLUDE	/epoc32/include/headsetsimulator
+SYSTEMINCLUDE	/epoc32/include/platform
+
+LIBRARY euser.lib
+LIBRARY sdpdatabase.lib
+LIBRARY btdevice.lib
+LIBRARY bluetooth.lib
+LIBRARY ecom.lib
+LIBRARY bafl.lib
+
+#ifdef ENABLE_ABIV2_MODE
+DEBUGGABLE_UDEBONLY
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/dataprocessing/hfpcommand.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,283 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HFPCOMMAND_H_
+#define HFPCOMMAND_H_
+
+#include <e32base.h>
+
+/** Profile helpful constants */
+_LIT8(KHsHFPCommandPrefix,"AT");
+_LIT8(KHsHFPCommandSuffix,"\r\n");
+_LIT8(KHsHFPBRSFCommand,"+BRSF");
+_LIT8(KHsHFPCIEVCommand,"+CIEV");
+_LIT8(KHsHFPCHUPCommand,"+CHUP");
+_LIT8(KHsHFPCINDCommand,"+CIND");
+_LIT8(KHsHFPCMERCommand,"+CMER");
+_LIT8(KHsHFPCOPSCommand,"+COPS");
+_LIT8(KHsHFPVGSCommand,"+VGS");
+_LIT8(KHsHFPVGMCommand,"+VGM");
+_LIT8(KHsHFPBLDNCommand,"+BLDN");
+_LIT8(KHsHFPCLIPCommand,"+CLIP");
+_LIT8(KHsHFPOKCommand,"\r\nOK\r\n");
+_LIT8(KHsHFPERRORCommand,"\r\nERROR\r\n");
+_LIT8(KHsHFPRINGCommand,"\r\nRING\r\n");
+_LIT8(KHsHFPATACommand,"ATA");
+_LIT8(KHsHFPATACommandWithoutPrefix,"A");
+_LIT8(KHsHFPATDCommand,"ATD");
+_LIT8(KHsHFPATDCommandWithoutPrefix,"D");
+_LIT8(KHsHFPParamsSeparator,",");
+_LIT8(KHsHFPCommandSeparator,"\r\n\r\n");
+_LIT8(KHsHFPIndicatorParamsSeparator,"),");
+_LIT8(KHsHFPATTestModeDes,"=?");
+_LIT8(KHsHFPATWriteModeDes,"=");
+_LIT8(KHsHFPATReadModeDes,"?");
+_LIT8(KHsHFPATTestModeDesAG,"=?");
+_LIT8(KHsHFPATWriteModeDesAG,": ");
+_LIT8(KHsHFPATReadModeDesAG,"?");
+
+/** Max size of HFP AT param */
+const TInt KHsHFPMaxATParamSize = 256;
+
+/** Max size of VGS or VGM param*/
+const TInt KHsHFPMaxVolumeLevelParamSize = 2;
+
+/**
+ *  @brief Represents singular AT command parameter.
+ */
+class TATParam
+    {
+public:
+
+    /**
+     * Constructor
+     * 
+     * @param aValue param descriptor
+     */
+    TATParam(const TDesC8& aValue);
+
+    /**
+     * Returns the parameter as text.
+     * 
+     * @return the non-modifiable pointer descriptor
+     */
+    const TDesC8& Des() const;
+
+    /**
+     * Returns the paramater as integer value (if conversion is possible)
+     * 
+     * @return integer value
+     */
+    TInt IntL() const;
+
+private:
+    /** Buffer for AT param */
+    TBuf8<KHsHFPMaxATParamSize> iValue;
+    };
+
+/** Array of AT params */
+typedef RArray<TATParam> RATParamArray;
+
+/** HFP AT commands types enum */
+enum THsHFPCommandType
+    {
+    EHFPCmdBRSF,
+    EHFPCmdCIEV,
+    EHFPCmdCHUP,
+    EHFPCmdOK,
+    EHFPCmdERROR,
+    EHFPCmdCIND,
+    EHFPCmdCMER,
+    EHFPCmdCOPS,
+    EHFPCmdRING,
+    EHFPCmdATA,
+    EHFPCmdVGS,
+    EHFPCmdVGM,
+    EHFPCmdBLDN,
+    EHFPCmdATD,
+    EHFPCmdCLIP,
+    EHFPCmdUnknown
+    };
+
+/** HFP AT commands modes enum */
+enum THsHFPCommandMode
+    {
+    /** = */
+    ECmdModeWrite,
+    /** ? */
+    ECmdModeRead,
+    /** =? */
+    ECmdModeTest,
+    /** empty without params */
+    ECmdModeNormal,
+    /** empty with params */
+    ECmdModeOther,
+    /** unknown mode - default */
+    ECmdUnknownMode
+    };
+
+/**
+ *  @brief AT command representation 
+ */
+class CHsHFPCommand : public CBase
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @return class instance
+     */
+    static CHsHFPCommand* NewL();
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @return class instance
+     */
+    static CHsHFPCommand* NewLC();
+
+    /** 
+     * Destructor
+     */
+    ~CHsHFPCommand();
+
+public:
+    /**
+     * Sets type of AT command
+     * 
+     * @param aType type
+     * @return KErrNone if successful, otherwise one of the system-wide error codes
+     */
+    TInt SetType(const THsHFPCommandType aType);
+
+    /**
+     * Sets mode of AT command
+     * 
+     * @param aMode mode
+     * @return KErrNone if successful, otherwise one of the system-wide error codes
+     */
+    TInt SetMode(const THsHFPCommandMode aMode);
+
+    /**
+     * Sets params of AT command
+     * 
+     * @param aParams array of params
+     * @return KErrNone if successful, otherwise one of the system-wide error codes
+     */
+    TInt SetParams(const RATParamArray& aParams);
+
+    /**
+     * Sets flag which denotes if AT command was sent from AG or HF
+     * 
+     * @param aFromAG AT command source
+     */
+    void SetSource(const TBool aFromAG);
+
+    /**
+     * Returns the AT command as text
+     * 
+     * @param aBuf on exit contains command as descriptor
+     */
+    void ToDes8(TDes8& aBuf) const;
+
+    /**
+     * Returns the AT command type
+     * 
+     * @return type of command
+     */
+    THsHFPCommandType Type() const;
+
+    /**
+     * Returns the AT command mode
+     * 
+     * @return mode of command
+     */
+    THsHFPCommandMode Mode() const;
+
+    /**
+     * Returns the AT command source
+     * 
+     * @return flag that denotes if AT command was sent from AG or HF
+     */
+    TBool FromAG() const;
+
+    /**
+     * Returns the AT command params
+     * 
+     * @return array of params
+     */
+    const RATParamArray& Params() const;
+
+    /**
+     * Clones CHsHFPCommand object
+     * 
+     * @param aCmdFrom source
+     * @param aCmdTo destination 
+     */
+    static void CopyL(const CHsHFPCommand& aCmdFrom, CHsHFPCommand& aCmdTo);
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsHFPCommand();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+
+    /** Granulity of AT params array */
+    const TInt KParamArrayGranularity = 3;
+
+    /** Max length of AT type descriptor */
+    const TInt KTypeDesMaxLength = 9;
+
+    /** Max length of AT mode descriptor */
+    const TInt KModeDesMaxLength = 3;
+
+    /** Max length of AT param descriptor */
+    const TInt KParamsDesMaxLength = 200;
+
+    /** Command type */
+    THsHFPCommandType iType;
+
+    /** Command mode */
+    THsHFPCommandMode iMode;
+
+    /** Denotes if AT command was sent from AG or HF */
+    TBool iFromAG;
+
+    /** Array of params */
+    RATParamArray iParams;
+
+    /** Command type as descriptor */
+    RBuf8 iTypeDes;
+
+    /** Command mode as descriptor */
+    RBuf8 iModeDes;
+
+    /** Command params as descriptor */
+    RBuf8 iParamsDes;
+    };
+
+#endif /* HFPCOMMAND_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/dataprocessing/hfpcommandparser.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,108 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HFPCOMMANDPARSER_H_
+#define HFPCOMMANDPARSER_H_
+
+#include <e32base.h>
+
+#include "hfpcommand.h"
+
+/**
+ *  @brief AT command parser 
+ */
+class CHsHFPParser : public CBase
+    {
+public:
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @return class instance
+     */
+    static CHsHFPParser* NewL();
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @return class instance
+     */
+    static CHsHFPParser* NewLC();
+
+    /** 
+     * Destructor
+     */
+    ~CHsHFPParser();
+
+public:
+
+    /**
+     * Parses AT command. Sets type, mode and params.
+     * 
+     * @param aBufCommand AT command as descriptor
+     * @param aFromAG denotes if AT command was sent from AG
+     * @param aCommand on exit command object
+     */
+    void ParseL(const TDesC8 &aBufCommand, const TBool aFromAG,
+            CHsHFPCommand& aCommand);
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsHFPParser();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+    /**
+     * Retrieves command mode
+     * 
+     * @param aCommand AT command as descriptor
+     * @param aFromAG denotes if AT command was sent from AG
+     * 
+     * @return command mode
+     */
+    THsHFPCommandMode RetrieveModeL(const TDesC8 &aCommand,
+            const TBool aFromAG);
+
+    /**
+     * Retrieves command type
+     * 
+     * @param aCommand AT command as descriptor
+     * 
+     * @return command type
+     */
+    THsHFPCommandType RetrieveTypeL(const TDesC8 &aCommand);
+
+    /**
+     * Retrieves command params
+     * 
+     * @param aCommand AT command as descriptor
+     * @param aCmdMode command mode
+     * @param aParams on exit array contains AT params 
+     * 
+     */
+    void RetrieveParamsL(const TDesC8 &aCommand,
+            const THsHFPCommandMode aCmdMode, RATParamArray& aParams);
+
+    };
+
+#endif /* HFPCOMMANDPARSER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/dataprocessing/hfpdatahandler.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,134 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef DATAHANDLER_H_
+#define DATAHANDLER_H_
+
+#include <e32base.h>
+
+class CHsHFPParser;
+class CHsHFPCommand;
+class CHsHFPFeatureManager;
+class CDesC8ArrayFlat;
+
+/**
+ * @brief Manages AT commands handling
+ */
+class CHsHFPDataHandler : public CBase
+    {
+public:
+
+    /**
+     * Two-phase constructor
+     * @return instance of class
+     */
+    static CHsHFPDataHandler* NewL();
+
+    /**
+     * Two-phase constructor
+     * @return instance of class
+     */
+    static CHsHFPDataHandler* NewLC();
+
+    /**
+     * Destructor
+     */
+    ~CHsHFPDataHandler();
+
+public:
+    /**
+     * Profile's method for handling AT Commands
+     * 
+     * @param aDataIn AT command received by HS
+     * @param aFromAG denotes if AT command was sent from AG
+     * @param aDataOut AT response
+     * 
+     */
+    void ProcessDataL(const TDesC8& aDataIn, const TBool aFromAG,
+            TDes8& aDataOut);
+
+    /**
+     * Profile's method for handling AG client disconnection
+     * 
+     * @param aErr disconnection reason
+     */
+    void HandleClientDisconnected(TInt aErr);
+
+    /**
+     * Profile's method for handling AG client connection
+     * 
+     * @param aCommandOut AT response
+     */
+    void HandleClientConnected(TDes8& aCommandOut);
+
+    /**
+     * Profile's method for accepting incoming call
+     * 
+     * @param aCommandOut AT response
+     */
+    void HandleAcceptCallL(TDes8& aCommandOut);
+
+    /**
+     * Profile's method for releasing ongoing call
+     * 
+     * @param aCommandOut AT response
+     */
+    void HandleReleaseCallL(TDes8& aCommandOut);
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsHFPDataHandler();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+    /**
+     * Splits multiple AT commands 
+     * 
+     * @param aCommands 8-bit descriptor containing
+     */
+    CDesC8ArrayFlat* SplitCommandsL(const TDesC8 &aCommands);
+
+    /**
+     * Common funcionality for HandleAcceptCallL() and HandleReleaseCall().
+     * 
+     * @param aCommand input AT command
+     * @param aResponse  AT response
+     */
+    void PerformRequestL(const TDesC8& aCommand, TDes8& aResponse);
+
+private:
+    /** Command array's granularity */
+    const TInt KCommandArrayGranularity = 2;
+    
+    /** Temporary buffer's max length */
+    const TInt KTmpBufferLength = 256;
+    
+    /** AT command parser */
+    CHsHFPParser* iParser;
+
+    /** Feature manager */
+    CHsHFPFeatureManager* iFeatureManager;
+    };
+
+#endif /* DATAHANDLER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/debug.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,192 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HFPPLUGIN_LOGGING_H
+#define HFPPLUGIN_LOGGING_H
+
+#include <e32base.h>
+#include "debugconfig.h"
+
+enum TPanic
+    {
+    EInvalidNullState = 1,
+    };
+
+#ifdef PRJ_ENABLE_TRACE
+
+#ifdef PRJ_FILE_TRACE
+#include <flogger.h>
+#else
+#include <e32debug.h>
+#endif
+
+NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow
+    {
+public:
+    void Overflow(TDes16& /*aDes*/)
+        {
+        }
+    };
+
+NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow
+    {
+public:
+    void Overflow(TDes8& /*aDes*/)
+        {
+        }
+    };
+
+inline void Trace(TRefByValue<const TDesC16> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    RBuf16 theFinalString;
+    theFinalString.Create(KMaxLogLineLength);
+    theFinalString.Append(KTracePrefix16);
+    TOverflowTruncate16 overflow;
+    theFinalString.AppendFormatList(aFmt, list, &overflow);
+    RDebug::Print(theFinalString);
+    theFinalString.Close();
+#endif
+    }
+
+inline void Trace(TRefByValue<const TDesC8> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list, aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    TOverflowTruncate8 overflow;
+    RBuf8 buf8;
+    buf8.Create(KMaxLogLineLength);
+    buf8.Append(KTracePrefix8);
+    buf8.AppendFormatList(aFmt, list, &overflow);
+
+    RBuf16 buf16;
+    buf16.Create(KMaxLogLineLength);
+    buf16.Copy(buf8);
+    TRefByValue<const TDesC> tmpFmt(_L("%S"));
+    RDebug::Print(tmpFmt, &buf16);
+    buf8.Close();
+    buf16.Close();
+#endif
+    }
+
+inline void TracePanic(char* aFile, TInt aLine, TInt aPanicCode,
+        const TDesC& aPanicCategory)
+    {
+    TPtrC8 fullFileName((const TUint8*) aFile);
+    TPtrC8
+            fileName(fullFileName.Ptr() + fullFileName.LocateReverse('\\')
+                    + 1);
+    RBuf8 buf;
+    buf.Create(KMaxLogLineLength);
+    buf.Append(KPanicPrefix8);
+    buf.AppendFormat(_L8("%d at line %d in file %S"), aPanicCode, aLine,
+            &fileName);
+    Trace(buf);
+    buf.Close();
+    User::Panic(aPanicCategory, aPanicCode);
+    }
+
+inline void TraceLeave(char* aFile, TInt aLine, TInt aReason)
+    {
+    TPtrC8 fullFileName((const TUint8*) aFile);
+    TPtrC8
+            fileName(fullFileName.Ptr() + fullFileName.LocateReverse('\\')
+                    + 1);
+    RBuf8 buf;
+    buf.Create(KMaxLogLineLength);
+    buf.Append(KLeavePrefix8);
+    buf.AppendFormat(_L8("%d at line %d in file %S"), aReason, aLine,
+            &fileName);
+    Trace(buf);
+    buf.Close();
+    User::Leave(aReason);
+    }
+
+#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;}
+
+#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;}
+
+#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;}
+
+#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;}
+
+#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;}
+
+#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);}
+
+#define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory)
+
+#define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define LEAVE_IF_NULL(PTR) {if (!PTR) TraceLeave(__FILE__, __LINE__, KErrGeneral);}
+
+#define LEAVE(REASON) {TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define TRACE_STATIC_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}}
+
+#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}}
+
+#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncExitFormat8, &ptr8);}}
+
+#define TRACE_STATIC_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncFormat8, &ptr8);}}
+
+#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncThisFormat8, &ptr8, this);}}
+
+#define RETURN_IF_ERR(ERR) {if(ERR) {TPtrC8 ptr8((TUint8*)__FILE__); Trace(_L8(" RETURN %d at file %S line %d"), ERR, &ptr8, __LINE__); return ERR;}}
+
+#else // PRJ_ENABLE_TRACE not defined
+#define TRACE_INFO(p)
+
+#define TRACE_ERROR(p)
+
+#define TRACE_STATE(p)
+
+#define TRACE_WARNING(p)
+
+#define TRACE_INFO_SEG(p)
+
+#define TRACE_ASSERT(GUARD, CODE)
+
+#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);}
+
+#define LEAVE_IF_ERROR(REASON) {static_cast<void>(User::LeaveIfError(REASON));}
+
+#define LEAVE_IF_NULL(PTR) {static_cast<void>(User::LeaveIfNull(PTR));}
+
+#define LEAVE(REASON) {static_cast<void>(User::Leave(REASON));}
+
+#define TRACE_STATIC_FUNC_ENTRY
+
+#define TRACE_FUNC_ENTRY
+
+#define TRACE_FUNC_EXIT
+
+#define TRACE_STATIC_FUNC
+
+#define TRACE_FUNC
+
+#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;}
+#endif // PRJ_ENABLE_TRACE
+#endif // HFPPLUGIN_LOGGING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/debugconfig.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,57 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HFPPLUGIN_DEBUGCONFIG_H
+#define HFPPLUGIN_DEBUGCONFIG_H
+
+#include "prjconfig.h"
+
+/**
+ * Custom logging variations.
+ */
+#ifdef PRJ_FILE_TRACE
+_LIT(KLogFile,"HFPPLUGIN.txt");
+_LIT(KLogDir,"HeadsetSimulator HFP Profile");
+#endif
+
+#ifdef PRJ_ENABLE_TRACE
+_LIT(KTracePrefix16, "[HFP] ");
+_LIT8(KTracePrefix8, "[HFP] ");
+_LIT8(KFuncFormat8, "><%S");
+_LIT8(KFuncThisFormat8, "><%S, [0x%08X]");
+_LIT8(KFuncEntryFormat8, ">%S");
+_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]");
+_LIT8(KFuncExitFormat8, "<%S");
+
+_LIT8(KPanicPrefix8, "PANIC code ");
+_LIT8(KLeavePrefix8, "LEAVE code ");
+#endif
+
+//needed??
+_LIT(KPanicCategory, "HFPPLUGIN"); // need it also for release 
+
+const TInt KMaxLogLineLength = 512;
+
+#define KPRINTERROR        0x00000001 // Tracing level: error
+#define KPRINTINFO        0x00000002 // Tracing level: function trace
+#define KPRINTSTATE        0x00000004 // Tracing level: state machine info
+#define KPRINTWARNING   0x00000008 // Tracing level: warning
+const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE
+        | KPRINTWARNING;
+
+#endif // HFPPLUGIN_DEBUGCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpcallinglineidentification.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,90 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSHFPCALLINGLINEIDENTIFICATION_H
+#define HSHFPCALLINGLINEIDENTIFICATION_H
+
+#include <e32base.h>
+
+#include "hfpfeaturecommons.h"
+
+class CHsHFPCommand;
+class CHsHFPSettings;
+
+/**
+ * @brief Represents "Calling Line Identification" feature
+ */
+class CHsHFPCallingLineIdentification : public CBase,
+        public MHsHFPProcedureCommons
+    {
+public:
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPCallingLineIdentification* NewL(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPCallingLineIdentification* NewLC(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /** 
+     * Destructor
+     */
+    ~CHsHFPCallingLineIdentification();
+
+public:
+    //Method inherited from MHsHFPProcedureCommons
+    TInt ProcessCommand(const CHsHFPCommand &aInputCmd,
+            CHsHFPCommand &aOutputCmd);
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aObserver feature observer
+     */
+    CHsHFPCallingLineIdentification(MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+    /** Pointer to observer */
+    MHsHFPFeatureProviderObserver* iObserver;
+
+    /** Denotes if OK command is expected */
+    TBool iWaitingForOK;
+
+    /** Profile setting */
+    CHsHFPSettings* iSettings;
+    };
+
+#endif // HSHFPCALLINGLINEIDENTIFICATION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpcalltermination.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,99 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HFPCALLTERMINATEPROC_H_
+#define HFPCALLTERMINATEPROC_H_
+
+#include <e32base.h>
+
+#include "hfpfeaturecommons.h"
+
+class CHsHFPCommand;
+class CHsHFPSettings;
+
+/**
+ * @brief Represents "Terminate a call" feature
+ */
+class CHsHFPCallTerminationProc : public CBase, public MHsHFPProcedureCommons
+    {
+public:
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPCallTerminationProc* NewL(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPCallTerminationProc* NewLC(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /** 
+     * Destructor
+     */
+    ~CHsHFPCallTerminationProc();
+
+public:
+    //Methods inherited from MHsHFPProcedureCommons
+    TInt ProcessCommand(const CHsHFPCommand &aInputCmd,
+            CHsHFPCommand &aOutputCmd);
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aObserver feature observer
+     */
+    CHsHFPCallTerminationProc(MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+    /**
+     * Checks if received CIEV is proper
+     * 
+     * @param aCommand AT command
+     */
+    TBool IsProperCIEV(const CHsHFPCommand* aCommand);
+
+private:
+    /** Pointer to observer */
+    MHsHFPFeatureProviderObserver* iObserver;
+
+    /** Denotes if OK command is expected */
+    TBool iWaitingForOK;
+
+    /** Denotes if CIEV command is expected */
+    TBool iWaitingForCIEV;
+
+    /** Profile setting */
+    CHsHFPSettings* iSettings;
+    };
+
+#endif /* HFPCALLTERMINATEPROC_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpconnectionmanagement.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,137 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HFPCONNECTIONMANAGEMENT_H
+#define HFPCONNECTIONMANAGEMENT_H
+
+#include "hfpfeaturecommons.h"
+
+class CHsHFPSettings;
+
+/**
+ * @brief Represents "Connection management" feature
+ */
+class CHsHFPConnectionManagement : public CBase
+    {
+public:
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPConnectionManagement* NewL(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPConnectionManagement* NewLC(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Destructor.
+     */
+    ~CHsHFPConnectionManagement();
+
+public:
+
+    /**
+     * Establishes service level connection
+     * 
+     * @param aInputCmd input AT command
+     * @param aOutputCmd response
+     * 
+     * @return  KErrNone if successful, otherwise one of the system-wide error
+     * codes
+     */
+    TInt EstablishServiceLevelConnection(const CHsHFPCommand &aInputCmd,
+            CHsHFPCommand &aOutputCmd);
+
+    /**
+     * Handles connection release after AG's disconnection
+     * 
+     * @param aErr reason of connection release
+     */
+    void HandleServiceLevelConnectionRelease(TInt aErr);
+
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aObserver feature observer
+     */
+    CHsHFPConnectionManagement(MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+    /**
+     * Initializes settings array by retrieving the mapping between each 
+     * indicator supported by the AG and its corresponding order index.
+     * 
+     * @param aCommand AT command
+     */
+    void InitializeIndicatorsL(const CHsHFPCommand* aCommand);
+
+    /**
+     * Saves current status of the AG indicators.
+     * 
+     * @param aCommand input AT command
+     */
+    void SetupIndicatorsL(const CHsHFPCommand* aCommand);
+
+private:
+
+    /**
+     * Service level connection establishment state
+     */
+    enum THsHFPServiceLevelEstablishmentState
+        {
+        EHFPNotConnected,
+        EHFPWaitingForBrsfAndOk,
+        EHFPWaitingForCindTestAndOk,
+        EHFPWaitingForCindReadAndOk,
+        EHFPWaitingForOk,
+        EHFPConnected
+        };
+
+    /** Current state of connection establishment */
+    THsHFPServiceLevelEstablishmentState iEstablishmentState;
+
+    /** Pointer to observer */
+    MHsHFPFeatureProviderObserver* iObserver;
+
+    /** Denotes if OK command is expected */
+    TBool iWaitingForOK;
+
+    /** Profile setting */
+    CHsHFPSettings* iSettings;
+    };
+
+#endif // HFPCONNECTIONMANAGEMENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpfeaturecommons.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,60 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef FEATUREPROVIDERBASE_H_
+#define FEATUREPROVIDERBASE_H_
+
+#include <e32base.h>
+
+class CHsHFPCommand;
+
+/**
+ * @brief Observer of feature's class
+ */
+class MHsHFPFeatureProviderObserver
+    {
+public:
+    /**
+     * Callback method indicates that procedure is finished
+     * 
+     * @param aErr KErrNone if procedure finishes successfully, 
+     * otherwise one of the system-wide error codes
+     */
+    virtual void HandleProcedureCompleted(TInt aErr) = 0
+    };
+
+/**
+ * @brief Abstract class for particular features 
+ */
+class MHsHFPProcedureCommons
+    {
+public:
+    /**
+     * Processes AT command and prepares response
+     * 
+     * @param aInputCmd input AT command
+     * @param aOutputCmd response
+     * 
+     * @return KErrNone if successful, otherwise one of the system-wide error
+     * codes
+     */
+    virtual TInt ProcessCommand(const CHsHFPCommand &aInputCmd,
+            CHsHFPCommand &aOutputCmd) = 0;
+    };
+
+#endif /* FEATUREPROVIDERBASE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpfeaturemanager.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,172 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HFFEATUREMANAGER_H_
+#define HFFEATUREMANAGER_H_
+
+#include "hfpfeaturecommons.h"
+#include "hfpsettings.h"
+
+class CHsHFPCommand;
+class CHsHFPConnectionManagement;
+class CHsHFPCallTerminationProc;
+class CHsHFPIncomingCallAcceptance;
+class CHsHFPIncomingCallRejection;
+class CHsHFPPhoneStatusInformation;
+class CHsHFPRemoteAudioVolumeControl;
+class CHsHFPLastNumberRedialing;
+class CHsHFPPhoneNumberDialing;
+class CHsHFPCallingLineIdentification;
+
+/**
+ * @brief Manages features supported by profile.
+ * 
+ * Delegates data handling to appropriate procedure and holds current state.
+ */
+class CHsHFPFeatureManager : public CBase,
+        public MHsHFPFeatureProviderObserver
+    {
+public:
+    /**
+     * Two-phased constructor.
+     * 
+     * @return instance of class
+     */
+    static CHsHFPFeatureManager* NewL();
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @return instance of class
+     */
+    static CHsHFPFeatureManager* NewLC();
+
+    /** 
+     * Destructor
+     */
+    ~CHsHFPFeatureManager();
+
+public:
+    /**
+     * Decides which feature's procedure should be started.
+     * 
+     * @param aATCommandIn input AT command
+     * @param aATCommandOut response
+     */
+    void PerformDataProcessingL(const CHsHFPCommand* aATCommandIn,
+            CHsHFPCommand& aATCommandOut);
+
+    /**
+     * Handles AG client disconnection event
+     * 
+     * @param aErr disconnection reason
+     */
+    void HandleClientDisconnected(TInt aErr);
+
+    /**
+     * Handles AG client connection event
+     * 
+     * @param aCommandOut AT response
+     */
+    void HandleClientConnectedL(TDes8& aCommandOut);
+
+public:
+    //Method inherited from MHsHFPFeatureProviderObserver
+    void HandleProcedureCompleted(TInt aErr);
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsHFPFeatureManager();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+    /**
+     * Handles OK command.
+     * 
+     * @param aATCommandIn input AT command
+     * @param aATCommandOut response
+     */
+    void HandleOKCommandL(const CHsHFPCommand* aATCommandIn,
+            CHsHFPCommand& aATCommandOut);
+
+    /**
+     * Handles CIEV command and saves current value of appropriate indicator.
+     * 
+     * @param aATCommandIn input AT command
+     * @param aATCommandOut response
+     */
+    void HandleCIEVCommandL(const CHsHFPCommand* aATCommandIn,
+            CHsHFPCommand& aATCommandOut);
+
+private:
+    /** HFP procedures */
+    enum THFPProcedures
+        {
+        EHFPServiceLevelConnectionEstablishment,
+        EHFPServiceLevelConnectionRelease,
+        EHFPCallTerminate,
+        EHFPCallAccept,
+        EHFPCallReject,
+        EHFPOperatorSelection,
+        EHFPVolumeControl,
+        EHFPLastNumberRedialing,
+        EHFPPhoneNumberDialing,
+        EHFPCallingLineIdentification,
+        EHFPIdle
+        };
+
+    /** Ongoing procedure */
+    THFPProcedures iProcedureStarted;
+
+    /** Denotes if service level connection is established */
+    TBool iSrvLvlConnEstablished;
+
+    /** Connection managment feature */
+    CHsHFPConnectionManagement* iConnectionManagement;
+
+    /** Terminate a call feature */
+    CHsHFPCallTerminationProc* iCallTermProc;
+
+    /** Accept an incoming voice call feature */
+    CHsHFPIncomingCallAcceptance* iCallAcceptProc;
+
+    /** Reject an incoming voice call feature */
+    CHsHFPIncomingCallRejection* iCallRejectProc;
+
+    /** Phone status information feature */
+    CHsHFPPhoneStatusInformation* iPhoneStatus;
+
+    /** Remote audio volume control feature */
+    CHsHFPRemoteAudioVolumeControl* iVolumeControl;
+
+    /** Place a call to the last number dialed feature */
+    CHsHFPLastNumberRedialing* iLastNumberRedialing;
+
+    /** Place a call with a phone number supplied by the HF feature */
+    CHsHFPPhoneNumberDialing* iPhoneNumberDialing;
+
+    /** Calling Line Identification feature */
+    CHsHFPCallingLineIdentification* iCallingLineIdentification;
+    };
+
+#endif /* HFFEATUREMANAGER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpincomingcallacceptance.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,110 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HFPINCOMINGCALLACCEPTANCE_H
+#define HFPINCOMINGCALLACCEPTANCE_H
+
+#include <e32base.h>
+
+#include "hfpfeaturecommons.h"
+
+class CHsHFPCommand;
+class CHsHFPSettings;
+
+/**
+ * @brief Represents "Accept an incoming voice call" feature
+ */
+class CHsHFPIncomingCallAcceptance : public CBase,
+        public MHsHFPProcedureCommons
+    {
+public:
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPIncomingCallAcceptance* NewL(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPIncomingCallAcceptance* NewLC(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Destructor.
+     */
+    ~CHsHFPIncomingCallAcceptance();
+
+public:
+    //Method inherited from MHsHFPProcedureCommons
+    TInt ProcessCommand(const CHsHFPCommand &aInputCmd,
+            CHsHFPCommand &aOutputCmd);
+
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aObserver feature observer
+     */
+    CHsHFPIncomingCallAcceptance(MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+    /**
+     * Checks if received CIEV is proper
+     * 
+     * @param aCommand AT command
+     * @param aIndicatorDes expected indicator kind
+     * @param aIndicatorValue expected indicator value
+     */
+    TBool IsProperCIEV(const CHsHFPCommand* aCommand,
+            const TDesC8& aIndicatorDes, const TInt aIndicatorValue);
+
+private:
+    /** Pointer to observer */
+    MHsHFPFeatureProviderObserver* iObserver;
+
+    /** Denotes if OK command is expected */
+    TBool iWaitingForOK;
+
+    /** Denotes if ATA command is expected */
+    TBool iWaitingForATA;
+
+    /** Denotes if CIEV with call indicator command is expected */
+    TBool iWaitingForCIEVCall1;
+
+    /** Denotes if CIEV with callsetup indicator command is expected */
+    TBool iWaitingForCIEVCallsetup0;
+
+    /** Profile setting */
+    CHsHFPSettings* iSettings;
+    };
+
+#endif // HFPINCOMINGCALLACCEPTANCE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpincomingcallrejection.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,102 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSHFPINCOMINGCALLREJECTION_H
+#define HSHFPINCOMINGCALLREJECTION_H
+
+#include <e32base.h>
+
+#include "hfpfeaturecommons.h"
+
+class CHsHFPCommand;
+class CHsHFPSettings;
+
+/**
+ * @brief Represents "Reject an incoming voice call" feature
+ */
+class CHsHFPIncomingCallRejection : public CBase,
+        public MHsHFPProcedureCommons
+    {
+public:
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPIncomingCallRejection* NewL(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPIncomingCallRejection* NewLC(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Destructor.
+     */
+    ~CHsHFPIncomingCallRejection();
+
+public:
+    //Method inherited from MHsHFPProcedureCommons
+    TInt ProcessCommand(const CHsHFPCommand &aInputCmd,
+            CHsHFPCommand &aOutputCmd);
+
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aObserver feature observer
+     */
+    CHsHFPIncomingCallRejection(MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+    /**
+     * Checks if received CIEV is proper
+     * 
+     * @param aCommand AT command
+     */
+    TBool IsProperCIEV(const CHsHFPCommand* aCommand);
+
+private:
+    /** Pointer to observer */
+    MHsHFPFeatureProviderObserver* iObserver;
+
+    /** Denotes if OK command is expected */
+    TBool iWaitingForOK;
+
+    /** Denotes if CIEV command is expected */
+    TBool iWaitingForCIEV;
+
+    /** Profile setting */
+    CHsHFPSettings* iSettings;
+    };
+
+#endif // HSHFPINCOMINGCALLREJECTION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfplastnumberredialing.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,101 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSHFPLASTNUMBERREDIALING_H
+#define HSHFPLASTNUMBERREDIALING_H
+
+#include <e32base.h>
+
+#include "hfpfeaturecommons.h"
+
+class CHsHFPCommand;
+class CHsHFPSettings;
+
+/**
+ * @brief Represents "Place a call to the last number dialed" feature
+ */
+class CHsHFPLastNumberRedialing : public CBase, public MHsHFPProcedureCommons
+    {
+public:
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPLastNumberRedialing* NewL(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPLastNumberRedialing* NewLC(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Destructor.
+     */
+    ~CHsHFPLastNumberRedialing();
+
+public:
+    //Method inherited from MHsHFPProcedureCommons
+    TInt ProcessCommand(const CHsHFPCommand &aInputCmd,
+            CHsHFPCommand &aOutputCmd);
+
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aObserver feature observer
+     */
+    CHsHFPLastNumberRedialing(MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+    /**
+     * Checks if received CIEV is proper
+     * 
+     * @param aCommand AT command
+     */
+    TBool IsProperCIEV(const CHsHFPCommand* aCommand);
+
+private:
+    /** Pointer to observer */
+    MHsHFPFeatureProviderObserver* iObserver;
+
+    /** Denotes if OK command is expected */
+    TBool iWaitingForOK;
+
+    /** Denotes if CIEV command is expected */
+    TBool iWaitingForCIEV;
+
+    /** Profile setting */
+    CHsHFPSettings* iSettings;
+    };
+
+#endif // HSHFPLASTNUMBERREDIALING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpphonenumberdialing.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,101 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSHFPPHONENUMBERDIALING_H
+#define HSHFPPHONENUMBERDIALING_H
+
+#include <e32base.h>
+
+#include "hfpfeaturecommons.h"
+
+class CHsHFPCommand;
+class CHsHFPSettings;
+
+/**
+ * @brief Represents "Place a call with a phone number supplied by the HF" feature
+ */
+class CHsHFPPhoneNumberDialing : public CBase, public MHsHFPProcedureCommons
+    {
+public:
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPPhoneNumberDialing* NewL(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPPhoneNumberDialing* NewLC(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Destructor.
+     */
+    ~CHsHFPPhoneNumberDialing();
+
+public:
+    //Method inherited from MHsHFPProcedureCommons
+    TInt ProcessCommand(const CHsHFPCommand &aInputCmd,
+            CHsHFPCommand &aOutputCmd);
+
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aObserver feature observer
+     */
+    CHsHFPPhoneNumberDialing(MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+    /**
+     * Checks if received CIEV is proper
+     * 
+     * @param aCommand AT command
+     */
+    TBool IsProperCIEV(const CHsHFPCommand* aCommand);
+
+private:
+    /** Pointer to observer */
+    MHsHFPFeatureProviderObserver* iObserver;
+
+    /** Denotes if OK command is expected */
+    TBool iWaitingForOK;
+
+    /** Denotes if CIEV command is expected */
+    TBool iWaitingForCIEV;
+
+    /** Profile setting */
+    CHsHFPSettings* iSettings;
+    };
+
+#endif // HSHFPPHONENUMBERDIALING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpphonestatusinformation.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,160 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSHFPPHONESTATUSINFORMATION_H
+#define HSHFPPHONESTATUSINFORMATION_H
+
+#include <e32base.h>
+
+#include "hfpfeaturecommons.h"
+
+class CHsHFPCommand;
+class CHsHFPSettings;
+
+/**
+ * @brief Represents "Phone status information" feature
+ */
+class CHsHFPPhoneStatusInformation : public CBase,
+        public MHsHFPProcedureCommons
+    {
+public:
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPPhoneStatusInformation* NewL(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPPhoneStatusInformation* NewLC(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Destructor.
+     */
+    ~CHsHFPPhoneStatusInformation();
+
+public:
+    //Method inherited from MHsHFPProcedureCommons
+    TInt ProcessCommand(const CHsHFPCommand &aInputCmd,
+            CHsHFPCommand &aOutputCmd);
+
+    /**
+     * Informs about call status
+     * 
+     * @return ETrue if call is ongoing, EFalse otherwise
+     */
+    TBool IsCallOngoing();
+
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aObserver feature observer
+     */
+    CHsHFPPhoneStatusInformation(MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+
+    /**
+     * Checks indicator and decides which particular handler should be invoked
+     * 
+     * @param aCommand CIEV command
+     */
+    void HandleIndicatorL(const CHsHFPCommand* aCommand);
+    
+    /**
+     * Handles call indicator 
+     * 
+     * @param aCommand CIEV command
+     */
+    void HandleCallIndicatorL(const CHsHFPCommand* aCommand);
+
+    /**
+     * Handles service indicator 
+     * 
+     * @param aCommand CIEV command
+     */
+    void HandleServiceIndicatorL(const CHsHFPCommand* aCommand);
+
+    /**
+     * Handles callsetup indicator 
+     * 
+     * @param aCommand CIEV command
+     */
+    void HandleCallsetupIndicatorL(const CHsHFPCommand* aCommand);
+
+    /**
+     * Handles callheld indicator 
+     * 
+     * @param aCommand CIEV command
+     */
+    void HandleCallheldIndicatorL(const CHsHFPCommand* aCommand);
+
+    /**
+     * Handles signal indicator 
+     * 
+     * @param aCommand CIEV command
+     */
+    void HandleSignalIndicatorL(const CHsHFPCommand* aCommand);
+
+    /**
+     * Handles roam indicator 
+     * 
+     * @param aCommand CIEV command
+     */
+    void HandleRoamingIndicatorL(const CHsHFPCommand* aCommand);
+
+    /**
+     * Handles battery charge indicator 
+     * 
+     * @param aCommand CIEV command
+     */
+    void HandleBatteryIndicatorL(const CHsHFPCommand* aCommand);
+
+private:
+    /** Pointer to observer */
+    MHsHFPFeatureProviderObserver* iObserver;
+
+    /** Denotes if OK command is expected */
+    TBool iWaitingForOK;
+
+    /** Denotes if COPS command is expected */
+    TBool iWaitingForCOPSFromAG;
+
+    /** Profile setting */
+    CHsHFPSettings* iSettings;
+    };
+
+#endif // HSHFPPHONESTATUSINFORMATION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/features/hfpremoteaudiovolumecontrol.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,117 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSHFPREMOTEAUDIOVOLUMECONTROL_H
+#define HSHFPREMOTEAUDIOVOLUMECONTROL_H
+
+#include <e32base.h>
+
+#include "hfpfeaturecommons.h"
+
+class CHsHFPCommand;
+class CHsHFPSettings;
+
+/**
+ * @brief Represents "Remote audio volume control" feature
+ */
+class CHsHFPRemoteAudioVolumeControl : public CBase,
+        public MHsHFPProcedureCommons
+    {
+public:
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPRemoteAudioVolumeControl* NewL(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHFPRemoteAudioVolumeControl* NewLC(
+            MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Destructor.
+     */
+    ~CHsHFPRemoteAudioVolumeControl();
+
+public:
+
+    /**
+     * Synchronizes volume levels in AG and HF
+     * 
+     * @param aInputCmd input AT command
+     * @param aOutputCmd response
+     * 
+     * @return KErrNone if successful, otherwise one of the system-wide error
+     * codes
+     */
+    TInt VolumeLevelSynchronization(const CHsHFPCommand &aInputCmd,
+            CHsHFPCommand &aOutputCmd);
+
+    /**
+     * Resets local setting after client disconnection
+     */
+    void Reset();
+
+public:
+    //Method inherited from MHsHFPProcedureCommons
+    TInt ProcessCommand(const CHsHFPCommand &aInputCmd,
+            CHsHFPCommand &aOutputCmd);
+
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aObserver feature observer
+     */
+    CHsHFPRemoteAudioVolumeControl(MHsHFPFeatureProviderObserver* aObserver);
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+    /** Pointer to observer */
+    MHsHFPFeatureProviderObserver* iObserver;
+
+    /** Denotes if volume level synchronization is finished */
+    TBool iVolumeLevelSynchronized;
+
+    /** Denotes if OK command is expected */
+    TBool iWaitingForOK;
+
+    /** Denotes if VGM command is expected */
+    TBool iWaitingForVgmOK;
+
+    /** Profile setting */
+    CHsHFPSettings* iSettings;
+    };
+
+#endif // HSHFPREMOTEAUDIOVOLUMECONTROL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/hfpcod.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,69 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HFPCOD_H_
+#define HFPCOD_H_
+
+#include <hscodpluginbase.h>
+
+/** HFP Class of Device */
+const TUint32 KHsHFPDeviceClass = 0x200408;
+
+/**
+ * @brief Manages Class of Device.
+ */
+class CHsHFPCoD : public CHsCoDBase
+    {
+public:
+    /**
+     * Two-phase constructor
+     * 
+     * @return instance of class
+     */
+    static CHsHFPCoD* NewL();
+
+    /**
+     * Two-phase constructor
+     * 
+     * @return instance of class
+     */
+    static CHsHFPCoD* NewLC();
+
+    /**
+     * Destructor
+     */
+    ~CHsHFPCoD();
+
+    /**
+     * Sets new Class of Device
+     */
+    void SetNewCodL();
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsHFPCoD();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+    };
+
+#endif /* HFPCOD_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/hfpprofileplugin.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,92 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HFPPROFILEPLUGIN_H
+#define HFPPROFILEPLUGIN_H
+
+#include <e32base.h>	
+#include <e32std.h>
+#include <hsprofilepluginbase.h>
+
+class CHsHFPSettings;
+class CHsHFPDataHandler;
+
+//  Constants
+/** HFP Ecom implementation Uid */
+const TUid KHsHFPProfileImplementationUid =
+    {
+    0xE0009DD3
+    };
+
+/**
+ * @brief Implementation of Hands-Free Profile
+ */
+class CHsHFPProfile : public CHsProfileBase
+    {
+public:
+    /**
+     * Two-phase constructor
+     * @return instance of class
+     */
+    static CHsHFPProfile* NewL();
+
+    /**
+     * Two-phase constructor
+     * @return instance of class
+     */
+    static CHsHFPProfile* NewLC();
+
+    /**
+     * Destructor
+     */
+    ~CHsHFPProfile();
+
+public:
+
+    // Methods derived from MHsProfileBase
+    void HandleCommandL(const TDesC8 &aCommandsIn, TDes8 &aCommandsOut,
+            const TBool aFromAG = ETrue);
+
+    void HandleClientDisconnected(TInt aErr);
+
+    void HandleClientConnected(TDes8& aCommandOut);
+
+    void HandleAcceptCallL(TDes8& aCommandOut);
+
+    void HandleReleaseCallL(TDes8& aCommandOut);
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsHFPProfile();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ContructL();
+
+private:
+    /** AT command handler. Owned */
+    CHsHFPDataHandler* iDataHandler;
+
+    /** HFP setting. Not owned */
+    CHsHFPSettings* iSettings;
+    };
+
+#endif  // HFPPROFILEPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/hfpsdp.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,101 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HFPSDP_H_
+#define HFPSDP_H_
+
+#include <btsdp.h>
+#include <hssdppluginbase.h>
+
+/** Hand-Free Uid */
+const TInt KHsHandsFreeUid = 0x111E;
+
+/** Generic Audio Uid */
+const TInt KHsHfpGenericAudioUid = 0x1203;
+
+/** HFP profile version */
+const TInt KHsHfpProfileVersion = 0x0105;
+
+/** HFP supported features Uid */
+const TInt KHsSupportedFeaturesUid = 0x0311;
+
+/** HFP supported features value */
+const TInt KHsSupportedFeaturesValue = 0x0010;
+/** Service name */
+_LIT(KHsServiceNameHandsFree, "Hands-Free unit");
+
+/**
+ * @brief Manages SDP record
+ */
+class CHsHFPSDP : public CHsSdpBase
+    {
+public:
+    /**
+     * Two-phase constructor
+     * 
+     * @return instance of class
+     */
+    static CHsHFPSDP* NewL();
+
+    /**
+     * Two-phase constructor
+     * 
+     * @return instance of class
+     */
+    static CHsHFPSDP* NewLC();
+
+    /**
+     * Destructor
+     */
+    ~CHsHFPSDP();
+
+public:
+    /**
+     * Creates SDP record
+     */
+    void CreateSdpRecordL();
+
+    /**
+     * Deletes SDP record
+     */
+    void DeleteSdpRecordL();
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsHFPSDP();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+
+    /** Session to the SDP */
+    RSdp iSdp;
+
+    /** Subsession to the SDP */
+    RSdpDatabase iSdpDatabase;
+
+    /** Handle to SDP record which is registered in SDP database */
+    TSdpServRecordHandle iSdpRecordHandle;
+    };
+
+#endif /* HFPSDP_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/hfpsettings.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,150 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HFPSETTINGS_H_
+#define HFPSETTINGS_H_
+
+#include <e32base.h>
+
+class CHsHFPCommand;
+
+/** HF supported features value */
+const TInt32 KHsHFPBluetoothSupportedFeatures = 112;
+
+/** Max size of indicator descriptor */
+const TInt KHsHFPMaxIndicatorDescSize = 16;
+
+/** Indicator descriptor buffer */
+typedef TBuf8<KHsHFPMaxIndicatorDescSize> THFPIndicatorDes;
+/** Expected indicators' descriptors */
+_LIT8(KHFPCallIndicatorDes,"call");
+_LIT8(KHFPServiceIndicatorDes,"service");
+_LIT8(KHFPCallsetupIndicatorDes,"callsetup");
+_LIT8(KHFPCall_setupIndicatorDes,"call_setup");
+_LIT8(KHFPCallheldIndicatorDes,"callheld");
+_LIT8(KHFPSignalIndicatorDes,"signal");
+_LIT8(KHFPRoamIndicatorDes,"roam");
+_LIT8(KHFPBattchgIndicatorDes,"battchg");
+
+/**
+ * @brief CIEV indicator structure
+ */
+class THsHFPIndicatorSetting
+    {
+public:
+    /**
+     * Constructor
+     * 
+     * @param aDes descriptor of indicator
+     * @param aValue value of indicator
+     */
+    THsHFPIndicatorSetting(const TDesC8& aDes, const TInt aValue = 0);
+
+    /**
+     * Sets value of indicator
+     * 
+     * @param aDesValue new value of indicator as descriptor
+     */
+    void SetValueL(const TDesC8& aDesValue);
+
+    /**
+     * Sets value of indicator
+     * 
+     * @param aValue new value of indicator as number
+     */
+    void SetValue(const TInt aValue);
+
+    /**
+     * Returns CIEV indicator's current value
+     * 
+     * @return value of indicator
+     */
+    TInt Int() const;
+
+    /**
+     * Returns CIEV indicator's descriptor
+     * 
+     * @return reference to descriptor
+     */
+    const THFPIndicatorDes& Des() const;
+
+private:
+    /** CIEV indicator's descriptor */
+    THFPIndicatorDes iDesc;
+
+    /** CIEV indicator's current value */
+    TInt iValue;
+    };
+
+/**
+ * @brief Singleton class representing profile's settings
+ */
+class CHsHFPSettings : public CBase
+    {
+public:
+    /**
+     * Returns pointer to singleton class
+     */
+    static CHsHFPSettings* InstanceL();
+
+    /**
+     * Decrements reference counter. Deletes singleton if there is no reference.
+     */
+    void Release();
+
+    /**
+     * Finds index of settings array applicable for indicator
+     * 
+     * @param aIndicatorDes CIEV indicator's descriptor
+     * 
+     * @return index of array, KErrNotFound when there is no suitable value 
+     * in array 
+     */
+    TInt FindIndicatorIndex(const TDesC8& aIndicatorDes);
+
+private:
+    /**
+     * Destructor
+     */
+    ~CHsHFPSettings();
+
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsHFPSettings();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+public:
+    /** CIEV indicators' array */
+    RArray<THsHFPIndicatorSetting> iSettingsArr;
+
+    /** VGS current value */
+    TInt iVgsLevel;
+
+    /** VGM current value */
+    TInt iVgmLevel;
+
+private:
+    /** Reference counter */
+    TInt iReferenceCounter;
+    };
+#endif /* HFPSETTINGS_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/inc/prjconfig.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,46 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HFPPLUGIN_PRJCONFIG_H
+#define HFPPLUGIN_PRJCONFIG_H
+
+/**
+ * Traces are enabled in _DEBUG build, by default.
+ */
+#ifdef _DEBUG
+#define PRJ_ENABLE_TRACE
+#endif
+
+/**
+ * traces to file if this is defined.
+ */
+//#define PRJ_FILE_TRACE
+
+
+/**
+ * build the project for module test purpose if this is defined
+ */
+//#define PRJ_MODULETEST_BUILD
+
+/**
+ * build the project using stubs to replace the dependencies if this is defined
+ */
+//#define PRJ_USE_STUB
+
+
+#endif // HFPPLUGIN_PRJCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/sis/hfpprofileplugin.pkg	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,29 @@
+;
+; Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of the License "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Original Contributors:
+; Comarch S.A. - original contribution.
+;
+; Contributors:
+;
+; Description:
+;
+
+; UID is the dll's UID
+;
+#{"hfpprofileplugin DLL"},(0xE422E38B),1,0,0
+
+
+;Localised Vendor name
+%{"Vendor-EN"}
+
+;Unique Vendor name
+:"Vendor"
+
+"\epoc32\release\armv5\udeb\hfpprofileplugin.dll"		  			  -"!:\sys\bin\hfpprofileplugin.dll"
+"\epoc32\data\Z\Resource\plugins\hfpprofileplugin.rsc"  	  		  -"!:\Resource\Plugins\hfpprofileplugin.rsc"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/dataprocessing/hfpcommand.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,273 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include <badesca.h>
+
+#include "hfpcommand.h"
+#include "debug.h"
+
+TATParam::TATParam( const TDesC8& aValue )
+    {
+    if ( aValue.Length() <= KHsHFPMaxATParamSize )
+        {
+        iValue.Copy( aValue );
+        }
+    }
+
+const TDesC8& TATParam::Des() const
+    {
+    return iValue;
+    }
+
+TInt TATParam::IntL() const
+    {
+    TRACE_FUNC_ENTRY
+    TLex8 lex( iValue );
+    TInt res = KErrNotFound;
+    User::LeaveIfError( lex.Val( res ) );
+
+    TRACE_FUNC_EXIT
+    return res;
+
+    }
+
+CHsHFPCommand* CHsHFPCommand::NewL()
+    {
+    CHsHFPCommand *self = CHsHFPCommand::NewLC();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+CHsHFPCommand* CHsHFPCommand::NewLC()
+    {
+
+    CHsHFPCommand *self = new ( ELeave ) CHsHFPCommand();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHFPCommand::~CHsHFPCommand()
+    {
+    TRACE_FUNC_ENTRY
+    iParams.Close();
+    iModeDes.Close();
+    iParamsDes.Close();
+    iTypeDes.Close();
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsHFPCommand::SetType( const THsHFPCommandType aType )
+    {
+    TRACE_FUNC_ENTRY
+    iType = aType;
+
+    switch ( iType )
+        {
+        case EHFPCmdOK:
+            iTypeDes.Copy( KHsHFPOKCommand );
+            break;
+        case EHFPCmdERROR:
+            iTypeDes.Copy( KHsHFPERRORCommand );
+            break;
+        case EHFPCmdBRSF:
+            iTypeDes.Copy( KHsHFPBRSFCommand );
+            break;
+        case EHFPCmdCIND:
+            iTypeDes.Copy( KHsHFPCINDCommand );
+            break;
+        case EHFPCmdCMER:
+            iTypeDes.Copy( KHsHFPCMERCommand );
+            break;
+        case EHFPCmdCIEV:
+            iTypeDes.Copy( KHsHFPCIEVCommand );
+            break;
+        case EHFPCmdCHUP:
+            iTypeDes.Copy( KHsHFPCHUPCommand );
+            break;
+        case EHFPCmdCOPS:
+            iTypeDes.Copy( KHsHFPCOPSCommand );
+            break;
+        case EHFPCmdRING:
+            iTypeDes.Copy( KHsHFPRINGCommand );
+            break;
+        case EHFPCmdATA:
+            iTypeDes.Copy( KHsHFPATACommandWithoutPrefix );
+            break;
+        case EHFPCmdVGS:
+            iTypeDes.Copy( KHsHFPVGSCommand );
+            break;
+        case EHFPCmdVGM:
+            iTypeDes.Copy( KHsHFPVGMCommand );
+            break;
+        case EHFPCmdBLDN:
+            iTypeDes.Copy( KHsHFPBLDNCommand );
+            break;
+        case EHFPCmdATD:
+            iTypeDes.Copy( KHsHFPATDCommandWithoutPrefix );
+            break;
+        case EHFPCmdCLIP:
+            iTypeDes.Copy( KHsHFPCLIPCommand );
+            break;
+        default:
+            TRACE_FUNC_EXIT
+            return KErrArgument;
+        }
+    TRACE_FUNC_EXIT
+    return KErrNone;
+    }
+
+TInt CHsHFPCommand::SetMode( const THsHFPCommandMode aMode )
+    {
+    TRACE_FUNC_ENTRY
+    iMode = aMode;
+    switch ( iMode )
+        {
+        case ECmdModeRead:
+            iModeDes.Copy( KHsHFPATReadModeDes );
+            break;
+        case ECmdModeWrite:
+            iModeDes.Copy( KHsHFPATWriteModeDes );
+            break;
+        case ECmdModeTest:
+            iModeDes.Copy( KHsHFPATTestModeDes );
+            break;
+        case ECmdModeNormal:
+            iModeDes.Copy( KNullDesC8 );
+            break;
+        case ECmdModeOther:
+            iModeDes.Copy( KNullDesC8 );
+            break;
+        default:
+            TRACE_FUNC_EXIT
+            return KErrArgument;
+        }
+    TRACE_FUNC_EXIT
+    return KErrNone;
+    }
+
+TInt CHsHFPCommand::SetParams( const RATParamArray& aParams )
+    {
+    TRACE_FUNC_ENTRY
+    TInt res = KErrNone;
+    
+    if ( aParams.Count() > 0 )
+        {
+        iParams.Reset();
+        iParams = aParams;
+        iParamsDes.Zero();
+
+        for ( TInt i = 0; i < iParams.Count() - 1; i++ )
+            {
+            iParamsDes.Append( iParams[i].Des() );
+            iParamsDes.Append( KHsHFPParamsSeparator );
+            }
+
+        iParamsDes.Append( iParams[iParams.Count() - 1].Des() );
+        }
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+void CHsHFPCommand::SetSource( const TBool aFromAG )
+    {
+    iFromAG = aFromAG;
+    }
+
+void CHsHFPCommand::ToDes8( TDes8& aBuf ) const
+    {
+    TRACE_FUNC_ENTRY
+    if ( iMode == ECmdModeNormal )
+        {
+        aBuf.Copy( KHsHFPCommandPrefix );
+        aBuf.Append( iTypeDes );
+        aBuf.Append( KHsHFPCommandSuffix );
+        }
+
+    else if ( iType != EHFPCmdUnknown )
+        {
+        aBuf.Copy( KHsHFPCommandPrefix );
+        aBuf.Append( iTypeDes );
+        aBuf.Append( iModeDes );
+        aBuf.Append( iParamsDes );
+        aBuf.Append( KHsHFPCommandSuffix );
+        }
+    else
+        {
+        aBuf.Zero();
+        }
+
+    TRACE_INFO((_L8("Command to des: %S"),&aBuf));
+    TRACE_FUNC_EXIT
+    }
+
+THsHFPCommandType CHsHFPCommand::Type() const
+    {
+    return iType;
+    }
+
+THsHFPCommandMode CHsHFPCommand::Mode() const
+    {
+    return iMode;
+    }
+
+TBool CHsHFPCommand::FromAG() const
+    {
+    return iFromAG;
+    }
+
+const RATParamArray& CHsHFPCommand::Params() const
+    {
+    return iParams;
+    }
+
+void CHsHFPCommand::CopyL( const CHsHFPCommand& aCmdFrom, CHsHFPCommand& aCmdTo )
+    {
+    TRACE_STATIC_FUNC_ENTRY
+    aCmdTo.iMode = aCmdFrom.iMode;
+    aCmdTo.iType = aCmdFrom.iType;
+
+    aCmdTo.iParams.Reset();
+    for ( TInt i = 0; i < aCmdFrom.iParams.Count(); i++ )
+        {
+        aCmdTo.iParams.AppendL( aCmdFrom.iParams[i] );
+        }
+
+    aCmdTo.iFromAG = aCmdFrom.iFromAG;
+
+    aCmdTo.iModeDes.Copy( aCmdFrom.iModeDes );
+    aCmdTo.iTypeDes.Copy( aCmdFrom.iTypeDes );
+    aCmdTo.iParamsDes.Copy( aCmdFrom.iParamsDes );
+    TRACE_FUNC_EXIT
+    }
+
+CHsHFPCommand::CHsHFPCommand() :
+    iType( EHFPCmdUnknown ), iParams( KParamArrayGranularity )
+    {
+
+    }
+
+void CHsHFPCommand::ConstructL()
+    {
+    TRACE_FUNC_ENTRY
+    iModeDes.CreateL( KModeDesMaxLength );
+    iTypeDes.CreateL( KTypeDesMaxLength );
+    iParamsDes.CreateL( KParamsDesMaxLength );
+    TRACE_FUNC_EXIT
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/dataprocessing/hfpcommandparser.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,342 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hfpcommandparser.h"
+#include "badesca.h"
+#include "debug.h"
+
+CHsHFPParser* CHsHFPParser::NewL()
+    {
+    CHsHFPParser *self = CHsHFPParser::NewLC();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+CHsHFPParser* CHsHFPParser::NewLC()
+    {
+
+    CHsHFPParser *self = new ( ELeave ) CHsHFPParser();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHFPParser::~CHsHFPParser()
+    {
+
+    }
+
+void CHsHFPParser::ParseL( const TDesC8& aBufCommand, const TBool aFromAG,
+        CHsHFPCommand& aCommand )
+    {
+    TRACE_FUNC_ENTRY
+
+    aCommand.SetSource( aFromAG );
+
+    THsHFPCommandType type = EHFPCmdUnknown;
+
+    type = RetrieveTypeL( aBufCommand );
+    User::LeaveIfError( aCommand.SetType( type ) );
+
+    if ( type == EHFPCmdOK || type == EHFPCmdERROR || type == EHFPCmdCHUP
+            || type == EHFPCmdRING || type == EHFPCmdATA || type == EHFPCmdBLDN )
+        {
+        User::LeaveIfError( aCommand.SetMode( ECmdModeNormal ) );
+        RATParamArray params( 1 );
+        User::LeaveIfError( aCommand.SetParams( params ) );
+
+        }
+    else if ( type == EHFPCmdATD )
+        {
+        aCommand.SetMode( ECmdModeOther );
+
+        RBuf8 buf;
+        buf.CreateL( aBufCommand );
+        buf.CleanupClosePushL();
+        buf.Delete( 0, KHsHFPATDCommand().Size() );
+        buf.Delete( buf.Size() - KHsHFPCommandSuffix().Size(), KHsHFPCommandSuffix().Size() );
+        RATParamArray params;
+        params.AppendL( TATParam( buf ) );
+        User::LeaveIfError( aCommand.SetParams( params ) );
+        CleanupStack::PopAndDestroy( &buf );
+        }
+    else
+        {
+        THsHFPCommandMode mode = ECmdUnknownMode;
+        mode = RetrieveModeL( aBufCommand, aFromAG );
+        User::LeaveIfError( aCommand.SetMode( mode ) );
+
+        RATParamArray params( 4 );
+
+        RetrieveParamsL( aBufCommand, mode, params );
+        User::LeaveIfError( aCommand.SetParams( params ) );
+
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+CHsHFPParser::CHsHFPParser()
+    {
+
+    }
+
+void CHsHFPParser::ConstructL()
+    {
+
+    }
+
+THsHFPCommandMode CHsHFPParser::RetrieveModeL( const TDesC8 &aCommand,
+        const TBool aFromAG )
+    {
+    TRACE_FUNC_ENTRY
+
+    THsHFPCommandMode res = ECmdUnknownMode;
+
+    if ( aFromAG )
+        {
+        if ( aCommand.Find( KHsHFPATTestModeDesAG ) != KErrNotFound )
+            {
+            res = ECmdModeTest;
+            }
+        else if ( aCommand.Find( KHsHFPATReadModeDesAG ) != KErrNotFound )
+            {
+            res = ECmdModeRead;
+            }
+        else if ( aCommand.Find( KHsHFPATWriteModeDesAG ) != KErrNotFound )
+            {
+            res = ECmdModeWrite;
+            }
+
+        }
+    else
+        {
+        if ( aCommand.Find( KHsHFPATTestModeDes ) != KErrNotFound )
+            {
+            res = ECmdModeTest;
+            }
+        else if ( aCommand.Find( KHsHFPATReadModeDes ) != KErrNotFound )
+            {
+            res = ECmdModeRead;
+            }
+        else if ( aCommand.Find( KHsHFPATWriteModeDes ) != KErrNotFound )
+            {
+            res = ECmdModeWrite;
+            }
+
+        }
+
+    if ( res == ECmdUnknownMode )
+        {
+        User::Leave( KErrArgument );
+        }
+    TRACE_FUNC_EXIT
+    return res;
+
+    }
+
+THsHFPCommandType CHsHFPParser::RetrieveTypeL( const TDesC8 &aCommand )
+    {
+    TRACE_FUNC_ENTRY
+    THsHFPCommandType res = EHFPCmdUnknown;
+    if ( aCommand.Find( KHsHFPBRSFCommand ) != KErrNotFound )
+        {
+        res = EHFPCmdBRSF;
+        }
+    else if ( aCommand.Find( KHsHFPCHUPCommand ) != KErrNotFound )
+        {
+        res = EHFPCmdCHUP;
+        }
+    else if ( aCommand.Find( KHsHFPCIEVCommand ) != KErrNotFound )
+        {
+        res = EHFPCmdCIEV;
+        }
+    else if ( aCommand.Find( KHsHFPOKCommand ) != KErrNotFound )
+        {
+        res = EHFPCmdOK;
+        }
+    else if ( aCommand.Find( KHsHFPERRORCommand ) != KErrNotFound )
+        {
+        res = EHFPCmdERROR;
+        }
+
+    else if ( aCommand.Find( KHsHFPCINDCommand ) != KErrNotFound )
+        {
+        res = EHFPCmdCIND;
+        }
+    else if ( aCommand.Find( KHsHFPCMERCommand ) != KErrNotFound )
+        {
+        res = EHFPCmdCMER;
+        }
+    else if ( aCommand.Find( KHsHFPCOPSCommand ) != KErrNotFound )
+        {
+        res = EHFPCmdCOPS;
+        }
+    else if ( aCommand.Find( KHsHFPRINGCommand ) != KErrNotFound )
+        {
+        res = EHFPCmdRING;
+        }
+    else if ( aCommand.Find( KHsHFPATACommand ) != KErrNotFound )
+        {
+        res = EHFPCmdATA;
+        }
+    else if ( aCommand.Find( KHsHFPVGSCommand ) != KErrNotFound )
+        {
+        res = EHFPCmdVGS;
+        }
+    else if ( aCommand.Find( KHsHFPVGMCommand ) != KErrNotFound )
+        {
+        res = EHFPCmdVGM;
+        }
+    else if ( aCommand.Find( KHsHFPBLDNCommand ) != KErrNotFound )
+        {
+        res = EHFPCmdBLDN;
+        }
+    else if ( aCommand.Find( KHsHFPATDCommand ) != KErrNotFound )
+        {
+        res = EHFPCmdATD;
+        }
+    else if ( aCommand.Find( KHsHFPCLIPCommand ) != KErrNotFound )
+        {
+        res = EHFPCmdCLIP;
+        }
+    if ( res == EHFPCmdUnknown )
+        User::Leave( KErrArgument );
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+void CHsHFPParser::RetrieveParamsL( const TDesC8 &aCommand,
+        const THsHFPCommandMode aCmdMode, RATParamArray& aParams )
+    {
+    TRACE_FUNC_ENTRY
+
+    RBuf8 buf;
+    buf.CreateL( aCommand );
+    buf.CleanupClosePushL();
+
+    TInt prefixLength = 0;
+    TInt suffixLength = 0;
+
+    TInt modeLength = 0;
+
+    TInt leftOffset = 0;
+    TInt rightOffset = 0;
+
+    TInt startPos = 0;
+    TBool indicatorsFound = EFalse;
+
+    if ( buf.Find( KHsHFPIndicatorParamsSeparator ) != KErrNotFound )
+        {
+        indicatorsFound = ETrue;
+        }
+
+    if ( indicatorsFound )
+        {
+        prefixLength = 9;
+        suffixLength = 2;
+        rightOffset = 2;
+        leftOffset = 1;
+        }
+    else
+        {
+
+        rightOffset = 1;
+        suffixLength = 2;
+
+        switch ( aCmdMode )
+
+            {
+            case ECmdModeTest:
+                {
+                startPos = buf.Find( KHsHFPATTestModeDes );
+                modeLength = 2;
+                }
+                break;
+            case ECmdModeRead:
+                {
+                startPos = buf.Find( KHsHFPATReadModeDes );
+                modeLength = 1;
+                }
+                break;
+            case ECmdModeWrite:
+                {
+                startPos = buf.Find( KHsHFPATWriteModeDes );
+                modeLength = 1;
+
+                if ( startPos == KErrNotFound )
+                    {
+                    startPos = buf.Find( KHsHFPATWriteModeDesAG );
+                    modeLength = 2;
+                    }
+
+                }
+                break;
+            default:
+
+                User::Leave( KErrArgument );
+                break;
+            }
+        }
+
+    if ( startPos != KErrNotFound )
+        {
+        //strip command's prefix
+        buf.Delete( 0, prefixLength + startPos + modeLength );
+
+        //strip command's suffix
+        buf.Delete( buf.Length() - suffixLength, suffixLength );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+
+    while ( buf.Size() > 0 )
+        {
+        TInt pos = 0;
+
+        if ( indicatorsFound )
+            {
+            pos = buf.Find( KHsHFPIndicatorParamsSeparator );
+            }
+        else
+            {
+            pos = buf.Find( KHsHFPParamsSeparator );
+            }
+
+        if ( pos == KErrNotFound )
+            {
+            aParams.AppendL( buf );
+            buf.Zero();
+
+            }
+        else
+            {
+            TPtrC8 ptr = buf.Left( pos + leftOffset );
+            aParams.AppendL( ptr );
+            buf.Delete( 0, pos + rightOffset );
+            }
+        }
+
+    CleanupStack::PopAndDestroy( &buf );
+    TRACE_FUNC_EXIT
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/dataprocessing/hfpdatahandler.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,208 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include <badesca.h>
+#include "hfpdatahandler.h"
+#include "hfpcommandparser.h"
+#include "hfpcommand.h"
+#include "hfpfeaturemanager.h"
+#include "hfpsettings.h"
+#include "debug.h"
+
+CHsHFPDataHandler* CHsHFPDataHandler::NewL()
+    {
+
+    CHsHFPDataHandler *self = CHsHFPDataHandler::NewLC();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+CHsHFPDataHandler* CHsHFPDataHandler::NewLC()
+    {
+
+    CHsHFPDataHandler *self = new ( ELeave ) CHsHFPDataHandler();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHFPDataHandler::~CHsHFPDataHandler()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iFeatureManager )
+        {
+        delete iFeatureManager;
+        }
+
+    if ( iParser )
+        {
+        delete iParser;
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPDataHandler::ProcessDataL( const TDesC8& aDataIn,
+        const TBool aFromAG, TDes8& aDataOut )
+    {
+    TRACE_FUNC_ENTRY
+    if ( aDataIn.Compare( KNullDesC8 ) == 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    aDataOut.Zero();
+
+    CDesC8ArrayFlat* cmdArr = SplitCommandsL( aDataIn );
+    CleanupStack::PushL( cmdArr );
+
+    CHsHFPCommand* cmdIn = CHsHFPCommand::NewL();
+    CleanupStack::PushL( cmdIn );
+
+    CHsHFPCommand* cmdOut = CHsHFPCommand::NewL();
+    CleanupStack::PushL( cmdOut );
+
+    RBuf8 buf, tmpOut;
+
+    tmpOut.CreateL( KTmpBufferLength );
+    tmpOut.CleanupClosePushL();
+
+    for ( TInt i = 0; i < cmdArr->Count(); i++ )
+        {
+        buf.CreateL( cmdArr->MdcaPoint( i ) );
+        buf.CleanupClosePushL();
+        TRACE_INFO((_L8("DATA RETRIEVED FROM ARRAY: %S") , &buf))
+
+        iParser->ParseL( buf, aFromAG, *cmdIn );
+
+        iFeatureManager->PerformDataProcessingL( cmdIn, *cmdOut );
+
+        cmdOut->ToDes8( tmpOut );
+        aDataOut.Append( tmpOut );
+        CleanupStack::PopAndDestroy( &buf );
+        }    
+    CleanupStack::PopAndDestroy( &tmpOut );
+    CleanupStack::PopAndDestroy( cmdOut );
+    CleanupStack::PopAndDestroy( cmdIn );
+    CleanupStack::PopAndDestroy( cmdArr );
+    
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPDataHandler::HandleClientDisconnected( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    iFeatureManager->HandleClientDisconnected( aErr );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPDataHandler::HandleClientConnected( TDes8& aCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+    TRAP_IGNORE( iFeatureManager->HandleClientConnectedL( aCommandOut ) );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPDataHandler::HandleAcceptCallL( TDes8& aCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+
+    PerformRequestL( _L8("ATA\r\n"), aCommandOut );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPDataHandler::HandleReleaseCallL( TDes8& aCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+    PerformRequestL( _L8("AT+CHUP\r\n"), aCommandOut );
+    TRACE_FUNC_EXIT
+    }
+
+CHsHFPDataHandler::CHsHFPDataHandler()
+    {
+
+    }
+
+void CHsHFPDataHandler::ConstructL()
+    {
+    TRACE_FUNC_ENTRY
+    iFeatureManager = CHsHFPFeatureManager::NewL();
+
+    iParser = CHsHFPParser::NewL();
+    TRACE_FUNC_EXIT
+    }
+
+CDesC8ArrayFlat* CHsHFPDataHandler::SplitCommandsL( const TDesC8 &aCommands )
+    {
+    TRACE_FUNC_ENTRY
+    CDesC8ArrayFlat* array = new ( ELeave ) CDesC8ArrayFlat(
+            KCommandArrayGranularity );
+
+    RBuf8 buf;
+    buf.CreateL( aCommands );
+    buf.CleanupClosePushL();
+
+    const TInt offset = 2;
+
+    while ( buf.Size() > 0 )
+        {
+        TInt pos = buf.Find( KHsHFPCommandSeparator );
+
+        if ( pos == KErrNotFound )
+            {
+            array->AppendL( buf );
+            buf.Zero();
+            }
+        else
+            {
+
+            TPtrC8 ptr = buf.Left( pos + offset );
+            array->AppendL( ptr );
+            buf.Delete( 0, pos + offset );
+            }
+        }
+    CleanupStack::PopAndDestroy( &buf );
+
+    TRACE_FUNC_EXIT
+    return array;
+    }
+
+void CHsHFPDataHandler::PerformRequestL( const TDesC8& aCommand,
+        TDes8& aResponse )
+    {
+    TRACE_FUNC_ENTRY
+    CHsHFPCommand* cmdIn = CHsHFPCommand::NewL();
+    CleanupStack::PushL( cmdIn );
+    CHsHFPCommand* cmdOut = CHsHFPCommand::NewL();
+    CleanupStack::PushL( cmdOut );
+
+    RBuf8 buf;
+    buf.CreateL( aCommand );
+    buf.CleanupClosePushL();
+
+    iParser->ParseL( buf, EFalse, *cmdIn );
+
+    iFeatureManager->PerformDataProcessingL( cmdIn, *cmdOut );
+    cmdOut->ToDes8( aResponse );
+
+    CleanupStack::PopAndDestroy( &buf );
+    CleanupStack::PopAndDestroy( &cmdOut );
+    CleanupStack::PopAndDestroy( &cmdIn );
+    TRACE_FUNC_EXIT
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpcallinglineidentification.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,104 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hfpcallinglineidentification.h"
+#include "hfpcommand.h"
+#include "hfpsettings.h"
+#include "debug.h"
+
+CHsHFPCallingLineIdentification* CHsHFPCallingLineIdentification::NewL(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPCallingLineIdentification *self =
+            CHsHFPCallingLineIdentification::NewLC( aObserver );
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+CHsHFPCallingLineIdentification* CHsHFPCallingLineIdentification::NewLC(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPCallingLineIdentification *self =
+            new ( ELeave ) CHsHFPCallingLineIdentification( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHFPCallingLineIdentification::~CHsHFPCallingLineIdentification()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iSettings )
+        {
+        iSettings->Release();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsHFPCallingLineIdentification::ProcessCommand(
+        const CHsHFPCommand &aInputCmd, CHsHFPCommand &aOutputCmd )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt res = KErrNone;
+    if ( aInputCmd.FromAG() )
+        {
+        if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdOK )
+            {
+            iWaitingForOK = EFalse;
+            iObserver->HandleProcedureCompleted( KErrNone );
+            }
+        else if ( aInputCmd.Type() == EHFPCmdCLIP )
+            {
+            iObserver->HandleProcedureCompleted( KErrNone );
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+    else
+        {
+        if ( aInputCmd.Type() == EHFPCmdCLIP )
+            {
+            iWaitingForOK = ETrue;
+            TRAP(res,CHsHFPCommand::CopyL( aInputCmd, aOutputCmd ));
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+CHsHFPCallingLineIdentification::CHsHFPCallingLineIdentification(
+        MHsHFPFeatureProviderObserver* aObserver ) :
+    iObserver( aObserver )
+    {
+
+    }
+
+void CHsHFPCallingLineIdentification::ConstructL()
+    {
+    iSettings = CHsHFPSettings::InstanceL();
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpcalltermination.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,131 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hfpcalltermination.h"
+#include "hfpcommand.h"
+#include "hfpsettings.h"
+#include "debug.h"
+
+CHsHFPCallTerminationProc* CHsHFPCallTerminationProc::NewL(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPCallTerminationProc *self = CHsHFPCallTerminationProc::NewLC(
+            aObserver );
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+CHsHFPCallTerminationProc* CHsHFPCallTerminationProc::NewLC(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPCallTerminationProc *self = new ( ELeave ) CHsHFPCallTerminationProc(
+            aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHFPCallTerminationProc::~CHsHFPCallTerminationProc()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iSettings )
+        {
+        iSettings->Release();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsHFPCallTerminationProc::ProcessCommand( const CHsHFPCommand &aInputCmd,
+        CHsHFPCommand &aOutputCmd )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt res = KErrNone;
+    if ( aInputCmd.FromAG() )
+        {
+        if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdOK )
+            {
+            iWaitingForOK = EFalse;
+            iWaitingForCIEV = ETrue;
+            }
+        else if ( iWaitingForCIEV && IsProperCIEV( &aInputCmd ) )
+            {
+            //call terminated successfully
+            iWaitingForCIEV = EFalse;
+            iObserver->HandleProcedureCompleted( KErrNone );
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+    else
+        {
+        if ( aInputCmd.Type() == EHFPCmdCHUP )
+            {
+            iWaitingForOK = ETrue;
+            TRAP(res,CHsHFPCommand::CopyL( aInputCmd, aOutputCmd ));
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+CHsHFPCallTerminationProc::CHsHFPCallTerminationProc(
+        MHsHFPFeatureProviderObserver* aObserver ) :
+    iObserver( aObserver )
+    {
+
+    }
+
+void CHsHFPCallTerminationProc::ConstructL()
+    {
+    iSettings = CHsHFPSettings::InstanceL();
+    }
+
+TBool CHsHFPCallTerminationProc::IsProperCIEV( const CHsHFPCommand* aCommand )
+    {
+    TRACE_FUNC_ENTRY
+    TBool res = EFalse;
+
+    TInt expectedIdx = iSettings->FindIndicatorIndex( KHFPCallIndicatorDes );
+
+    TInt retrievedIdx = KErrNotFound;
+    TRAPD(errRetrieveIdx, retrievedIdx = aCommand->Params()[0].IntL() )
+
+    TInt retrievedValue = KErrNotFound;
+    TRAPD(errRetrieveValue, retrievedValue = aCommand->Params()[1].IntL() )
+    TRACE_INFO((_L8(" Index retrieved = %d, expected = %d"),
+                    expectedIdx, retrievedIdx))
+
+    if ( errRetrieveIdx == KErrNone && errRetrieveValue == KErrNone
+            && aCommand->Type() == EHFPCmdCIEV && aCommand->FromAG()
+            && expectedIdx == retrievedIdx && retrievedValue == 0 )
+        {
+        res = ETrue;
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpconnectionmanagement.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,251 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+#include "hfpconnectionmanagement.h"
+#include "hfpcommand.h"
+#include "hfpsettings.h"
+#include "debug.h"
+_LIT8(KHsHFPParamValue0,"0");
+_LIT8(KHsHFPParamValue1,"1");
+_LIT8(KHsHFPParamValue3,"3");
+_LIT8(KHsHFPParamValue16,"16");
+
+CHsHFPConnectionManagement* CHsHFPConnectionManagement::NewL(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPConnectionManagement* self = CHsHFPConnectionManagement::NewLC(
+            aObserver );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CHsHFPConnectionManagement* CHsHFPConnectionManagement::NewLC(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPConnectionManagement* self =
+            new ( ELeave ) CHsHFPConnectionManagement( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHFPConnectionManagement::~CHsHFPConnectionManagement()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iSettings )
+        {
+        iSettings->Release();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsHFPConnectionManagement::EstablishServiceLevelConnection(
+        const CHsHFPCommand &aInputCmd, CHsHFPCommand &aOutputCmd )
+    {
+    TRACE_FUNC_ENTRY
+    TInt res = KErrNone;
+    switch ( iEstablishmentState )
+        {
+        case EHFPNotConnected:
+            {
+            if ( aInputCmd.Type() == EHFPCmdUnknown )//initialization
+                {
+                aOutputCmd.SetType( EHFPCmdBRSF );
+                aOutputCmd.SetMode( ECmdModeWrite );
+                RATParamArray params;
+                params.Append( TATParam( KHsHFPParamValue16 ) );
+                aOutputCmd.SetParams( params );
+                iEstablishmentState = EHFPWaitingForBrsfAndOk;
+                }
+            else
+                {
+                res = KErrArgument;
+                }
+            break;
+            }
+        case EHFPWaitingForBrsfAndOk:
+            {
+            if ( aInputCmd.Type() == EHFPCmdBRSF )
+                {
+                iWaitingForOK = ETrue;
+                }
+            else if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdOK )
+                {
+                iWaitingForOK = EFalse;
+                aOutputCmd.SetType( EHFPCmdCIND );
+                aOutputCmd.SetMode( ECmdModeTest );
+                iEstablishmentState = EHFPWaitingForCindTestAndOk;
+                }
+            else
+                {
+                res = KErrArgument;
+                }
+            break;
+            }
+        case EHFPWaitingForCindTestAndOk:
+            {
+            if ( aInputCmd.Type() == EHFPCmdCIND )
+                {
+                TRAP( res, InitializeIndicatorsL( &aInputCmd ) );
+                iWaitingForOK = ETrue;
+                }
+            else if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdOK )
+                {
+                iWaitingForOK = EFalse;
+                aOutputCmd.SetType( EHFPCmdCIND );
+                aOutputCmd.SetMode( ECmdModeRead );
+                iEstablishmentState = EHFPWaitingForCindReadAndOk;
+                }
+            else
+                {
+                res = KErrArgument;
+                }
+            break;
+            }
+        case EHFPWaitingForCindReadAndOk:
+            {
+            if ( aInputCmd.Type() == EHFPCmdCIND )
+                {
+                TRAP( res, SetupIndicatorsL( &aInputCmd ) );
+                iWaitingForOK = ETrue;
+                }
+            else if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdOK )
+                {
+                iWaitingForOK = EFalse;
+                aOutputCmd.SetType( EHFPCmdCMER );
+                aOutputCmd.SetMode( ECmdModeWrite );
+                RATParamArray params;
+                params.Append( TATParam( KHsHFPParamValue3 ) );
+                params.Append( TATParam( KHsHFPParamValue0 ) );
+                params.Append( TATParam( KHsHFPParamValue0 ) );
+                params.Append( TATParam( KHsHFPParamValue1 ) );
+                aOutputCmd.SetParams( params );
+                iEstablishmentState = EHFPWaitingForOk;
+                }
+            else
+                {
+                res = KErrArgument;
+                }
+            break;
+            }
+        case EHFPWaitingForOk:
+            {
+            if ( aInputCmd.Type() == EHFPCmdOK )
+                {
+                iEstablishmentState = EHFPConnected;
+
+                // Initialize volume level synchronization
+                aOutputCmd.SetType( EHFPCmdVGS );
+                aOutputCmd.SetMode( ECmdModeWrite );
+                RATParamArray params;
+                TBuf8 <KHsHFPMaxVolumeLevelParamSize> vgsLevel;
+                vgsLevel.AppendNum( iSettings->iVgsLevel );
+                params.Append( TATParam( vgsLevel ) );
+                aOutputCmd.SetParams( params );
+
+                iObserver->HandleProcedureCompleted( KErrNone );
+                }
+            else
+                {
+                res = KErrArgument;
+                }
+            break;
+            }
+        default:
+            res = KErrArgument;
+            break;
+        }
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+void CHsHFPConnectionManagement::HandleServiceLevelConnectionRelease( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    iEstablishmentState = EHFPNotConnected;
+    iObserver->HandleProcedureCompleted( KErrNone );
+    TRACE_FUNC_EXIT
+    }
+
+CHsHFPConnectionManagement::CHsHFPConnectionManagement(
+        MHsHFPFeatureProviderObserver* aObserver ) :
+    iObserver( aObserver )
+    {
+    }
+
+void CHsHFPConnectionManagement::ConstructL()
+    {
+    TRACE_FUNC_ENTRY
+
+    iSettings = CHsHFPSettings::InstanceL();
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPConnectionManagement::InitializeIndicatorsL(
+        const CHsHFPCommand* aCommand )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt params = aCommand->Params().Count();
+
+    TChar end( '\"' );
+
+    const TInt prefixLength = 2;
+    const TInt suffixLength = 2;
+    for ( TInt i = 0; i < params; i++ )
+        {
+        TInt pos = aCommand->Params()[i].Des().LocateReverse( end );
+
+        if ( pos == KErrNotFound )
+            {
+            User::Leave( KErrArgument );
+            }
+
+        RBuf8 buf;
+        buf.CreateL( aCommand->Params()[i].Des() );
+        buf.CleanupClosePushL();
+
+        buf.Delete( 0, prefixLength );
+
+        buf.Delete( pos - suffixLength, buf.Length() - 1 );
+
+        iSettings->iSettingsArr.AppendL( THsHFPIndicatorSetting( buf, 0 ) );
+        CleanupStack::PopAndDestroy( &buf );
+
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPConnectionManagement::SetupIndicatorsL(
+        const CHsHFPCommand* aCommand )
+    {
+    TRACE_FUNC_ENTRY
+
+    for ( TInt i = 0; i < aCommand->Params().Count(); i++ )
+        {
+        if ( iSettings->iSettingsArr.Count() > ( i + 1 ) )
+            {
+            iSettings->iSettingsArr[i + 1].SetValueL(
+                    aCommand->Params()[i].Des() );
+            TRACE_INFO( (_L8("INDICATOR: %S - value: %d "),
+                            &iSettings->iSettingsArr[i + 1].Des(),
+                            iSettings->iSettingsArr[i + 1].Int() ) );
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpfeaturemanager.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,451 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hfpfeaturemanager.h"
+#include "hfpcalltermination.h"
+#include "hfpconnectionmanagement.h"
+#include "hfpincomingcallacceptance.h"
+#include "hfpincomingcallrejection.h"
+#include "hfpphonestatusinformation.h"
+#include "hfpremoteaudiovolumecontrol.h"
+#include "hfplastnumberredialing.h"
+#include "hfpphonenumberdialing.h"
+#include "hfpcallinglineidentification.h"
+#include "hfpcommand.h"
+#include "debug.h"
+
+CHsHFPFeatureManager* CHsHFPFeatureManager::NewL()
+    {
+    CHsHFPFeatureManager *self = CHsHFPFeatureManager::NewLC();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+CHsHFPFeatureManager* CHsHFPFeatureManager::NewLC()
+    {
+
+    CHsHFPFeatureManager *self = new ( ELeave ) CHsHFPFeatureManager();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHFPFeatureManager::~CHsHFPFeatureManager()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iConnectionManagement )
+        {
+        delete iConnectionManagement;
+        }
+    if ( iCallTermProc )
+        {
+        delete iCallTermProc;
+        }
+    if ( iCallAcceptProc )
+        {
+        delete iCallAcceptProc;
+        }
+    if ( iCallRejectProc )
+        {
+        delete iCallRejectProc;
+        }
+    if ( iPhoneStatus )
+        {
+        delete iPhoneStatus;
+        }
+    if ( iVolumeControl )
+        {
+        delete iVolumeControl;
+        }
+    if ( iLastNumberRedialing )
+        {
+        delete iLastNumberRedialing;
+        }
+    if ( iPhoneNumberDialing )
+        {
+        delete iPhoneNumberDialing;
+        }
+    if ( iCallingLineIdentification )
+        {
+        delete iCallingLineIdentification;
+        }
+    TRACE_FUNC_EXIT
+
+    }
+
+void CHsHFPFeatureManager::PerformDataProcessingL(
+        const CHsHFPCommand* aATCommandIn, CHsHFPCommand& aATCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+    if ( iSrvLvlConnEstablished )
+        {
+        //decide which procedure should be used
+        switch ( aATCommandIn->Type() )
+            {
+            case EHFPCmdCHUP:
+                {
+                if ( iPhoneStatus->IsCallOngoing() )
+                    {
+                    //start releasing connection
+                    User::LeaveIfNull( iCallTermProc );
+                    User::LeaveIfError( iCallTermProc->ProcessCommand(
+                            *aATCommandIn, aATCommandOut ) );
+                    iProcedureStarted = EHFPCallTerminate;
+                    }
+                else
+                    {
+                    //start call rejection
+                    User::LeaveIfNull( iCallRejectProc );
+                    User::LeaveIfError( iCallRejectProc->ProcessCommand(
+                            *aATCommandIn, aATCommandOut ) );
+                    iProcedureStarted = EHFPCallReject;
+                    }
+                }
+                break;
+
+            case EHFPCmdOK:
+                {
+                HandleOKCommandL( aATCommandIn, aATCommandOut );
+                }
+                break;
+            case EHFPCmdERROR:
+                {
+                if ( iProcedureStarted == EHFPLastNumberRedialing )
+                    {
+                    User::LeaveIfNull( iLastNumberRedialing );
+                    User::LeaveIfError( iLastNumberRedialing->ProcessCommand(
+                            *aATCommandIn, aATCommandOut ) );
+                    }
+                else if ( iProcedureStarted == EHFPPhoneNumberDialing )
+                    {
+                    User::LeaveIfNull( iPhoneNumberDialing );
+                    User::LeaveIfError( iPhoneNumberDialing->ProcessCommand(
+                            *aATCommandIn, aATCommandOut ) );
+                    }
+                else
+                    {
+                    User::Leave( KErrArgument );
+                    }
+                }
+                break;
+            case EHFPCmdCIEV:
+                {
+                HandleCIEVCommandL( aATCommandIn, aATCommandOut );
+                }
+                break;
+            case EHFPCmdRING:
+                {
+                User::LeaveIfNull( iCallAcceptProc );
+                User::LeaveIfError( iCallAcceptProc->ProcessCommand(
+                        *aATCommandIn, aATCommandOut ) );
+                iProcedureStarted = EHFPCallAccept;
+                }
+                break;
+            case EHFPCmdATA:
+                {
+                if ( iProcedureStarted == EHFPCallAccept )
+                    {
+                    User::LeaveIfNull( iCallAcceptProc );
+                    User::LeaveIfError( iCallAcceptProc->ProcessCommand(
+                            *aATCommandIn, aATCommandOut ) );
+                    }
+                else
+                    {
+                    User::Leave( KErrArgument );
+                    }
+                }
+                break;
+            case EHFPCmdCOPS:
+                {
+                iProcedureStarted = EHFPOperatorSelection;
+                User::LeaveIfNull( iPhoneStatus );
+                User::LeaveIfError( iPhoneStatus->ProcessCommand(
+                        *aATCommandIn, aATCommandOut ) );
+                }
+                break;
+            case EHFPCmdVGS: // fall-through intended here
+            case EHFPCmdVGM:
+                {
+                iProcedureStarted = EHFPVolumeControl;
+                User::LeaveIfNull( iVolumeControl );
+                User::LeaveIfError( iVolumeControl->ProcessCommand(
+                        *aATCommandIn, aATCommandOut ) );
+                }
+                break;
+            case EHFPCmdBLDN:
+                {
+                iProcedureStarted = EHFPLastNumberRedialing;
+                User::LeaveIfNull( iLastNumberRedialing );
+                User::LeaveIfError( iLastNumberRedialing->ProcessCommand(
+                        *aATCommandIn, aATCommandOut ) );
+                }
+                break;
+            case EHFPCmdATD:
+                {
+                iProcedureStarted = EHFPPhoneNumberDialing;
+                User::LeaveIfNull( iPhoneNumberDialing );
+                User::LeaveIfError( iPhoneNumberDialing->ProcessCommand(
+                        *aATCommandIn, aATCommandOut ) );
+                }
+                break;
+            case EHFPCmdCLIP:
+                {
+                iProcedureStarted = EHFPCallingLineIdentification;
+                User::LeaveIfNull( iCallingLineIdentification );
+                User::LeaveIfError( iCallingLineIdentification->ProcessCommand(
+                        *aATCommandIn, aATCommandOut ) );
+                }
+                break;
+            default:
+                User::Leave( KErrArgument );
+            }
+        }
+    else
+        {
+        //start ServiceLevelConnectionProcedure
+        User::LeaveIfNull( iConnectionManagement );
+        iProcedureStarted = EHFPServiceLevelConnectionEstablishment;
+        User::LeaveIfError(
+                iConnectionManagement->EstablishServiceLevelConnection(
+                        *aATCommandIn, aATCommandOut ) );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPFeatureManager::HandleClientDisconnected( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    iProcedureStarted = EHFPServiceLevelConnectionRelease;
+    iConnectionManagement->HandleServiceLevelConnectionRelease( aErr );
+    iVolumeControl->Reset();
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPFeatureManager::HandleClientConnectedL( TDes8& aCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+    CHsHFPCommand* cmdIn = CHsHFPCommand::NewL();
+    CleanupStack::PushL( cmdIn );
+    CHsHFPCommand* cmdOut = CHsHFPCommand::NewL();
+    CleanupStack::Pop( cmdIn );
+    iProcedureStarted = EHFPServiceLevelConnectionEstablishment;
+    iConnectionManagement->EstablishServiceLevelConnection( *cmdIn, *cmdOut );
+    cmdOut->ToDes8( aCommandOut );
+
+    delete cmdIn;
+    delete cmdOut;
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPFeatureManager::HandleProcedureCompleted( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    switch ( iProcedureStarted )
+        {
+        case EHFPServiceLevelConnectionEstablishment:
+            if ( aErr == KErrNone )
+                {
+                TRACE_INFO(_L8("Connection established"))
+                iSrvLvlConnEstablished = ETrue;
+                iProcedureStarted = EHFPVolumeControl;
+                }
+            break;
+        case EHFPServiceLevelConnectionRelease:
+            if ( aErr == KErrNone )
+                {
+                TRACE_INFO(_L8("Connection released"))
+                iSrvLvlConnEstablished = EFalse;
+                iProcedureStarted = EHFPIdle;
+                }
+            break;
+        case EHFPCallTerminate:
+            iProcedureStarted = EHFPIdle;
+            TRACE_INFO(_L8("Call terminated"))
+            break;
+        case EHFPCallAccept:
+            TRACE_INFO(_L("Call answered"))
+            iProcedureStarted = EHFPIdle;
+            break;
+        case EHFPCallReject:
+            TRACE_INFO(_L("Call rejected"))
+            iProcedureStarted = EHFPIdle;
+            break;
+        case EHFPOperatorSelection:
+            TRACE_INFO(_L("Operator selection"))
+            iProcedureStarted = EHFPIdle;
+            break;
+        case EHFPVolumeControl:
+            TRACE_INFO(_L("Volume control"))
+            break;
+        case EHFPLastNumberRedialing:
+            TRACE_INFO(_L("Last number re-dial"))
+            iProcedureStarted = EHFPIdle;
+            break;
+        case EHFPPhoneNumberDialing:
+            TRACE_INFO(_L("Phone number dialing"))
+            iProcedureStarted = EHFPIdle;
+            break;
+        case EHFPCallingLineIdentification:
+            TRACE_INFO(_L("Calling line identification"))
+            iProcedureStarted = EHFPCallAccept;
+            break;
+        default:
+            iProcedureStarted = EHFPIdle;
+        }
+    TRACE_FUNC_EXIT
+    }
+
+CHsHFPFeatureManager::CHsHFPFeatureManager()
+    {
+
+    }
+
+void CHsHFPFeatureManager::ConstructL()
+    {
+    TRACE_FUNC_ENTRY
+    iConnectionManagement = CHsHFPConnectionManagement::NewL( this );
+    iCallTermProc = CHsHFPCallTerminationProc::NewL( this );
+    iCallAcceptProc = CHsHFPIncomingCallAcceptance::NewL( this );
+    iCallRejectProc = CHsHFPIncomingCallRejection::NewL( this );
+    iPhoneStatus = CHsHFPPhoneStatusInformation::NewL( this );
+    iVolumeControl = CHsHFPRemoteAudioVolumeControl::NewL( this );
+    iLastNumberRedialing = CHsHFPLastNumberRedialing::NewL( this );
+    iPhoneNumberDialing = CHsHFPPhoneNumberDialing::NewL( this );
+    iCallingLineIdentification = CHsHFPCallingLineIdentification::NewL( this );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPFeatureManager::HandleOKCommandL( const CHsHFPCommand* aATCommandIn,
+        CHsHFPCommand& aATCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+    if ( iProcedureStarted == EHFPCallTerminate )
+        {
+        User::LeaveIfNull( iCallTermProc );
+        User::LeaveIfError( iCallTermProc->ProcessCommand( *aATCommandIn,
+                aATCommandOut ) );
+        }
+    else if ( iProcedureStarted == EHFPCallAccept )
+        {
+        TRACE_INFO(_L("iProcedureStarted == EHFPCallAccept"))
+        User::LeaveIfNull( iCallAcceptProc );
+        User::LeaveIfError( iCallAcceptProc->ProcessCommand( *aATCommandIn,
+                aATCommandOut ) );
+        }
+    else if ( iProcedureStarted == EHFPCallReject )
+        {
+        TRACE_INFO(_L("iProcedureStarted == EHFPCallReject"))
+        User::LeaveIfNull( iCallRejectProc );
+        User::LeaveIfError( iCallRejectProc->ProcessCommand( *aATCommandIn,
+                aATCommandOut ) );
+        }
+    else if ( iProcedureStarted == EHFPOperatorSelection )
+        {
+        TRACE_INFO(_L("iProcedureStarted == EHFPOperatorSelection"))
+        User::LeaveIfNull( iPhoneStatus );
+        User::LeaveIfError( iPhoneStatus->ProcessCommand( *aATCommandIn,
+                aATCommandOut ) );
+        }
+    else if ( iProcedureStarted == EHFPVolumeControl )
+        {
+        TRACE_INFO(_L("iProcedureStarted == EHFPVolumeControl"))
+        User::LeaveIfNull( iVolumeControl );
+        User::LeaveIfError( iVolumeControl->ProcessCommand( *aATCommandIn,
+                aATCommandOut ) );
+        }
+    else if ( iProcedureStarted == EHFPLastNumberRedialing )
+        {
+        TRACE_INFO(_L("iProcedureStarted == EHFPLastNumberRedialing"))
+        User::LeaveIfNull( iLastNumberRedialing );
+        User::LeaveIfError( iLastNumberRedialing->ProcessCommand(
+                *aATCommandIn, aATCommandOut ) );
+        }
+    else if ( iProcedureStarted == EHFPPhoneNumberDialing )
+        {
+        TRACE_INFO(_L("iProcedureStarted == EHFPPhoneNumberDialing"))
+        User::LeaveIfNull( iPhoneNumberDialing );
+        User::LeaveIfError( iPhoneNumberDialing->ProcessCommand( *aATCommandIn,
+                aATCommandOut ) );
+        }
+    else if ( iProcedureStarted == EHFPCallingLineIdentification )
+        {
+        TRACE_INFO(_L("iProcedureStarted == EHFPCallingLineIdentification"))
+        User::LeaveIfNull( iCallingLineIdentification );
+        User::LeaveIfError( iCallingLineIdentification->ProcessCommand(
+                *aATCommandIn, aATCommandOut ) );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPFeatureManager::HandleCIEVCommandL(
+        const CHsHFPCommand* aATCommandIn, CHsHFPCommand& aATCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+
+    // refresh settings
+    iPhoneStatus->ProcessCommand( *aATCommandIn, aATCommandOut );
+
+    if ( iProcedureStarted == EHFPCallTerminate )
+        {
+        TRACE_INFO(_L8("CIEV : CALL TERMINATE"))
+        User::LeaveIfNull( iCallTermProc );
+        User::LeaveIfError( iCallTermProc->ProcessCommand( *aATCommandIn,
+                aATCommandOut ) );
+        }
+    else if ( iProcedureStarted == EHFPCallReject )
+        {
+        TRACE_INFO(_L("CIEV : CALL REJECT"))
+        User::LeaveIfNull( iCallRejectProc );
+        User::LeaveIfError( iCallRejectProc->ProcessCommand( *aATCommandIn,
+                aATCommandOut ) );
+        }
+    else if ( iProcedureStarted == EHFPCallAccept )
+        {
+        TRACE_INFO(_L("CIEV : CALL ACCEPT"))
+        User::LeaveIfNull( iCallAcceptProc );
+        User::LeaveIfError( iCallAcceptProc->ProcessCommand( *aATCommandIn,
+                aATCommandOut ) );
+        }
+    else if ( iProcedureStarted == EHFPLastNumberRedialing )
+        {
+        TRACE_INFO(_L("CIEV : LAST NUMBER REDIAL"))
+        User::LeaveIfNull( iLastNumberRedialing );
+        User::LeaveIfError( iLastNumberRedialing->ProcessCommand(
+                *aATCommandIn, aATCommandOut ) );
+        }
+    else if ( iProcedureStarted == EHFPPhoneNumberDialing )
+        {
+        TRACE_INFO(_L("CIEV : PHONE NUMBER DIALING"))
+        User::LeaveIfNull( iPhoneNumberDialing );
+        User::LeaveIfError( iPhoneNumberDialing->ProcessCommand( *aATCommandIn,
+                aATCommandOut ) );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+
+    TRACE_FUNC_EXIT
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpincomingcallacceptance.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,150 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hfpincomingcallacceptance.h"
+#include "hfpcommand.h"
+#include "hfpsettings.h"
+#include "debug.h"
+
+CHsHFPIncomingCallAcceptance* CHsHFPIncomingCallAcceptance::NewL(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPIncomingCallAcceptance* self = CHsHFPIncomingCallAcceptance::NewLC(
+            aObserver );
+    CleanupStack::Pop( self );
+    return self;
+    }
+CHsHFPIncomingCallAcceptance* CHsHFPIncomingCallAcceptance::NewLC(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPIncomingCallAcceptance* self =
+            new ( ELeave ) CHsHFPIncomingCallAcceptance( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHFPIncomingCallAcceptance::~CHsHFPIncomingCallAcceptance()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iSettings )
+        {
+        iSettings->Release();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsHFPIncomingCallAcceptance::ProcessCommand(
+        const CHsHFPCommand &aInputCmd, CHsHFPCommand &aOutputCmd )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt res = KErrNone;
+    if ( aInputCmd.FromAG() )
+        {
+        if ( aInputCmd.Type() == EHFPCmdRING )
+            {
+            TInt ind =
+                    iSettings->FindIndicatorIndex( KHFPCallsetupIndicatorDes );
+            if ( ind != KErrNotFound && iSettings->iSettingsArr[ind].Int() == 1 )
+                {
+                iWaitingForATA = ETrue;
+                }
+            }
+        else if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdOK )
+            {
+            iWaitingForOK = EFalse;
+            iWaitingForCIEVCall1 = ETrue;
+            }
+        else if ( iWaitingForCIEVCall1 && IsProperCIEV( &aInputCmd,
+                KHFPCallIndicatorDes, 1 ) )
+            {
+            iWaitingForCIEVCall1 = EFalse;
+            iWaitingForCIEVCallsetup0 = ETrue;
+            }
+        else if ( iWaitingForCIEVCallsetup0 && IsProperCIEV( &aInputCmd,
+                KHFPCallsetupIndicatorDes, 0 ) )
+            {
+            iWaitingForCIEVCallsetup0 = EFalse;
+            iObserver->HandleProcedureCompleted( KErrNone );
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+    else
+        {
+        if ( iWaitingForATA && aInputCmd.Type() == EHFPCmdATA )
+            {
+            iWaitingForATA = EFalse;
+            iWaitingForOK = ETrue;
+            TRAP(res,CHsHFPCommand::CopyL( aInputCmd, aOutputCmd ));
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+CHsHFPIncomingCallAcceptance::CHsHFPIncomingCallAcceptance(
+        MHsHFPFeatureProviderObserver* aObserver ) :
+    iObserver( aObserver )
+    {
+    }
+
+void CHsHFPIncomingCallAcceptance::ConstructL()
+    {
+    iSettings = CHsHFPSettings::InstanceL();
+    }
+
+TBool CHsHFPIncomingCallAcceptance::IsProperCIEV(
+        const CHsHFPCommand* aCommand, const TDesC8& aIndicatorDes,
+        const TInt aIndicatorValue )
+    {
+    TRACE_FUNC_ENTRY
+    TBool res = EFalse;
+
+    if ( aCommand->Params().Count() == 2 )
+        {
+        TInt expectedIdx = iSettings->FindIndicatorIndex( aIndicatorDes );
+
+        TInt retrievedIdx = KErrNotFound;
+        TRAPD(errRetrieveIdx, retrievedIdx = aCommand->Params()[0].IntL() )
+
+        TInt retrievedValue = KErrNotFound;
+        TRAPD(errRetrieveValue, retrievedValue = aCommand->Params()[1].IntL() )
+        TRACE_INFO((_L8(" Index retrieved = %d, expected = %d"),
+                        expectedIdx, retrievedIdx))
+
+        if ( errRetrieveIdx == KErrNone && errRetrieveValue == KErrNone
+                && aCommand->Type() == EHFPCmdCIEV && aCommand->FromAG()
+                && expectedIdx == retrievedIdx && retrievedValue
+                == aIndicatorValue )
+            {
+            res = ETrue;
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpincomingcallrejection.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,133 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hfpincomingcallrejection.h"
+#include "hfpcommand.h"
+#include "hfpsettings.h"
+#include "debug.h"
+
+CHsHFPIncomingCallRejection* CHsHFPIncomingCallRejection::NewL(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPIncomingCallRejection* self = CHsHFPIncomingCallRejection::NewLC(
+            aObserver );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CHsHFPIncomingCallRejection* CHsHFPIncomingCallRejection::NewLC(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPIncomingCallRejection* self =
+            new ( ELeave ) CHsHFPIncomingCallRejection( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+CHsHFPIncomingCallRejection::~CHsHFPIncomingCallRejection()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iSettings )
+        {
+        iSettings->Release();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsHFPIncomingCallRejection::ProcessCommand(
+        const CHsHFPCommand &aInputCmd, CHsHFPCommand &aOutputCmd )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt res = KErrNone;
+    if ( aInputCmd.FromAG() )
+        {
+
+        if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdOK )
+            {
+            iWaitingForOK = EFalse;
+            iWaitingForCIEV = ETrue;
+            }
+        else if ( iWaitingForCIEV && IsProperCIEV( &aInputCmd ) )
+            {
+            //call rejected successfully
+            iWaitingForCIEV = EFalse;
+            iObserver->HandleProcedureCompleted( KErrNone );
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+    else
+        {
+        if ( aInputCmd.Type() == EHFPCmdCHUP )
+            {
+            iWaitingForOK = ETrue;
+            TRAP( res, CHsHFPCommand::CopyL( aInputCmd, aOutputCmd ) );
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+CHsHFPIncomingCallRejection::CHsHFPIncomingCallRejection(
+        MHsHFPFeatureProviderObserver* aObserver ) :
+    iObserver( aObserver )
+    {
+    }
+
+void CHsHFPIncomingCallRejection::ConstructL()
+    {
+    iSettings = CHsHFPSettings::InstanceL();
+    }
+
+TBool CHsHFPIncomingCallRejection::IsProperCIEV( const CHsHFPCommand* aCommand )
+    {
+    TRACE_FUNC_ENTRY
+    TBool res = EFalse;
+
+    if ( aCommand->Params().Count() == 2 )
+        {
+        TInt expectedIdx = iSettings->FindIndicatorIndex(
+                KHFPCallsetupIndicatorDes );
+
+        TInt retrievedIdx = KErrNotFound;
+        TRAPD(errRetrieveIdx, retrievedIdx = aCommand->Params()[0].IntL() )
+
+        TInt retrievedValue = KErrNotFound;
+        TRAPD(errRetrieveValue, retrievedValue = aCommand->Params()[1].IntL() )
+        TRACE_INFO((_L8(" Index retrieved = %d, expected = %d"),
+                        expectedIdx, retrievedIdx))
+
+        if ( errRetrieveIdx == KErrNone && errRetrieveValue == KErrNone
+                && aCommand->Type() == EHFPCmdCIEV && aCommand->FromAG()
+                && expectedIdx == retrievedIdx && retrievedValue == 0 )
+            {
+            res = ETrue;
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfplastnumberredialing.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,139 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hfplastnumberredialing.h"
+#include "hfpcommand.h"
+#include "hfpsettings.h"
+#include "debug.h"
+
+CHsHFPLastNumberRedialing* CHsHFPLastNumberRedialing::NewL(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPLastNumberRedialing* self = CHsHFPLastNumberRedialing::NewLC(
+            aObserver );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CHsHFPLastNumberRedialing* CHsHFPLastNumberRedialing::NewLC(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPLastNumberRedialing* self = new ( ELeave ) CHsHFPLastNumberRedialing(
+            aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+CHsHFPLastNumberRedialing::~CHsHFPLastNumberRedialing()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iSettings )
+        {
+        iSettings->Release();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsHFPLastNumberRedialing::ProcessCommand( const CHsHFPCommand &aInputCmd,
+        CHsHFPCommand &aOutputCmd )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt res = KErrNone;
+    if ( aInputCmd.FromAG() )
+        {
+
+        if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdOK )
+            {
+            iWaitingForOK = EFalse;
+            iWaitingForCIEV = ETrue;
+            }
+        else if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdERROR )
+            {
+            iWaitingForOK = EFalse;
+            iObserver->HandleProcedureCompleted( KErrNotFound );
+            }
+        else if ( iWaitingForCIEV && IsProperCIEV( &aInputCmd ) )
+            {
+            iWaitingForCIEV = EFalse;
+            iObserver->HandleProcedureCompleted( KErrNone );
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+    else
+        {
+        if ( aInputCmd.Type() == EHFPCmdBLDN )
+            {
+            iWaitingForOK = ETrue;
+            TRAP( res, CHsHFPCommand::CopyL( aInputCmd, aOutputCmd ) );
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+CHsHFPLastNumberRedialing::CHsHFPLastNumberRedialing(
+        MHsHFPFeatureProviderObserver* aObserver ) :
+    iObserver( aObserver )
+    {
+    }
+
+void CHsHFPLastNumberRedialing::ConstructL()
+    {
+    iSettings = CHsHFPSettings::InstanceL();
+    }
+
+TBool CHsHFPLastNumberRedialing::IsProperCIEV( const CHsHFPCommand* aCommand )
+    {
+    TRACE_FUNC_ENTRY
+    TBool res = EFalse;
+
+    if ( aCommand->Params().Count() == 2 )
+        {
+        TInt expectedIdx = iSettings->FindIndicatorIndex(
+                KHFPCallsetupIndicatorDes );
+
+        TInt retrievedIdx = KErrNotFound;
+        TRAPD(errRetrieveIdx, retrievedIdx = aCommand->Params()[0].IntL() )
+
+        TInt retrievedValue = KErrNotFound;
+        TRAPD(errRetrieveValue, retrievedValue = aCommand->Params()[1].IntL() )
+        TRACE_INFO((_L8(" Index retrieved = %d, expected = %d"),
+                        expectedIdx, retrievedIdx))
+
+        const TInt expectedCallsetupValue = 2;
+        if ( errRetrieveIdx == KErrNone && errRetrieveValue == KErrNone
+                && aCommand->Type() == EHFPCmdCIEV && aCommand->FromAG()
+                && expectedIdx == retrievedIdx && retrievedValue
+                == expectedCallsetupValue )
+            {
+            res = ETrue;
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpphonenumberdialing.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,138 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hfpphonenumberdialing.h"
+#include "hfpcommand.h"
+#include "hfpsettings.h"
+#include "debug.h"
+
+CHsHFPPhoneNumberDialing* CHsHFPPhoneNumberDialing::NewL(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPPhoneNumberDialing* self =
+            CHsHFPPhoneNumberDialing::NewLC( aObserver );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CHsHFPPhoneNumberDialing* CHsHFPPhoneNumberDialing::NewLC(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPPhoneNumberDialing* self = new ( ELeave ) CHsHFPPhoneNumberDialing(
+            aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+CHsHFPPhoneNumberDialing::~CHsHFPPhoneNumberDialing()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iSettings )
+        {
+        iSettings->Release();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsHFPPhoneNumberDialing::ProcessCommand( const CHsHFPCommand &aInputCmd,
+        CHsHFPCommand &aOutputCmd )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt res = KErrNone;
+    if ( aInputCmd.FromAG() )
+        {
+        if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdOK )
+            {
+            iWaitingForOK = EFalse;
+            iWaitingForCIEV = ETrue;
+            }
+        else if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdERROR )
+            {
+            iWaitingForOK = EFalse;
+            iObserver->HandleProcedureCompleted( KErrArgument );
+            }
+        else if ( iWaitingForCIEV && IsProperCIEV( &aInputCmd ) )
+            {
+            iWaitingForCIEV = EFalse;
+            iObserver->HandleProcedureCompleted( KErrNone );
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+    else
+        {
+        if ( aInputCmd.Type() == EHFPCmdATD )
+            {
+            iWaitingForOK = ETrue;
+            TRAP( res, CHsHFPCommand::CopyL( aInputCmd, aOutputCmd ) );
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+CHsHFPPhoneNumberDialing::CHsHFPPhoneNumberDialing(
+        MHsHFPFeatureProviderObserver* aObserver ) :
+    iObserver( aObserver )
+    {
+    }
+
+void CHsHFPPhoneNumberDialing::ConstructL()
+    {
+    iSettings = CHsHFPSettings::InstanceL();
+    }
+
+TBool CHsHFPPhoneNumberDialing::IsProperCIEV( const CHsHFPCommand* aCommand )
+    {
+    TRACE_FUNC_ENTRY
+    TBool res = EFalse;
+
+    if ( aCommand->Params().Count() == 2 )
+        {
+        TInt expectedIdx = iSettings->FindIndicatorIndex(
+                KHFPCallsetupIndicatorDes );
+
+        TInt retrievedIdx = KErrNotFound;
+        TRAPD(errRetrieveIdx, retrievedIdx = aCommand->Params()[0].IntL() )
+
+        TInt retrievedValue = KErrNotFound;
+        TRAPD(errRetrieveValue, retrievedValue = aCommand->Params()[1].IntL() )
+        TRACE_INFO((_L8(" Index retrieved = %d, expected = %d"),
+                        expectedIdx, retrievedIdx))
+
+        const TInt expectedCallsetupValue = 2;
+        if ( errRetrieveIdx == KErrNone && errRetrieveValue == KErrNone
+                && aCommand->Type() == EHFPCmdCIEV && aCommand->FromAG()
+                && expectedIdx == retrievedIdx && retrievedValue
+                == expectedCallsetupValue )
+            {
+            res = ETrue;
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpphonestatusinformation.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,253 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hfpphonestatusinformation.h"
+#include "hfpcommand.h"
+#include "hfpsettings.h"
+#include "debug.h"
+
+CHsHFPPhoneStatusInformation* CHsHFPPhoneStatusInformation::NewL(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPPhoneStatusInformation* self = CHsHFPPhoneStatusInformation::NewLC(
+            aObserver );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CHsHFPPhoneStatusInformation* CHsHFPPhoneStatusInformation::NewLC(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPPhoneStatusInformation* self =
+            new ( ELeave ) CHsHFPPhoneStatusInformation( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHFPPhoneStatusInformation::~CHsHFPPhoneStatusInformation()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iSettings )
+        {
+        iSettings->Release();
+        }
+    TRACE_FUNC_ENTRY
+    }
+
+TInt CHsHFPPhoneStatusInformation::ProcessCommand(
+        const CHsHFPCommand &aInputCmd, CHsHFPCommand &aOutputCmd )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt res = KErrNone;
+    if ( aInputCmd.FromAG() )
+        {
+        if ( aInputCmd.Type() == EHFPCmdCIEV )
+            {
+            TRAP( res, HandleIndicatorL( &aInputCmd ) );
+            }
+        else if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdOK )
+            {
+            iWaitingForOK = EFalse;
+            iWaitingForCOPSFromAG = ETrue;
+            aOutputCmd.SetType( EHFPCmdCOPS );
+            aOutputCmd.SetMode( ECmdModeRead );
+
+            }
+        else if ( iWaitingForCOPSFromAG && aInputCmd.Type() == EHFPCmdCOPS )
+            {
+            iWaitingForCOPSFromAG = EFalse;
+            iObserver->HandleProcedureCompleted( KErrNone );
+            }
+
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+    else
+        {
+        if ( aInputCmd.Type() == EHFPCmdCOPS )
+            {
+            iWaitingForOK = ETrue;
+            TRAP(res, CHsHFPCommand::CopyL( aInputCmd, aOutputCmd ));
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+TBool CHsHFPPhoneStatusInformation::IsCallOngoing()
+    {
+    TRACE_FUNC_ENTRY
+    TInt index = iSettings->FindIndicatorIndex( KHFPCallIndicatorDes );
+    TRACE_FUNC_EXIT
+    if ( index != KErrNotFound )
+        {
+        return ( iSettings->iSettingsArr[index].Int() == 1 ? ETrue : EFalse );
+        }
+    else
+        {
+        return EFalse;
+        }
+    }
+
+CHsHFPPhoneStatusInformation::CHsHFPPhoneStatusInformation(
+        MHsHFPFeatureProviderObserver* aObserver ) :
+    iObserver( aObserver )
+    {
+    }
+
+void CHsHFPPhoneStatusInformation::ConstructL()
+    {
+    TRACE_FUNC_ENTRY
+    iSettings = CHsHFPSettings::InstanceL();
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPPhoneStatusInformation::HandleIndicatorL(
+        const CHsHFPCommand* aCommand )
+    {
+    TRACE_FUNC_ENTRY
+    if ( aCommand->Params().Count() != 2 )
+        {
+        User::Leave( KErrArgument );        
+        }
+    
+    THFPIndicatorDes indicatorBuf =
+            iSettings->iSettingsArr[aCommand->Params()[0].IntL()].Des();
+
+    TRACE_INFO( (_L8("INDICATOR before: %S - value: %d "), &indicatorBuf,
+                    iSettings->iSettingsArr[aCommand->Params()[0].IntL()].Int() ) );
+    TRACE_INFO( (_L8("INDICATOR after: %S - value: %d "), &indicatorBuf,
+                    aCommand->Params()[1].IntL() ) );
+
+    if ( indicatorBuf.Compare( KHFPCallIndicatorDes ) == 0 )
+        {
+        TRACE_INFO(_L8("KHFPCallIndicatorDes"))
+        HandleCallIndicatorL( aCommand );
+        }
+    else if ( indicatorBuf.Compare( KHFPServiceIndicatorDes ) == 0 )
+        {
+        TRACE_INFO(_L8("KHFPServiceIndicatorDes"))
+        HandleServiceIndicatorL( aCommand );
+        }
+    else if ( indicatorBuf.Compare( KHFPCallsetupIndicatorDes ) == 0 )
+        {
+        TRACE_INFO(_L8("KHFPCallsetupIndicatorDes"))
+        HandleCallsetupIndicatorL( aCommand );
+        }
+    else if ( indicatorBuf.Compare( KHFPCall_setupIndicatorDes ) == 0 )
+        {
+        TRACE_INFO(_L8("KHFPCall_setupIndicatorDes"))
+        }
+    else if ( indicatorBuf.Compare( KHFPCallheldIndicatorDes ) == 0 )
+        {
+        TRACE_INFO(_L8("KHFPCallheldIndicatorDes"))
+        HandleCallheldIndicatorL( aCommand );
+        }
+    else if ( indicatorBuf.Compare( KHFPSignalIndicatorDes ) == 0 )
+        {
+        TRACE_INFO(_L8("KHFPSignalIndicatorDes"))
+        HandleSignalIndicatorL( aCommand );
+        }
+    else if ( indicatorBuf.Compare( KHFPRoamIndicatorDes ) == 0 )
+        {
+        TRACE_INFO(_L8("KHFPRoamIndicatorDes"))
+        HandleRoamingIndicatorL( aCommand );
+        }
+    else if ( indicatorBuf.Compare( KHFPBattchgIndicatorDes ) == 0 )
+        {
+        TRACE_INFO(_L8("KHFPBattchgIndicatorDes"))
+        HandleBatteryIndicatorL( aCommand );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPPhoneStatusInformation::HandleCallIndicatorL(
+        const CHsHFPCommand* aCommand )
+    {
+    TRACE_FUNC_ENTRY
+    iSettings->iSettingsArr[aCommand->Params()[0].IntL()].SetValueL(
+            aCommand->Params()[1].Des() );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPPhoneStatusInformation::HandleServiceIndicatorL(
+        const CHsHFPCommand* aCommand )
+    {
+    TRACE_FUNC_ENTRY
+    iSettings->iSettingsArr[aCommand->Params()[0].IntL()].SetValueL(
+            aCommand->Params()[1].Des() );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPPhoneStatusInformation::HandleCallsetupIndicatorL(
+        const CHsHFPCommand* aCommand )
+    {
+    TRACE_FUNC_ENTRY
+    iSettings->iSettingsArr[aCommand->Params()[0].IntL()].SetValueL(
+            aCommand->Params()[1].Des() );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPPhoneStatusInformation::HandleCallheldIndicatorL(
+        const CHsHFPCommand* aCommand )
+    {
+    TRACE_FUNC_ENTRY
+    iSettings->iSettingsArr[aCommand->Params()[0].IntL()].SetValueL(
+            aCommand->Params()[1].Des() );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPPhoneStatusInformation::HandleSignalIndicatorL(
+        const CHsHFPCommand* aCommand )
+    {
+    TRACE_FUNC_ENTRY
+    iSettings->iSettingsArr[aCommand->Params()[0].IntL()].SetValueL(
+            aCommand->Params()[1].Des() );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPPhoneStatusInformation::HandleRoamingIndicatorL(
+        const CHsHFPCommand* aCommand )
+    {
+    TRACE_FUNC_ENTRY
+    iSettings->iSettingsArr[aCommand->Params()[0].IntL()].SetValueL(
+            aCommand->Params()[1].Des() );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPPhoneStatusInformation::HandleBatteryIndicatorL(
+        const CHsHFPCommand* aCommand )
+    {
+    TRACE_FUNC_ENTRY
+    iSettings->iSettingsArr[aCommand->Params()[0].IntL()].SetValueL(
+            aCommand->Params()[1].Des() );
+    TRACE_FUNC_EXIT
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfpremoteaudiovolumecontrol.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,173 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hfpremoteaudiovolumecontrol.h"
+#include "hfpcommand.h"
+#include "hfpsettings.h"
+#include "debug.h"
+
+CHsHFPRemoteAudioVolumeControl* CHsHFPRemoteAudioVolumeControl::NewL(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPRemoteAudioVolumeControl* self =
+            CHsHFPRemoteAudioVolumeControl::NewLC( aObserver );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CHsHFPRemoteAudioVolumeControl* CHsHFPRemoteAudioVolumeControl::NewLC(
+        MHsHFPFeatureProviderObserver* aObserver )
+    {
+    CHsHFPRemoteAudioVolumeControl* self =
+            new ( ELeave ) CHsHFPRemoteAudioVolumeControl( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+CHsHFPRemoteAudioVolumeControl::~CHsHFPRemoteAudioVolumeControl()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iSettings )
+        {
+        iSettings->Release();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsHFPRemoteAudioVolumeControl::VolumeLevelSynchronization(
+        const CHsHFPCommand &aInputCmd, CHsHFPCommand &aOutputCmd )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt res = KErrNone;
+    if ( aInputCmd.FromAG() )
+        {
+
+        if ( aInputCmd.Type() == EHFPCmdVGS )
+            {
+            iSettings->iVgsLevel = aInputCmd.Params()[0].IntL();
+            }
+        else if ( aInputCmd.Type() == EHFPCmdVGM )
+            {
+            iSettings->iVgmLevel = aInputCmd.Params()[0].IntL();
+            }
+        else if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdOK )
+            {
+            iWaitingForOK = EFalse;
+            iWaitingForVgmOK = ETrue;
+            aOutputCmd.SetType( EHFPCmdVGM );
+            aOutputCmd.SetMode( ECmdModeWrite );
+            RATParamArray params;
+            TBuf8 <KHsHFPMaxVolumeLevelParamSize> vgmLevel;
+            vgmLevel.AppendNum( iSettings->iVgmLevel );
+            res = params.Append( TATParam( vgmLevel ) );
+            aOutputCmd.SetParams( params );
+            }
+        else if ( iWaitingForVgmOK && aInputCmd.Type() == EHFPCmdOK )
+            {
+            iWaitingForVgmOK = EFalse;
+            iVolumeLevelSynchronized = ETrue;
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+    else
+        {
+        res = KErrArgument;
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+void CHsHFPRemoteAudioVolumeControl::Reset()
+    {
+    TRACE_FUNC_ENTRY
+    iVolumeLevelSynchronized = EFalse;
+    iWaitingForOK = ETrue;
+    iWaitingForVgmOK = EFalse;
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsHFPRemoteAudioVolumeControl::ProcessCommand(
+        const CHsHFPCommand &aInputCmd, CHsHFPCommand &aOutputCmd )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt res = KErrNone;
+    if ( !iVolumeLevelSynchronized )
+        {
+        res = VolumeLevelSynchronization( aInputCmd, aOutputCmd );
+        }
+    else if ( aInputCmd.FromAG() )
+        {
+        if ( aInputCmd.Type() == EHFPCmdVGS && aInputCmd.Params().Count() == 1 )
+            {
+            TRAP( res, iSettings->iVgsLevel = aInputCmd.Params()[0].IntL() );
+            }
+        else if ( aInputCmd.Type() == EHFPCmdVGM && aInputCmd.Params().Count() == 1 )
+            {
+            TRAP( res, iSettings->iVgmLevel = aInputCmd.Params()[0].IntL() );
+            }
+        else if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdOK )
+            {
+            iWaitingForOK = EFalse;
+            iObserver->HandleProcedureCompleted( KErrNone );
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+    else
+        {
+        if ( aInputCmd.Type() == EHFPCmdVGS && aInputCmd.Params().Count() == 1 )
+            {
+            iWaitingForOK = ETrue;
+            TRAP( res, iSettings->iVgsLevel = aInputCmd.Params()[0].IntL();
+                    CHsHFPCommand ::CopyL( aInputCmd, aOutputCmd ) );
+            }
+        else if ( aInputCmd.Type() == EHFPCmdVGM && aInputCmd.Params().Count() == 1 )
+            {
+            iWaitingForOK = ETrue;
+            TRAP( res, iSettings->iVgmLevel = aInputCmd.Params()[0].IntL();
+                    CHsHFPCommand::CopyL( aInputCmd, aOutputCmd ) );
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+CHsHFPRemoteAudioVolumeControl::CHsHFPRemoteAudioVolumeControl(
+        MHsHFPFeatureProviderObserver* aObserver ) :
+    iObserver( aObserver ), iWaitingForOK( ETrue )
+    {
+    }
+
+void CHsHFPRemoteAudioVolumeControl::ConstructL()
+    {
+    iSettings = CHsHFPSettings::InstanceL();
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/hfpcod.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,74 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include <btdevice.h>
+
+#include "hfpcod.h"
+#include "debug.h"
+
+CHsHFPCoD* CHsHFPCoD::NewL()
+    {
+
+    CHsHFPCoD *self = CHsHFPCoD::NewLC();
+    CleanupStack::Pop(self);
+
+    return self;
+    }
+
+CHsHFPCoD* CHsHFPCoD::NewLC()
+    {
+
+    CHsHFPCoD *self = new (ELeave) CHsHFPCoD();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+CHsHFPCoD::~CHsHFPCoD()
+    {
+    TRACE_FUNC_ENTRY
+    RestoreOldCod();
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPCoD::SetNewCodL()
+    {
+    TRACE_FUNC_ENTRY
+
+    TBTDeviceClass newDeviceClass = TBTDeviceClass(KHsHFPDeviceClass);
+    TInt err =
+            RProperty::Set(KPropertyUidBluetoothCategory,
+                    KPropertyKeyBluetoothSetDeviceClass,
+                    newDeviceClass.DeviceClass());
+
+    TRACE_INFO( (_L("returned value = %d"), err));
+
+    User::LeaveIfError(err);
+
+    TRACE_FUNC_EXIT
+    }
+
+CHsHFPCoD::CHsHFPCoD()
+    {
+
+    }
+
+void CHsHFPCoD::ConstructL()
+    {
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/hfpprofile.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,106 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hfpprofileplugin.h"
+#include "hfpdatahandler.h"
+#include "hfpsettings.h"
+#include "debug.h"
+
+CHsHFPProfile* CHsHFPProfile::NewL()
+    {
+    CHsHFPProfile *self = CHsHFPProfile::NewLC();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CHsHFPProfile* CHsHFPProfile::NewLC()
+    {
+    CHsHFPProfile *self = new (ELeave) CHsHFPProfile();
+    CleanupStack::PushL(self);
+    self->ContructL();
+    return self;
+    }
+
+CHsHFPProfile::CHsHFPProfile()
+    {
+
+    }
+
+void CHsHFPProfile::ContructL()
+    {
+    TRACE_FUNC_ENTRY
+    iDataHandler = CHsHFPDataHandler::NewL();
+    iSettings = CHsHFPSettings::InstanceL();
+    TRACE_FUNC_EXIT
+    }
+
+CHsHFPProfile::~CHsHFPProfile()
+    {
+    TRACE_FUNC_ENTRY
+    if (iDataHandler)
+        {
+        delete iDataHandler;
+        }
+    if (iSettings)
+        {
+        iSettings->Release();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPProfile::HandleCommandL(const TDesC8& aCommandsIn,
+        TDes8& aCommandsOut, const TBool aFromAG)
+    {
+    TRACE_FUNC_ENTRY
+
+    iDataHandler->ProcessDataL(aCommandsIn, aFromAG, aCommandsOut);
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPProfile::HandleClientDisconnected(TInt aErr)
+    {
+    TRACE_FUNC_ENTRY
+    iDataHandler->HandleClientDisconnected(aErr);
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPProfile::HandleClientConnected(TDes8& aCommandOut)
+    {
+    TRACE_FUNC_ENTRY
+    iDataHandler->HandleClientConnected(aCommandOut);
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPProfile::HandleAcceptCallL(TDes8& aCommandOut)
+    {
+    TRACE_FUNC_ENTRY
+
+    iDataHandler->HandleAcceptCallL(aCommandOut);
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPProfile::HandleReleaseCallL(TDes8& aCommandOut)
+    {
+    TRACE_FUNC_ENTRY
+
+    iDataHandler->HandleReleaseCallL(aCommandOut);
+
+    TRACE_FUNC_EXIT
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/hfpsdp.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,143 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hfpsdp.h"
+#include "debug.h"
+
+CHsHFPSDP* CHsHFPSDP::NewL()
+    {
+    CHsHFPSDP *self = CHsHFPSDP::NewLC();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CHsHFPSDP* CHsHFPSDP::NewLC()
+    {
+    CHsHFPSDP *self = new (ELeave) CHsHFPSDP();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+CHsHFPSDP::CHsHFPSDP()
+    {
+    }
+
+CHsHFPSDP::~CHsHFPSDP()
+    {
+    TRACE_FUNC_ENTRY
+    iSdpDatabase.Close();
+    iSdp.Close();
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPSDP::CreateSdpRecordL()
+    {
+    TRACE_FUNC_ENTRY
+
+    if (iSdpRecordHandle)
+        {
+        User::Leave(KErrAlreadyExists);
+        }
+
+    // create service class id list
+    CSdpAttrValueDES* serviceClassIdList = CSdpAttrValueDES::NewDESL(NULL);
+    CleanupStack::PushL(serviceClassIdList);
+
+    // add Hands-Free UID (0x111E) and Generic Audio UID (0x1203)
+    serviceClassIdList->StartListL()->BuildDESL()->StartListL()->BuildUUIDL(
+            TUUID(KHsHandsFreeUid))->EndListL()->BuildDESL()->StartListL()->BuildUUIDL(
+            TUUID(KHsHfpGenericAudioUid))->EndListL()->EndListL();
+
+    // register record in database
+    iSdpDatabase.CreateServiceRecordL(*serviceClassIdList, iSdpRecordHandle);
+    CleanupStack::PopAndDestroy(serviceClassIdList);
+
+    CSdpAttrValueDES* protocolDescList = CSdpAttrValueDES::NewDESL(NULL);
+    CleanupStack::PushL(protocolDescList);
+
+    // add protocol descriptor list to inform clients about listening channel
+    protocolDescList->StartListL()->BuildDESL()->StartListL()->BuildUUIDL(
+            TUUID(KL2CAPUUID))->EndListL()->BuildDESL()->StartListL()->BuildUUIDL(
+            TUUID(KRFCommUUID))->BuildUintL(TSdpIntBuf<TUint8> (iServicePort))->EndListL()->EndListL();
+
+    // update record in database
+    iSdpDatabase.UpdateAttributeL(iSdpRecordHandle,
+            KSdpAttrIdProtocolDescriptorList, *protocolDescList);
+    CleanupStack::PopAndDestroy(protocolDescList);
+
+    CSdpAttrValueDES* bluetoothProfileDescList = CSdpAttrValueDES::NewDESL(
+            NULL);
+    CleanupStack::PushL(bluetoothProfileDescList);
+
+    // add info of bluetooth profile - headset profile (0x111E) version 1.5 (0x0105)
+    bluetoothProfileDescList->StartListL()->BuildDESL()->StartListL()->BuildUUIDL(
+            TUUID(KHsHandsFreeUid))->BuildUintL(TSdpIntBuf<TUint16> (
+            KHsHfpProfileVersion))->EndListL()->EndListL();
+
+    // update record in database
+    iSdpDatabase.UpdateAttributeL(iSdpRecordHandle,
+            KSdpAttrIdBluetoothProfileDescriptorList,
+            *bluetoothProfileDescList);
+    CleanupStack::PopAndDestroy(bluetoothProfileDescList);
+
+    // set service name and update record
+    iSdpDatabase.UpdateAttributeL(iSdpRecordHandle,
+            KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceName,
+            KHsServiceNameHandsFree);
+
+    // set supported features
+    CSdpAttrValueUint* supportedFeatures = CSdpAttrValueUint::NewUintL(
+            TSdpIntBuf<TUint16> (KHsSupportedFeaturesValue));
+    CleanupStack::PushL(supportedFeatures);
+    iSdpDatabase.UpdateAttributeL(iSdpRecordHandle, KHsSupportedFeaturesUid,
+            *supportedFeatures);
+    CleanupStack::PopAndDestroy(supportedFeatures);
+
+    // set availability to true
+    iSdpDatabase.UpdateAttributeL(iSdpRecordHandle,
+            KSdpAttrIdServiceAvailability, 0xFF);
+    iSdpDatabase.UpdateAttributeL(iSdpRecordHandle,
+            KSdpAttrIdServiceRecordState, 1);
+    TRACE_INFO( _L("HFP SDP registering OK") );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPSDP::DeleteSdpRecordL()
+    {
+    TRACE_FUNC_ENTRY
+
+    if (iSdpRecordHandle)
+        {
+        iSdpDatabase.DeleteRecordL(iSdpRecordHandle);
+        iSdpRecordHandle = 0;
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHFPSDP::ConstructL()
+    {
+    TRACE_FUNC_ENTRY
+
+    User::LeaveIfError(iSdp.Connect());
+
+    User::LeaveIfError(iSdpDatabase.Open(iSdp));
+
+    TRACE_FUNC_EXIT
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/hfpsettings.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,136 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hfpsettings.h"
+#include "hfpcommand.h"
+#include "debug.h"
+
+THsHFPIndicatorSetting::THsHFPIndicatorSetting( const TDesC8& aDes,
+        const TInt aValue )
+    {
+    TRACE_FUNC_ENTRY
+    iDesc.Copy( aDes );
+    iValue = aValue;
+    TRACE_FUNC_EXIT
+    }
+
+void THsHFPIndicatorSetting::SetValueL( const TDesC8& aDesValue )
+    {
+    TRACE_FUNC_ENTRY
+    TLex8 lex( aDesValue );
+
+    TInt parsedValue;
+    User::LeaveIfError( lex.Val( parsedValue ) );
+    SetValue( parsedValue );
+    TRACE_FUNC_EXIT
+    }
+
+void THsHFPIndicatorSetting::SetValue( const TInt aValue )
+    {
+    iValue = aValue;
+    }
+
+TInt THsHFPIndicatorSetting::Int() const
+    {
+    return iValue;
+    }
+
+const THFPIndicatorDes& THsHFPIndicatorSetting::Des() const
+    {
+    return iDesc;
+    }
+
+CHsHFPSettings* CHsHFPSettings::InstanceL()
+    {
+    TRACE_STATIC_FUNC_ENTRY
+    CHsHFPSettings* self = NULL;
+
+    TAny* tlsPtr = Dll::Tls();
+    if ( !tlsPtr )
+        {
+        self = new ( ELeave ) CHsHFPSettings;
+        CleanupStack::PushL( self );
+        self->ConstructL();
+        User::LeaveIfError( Dll::SetTls( self ) );
+        CleanupStack::Pop( self );
+        }
+    else
+        {
+        self = static_cast <CHsHFPSettings*> ( tlsPtr );
+        ++self->iReferenceCounter;
+        }
+
+    TRACE_FUNC_EXIT
+    return self;
+    }
+
+void CHsHFPSettings::Release()
+    {
+    TRACE_FUNC_ENTRY
+    TAny* tlsPtr = Dll::Tls();
+    __ASSERT_DEBUG( tlsPtr != NULL, User::Panic( _L( "HFP Settings error" ),
+                    KErrNotFound ) );
+
+    CHsHFPSettings* self = static_cast <CHsHFPSettings*> ( tlsPtr );
+    if ( --self->iReferenceCounter == 0 )
+        {
+        Dll::FreeTls();
+        delete self;
+        }
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsHFPSettings::FindIndicatorIndex( const TDesC8& aIndicatorDes )
+    {
+    TRACE_FUNC_ENTRY
+    TInt idx = KErrNotFound;
+    for ( TInt i = 0; i < iSettingsArr.Count(); i++ )
+        {
+
+        if ( iSettingsArr[i].Des().Compare( aIndicatorDes ) == 0 )
+            {
+            TRACE_INFO((_L8("Found index = %d"), i ))
+            idx = i;
+            break;
+            }
+
+        }
+    TRACE_FUNC_EXIT
+    return idx;
+    }
+
+CHsHFPSettings::~CHsHFPSettings()
+    {
+    TRACE_FUNC_ENTRY
+    iSettingsArr.Close();
+    TRACE_FUNC_EXIT
+    }
+
+CHsHFPSettings::CHsHFPSettings() :
+    iReferenceCounter( 1 )
+    {
+
+    }
+
+void CHsHFPSettings::ConstructL()
+    {
+    TRACE_FUNC_ENTRY
+    iSettingsArr.AppendL( THsHFPIndicatorSetting( KNullDesC8, 0 ) );
+    TRACE_FUNC_EXIT
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hfpprofile/src/proxy.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,40 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include <e32std.h>
+#include <Implementationproxy.h>
+
+#include "hfpprofileplugin.h" 
+#include "hfpcod.h"
+#include "hfpsdp.h"
+
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY( 0xE0009DD2, CHsHFPSDP::NewL),
+    IMPLEMENTATION_PROXY_ENTRY( 0xE0009DD1, CHsHFPCoD::NewL),
+    IMPLEMENTATION_PROXY_ENTRY(0xE0009DD3, CHsHFPProfile::NewL)
+
+    };
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
+        TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
+;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/data/E259E538.rss	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,60 @@
+#include <RegistryInfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo 
+	{ 
+	dll_uid = 0xE259E538; 
+
+	interfaces = 
+		{
+		INTERFACE_INFO 
+			{ 
+			interface_uid = 0xE0009DC1; 
+				
+			implementations = 	
+				{ 			
+				IMPLEMENTATION_INFO 	
+					{ 
+					implementation_uid = 0xE0009DC7;
+ 
+					version_no = 1;
+					display_name = "HSP implementation";
+					default_data = "hsp";
+					opaque_data = "";
+					}
+				};
+			},
+		INTERFACE_INFO 
+			{ 
+			interface_uid = 0xE0009DC2; 
+				
+			implementations = 	
+				{ 			 				 
+				IMPLEMENTATION_INFO 	
+					{ 
+					implementation_uid = 0xE0009DC5; 
+					version_no = 1;
+					display_name = "HSP CoD implementation";
+					default_data = "hsp_cod";
+					opaque_data = "";
+					}
+				};
+			},
+		INTERFACE_INFO 
+			{ 
+			interface_uid = 0xE0009DC3; 
+				
+			implementations = 	
+				{ 			 				 
+				IMPLEMENTATION_INFO 	
+					{ 
+					implementation_uid = 0xE0009DC4; 
+					
+					version_no = 1;
+					display_name = "HSP Sdp implementation";
+					default_data = "hsp_sdp";
+					opaque_data = "";	
+					} 
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/group/bld.inf	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,23 @@
+/* 
+*
+* Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Original Contributors:
+* Comarch S.A. - original contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+hspprofile.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/group/hspprofile.mmp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,65 @@
+/* 
+*
+* Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Original Contributors:
+* Comarch S.A. - original contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+TARGET		  hspprofile.dll
+TARGETTYPE	  PLUGIN
+UID			 0x10009D8D 0xE259E538
+
+CAPABILITY CAP_ECOM_PLUGIN
+
+SOURCEPATH	..\src
+SOURCE		hspprofile.cpp 
+SOURCE		proxy.cpp
+SOURCE		hspcod.cpp 
+SOURCE		hspsdp.cpp
+SOURCE		hspsettings.cpp
+
+SOURCEPATH ..\src\dataprocessing
+SOURCE		hspcommand.cpp 
+SOURCE		hspcommandparser.cpp 
+SOURCE		hspdatahandler.cpp
+
+SOURCEPATH ..\src\features
+SOURCE		hspcalltermination.cpp
+SOURCE		hspfeaturemanager.cpp 
+SOURCE		hspincomingcallacceptance.cpp 
+SOURCE		hspremoteaudiovolumecontrol.cpp
+
+
+USERINCLUDE	 ..\inc
+USERINCLUDE	 ..\inc\features
+USERINCLUDE	 ..\inc\dataprocessing
+
+SYSTEMINCLUDE   \epoc32\include
+SYSTEMINCLUDE   \epoc32\include\platform
+SYSTEMINCLUDE   \epoc32\include\ecom
+SYSTEMINCLUDE   \epoc32\include\headsetsimulator
+
+LIBRARY		 euser.lib
+LIBRARY 	 ecom.lib 
+LIBRARY 	 btdevice.lib
+LIBRARY 	 sdpdatabase.lib
+LIBRARY 	 bluetooth.lib 
+LIBRARY 	 bafl.lib
+
+SOURCEPATH ..\data
+START RESOURCE E259E538.rss
+	TARGET hspprofile.rsc
+END
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/inc/dataprocessing/hspcommand.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,247 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+#ifndef HSPCOMMAND_H_
+#define HSPCOMMAND_H_
+
+#include <e32base.h>
+
+/** Helpful constants */
+_LIT8(KHsHSPCommandPrefix,"AT");
+_LIT8(KHsHSPCommandSuffix,"\r\n");
+_LIT8(KHsHSPVGSCommand,"+VGS");
+_LIT8(KHsHSPVGMCommand,"+VGM");
+_LIT8(KHsHSPCKPDCommand,"+CKPD");
+_LIT8(KHsHSPOKCommand,"\r\nOK\r\n");
+_LIT8(KHsHSPERRORCommand,"\r\nERROR\r\n");
+_LIT8(KHsHSPRINGCommand,"\r\nRING\r\n");
+_LIT8(KHsHSPParamsSeparator,",");
+_LIT8(KHsHSPIndicatorParamsSeparator,"),");
+_LIT8(KHsHSPCommandSeparator,"\r\n\r\n");
+_LIT8(KHsHSPATTestModeDes,"=?");
+_LIT8(KHsHSPATWriteModeDes,"=");
+_LIT8(KHsHSPATReadModeDes,"?");
+_LIT8(KHsHSPATTestModeDesAG,"=?");
+_LIT8(KHsHSPATWriteModeDesAG,": ");
+_LIT8(KHsHSPATReadModeDesAG,"?");
+
+/** Max size of AT command's param */
+const TInt KHsHSPMaxATParamSize = 256;
+
+/**
+ * @brief TATParam represents singular AT command parameter.
+ */
+class TATParam
+{
+public:
+
+    /**
+     * Constructor
+     * 
+     * @param aValue 8-bit param descriptor
+     */
+    TATParam( const TDesC8& aValue );
+
+    /**
+     * Returns the parameter as text.
+     * @return the non-modifiable pointer descriptor
+     */
+    const TDesC8& Des() const;
+
+    /**
+     * Returns the paramater as integer value (if conversion is possible)
+     * 
+     * @return integer value. If conversion is impossible then leave occures
+     */
+    TInt IntL() const;
+
+private:
+
+    /** Buffer for AT param */
+    TBuf8 <KHsHSPMaxATParamSize> iValue;
+};
+
+/** Array of AT params */
+typedef RArray <TATParam> RATParamArray;
+
+/** HSP's supported commands */
+enum THsHSPCommandType
+{
+    /** <cr><lf> OK <cr><lf> */
+    EHSPCmdOK,
+    /** <cr><lf> ERROR <cr><lf> */
+    EHSPCmdERROR,
+    /** <cr><lf> RING <cr><lf> */
+    EHSPCmdRING,
+    /** +VGS */
+    EHSPCmdVGS,
+    /** +VGM */
+    EHSPCmdVGM,
+    /** +CKPD */
+    EHSPCmdCKPD,
+    /** Other (unsupported) command */
+    EHSPCmdUnknown
+};
+
+/** AT command's mode */
+enum THsHSPCommandMode
+{
+    /** = */
+    ECmdModeWrite,
+    /** ? */
+    ECmdModeRead,
+    /** =? */
+    ECmdModeTest,
+    /** empty without params */
+    ECmdModeNormal,
+    /** empty with params */
+    ECmdModeOther,
+
+    ECmdUnknownMode
+};
+
+/**
+ *  @brief AT command representation 
+ */
+class CHsHSPCommand : public CBase
+{
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @return class instance
+     */
+    static CHsHSPCommand* NewL();
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @return class instance
+     */
+    static CHsHSPCommand* NewLC();
+
+    /** 
+     * Destructor
+     */
+    ~CHsHSPCommand();
+
+public:
+
+    /** Sets command's type 
+     * 
+     * @param aType type
+     * @return error code
+     */
+    TInt SetType( const THsHSPCommandType aType );
+
+    /** Sets command's mode
+     * 
+     * @param aMode  mode
+     * @return error code
+     */
+    TInt SetMode( const THsHSPCommandMode aMode );
+
+    /** Sets command's params 
+     * 
+     * @param aParams array of params
+     * @return error code
+     */
+    TInt SetParams( const RATParamArray& aParams );
+
+    /** Sets command's source
+     * 
+     * @param aFromAG denotes if command sent by AG
+     */
+    void SetSource( const TBool aFromAG );
+
+    /**
+     * Returns command as a 8-bit descriptor
+     * 
+     * @param aBuf buffer
+     */
+    void ToDes8( TDes8& aBuf ) const;
+
+    /** Getter for command's type */
+    THsHSPCommandType Type() const;
+
+    /** Getter for command's mode */
+    THsHSPCommandMode Mode() const;
+
+    /** Getter for command's source - denotes if sent by AG */
+    TBool FromAG() const;
+
+    /** Getter for command's array of params */
+    const RATParamArray Params() const;
+
+    /**
+     * Clones CHsHSPCommand object
+     * 
+     * @param aCmdFrom source
+     * @param aCmdTo destination 
+     */
+    static void CopyL( const CHsHSPCommand* aCmdFrom, CHsHSPCommand& aCmdTo );
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsHSPCommand();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+
+    /** Param array's granularity */
+    const TInt KParamArrayGranularity = 3;
+
+    /** Max length of command's type represented as descriptor */
+    const TInt KTypeDesMaxLength = 9;
+
+    /** Max length of command's mode represented as descriptor */
+    const TInt KModeDesMaxLength = 3;
+
+    /** Max length of command's params represented as descriptor */
+    const TInt KParamsDesMaxLength = 200;
+
+    /** Command's type */
+    THsHSPCommandType iType;
+
+    /** Command's mode */
+    THsHSPCommandMode iMode;
+
+    /** Command's source. Denotes if command was sent from AG */
+    TBool iFromAG;
+
+    /** Command's params */
+    RATParamArray iParams;
+
+    /** Command's type as a descriptor */
+    RBuf8 iTypeDes;
+
+    /** Command's mode as a descriptor */
+    RBuf8 iModeDes;
+
+    /** Command's params as a descriptor */
+    RBuf8 iParamsDes;
+};
+
+#endif /* HSPCOMMAND_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/inc/dataprocessing/hspcommandparser.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,108 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSPCOMMANDPARSER_H_
+#define HSPCOMMANDPARSER_H_
+
+#include <e32base.h>
+
+#include "hspcommand.h"
+
+/**
+ *  @brief Parser for AT commands 
+ */
+class CHsHSPParser : public CBase
+{
+public:
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @return class instance
+     */
+    static CHsHSPParser* NewL();
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @return class instance
+     */
+    static CHsHSPParser* NewLC();
+
+    /** 
+     * Destructor
+     */
+    ~CHsHSPParser();
+
+public:
+
+    /**
+     * Parses 8-bit descriptor into AT command
+     * 
+     * @param aBufCommand descriptor to be parsed
+     * @param aFromAG is data passed from AG
+     * @param aCommand result (AT command)
+     */
+    void ParseL( const TDesC8 &aBufCommand, const TBool aFromAG,
+            CHsHSPCommand& aCommand );
+
+private:
+
+    /**
+     * Contructor for performing 1st stage construction
+     */
+    CHsHSPParser();
+
+    /**
+     * Constructor for performing 2nd stage contruction
+     */
+    void ConstructL();
+
+private:
+
+    /**
+     * Retrieves command's mode from descriptor data
+     * 
+     * @param aCommand descriptor to be parsed
+     * @param aFromAG denotes if data sent from AG
+     * @return command's mode 
+     */
+    THsHSPCommandMode RetrieveModeL( const TDesC8 &aCommand,
+            const TBool aFromAG );
+
+    /**
+     * Retrieves command's type from descriptor data
+     * 
+     * @param aCommand descriptor to be parsed
+     * @return command's type 
+     */
+    THsHSPCommandType RetrieveTypeL( const TDesC8 &aCommand );
+
+    /**
+     * Retrieves command's params from descriptor data
+     * 
+     * @param aCommand descriptor to be parsed
+     * @param aCmdMode command's mode
+     * @param aParams reference for array of params
+     */
+    void RetrieveParamsL( const TDesC8 &aCommand,
+            const THsHSPCommandMode aCmdMode, RATParamArray& aParams );
+
+};
+
+#endif /* HSPCOMMANDPARSER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/inc/dataprocessing/hspdatahandler.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,143 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSPDATAHANDLER_H_
+#define HSPDATAHANDLER_H_
+
+#include <e32base.h>
+
+class CHsHSPParser;
+class CHsHSPCommand;
+class CHsHSPFeatureManager;
+class CDesC8ArrayFlat;
+
+/** Useful constants */
+_LIT8(KHSPCallAcceptCmd, "AT+CKPD=200\r\n");
+_LIT8(KHSPCallReleaseCmd, "AT+CKPD=200\r\n");
+
+
+/**
+ * @brief Manages AT commands handling
+ */
+class CHsHSPDataHandler : public CBase
+{
+public:
+
+    /**
+     * Two-phase constructor
+     * @return instance of class
+     */
+    static CHsHSPDataHandler* NewL();
+
+    /**
+     * Two-phase constructor
+     * @return instance of class
+     */
+    static CHsHSPDataHandler* NewLC();
+
+    /**
+     * Destructor
+     */
+    ~CHsHSPDataHandler();
+
+public:
+    /**
+     * Profile's method for handling AT Commands
+     * 
+     * @param aDataIn descriptor containing AT command
+     * @param aFromAG denotes if datac was sent by AG
+     * @param aDataOut response for passed command
+     * 
+     */
+    void ProcessDataL( const TDesC8& aDataIn, const TBool aFromAG,
+            TDes8& aDataOut );
+
+    /**
+     * Profile's method for handling AG client's disconnection
+     * 
+     * @param aErr disconnection reason
+     */
+    void HandleClientDisconnected( TInt aErr );
+
+    /**
+     * Profile's method for handling AG client connection
+     * 
+     * @param aCommandOut AT response
+     */
+    void HandleClientConnected( TDes8& aCommandOut );
+
+    /**
+     * Profile's method for accepting incoming call
+     * 
+     * @param aCommandOut AT response
+     */
+    void HandleAcceptCallL( TDes8& aCommandOut );
+
+    /**
+     * Profile's method for releasing ongoing call
+     * 
+     * @param aCommandOut AT response
+     */
+    void HandleReleaseCallL( TDes8& aCommandOut );
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsHSPDataHandler();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+    /**
+     * Splits multiple AT commands 
+     * 
+     * @param aCommands 8-bit descriptor containing AT command(s)
+     * @return pointer to array of desciptors (each element is a separate AT command)
+     */
+    CDesC8ArrayFlat* SplitCommandsL( const TDesC8 &aCommands );
+
+    /**
+     * Common funcionality for HandleAcceptCallL() and HandleReleaseCallL().
+     * 
+     * @param aCommand descriptor containing AT command
+     * @param aResponse response for passed command
+     * 
+     */
+    void PerformRequestL( const TDesC8& aCommand, TDes8& aResponse );
+
+private:
+
+    /** Command array's granularity */
+    const TInt KCommandArrayGranularity = 2;
+
+    /** Temporary buffer's max length */
+    const TInt KTmpBufferLength = 256;
+
+    /** AT command parser, owned */
+    CHsHSPParser* iParser;
+
+    /** Feature manager, owned */
+    CHsHSPFeatureManager* iFeatureManager;
+
+};
+
+#endif /* HSPDATAHANDLER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/inc/debug.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,190 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSPPLUGIN_LOGGING_H
+#define HSPPLUGIN_LOGGING_H
+
+#include <e32base.h>
+#include "debugconfig.h"
+
+enum TPanic
+{
+    EInvalidNullState = 1,
+};
+
+#ifdef PRJ_ENABLE_TRACE
+
+#ifdef PRJ_FILE_TRACE
+#include <flogger.h>
+#else
+#include <e32debug.h>
+#endif
+
+NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow
+{
+public:
+    void Overflow( TDes16& /*aDes*/)
+        {
+        }
+};
+
+NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow
+{
+public:
+    void Overflow( TDes8& /*aDes*/)
+        {
+        }
+};
+
+inline void Trace( TRefByValue <const TDesC16> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    RBuf16 theFinalString;
+    theFinalString.Create( KMaxLogLineLength );
+    theFinalString.Append( KTracePrefix16 );
+    TOverflowTruncate16 overflow;
+    theFinalString.AppendFormatList( aFmt, list, &overflow );
+    RDebug::Print( theFinalString );
+    theFinalString.Close();
+#endif
+    }
+
+inline void Trace( TRefByValue <const TDesC8> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START(list, aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    TOverflowTruncate8 overflow;
+    RBuf8 buf8;
+    buf8.Create( KMaxLogLineLength );
+    buf8.Append( KTracePrefix8 );
+    buf8.AppendFormatList( aFmt, list, &overflow );
+
+    RBuf16 buf16;
+    buf16.Create( KMaxLogLineLength );
+    buf16.Copy( buf8 );
+    TRefByValue <const TDesC> tmpFmt( _L("%S") );
+    RDebug::Print( tmpFmt, &buf16 );
+    buf8.Close();
+    buf16.Close();
+#endif
+    }
+
+inline void TracePanic( char* aFile, TInt aLine, TInt aPanicCode,
+        const TDesC& aPanicCategory )
+    {
+    TPtrC8 fullFileName( (const TUint8*) aFile );
+    TPtrC8 fileName( fullFileName.Ptr() + fullFileName.LocateReverse( '\\' )
+            + 1 );
+    RBuf8 buf;
+    buf.Create( KMaxLogLineLength );
+    buf.Append( KPanicPrefix8 );
+    buf.AppendFormat( _L8("%d at line %d in file %S"), aPanicCode, aLine,
+            &fileName );
+    Trace( buf );
+    buf.Close();
+    User::Panic( aPanicCategory, aPanicCode );
+    }
+
+inline void TraceLeave( char* aFile, TInt aLine, TInt aReason )
+    {
+    TPtrC8 fullFileName( (const TUint8*) aFile );
+    TPtrC8 fileName( fullFileName.Ptr() + fullFileName.LocateReverse( '\\' )
+            + 1 );
+    RBuf8 buf;
+    buf.Create( KMaxLogLineLength );
+    buf.Append( KLeavePrefix8 );
+    buf.AppendFormat( _L8("%d at line %d in file %S"), aReason, aLine,
+            &fileName );
+    Trace( buf );
+    buf.Close();
+    User::Leave( aReason );
+    }
+
+#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;}
+
+#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;}
+
+#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;}
+
+#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;}
+
+#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;}
+
+#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);}
+
+#define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory)
+
+#define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define LEAVE_IF_NULL(PTR) {if (!PTR) TraceLeave(__FILE__, __LINE__, KErrGeneral);}
+
+#define LEAVE(REASON) {TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define TRACE_STATIC_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}}
+
+#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}}
+
+#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncExitFormat8, &ptr8);}}
+
+#define TRACE_STATIC_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncFormat8, &ptr8);}}
+
+#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncThisFormat8, &ptr8, this);}}
+
+#define RETURN_IF_ERR(ERR) {if(ERR) {TPtrC8 ptr8((TUint8*)__FILE__); Trace(_L8(" RETURN %d at file %S line %d"), ERR, &ptr8, __LINE__); return ERR;}}
+
+#else // PRJ_ENABLE_TRACE not defined
+#define TRACE_INFO(p)
+
+#define TRACE_ERROR(p)
+
+#define TRACE_STATE(p)
+
+#define TRACE_WARNING(p)
+
+#define TRACE_INFO_SEG(p)
+
+#define TRACE_ASSERT(GUARD, CODE)
+
+#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);}
+
+#define LEAVE_IF_ERROR(REASON) {static_cast<void>(User::LeaveIfError(REASON));}
+
+#define LEAVE_IF_NULL(PTR) {static_cast<void>(User::LeaveIfNull(PTR));}
+
+#define LEAVE(REASON) {static_cast<void>(User::Leave(REASON));}
+
+#define TRACE_STATIC_FUNC_ENTRY
+
+#define TRACE_FUNC_ENTRY
+
+#define TRACE_FUNC_EXIT
+
+#define TRACE_STATIC_FUNC
+
+#define TRACE_FUNC
+
+#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;}
+#endif // PRJ_ENABLE_TRACE
+#endif // HSPPLUGIN_LOGGING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/inc/debugconfig.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,56 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HFPPLUGIN_DEBUGCONFIG_H
+#define HFPPLUGIN_DEBUGCONFIG_H
+
+#include "prjconfig.h"
+
+/**
+ * Custom logging variations.
+ */
+#ifdef PRJ_FILE_TRACE
+_LIT(KLogFile,"HSPPLUGIN.txt");
+_LIT(KLogDir,"HeadsetSimulator HSP Profile");
+#endif
+
+#ifdef PRJ_ENABLE_TRACE
+_LIT(KTracePrefix16, "[HSP] ");
+_LIT8(KTracePrefix8, "[HSP] ");
+_LIT8(KFuncFormat8, "><%S");
+_LIT8(KFuncThisFormat8, "><%S, [0x%08X]");
+_LIT8(KFuncEntryFormat8, ">%S");
+_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]");
+_LIT8(KFuncExitFormat8, "<%S");
+
+_LIT8(KPanicPrefix8, "PANIC code ");
+_LIT8(KLeavePrefix8, "LEAVE code ");
+#endif
+
+//needed??
+_LIT(KPanicCategory, "HSPPLUGIN"); // need it also for release 
+
+const TInt KMaxLogLineLength = 512;
+
+#define KPRINTERROR        0x00000001 // Tracing level: error
+#define KPRINTINFO        0x00000002 // Tracing level: function trace
+#define KPRINTSTATE        0x00000004 // Tracing level: state machine info
+#define KPRINTWARNING   0x00000008 // Tracing level: warning
+const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING;
+
+#endif // HFPPLUGIN_DEBUGCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/inc/features/hspcalltermination.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,108 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSPCALLTERMINATEPROC_H_
+#define HSPCALLTERMINATEPROC_H_
+
+#include <e32base.h>
+
+#include "hspfeaturecommons.h"
+
+class CHsHSPCommand;
+class CHsHSPSettings;
+
+/**
+ * @brief Represents "Terminate a call" feature
+ */
+class CHsHSPCallTerminationProc : public CBase, public MHsHSPProcedureCommons
+{
+public:
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHSPCallTerminationProc* NewL(
+            MHsHSPFeatureProviderObserver* aObserver );
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHSPCallTerminationProc* NewLC(
+            MHsHSPFeatureProviderObserver* aObserver );
+
+    /**
+     * Destructor
+     */
+    ~CHsHSPCallTerminationProc();
+
+public:
+    //Methods inherited from MHsHSPProcedureCommons
+    TInt ProcessCommand( const CHsHSPCommand* aInputCmd,
+            CHsHSPCommand &aOutputCmd );
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aObserver feature observer
+     */
+    CHsHSPCallTerminationProc( MHsHSPFeatureProviderObserver* aObserver );
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+
+    /**
+     * Checks if received command is proper +CKPD
+     * 
+     * @param aCommand AT command
+     * @return ETrue if command is AT+CKPD=200<cr><lf>, otherwise EFalse
+     */
+    TBool IsCKPD200( const CHsHSPCommand* aCommand );
+
+    /**
+     * Informs observer about procedure's completion
+     * 
+     * @param aErr error value
+     */
+    void InformObserver( TInt aErr );
+
+private:
+
+    /** Procedure's type */
+    const THSPProcedure iHSPProc = EHSPCallTerminate;
+
+    /** Pointer to observer, not owned */
+    MHsHSPFeatureProviderObserver* iObserver;
+
+    /** Denotes if the next expected command is  <cr><lf> OK <cr><lf> */
+    TBool iWaitingForOK;
+
+};
+
+#endif /* HSPCALLTERMINATEPROC_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/inc/features/hspfeaturecommons.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,75 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSPFEATURECOMMONS_H_
+#define HSPFEATURECOMMONS_H_
+
+#include <e32base.h>
+
+class CHsHSPCommand;
+
+/** Profile's procedures */
+enum THSPProcedure
+{
+    /** Voice call termination */
+    EHSPCallTerminate,
+    /** Voice call acceptance */
+    EHSPCallAccept,
+    /** Remote volume control */
+    EHSPVolumeControl,
+    /** Other state */
+    EHSPIdle
+};
+
+/**
+ * @brief Observer for feature's classes
+ */
+class MHsHSPFeatureProviderObserver
+{
+public:
+    /**
+     * Callback method indicates that procedure is finished
+     * 
+     * @param aErr KErrNone if procedure finishes successfully, 
+     *        otherwise one of the system-wide error codes
+     * @param aProcedure type of procedure
+     */
+    virtual void HandleProcedureCompleted( TInt aErr,
+            const THSPProcedure aProcedure ) = 0
+};
+
+/**
+ * @brief Abstract class for particular features 
+ */
+class MHsHSPProcedureCommons
+{
+public:
+
+    /**
+     * Processes AT command and prepares response
+     * 
+     * @param aInputCmd input AT command
+     * @param aOutputCmd response
+     * @return KErrNone if successful, otherwise one of the system-wide error
+     *         codes
+     */
+    virtual TInt ProcessCommand( const CHsHSPCommand* aInputCmd,
+            CHsHSPCommand &aOutputCmd ) = 0;
+};
+
+#endif /* HSPFEATURECOMMONS_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/inc/features/hspfeaturemanager.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,134 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSPFEATUREMANAGER_H_
+#define HSPFEATUREMANAGER_H_
+
+#include "hspfeaturecommons.h"
+#include "hspsettings.h"
+
+class CHsHSPCommand;
+class CHsHSPCallTerminationProc;
+class CHsHSPIncomingCallAcceptance;
+class CHsHSPRemoteAudioVolumeControl;
+
+/**
+ * @brief Manages features supported by profile.
+ * 
+ * Delegates data handling to appropriate procedure and holds current state.
+ */
+class CHsHSPFeatureManager : public CBase, public MHsHSPFeatureProviderObserver
+{
+public:
+    /**
+     * Two-phased constructor.
+     * 
+     * @return instance of class
+     */
+    static CHsHSPFeatureManager* NewL();
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @return instance of class
+     */
+    static CHsHSPFeatureManager* NewLC();
+
+    /**
+     * Destructor
+     */
+    ~CHsHSPFeatureManager();
+
+public:
+    /**
+     * Decides which procedure should be started.
+     * 
+     * @param aATCommandIn input AT command
+     * @param aATCommandOut response
+     */
+    void PerformDataProcessingL( const CHsHSPCommand* aATCommandIn,
+            CHsHSPCommand& aATCommandOut );
+
+    /**
+     * Handles AG's client disconnection event
+     * 
+     * @param aErr disconnection reason
+     */
+    void HandleClientDisconnected( TInt aErr );
+
+    /**
+     * Handles AG's client connection event
+     * 
+     * @param aCommandOut AT response
+     */
+    void HandleClientConnected( TDes8& aCommandOut );
+
+public:
+    //Methods inherited from MHsHSPFeatureProviderObserver
+    void HandleProcedureCompleted( TInt aErr, const THSPProcedure aProcedure );
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsHSPFeatureManager();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+
+    /**
+     * Handles <cr><lf> OK <cr><lf> command.
+     * 
+     * @param aATCommandIn input AT command
+     * @param aATCommandOut response
+     */
+    void HandleOKCommandL( const CHsHSPCommand* aATCommandIn,
+            CHsHSPCommand& aATCommandOut );
+
+    /**
+     * Handles +CKPD command 
+     * 
+     * @param aATCommandIn input AT command
+     * @param aATCommandOut response
+     */
+    void HandleCKPDCommandL( const CHsHSPCommand* aATCommandIn,
+            CHsHSPCommand& aATCommandOut );
+private:
+
+    /** Ongoing procedure */
+    THSPProcedure iProcedureStarted;
+
+    /** Pointer to 'Terminate a call' feature. Owned */
+    CHsHSPCallTerminationProc* iCallTermProc;
+
+    /** Pointer to 'Accept an incoming voice call' feature. Owned */
+    CHsHSPIncomingCallAcceptance* iCallAcceptProc;
+
+    /** Pointer to 'Remote audio volume control' feature. Owned */
+    CHsHSPRemoteAudioVolumeControl* iVolumeControl;
+
+    /** Profile's settings */
+    CHsHSPSettings* iSettings;
+
+};
+
+#endif /* HSPFEATUREMANAGER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/inc/features/hspincomingcallacceptance.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,112 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSPINCOMINGCALLACCEPTANCE_H
+#define HSPINCOMINGCALLACCEPTANCE_H
+
+#include <e32base.h>
+
+#include "hspfeaturecommons.h"
+
+class CHsHSPCommand;
+class CHsHSPSettings;
+
+/**
+ * @brief Represents "Accept an incoming voice call" feature
+ */
+class CHsHSPIncomingCallAcceptance : public CBase,
+        public MHsHSPProcedureCommons
+{
+public:
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHSPIncomingCallAcceptance* NewL(
+            MHsHSPFeatureProviderObserver* aObserver );
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHSPIncomingCallAcceptance* NewLC(
+            MHsHSPFeatureProviderObserver* aObserver );
+
+    /**
+     * Destructor.
+     */
+    ~CHsHSPIncomingCallAcceptance();
+
+public:
+    //Methods inherited from MHsHSPProcedureCommons
+    TInt ProcessCommand( const CHsHSPCommand* aInputCmd,
+            CHsHSPCommand& aOutputCmd );
+
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aObserver feature observer
+     */
+    CHsHSPIncomingCallAcceptance( MHsHSPFeatureProviderObserver* aObserver );
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+    /**
+     * Checks if received command is proper +CKPD
+     * 
+     * @param aCommand AT command
+     * @return ETrue if command is AT+CKPD=200<cr><lf>, otherwise EFalse
+     */
+    TBool IsCKPD200( const CHsHSPCommand* aCommand );
+
+    /**
+     * Informs observer about procedure's completion
+     * 
+     * @param aErr error value
+     */
+    void InformObserver( TInt aErr );
+
+private:
+
+    /** Procedure's type */
+    const THSPProcedure iHSPProc = EHSPCallAccept;
+
+    /** Pointer to observer, not owned */
+    MHsHSPFeatureProviderObserver* iObserver;
+
+    /** Denotes if the next expected command is  <cr><lf> OK <cr><lf> */
+    TBool iWaitingForOK;
+
+    /** Denotes if the next expected command is  AT+CKPD=200<cr><lf> */
+    TBool iWaitingForCKPD200;
+
+};
+
+#endif // HSPINCOMINGCALLACCEPTANCE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/inc/features/hspremoteaudiovolumecontrol.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,142 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSPREMOTEAUDIOVOLUMECONTROL_H
+#define HSPREMOTEAUDIOVOLUMECONTROL_H
+
+#include <e32base.h>
+
+#include "hspfeaturecommons.h"
+
+class CHsHSPCommand;
+class CHsHSPSettings;
+
+/**
+ * @brief Represents "Remote audio volume control" feature
+ */
+class CHsHSPRemoteAudioVolumeControl : public CBase,
+        public MHsHSPProcedureCommons
+{
+public:
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHSPRemoteAudioVolumeControl* NewL(
+            MHsHSPFeatureProviderObserver* aObserver );
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aObserver feature observer
+     * 
+     * @return instance of class
+     */
+    static CHsHSPRemoteAudioVolumeControl* NewLC(
+            MHsHSPFeatureProviderObserver* aObserver );
+
+    /**
+     * Destructor.
+     */
+    ~CHsHSPRemoteAudioVolumeControl();
+
+public:
+
+    /** 
+     * Resets volume settings
+     */
+    void Reset();
+
+public:
+    //Methods inherited from MHsHFPProcedureCommons
+    TInt ProcessCommand( const CHsHSPCommand* aInputCmd,
+            CHsHSPCommand &aOutputCmd );
+
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aObserver feature observer
+     */
+    CHsHSPRemoteAudioVolumeControl( MHsHSPFeatureProviderObserver* aObserver );
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+
+    /**
+     * Informs observer about procedure's completion
+     * 
+     * @param aErr error value
+     */
+    void InformObserver( TInt aErr );
+
+    /**
+     * Sets volume level. Value is retrieved from AT command.
+     * 
+     * @param aCmd AT command
+     */
+    void SetVolumeLevelL( const CHsHSPCommand* aCmd );
+
+    /**
+     * Sets mic gain level. Value is retrieved from AT command.
+     * 
+     * @param aCmd AT command
+     */
+    void SetMicGainLevelL( const CHsHSPCommand* aCmd );
+
+    /**
+     * Checks if passed AT command's params are valid. Leaves if invalid.
+     * 
+     * @param aCmd AT command
+     */
+    void CheckParamsL( const CHsHSPCommand* aCmd );
+private:
+
+    /** Procedure's type */
+    const THSPProcedure iHSPProc = EHSPVolumeControl;
+
+    /** Pointer to observer, not owned */
+    MHsHSPFeatureProviderObserver* iObserver;
+
+    /** Pointer to profile's settings */
+    CHsHSPSettings* iSettings;
+
+    /** 
+     * Denotes if the next expected command is  <cr><lf> OK <cr><lf>
+     * after +VGM handled 
+     */
+    TBool iWaitingForVgmOK;
+
+    /** 
+     * Denotes if the next expected command is <cr><lf> OK <cr><lf> 
+     * after +VGS handled 
+     */
+    TBool iWaitingForVgsOK;
+
+};
+
+#endif // HSPREMOTEAUDIOVOLUMECONTROL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/inc/hspcod.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,66 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSPCOD_H_
+#define HSPCOD_H_
+
+#include <hscodpluginbase.h>
+
+/** HSP Class of Device */
+const TUint32 KHsHSPDeviceClass = 0x200404;
+
+/**
+ * @brief Manages Class of Device.
+ */
+class CHsHSPCoD : public CHsCoDBase
+{
+public:
+    /**
+     * Two-phase constructor
+     * 
+     * @return instance of class
+     */
+    static CHsHSPCoD* NewL();
+
+    /**
+     * Two-phase constructor
+     * 
+     * @return instance of class
+     */
+    static CHsHSPCoD* NewLC();
+
+    /**
+     * Destructor
+     */
+    ~CHsHSPCoD();
+
+public:
+
+    /**
+     * Sets new Class of Device
+     */
+    void SetNewCodL();
+
+private:
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+};
+
+#endif /* HSPCOD_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/inc/hspprofileplugin.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,91 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef __HSPPROFILE_H__
+#define __HSPPROFILE_H__
+
+#include <e32base.h>    
+#include <e32std.h>
+#include <hsprofilepluginbase.h>
+
+class CHsHSPDataHandler;
+class CHsHSPSettings;
+
+/** HSP Ecom implementation Uid */
+const TUid KHsHSPProfileImplementationUid =
+    {
+    0xE0009DC7
+    };
+
+
+/**
+ * @brief Implementation of Headset profile
+ */
+class CHsHSPProfile : public CHsProfileBase
+{
+public:
+    /**
+     * Two-phase constructor
+     * @return instance of class
+     */
+    static CHsHSPProfile* NewL();
+
+    /**
+     * Two-phase constructor
+     * @return instance of class
+     */
+    static CHsHSPProfile* NewLC();
+
+    /**
+     * Destructor
+     */
+    ~CHsHSPProfile();
+
+public:
+    // Methods derived from MHsProfileBase
+    void HandleCommandL( const TDesC8 &aCommandsIn, TDes8 &aCommandsOut,
+            const TBool aFromAG = ETrue );
+
+    void HandleClientDisconnected( TInt aErr );
+
+    void HandleClientConnected( TDes8& aCommandOut );
+
+    void HandleAcceptCallL( TDes8& aCommandOut );
+
+    void HandleReleaseCallL( TDes8& aCommandOut );
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsHSPProfile();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ContructL();
+
+private:
+    /** AT command handler. Owned */
+    CHsHSPDataHandler* iDataHandler;
+
+    /**  Profile's settings   */
+    CHsHSPSettings* iSettings;
+};
+
+#endif  // __HSPPROFILE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/inc/hspsdp.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,100 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSPSDP_H_
+#define HSPSDP_H_
+
+#include <btsdp.h>
+#include <hssdppluginbase.h>
+
+/** Headset Uid */
+const TInt KHsHeadsetUid = 0x1131;
+
+/** Generic Audio Uid */
+const TInt KHsGenericAudioUid = 0x1203;
+
+/** Profile's UID */
+const TInt KHsHeadsetProfileUid = 0x1108;
+
+/** Profile's version */
+const TInt KHsHeadsetProfileVersion = 0x0102;
+
+/** Supported remote audio volume control UID */
+const TInt KHsRemoteAudioVolumeControl = 0x0302;
+/** Service name */
+_LIT(KHsServiceNameHeadset, "Headset");
+
+/**
+ * @brief Manages SDP record
+ */
+class CHsHSPSDP : public CHsSdpBase
+{
+public:
+    /**
+     * Two-phase constructor
+     * 
+     * @return instance of class
+     */
+    static CHsHSPSDP* NewL();
+
+    /**
+     * Two-phase constructor
+     * 
+     * @return instance of class
+     */
+    static CHsHSPSDP* NewLC();
+
+    /**
+     * Destructor
+     */
+    ~CHsHSPSDP();
+
+public:
+    /**
+     * Creates SDP record
+     */
+    void CreateSdpRecordL();
+
+    /**
+     * Destroys SDP record
+     */
+    void DeleteSdpRecordL();
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsHSPSDP();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+    /** Session to the SDP */
+    RSdp iSdp;
+
+    /** Subsession to the SDP */
+    RSdpDatabase iSdpDatabase;
+
+    /** Handle to SDP record */
+    TSdpServRecordHandle iSdpRecordHandle;
+};
+
+#endif /* HSPSDP_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/inc/hspsettings.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,104 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSPSETTINGS_H_
+#define HSPSETTINGS_H_
+
+#include <e32base.h>
+
+/**
+ * @brief Singleton class representing profile's settings
+ */
+class CHsHSPSettings : public CBase
+{
+public:
+
+    /**
+     * Returns pointer to singleton class
+     * 
+     * @return class instance
+     */
+    static CHsHSPSettings* InstanceL();
+
+    /**
+     * Decrements reference counter. Deletes singleton if there are no references.
+     */
+    void Release();
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsHSPSettings();
+
+    /**
+     * Destructor
+     */
+    ~CHsHSPSettings();
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+public:
+
+    /**
+     * Sets speaker volume level
+     * 
+     * @param aLevel new level
+     */
+    void SetSpeakerVolumeLevel( const TInt aLevel );
+
+    /**
+     * Sets speaker volume level
+     * 
+     * @param aLevel new level
+     */
+    void SetMicGainLevel( const TInt aLevel );
+
+    /**
+     * Updates call status
+     * 
+     * @param aIsCallOngoing denotes if audio call is ongoing
+     */
+    void UpdateCallStatus( const TBool aIsCallOngoing );
+
+    
+    /**
+     * Getter for 'CallOngoing' status
+     * 
+     * @return ETrue if audio call is ongoing, otherwise EFalse
+     */
+     TBool CallOngoing() const;
+    
+private:
+
+    /** Speaker volume level */
+    TInt iSpeakerVolumeLevel;
+
+    /** Microphone gain level */
+    TInt iMicGainLevel;
+
+    /** Denotes if voice call is ongoing */
+    TBool iCallOngoing;
+
+    /** Reference counter */
+    TInt iReferenceCounter;
+};
+#endif /* HSPSETTINGS_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/inc/prjconfig.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,46 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HSPPLUGIN_PRJCONFIG_H
+#define HSPPLUGIN_PRJCONFIG_H
+
+/**
+ * Traces are enabled in _DEBUG build, by default.
+ */
+#ifdef _DEBUG
+#define PRJ_ENABLE_TRACE
+#endif
+
+/**
+ * traces to file if this is defined.
+ */
+//#define PRJ_FILE_TRACE
+
+
+/**
+ * build the project for module test purpose if this is defined
+ */
+//#define PRJ_MODULETEST_BUILD
+
+/**
+ * build the project using stubs to replace the dependencies if this is defined
+ */
+//#define PRJ_USE_STUB
+
+
+#endif // HSPPLUGIN_PRJCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/sis/hspprofile.pkg	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,29 @@
+;
+; Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of the License "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Original Contributors:
+; Comarch S.A. - original contribution.
+;
+; Contributors:
+;
+; Description:
+;
+
+
+; UID is the dll's UID
+;
+#{"hspprofileplugin DLL"},(0xE259E538),1,0,0
+
+;Localised Vendor name
+%{"Vendor-EN"}
+
+;Unique Vendor name
+:"Vendor"
+
+"\epoc32\release\armv5\udeb\hspprofile.dll"		  -"!:\sys\bin\hspprofile.dll"
+"\epoc32\data\Z\Resource\plugins\hspprofile.rsc"  -"!:\Resource\Plugins\hspprofile.rsc"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/src/dataprocessing/hspcommand.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,231 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include <badesca.h>
+
+#include "hspcommand.h"
+#include "debug.h"
+
+TATParam::TATParam( const TDesC8& aValue )
+
+    {
+    iValue.Copy( aValue );
+    }
+
+const TDesC8& TATParam::Des() const
+    {
+    return iValue;
+    }
+
+TInt TATParam::IntL() const
+    {
+    TLex8 lex( iValue );
+    TInt res = KErrNotFound;
+    User::LeaveIfError( lex.Val( res ) );
+
+    return res;
+
+    }
+
+CHsHSPCommand* CHsHSPCommand::NewL()
+    {
+    CHsHSPCommand *self = CHsHSPCommand::NewLC();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+CHsHSPCommand* CHsHSPCommand::NewLC()
+    {
+
+    CHsHSPCommand *self = new ( ELeave ) CHsHSPCommand();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHSPCommand::~CHsHSPCommand()
+    {
+    iParams.Close();
+    iModeDes.Close();
+    iParamsDes.Close();
+    iTypeDes.Close();
+    }
+
+TInt CHsHSPCommand::SetType( const THsHSPCommandType aType )
+    {
+    iType = aType;
+
+    switch ( iType )
+        {
+        case EHSPCmdRING:
+            iTypeDes.Copy( KHsHSPRINGCommand );
+            break;
+        case EHSPCmdVGS:
+            iTypeDes.Copy( KHsHSPVGSCommand );
+            break;
+        case EHSPCmdVGM:
+            iTypeDes.Copy( KHsHSPVGMCommand );
+            break;
+        case EHSPCmdCKPD:
+            iTypeDes.Copy( KHsHSPCKPDCommand );
+            break;
+        default:
+            return KErrArgument;
+
+        }
+    return KErrNone;
+    }
+
+TInt CHsHSPCommand::SetMode( const THsHSPCommandMode aMode )
+    {
+    iMode = aMode;
+    switch ( iMode )
+        {
+        case ECmdModeRead:
+            iModeDes.Copy( KHsHSPATReadModeDes );
+            break;
+        case ECmdModeWrite:
+            iModeDes.Copy( KHsHSPATWriteModeDes );
+            break;
+        case ECmdModeTest:
+            iModeDes.Copy( KHsHSPATTestModeDes );
+            break;
+        case ECmdModeNormal:
+            iModeDes.Copy( KNullDesC8 );
+            break;
+        case ECmdModeOther:
+            iModeDes.Copy( KNullDesC8 );
+            break;
+        default:
+            return KErrArgument;
+        }
+
+    return KErrNone;
+    }
+
+TInt CHsHSPCommand::SetParams( const RATParamArray& aParams )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt res = KErrNone;
+    if ( aParams.Count() > 0 )
+        {
+        iParams.Reset();
+        iParams = aParams;
+
+        for ( TInt i = 0; i < iParams.Count() - 1; i++ )
+            {
+
+            iParamsDes.Append( iParams[i].Des() );
+            iParamsDes.Append( KHsHSPParamsSeparator );
+            }
+
+        iParamsDes.Append( iParams[iParams.Count() - 1].Des() );
+
+        }
+    else
+        res = KErrArgument;
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+void CHsHSPCommand::SetSource( const TBool aFromAG )
+    {
+    iFromAG = aFromAG;
+    }
+
+void CHsHSPCommand::ToDes8( TDes8& aBuf ) const
+    {
+
+    if ( iMode == ECmdModeNormal )
+        {
+        aBuf.Copy( KHsHSPCommandPrefix );
+        aBuf.Append( iTypeDes );
+        aBuf.Append( KHsHSPCommandSuffix );
+        }
+
+    else if ( iType != EHSPCmdUnknown )
+        {
+        aBuf.Copy( KHsHSPCommandPrefix );
+        aBuf.Append( iTypeDes );
+        aBuf.Append( iModeDes );
+        aBuf.Append( iParamsDes );
+        aBuf.Append( KHsHSPCommandSuffix );
+        }
+    else
+        {
+        aBuf.Zero();
+        }
+
+    TRACE_INFO((_L8("COMMAND TO DES: %S"),&aBuf));
+    }
+
+THsHSPCommandType CHsHSPCommand::Type() const
+    {
+    return iType;
+    }
+
+THsHSPCommandMode CHsHSPCommand::Mode() const
+    {
+    return iMode;
+    }
+
+TBool CHsHSPCommand::FromAG() const
+    {
+    return iFromAG;
+    }
+
+const RATParamArray CHsHSPCommand::Params() const
+    {
+    return iParams;
+    }
+
+void CHsHSPCommand::CopyL( const CHsHSPCommand* aCmdFrom, CHsHSPCommand& aCmdTo )
+    {
+    aCmdTo.iMode = aCmdFrom->iMode;
+    aCmdTo.iType = aCmdFrom->iType;
+
+    aCmdTo.iParams.Reset();
+    for ( TInt i = 0; i < aCmdFrom->iParams.Count(); i++ )
+        {
+        aCmdTo.iParams.AppendL( aCmdFrom->iParams[i] );
+        }
+
+    aCmdTo.iFromAG = aCmdFrom->iFromAG;
+
+    aCmdTo.iModeDes.Copy( aCmdFrom->iModeDes );
+    aCmdTo.iTypeDes.Copy( aCmdFrom->iTypeDes );
+    aCmdTo.iParamsDes.Copy( aCmdFrom->iParamsDes );
+
+    }
+
+CHsHSPCommand::CHsHSPCommand() :
+    iType( EHSPCmdUnknown ), iParams( KParamArrayGranularity )
+    {
+
+    }
+
+void CHsHSPCommand::ConstructL()
+    {
+    iModeDes.CreateL( KModeDesMaxLength );
+    iTypeDes.CreateL( KTypeDesMaxLength );
+    iParamsDes.CreateL( KParamsDesMaxLength );
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/src/dataprocessing/hspcommandparser.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,293 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include <badesca.h>
+
+#include "hspcommandparser.h"
+#include "debug.h"
+
+CHsHSPParser* CHsHSPParser::NewL()
+    {
+    CHsHSPParser *self = CHsHSPParser::NewLC();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+CHsHSPParser* CHsHSPParser::NewLC()
+    {
+
+    CHsHSPParser *self = new ( ELeave ) CHsHSPParser();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHSPParser::~CHsHSPParser()
+    {
+
+    }
+
+void CHsHSPParser::ParseL( const TDesC8& aBufCommand, const TBool aFromAG,
+        CHsHSPCommand& aCommand )
+    {
+    TRACE_FUNC_ENTRY
+
+    aCommand.SetSource( aFromAG );
+
+    THsHSPCommandType type = EHSPCmdUnknown;
+
+    type = RetrieveTypeL( aBufCommand );
+
+    User::LeaveIfError( aCommand.SetType( type ) );
+
+    if ( type == EHSPCmdOK || type == EHSPCmdERROR || type == EHSPCmdRING )
+        {
+        User::LeaveIfError( aCommand.SetMode( ECmdModeNormal ) );
+        RATParamArray params( 1 );
+        User::LeaveIfError( aCommand.SetParams( params ) );
+
+        }
+    else
+        {
+        THsHSPCommandMode mode = ECmdUnknownMode;
+        mode = RetrieveModeL( aBufCommand, aFromAG );
+        User::LeaveIfError( aCommand.SetMode( mode ) );
+
+        RATParamArray params( 4 );
+
+        RetrieveParamsL( aBufCommand, mode, params );
+        User::LeaveIfError( aCommand.SetParams( params ) );
+
+        }
+
+    TRACE_FUNC_EXIT
+
+    }
+
+CHsHSPParser::CHsHSPParser()
+    {
+
+    }
+
+void CHsHSPParser::ConstructL()
+    {
+
+    }
+
+THsHSPCommandMode CHsHSPParser::RetrieveModeL( const TDesC8 &aCommand,
+        const TBool aFromAG )
+    {
+    TRACE_FUNC_ENTRY
+
+    THsHSPCommandMode res = ECmdUnknownMode;
+
+    if ( aFromAG )
+        {
+        if ( aCommand.Find( KHsHSPATTestModeDesAG ) != KErrNotFound )
+            {
+            res = ECmdModeTest;
+            }
+        else if ( aCommand.Find( KHsHSPATReadModeDesAG ) != KErrNotFound )
+            {
+            res = ECmdModeRead;
+            }
+        else if ( aCommand.Find( KHsHSPATWriteModeDesAG ) != KErrNotFound )
+            {
+            res = ECmdModeWrite;
+            }
+
+        }
+    else
+        {
+        if ( aCommand.Find( KHsHSPATTestModeDes ) != KErrNotFound )
+            {
+            res = ECmdModeTest;
+            }
+        else if ( aCommand.Find( KHsHSPATReadModeDes ) != KErrNotFound )
+            {
+            res = ECmdModeRead;
+            }
+        else if ( aCommand.Find( KHsHSPATWriteModeDes ) != KErrNotFound )
+            {
+            res = ECmdModeWrite;
+            }
+
+        }
+
+    if ( res == ECmdUnknownMode )
+        {
+
+        User::Leave( KErrArgument );
+        }
+    TRACE_FUNC_EXIT
+    return res;
+
+    }
+
+THsHSPCommandType CHsHSPParser::RetrieveTypeL( const TDesC8 &aCommand )
+    {
+    TRACE_FUNC_ENTRY
+    THsHSPCommandType res = EHSPCmdUnknown;
+    if ( aCommand.Find( KHsHSPOKCommand ) != KErrNotFound )
+        {
+        res = EHSPCmdOK;
+        }
+    else if ( aCommand.Find( KHsHSPERRORCommand ) != KErrNotFound )
+        {
+        res = EHSPCmdERROR;
+        }
+    else if ( aCommand.Find( KHsHSPRINGCommand ) != KErrNotFound )
+        {
+        res = EHSPCmdRING;
+        }
+    else if ( aCommand.Find( KHsHSPVGSCommand ) != KErrNotFound )
+        {
+        res = EHSPCmdVGS;
+        }
+    else if ( aCommand.Find( KHsHSPVGMCommand ) != KErrNotFound )
+        {
+        res = EHSPCmdVGM;
+        }
+    else if ( aCommand.Find( KHsHSPCKPDCommand ) != KErrNotFound )
+        {
+        res = EHSPCmdCKPD;
+        }
+
+    if ( res == EHSPCmdUnknown )
+        User::Leave( KErrArgument );
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+void CHsHSPParser::RetrieveParamsL( const TDesC8 &aCommand,
+        const THsHSPCommandMode aCmdMode, RATParamArray& aParams )
+    {
+    TRACE_FUNC_ENTRY
+
+    RBuf8 buf;
+    buf.CreateL( aCommand );
+    buf.CleanupClosePushL();
+
+    TInt prefixLength = 0;
+    TInt suffixLength = 0;
+
+    TInt modeLength = 0;
+
+    TInt leftOffset = 0;
+    TInt rightOffset = 0;
+
+    TInt startPos = 0;
+    TBool indicatorsFound = EFalse;
+
+    if ( buf.Find( KHsHSPIndicatorParamsSeparator ) != KErrNotFound )
+        {
+        indicatorsFound = ETrue;
+        }
+
+    if ( indicatorsFound )
+        {
+        prefixLength = 9;
+        suffixLength = 2;
+        rightOffset = 2;
+        leftOffset = 1;
+        }
+    else
+        {
+
+        rightOffset = 1;
+        suffixLength = 2;
+
+        switch ( aCmdMode )
+
+            {
+            case ECmdModeTest:
+                {
+                startPos = buf.Find( KHsHSPATTestModeDes );
+                modeLength = 2;
+                }
+                break;
+            case ECmdModeRead:
+                {
+                startPos = buf.Find( KHsHSPATReadModeDes );
+                modeLength = 1;
+                }
+                break;
+            case ECmdModeWrite:
+                {
+                startPos = buf.Find( KHsHSPATWriteModeDes );
+                modeLength = 1;
+
+                if ( startPos == KErrNotFound )
+                    {
+                    startPos = buf.Find( KHsHSPATWriteModeDesAG );
+                    modeLength = 2;
+                    }
+
+                }
+                break;
+            default:
+
+                User::Leave( KErrArgument );
+                break;
+            }
+        }
+
+    if ( startPos != KErrNotFound )
+        {
+        //strip command's prefix
+        buf.Delete( 0, prefixLength + startPos + modeLength );
+
+        //strip command's suffix
+        buf.Delete( buf.Length() - suffixLength, suffixLength );
+        }
+    else
+        User::Leave( KErrArgument );
+
+    while ( buf.Size() > 0 )
+        {
+        TInt pos = 0;
+
+        if ( indicatorsFound )
+            {
+            pos = buf.Find( KHsHSPIndicatorParamsSeparator );
+            }
+        else
+            {
+            pos = buf.Find( KHsHSPParamsSeparator );
+            }
+
+        if ( pos == KErrNotFound )
+            {
+            aParams.AppendL( buf );
+            buf.Zero();
+
+            }
+        else
+            {
+            TPtrC8 ptr = ( buf.Left( pos + leftOffset ) );
+            aParams.AppendL( ptr );
+            buf.Delete( 0, pos + rightOffset );
+            }
+        }
+
+    CleanupStack::PopAndDestroy( &buf );
+    TRACE_FUNC_EXIT
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/src/dataprocessing/hspdatahandler.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,205 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include <badesca.h>
+
+#include "hspdatahandler.h"
+#include "hspcommandparser.h"
+#include "hspcommand.h"
+#include "hspfeaturemanager.h"
+#include "hspsettings.h"
+#include "debug.h"
+
+CHsHSPDataHandler* CHsHSPDataHandler::NewL()
+    {
+
+    CHsHSPDataHandler *self = CHsHSPDataHandler::NewLC();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+CHsHSPDataHandler* CHsHSPDataHandler::NewLC()
+    {
+
+    CHsHSPDataHandler *self = new ( ELeave ) CHsHSPDataHandler();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHSPDataHandler::~CHsHSPDataHandler()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iFeatureManager )
+        {
+        delete iFeatureManager;
+        }
+
+    if ( iParser )
+        {
+        delete iParser;
+        }
+    
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPDataHandler::ProcessDataL( const TDesC8& aDataIn,
+        const TBool aFromAG, TDes8& aDataOut )
+    {
+    TRACE_FUNC_ENTRY
+    if ( aDataIn.Compare( KNullDesC8 ) == 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    aDataOut.Zero();
+
+    CDesC8ArrayFlat* cmdArr = SplitCommandsL( aDataIn );
+    CleanupStack::PushL( cmdArr );
+
+    CHsHSPCommand* cmdIn = CHsHSPCommand::NewL();
+    CleanupStack::PushL( cmdIn );
+
+    CHsHSPCommand* cmdOut = CHsHSPCommand::NewL();
+    CleanupStack::PushL( cmdOut );
+
+    RBuf8 buf, tmpOut;
+    tmpOut.CreateL( KTmpBufferLength );
+    buf.CleanupClosePushL();
+    tmpOut.CleanupClosePushL();
+
+    for ( TInt i = 0; i < cmdArr->Count(); i++ )
+        {
+        buf.CreateL( cmdArr->MdcaPoint( i ) );
+
+        iParser->ParseL( buf, aFromAG, *cmdIn );
+
+        iFeatureManager->PerformDataProcessingL( cmdIn, *cmdOut );
+
+        cmdOut->ToDes8( tmpOut );
+        aDataOut.Append( tmpOut );
+        buf.Close();
+        }
+
+    CleanupStack::PopAndDestroy( &tmpOut );
+    CleanupStack::PopAndDestroy( &buf );
+    CleanupStack::PopAndDestroy( cmdOut );
+    CleanupStack::PopAndDestroy( cmdIn );
+    CleanupStack::PopAndDestroy( cmdArr );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPDataHandler::HandleClientDisconnected( TInt aErr )
+    {
+    iFeatureManager->HandleClientDisconnected( aErr );
+    }
+
+void CHsHSPDataHandler::HandleClientConnected( TDes8& aCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+    iFeatureManager->HandleClientConnected( aCommandOut );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPDataHandler::HandleAcceptCallL( TDes8& aCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+
+    PerformRequestL( KHSPCallAcceptCmd, aCommandOut );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPDataHandler::HandleReleaseCallL( TDes8& aCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+    PerformRequestL( KHSPCallReleaseCmd, aCommandOut );
+    TRACE_FUNC_EXIT
+    }
+
+CHsHSPDataHandler::CHsHSPDataHandler()
+    {
+
+    }
+
+void CHsHSPDataHandler::ConstructL()
+    {
+    TRACE_FUNC_ENTRY
+    iFeatureManager = CHsHSPFeatureManager::NewL();
+    iParser = CHsHSPParser::NewL();
+    TRACE_FUNC_EXIT
+    }
+
+CDesC8ArrayFlat* CHsHSPDataHandler::SplitCommandsL( const TDesC8 &aCommands )
+    {
+    CDesC8ArrayFlat* array = new ( ELeave ) CDesC8ArrayFlat(
+            KCommandArrayGranularity );
+    CleanupStack::PushL( array );
+    RBuf8 buf;
+    buf.CreateL( aCommands );
+    buf.CleanupClosePushL();
+
+    const TInt offset = 2;
+
+    while ( buf.Size() > 0 )
+        {
+        TInt pos = buf.Find( KHsHSPCommandSeparator );
+
+        if ( pos == KErrNotFound )
+            {
+            array->AppendL( buf );
+            buf.Zero();
+            }
+        else
+            {
+
+            TPtrC8 ptr = ( buf.Left( pos + offset ) );
+            array->AppendL( ptr );
+            buf.Delete( 0, pos + offset );
+            }
+        }
+
+    CleanupStack::PopAndDestroy( &buf );
+    CleanupStack::Pop( array );
+
+    return array;
+    }
+
+void CHsHSPDataHandler::PerformRequestL( const TDesC8& aCommand,
+        TDes8& aResponse )
+    {
+    CHsHSPCommand* cmdIn = CHsHSPCommand::NewL();
+    CleanupStack::PushL( cmdIn );
+    CHsHSPCommand* cmdOut = CHsHSPCommand::NewL();
+    CleanupStack::PushL( cmdOut );
+
+    RBuf8 buf;
+    buf.CreateL( aCommand );
+    buf.CleanupClosePushL();
+
+    iParser->ParseL( buf, EFalse, *cmdIn );
+
+    iFeatureManager->PerformDataProcessingL( cmdIn, *cmdOut );
+    cmdOut->ToDes8( aResponse );
+
+    CleanupStack::PopAndDestroy( &buf );
+    CleanupStack::PopAndDestroy( cmdOut );
+    CleanupStack::PopAndDestroy( cmdIn );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/src/features/hspcalltermination.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,112 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hspcalltermination.h"
+#include "hspcommand.h"
+#include "hspsettings.h"
+#include "debug.h"
+
+CHsHSPCallTerminationProc* CHsHSPCallTerminationProc::NewL(
+        MHsHSPFeatureProviderObserver* aObserver )
+    {
+    CHsHSPCallTerminationProc *self = CHsHSPCallTerminationProc::NewLC(
+            aObserver );
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+CHsHSPCallTerminationProc* CHsHSPCallTerminationProc::NewLC(
+        MHsHSPFeatureProviderObserver* aObserver )
+    {
+    CHsHSPCallTerminationProc *self = new ( ELeave ) CHsHSPCallTerminationProc(
+            aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHSPCallTerminationProc::~CHsHSPCallTerminationProc()
+    {
+    }
+
+TInt CHsHSPCallTerminationProc::ProcessCommand( const CHsHSPCommand* aInputCmd,
+        CHsHSPCommand &aOutputCmd )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt res = KErrNone;
+    if ( aInputCmd->FromAG() )
+        {
+        if ( iWaitingForOK && aInputCmd->Type() == EHSPCmdOK )
+            {
+            iWaitingForOK = EFalse;
+            iObserver->HandleProcedureCompleted( KErrNone, EHSPCallTerminate );
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+    else
+        {
+        if ( IsCKPD200( aInputCmd ) )
+            {
+            iWaitingForOK = ETrue;
+            TRAP(res,CHsHSPCommand::CopyL( aInputCmd, aOutputCmd ));
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+CHsHSPCallTerminationProc::CHsHSPCallTerminationProc(
+        MHsHSPFeatureProviderObserver* aObserver ) :
+    iObserver( aObserver )
+    {
+
+    }
+
+void CHsHSPCallTerminationProc::ConstructL()
+    {
+    }
+
+TBool CHsHSPCallTerminationProc::IsCKPD200( const CHsHSPCommand* aCommand )
+    {
+    TBool res = EFalse;
+
+    if ( ( EHSPCmdCKPD == aCommand->Type() )
+            && ( aCommand->Params().Count() == 1 )
+            && ( ( aCommand->Params()[0].Des().Compare( _L8("200") ) ) == 0 ) )
+        {
+        res = ETrue;
+        }
+
+    return res;
+    }
+
+void CHsHSPCallTerminationProc::InformObserver( TInt aErr )
+    {
+    __ASSERT_ALWAYS(iObserver, User::Panic(_L("Observer missing"),KErrGeneral));
+    iObserver->HandleProcedureCompleted( aErr, iHSPProc );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/src/features/hspfeaturemanager.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,248 @@
+/* 
+ * 
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hspfeaturemanager.h"
+#include "hspcalltermination.h"
+#include "hspincomingcallacceptance.h"
+#include "hspremoteaudiovolumecontrol.h"
+#include "hspcommand.h"
+#include "debug.h"
+
+CHsHSPFeatureManager* CHsHSPFeatureManager::NewL()
+    {
+    CHsHSPFeatureManager *self = CHsHSPFeatureManager::NewLC();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+CHsHSPFeatureManager* CHsHSPFeatureManager::NewLC()
+    {
+
+    CHsHSPFeatureManager *self = new ( ELeave ) CHsHSPFeatureManager();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHSPFeatureManager::~CHsHSPFeatureManager()
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iCallTermProc )
+        {
+        delete iCallTermProc;
+        }
+    if ( iCallAcceptProc )
+        {
+        delete iCallAcceptProc;
+        }
+    if ( iVolumeControl )
+        {
+        delete iVolumeControl;
+        }
+
+    if ( iSettings )
+        {
+        iSettings -> Release();
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPFeatureManager::PerformDataProcessingL(
+        const CHsHSPCommand* aATCommandIn, CHsHSPCommand& aATCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+    switch ( aATCommandIn->Type() )
+        {
+        case EHSPCmdOK:
+            {
+            HandleOKCommandL( aATCommandIn, aATCommandOut );
+            }
+            break;
+        case EHSPCmdERROR:
+            {
+            //No implementation needed
+            }
+            break;
+
+        case EHSPCmdRING:
+            {
+            User::LeaveIfNull( iCallAcceptProc );
+            User::LeaveIfError( iCallAcceptProc->ProcessCommand( aATCommandIn,
+                    aATCommandOut ) );
+            iProcedureStarted = EHSPCallAccept;
+            }
+            break;
+
+        case EHSPCmdVGS:
+            {
+            if ( !aATCommandIn ->FromAG() )
+                iProcedureStarted = EHSPVolumeControl;
+
+            User::LeaveIfNull( iVolumeControl );
+            User::LeaveIfError( iVolumeControl->ProcessCommand( aATCommandIn,
+                    aATCommandOut ) );
+            }
+            break;
+        case EHSPCmdVGM:
+            {
+            if ( !aATCommandIn ->FromAG() )
+                iProcedureStarted = EHSPVolumeControl;
+
+            User::LeaveIfNull( iVolumeControl );
+            User::LeaveIfError( iVolumeControl->ProcessCommand( aATCommandIn,
+                    aATCommandOut ) );
+            }
+            break;
+        case EHSPCmdCKPD:
+            {
+            HandleCKPDCommandL( aATCommandIn, aATCommandOut );
+            }
+            break;
+        default:
+            User::Leave( KErrArgument );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPFeatureManager::HandleClientDisconnected( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iVolumeControl )
+        {
+        iVolumeControl->Reset();
+        }
+
+    iSettings ->UpdateCallStatus( EFalse );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPFeatureManager::HandleClientConnected( TDes8& aCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPFeatureManager::HandleProcedureCompleted( TInt aErr,
+        const THSPProcedure aProcedure )
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( KErrNone == aErr )
+        {
+        switch ( aProcedure )
+            {
+            case EHSPCallTerminate:
+                iSettings -> UpdateCallStatus( EFalse );
+                TRACE_INFO(_L("Completed: Call release"))
+                iProcedureStarted = EHSPIdle;
+                break;
+
+            case EHSPCallAccept:
+                iSettings -> UpdateCallStatus( ETrue );
+                TRACE_INFO(_L("Completed: Call accept"))
+                iProcedureStarted = EHSPIdle;
+                break;
+
+            case EHSPVolumeControl:
+                TRACE_INFO(_L("Completed: Volume control"))
+                break;
+            }
+
+        }
+    TRACE_FUNC_EXIT
+    }
+
+CHsHSPFeatureManager::CHsHSPFeatureManager()
+    {
+
+    }
+
+void CHsHSPFeatureManager::ConstructL()
+    {
+    TRACE_FUNC_ENTRY
+    iCallTermProc = CHsHSPCallTerminationProc::NewL( this );
+    iCallAcceptProc = CHsHSPIncomingCallAcceptance::NewL( this );
+    iVolumeControl = CHsHSPRemoteAudioVolumeControl::NewL( this );
+    iSettings = CHsHSPSettings::InstanceL();
+    iProcedureStarted = EHSPIdle;
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPFeatureManager::HandleOKCommandL( const CHsHSPCommand* aATCommandIn,
+        CHsHSPCommand& aATCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iProcedureStarted == EHSPCallTerminate )
+        {
+        TRACE_INFO(_L("iProcedureStarted == EHSPCallTerminate"))
+        User::LeaveIfNull( iCallTermProc );
+        User::LeaveIfError( iCallTermProc->ProcessCommand( aATCommandIn,
+                aATCommandOut ) );
+        }
+    else if ( iProcedureStarted == EHSPCallAccept )
+        {
+        TRACE_INFO(_L("iProcedureStarted == EHSPCallAccept"))
+        User::LeaveIfNull( iCallAcceptProc );
+        User::LeaveIfError( iCallAcceptProc->ProcessCommand( aATCommandIn,
+                aATCommandOut ) );
+        }
+    else if ( iProcedureStarted == EHSPVolumeControl )
+        {
+        TRACE_INFO(_L("iProcedureStarted == EHSPVolumeControl"))
+        User::LeaveIfNull( iVolumeControl );
+        User::LeaveIfError( iVolumeControl->ProcessCommand( aATCommandIn,
+                aATCommandOut ) );
+        }
+
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPFeatureManager::HandleCKPDCommandL(
+        const CHsHSPCommand* aATCommandIn, CHsHSPCommand& aATCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( !iSettings -> CallOngoing() )
+        {
+        iProcedureStarted = EHSPCallAccept;
+        User::LeaveIfNull( iCallAcceptProc );
+        User::LeaveIfError( iCallAcceptProc->ProcessCommand( aATCommandIn,
+                aATCommandOut ) );
+        }
+    else
+        {
+        iProcedureStarted = EHSPCallTerminate;
+        User::LeaveIfNull( iCallTermProc );
+        User::LeaveIfError( iCallTermProc->ProcessCommand( aATCommandIn,
+                aATCommandOut ) );
+        }
+
+    TRACE_FUNC_EXIT
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/src/features/hspincomingcallacceptance.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,121 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hspincomingcallacceptance.h"
+#include "hspcommand.h"
+#include "hspsettings.h"
+#include "debug.h"
+
+CHsHSPIncomingCallAcceptance* CHsHSPIncomingCallAcceptance::NewL(
+        MHsHSPFeatureProviderObserver* aObserver )
+    {
+    CHsHSPIncomingCallAcceptance* self = CHsHSPIncomingCallAcceptance::NewLC(
+            aObserver );
+    CleanupStack::Pop( self );
+    return self;
+    }
+CHsHSPIncomingCallAcceptance* CHsHSPIncomingCallAcceptance::NewLC(
+        MHsHSPFeatureProviderObserver* aObserver )
+    {
+    CHsHSPIncomingCallAcceptance* self =
+            new ( ELeave ) CHsHSPIncomingCallAcceptance( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHSPIncomingCallAcceptance::~CHsHSPIncomingCallAcceptance()
+    {
+    }
+
+TInt CHsHSPIncomingCallAcceptance::ProcessCommand(
+        const CHsHSPCommand *aInputCmd, CHsHSPCommand &aOutputCmd )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt res = KErrNone;
+    if ( aInputCmd -> FromAG() )
+        {
+        if ( aInputCmd -> Type() == EHSPCmdRING )
+            {
+            iWaitingForCKPD200 = ETrue;
+            }
+        else if ( iWaitingForOK && aInputCmd -> Type() == EHSPCmdOK )
+            {
+            iWaitingForOK = EFalse;
+            iObserver->HandleProcedureCompleted( KErrNone, EHSPCallAccept );
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+    else
+        {
+        if ( iWaitingForCKPD200 && IsCKPD200( aInputCmd ) )
+            {
+            iWaitingForCKPD200 = EFalse;
+            iWaitingForOK = ETrue;
+            TRAP(res,CHsHSPCommand::CopyL( aInputCmd, aOutputCmd ));
+            }
+        /** Incoming call not indicated by RING command */
+        else if ( !iWaitingForCKPD200 && IsCKPD200( aInputCmd ) )
+            {
+            iWaitingForCKPD200 = EFalse;
+            iWaitingForOK = ETrue;
+            TRAP(res,CHsHSPCommand::CopyL( aInputCmd, aOutputCmd ));
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+CHsHSPIncomingCallAcceptance::CHsHSPIncomingCallAcceptance(
+        MHsHSPFeatureProviderObserver* aObserver ) :
+    iObserver( aObserver )
+    {
+    }
+
+void CHsHSPIncomingCallAcceptance::ConstructL()
+    {
+    }
+
+TBool CHsHSPIncomingCallAcceptance::IsCKPD200( const CHsHSPCommand* aCommand )
+    {
+    TBool res = EFalse;
+
+    if ( ( EHSPCmdCKPD == aCommand -> Type() )
+            && ( aCommand -> Params().Count() == 1 )
+            && ( ( aCommand -> Params()[0].Des().Compare( _L8("200") ) ) == 0 ) )
+        {
+        res = ETrue;
+        }
+
+    return res;
+    }
+
+void CHsHSPIncomingCallAcceptance::InformObserver( TInt aErr )
+    {
+    __ASSERT_ALWAYS(iObserver, User::Panic(_L("Observer missing"),KErrGeneral));
+    iObserver ->HandleProcedureCompleted( aErr, iHSPProc );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/src/features/hspremoteaudiovolumecontrol.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,175 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hspremoteaudiovolumecontrol.h"
+#include "hspcommand.h"
+#include "hspsettings.h"
+#include "debug.h"
+
+CHsHSPRemoteAudioVolumeControl* CHsHSPRemoteAudioVolumeControl::NewL(
+        MHsHSPFeatureProviderObserver* aObserver )
+    {
+    CHsHSPRemoteAudioVolumeControl* self =
+            CHsHSPRemoteAudioVolumeControl::NewLC( aObserver );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CHsHSPRemoteAudioVolumeControl* CHsHSPRemoteAudioVolumeControl::NewLC(
+        MHsHSPFeatureProviderObserver* aObserver )
+    {
+    CHsHSPRemoteAudioVolumeControl* self =
+            new ( ELeave ) CHsHSPRemoteAudioVolumeControl( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHSPRemoteAudioVolumeControl::~CHsHSPRemoteAudioVolumeControl()
+    {
+    if ( iSettings )
+        {
+        iSettings->Release();
+        }
+    }
+
+void CHsHSPRemoteAudioVolumeControl::Reset()
+    {
+    TRACE_FUNC_ENTRY
+
+    iWaitingForVgmOK = EFalse;
+    iWaitingForVgsOK = EFalse;
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsHSPRemoteAudioVolumeControl::ProcessCommand(
+        const CHsHSPCommand* aInputCmd, CHsHSPCommand &aOutputCmd )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt res = KErrNone;
+    if ( aInputCmd -> FromAG() )
+        {
+        if ( aInputCmd -> Type() == EHSPCmdVGS )
+            {
+            TRAP( res, SetVolumeLevelL(aInputCmd));
+            TRACE_INFO(_L("Speaker volume changed : AG initiated"))
+            InformObserver( res );
+            }
+        else if ( aInputCmd -> Type() == EHSPCmdVGM )
+            {
+            TRAP( res, SetMicGainLevelL(aInputCmd));
+            TRACE_INFO(_L("Mic gain changed : AG initiated"))
+            InformObserver( res );
+            }
+        else if ( aInputCmd -> Type() == EHSPCmdOK )
+            {
+            if ( iWaitingForVgmOK )
+                {
+                TRACE_INFO(_L("Mic gain changed"))
+                InformObserver( res );
+                }
+            else if ( iWaitingForVgsOK )
+                {
+                TRACE_INFO(_L("Speaker volume changed"))
+                InformObserver( res );
+                }
+            else
+                res = KErrArgument;
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+    else
+        {
+        if ( aInputCmd-> Type() == EHSPCmdVGS )
+            {
+            iWaitingForVgsOK = ETrue;
+            iWaitingForVgmOK = EFalse;
+            TRAP( res, SetVolumeLevelL(aInputCmd);
+                    CHsHSPCommand ::CopyL( aInputCmd, aOutputCmd ) );
+            }
+        else if ( aInputCmd->Type() == EHSPCmdVGM )
+            {
+            iWaitingForVgmOK = ETrue;
+            iWaitingForVgsOK = EFalse;
+            TRAP( res, SetMicGainLevelL(aInputCmd);
+                    CHsHSPCommand::CopyL( aInputCmd, aOutputCmd ) );
+            }
+        else
+            {
+            res = KErrArgument;
+            }
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+CHsHSPRemoteAudioVolumeControl::CHsHSPRemoteAudioVolumeControl(
+        MHsHSPFeatureProviderObserver* aObserver ) :
+    iObserver( aObserver )
+    {
+    }
+
+void CHsHSPRemoteAudioVolumeControl::ConstructL()
+    {
+    iSettings = CHsHSPSettings::InstanceL();
+    }
+
+void CHsHSPRemoteAudioVolumeControl::InformObserver( TInt aErr )
+    {
+    __ASSERT_ALWAYS(iObserver, User::Panic(_L("Observer missing"),KErrGeneral));
+    iObserver ->HandleProcedureCompleted( aErr, iHSPProc );
+    }
+
+void CHsHSPRemoteAudioVolumeControl::SetVolumeLevelL( 
+        const CHsHSPCommand* aCmd )
+    {
+    TRACE_FUNC_ENTRY
+
+    CheckParamsL( aCmd );
+    iSettings->SetSpeakerVolumeLevel( aCmd->Params()[0].IntL() );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPRemoteAudioVolumeControl::SetMicGainLevelL(
+        const CHsHSPCommand* aCmd )
+    {
+
+    TRACE_FUNC_ENTRY
+
+    CheckParamsL( aCmd );
+    iSettings->SetMicGainLevel( aCmd->Params()[0].IntL() );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPRemoteAudioVolumeControl::CheckParamsL( const CHsHSPCommand* aCmd )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt params = 1;
+    if ( params != aCmd -> Params().Count() )
+        User::Leave( KErrArgument );
+
+    TRACE_FUNC_EXIT
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/src/hspcod.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,62 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include <btdevice.h>
+
+#include "hspcod.h"
+#include "debug.h"
+
+CHsHSPCoD* CHsHSPCoD::NewL()
+    {
+
+    CHsHSPCoD *self = CHsHSPCoD::NewLC();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+CHsHSPCoD* CHsHSPCoD::NewLC()
+    {
+    CHsHSPCoD *self = new ( ELeave ) CHsHSPCoD;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHSPCoD::~CHsHSPCoD()
+    {
+    RestoreOldCod();
+    }
+
+void CHsHSPCoD::ConstructL()
+    {
+
+    }
+
+void CHsHSPCoD::SetNewCodL()
+    {
+    TRACE_FUNC_ENTRY
+
+    TBTDeviceClass newDeviceClass = TBTDeviceClass( KHsHSPDeviceClass );
+    TInt err = RProperty::Set( KPropertyUidBluetoothCategory,
+            KPropertyKeyBluetoothSetDeviceClass, newDeviceClass.DeviceClass() );
+    TRACE_INFO( (_L("error value = %d"), err) )
+    User::LeaveIfError( err );
+
+    TRACE_FUNC_EXIT
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/src/hspprofile.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,102 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hspprofileplugin.h"
+#include "hspdatahandler.h"
+#include "hspsettings.h"
+#include "debug.h"
+
+CHsHSPProfile* CHsHSPProfile::NewL()
+    {
+    CHsHSPProfile *self = CHsHSPProfile::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CHsHSPProfile* CHsHSPProfile::NewLC()
+    {
+    CHsHSPProfile *self = new ( ELeave ) CHsHSPProfile;
+    CleanupStack::PushL( self );
+    self->ContructL();
+    return self;
+    }
+
+CHsHSPProfile::CHsHSPProfile()
+    {
+
+    }
+
+void CHsHSPProfile::ContructL()
+    {
+    iDataHandler = CHsHSPDataHandler::NewL();
+    iSettings = CHsHSPSettings::InstanceL();
+    }
+
+CHsHSPProfile::~CHsHSPProfile()
+    {
+    if ( iDataHandler )
+        {
+        delete iDataHandler;
+        }
+    if ( iSettings )
+        {
+        iSettings->Release();
+        }
+    }
+
+void CHsHSPProfile::HandleCommandL( const TDesC8& aCommandsIn,
+        TDes8& aCommandsOut, const TBool aFromAG )
+    {
+    TRACE_FUNC_ENTRY
+
+    iDataHandler->ProcessDataL( aCommandsIn, aFromAG, aCommandsOut );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPProfile::HandleClientDisconnected( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    iDataHandler->HandleClientDisconnected( aErr );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPProfile::HandleClientConnected( TDes8& aCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+    iDataHandler->HandleClientConnected( aCommandOut );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPProfile::HandleAcceptCallL( TDes8& aCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+
+    iDataHandler->HandleAcceptCallL( aCommandOut );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPProfile::HandleReleaseCallL( TDes8& aCommandOut )
+    {
+    TRACE_FUNC_ENTRY
+
+    iDataHandler->HandleReleaseCallL( aCommandOut );
+
+    TRACE_FUNC_EXIT
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/src/hspsdp.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,148 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hspsdp.h"
+#include "debug.h"
+
+CHsHSPSDP* CHsHSPSDP::NewL()
+    {
+
+    CHsHSPSDP *self = CHsHSPSDP::NewLC();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+CHsHSPSDP* CHsHSPSDP::NewLC()
+    {
+    CHsHSPSDP *self = new ( ELeave ) CHsHSPSDP;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsHSPSDP::CHsHSPSDP()
+    {
+    }
+
+CHsHSPSDP::~CHsHSPSDP()
+    {
+    iSdpDatabase.Close();
+    iSdp.Close();
+    }
+
+void CHsHSPSDP::CreateSdpRecordL()
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iSdpRecordHandle )
+        {
+        User::Leave( KErrAlreadyExists );
+        }
+
+    // create service class id list
+    CSdpAttrValueDES* serviceClassIdList = CSdpAttrValueDES::NewDESL( NULL );
+    CleanupStack::PushL( serviceClassIdList );
+
+    // add Headset UID (0x1131) and Generic Audio UID (0x1203)
+    serviceClassIdList->StartListL()->BuildDESL()->StartListL()
+            ->BuildUUIDL( TUUID( KHsHeadsetUid ) )->EndListL()->BuildDESL()
+            ->StartListL()->BuildUUIDL( TUUID( KHsGenericAudioUid ) )
+            ->EndListL()->EndListL();
+
+    // register record in database
+    iSdpDatabase.CreateServiceRecordL( *serviceClassIdList, iSdpRecordHandle );
+    CleanupStack::PopAndDestroy( serviceClassIdList );
+
+    CSdpAttrValueDES* protocolDescList = CSdpAttrValueDES::NewDESL( NULL );
+    CleanupStack::PushL( protocolDescList );
+
+    // add protocol descriptor list to inform clients about listening channel
+    protocolDescList->StartListL()->BuildDESL()->StartListL()->BuildUUIDL(
+            TUUID( KL2CAPUUID ) )->EndListL()->BuildDESL()->StartListL()
+            ->BuildUUIDL( TUUID( KRFCommUUID ) )->BuildUintL(
+            TSdpIntBuf <TUint8> ( iServicePort ) )->EndListL()->EndListL();
+
+    // update record in database
+    iSdpDatabase.UpdateAttributeL( iSdpRecordHandle,
+            KSdpAttrIdProtocolDescriptorList, *protocolDescList );
+    CleanupStack::PopAndDestroy( protocolDescList );
+
+    CSdpAttrValueDES* bluetoothProfileDescList = CSdpAttrValueDES::NewDESL(
+            NULL );
+    CleanupStack::PushL( bluetoothProfileDescList );
+
+    /**
+     * add info of bluetooth profile - headset profile (0x1108) version 1.2 
+     * (0x0102) 
+     */ 
+    bluetoothProfileDescList->StartListL()->BuildDESL()->StartListL()
+            ->BuildUUIDL( TUUID( KHsHeadsetProfileUid ) )
+            ->BuildUintL( TSdpIntBuf <TUint16> ( KHsHeadsetProfileVersion ) )
+            ->EndListL()->EndListL();
+
+    // update record in database
+    iSdpDatabase.UpdateAttributeL( iSdpRecordHandle,
+            KSdpAttrIdBluetoothProfileDescriptorList, 
+            *bluetoothProfileDescList );
+    CleanupStack::PopAndDestroy( bluetoothProfileDescList );
+
+    // set service name and update record
+    iSdpDatabase.UpdateAttributeL( iSdpRecordHandle,
+            KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceName,
+            KHsServiceNameHeadset );
+
+    // set remote audio volume control to false
+    CSdpAttrValueBoolean* remoteAudioVolumeControl =
+            CSdpAttrValueBoolean::NewBoolL( ETrue );
+    CleanupStack::PushL( remoteAudioVolumeControl );
+    iSdpDatabase.UpdateAttributeL( iSdpRecordHandle,
+            KHsRemoteAudioVolumeControl, *remoteAudioVolumeControl );
+    CleanupStack::PopAndDestroy( remoteAudioVolumeControl );
+
+    // set availability to true
+    iSdpDatabase.UpdateAttributeL( iSdpRecordHandle,
+            KSdpAttrIdServiceAvailability, 0xFF );
+    iSdpDatabase.UpdateAttributeL( iSdpRecordHandle,
+            KSdpAttrIdServiceRecordState, 1 );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPSDP::DeleteSdpRecordL()
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iSdpRecordHandle )
+        {
+        iSdpDatabase.DeleteRecordL( iSdpRecordHandle );
+        iSdpRecordHandle = 0;
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsHSPSDP::ConstructL()
+    {
+    TRACE_FUNC_ENTRY
+
+    User::LeaveIfError( iSdp.Connect() );
+    User::LeaveIfError( iSdpDatabase.Open( iSdp ) );
+
+    TRACE_FUNC_EXIT
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/src/hspsettings.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,93 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "hspsettings.h"
+#include "hspcommand.h"
+#include "debug.h"
+
+CHsHSPSettings* CHsHSPSettings::InstanceL()
+    {
+    CHsHSPSettings* self = NULL;
+
+    TAny* tlsPtr = Dll::Tls();
+    if ( !tlsPtr )
+        {
+        self = new ( ELeave ) CHsHSPSettings;
+        CleanupStack::PushL( self );
+        self->ConstructL();
+        User::LeaveIfError( Dll::SetTls( self ) );
+        CleanupStack::Pop( self );
+        }
+    else
+        {
+        self = static_cast <CHsHSPSettings*> ( tlsPtr );
+        ++self->iReferenceCounter;
+        }
+
+    return self;
+    }
+
+void CHsHSPSettings::Release()
+    {
+    TAny* tlsPtr = Dll::Tls();
+    __ASSERT_DEBUG( tlsPtr, User::Panic( _L( "HSP Settings error" ),
+                    KErrNotFound ) );
+
+    CHsHSPSettings* self = static_cast <CHsHSPSettings*> ( tlsPtr );
+    if ( --self->iReferenceCounter == 0 )
+        {
+        Dll::FreeTls();
+        delete self;
+        }
+    }
+
+CHsHSPSettings::CHsHSPSettings() :
+    iReferenceCounter( 1 )
+    {
+
+    }
+
+CHsHSPSettings::~CHsHSPSettings()
+    {
+    }
+
+void CHsHSPSettings::ConstructL()
+    {
+
+    }
+
+void CHsHSPSettings::SetSpeakerVolumeLevel( const TInt aLevel )
+    {
+    iSpeakerVolumeLevel = aLevel;
+    }
+
+void CHsHSPSettings::SetMicGainLevel( const TInt aLevel )
+    {
+    iMicGainLevel = aLevel;
+    }
+
+void CHsHSPSettings::UpdateCallStatus( const TBool aIsCallOngoing )
+    {
+    iCallOngoing = aIsCallOngoing;
+    }
+
+TBool CHsHSPSettings::CallOngoing() const
+    {
+    return iCallOngoing;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/src/proxy.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,39 @@
+/* 
+ *
+ * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Original Contributors:
+ * Comarch S.A. - original contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include <e32std.h>
+#include <Implementationproxy.h>
+
+#include "hspprofileplugin.h" 
+#include "hspcod.h"
+#include "hspsdp.h"
+
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY(0xE0009DC4, CHsHSPSDP::NewL),
+IMPLEMENTATION_PROXY_ENTRY(0xE0009DC5, CHsHSPCoD::NewL),
+IMPLEMENTATION_PROXY_ENTRY(0xE0009DC7, CHsHSPProfile::NewL)
+    };
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
+        TInt& aTableCount )
+    {
+    aTableCount = sizeof( ImplementationTable ) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
+;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/remotecontroller/eabi/hsremotecontrolleru.def	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,28 @@
+EXPORTS
+	_ZN19CHsRemoteController11ReqTurnOnHsERK7TDesC16S2_S2_ @ 1 NONAME
+	_ZN19CHsRemoteController12ReqSendAnyAtERK7TDesC16 @ 2 NONAME
+	_ZN19CHsRemoteController12ReqTurnOffHsEv @ 3 NONAME
+	_ZN19CHsRemoteController13ReqAcceptCallEv @ 4 NONAME
+	_ZN19CHsRemoteController13ReqSetMicGainERK7TDesC16 @ 5 NONAME
+	_ZN19CHsRemoteController14ReqReleaseCallEv @ 6 NONAME
+	_ZN19CHsRemoteController15ReqDisconnectAGEv @ 7 NONAME
+	_ZN19CHsRemoteController16DisconnectFromHsEv @ 8 NONAME
+	_ZN19CHsRemoteController17ConnectHsDevAddrLERK10TBTDevAddrRK5TUUID @ 9 NONAME
+	_ZN19CHsRemoteController17ConnectHsDevNameLERK7TDesC16RK5TUUID @ 10 NONAME
+	_ZN19CHsRemoteController19ReqSetSpeakerVolumeERK7TDesC16 @ 11 NONAME
+	_ZN19CHsRemoteController20CancelConnectingToHsEv @ 12 NONAME
+	_ZN19CHsRemoteController21ReqConnectWithDevAddrERK10TBTDevAddr @ 13 NONAME
+	_ZN19CHsRemoteController21ReqConnectWithDevNameERK7TDesC16 @ 14 NONAME
+	_ZN19CHsRemoteController27ReqConnectWithLastConnectedEv @ 15 NONAME
+	_ZN19CHsRemoteController4NewLEP13MHsRCObserver @ 16 NONAME
+	_ZN19CHsRemoteController5NewLCEP13MHsRCObserver @ 17 NONAME
+	_ZN19CHsRemoteControllerD0Ev @ 18 NONAME
+	_ZN19CHsRemoteControllerD1Ev @ 19 NONAME
+	_ZN19CHsRemoteControllerD2Ev @ 20 NONAME
+	_ZTI14CHsRCBTManager @ 21 NONAME
+	_ZTI19CHsRemoteController @ 22 NONAME
+	_ZTI21CHsRCDeviceDiscoverer @ 23 NONAME
+	_ZTV14CHsRCBTManager @ 24 NONAME
+	_ZTV19CHsRemoteController @ 25 NONAME
+	_ZTV21CHsRCDeviceDiscoverer @ 26 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/remotecontroller/group/bld.inf	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,24 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../inc/hsremotecontroller.h headsetsimulator/rc/hsremotecontroller.h
+../inc/bttools/hsrcbttoolsobserver.h headsetsimulator/rc/hsrcbttoolsobserver.h
+
+PRJ_MMPFILES
+hsremotecontroller.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/remotecontroller/group/hsremotecontroller.mmp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,52 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+
+#include <platform_paths.hrh>
+
+TARGET		  hsremotecontroller.dll
+TARGETTYPE	  dll
+UID			 0x1000008d 0xE45013E0
+
+
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE	 ..\inc 
+USERINCLUDE  ..\inc\bttools 
+USERINCLUDE  ..\inc\remotecontrol
+
+SYSTEMINCLUDE	/epoc32/include/headsetsimulator/rc
+SYSTEMINCLUDE	/epoc32/include/headsetsimulator
+
+CAPABILITY ALL -TCB
+
+LIBRARY		 euser.lib 
+LIBRARY		 esock.lib 
+LIBRARY		 bluetooth.lib 
+LIBRARY		 btengsettings.lib 
+LIBRARY		 sdpagent.lib 
+LIBRARY		 sdpdatabase.lib 
+LIBRARY		 btengconnman.lib 
+LIBRARY		 btdevice.lib 
+LIBRARY		 btengdiscovery.lib 
+LIBRARY		 charconv.lib
+
+
+SOURCEPATH ..\src
+SOURCE hsremotecontroller.cpp
+SOURCEPATH ..\src\bttools
+SOURCE hsrcdevicediscoverer.cpp
+SOURCEPATH ..\src\remotecontrol
+SOURCE ..\bttools\hsrcbtmanager.cpp hsrccommand.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/remotecontroller/inc/bttools/hsrcbttools.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,395 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSRCBTTOOLS_H
+#define HSRCBTTOOLS_H
+
+#include <btsdp.h>
+#include <bt_sock.h>
+#include <btengconnman.h>
+#include <btengsettings.h>
+#include <btengdiscovery.h>
+
+class CBTEngSettings;
+class CBTEngConnMan;
+class CBTEngDiscovery;
+class RSocketServ;
+class MHsRCBTManagerObserver;
+
+/** Length of device bluetooth address */
+const TInt KDevAddrLength = KBTDevAddrSize * 2;
+
+/** default bluetooth name */
+_LIT(KHsRCDefaultName,"HS_RemoteController");
+
+/**
+ * @brief Observes devices found during inquiry 
+ */
+class MHsRCDeviceDiscovererObserver
+{
+public:
+    /**
+     * Informs that device was found during inquiry
+     * 
+     * @param aBTAddress 8-bit descriptor containing bluetooth address
+     * @param aBTName  8-bit descriptor containing bluetooth name
+     * @param aMajServClass major service class - part of Class of Device
+     * @param aMajDeviceClass major device class - part of Class of Device
+     * @param aMinDeviceClass minor device class - part of Class of Device
+     */
+    virtual void HandleDeviceFindSuccessL( TDesC8 &aBTAddress, TDesC8 &aBTName,
+            TUint16 aMajServClass, TUint aMajDeviceClass,
+            TUint8 aMinDeviceClass )=0;
+
+    /**
+     * Informs that inquiry finished 
+     * 
+     * @param aErr error value. If KErrEof - proper finish, otherwise error 
+     *        occured 
+     */
+    virtual void HandleDeviceFindFailed( TInt aErr )=0;
+};
+
+/**
+ * @brief Class asynchronously finds devices equipped with bluetooth
+ */
+class CHsRCDeviceDiscoverer : public CActive
+{
+public:
+    /**
+     * Two-phase constructor
+     * @param aDeviceObserver inquiry observer
+     * @param aSServ session of application
+     * 
+     * @return instance of class
+     */
+    static CHsRCDeviceDiscoverer
+            * NewL( MHsRCDeviceDiscovererObserver *aDeviceObserver,
+                    RSocketServ &aSServ );
+
+    /**
+     * Two-phase constructor
+     * @param aDeviceObserver inquiry observer
+     * @param aSServ session of application
+     * 
+     * @return instance of class
+     */
+    static CHsRCDeviceDiscoverer
+    * NewLC( MHsRCDeviceDiscovererObserver *aDeviceObserver,
+            RSocketServ &aSServ );
+    /**
+     * Destructor
+     */
+    ~CHsRCDeviceDiscoverer();
+
+public:
+
+    /**
+     * Async method for searching devices
+     */
+    void DeviceSearchL();
+
+    /**
+     * Gets device's bluetooth address
+     * 
+     * @return TBTDevAddr address of device
+     */
+    TBTDevAddr GetBTDevAddress();
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aDeviceObserver pointer to inquiry observer 
+     * @param aSServ subsession of socket server 
+     */
+    CHsRCDeviceDiscoverer( MHsRCDeviceDiscovererObserver* aDeviceObserver,
+            RSocketServ& aSServ );
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+
+    /**
+     * Initializes and connects host resolver
+     */
+    void ConnectHostResolverL();
+
+private:
+    /**
+     * CActive method
+     */
+    void RunL();
+
+    /**
+     * CActive method
+     */
+    void DoCancel();
+
+private:
+
+    /** Session of socket server */
+    RSocketServ& iSServ;
+
+    /** Provides methods to find device*/
+    RHostResolver iHRes;
+
+    /** Bluetooth device's name */
+    TBuf <KMaxBluetoothNameLen> iName;
+
+    /** Socket address used for inquiry */
+    TInquirySockAddr iSockAddr;
+
+    /** Bluetooth address */
+    TBTDevAddr iDevAddr;
+
+    /** Wrapps bluetooth device"*/
+    TNameEntry iEntry;
+
+    /** Denotes if searching is in progress*/
+    TBool iSearching;
+
+    /** 
+     * Pointer to observer 
+     * not owned
+     */
+    MHsRCDeviceDiscovererObserver* iDeviceObserver;
+};
+
+/**
+ * @brief Provides handling of bluetooth. Manages Headset Simulator searching 
+ *        and connection
+ */
+class CHsRCBTManager : public CBase, public MBTEngSettingsObserver,
+        public MBTEngConnObserver, public MBTEngSdpResultReceiver,
+        public MHsRCDeviceDiscovererObserver
+{
+
+public:
+
+    /**
+     * Two-phased constructor
+     * 
+     * @param aSServ socket server subsession
+     * @param aBTManagerObserver pointer to observer
+     * 
+     * @return instance of class
+     */
+    static CHsRCBTManager* NewL( RSocketServ& aSServ,
+            MHsRCBTManagerObserver* aBTManagerObserver );
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aSServ socket server subsession
+     * @param aBTManagerObserver pointer to observer
+     * 
+     * @return instance of class
+     */
+    static CHsRCBTManager* NewLC( RSocketServ& aSServ,
+            MHsRCBTManagerObserver* aBTManagerObserver );
+
+    /**
+     * Destructor
+     */
+    ~CHsRCBTManager();
+
+public:
+
+    /**
+     * Connects with Headset Simulator by bluetooth address
+     * 
+     * @pre SetService() should be called
+     * 
+     * @param aDevAddr bluetooth address
+     */
+    void ConnectDevAddrL( const TBTDevAddr& aDevAddr );
+
+    /**
+     * Connects with Headset Simulator by bluetooth name
+     * 
+     * @pre SetService() should be called
+     * 
+     * @param aDeviceName bluetooth name
+     */
+    void ConnectDevNameL( const TDesC& aDeviceName );
+
+    /**
+     * Cancels ongoing attempt to connect with Headset Simulator
+     */
+    void CancelConnecting();
+
+    /**
+     * Sets Headset Simulator's remote control service
+     */
+    void SetService( const TUUID& aService );
+
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CHsRCBTManager( RSocketServ& aSServ,
+            MHsRCBTManagerObserver* aBTManagerObserver );
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+    /** Methods derived from MBTEngSettingsObserver */
+
+    void PowerStateChanged( TBTPowerStateValue aState );
+
+    void VisibilityModeChanged( TBTVisibilityMode aState );
+
+private:
+    /** Methods derived from MBTEngConnObserver */
+
+    void ConnectComplete( TBTDevAddr& aAddr, TInt aErr,
+            RBTDevAddrArray* aConflicts = NULL );
+
+    void DisconnectComplete( TBTDevAddr& aAddr, TInt aErr );
+
+    void PairingComplete( TBTDevAddr& aAddr, TInt aErr );
+
+private:
+    /** Methods derived from MBTEngSdpResultReceiver */
+
+    void ServiceSearchComplete( const RSdpRecHandleArray& aResult,
+            TUint aTotalRecordsCount, TInt aErr );
+
+    void AttributeSearchComplete( TSdpServRecordHandle aHandle,
+            const RSdpResultArray& aAttr, TInt aErr );
+
+    void ServiceAttributeSearchComplete( TSdpServRecordHandle aHandle,
+            const RSdpResultArray& aAttr, TInt aErr );
+
+    void DeviceSearchComplete( CBTDevice* aDevice, TInt aErr );
+
+private:
+    /** Methods derived from  MDeviceDiscovererObserver */
+
+    void HandleDeviceFindSuccessL( TDesC8 & address, TDesC8 & name,
+            TUint16 aMajServClass, TUint aMajDeviceClass,
+            TUint8 aMinDeviceClass );
+
+    void HandleDeviceFindFailed( TInt aErr );
+
+private:
+
+    /**
+     * Finds port on Audio Gateway
+     * 
+     * @return error value. KErrNotFound in case of failure, otherwise KErrNone
+     */
+
+    TInt FindPort( const RSdpResultArray& aAttr, TInt& aPort );
+
+    /**
+     * Restores local name and power state to initial values 
+     */
+    void RestoreInitialSettingsL();
+
+    /**
+     * Sets local bluetooth name
+     * @param aBTName new local name
+     */
+    void SetBTNameL( const TDesC& aBTName );
+
+    /*
+     * Turns on bluetooth with specified (optional) name
+     * 
+     * @param aName bluetooth name
+     */
+    void TurnOnBTL( const TDesC& aName = KHsRCDefaultName );
+
+    /*
+     * Turns off bluetooth on device
+     */
+    void TurnOffBTL();
+
+    /*
+     * Finds service on a specified device
+     * 
+     * @param aDevAddr  bluetooth address
+     * @param aService  service UUID
+     */
+    void FindServiceL( const TBTDevAddr& aDevAddr, const TUUID& aService );
+
+private:
+    /** Searching type enum */
+    enum THsRCSearchType
+    {
+        /** Search device by bluetooth name*/
+        EDevName,
+        /** Search device by bluetooth address*/
+        EDevAddr
+    };
+
+    /** Searching type */
+    THsRCSearchType iSearchType;
+
+    /** Service */
+    TUUID iService;
+
+    /** Needed for restoring bluetooth name */
+    RBuf iBTInitialName;
+
+    /** Needed for restoring bluetooth power */
+    TBTPowerStateValue iBTInitialPowerState;
+
+    /** Needed for restoring bluetooth visibility */
+    TBTVisibilityMode iBTInitialVisibilityMode;
+
+    /** Bluetooth name */
+    RBuf iBTName;
+
+    /** Bluetooth address */
+    TBTDevAddr iDevAddr;
+
+    /** Bluetooth address to be searched */
+    RBuf iDesiredMAC;
+
+    /** Bluetooth name to be searched */
+    RBuf iDesiredName;
+
+    /** Session of socket server */
+    RSocketServ& iSServ;
+
+    /** Pointer to bluetooth settings (power state, local name). Owned */
+    CBTEngSettings* iBTSettings;
+
+    /** Pointer to bluetooth connection manager. Owned */
+    CBTEngConnMan* iBTConnection;
+
+    /** Pointer to class responsible SDP queries */
+    CBTEngDiscovery* iBTDiscovery;
+
+    /** Pointer to class responsible for device discovery */
+    CHsRCDeviceDiscoverer* iDiscoverer;
+
+    /** Pointer to observer */
+    MHsRCBTManagerObserver* iBTManagerObserver;
+
+    /** Denotes if service is set */
+    TBool iServiceSet;
+};
+
+#endif //HSRCBTTOOLS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/remotecontroller/inc/bttools/hsrcbttoolsobserver.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,46 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSRCBTTOOLSOBSERVER_H
+#define HSRCBTTOOLSOBSERVER_H
+
+/**
+ * @brief Observes if Headset Simulator is reachable
+ */
+class MHsRCBTManagerObserver
+    {
+
+public:
+    /** 
+     * Called when desired device found 
+     * 
+     * @param aDevName bluetooth name of found device
+     * @param aDevAddr bluetooth address of found device
+     * @param aPort found port number
+     */
+    virtual void HandleDesiredDevFound(const TDesC& aDevName,
+            const TBTDevAddr& aDevAddr, const TInt aPort) = 0;
+    
+    /** 
+     * Called when desired device not found 
+     *
+     * @param aErr error code 
+     */
+    virtual void HandleDesiredDevNotFound(TInt aErr) = 0;
+
+    };
+
+
+#endif //HSRCBTTOOLSOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/remotecontroller/inc/debug.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,187 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef PRJ_LOGGING_H
+#define PRJ_LOGGING_H
+
+#include <e32base.h>
+#include "debugconfig.h"
+
+enum TPanic
+{
+    EInvalidNullState = 1,
+};
+
+#ifdef PRJ_ENABLE_TRACE
+
+#ifdef PRJ_FILE_TRACE
+#include <flogger.h>
+#else
+#include <e32debug.h>
+#endif
+
+NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow
+{
+public:
+    void Overflow( TDes16& /*aDes*/)
+        {
+        }
+};
+
+NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow
+{
+public:
+    void Overflow( TDes8& /*aDes*/)
+        {
+        }
+};
+
+inline void Trace( TRefByValue <const TDesC16> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    RBuf16 theFinalString;
+    theFinalString.Create( KMaxLogLineLength );
+    theFinalString.Append( KTracePrefix16 );
+    TOverflowTruncate16 overflow;
+    theFinalString.AppendFormatList( aFmt, list, &overflow );
+    RDebug::Print( theFinalString );
+    theFinalString.Close();
+#endif
+    }
+
+inline void Trace( TRefByValue <const TDesC8> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START(list, aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    TOverflowTruncate8 overflow;
+    RBuf8 buf8;
+    buf8.Create( KMaxLogLineLength );
+    buf8.Append( KTracePrefix8 );
+    buf8.AppendFormatList( aFmt, list, &overflow );
+
+    RBuf16 buf16;
+    buf16.Create( KMaxLogLineLength );
+    buf16.Copy( buf8 );
+    TRefByValue <const TDesC> tmpFmt( _L("%S") );
+    RDebug::Print( tmpFmt, &buf16 );
+    buf8.Close();
+    buf16.Close();
+#endif
+    }
+
+inline void TracePanic( char* aFile, TInt aLine, TInt aPanicCode,
+        const TDesC& aPanicCategory )
+    {
+    TPtrC8 fullFileName( (const TUint8*) aFile );
+    TPtrC8 fileName( fullFileName.Ptr() + fullFileName.LocateReverse( '\\' )
+            + 1 );
+    RBuf8 buf;
+    buf.Create( KMaxLogLineLength );
+    buf.Append( KPanicPrefix8 );
+    buf.AppendFormat( _L8("%d at line %d in file %S"), aPanicCode, aLine,
+            &fileName );
+    Trace( buf );
+    buf.Close();
+    User::Panic( aPanicCategory, aPanicCode );
+    }
+
+inline void TraceLeave( char* aFile, TInt aLine, TInt aReason )
+    {
+    TPtrC8 fullFileName( (const TUint8*) aFile );
+    TPtrC8 fileName( fullFileName.Ptr() + fullFileName.LocateReverse( '\\' )
+            + 1 );
+    RBuf8 buf;
+    buf.Create( KMaxLogLineLength );
+    buf.Append( KLeavePrefix8 );
+    buf.AppendFormat( _L8("%d at line %d in file %S"), aReason, aLine,
+            &fileName );
+    Trace( buf );
+    buf.Close();
+    User::Leave( aReason );
+    }
+
+#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;}
+
+#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;}
+
+#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;}
+
+#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;}
+
+#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;}
+
+#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);}
+
+#define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory)
+
+#define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define LEAVE_IF_NULL(PTR) {if (!PTR) TraceLeave(__FILE__, __LINE__, KErrGeneral);}
+
+#define LEAVE(REASON) {TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define TRACE_STATIC_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}}
+
+#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}}
+
+#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncExitFormat8, &ptr8);}}
+
+#define TRACE_STATIC_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncFormat8, &ptr8);}}
+
+#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncThisFormat8, &ptr8, this);}}
+
+#define RETURN_IF_ERR(ERR) {if(ERR) {TPtrC8 ptr8((TUint8*)__FILE__); Trace(_L8(" RETURN %d at file %S line %d"), ERR, &ptr8, __LINE__); return ERR;}}
+
+#else // PRJ_ENABLE_TRACE not defined
+#define TRACE_INFO(p)
+
+#define TRACE_ERROR(p)
+
+#define TRACE_STATE(p)
+
+#define TRACE_WARNING(p)
+
+#define TRACE_INFO_SEG(p)
+
+#define TRACE_ASSERT(GUARD, CODE)
+
+#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);}
+
+#define LEAVE_IF_ERROR(REASON) {static_cast<void>(User::LeaveIfError(REASON));}
+
+#define LEAVE_IF_NULL(PTR) {static_cast<void>(User::LeaveIfNull(PTR));}
+
+#define LEAVE(REASON) {static_cast<void>(User::Leave(REASON));}
+
+#define TRACE_STATIC_FUNC_ENTRY
+
+#define TRACE_FUNC_ENTRY
+
+#define TRACE_FUNC_EXIT
+
+#define TRACE_STATIC_FUNC
+
+#define TRACE_FUNC
+
+#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;}
+#endif // PRJ_ENABLE_TRACE
+#endif // PRJ_LOGGING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/remotecontroller/inc/debugconfig.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,52 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HS_RC_DEBUGCONFIG_H
+#define HS_RC_DEBUGCONFIG_H
+
+#include "prjconfig.h"
+
+/**
+ * Custom logging variations.
+ */
+#ifdef PRJ_FILE_TRACE
+_LIT(KLogFile,"HS RC.txt");
+_LIT(KLogDir,"HeadsetSimulator RC");
+#endif
+
+#ifdef PRJ_ENABLE_TRACE
+_LIT(KTracePrefix16, "[HS RC] ");
+_LIT8(KTracePrefix8, "[HS RC] ");
+_LIT8(KFuncFormat8, "><%S");
+_LIT8(KFuncThisFormat8, "><%S, [0x%08X]");
+_LIT8(KFuncEntryFormat8, ">%S");
+_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]");
+_LIT8(KFuncExitFormat8, "<%S");
+
+_LIT8(KPanicPrefix8, "PANIC code ");
+_LIT8(KLeavePrefix8, "LEAVE code ");
+#endif
+
+_LIT(KPanicCategory, "HeadsetSimulator RC"); // need it also for release 
+
+const TInt KMaxLogLineLength = 512;
+
+#define KPRINTERROR        0x00000001 // Tracing level: error
+#define KPRINTINFO        0x00000002 // Tracing level: function trace
+#define KPRINTSTATE        0x00000004 // Tracing level: state machine info
+#define KPRINTWARNING   0x00000008 // Tracing level: warning
+const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING;
+
+#endif // HS_RC_DEBUGCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/remotecontroller/inc/hsremotecontroller.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,346 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSREMOTECONTROLLER_H
+#define HSREMOTECONTROLLER_H
+
+#include <e32base.h>
+#include <bttypes.h> 
+#include <bt_sock.h>
+#include <UTF.H>
+#include <hsrcbttoolsobserver.h>
+#include <hsremoterequest.h>
+
+_LIT(KHSRemoteControllerNotConnectedPanicMsg,
+        "Not connected to Headset Simulator");
+
+class CHsRCBTManager;
+
+/** Length of the remote request data */
+const TInt KHsRemoteControlDataLength = 1024;
+
+/** Buffer for remote control */
+typedef TBuf8 <KHsRemoteControlDataLength> THsRemoteControlBuffer;
+
+/**
+ * @brief Interface for handling Headset Simulator Remote Controller's status
+ */
+class MHsRCObserver
+{
+
+public:
+    /**
+     * Informs about connection with Headset Simulator
+     * 
+     * @param aErr error value. If aErr == KErrNone connection is established, 
+     * otherwise not. 
+     */
+    virtual void HandleConnectedToHs( TInt aErr ) = 0;
+
+    /**
+     * Informs about released connection with Headset Simulator
+     */
+    virtual void HandleDisconnectedFromHs( TInt aErr ) = 0;
+
+    /**
+     * Informs that connection with Headset Simulator is being established 
+     */
+    virtual void HandleConnectingToHs() = 0;
+
+    /**
+     * Informs that remote request was sent
+     * @param aType THsRemoteControlCommandType
+     */
+    virtual void HandleRequestSent( THsRemoteControlCommandType aType ) = 0;
+};
+
+/**
+ * @brief Class responsible for remote control of Headset Simulator
+ */
+class CHsRemoteController : public CBase, public MBluetoothSocketNotifier,
+        public MHsRCBTManagerObserver
+{
+public:
+    /**
+     * Two-phase constructor
+     * @param aObserver pointer to MHsRCObserver
+     * @return instance of class
+     */
+    IMPORT_C static CHsRemoteController* NewL( MHsRCObserver* aObserver );
+
+    /**
+     * Two-phase constructor
+     * @param aObserver pointer to MHsRCObserver
+     * @return instance of class
+     */
+    IMPORT_C static CHsRemoteController* NewLC( MHsRCObserver* aObserver );
+
+    /**
+     * Destructor
+     */
+    IMPORT_C ~CHsRemoteController();
+
+public:
+
+    /**
+     * Connects Headset Simulator by its bluetooth address
+     * 
+     * When request completes notification is sent to 
+     * MHsRCObserver::HandleConnectedToHs()
+     * 
+     * @param aDevAddr Headset Simulator's bluetooth address
+     * @param aService Headset Simulator's Remote Control service TUUID
+     * 
+     * @leave KErrInUse if connection with Headset Simulator is already 
+     *        established 
+     */
+    IMPORT_C void ConnectHsDevAddrL( const TBTDevAddr& aDevAddr,
+            const TUUID& aService );
+
+    /**
+     * Connects Headset Simulator by its bluetooth name
+     * 
+     * When request completes notification is sent to 
+     * MHsRCObserver::HandleConnectedToHs()
+     * 
+     * @param aHsName Headset Simulator's bluetooth name
+     * @param aService Headset Simulator's Remote Control service TUUID
+     * 
+     * @leave KErrInUse if connection with Headset Simulator is 
+     *        already established
+     */
+    IMPORT_C void ConnectHsDevNameL( const TDesC& aHsName,
+            const TUUID& aService );
+
+    /**
+     * Cancels attempt of connection with Headset Simulator
+     */
+    IMPORT_C void CancelConnectingToHs();
+
+    /**
+     * Disconnects from Headset Simulator
+     *
+     * When request completes notification is sent to 
+     * MHsRCObserver::HandleDisconnectedFromHs()
+     */
+    IMPORT_C void DisconnectFromHs();
+
+    //remote requests
+
+    /**
+     * Requests turning HS on (i.e. start providing headset service)
+     * 
+     * @pre Established connection with Headset Simulator
+     * @param aPluginCod CoD plugin's name
+     * @param aPluginSdp SDP plugin's name
+     * @param aPluginProfile Profile plugin's name
+     */
+    IMPORT_C void ReqTurnOnHs( const TDesC& aPluginCod,
+            const TDesC& aPluginSdp, const TDesC& aPluginProfile );
+
+    /**
+     * Requests turning HS off (i.e. stop providing headset service)
+     * 
+     * @pre Established connection with Headset Simulator
+     */
+    IMPORT_C void ReqTurnOffHs();
+    
+    /**
+     * Requests connection establishment between Headset Simulator and AG 
+     * with specified bluetooth address. Address should be lower-case.
+     * 
+     * @pre Established connection with Headset Simulator
+     * 
+     * @param aDevAddr AG's bluetooth device address
+     */
+    IMPORT_C void ReqConnectWithDevAddr( const TBTDevAddr& aDevAddr );
+
+    /**
+     * Requests connection establishment between Headset Simulator and AG 
+     * with specified bluetooth name
+     * 
+     * @pre Established connection with Headset Simulator 
+     * 
+     * @param aDevName AG's bluetooth device name
+     */
+    IMPORT_C void ReqConnectWithDevName( const TDesC& aDevName );
+
+    /**
+     * Requests connection establishment between Headset Simulator and 
+     * last-connected AG
+     * 
+     * @pre Established connection with Headset Simulator 
+     */
+    IMPORT_C void ReqConnectWithLastConnected();
+
+    /**
+     * Requests accept incoming call on AG
+     * 
+     * @pre Established connection with Headset Simulator 
+     */
+    IMPORT_C void ReqAcceptCall();
+
+    /**
+     * Requests call release on AG
+     * 
+     * @pre Established connection with Headset Simulator 
+     */
+    IMPORT_C void ReqReleaseCall();
+
+    /**
+     * Requests setting AG's microphone gain
+     * 
+     * @pre Established connection with Headset Simulator
+     * 
+     * @param aValue text-value 
+     */
+    IMPORT_C void ReqSetMicGain( const TDesC& aValue );
+
+    /**
+     * Requests setting AG's speaker volume
+     * 
+     * @pre Established connection with Headset Simulator
+     * 
+     * @param aValue text-value 
+     */
+    IMPORT_C void ReqSetSpeakerVolume( const TDesC& aValue );
+
+    /**
+     * Requests sending any AT command
+     * 
+     * @pre Established connection with Headset Simulator
+     * 
+     * @param aValue text-value 
+     */
+    IMPORT_C void ReqSendAnyAt( const TDesC& aValue );
+
+    /**
+     * Requests disconnection of AG from Headset Simulator
+     * 
+     * @pre Established connection with Headset Simulator
+     */
+    IMPORT_C void ReqDisconnectAG();
+
+private:
+    /**
+     * Constructor for performing 1st stage construction
+     * 
+     * @param aObserver pointer to MHsRCObserver
+     */
+    CHsRemoteController( MHsRCObserver* aObserver );
+
+    /**
+     * Constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+    /**
+     * Sends request to Headset Simulator
+     * 
+     * @param aCommandType type of command
+     * @param aData additional data send within request
+     */
+    void SendRequest( const THsRemoteControlCommandType aCommandType,
+            const TDesC& aData = KNullDesC );
+
+    /**
+     * Sends data (THsRCCommand as a descriptor) to remote bluetooth device
+     * 
+     * @param aData data to be send
+     * @return error value
+     */
+    TInt Send( const TDesC8& aData );
+
+    /**
+     *  Receives data from remote bluetooth device
+     */
+    void Receive();
+
+    /**
+     * Connects with Headset Simulator's Remote Control server
+     * 
+     * @param aAddr Headset Simulator's bluetooth address
+     * @param aPort Headset Simulator's remote controls's server port
+     * 
+     * @return error value
+     */
+    TInt ConnectRemoteControlServer( const TBTDevAddr &aAddr, const TInt aPort );
+
+    /**
+     * Creates component responsible for handling bluetooth 
+     * 
+     * @return error value
+     */
+    TInt CreateBTManager();
+
+private:
+    //Methods inherited from MBluetoothSocketNotifier
+
+    void HandleConnectCompleteL( TInt aErr );
+
+    void HandleAcceptCompleteL( TInt aErr );
+
+    void HandleShutdownCompleteL( TInt aErr );
+
+    void HandleSendCompleteL( TInt aErr );
+
+    void HandleReceiveCompleteL( TInt aErr );
+
+    void HandleIoctlCompleteL( TInt aErr );
+
+    void HandleActivateBasebandEventNotifierCompleteL( TInt aErr,
+            TBTBasebandEventNotification& aEventNotification );
+
+private:
+    //Methods inherited from MHsRCBTManagerObserver
+
+    void HandleDesiredDevFound( const TDesC& aDevName,
+            const TBTDevAddr& aDevAddr, const TInt aPort );
+
+    void HandleDesiredDevNotFound( TInt aErr );
+
+private:
+
+    /** received data */
+    THsRemoteControlBuffer iReceiveDataBuffer;
+
+    /** data to be sent */
+    THsRemoteControlBuffer iSendDataBuffer;
+
+    /** buffered data */
+    THsRemoteControlBuffer iTempDataBuffer;
+
+    /** data length */
+    TSockXfrLength iDataLength;
+
+    /** instance of socket server */
+    RSocketServ iSocketServ;
+
+    /** denotes if connection with Headset Simulator is established */
+    TBool iConnected;
+
+    /** pointer to CHsRCBTManager, owned */
+    CHsRCBTManager* iBTManager;
+
+    /** pointer to CBluetoothSocket, owned */
+    CBluetoothSocket* iSocket;
+
+    /** pointer to MHsRCObserver, not owned */
+    MHsRCObserver* iObserver;
+
+};
+
+#endif // HSREMOTECONTROLLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/remotecontroller/inc/prjconfig.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,43 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSRC_PRJCONFIG_H
+#define HSRC_PRJCONFIG_H
+
+/**
+ * Traces are enabled in _DEBUG build, by default.
+ */
+#ifdef _DEBUG
+#define PRJ_ENABLE_TRACE
+#endif
+
+/**
+ * traces to file if this is defined.
+ */
+//#define PRJ_FILE_TRACE
+
+
+/**
+ * build the project for module test purpose if this is defined
+ */
+//#define PRJ_MODULETEST_BUILD
+
+/**
+ * build the project using stubs to replace the dependencies if this is defined
+ */
+//#define PRJ_USE_STUB
+
+
+#endif // HSRC_PRJCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/remotecontroller/inc/remotecontrol/hsrcbttoolsobserver.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,46 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSRCBTTOOLSOBSERVER_H
+#define HSRCBTTOOLSOBSERVER_H
+
+/**
+ * @brief Observes if Headset Simulator is reachable
+ */
+class MHsRCBTManagerObserver
+    {
+
+public:
+    /** 
+     * Called when desired device found 
+     * 
+     * @param aDevName bluetooth name of found device
+     * @param aDevAddr bluetooth address of found device
+     * @param aPort found port number
+     */
+    virtual void HandleDesiredDevFound(const TDesC& aDevName,
+            const TBTDevAddr& aDevAddr, const TInt aPort) = 0;
+    
+    /** 
+     * Called when desired device not found 
+     *
+     * @param aErr error code 
+     */
+    virtual void HandleDesiredDevNotFound(TInt aErr) = 0;
+
+    };
+
+
+#endif //HSRCBTTOOLSOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/remotecontroller/inc/remotecontrol/hsrccommand.h	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,76 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#ifndef HSRCCOMMAND_H
+#define HSRCCOMMAND_H
+
+#include <e32base.h>
+#include <hsremoterequest.h>
+
+/** Length of package */
+const TInt KHsRemoteControlPackageLength = 128;
+
+/** Length of package's header */
+const TInt KHsRemoteControlPackageTypeMaxLength = 2;
+
+/** Headset Simulator's remote control command */
+typedef TBuf8 <KHsRemoteControlPackageLength> THsRCCommandData;
+
+/**
+ * @brief Represents command for remote control of Headset Simulator
+ */
+class THsRCCommand
+{
+public:
+        
+    /**
+     * Constructor
+     * 
+     * @param aData command's data
+     * @param aCommandType type of command
+     */
+    THsRCCommand( THsRCCommandData& aData, 
+            THsRemoteControlCommandType aCommandType );
+
+    /**
+     * Represents THsRCCommand as 8-bit descriptor
+     * 
+     * @param aCommandDesc parameter containing response
+     */
+    void ToDes8( TDes8& aCommandDesc );
+
+    /**
+     * Clones THsRCCommand object
+     * 
+     * @param aCmdFrom source
+     * @param aCmdTo destination 
+     */
+    static void Copy( const THsRCCommand& aCmdFrom, THsRCCommand& aCmdTo );
+
+    /**
+     * Getter for type of command
+     * 
+     * @return command type
+     */
+    THsRemoteControlCommandType Type() const;
+
+private:
+    /** Command data */
+    THsRCCommandData& iData;
+    
+    /** Command type */
+    THsRemoteControlCommandType iType;
+};
+#endif // HSRCOMMAND_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/remotecontroller/sis/hsremotecontroller.pkg	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,25 @@
+;
+; Component Name: Headset Simulator
+; Author: Comarch S.A.
+; Version: 1.0
+; Copyright (c) 2010 Comarch S.A.
+;  
+; This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+; the basis of the Member Contribution Agreement entered between Comarch S.A. 
+; and Symbian Foundation Limited on 5th June 2009 ("Agreement") and may be 
+; used only in accordance with the terms and conditions of the Agreement. 
+; Any other usage, duplication or redistribution of this Software is not 
+; allowed without written permission of Comarch S.A.
+; 
+
+;Header
+#{"HeadsetSimulator Remote Controller DLL"},(0xE45013E0),1,0,0
+
+;Localised Vendor name
+%{"Vendor-EN"}
+
+;Unique Vendor name
+:"Vendor"
+
+;files
+"\epoc32\release\armv5\udeb\hsremotecontroller.dll"		  -"!:\sys\bin\hsremotecontroller.dll"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/remotecontroller/src/bttools/hsrcbtmanager.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,378 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#include "hsrcbttools.h"
+#include "hsrcbttoolsobserver.h"
+#include "debug.h"
+
+CHsRCBTManager* CHsRCBTManager::NewL( RSocketServ& aSServ,
+        MHsRCBTManagerObserver* aBTManagerObserver )
+    {
+    CHsRCBTManager* self = CHsRCBTManager::NewLC( aSServ, aBTManagerObserver );
+    CleanupStack::Pop( self ); // self;
+    return self;
+    }
+
+CHsRCBTManager* CHsRCBTManager::NewLC( RSocketServ& aSServ,
+        MHsRCBTManagerObserver* aBTManagerObserver )
+    {
+    CHsRCBTManager* self = new ( ELeave ) CHsRCBTManager( aSServ,
+            aBTManagerObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsRCBTManager::~CHsRCBTManager()
+    {
+    TRACE_FUNC_ENTRY
+    TRAP_IGNORE(RestoreInitialSettingsL());
+
+    if ( iBTSettings )
+        {
+        delete iBTSettings;
+        }
+
+    if ( iBTConnection )
+        {
+        delete iBTConnection;
+        }
+
+    if ( iDiscoverer )
+        {
+        delete iDiscoverer;
+        }
+
+    if ( iBTDiscovery )
+        {
+        delete iBTDiscovery;
+        }
+
+    iDesiredMAC.Close();
+    iDesiredName.Close();
+
+    iBTInitialName.Close();
+    iBTName.Close();
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsRCBTManager::ConnectDevAddrL( const TBTDevAddr& aDevAddr )
+    {
+    TRACE_FUNC_ENTRY
+    iDesiredMAC.Zero();
+    iDesiredName.Zero();
+
+    iSearchType = EDevAddr;
+    aDevAddr.GetReadable( iDesiredMAC );
+
+    TBTPowerStateValue powerState;
+    TInt err = iBTSettings->GetPowerState( powerState );
+    if ( KErrNone == err && powerState == EBTPowerOff )
+        {
+        TurnOnBTL();
+        }
+    iDiscoverer->DeviceSearchL();
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsRCBTManager::ConnectDevNameL( const TDesC& aDeviceName )
+    {
+    TRACE_FUNC_ENTRY
+    iDesiredMAC.Zero();
+    iDesiredName.Zero();
+
+    iSearchType = EDevName;
+    iDesiredName.Copy( aDeviceName );
+
+    TBTPowerStateValue powerState;
+    iBTSettings->GetPowerState( powerState );
+    TInt err = iBTSettings->GetPowerState( powerState );
+    if ( KErrNone == err && powerState == EBTPowerOff )
+        {
+        TurnOnBTL();
+        }
+
+    iDiscoverer->DeviceSearchL();
+    TRACE_FUNC_EXIT
+    }
+
+void CHsRCBTManager::CancelConnecting()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iDiscoverer )
+        iDiscoverer->Cancel();
+    TRACE_FUNC_EXIT
+    }
+
+void CHsRCBTManager::SetService( const TUUID &aService )
+    {
+    iServiceSet = ETrue;
+    iService = aService;
+    }
+
+CHsRCBTManager::CHsRCBTManager( RSocketServ& aSServ,
+        MHsRCBTManagerObserver* aBTManagerObserver ) :
+    iSServ( aSServ ), iBTManagerObserver( aBTManagerObserver )
+    {
+
+    }
+
+void CHsRCBTManager::ConstructL()
+    {
+    TRACE_FUNC_ENTRY
+    iBTSettings = CBTEngSettings::NewL( this );
+    iBTConnection = CBTEngConnMan::NewL( this );
+    iDiscoverer = CHsRCDeviceDiscoverer::NewL( this, iSServ );
+    iBTDiscovery = CBTEngDiscovery::NewL( this );
+
+    User::LeaveIfError( iDesiredName.Create( KMaxBCBluetoothNameLen ) );
+    User::LeaveIfError( iDesiredMAC.Create( KMaxBCBluetoothNameLen ) );
+    User::LeaveIfError( iBTInitialName.Create( KMaxBluetoothNameLen ) );
+    User::LeaveIfError( iBTName.Create( KMaxBluetoothNameLen ) );
+
+    User::LeaveIfError( iBTSettings->GetLocalName( iBTInitialName ) );
+    iBTName.Copy( iBTInitialName );
+
+    User::LeaveIfError( iBTSettings->GetVisibilityMode(
+            iBTInitialVisibilityMode ) );
+    iServiceSet = EFalse;
+
+    User::LeaveIfError( iBTSettings->GetPowerState( iBTInitialPowerState ) );
+    TRACE_FUNC_EXIT
+    }
+
+void CHsRCBTManager::PowerStateChanged( TBTPowerStateValue /*aState*/)
+    {
+    }
+
+void CHsRCBTManager::VisibilityModeChanged( TBTVisibilityMode /*aState*/)
+    {
+    }
+
+void CHsRCBTManager::ConnectComplete( TBTDevAddr& /*aAddr*/, TInt aErr,
+        RBTDevAddrArray* /*aConflicts*/)
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+
+    if ( ( aErr != KErrNone ) && iBTManagerObserver )
+        {
+        iBTManagerObserver->HandleDesiredDevNotFound( aErr );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsRCBTManager::DisconnectComplete( TBTDevAddr& /*aAddr*/, TInt /*aErr*/)
+    {
+    }
+
+void CHsRCBTManager::PairingComplete( TBTDevAddr& /*aAddr*/, TInt /*aErr*/)
+    {
+    }
+
+void CHsRCBTManager::ServiceSearchComplete(
+        const RSdpRecHandleArray& /* aResult */,
+        TUint /* aTotalRecordsCount */, TInt /* aErr */)
+    {
+    }
+
+void CHsRCBTManager::AttributeSearchComplete(
+        TSdpServRecordHandle /* aHandle */, const RSdpResultArray& /* aAttr */,
+        TInt /* aErr */)
+    {
+    }
+
+void CHsRCBTManager::ServiceAttributeSearchComplete(
+        TSdpServRecordHandle /* aHandle */, const RSdpResultArray& aAttr, 
+        TInt /* aErr */)
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt port;
+
+    TInt err = FindPort( aAttr, port );
+    iDiscoverer->Cancel();
+
+    if ( ( err == KErrNone ) && ( iBTManagerObserver ) )
+        {
+        iBTManagerObserver->HandleDesiredDevFound( iDesiredName, iDevAddr, 
+                port );
+        }
+    else
+        {
+
+        if ( iBTManagerObserver )
+            {
+            iBTManagerObserver->HandleDesiredDevNotFound( err );
+            }
+
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsRCBTManager::DeviceSearchComplete( CBTDevice* /* aDevice */, 
+        TInt /* aErr */)
+    {
+    }
+
+void CHsRCBTManager::HandleDeviceFindSuccessL( TDesC8& aDevAddr,
+        TDesC8& aDevName, TUint16 /* aMajServClass */,
+        TUint /* aMajDeviceClass */, TUint8 /* aMinDeviceClass */)
+    {
+    TRACE_FUNC_ENTRY
+
+    RBuf bufAddr;
+    RBuf bufName;
+
+    bufAddr.CleanupClosePushL();
+    bufName.CleanupClosePushL();
+
+    bufAddr.CreateL( aDevAddr.Length() );
+    bufName.CreateL( aDevName.Length() );
+
+    bufAddr.Copy( aDevAddr );
+    bufName.Copy( aDevName );
+
+    TRACE_INFO( (_L8("DevNAME: %S :: DevADDR: %S") , &aDevName, &aDevAddr) )
+
+    if ( ( iSearchType == EDevAddr ) && ( bufAddr == iDesiredMAC ) )
+        {
+        iDiscoverer->Cancel();
+        TBTDevAddr addr;
+
+        User::LeaveIfError( addr.SetReadable( bufAddr ) );
+
+        iDevAddr = addr;
+        iDesiredName.Copy( aDevName );
+        TRAPD(err,FindServiceL(iDevAddr, iService));
+
+        if ( ( err != KErrNone ) && ( iBTManagerObserver ) )
+            {
+            iBTManagerObserver->HandleDesiredDevNotFound( err );
+            }
+        iDesiredMAC.Zero();
+        }
+
+    else if ( ( iSearchType == EDevName ) && ( bufName == iDesiredName ) )
+        {
+
+        iDiscoverer->Cancel();
+        User::LeaveIfError( iDevAddr.SetReadable( bufAddr ) );
+        TRAPD(err, FindServiceL(iDevAddr, iService));
+
+        if ( ( err != KErrNone ) && ( iBTManagerObserver ) )
+            {
+            iBTManagerObserver->HandleDesiredDevNotFound( err );
+            }
+
+        iDesiredName.Zero();
+        }
+
+    CleanupStack::PopAndDestroy( 2 );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsRCBTManager::HandleDeviceFindFailed( TInt aErr )
+    {
+
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) );
+
+    if ( iBTManagerObserver )
+        {
+        iBTManagerObserver->HandleDesiredDevNotFound( aErr );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsRCBTManager::FindPort( const RSdpResultArray& aAttr, TInt& aPort )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt res = KErrNotFound;
+
+    for ( TInt i = 0; i < aAttr.Count(); i++ )
+        {
+        TBTEngSdpAttrValue attr = aAttr[i];
+
+        if ( attr.iAttrType == ETypeUint )
+            {
+            aPort = attr.iAttrValue.iValNumeric;
+            res = KErrNone;
+            TRACE_INFO( (_L("Found port: %d"), aPort) );
+
+            }
+
+        }
+
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+void CHsRCBTManager::RestoreInitialSettingsL()
+    {
+    TRACE_FUNC_ENTRY
+    User::LeaveIfError( iBTSettings->SetLocalName( iBTInitialName ) );
+
+    User::LeaveIfError( iBTSettings->SetPowerState( iBTInitialPowerState ) );
+
+    User::LeaveIfError( iBTSettings->SetVisibilityMode(
+            iBTInitialVisibilityMode ) );
+
+    TRACE_FUNC_EXIT
+    }
+
+void CHsRCBTManager::SetBTNameL( const TDesC& aBTName )
+    {
+
+    iBTName.Copy( aBTName );
+    User::LeaveIfError( iBTSettings->SetLocalName( iBTName ) );
+
+    }
+
+void CHsRCBTManager::TurnOnBTL( const TDesC& aName )
+    {
+    User::LeaveIfError( iBTSettings->SetPowerState( EBTPowerOn ) );
+    SetBTNameL( aName );
+    }
+
+void CHsRCBTManager::TurnOffBTL()
+    {
+    User::LeaveIfError( iBTSettings->SetPowerState( EBTPowerOff ) );
+    }
+
+void CHsRCBTManager::FindServiceL( const TBTDevAddr &aDevAddr,
+        const TUUID& aService )
+    {
+    TRACE_FUNC_ENTRY
+    if ( !iServiceSet )
+        {
+        User::Leave( KErrNotReady );
+        }
+    TInt err = iBTDiscovery->RemoteSdpQuery( aDevAddr, aService,
+            KSdpAttrIdProtocolDescriptorList );
+    if ( err != KErrNone )
+        {
+        iDiscoverer->DeviceSearchL();
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/remotecontroller/src/bttools/hsrcdevicediscoverer.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,157 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#include "hsrcbttools.h"
+#include "debug.h"
+
+CHsRCDeviceDiscoverer* CHsRCDeviceDiscoverer::NewL(
+        MHsRCDeviceDiscovererObserver* aDeviceObserver, RSocketServ& aSServ )
+    {
+    CHsRCDeviceDiscoverer *self = CHsRCDeviceDiscoverer::NewLC(
+            aDeviceObserver, aSServ );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CHsRCDeviceDiscoverer* CHsRCDeviceDiscoverer::NewLC(
+        MHsRCDeviceDiscovererObserver* aDeviceObserver, RSocketServ& aSServ )
+    {
+    CHsRCDeviceDiscoverer *self = new ( ELeave ) CHsRCDeviceDiscoverer(
+            aDeviceObserver, aSServ );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CHsRCDeviceDiscoverer::~CHsRCDeviceDiscoverer()
+    {
+    TRACE_FUNC_ENTRY
+    Cancel();
+    iHRes.Close();
+    TRACE_FUNC_EXIT
+    }
+
+void CHsRCDeviceDiscoverer::DeviceSearchL()
+    {
+    TRACE_FUNC_ENTRY
+
+    Cancel();
+    ConnectHostResolverL();
+    iSearching = ETrue;
+    iHRes.GetByAddress( iSockAddr, iEntry, iStatus );
+    SetActive();
+
+    TRACE_FUNC_EXIT
+    }
+
+TBTDevAddr CHsRCDeviceDiscoverer::GetBTDevAddress()
+    {
+    return iDevAddr;
+    }
+
+CHsRCDeviceDiscoverer::CHsRCDeviceDiscoverer(
+        MHsRCDeviceDiscovererObserver* aDeviceObserver, RSocketServ& aSServ ) :
+    CActive( EPriorityNormal ), iSServ( aSServ ), iDeviceObserver(
+            aDeviceObserver )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+void CHsRCDeviceDiscoverer::ConstructL()
+    {
+    }
+
+void CHsRCDeviceDiscoverer::ConnectHostResolverL()
+    {
+
+    TRACE_FUNC_ENTRY
+    TProtocolDesc protDesc;
+    _LIT(KHsProtocolName,"BTLinkManager");
+    TProtocolName protName( KHsProtocolName );
+
+    User::LeaveIfError( iSServ.FindProtocol( protName, protDesc ) );
+    User::LeaveIfError( iHRes.Open( iSServ, protDesc.iAddrFamily,
+            protDesc.iProtocol ) );
+    iSockAddr.SetIAC( KGIAC );
+    iSockAddr.SetAction( KHostResInquiry | KHostResName );
+
+    TRACE_FUNC_EXIT
+
+    }
+
+void CHsRCDeviceDiscoverer::RunL()
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_ERROR((_L("iStatus value = %d"), iStatus.Int()))
+
+    if ( iStatus.Int() == KErrNone )
+        {
+
+        //dev found
+        TInquirySockAddr& sockAddr = TInquirySockAddr::Cast( iEntry().iAddr );
+
+        TBuf <KDevAddrLength> devAddrBuf;
+        TBuf <KMaxBluetoothNameLen> devNameBuf;
+
+        sockAddr.BTAddr().GetReadable( devAddrBuf );
+        devNameBuf.Copy( iEntry().iName );
+
+        TBuf8 <KDevAddrLength> addrBuf8;
+        TBuf8 <KMaxBluetoothNameLen> nameBuf8;
+
+        addrBuf8.Copy( devAddrBuf );
+        nameBuf8.Copy( devNameBuf );
+
+        if ( iDeviceObserver )
+            {
+            iDeviceObserver->HandleDeviceFindSuccessL( addrBuf8, nameBuf8,
+                    sockAddr.MajorServiceClass(),
+                    sockAddr.MajorClassOfDevice(),
+                    sockAddr.MinorClassOfDevice() );
+            }
+
+        // Get next device
+        iHRes.Next( iEntry, iStatus );
+        SetActive();
+        }
+    else
+        {
+        //Inquiry finished or error
+        Cancel();
+        iHRes.Close();
+        iSearching = EFalse;
+
+        if ( iDeviceObserver )
+            {
+            iDeviceObserver->HandleDeviceFindFailed( iStatus.Int() );
+            }
+        }
+    TRACE_FUNC_EXIT
+
+    }
+
+void CHsRCDeviceDiscoverer::DoCancel()
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iSearching )
+        {
+        iHRes.Cancel();
+        iHRes.Close();
+        }
+
+    TRACE_FUNC_EXIT
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/remotecontroller/src/hsremotecontroller.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,522 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+
+#include "hsremotecontroller.h"
+#include "hsrcbttools.h"
+#include "hsrccommand.h"
+#include "debug.h"
+
+EXPORT_C CHsRemoteController* CHsRemoteController::NewL(
+        MHsRCObserver* aObserver )
+    {
+    CHsRemoteController* self = CHsRemoteController::NewLC( aObserver );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+EXPORT_C CHsRemoteController* CHsRemoteController::NewLC(
+        MHsRCObserver* aObserver )
+    {
+    CHsRemoteController* self = new ( ELeave ) CHsRemoteController( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+EXPORT_C CHsRemoteController::~CHsRemoteController()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iBTManager )
+        {
+        delete iBTManager;
+        }
+
+    if ( iSocket )
+        {
+        if ( iConnected )
+            {
+            iSocket->CancelAll();
+            // Return value may be ignored
+            iSocket->Shutdown( RSocket::EImmediate );
+            }
+        delete iSocket;
+        }
+
+    iSocketServ.Close();
+
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsRemoteController::ConnectHsDevAddrL(
+        const TBTDevAddr& aDevAddr, const TUUID& aService )
+    {
+    TRACE_FUNC_ENTRY
+    if ( iConnected )
+        {
+        User::Leave( KErrInUse );
+        }
+    if ( iObserver )
+        {
+        iObserver->HandleConnectingToHs();
+        }
+    iBTManager->SetService( aService );
+
+    iBTManager->ConnectDevAddrL( aDevAddr );
+
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsRemoteController::ConnectHsDevNameL( const TDesC& aHsName,
+        const TUUID& aService )
+    {
+    TRACE_FUNC_ENTRY
+    if ( iConnected )
+        {
+        User::Leave( KErrInUse );
+        }
+    if ( iObserver )
+        {
+        iObserver->HandleConnectingToHs();
+        }
+    iBTManager->SetService( aService );
+    iBTManager->ConnectDevNameL( aHsName );
+
+    TRACE_FUNC_EXIT
+
+    }
+
+EXPORT_C void CHsRemoteController::CancelConnectingToHs()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iBTManager )
+        {
+        iBTManager->CancelConnecting();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsRemoteController::DisconnectFromHs()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iSocket )
+        {
+        if ( iConnected )
+            {
+            iSocket->CancelAll();
+            // Return value may be ignored
+            iSocket->Shutdown( RSocket::EImmediate );
+            }
+        delete iSocket;
+        iSocket = NULL;
+        iConnected = EFalse;
+        if ( iObserver )
+            {
+            iObserver->HandleDisconnectedFromHs( KErrNone );
+            }
+
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsRemoteController::ReqTurnOnHs( const TDesC& aPluginCod,
+        const TDesC& aPluginSdp, const TDesC& aPluginProfile )
+    {
+    TRACE_FUNC_ENTRY
+
+    __ASSERT_ALWAYS( iConnected,
+            User::Panic(KHSRemoteControllerNotConnectedPanicMsg, KErrNotReady));
+
+    RBuf buf;
+    TRAPD(err, buf.CreateL( aPluginCod.Length() + aPluginSdp.Length()
+                    + aPluginProfile.Length() + 4 ) );
+    if ( err == KErrNone )
+        {
+        TBuf <2> sep;
+        CnvUtfConverter::ConvertToUnicodeFromUtf8( sep,
+                KHsRemoteRequestParamSeparator );
+
+        buf.Copy( aPluginCod );
+        buf.Append( sep );
+        buf.Append( aPluginSdp );
+        buf.Append( sep );
+        buf.Append( aPluginProfile );
+
+        SendRequest( EHsTurnOn, buf );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsRemoteController::ReqTurnOffHs()
+    {
+    TRACE_FUNC_ENTRY
+
+    __ASSERT_ALWAYS( iConnected,
+            User::Panic(KHSRemoteControllerNotConnectedPanicMsg, KErrNotReady));
+
+    SendRequest( EHsTurnOff );
+
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsRemoteController::ReqConnectWithDevAddr(
+        const TBTDevAddr& aDevAddr )
+    {
+    TRACE_FUNC_ENTRY
+
+    __ASSERT_ALWAYS( iConnected, 
+            User::Panic(KHSRemoteControllerNotConnectedPanicMsg, KErrNotReady));
+
+    TBuf <KDevAddrLength> devAddrBuf;
+    aDevAddr.GetReadable( devAddrBuf );
+    SendRequest( EHsConnectDevAddress, devAddrBuf );
+
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsRemoteController::ReqConnectWithDevName( 
+        const TDesC& aDevName )
+    {
+    TRACE_FUNC_ENTRY
+
+    __ASSERT_ALWAYS( iConnected, 
+            User::Panic(KHSRemoteControllerNotConnectedPanicMsg, KErrNotReady));
+    SendRequest( EHsConnectName, aDevName );
+
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsRemoteController::ReqConnectWithLastConnected()
+    {
+    TRACE_FUNC_ENTRY
+
+    __ASSERT_ALWAYS( iConnected,
+            User::Panic(KHSRemoteControllerNotConnectedPanicMsg, KErrNotReady));
+    
+    SendRequest( EHsConnectLastconnected );
+
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsRemoteController::ReqAcceptCall()
+    {
+    TRACE_FUNC_ENTRY
+
+    __ASSERT_ALWAYS( iConnected, 
+            User::Panic(KHSRemoteControllerNotConnectedPanicMsg, KErrNotReady));
+    SendRequest( EHsAcceptCall );
+
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsRemoteController::ReqReleaseCall()
+    {
+    TRACE_FUNC_ENTRY
+
+    __ASSERT_ALWAYS( iConnected, 
+            User::Panic(KHSRemoteControllerNotConnectedPanicMsg, KErrNotReady));
+    SendRequest( EHsReleaseCall );
+
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsRemoteController::ReqSetMicGain( const TDesC& aValue )
+    {
+    TRACE_FUNC_ENTRY
+
+    __ASSERT_ALWAYS( iConnected, 
+            User::Panic(KHSRemoteControllerNotConnectedPanicMsg, KErrNotReady));
+    SendRequest( EHsSetMicVolume, aValue );
+
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsRemoteController::ReqSetSpeakerVolume( const TDesC& aValue )
+    {
+    TRACE_FUNC_ENTRY
+
+    __ASSERT_ALWAYS( iConnected, 
+            User::Panic(KHSRemoteControllerNotConnectedPanicMsg, KErrNotReady));
+    
+    SendRequest( EHsSetSpeakerVolume, aValue );
+
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsRemoteController::ReqSendAnyAt( const TDesC& aValue )
+    {
+    TRACE_FUNC_ENTRY
+
+    __ASSERT_ALWAYS( iConnected, 
+            User::Panic(KHSRemoteControllerNotConnectedPanicMsg, KErrNotReady));
+    SendRequest( EHsSendAnyAt, aValue );
+
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void CHsRemoteController::ReqDisconnectAG()
+    {
+    TRACE_FUNC_ENTRY
+
+    __ASSERT_ALWAYS( iConnected, 
+            User::Panic(KHSRemoteControllerNotConnectedPanicMsg, KErrNotReady));
+    SendRequest( EHsDisconnectAGs );
+
+    TRACE_FUNC_EXIT
+    }
+
+CHsRemoteController::CHsRemoteController( MHsRCObserver* aObserver ) :
+    iObserver( aObserver )
+    {
+
+    }
+
+void CHsRemoteController::ConstructL()
+    {
+    User::LeaveIfError( iSocketServ.Connect() );
+    User::LeaveIfError( CreateBTManager() );
+    }
+
+void CHsRemoteController::SendRequest(
+        const THsRemoteControlCommandType aCommandType, const TDesC& aData )
+    {
+    TRACE_FUNC_ENTRY
+
+    THsRCCommandData data( KNullDesC8 );
+    TInt err = CnvUtfConverter::ConvertFromUnicodeToUtf8( data, aData );
+    if ( err == KErrNone )
+        {
+        THsRCCommand cmd( data, aCommandType );
+        cmd.ToDes8( iSendDataBuffer );
+
+        err = Send( iSendDataBuffer );
+        if ( ( err == KErrNone ) && iObserver )
+            {
+            iObserver->HandleRequestSent( aCommandType );
+            }
+        }
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsRemoteController::Send( const TDesC8& aData )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L8("Data to be send: [%S]"), &aData) )
+
+    if ( !iConnected )
+        {
+        TRACE_INFO( _L("Not connected to HS") )
+        TRACE_FUNC_EXIT
+        return KErrNotReady;
+        }
+
+    iSendDataBuffer.Copy( aData );
+    if ( iSendDataBuffer.Length() > 0 )
+        {
+        TInt err = iSocket->Write( iSendDataBuffer );
+        if ( err == KErrNone )
+            {
+            iSendDataBuffer.Zero();
+            }
+
+        TRACE_FUNC_EXIT
+        return err;
+        }
+
+    TRACE_FUNC_EXIT
+
+    return KErrNone;
+    }
+
+void CHsRemoteController::Receive()
+    {
+    TRACE_FUNC_ENTRY
+    // Return value may be ignored, 
+    // error will be notified to HandleReceiveCompleteL
+    iSocket->RecvOneOrMore( iReceiveDataBuffer, 0, iDataLength );
+    TRACE_FUNC_EXIT
+    }
+
+TInt CHsRemoteController::ConnectRemoteControlServer( const TBTDevAddr& aAddr,
+        const TInt aPort )
+    {
+    TRACE_FUNC_ENTRY
+    TInt error = KErrNone;
+    if ( !iConnected )
+        {
+
+        TProtocolDesc protocolDesc;
+        error = iSocketServ.FindProtocol( _L("RFCOMM"), protocolDesc );
+        if ( error != KErrNone )
+            {
+            TRACE_INFO( ( _L("iSocketServ.FindProtocol error = %d"), error) )
+            TRACE_FUNC_EXIT
+            return error;
+            }
+
+        TRAP(error, iSocket = CBluetoothSocket::NewL(*this, iSocketServ,
+                        protocolDesc.iSockType, protocolDesc.iProtocol));
+        if ( error != KErrNone )
+            {
+            TRACE_INFO( ( _L("iSocket = CBluetoothSocket::NewL error = %d"), error))
+            TRACE_FUNC_EXIT
+            return error;
+            }
+
+        TBTSockAddr addr;
+        addr.SetBTAddr( aAddr );
+        addr.SetPort( aPort );
+        error = iSocket->Connect( addr );
+
+        if ( error != KErrNone )
+            {
+            TRACE_INFO( ( _L("iSocket->Connect error = %d"), error))
+            TRACE_FUNC_EXIT
+            return error;
+            }
+        }
+    else
+        {
+        TRACE_INFO( _L("CHsRemoteController::Connect() - client is already connected") )
+        TRACE_FUNC_EXIT
+        return KErrInUse;
+        }
+
+    TRACE_FUNC_EXIT
+    return KErrNone;
+    }
+
+TInt CHsRemoteController::CreateBTManager()
+    {
+    TInt err = KErrNone;
+
+    if ( !iBTManager )
+        {
+        TRAP(err, iBTManager = CHsRCBTManager::NewL(iSocketServ, this));
+        if ( err != KErrNone )
+            {
+            iBTManager = NULL;
+            }
+        return err;
+        }
+    else
+        {
+        return KErrAlreadyExists;
+        }
+
+    }
+
+void CHsRemoteController::HandleConnectCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) )
+
+    if ( aErr == KErrNone )
+        {
+        TRACE_INFO(_L("Connect completed"))
+        iConnected = ETrue;
+        Receive();
+        }
+    if ( iObserver )
+        {
+        iObserver->HandleConnectedToHs( aErr );
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsRemoteController::HandleAcceptCompleteL( TInt /*aErr*/)
+    {
+    }
+
+void CHsRemoteController::HandleShutdownCompleteL( TInt /*aErr*/)
+    {
+    }
+
+void CHsRemoteController::HandleSendCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) )
+
+    if ( aErr == KErrNone )
+        {
+        if ( ( iSendDataBuffer.Length() > 0 ) && ( ( iSocket->Write(
+                iSendDataBuffer ) ) == KErrNone ) )
+            {
+            iSendDataBuffer.Zero();
+            }
+        }
+    Receive();
+    TRACE_FUNC_EXIT
+    }
+
+void CHsRemoteController::HandleReceiveCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO( ( _L("aErr = %d"), aErr) )
+
+    if ( aErr == KErrNone )
+        {
+        if ( ( iSendDataBuffer.Length() > 0 ) && ( ( iSocket->Write(
+                iSendDataBuffer ) ) == KErrNone ) )
+            {
+            iSendDataBuffer.Zero();
+            }
+        Receive();
+        }
+    else
+        {
+        TRACE_INFO(_L("ControlServer cancelled listening"));
+        DisconnectFromHs();
+        }
+    }
+
+void CHsRemoteController::HandleIoctlCompleteL( TInt /*aErr*/)
+    {
+    }
+
+void CHsRemoteController::HandleActivateBasebandEventNotifierCompleteL(
+        TInt /*aErr*/, TBTBasebandEventNotification& /*aEventNotification*/)
+    {
+    }
+
+void CHsRemoteController::HandleDesiredDevFound( const TDesC& aDevName,
+        const TBTDevAddr& aDevAddr, const TInt aPort )
+    {
+    TRACE_FUNC_ENTRY
+    //value ignored
+    TInt err = ConnectRemoteControlServer( aDevAddr, aPort );
+
+    TRACE_INFO((_L("err = %d"), err))
+
+    if ( iObserver && err != KErrNone )
+        {
+        iObserver->HandleConnectedToHs( err );
+        }
+    TRACE_FUNC_EXIT
+    }
+
+void CHsRemoteController::HandleDesiredDevNotFound( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iObserver )
+        {
+        iObserver->HandleConnectedToHs( aErr );
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/headsetsimulator/remotecontroller/src/remotecontrol/hsrccommand.cpp	Wed Sep 15 15:59:44 2010 +0200
@@ -0,0 +1,43 @@
+/*
+ * Component Name: Headset Simulator
+ * Author: Comarch S.A.
+ * Version: 1.0
+ * Copyright (c) 2010 Comarch S.A.
+ *  
+ * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on 
+ * the basis of the Member Contribution Agreement entered between Comarch S.A. 
+ * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be 
+ * used only in accordance with the terms and conditions of the Agreement. 
+ * Any other usage, duplication or redistribution of this Software is not 
+ * allowed without written permission of Comarch S.A.
+ * 
+ */
+#include "hsrccommand.h"
+
+_LIT8(KHsRemoteCommandDelimiter,":");
+
+THsRCCommand::THsRCCommand( THsRCCommandData& aData,
+        THsRemoteControlCommandType aCommandType ) :
+    iData( aData ), iType( aCommandType )
+    {
+    }
+
+void THsRCCommand::ToDes8( TDes8& aCommandDesc )
+    {
+    aCommandDesc.Copy( KNullDesC8 );
+    aCommandDesc.AppendNum( iType );
+    aCommandDesc.Append( KHsRemoteCommandDelimiter );
+    aCommandDesc.Append( iData );
+    }
+
+void THsRCCommand::Copy( const THsRCCommand& aCmdFrom, THsRCCommand& aCmdTo )
+    {
+    aCmdTo.iData.Copy( aCmdFrom.iData );
+    aCmdTo.iType = aCmdFrom.iType;
+    }
+
+THsRemoteControlCommandType THsRCCommand::Type() const
+    {
+    return iType;
+    }
+