diff -r 6743bfee309e -r 23264c07fd05 localconnectivityservice/dun/atext/src/DunAtCmdHandler.cpp --- a/localconnectivityservice/dun/atext/src/DunAtCmdHandler.cpp Fri May 14 16:44:53 2010 +0300 +++ b/localconnectivityservice/dun/atext/src/DunAtCmdHandler.cpp Thu May 27 13:45:56 2010 +0300 @@ -377,8 +377,12 @@ iCommand = NULL; iDecodeInfo.iFirstDecode = ETrue; iDecodeInfo.iDecodeIndex = KErrNotFound; + iDecodeInfo.iExtendedIndex = KErrNotFound; iDecodeInfo.iPrevChar = 0; iDecodeInfo.iPrevExists = EFalse; + iDecodeInfo.iAssignFound = EFalse; + iDecodeInfo.iInQuotes = EFalse; + iDecodeInfo.iSpecialFound = EFalse; iEditorModeInfo.iContentFound = EFalse; iCmdPusher = NULL; iEcomListen = NULL; @@ -882,11 +886,8 @@ TDunDecodeInfo oldInfo = iDecodeInfo; iDecodeInfo.iDecodeBuffer.Zero(); // Find start of decode command from input buffer - TBool extendedCmd = EFalse; TInt startIndex = iDecodeInfo.iDecodeIndex; - startIndex = FindStartOfDecodedCommand( iInputBuffer, - startIndex, - extendedCmd ); + startIndex = FindStartOfDecodedCommand( iInputBuffer, startIndex ); if ( startIndex < 0 ) { RestoreOldDecodeInfo( aPeek, oldInfo ); @@ -894,24 +895,12 @@ return EFalse; } // Find end of decode command from input buffer - TBool extendedEnd = EFalse; - TBool oneCharCmd = EFalse; TBool specialCmd = EFalse; TInt endIndex = KErrNotFound; - if ( extendedCmd ) + specialCmd = CheckSpecialCommand( startIndex, endIndex ); + if ( !specialCmd ) { - if( iAtSpecialCmdHandler->IsCompleteSubCommand(iInputBuffer, startIndex, endIndex) == EFalse ) - { - extendedEnd = CheckExtendedCommand( startIndex, endIndex ); - } - } - else - { - specialCmd = CheckSpecialCommand( startIndex, endIndex ); - if ( !specialCmd ) - { - CheckBasicCommand( startIndex, endIndex, oneCharCmd ); - } + FindSubCommand( startIndex, endIndex ); } if ( endIndex < startIndex ) { @@ -926,7 +915,7 @@ iParseInfo.iLimit = cmdLength; } // Next create a new command - if ( !iDecodeInfo.iFirstDecode && !oneCharCmd && !specialCmd ) + if ( !iDecodeInfo.iFirstDecode && !specialCmd ) { _LIT( KAtMsg, "AT" ); iDecodeInfo.iDecodeBuffer.Append( KAtMsg ); @@ -939,10 +928,6 @@ // Set index for next round iDecodeInfo.iFirstDecode = EFalse; iDecodeInfo.iDecodeIndex = endIndex + 1; - if ( extendedEnd ) // skip the extra ';' - { - iDecodeInfo.iDecodeIndex++; - } RestoreOldDecodeInfo( aPeek, oldInfo ); FTRACE(FPrint( _L("CDunAtCmdHandler::ExtractNextDecodedCommand() complete") )); return ETrue; @@ -1008,35 +993,19 @@ // --------------------------------------------------------------------------- // TInt CDunAtCmdHandler::FindStartOfDecodedCommand( TDesC8& aDes, - TInt aStartIndex, - TBool& aExtended ) + TInt aStartIndex ) { FTRACE(FPrint( _L("CDunAtCmdHandler::FindStartOfDecodedCommand()") )); - aExtended = EFalse; TInt i; TInt count = aDes.Length(); for ( i=aStartIndex; i| + // border must be detected but only for a "basic" command, not for + // extended. + if ( iDecodeInfo.iExtendedIndex<0 && iDecodeInfo.iPrevExists && + iDecodeInfo.iPrevChar.IsDigit() && aCharacter.IsAlpha() ) + { + aEndIndex--; + FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder() (N|A) complete") )); + return ETrue; + } + // The code below is for the following type of cases: + // (do not check alphanumeric borders if "=" set without quotes): + // AT+CMD=a + FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder() (skip) complete") )); + return EFalse; + } + if ( !iDecodeInfo.iPrevExists || !aCharacter.IsAlpha() ) + { + FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder() (not found) complete") )); + return EFalse; + } + if ( iDecodeInfo.iPrevChar.IsAlpha() ) + { + // The check below detects the following type of cases + // (note that special handling is needed to separate the Alpha|Alpha boundary): + // AT&FE0 + if ( iDecodeInfo.iSpecialFound ) + { + // Special command was found before and this is Alpha|Alpha boundary -> end + aEndIndex--; + FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder() (special) complete") )); + return ETrue; + } + // The code below is for the following type of cases + // (note there is no border between C|M, for example -> continue): + // ATCMD + FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder() (continue) complete") )); + return EFalse; + } + // The code below is for skipping the following type of cases: + // AT+CMD [the '+' must be skipped] + if ( aEndIndex-1 == iDecodeInfo.iExtendedIndex ) + { + FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder() (extended) complete") )); + return EFalse; + } + // The code below is for the following type of cases: + // ATCMD?ATCMD + FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder() (boundary) complete") )); + aEndIndex--; + return ETrue; + } + +// --------------------------------------------------------------------------- +// Finds subcommand +// --------------------------------------------------------------------------- +// +TInt CDunAtCmdHandler::FindSubCommand( TInt aStartIndex, TInt& aEndIndex ) + { + FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommand()") )); aEndIndex = aStartIndex; - aOneCharCmd = EFalse; - TBool inQuotes = EFalse; + TBool found = EFalse; TInt length = iInputBuffer.Length(); - iDecodeInfo.iPrevExists = EFalse; - if ( aStartIndex < length ) - { - TChar character = iInputBuffer[aStartIndex]; - if ( IsOneCharacterCommand(aStartIndex) ) - { - aOneCharCmd = ETrue; - // Without "endIndex++" here - FTRACE(FPrint( _L("CDunAtCmdHandler::CheckBasicCommand() (X) complete") )); - return KErrNone; - } - } + iDecodeInfo.iAssignFound = EFalse; + iDecodeInfo.iInQuotes = EFalse; + iDecodeInfo.iExtendedIndex = KErrNotFound; + SaveNotFoundCharDecodeState(); + iAtSpecialCmdHandler->ResetComparisonBuffer(); // just to be sure for ( ; aEndIndex + if ( IsDelimiterCharacter(character) ) { aEndIndex--; - FTRACE(FPrint( _L("CDunAtCmdHandler::CheckBasicCommand() (S or extended) complete") )); + FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommand() (delimiter) complete") )); return KErrNone; } - if ( !iDecodeInfo.iPrevExists ) + // The check below detects the following type of cases: + // ATCMD+CMD [first + as delimiter] + // AT+CMD+CMD [second + as delimiter] + if ( IsExtendedCharacter(character) ) { - iDecodeInfo.iPrevExists = ETrue; - iDecodeInfo.iPrevChar = character; - continue; - } - if ( IsOneCharacterCommand(aEndIndex) ) - { - aEndIndex--; - FTRACE(FPrint( _L("CDunAtCmdHandler::CheckBasicCommand() (one char) complete") )); + found = IsExtendedBorder( character, aStartIndex, aEndIndex ); + if ( !found ) + { + continue; + } + FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommand() (extended) complete") )); return KErrNone; } - if ( character.IsAlpha() && !iDecodeInfo.iPrevChar.IsAlpha() ) + found = FindSubCommandAlphaBorder( character, aEndIndex ); + if ( found ) { - aEndIndex--; - FTRACE(FPrint( _L("CDunAtCmdHandler::CheckBasicCommand() (boundary) complete") )); + FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommand() (alpha sub) complete") )); return KErrNone; } - iDecodeInfo.iPrevExists = ETrue; - iDecodeInfo.iPrevChar = character; + SaveFoundCharDecodeState( character ); } aEndIndex--; - FTRACE(FPrint( _L("CDunAtCmdHandler::CheckBasicCommand() (not found) complete") )); + FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommand() (not found) complete") )); return KErrNotFound; } // --------------------------------------------------------------------------- -// Check if any one character command -// --------------------------------------------------------------------------- -// -TBool CDunAtCmdHandler::IsOneCharacterCommand( TInt aIndex ) - { - FTRACE(FPrint( _L("CDunAtCmdHandler::IsOneCharacterCommand()") )); - if ( aIndex<0 || aIndex>=iInputBuffer.Length() ) - { - FTRACE(FPrint( _L("CDunAtCmdHandler::IsOneCharacterCommand() (index out of bounds) complete") )); - return EFalse; - } - TChar character = iInputBuffer[aIndex]; - if ( character==',' || character==';' || character=='@' || character=='!' || - IsOneCharacterACommand(aIndex) ) - { - FTRACE(FPrint( _L("CDunAtCmdHandler::IsOneCharacterCommand() complete") )); - return ETrue; - } - FTRACE(FPrint( _L("CDunAtCmdHandler::IsOneCharacterCommand() (not found) complete") )); - return EFalse; - } - -// --------------------------------------------------------------------------- -// Check if one character "A" command -// --------------------------------------------------------------------------- -// -TBool CDunAtCmdHandler::IsOneCharacterACommand( TInt aIndex ) - { - FTRACE(FPrint( _L("CDunAtCmdHandler::IsOneCharacterACommand()") )); - if ( aIndex<0 || aIndex>=iInputBuffer.Length() ) - { - FTRACE(FPrint( _L("CDunAtCmdHandler::IsOneCharacterACommand() (index out of bounds) complete") )); - return EFalse; - } - if ( iInputBuffer[aIndex]!='a' && iInputBuffer[aIndex]!='A' ) - { - FTRACE(FPrint( _L("CDunAtCmdHandler::IsOneCharacterACommand() (not found) complete") )); - return EFalse; - } - TBool prevAlpha = EFalse; - TBool nextAlpha = EFalse; - TBool nextSlash = EFalse; - TInt length = iInputBuffer.Length(); - if ( iDecodeInfo.iPrevExists && iDecodeInfo.iPrevChar.IsAlpha() ) - { - prevAlpha = ETrue; - } - if ( aIndex+1 < length ) - { - TChar nextChar = iInputBuffer[aIndex+1]; - if ( nextChar.IsAlpha() ) - { - nextAlpha = ETrue; - } - if ( nextChar == '/' ) - { - nextSlash = ETrue; - } - } - if ( prevAlpha || nextAlpha || nextSlash ) - { - FTRACE(FPrint( _L("CDunAtCmdHandler::IsOneCharacterACommand() (not found) complete") )); - return EFalse; - } - FTRACE(FPrint( _L("CDunAtCmdHandler::IsOneCharacterACommand() (complete) complete") )); - return ETrue; - } - -// --------------------------------------------------------------------------- // Check if "A/" command // --------------------------------------------------------------------------- //