javaextensions/satsa/apdu/src.s60/cstscmdapdu.h
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 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:
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CSTSCMDAPDU_H
       
    20 #define CSTSCMDAPDU_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include "cstsapdu.h"
       
    24 #include "stsapduconstants.h"
       
    25 
       
    26 //  CONSTANTS
       
    27 //Apdu CLA bytes
       
    28 const TUint8 KSTSCLABasicGSM = 0xA0;
       
    29 const TUint8 KSTSCLABasicUMTS = 0x00;
       
    30 
       
    31 namespace java
       
    32 {
       
    33 namespace satsa
       
    34 {
       
    35 
       
    36 // CLASS DECLARATION
       
    37 /**
       
    38  *  Common command APDU class. Base class for detailed command apdu classes.
       
    39  *
       
    40  *  @since 3.0
       
    41  */
       
    42 NONSHARABLE_CLASS(CSTSCmdApdu): public CBase
       
    43 {
       
    44 public: // command apdu byte locations
       
    45     enum TSTSApduByteType
       
    46     {
       
    47         ESTSCLA = 0,
       
    48         ESTSINS = 1,
       
    49         ESTSP1 = 2,
       
    50         ESTSP2 = 3,
       
    51         ESTSLc = 4,
       
    52         ESTSData = 5 //only if data is one byte long
       
    53     };
       
    54 
       
    55 public: // Constructors and destructor
       
    56     /**
       
    57      * Two-phased constructor.
       
    58      */
       
    59     static CSTSCmdApdu* NewLC(TDesC8& aApduBytes,
       
    60                               CSTSApdu::TSTSApduStandard aStandard);
       
    61 
       
    62     static CSTSCmdApdu* NewL(TDesC8& aApduBytes,
       
    63                              CSTSApdu::TSTSApduStandard aStandard);
       
    64 
       
    65     /**
       
    66      * Destructor.
       
    67      */
       
    68     virtual ~CSTSCmdApdu();
       
    69 
       
    70 public: // New functions
       
    71 
       
    72     /**
       
    73      * Check is apdu in correct form according to JSR177. Leaves with proper
       
    74      * error code if needed.
       
    75      * @since 3.0
       
    76      * @param aUsedChannel Channel number which will be used.
       
    77      */
       
    78     void CheckL(TInt aUsedChannel) const;
       
    79 
       
    80     /**
       
    81      * Getter for command apdu bytes
       
    82      * @since 3.0
       
    83      * @return Bytes in modifiable TPtr8 reference
       
    84      */
       
    85     TPtr8& ApduBytes() const;
       
    86 
       
    87     /**
       
    88      * Sets channel bits to APDU data bytes
       
    89      * @since 3.0
       
    90      */
       
    91     void SetChannel(TInt aChannel);
       
    92 
       
    93     /**
       
    94      * Returns apdu header part
       
    95      * @since 3.0
       
    96      * @return Apdu header part
       
    97      */
       
    98     const TDesC8& Header();
       
    99 
       
   100     /**
       
   101      * Gets wanted apdu byte from APDU data bytes
       
   102      * @since 3.0
       
   103      * @param aByteType Type of the byte
       
   104      * @return Apdu header part
       
   105      */
       
   106     TUint8 ApduByte(TSTSApduByteType aByteType) const;
       
   107 
       
   108     /**
       
   109      * Appends Lc byte and data bytes after header part. Header must exist.
       
   110      * Takes copy and reallocates apdu buffer if needed.
       
   111      * @since 3.0
       
   112      * @param aDataBytes Data bytes.
       
   113      */
       
   114     void AppendDatabytesL(const TDesC8& aDataBytes);
       
   115 
       
   116     /**
       
   117      * Sets Le byte to APDU data bytes
       
   118      * @param aLe Le byte
       
   119      *
       
   120      * @since 3.0
       
   121      */
       
   122     void SetLe(TUint8 aLe);
       
   123 
       
   124 protected: //New fuctions
       
   125 
       
   126     /**
       
   127      * C++ default constructor.
       
   128      */
       
   129     CSTSCmdApdu();
       
   130 
       
   131     /**
       
   132      * Protected to allow derivation
       
   133      */
       
   134     void ConstructL(TDesC8& aApduBytes,
       
   135                     CSTSApdu::TSTSApduStandard aStandard);
       
   136 
       
   137     /**
       
   138      * Checks is apdu length correct and leaves proper error code if not.
       
   139      * @since 3.0
       
   140      */
       
   141     void CheckApduLengthL() const;
       
   142 
       
   143     /**
       
   144      * Sets header bytes to APDU data buffer
       
   145      * @param aCla CLA byte
       
   146      * @param aIns CLA byte
       
   147      * @param aP1 P1 byte
       
   148      * @param aP2 P2 byte
       
   149      *
       
   150      * @since 3.0
       
   151      */
       
   152     void SetHeader(TUint8 aCla, TUint8 aIns, TUint8 aP1, TUint8 aP2);
       
   153 
       
   154     /**
       
   155      * Sets wanted apdu byte to APDU data bytes
       
   156      * @param aByte Byte to be set
       
   157      * @param aByteType Type of the byte
       
   158      *
       
   159      * @since 3.0
       
   160      */
       
   161     void SetApduByte(TUint8 aByte, TSTSApduByteType aByteType);
       
   162 
       
   163 private: //New fuctions
       
   164 
       
   165     /**
       
   166      * Check is used apdu phone application selection apdu and leaves
       
   167      * with security leave if so.
       
   168      *
       
   169      * @since 3.0
       
   170      */
       
   171     void CheckPhoneAppSelectionL() const;
       
   172 
       
   173     /**
       
   174      * Checks is gived file id illegal and leaves with security leave if so.
       
   175      * @param aFileId File id
       
   176      *
       
   177      * @since 3.0
       
   178      */
       
   179     void CheckIllegalFileIdL(const TDesC8& aFileId) const;
       
   180 
       
   181     /**
       
   182      * Checks does apdu lead to file selection
       
   183      * @return ETrue if proper file selection apdu. Otherwise EFalse.
       
   184      *
       
   185      * @since 3.0
       
   186      */
       
   187     TBool IsProperFileSelectionApdu(TInt aDataLength) const;
       
   188 
       
   189     /**
       
   190      * Checks is there proper path and does it contain illegal file ids.
       
   191      * @param aData Data field part of the apdu
       
   192      *
       
   193      * @since 3.0
       
   194      */
       
   195     void CheckPathL(const TDesC8& aData) const;
       
   196 
       
   197     /**
       
   198      * Checks is there proper file id and is it illegal.
       
   199      * @param aData Data field part of the apdu
       
   200      *
       
   201      * @since 3.0
       
   202      */
       
   203     void CheckFileIdL(const TDesC8& aData) const;
       
   204 
       
   205 protected: // Data
       
   206 
       
   207     CSTSApdu* iApduData; //owned
       
   208 
       
   209 private: // Data
       
   210 
       
   211     TPtrC8 iHeaderPtr;
       
   212 };
       
   213 
       
   214 } // namespace satsa
       
   215 } // namespace java
       
   216 #endif // CSTSCMDAPDU_H
       
   217 // End of File