telutils/phoneparser/src/CPhoneGsmSsCallParser.cpp
changeset 0 ff3b6d0fd310
child 19 7d48bed6ce0c
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Parser for call concerned SS procedures.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "CPhoneGsmSsCallParser.h"
       
    21 #include    "CPhoneGsmParserResult.h"
       
    22 #include    "CPhoneGsmOptionContainer.h"
       
    23 
       
    24 // CONSTANTS
       
    25 
       
    26 const TInt KPhoneCommandLength = 1;
       
    27 
       
    28 // The length of the following are expected to be KPhoneCommandLength.
       
    29 _LIT( KPhoneCommand0, "0" );
       
    30 _LIT( KPhoneCommand1, "1" );
       
    31 _LIT( KPhoneCommand2, "2" );
       
    32 _LIT( KPhoneCommand3, "3" );
       
    33 _LIT( KPhoneCommand4, "4" );
       
    34 
       
    35 // 2 character commands.
       
    36 const TInt KPhoneCommandXLength = 2;
       
    37 _LIT( KPhoneCommand2X, "2" );
       
    38 _LIT( KPhoneCommand1X, "1" );
       
    39 
       
    40 // ============================ MEMBER FUNCTIONS ===============================
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CPhoneGsmSsCallParser::CPhoneGsmSsCallParser
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 CPhoneGsmSsCallParser::CPhoneGsmSsCallParser()
       
    47     {
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CPhoneGsmSsCallParser::NewLC
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 CPhoneGsmSsCallParser* CPhoneGsmSsCallParser::NewLC()
       
    55     {
       
    56     CPhoneGsmSsCallParser* self = 
       
    57         new ( ELeave ) CPhoneGsmSsCallParser;
       
    58     
       
    59     CleanupStack::PushL( self );
       
    60         
       
    61     return self;
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CPhoneGsmSsCallParser::ParseL
       
    66 //
       
    67 // Parse call concerned ss strings.
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 TBool CPhoneGsmSsCallParser::ParseL( 
       
    71         const TDesC& aString,
       
    72         CPhoneGsmParserResult& aResult,
       
    73         CPhoneGsmOptionContainerBase& aOptions )
       
    74     {
       
    75     aResult.ClearL();
       
    76 
       
    77     if ( !aOptions.FindOptionStatus( KPhoneOptionInCall ) ||
       
    78          !aOptions.FindOptionStatus( KPhoneOptionSend ) )
       
    79         {
       
    80         return EFalse;
       
    81         }
       
    82     
       
    83     TInt length = aString.Length();
       
    84 
       
    85     if ( length == KPhoneCommandXLength )
       
    86         {
       
    87         // Check one character from the beginning.
       
    88         TPtrC prefix( aString.Left( 1 ) );
       
    89 
       
    90         if ( prefix == KPhoneCommand1X )
       
    91             {
       
    92             TLex lex( aString.Right(1) );
       
    93             TUint32 value;
       
    94 
       
    95             if ( lex.Val( value, EDecimal ) == KErrNone )
       
    96                 {
       
    97                 aResult.SetUid( KPhoneUidCommand1 );
       
    98                 aResult.SetAuxInformation( value + 1 );
       
    99                 }           
       
   100             }
       
   101         else if ( prefix == KPhoneCommand2X )
       
   102             {
       
   103             TLex lex( aString.Right(1) );
       
   104             TUint32 value;
       
   105 
       
   106             if ( lex.Val( value, EDecimal ) == KErrNone )
       
   107                 {
       
   108                 aResult.SetUid( KPhoneUidCommand2 );
       
   109                 aResult.SetAuxInformation( value + 1 );
       
   110                 }
       
   111             }
       
   112         }
       
   113     else
       
   114         {
       
   115         if ( length == KPhoneCommandLength )
       
   116             {
       
   117             if ( aString == KPhoneCommand0 )
       
   118                 {
       
   119                 aResult.SetUid( KPhoneUidCommand0 );
       
   120                 }
       
   121             else if ( aString == KPhoneCommand1 )
       
   122                 {
       
   123                 aResult.SetUid( KPhoneUidCommand1 );
       
   124                 }
       
   125             else if ( aString == KPhoneCommand2 )
       
   126                 {
       
   127                 aResult.SetUid( KPhoneUidCommand2 );
       
   128                 }
       
   129             else if ( aString == KPhoneCommand3 )
       
   130                 {
       
   131                 aResult.SetUid( KPhoneUidCommand3 );
       
   132                 }
       
   133             else if ( aString == KPhoneCommand4 )
       
   134                 {
       
   135                 aResult.SetUid( KPhoneUidCommand4 );
       
   136                 }
       
   137             }
       
   138         }
       
   139    
       
   140     return ( aResult.Uid() != KPhoneGsmUidInvalid );
       
   141     }
       
   142 
       
   143 //  End of File