bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfplastnumberredialing.cpp
--- /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;
+ }