diff -r 02103bf20ee5 -r 90dbfc0435e3 bluetoothengine/headsetsimulator/profiles/hspprofile/src/features/hspfeaturemanager.cpp --- /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 + }