bluetoothengine/headsetsimulator/core/src/RemoteControl/hsremotecontroldatahandler.cpp
--- /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 );
+ }
+