|
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 "cstsapdu.h" |
|
21 #include "logger.h" |
|
22 |
|
23 namespace java |
|
24 { |
|
25 namespace satsa |
|
26 { |
|
27 |
|
28 // CONSTANTS |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CSTSApdu::CSTSApdu |
|
34 // C++ default constructor can NOT contain any code, that |
|
35 // might leave. |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CSTSApdu::CSTSApdu(TSTSApduStandard aStandard) : |
|
39 iApduBytesPtr(NULL, 0) |
|
40 { |
|
41 iStandard = aStandard; |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CSTSApdu::ConstructL |
|
46 // Symbian 2nd phase constructor can leave. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 void CSTSApdu::ConstructL(TDesC8& aApduBytes) |
|
50 { |
|
51 LOG(ESATSA, EInfo, "+ CSTSApdu::ConstructL"); |
|
52 iApduBytes = aApduBytes.AllocL(); |
|
53 iApduBytesPtr.Set(iApduBytes->Des()); |
|
54 LOG(ESATSA, EInfo, "-- CSTSApdu::ConstructL"); |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CSTSApdu::ConstructL |
|
59 // Symbian 2nd phase constructor can leave. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 void CSTSApdu::ConstructL(TInt aMaxLength) |
|
63 { |
|
64 iApduBytes = HBufC8::NewL(aMaxLength); |
|
65 iApduBytesPtr.Set(iApduBytes->Des()); |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CSTSApdu::NewLC |
|
70 // Two-phased constructor. |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CSTSApdu* CSTSApdu::NewLC(TDesC8& aApduBytes, TSTSApduStandard aStandard) |
|
74 { |
|
75 LOG(ESATSA, EInfo, "+ CSTSApdu::NewLC"); |
|
76 CSTSApdu* self = new(ELeave) CSTSApdu(aStandard); |
|
77 CleanupStack::PushL(self); |
|
78 self->ConstructL(aApduBytes); |
|
79 LOG(ESATSA, EInfo, "-- CSTSApdu::NewLC"); |
|
80 return self; |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CSTSApdu::NewL |
|
85 // Two-phased constructor. |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 CSTSApdu* CSTSApdu::NewL(TDesC8& aApduBytes, TSTSApduStandard aStandard) |
|
89 { |
|
90 LOG(ESATSA, EInfo, "+ CSTSApdu::NewL"); |
|
91 CSTSApdu* self = CSTSApdu::NewLC(aApduBytes, aStandard); |
|
92 CleanupStack::Pop(self); |
|
93 LOG(ESATSA, EInfo, "-- CSTSApdu::NewL"); |
|
94 return self; |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CSTSApdu::NewLC |
|
99 // Two-phased constructor. |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 CSTSApdu* CSTSApdu::NewLC(TInt aMaxLength, TSTSApduStandard aStandard) |
|
103 { |
|
104 LOG(ESATSA, EInfo, "+ CSTSApdu::NewLC"); |
|
105 CSTSApdu* self = new(ELeave) CSTSApdu(aStandard); |
|
106 CleanupStack::PushL(self); |
|
107 self->ConstructL(aMaxLength); |
|
108 LOG(ESATSA, EInfo, "-- CSTSApdu::NewLC"); |
|
109 return self; |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CSTSApdu::NewL |
|
114 // Two-phased constructor. |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 CSTSApdu* CSTSApdu::NewL(TInt aMaxLength, TSTSApduStandard aStandard) |
|
118 { |
|
119 CSTSApdu* self = CSTSApdu::NewLC(aMaxLength, aStandard); |
|
120 CleanupStack::Pop(self); |
|
121 |
|
122 return self; |
|
123 } |
|
124 |
|
125 // Destructor |
|
126 CSTSApdu::~CSTSApdu() |
|
127 { |
|
128 delete iApduBytes; |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CSTSApdu::ApduPtr |
|
133 // Getter for APDU ptr |
|
134 // (other items were commented in a header). |
|
135 // ----------------------------------------------------------------------------- |
|
136 TPtr8& CSTSApdu::ApduPtr() |
|
137 { |
|
138 iApduBytesPtr.Set(iApduBytes->Des()); |
|
139 return iApduBytesPtr; |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CSTSApdu::ReAllocL |
|
144 // |
|
145 // (other items were commented in a header). |
|
146 // ----------------------------------------------------------------------------- |
|
147 void CSTSApdu::ReAllocL(TInt aMaxLength) |
|
148 { |
|
149 if (!iApduBytes) |
|
150 { |
|
151 iApduBytes = HBufC8::NewL(aMaxLength); |
|
152 } |
|
153 else if (iApduBytesPtr.MaxLength() < aMaxLength) |
|
154 { |
|
155 iApduBytes = iApduBytes->ReAllocL(aMaxLength); |
|
156 } |
|
157 iApduBytesPtr.Set(iApduBytes->Des()); |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CSTSApdu::Standard |
|
162 // Returns used standard |
|
163 // (other items were commented in a header). |
|
164 // ----------------------------------------------------------------------------- |
|
165 CSTSApdu::TSTSApduStandard CSTSApdu::Standard() const |
|
166 { |
|
167 return iStandard; |
|
168 } |
|
169 |
|
170 } // namespace satsa |
|
171 } // namespace java |
|
172 // End of File |