|
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 "cstsselectfile.h" |
|
21 |
|
22 namespace java |
|
23 { |
|
24 namespace satsa |
|
25 { |
|
26 |
|
27 // CONSTANTS |
|
28 const TUint8 KSTSINSSelectFile = 0xA4; |
|
29 const TUint8 KSTSP1SelectAID = 0x04; |
|
30 |
|
31 // Activation, Return FCP tmpl, First only occurence |
|
32 const TUint8 KSTSP2SelectAIDActivation = 0x00; |
|
33 // Termination, Return FCP tmpl, First only occurence |
|
34 const TUint8 KSTSP2SelectAIDTermination = 0x44; |
|
35 |
|
36 const TUint8 KSTSP1SelectByFileId = 0x00; |
|
37 const TUint8 KSTSP1SelectByPathFromMF = 0x08; |
|
38 const TUint8 KSTSP1SelectByPathFromCurrentDF = 0x09; |
|
39 |
|
40 const TUint8 KSTSP2ReturnFCPTemplate = 0x04; |
|
41 |
|
42 // ============================ MEMBER FUNCTIONS =============================== |
|
43 |
|
44 |
|
45 CSTSSelectFile::CSTSSelectFile() |
|
46 { |
|
47 |
|
48 } |
|
49 |
|
50 void CSTSSelectFile::ConstructL(const TDesC8& aData, |
|
51 TSTSSelectFileApduType aType, CSTSApdu::TSTSApduStandard aStandard) |
|
52 { |
|
53 |
|
54 TUint8 p1; |
|
55 TUint8 p2; |
|
56 |
|
57 GenerateP1P2(p1, p2, aType); |
|
58 |
|
59 TInt aidLength = aData.Length(); |
|
60 // Lc length=1 byte |
|
61 TInt maxLength = KSTSApduMandatoryHeaderLen + 1 + aidLength; |
|
62 |
|
63 iApduData = CSTSApdu::NewL(maxLength, aStandard); |
|
64 |
|
65 // fills header and Lc with zeros |
|
66 iApduData->ApduPtr().FillZ(KSTSApduMandatoryHeaderLen); |
|
67 |
|
68 SetHeader(KSTSCLABasicUMTS, KSTSINSSelectFile, p1, p2); |
|
69 |
|
70 AppendDatabytesL(aData); |
|
71 |
|
72 } |
|
73 |
|
74 CSTSSelectFile* CSTSSelectFile::NewLC(const TDesC8& aData, |
|
75 TSTSSelectFileApduType aType, CSTSApdu::TSTSApduStandard aStandard) |
|
76 { |
|
77 CSTSSelectFile* self = new(ELeave) CSTSSelectFile(); |
|
78 CleanupStack::PushL(self); |
|
79 self->ConstructL(aData, aType, aStandard); |
|
80 return self; |
|
81 } |
|
82 |
|
83 CSTSSelectFile* CSTSSelectFile::NewL(const TDesC8& aData, |
|
84 TSTSSelectFileApduType aType, CSTSApdu::TSTSApduStandard aStandard) |
|
85 { |
|
86 CSTSSelectFile* self = CSTSSelectFile::NewLC(aData, aType, aStandard); |
|
87 CleanupStack::Pop(self); |
|
88 |
|
89 return self; |
|
90 } |
|
91 |
|
92 CSTSSelectFile::~CSTSSelectFile() |
|
93 { |
|
94 } |
|
95 |
|
96 void CSTSSelectFile::SetApduType(TSTSSelectFileApduType aType) |
|
97 { |
|
98 iType = aType; |
|
99 |
|
100 TUint8 p1; |
|
101 TUint8 p2; |
|
102 GenerateP1P2(p1, p2, aType); |
|
103 SetApduByte(p1, ESTSP1); |
|
104 SetApduByte(p2, ESTSP2); |
|
105 } |
|
106 |
|
107 void CSTSSelectFile::GenerateP1P2(TUint8& aP1, TUint8& aP2, |
|
108 TSTSSelectFileApduType aType) |
|
109 { |
|
110 |
|
111 aP1 = KSTSP1SelectAID; |
|
112 aP2 = KSTSP2ReturnFCPTemplate; |
|
113 |
|
114 switch (aType) |
|
115 { |
|
116 case ESTSAIDActivation: |
|
117 { |
|
118 aP2 = KSTSP2SelectAIDActivation; |
|
119 break; |
|
120 } |
|
121 case ESTSAIDTermination: |
|
122 { |
|
123 aP2 = KSTSP2SelectAIDTermination; |
|
124 break; |
|
125 } |
|
126 case ESTSSelectByFileId: |
|
127 { |
|
128 aP1 = KSTSP1SelectByFileId; |
|
129 break; |
|
130 } |
|
131 case ESTSSelectByPathFromMF: |
|
132 { |
|
133 aP1 = KSTSP1SelectByPathFromMF; |
|
134 break; |
|
135 } |
|
136 case ESTSSelectByPathFromCurrentDF: |
|
137 { |
|
138 aP1 = KSTSP1SelectByPathFromCurrentDF; |
|
139 break; |
|
140 } |
|
141 default: |
|
142 { |
|
143 break; |
|
144 } |
|
145 } |
|
146 } |
|
147 |
|
148 } // namespace satsa |
|
149 } // namespace java |
|
150 // End of File |