javaextensions/satsa/apdu/src.s60/cstsmanagechannelresp.cpp
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 // INCLUDE FILES
       
    20 #include  "cstsmanagechannelresp.h"
       
    21 
       
    22 namespace java
       
    23 {
       
    24 namespace satsa
       
    25 {
       
    26 
       
    27 // CONSTANTS
       
    28 const TInt KSTSSuccesfullRespLength = 3;
       
    29 const TInt KSTSMaxChannelNum = 3;
       
    30 
       
    31 // ============================ MEMBER FUNCTIONS ===============================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CSTSManageChannelResp::CSTSManageChannelResp
       
    35 // C++ default constructor can NOT contain any code, that
       
    36 // might leave.
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CSTSManageChannelResp::CSTSManageChannelResp()
       
    40 {
       
    41 
       
    42 }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CSTSApdu::NewL
       
    46 // Two-phased constructor.
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 CSTSManageChannelResp* CSTSManageChannelResp::NewLC(TInt aMaxLength,
       
    50         CSTSApdu::TSTSApduStandard aStandard)
       
    51 {
       
    52     CSTSManageChannelResp* self = new(ELeave) CSTSManageChannelResp();
       
    53     CleanupStack::PushL(self);
       
    54     self->ConstructL(aMaxLength, aStandard);
       
    55     return self;
       
    56 }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CSTSApdu::NewL
       
    60 // Two-phased constructor.
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 CSTSManageChannelResp* CSTSManageChannelResp::NewL(TInt aMaxLength,
       
    64         CSTSApdu::TSTSApduStandard aStandard)
       
    65 {
       
    66     CSTSManageChannelResp* self = CSTSManageChannelResp::NewLC(aMaxLength,
       
    67                                   aStandard);
       
    68     CleanupStack::Pop(self);
       
    69 
       
    70     return self;
       
    71 }
       
    72 
       
    73 // Destructor
       
    74 CSTSManageChannelResp::~CSTSManageChannelResp()
       
    75 {
       
    76 }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CSTSManageChannelResp::GetChannel
       
    80 // Panics, if apdu data buffer contains too little information.
       
    81 // Returns KErrNotFound if Data part of response apdu buffer is missing or is
       
    82 // too long. It should be only one byte long and contain channel number.
       
    83 // Returns channel number if Data part is correct length.
       
    84 //
       
    85 // -----------------------------------------------------------------------------
       
    86 TInt CSTSManageChannelResp::GetChannel() const
       
    87 {
       
    88 
       
    89     TInt returnValue = KErrNotFound;
       
    90 
       
    91     if (iRespData->ApduPtr().Length() == KSTSSuccesfullRespLength)
       
    92     {
       
    93         //first byte is channel number
       
    94         returnValue = (TInt) iRespData->ApduPtr().Ptr()[0];
       
    95 
       
    96         //if channel number is not ok
       
    97         if (returnValue > KSTSMaxChannelNum)
       
    98         {
       
    99             returnValue = KErrNotFound;
       
   100         }
       
   101     }
       
   102     return returnValue;
       
   103 }
       
   104 
       
   105 } // namespace satsa
       
   106 } // namespace java
       
   107 //  End of File