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