javaextensions/satsa/apdu/src.s60/cstsenvelope.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19: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 // INCLUDE FILES
       
    20 
       
    21 #include  "cstsenvelope.h"
       
    22 
       
    23 namespace java
       
    24 {
       
    25 namespace satsa
       
    26 {
       
    27 
       
    28 // CONSTANTS
       
    29 const TUint8 KSTSCLAEnvelopeUMTS = 0x80;
       
    30 const TUint8 KSTSCLAEnvelopeGSM = 0xA0;
       
    31 const TUint8 KSTSINSEnvelope = 0xC2;
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ===============================
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CSTSEnvelope::CSTSEnvelope
       
    37 // C++ default constructor can NOT contain any code, that
       
    38 // might leave.
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 CSTSEnvelope::CSTSEnvelope()
       
    42 {
       
    43 }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CSTSEnvelope::NewLC
       
    47 // Two-phased constructor.
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 CSTSEnvelope* CSTSEnvelope::NewLC(TDesC8& aApduBytes,
       
    51                                   CSTSApdu::TSTSApduStandard aStandard)
       
    52 {
       
    53     CSTSEnvelope* self = new(ELeave) CSTSEnvelope();
       
    54     CleanupStack::PushL(self);
       
    55     self->ConstructL(aApduBytes, aStandard);
       
    56     return self;
       
    57 }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CSTSEnvelope::NewL
       
    61 // Two-phased constructor.
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 CSTSEnvelope* CSTSEnvelope::NewL(TDesC8& aApduBytes,
       
    65                                  CSTSApdu::TSTSApduStandard aStandard)
       
    66 {
       
    67     CSTSEnvelope* self = CSTSEnvelope::NewLC(aApduBytes, aStandard);
       
    68     CleanupStack::Pop(self);
       
    69 
       
    70     return self;
       
    71 }
       
    72 
       
    73 // Destructor
       
    74 CSTSEnvelope::~CSTSEnvelope()
       
    75 {
       
    76 }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CSTSEnvelope::CheckL
       
    80 // Checks apdu data and leaves with proper error code
       
    81 // Checking is done according to JSR177 design document.
       
    82 // (other items were commented in a header).
       
    83 // -----------------------------------------------------------------------------
       
    84 void CSTSEnvelope::CheckL() const
       
    85 {
       
    86     CheckApduLengthL();
       
    87     //only envelope apdus are allowed
       
    88     if (ApduByte(ESTSINS) != KSTSINSEnvelope) //not envelope
       
    89     {
       
    90         User::Leave(KSTSErrIllegalArgument + KSTSErrIANotEnvelope);
       
    91     }
       
    92 }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CSTSEnvelope::SetClassByte
       
    96 // Checks which standard is used and sets the class byte either A0 or 80
       
    97 // depending on whether the phone is running GSM or UMTS.
       
    98 // Specified in JSR177 in chapter "Support for (U)SIM Application Toolkit".
       
    99 // (other items were commented in a header).
       
   100 // -----------------------------------------------------------------------------
       
   101 void CSTSEnvelope::SetClassByte()
       
   102 {
       
   103     if (iApduData->Standard() == CSTSApdu::ESTSGSM)
       
   104     {
       
   105         SetApduByte(KSTSCLAEnvelopeGSM, ESTSCLA);
       
   106     }
       
   107     else if (iApduData->Standard() == CSTSApdu::ESTSUICC)
       
   108     {
       
   109         SetApduByte(KSTSCLAEnvelopeUMTS, ESTSCLA);
       
   110     }
       
   111 }
       
   112 
       
   113 } // namespace satsa
       
   114 } // namespace java
       
   115 //  End of File