|
1 /* |
|
2 * Copyright (c) 2003 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: Class for APDU request header |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "SwimApduReqHeader.h" |
|
22 #include "WimTrace.h" // for trace logging |
|
23 |
|
24 #ifdef _DEBUG |
|
25 #include <flogger.h> |
|
26 #endif |
|
27 |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // TSwimApduReqHeader::TSwimApduReqHeader |
|
33 // C++ default constructor can NOT contain any code, that |
|
34 // might leave. |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 TSwimApduReqHeader::TSwimApduReqHeader() |
|
38 { |
|
39 _WIMTRACE(_L("WIM|SwimReader|TSwimApduReqHeader::TSwimApduReqHeader|Begin")); |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // TSwimApduReqHeader::Data |
|
44 // Return APDU data |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 TDes8* TSwimApduReqHeader::Data() |
|
48 { |
|
49 _WIMTRACE(_L("WIM|SwimReader|TSwimApduReqHeader::Data|Begin")); |
|
50 return &iData; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // TSwimApduReqHeader::operator= |
|
55 // Operator = |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 void TSwimApduReqHeader::operator=( const TDesC8& /*aData*/ ) |
|
59 { |
|
60 _WIMTRACE(_L("WIM|SwimReader|TSwimApduReqHeader::operator=|Begin")); |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // TSwimApduReqHeader::SetAppType |
|
65 // Set Application type byte |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void TSwimApduReqHeader::SetAppType( TUint8 aAppType ) |
|
69 { |
|
70 _WIMTRACE(_L("WIM|SwimReader|TSwimApduReqHeader::SetAppType|Begin")); |
|
71 iData[KIndexAppType] = aAppType; |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // TSwimApduReqHeader::SetCardReader |
|
76 // Set CardReader byte |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 void TSwimApduReqHeader::SetCardReader( TUint8 aCardReader ) |
|
80 { |
|
81 _WIMTRACE(_L("WIM|SwimReader|TSwimApduReqHeader::SetCardReader|Begin")); |
|
82 iData[KIndexCardReader] = aCardReader; |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // TSwimApduReqHeader::SetHeader |
|
87 // Set header for ADPU |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void TSwimApduReqHeader::SetHeader( |
|
91 TUint8 aServiceType, |
|
92 TUint8 aCardReader, |
|
93 TUint8 aAppType, |
|
94 TUint8 aPaddingByte ) |
|
95 { |
|
96 _WIMTRACE(_L("WIM|SwimReader|TSwimApduReqHeader::SetHeader|Begin")); |
|
97 // Initialize data buffer so it can be accessed byte by byte. |
|
98 for ( TInt i = 0; i < KMaxApduHeaderLen; i++ ) |
|
99 { |
|
100 if ( iData.Length() < iData.MaxLength() ) |
|
101 { |
|
102 iData.Append( 0 ); |
|
103 } |
|
104 else |
|
105 { |
|
106 iData[i] = 0; |
|
107 } |
|
108 } |
|
109 |
|
110 // Service type and card reader are used in all types of APDUs. |
|
111 SetServiceType( aServiceType ); |
|
112 SetCardReader( aCardReader ); |
|
113 |
|
114 switch ( aServiceType ) |
|
115 { |
|
116 case KSendApdu: |
|
117 { |
|
118 // App type and padding byte are used only with SEND_APDU msg. |
|
119 SetAppType( aAppType ); |
|
120 SetPaddingByte( aPaddingByte ); |
|
121 |
|
122 iData.SetLength( KSendApduHeaderLen ); |
|
123 break; |
|
124 } |
|
125 case KList: |
|
126 { |
|
127 iData.SetLength( KGetListHeaderLen ); |
|
128 break; |
|
129 } |
|
130 default: |
|
131 { |
|
132 iData.SetLength( KMaxApduHeaderLen ); |
|
133 break; |
|
134 } |
|
135 } |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // TSwimApduReqHeader::SetPaddingByte |
|
140 // Set padding byte |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 void TSwimApduReqHeader::SetPaddingByte( TUint8 aPaddingByte ) |
|
144 { |
|
145 _WIMTRACE(_L("WIM|SwimReader|TSwimApduReqHeader::SetPaddingByte|Begin")); |
|
146 iData[KIndexPaddingByte] = aPaddingByte; |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // TSwimApduReqHeader::SetServiceType |
|
151 // Set ServiceType byte |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 void TSwimApduReqHeader::SetServiceType( TUint8 aServiceType ) |
|
155 { |
|
156 _WIMTRACE(_L("WIM|SwimReader|TSwimApduReqHeader::SetServiceType|Begin")); |
|
157 iData[KIndexServiceType] = aServiceType; |
|
158 } |
|
159 |
|
160 // End of File |