cbsatplugin/atmisccmdplugin/inc/atcommandparser.h
branchRCL_3
changeset 16 b23265fb36da
child 32 19bd632b5100
equal deleted inserted replaced
14:f7fbeaeb166a 16:b23265fb36da
       
     1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This file contains the implementation of the AT command parser and common utilities
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef ATCOMMANDPARSER_H
       
    19 #define ATCOMMANDPARSER_H
       
    20 
       
    21 #include <e32std.h>
       
    22 
       
    23 
       
    24 /**
       
    25  *  This class parses a given AT command into command type, command handler type and parameters.
       
    26  * 
       
    27  */
       
    28 NONSHARABLE_CLASS(TAtCommandParser)
       
    29     {
       
    30 public:
       
    31     /**
       
    32      * AT command handler type which determines how the command is interpreted.
       
    33      */
       
    34     enum TCommandHandlerType
       
    35         {
       
    36         ECmdHandlerTypeUndefined = KErrNotFound,
       
    37         ECmdHandlerTypeBase      = 0x01,  // For command "AT+COMMAND"
       
    38         ECmdHandlerTypeSet       = 0x02,  // For command "AT+COMMAND="
       
    39         ECmdHandlerTypeRead      = 0x04,  // For command "AT+COMMAND?"
       
    40         ECmdHandlerTypeTest      = 0x08,  // For command "AT+COMMAND=?"
       
    41         };
       
    42     
       
    43     /**
       
    44      * Extended AT commands supported by this parser.
       
    45      */
       
    46     enum TCommandType
       
    47         {
       
    48         EUnknown = KErrNotFound,
       
    49         ECmdAtCfun = 0,
       
    50         ECmdAtCbc,
       
    51         ECmdAtClck,
       
    52         ECmdAtCpwd,
       
    53         ECmdAtCpin,
       
    54         ECmdAtCusd,
       
    55         ECmdAtCnum
       
    56         };
       
    57 public:
       
    58     TAtCommandParser();
       
    59     
       
    60     /**
       
    61      * @param aCmd AT command to be parsed
       
    62      */
       
    63     TAtCommandParser(const TDesC8& aCmd);
       
    64     
       
    65     /**
       
    66      * Parse a new AT command. Previously parsed AT command is lost.
       
    67      * @param aCmd AT command to be parsed
       
    68      */
       
    69     void ParseAtCommand(const TDesC8& aCmd);
       
    70     
       
    71     /**
       
    72      * @return AT command type @see CAtCommandParser::TCommandType 
       
    73      */
       
    74     TCommandType Command() const;
       
    75     
       
    76     /**
       
    77      * @return AT Command handler type @see CAtCommandParser::TCommandHandlerType
       
    78      */
       
    79     TCommandHandlerType CommandHandlerType() const;
       
    80     
       
    81     /**
       
    82      * @return Next available parameter. KNullDesC8 if no more parameters.
       
    83      */
       
    84     TPtrC8 NextParam();
       
    85     
       
    86     /**
       
    87      * Gets the integer value of the next parameter.
       
    88      * 
       
    89      * @param aValue the integer value of the parameter
       
    90      * @return Symbian system wide error codes
       
    91      */
       
    92     TInt NextIntParam(TInt& aValue);
       
    93     
       
    94     /**
       
    95      * Get the next text string without quote.
       
    96      * This function validate the parameter is a valid string.
       
    97      * if the parameter is absent, it returns KErrNotFound.
       
    98      * if the parameter is an invalid string such as not in a pair of double quotes, it returns KErrArgument
       
    99      * @param aError return the error code. 
       
   100      * @return Next text parameter when aError is not KErrNone; 
       
   101      */
       
   102     TPtrC8 NextTextParam(TInt& aError);
       
   103 
       
   104     /**
       
   105      * Get ISA hash code for security code
       
   106      * Phone lock code is encoded by using ISA hash. This hash algorithm is implemented in remotemgmt component
       
   107      * This function is copied and modified from CSCPServer::HashISACode()
       
   108      * @param aPasscode passcode to be encoded
       
   109      * @param aHashCode encoded output
       
   110      * @return Symbian system wide error codes
       
   111      */
       
   112     TInt HashSecurityCode(const TDesC8& aPasscode, TDes8& aHashCode);
       
   113     
       
   114 private:
       
   115     TLex8 iCmd;
       
   116     TCommandType iCmdType;
       
   117     TCommandHandlerType iCmdHandlerType;
       
   118     };
       
   119 
       
   120 #endif // ATCOMMANDPARSER_H