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: #include "T_EComResolverParamsData.h" sl@0: sl@0: sl@0: /*@{*/ sl@0: /// Parameters sl@0: _LIT(KExpectedString, "expected_string"); sl@0: _LIT(KExpectedBool, "expected_bool"); sl@0: _LIT(KDataType, "data_type"); sl@0: _LIT(KGenericMatch, "generic_match"); sl@0: _LIT(KWildcardMatch, "wildcard_match"); sl@0: sl@0: /// TEcomResolverParams sl@0: _LIT(KCmdDataType, "DataType"); sl@0: _LIT(KCmdSetDataType, "SetDataType"); sl@0: _LIT(KCmdSetGenericMatch, "SetGenericMatch"); sl@0: _LIT(KCmdIsGenericMatch, "IsGenericMatch"); sl@0: _LIT(KCmdSetWildcardMatch, "SetWildcardMatch"); sl@0: _LIT(KCmdIsWildcardMatch, "IsWildcardMatch"); sl@0: sl@0: _LIT( KEmptyString, ""); sl@0: /*@}*/ sl@0: sl@0: ////////////////////////////////////////////////////////////////////// sl@0: // Construction/Destruction sl@0: ////////////////////////////////////////////////////////////////////// sl@0: sl@0: /** sl@0: * Two phase constructor sl@0: */ sl@0: CT_EComResolverParamsData* CT_EComResolverParamsData::NewL() sl@0: { sl@0: CT_EComResolverParamsData* ret=new (ELeave) CT_EComResolverParamsData(); sl@0: CleanupStack::PushL(ret); sl@0: ret->ConstructL(); sl@0: CleanupStack::Pop(ret); sl@0: return ret; sl@0: } sl@0: sl@0: /** sl@0: * Constructor. First phase construction sl@0: */ sl@0: CT_EComResolverParamsData::CT_EComResolverParamsData() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Second phase construction sl@0: */ sl@0: void CT_EComResolverParamsData::ConstructL() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Destructor sl@0: */ sl@0: CT_EComResolverParamsData::~CT_EComResolverParamsData() sl@0: { sl@0: DestroyData(); sl@0: } sl@0: sl@0: void CT_EComResolverParamsData::DestroyData() sl@0: { sl@0: } sl@0: sl@0: sl@0: TAny* CT_EComResolverParamsData::GetObject() 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: { sl@0: return &iResolverParams; sl@0: }; sl@0: sl@0: ////////////////////////////////////////////////////////////////////// sl@0: // Read data from INI file sl@0: ////////////////////////////////////////////////////////////////////// sl@0: sl@0: TBool CT_EComResolverParamsData::GetExpectedString(const TDesC& aSection, TPtrC& aExpectedString) sl@0: { sl@0: aExpectedString.Set(KEmptyString); sl@0: return GetStringFromConfig(aSection, KExpectedString(), aExpectedString); sl@0: } sl@0: sl@0: TBool CT_EComResolverParamsData::GetDataType(const TDesC& aSection, TBuf8& aDataType) sl@0: { sl@0: TPtrC dataType(KEmptyString); sl@0: TBool ret=GetStringFromConfig(aSection, KDataType(), dataType); sl@0: if ( ret ) sl@0: { sl@0: aDataType.Copy(dataType); sl@0: } sl@0: return ret; sl@0: } sl@0: sl@0: TBool CT_EComResolverParamsData::GetExpectedBool(const TDesC& aSection, TBool& aBool) sl@0: { sl@0: aBool = EFalse; sl@0: return GetBoolFromConfig(aSection, KExpectedBool(), aBool ); sl@0: } sl@0: sl@0: TBool CT_EComResolverParamsData::GetGenericMatch(const TDesC& aSection, TBool& aGenericMatch) sl@0: { sl@0: aGenericMatch = EFalse; sl@0: return GetBoolFromConfig(aSection, KGenericMatch(), aGenericMatch ); sl@0: } sl@0: sl@0: TBool CT_EComResolverParamsData::GetWildcardMatch(const TDesC& aSection, TBool& aWildcardMatch) sl@0: { sl@0: aWildcardMatch = EFalse; sl@0: return GetBoolFromConfig(aSection, KWildcardMatch(), aWildcardMatch ); sl@0: } sl@0: sl@0: TBool CT_EComResolverParamsData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) sl@0: /** sl@0: * Process a command read from the ini file sl@0: * sl@0: * @param aCommand The command to process sl@0: * @param aSection The section in the ini containing data for the command sl@0: * @param aAsyncErrorIndex Command index for async calls to return errors to sl@0: * sl@0: * @return ETrue if the command is processed sl@0: * sl@0: * @leave System wide error sl@0: */ sl@0: { sl@0: TBool retVal=ETrue; sl@0: sl@0: if ( aCommand==KCmdDataType ) sl@0: { sl@0: DoCmdDataType(aSection); sl@0: } sl@0: else if ( aCommand==KCmdSetDataType ) sl@0: { sl@0: DoCmdSetDataType(aSection); sl@0: } sl@0: else if ( aCommand==KCmdSetGenericMatch ) sl@0: { sl@0: DoCmdSetGenericMatch(aSection); sl@0: } sl@0: else if ( aCommand==KCmdIsGenericMatch ) sl@0: { sl@0: DoCmdIsGenericMatch(aSection); sl@0: } sl@0: else if ( aCommand==KCmdSetWildcardMatch ) sl@0: { sl@0: DoCmdSetWildcardMatch(aSection); sl@0: } sl@0: else if ( aCommand==KCmdIsWildcardMatch ) sl@0: { sl@0: DoCmdIsWildcardMatch(aSection); sl@0: } sl@0: else sl@0: { sl@0: retVal=EFalse; sl@0: } sl@0: sl@0: return retVal; sl@0: } sl@0: sl@0: void CT_EComResolverParamsData::DoCmdDataType(const TDesC& aSection) sl@0: { sl@0: TBuf actualValue; sl@0: actualValue.Copy(iResolverParams.DataType()); sl@0: INFO_PRINTF2(_L("DataType %S"), &actualValue); sl@0: sl@0: TPtrC expectedValue; sl@0: if (GetExpectedString(aSection, expectedValue)) sl@0: { sl@0: if (actualValue!=expectedValue) sl@0: { sl@0: ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_EComResolverParamsData::DoCmdSetDataType(const TDesC& aSection) sl@0: { sl@0: if (!GetDataType(aSection, iDataType)) sl@0: { sl@0: ERR_PRINTF1(_L("Not enought arguments")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: iResolverParams.SetDataType(iDataType); sl@0: } sl@0: } sl@0: sl@0: void CT_EComResolverParamsData::DoCmdSetGenericMatch(const TDesC& aSection) sl@0: { sl@0: TBool setGenericMatch; sl@0: if (!GetGenericMatch(aSection, setGenericMatch)) sl@0: { sl@0: ERR_PRINTF1(_L("Not enought arguments")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: iResolverParams.SetGenericMatch(setGenericMatch); sl@0: } sl@0: } sl@0: sl@0: void CT_EComResolverParamsData::DoCmdIsGenericMatch(const TDesC& aSection) sl@0: { sl@0: TBool actualValue=iResolverParams.IsGenericMatch(); sl@0: INFO_PRINTF2(_L("IsGenericMatch %d"), actualValue); sl@0: sl@0: TBool expectedValue; sl@0: if (GetExpectedBool(aSection, expectedValue)) sl@0: { sl@0: if (actualValue!=expectedValue) sl@0: { sl@0: ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_EComResolverParamsData::DoCmdSetWildcardMatch(const TDesC& aSection) sl@0: { sl@0: TBool setWildcardMatch; sl@0: if (!GetWildcardMatch(aSection, setWildcardMatch)) sl@0: { sl@0: ERR_PRINTF1(_L("Not enought arguments")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: iResolverParams.SetWildcardMatch(setWildcardMatch); sl@0: } sl@0: } sl@0: sl@0: void CT_EComResolverParamsData::DoCmdIsWildcardMatch(const TDesC& aSection) sl@0: { sl@0: TBool actualValue=iResolverParams.IsWildcardMatch(); sl@0: INFO_PRINTF2(_L("IsWildcardMatch %d"), actualValue); sl@0: sl@0: TBool expectedValue; sl@0: if (GetExpectedBool(aSection, expectedValue)) sl@0: { sl@0: if (actualValue!=expectedValue) sl@0: { sl@0: ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: