sl@0: /* sl@0: * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: sl@0: #include "t_cg711decoderintfcdata.h" sl@0: sl@0: /*@{*/ sl@0: //Enumeration Literals sl@0: _LIT(KEDecALaw, "EDecALaw"); sl@0: _LIT(KEDecULaw, "EDecULaw" ); sl@0: /*@}*/ sl@0: sl@0: /*@{*/ sl@0: //Command literals sl@0: _LIT(KCmdNewL, "NewL"); sl@0: _LIT(KCmdDestructor, "~"); sl@0: _LIT(KCmdSetDecoderMode, "SetDecoderMode"); sl@0: _LIT(KCmdSetCng, "KCmdSetCng"); sl@0: /*@}*/ sl@0: sl@0: /*@{*/ sl@0: //INI Section name literals sl@0: _LIT(KDecoder, "Decoder"); sl@0: _LIT(KCng, "CNG"); sl@0: /*@}*/ sl@0: sl@0: const CDataWrapperBase::TEnumEntryTable iEnumDecoders[] = sl@0: { sl@0: { KEDecALaw, 0/*EDecALaw */}, sl@0: { KEDecULaw, 1/*EDecULaw*/ } sl@0: }; sl@0: sl@0: sl@0: /** sl@0: * Private constructor. First phase construction sl@0: */ sl@0: CT_CG711DecoderIntfcData::CT_CG711DecoderIntfcData() sl@0: : sl@0: iG711Decoder(NULL), sl@0: iCng(EFalse) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Second phase construction sl@0: * sl@0: * @internalComponent sl@0: * @return N/A sl@0: * @pre None sl@0: * @post None sl@0: * @leave system wide error sl@0: */ sl@0: //void CT_CG711DecoderIntfcData::ConstructL() sl@0: // { sl@0: // sl@0: // } sl@0: sl@0: /** sl@0: * Two phase constructor sl@0: * sl@0: * @leave system wide error sl@0: */ sl@0: CT_CG711DecoderIntfcData* CT_CG711DecoderIntfcData::NewL() sl@0: { sl@0: CT_CG711DecoderIntfcData* self = new (ELeave)CT_CG711DecoderIntfcData(); sl@0: return self; sl@0: } sl@0: sl@0: /** sl@0: * Return a pointer to the object that the data wraps sl@0: * sl@0: * @return pointer to the object that the data wraps sl@0: */ sl@0: TAny* CT_CG711DecoderIntfcData::GetObject() sl@0: { sl@0: return iG711Decoder; sl@0: } sl@0: sl@0: /** sl@0: * Public destructor sl@0: */ sl@0: CT_CG711DecoderIntfcData::~CT_CG711DecoderIntfcData() sl@0: { sl@0: DestroyData(); sl@0: } sl@0: sl@0: /** sl@0: * Helper method for DoCmdDestructor sl@0: */ sl@0: void CT_CG711DecoderIntfcData::DestroyData() sl@0: { sl@0: if (iG711Decoder != NULL) sl@0: { sl@0: delete iG711Decoder; sl@0: iG711Decoder = NULL; sl@0: } sl@0: } sl@0: sl@0: /** sl@0: * Process a command read from the Ini file sl@0: * @param aCommand - The command to process sl@0: * @param aSection - The section get from the *.ini file of the project T_Wlan sl@0: * @param aAsyncErrorIndex - Command index dor async calls to returns errors to sl@0: * @return TBool - ETrue if the command is process sl@0: * @leave - system wide error sl@0: */ sl@0: TBool CT_CG711DecoderIntfcData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) sl@0: { sl@0: TBool ret = ETrue; sl@0: sl@0: if (aCommand == KCmdNewL) sl@0: { sl@0: DoCmdNewL(); sl@0: } sl@0: else if (aCommand == KCmdDestructor) sl@0: { sl@0: DoCmdDestructor(); sl@0: } sl@0: else if (aCommand == KCmdSetDecoderMode) sl@0: { sl@0: DoCmdSetDecoderMode(aSection); sl@0: } sl@0: else if (aCommand == KCmdSetCng) sl@0: { sl@0: DoCmdSetCng(aSection); sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF1(_L("Unknown command.")); sl@0: ret=EFalse; sl@0: } sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: /** sl@0: * Create an Instance of CG711DecoderIntfc sl@0: * @param none sl@0: * @return none sl@0: */ sl@0: void CT_CG711DecoderIntfcData::DoCmdNewL() sl@0: { sl@0: INFO_PRINTF1(_L("*START*CT_CG711DecoderIntfcData::DoCmdNewL()")); sl@0: sl@0: TRAPD(error, CT_CG711DecoderIntfcData::NewL()); sl@0: if(KErrNone!=error) sl@0: { sl@0: ERR_PRINTF2(_L("> Could not create CG711HwDevice: %d"), error); sl@0: SetError(error); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("*END*CT_CG711DecoderIntfcData::DoCmdNewL()")); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: * Destroy an instance of CG711DecoderIntfc sl@0: * @param none sl@0: * @return none sl@0: */ sl@0: void CT_CG711DecoderIntfcData::DoCmdDestructor() sl@0: { sl@0: INFO_PRINTF1(_L("*START*CT_CG711DecoderIntfcData::DoCmdDestructor()")); sl@0: DestroyData(); sl@0: INFO_PRINTF1(_L("*END*CT_CG711DecoderIntfcData::DoCmdDestructor()")); sl@0: } sl@0: sl@0: /** sl@0: * Set decoder mode sl@0: * @param aSection - Section to read param from the ini file sl@0: * @return none sl@0: */ sl@0: void CT_CG711DecoderIntfcData::DoCmdSetDecoderMode(const TTEFSectionName& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CG711DecoderIntfcData::DoCmdSetDecoderMode()")); sl@0: TInt expectedValue; sl@0: if (!GetEnumFromConfig(aSection, KDecoder, iEnumDecoders, expectedValue)) sl@0: { sl@0: INFO_PRINTF2(_L("Parameter %S was not found in INI file."), &KDecoder); sl@0: SetBlockResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: TInt error = iG711Decoder->SetDecoderMode((CG711DecoderIntfc::TDecodeMode)expectedValue); sl@0: if ( KErrNone != error ) sl@0: { sl@0: ERR_PRINTF2(_L("[%d] SetDecoderMode()"), error); sl@0: SetError(error); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("*END*CT_CG711DecoderIntfcData::DoCmdSetDecoderMode()")); sl@0: } sl@0: } sl@0: } sl@0: sl@0: /** sl@0: * @param aSection - Section to read param from the ini file sl@0: * @return none sl@0: */ sl@0: void CT_CG711DecoderIntfcData::DoCmdSetCng(const TTEFSectionName& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("*START*CT_CG711DecoderIntfcData::DoCmdSetCng()")); sl@0: sl@0: if(!GetBoolFromConfig(aSection, KCng, iCng)) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCng); sl@0: SetBlockResult(EFail); sl@0: return; sl@0: } sl@0: else sl@0: { sl@0: TInt error = iG711Decoder->SetCng(iCng); sl@0: if ( KErrNone != error ) sl@0: { sl@0: ERR_PRINTF2(_L("[%d] SetCng() error "), error); sl@0: SetError(error); sl@0: return; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("*END*CT_CG711DecoderIntfcData::DoCmdSetCng()")); sl@0: } sl@0: } sl@0: } sl@0: