|
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 "cstspinapduresp.h" |
|
21 |
|
22 namespace java |
|
23 { |
|
24 namespace satsa |
|
25 { |
|
26 |
|
27 // CONSTANTS |
|
28 const TUint8 KSTSSW1RetriesLeft = 0x63; |
|
29 const TUint8 KSTSSW1PinBlocked = 0x69; |
|
30 const TUint8 KSTSSW2PinBlocked = 0x83; |
|
31 |
|
32 CSTSPinApduResp::CSTSPinApduResp() |
|
33 { |
|
34 |
|
35 } |
|
36 |
|
37 CSTSPinApduResp* CSTSPinApduResp::NewLC(TInt aMaxLength, |
|
38 CSTSApdu::TSTSApduStandard aStandard) |
|
39 { |
|
40 CSTSPinApduResp* self = new(ELeave) CSTSPinApduResp(); |
|
41 CleanupStack::PushL(self); |
|
42 self->ConstructL(aMaxLength, aStandard); |
|
43 return self; |
|
44 } |
|
45 |
|
46 CSTSPinApduResp* CSTSPinApduResp::NewL(TInt aMaxLength, |
|
47 CSTSApdu::TSTSApduStandard aStandard) |
|
48 { |
|
49 CSTSPinApduResp* self = CSTSPinApduResp::NewLC(aMaxLength, aStandard); |
|
50 CleanupStack::Pop(self); |
|
51 |
|
52 return self; |
|
53 } |
|
54 |
|
55 CSTSPinApduResp::~CSTSPinApduResp() |
|
56 { |
|
57 |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CSTSPinApduResp::IsBlocked |
|
62 // Panics, if apdu data buffer contains too little information. |
|
63 // (other items were commented in a header). |
|
64 // ----------------------------------------------------------------------------- |
|
65 TBool CSTSPinApduResp::IsBlocked() |
|
66 { |
|
67 return (CountRetriesLeft(GetSW1(), GetSW2()) == 0); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CSTSPinApduResp::RetriesLeft |
|
72 // Panics, if apdu data buffer contains too little information. |
|
73 // (other items were commented in a header). |
|
74 // ----------------------------------------------------------------------------- |
|
75 TInt CSTSPinApduResp::RetriesLeft() const |
|
76 { |
|
77 return CountRetriesLeft(GetSW1(), GetSW2()); |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CSTSPinApduResp::CountRetriesLeft |
|
82 // Panics, if apdu data buffer contains too little information. |
|
83 // Checks in two ways from response apdu buffer, how many retries is left. |
|
84 // Returns KErrNotFound if retries left value cannot be calculated. |
|
85 // (other items were commented in a header). |
|
86 // ----------------------------------------------------------------------------- |
|
87 TInt CSTSPinApduResp::CountRetriesLeft(TUint8 aSW1, TUint8 aSW2) const |
|
88 { |
|
89 TInt returnValue; |
|
90 if ((aSW1 == KSTSSW1PinBlocked) && (aSW2 == KSTSSW2PinBlocked)) |
|
91 { |
|
92 returnValue = 0; |
|
93 } |
|
94 else if (aSW1 == KSTSSW1RetriesLeft) |
|
95 { |
|
96 TUint8 retryCounterMask = 0x03; |
|
97 returnValue = aSW2 & retryCounterMask; |
|
98 } |
|
99 else |
|
100 { |
|
101 returnValue = KErrNotFound; |
|
102 } |
|
103 return returnValue; |
|
104 } |
|
105 |
|
106 } // namespace satsa |
|
107 } // namespace java |
|
108 // End of File |