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