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: #include "T_ParseBaseData.h" sl@0: sl@0: // Commands sl@0: sl@0: _LIT( KCmdDrive, "Drive" ); sl@0: _LIT( KCmdDriveAndPath, "DriveAndPath" ); sl@0: _LIT( KCmdDrivePresent, "DrivePresent" ); sl@0: _LIT( KCmdExt, "Ext" ); sl@0: _LIT( KCmdExtPresent, "ExtPresent" ); sl@0: _LIT( KCmdFullName, "FullName" ); sl@0: _LIT( KCmdIsExtWild, "IsExtWild" ); sl@0: _LIT( KCmdIsKMatchAny, "IsKMatchAny" ); sl@0: _LIT( KCmdIsKMatchOne, "IsKMatchOne" ); sl@0: _LIT( KCmdIsNameWild, "IsNameWild" ); sl@0: _LIT( KCmdIsRoot, "IsRoot" ); sl@0: _LIT( KCmdIsWild, "IsWild" ); sl@0: _LIT( KCmdName, "Name" ); sl@0: _LIT( KCmdNameAndExt, "NameAndExt" ); sl@0: _LIT( KCmdNameOrExtPresent, "NameOrExtPresent" ); sl@0: _LIT( KCmdNamePresent, "NamePresent" ); sl@0: _LIT( KCmdPath, "Path" ); sl@0: _LIT( KCmdPathPresent, "PathPresent" ); sl@0: sl@0: // Parameters sl@0: _LIT( KParamExpected, "expected" ); sl@0: sl@0: sl@0: CT_ParseBaseData::~CT_ParseBaseData() sl@0: /** sl@0: * Destructor. sl@0: */ sl@0: { sl@0: } sl@0: sl@0: sl@0: TAny* CT_ParseBaseData::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 GetParse(); sl@0: } sl@0: sl@0: TBool CT_ParseBaseData::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 entry in the ini file requiring the command to be processed sl@0: * sl@0: * @return ETrue if the command is processed sl@0: */ sl@0: { sl@0: TBool retVal = ETrue; sl@0: sl@0: sl@0: if ( aCommand == KCmdDrive ) sl@0: { sl@0: DoCmdDrive( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdDriveAndPath ) sl@0: { sl@0: DoCmdDriveAndPath( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdDrivePresent ) sl@0: { sl@0: DoCmdDrivePresent( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdExt ) sl@0: { sl@0: DoCmdExt( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdExtPresent ) sl@0: { sl@0: DoCmdExtPresent( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdFullName ) sl@0: { sl@0: DoCmdFullName( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdIsKMatchAny ) sl@0: { sl@0: DoCmdIsKMatchAny( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdIsKMatchOne ) sl@0: { sl@0: DoCmdIsKMatchOne( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdIsExtWild ) sl@0: { sl@0: DoCmdIsExtWild( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdIsNameWild ) sl@0: { sl@0: DoCmdIsNameWild( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdIsRoot) sl@0: { sl@0: DoCmdIsRoot( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdIsWild ) sl@0: { sl@0: DoCmdIsWild( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdName ) sl@0: { sl@0: DoCmdName( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdNameAndExt ) sl@0: { sl@0: DoCmdNameAndExt( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdNameOrExtPresent ) sl@0: { sl@0: DoCmdNameOrExtPresent( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdNamePresent ) sl@0: { sl@0: DoCmdNamePresent( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdPath ) sl@0: { sl@0: DoCmdPath( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdPathPresent ) sl@0: { sl@0: DoCmdPathPresent( 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: sl@0: void CT_ParseBaseData::DoCmdDrive( const TDesC& aSection ) sl@0: /** Gets the drive letter using Drive(). */ sl@0: { sl@0: INFO_PRINTF1( _L( "Drive()" ) ); sl@0: sl@0: TPtrC result = GetParse()->Drive(); sl@0: INFO_PRINTF2(_L("Drive() return: %S"), &result); sl@0: sl@0: TPtrC expected; sl@0: if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( result != expected ) sl@0: { sl@0: ERR_PRINTF3(_L("Drive() returns %S but expected %S"), &result, &expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdDriveAndPath( const TDesC& aSection ) sl@0: /** Gets the path and drive letter using DriveAndPath(). */ sl@0: { sl@0: INFO_PRINTF1( _L( "DriveAndPath()" ) ); sl@0: sl@0: TPtrC result = GetParse()->DriveAndPath(); sl@0: INFO_PRINTF2(_L("DriveAndPath() return: %S"), &result); sl@0: sl@0: TPtrC expected; sl@0: if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( result != expected ) sl@0: { sl@0: ERR_PRINTF3(_L("DriveAndPath() returns %S but expected %S"), &result, &expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: sl@0: sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdDrivePresent( const TDesC& aSection ) sl@0: /** Tests whether a drive is present using DrivePresent(). */ sl@0: { sl@0: INFO_PRINTF1( _L( "DrivePresent()" ) ); sl@0: sl@0: TBool result = GetParse()->DrivePresent(); sl@0: sl@0: TPtrC strIsTrue = result ? _L("TRUE") : _L("FALSE"); sl@0: INFO_PRINTF2(_L("DrivePresent() return: %S"), &strIsTrue); sl@0: sl@0: TBool expected; sl@0: if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( (result>0) != (expected>0) ) sl@0: { sl@0: ERR_PRINTF3(_L("DrivePresent() returns %d but expected %d"), result, expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdExt( const TDesC& aSection ) sl@0: /** Gets the file extension using Ext(). */ sl@0: { sl@0: INFO_PRINTF1( _L( "Ext()" ) ); sl@0: sl@0: TPtrC result = GetParse()->Ext(); sl@0: INFO_PRINTF2(_L("Ext() returns: %S"), &result); sl@0: sl@0: TPtrC expected; sl@0: if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( result != expected ) sl@0: { sl@0: ERR_PRINTF3(_L("Ext() returns %S but expected %S"), &result, &expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdExtPresent( const TDesC& aSection ) sl@0: /** Tests whether an extension is present using ExtPresent(). */ sl@0: { sl@0: INFO_PRINTF1( _L( "ExtPresent()" ) ); sl@0: sl@0: TBool result = GetParse()->ExtPresent(); sl@0: sl@0: TPtrC strIsTrue = result ? _L("TRUE") : _L("FALSE"); sl@0: INFO_PRINTF2(_L("ExtPresent() return: %S"), &strIsTrue); sl@0: sl@0: TBool expected; sl@0: if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( (result>0) != (expected>0) ) sl@0: { sl@0: ERR_PRINTF3(_L("ExtPresent() returns %d but expected %d"), result, expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdFullName( const TDesC& aSection ) sl@0: /** Gets the complete file specification using FullName(). */ sl@0: { sl@0: INFO_PRINTF1( _L( "FullName()" ) ); sl@0: sl@0: TPtrC result = GetParse()->FullName(); sl@0: INFO_PRINTF2(_L("FullName() return: %S"), &result); sl@0: sl@0: TPtrC expected; sl@0: if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( result != expected ) sl@0: { sl@0: ERR_PRINTF3(_L("FullName() returns %S but expected %S"), &result, &expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdIsExtWild( const TDesC& aSection ) sl@0: /** Tests whether the extension in the fully parsed specification contains one or sl@0: * more wildcard characters using IsExtWild() sl@0: */ sl@0: { sl@0: INFO_PRINTF1( _L( "IsExtWild()" ) ); sl@0: sl@0: TBool result = GetParse()->IsExtWild(); sl@0: TPtrC temp = result ? _L("TRUE") : _L("FALSE"); sl@0: INFO_PRINTF2(_L("IsExtWild() return: %S"), &temp); sl@0: sl@0: TBool expected; sl@0: if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: //NB! IsExtWild can return values >1 sl@0: if ( (result>0) != (expected>0) ) sl@0: { sl@0: ERR_PRINTF3(_L("IsExtWild() returns %S but expected %S"), &result, &expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdIsKMatchAny( const TDesC& aSection ) sl@0: /** Tests whether the name or the extension contains asterisk wildcards usinbg IsKMatchAny(). */ sl@0: { sl@0: INFO_PRINTF1( _L( "IsKMatchAny()" ) ); sl@0: sl@0: TBool result = GetParse()->IsKMatchAny(); sl@0: TPtrC temp = result ? _L("TRUE") : _L("FALSE"); sl@0: INFO_PRINTF2(_L("IsKMatchAny() return: %S"), &temp); sl@0: sl@0: TBool expected; sl@0: if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( (result>0) != (expected>0) ) sl@0: { sl@0: ERR_PRINTF3(_L("IsKMatchAny() returns %d but expected %d"), result, expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdIsKMatchOne( const TDesC& aSection ) sl@0: /** Tests whether the name or the extension contains a question mark wildcard using IsKMatchOne() */ sl@0: { sl@0: INFO_PRINTF1( _L( "IsKMatchOne()" ) ); sl@0: sl@0: TBool result = GetParse()->IsKMatchOne(); sl@0: TPtrC temp = result ? _L("TRUE") : _L("FALSE"); sl@0: INFO_PRINTF2(_L("IsKMatchOne() return: %S"), &temp); sl@0: sl@0: TBool expected; sl@0: if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( (result>0) != (expected>0) ) sl@0: { sl@0: ERR_PRINTF3(_L("IsKMatchOne() returns %d but expected %d"), result, expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdIsNameWild( const TDesC& aSection ) sl@0: /** Tests whether the filename in the fully parsed specification contains one or more wildcard sl@0: * characters using IsNameWild() sl@0: */ sl@0: { sl@0: INFO_PRINTF1( _L( "IsNameWild()" ) ); sl@0: sl@0: TBool result = GetParse()->IsNameWild(); sl@0: TPtrC temp = result ? _L("TRUE") : _L("FALSE"); sl@0: INFO_PRINTF2(_L("IsNameWild() return: %S"), &temp); sl@0: sl@0: TBool expected; sl@0: if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( (result>0) != (expected>0) ) sl@0: { sl@0: ERR_PRINTF3(_L("IsNameWild() returns %d but expected %d"), result, expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdIsRoot( const TDesC& aSection ) sl@0: /** Tests whether the path in the fully parsed specification is the root directory using IsRoot(). */ sl@0: { sl@0: INFO_PRINTF1( _L( "IsRoot()" ) ); sl@0: sl@0: TBool result = GetParse()->IsRoot(); sl@0: TPtrC temp = result ? _L("TRUE") : _L("FALSE"); sl@0: INFO_PRINTF2(_L("IsRoot() return: %S"), &temp); sl@0: sl@0: TBool expected; sl@0: if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( (result>0) != (expected>0) ) sl@0: { sl@0: ERR_PRINTF3(_L("IsRoot() returns %d but expected %d"), result, expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdIsWild( const TDesC& aSection ) sl@0: /** Tests whether the filename or the extension in the fully parsed specification contains one or sl@0: * more wildcard characters using IsWild() sl@0: */ sl@0: { sl@0: INFO_PRINTF1( _L( "IsWild()" ) ); sl@0: sl@0: TBool result = GetParse()->IsWild(); sl@0: TPtrC temp = result ? _L("TRUE") : _L("FALSE"); sl@0: INFO_PRINTF2(_L("IsWild() return: %S"), &temp); sl@0: sl@0: TBool expected; sl@0: if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( (result>0) != (expected>0) ) sl@0: { sl@0: ERR_PRINTF3(_L("IsWild() returns %d but expected %d"), result, expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdName( const TDesC& aSection ) sl@0: /** Gets the file name using Name(). */ sl@0: { sl@0: INFO_PRINTF1( _L( "Name()" ) ); sl@0: sl@0: TPtrC result = GetParse()->Name(); sl@0: INFO_PRINTF2(_L( "Name() return: %S" ), &result); sl@0: sl@0: TPtrC expected; sl@0: if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( result != expected ) sl@0: { sl@0: ERR_PRINTF3(_L("Name() returns %S but expected %S"), &result, &expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdNameOrExtPresent( const TDesC& aSection ) sl@0: /** Tests whether a name or an extension are present using NameOrExtPresent(). */ sl@0: { sl@0: INFO_PRINTF1( _L( "NameOrExtPresent()" ) ); sl@0: sl@0: TBool result = GetParse()->NameOrExtPresent(); sl@0: TPtrC temp = result ? _L("TRUE") : _L("FALSE"); sl@0: INFO_PRINTF2(_L("NameOrExtPresent() return: %S"), &temp); sl@0: sl@0: TBool expected; sl@0: if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( (result>0) != (expected>0) ) sl@0: { sl@0: ERR_PRINTF3(_L("NameOrExtPresent() returns %d but expected %d"), result, expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdNameAndExt( const TDesC& aSection ) sl@0: /** Gets the file name and extension using NameAndExt(). */ sl@0: { sl@0: INFO_PRINTF1( _L( "NameAndExt()" ) ); sl@0: sl@0: TPtrC result = GetParse()->NameAndExt(); sl@0: INFO_PRINTF2( _L( "NameAndExt() return: %S" ), &result ); sl@0: sl@0: TPtrC expected; sl@0: if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( result != expected ) sl@0: { sl@0: ERR_PRINTF3(_L("NameAndExt() returns %S but expected %S"), &result, &expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdNamePresent( const TDesC& aSection ) sl@0: /** Tests whether a file name is present using NamePresent(). */ sl@0: { sl@0: INFO_PRINTF1( _L( "NamePresent()" ) ); sl@0: sl@0: TBool result = GetParse()->NamePresent(); sl@0: TPtrC temp = result ? _L("TRUE") : _L("FALSE"); sl@0: INFO_PRINTF2(_L("NamePresent() return: %S"), &temp); sl@0: sl@0: TBool expected; sl@0: if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( (result>0) != (expected>0) ) sl@0: { sl@0: ERR_PRINTF3(_L("NamePresent() returns %d but expected %d"), result, expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdPath( const TDesC& aSection ) sl@0: /** Gets the path using Path(). */ sl@0: { sl@0: INFO_PRINTF1( _L( "Path()" ) ); sl@0: sl@0: TPtrC result = GetParse()->Path(); sl@0: INFO_PRINTF2( _L( "Path() return: %S" ), &result ); sl@0: sl@0: TPtrC expected; sl@0: if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( result != expected ) sl@0: { sl@0: ERR_PRINTF3(_L("Path() returns %S but expected %S"), &result, &expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ParseBaseData::DoCmdPathPresent( const TDesC& aSection ) sl@0: /** Tests whether a path is present using PathPresent(). */ sl@0: { sl@0: INFO_PRINTF1( _L( "PathPresent()" ) ); sl@0: sl@0: TBool result = GetParse()->PathPresent(); sl@0: TPtrC temp = result ? _L("TRUE") : _L("FALSE"); sl@0: INFO_PRINTF2(_L("PathPresent() return: %S"), &temp); sl@0: sl@0: TBool expected; sl@0: if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) ) sl@0: { sl@0: if ( (result>0) != (expected>0) ) sl@0: { sl@0: ERR_PRINTF3(_L("PathPresent() returns %d but expected %d"), result, expected); sl@0: SetBlockResult( EFail); sl@0: } sl@0: } sl@0: } sl@0: