|
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 "cstspinattributes.h" |
|
21 |
|
22 namespace java |
|
23 { |
|
24 namespace satsa |
|
25 { |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 //0000 0000 1000 0000 -->9. bit from left but first byte ignored |
|
30 const TUint8 KSTSDisableAllowed = 0x80; |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CSTSPinAttributes::CSTSPinAttributes |
|
36 // C++ default constructor can NOT contain any code, that |
|
37 // might leave. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CSTSPinAttributes::CSTSPinAttributes() |
|
41 { |
|
42 iPinType = ENotInitialized; |
|
43 iMaxLength = KErrNotFound; |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CSTSPinAttributes::CSTSPinAttributes |
|
48 // C++ default constructor can NOT contain any code, that |
|
49 // might leave. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CSTSPinAttributes::CSTSPinAttributes(TInt aPinType, TInt aMinLength, |
|
53 TInt aStoredLength, TInt aMaxLength, TInt aPinReference) |
|
54 { |
|
55 |
|
56 iPinType = (TPinType) aPinType; |
|
57 |
|
58 //if maxLenght is zero or less it is not found correctly |
|
59 if (aMaxLength <= 0) |
|
60 { |
|
61 iMaxLength = KErrNotFound; |
|
62 } |
|
63 else |
|
64 { |
|
65 iMaxLength = aMaxLength; |
|
66 } |
|
67 |
|
68 iMinLength = aMinLength; |
|
69 iStoredLength = aStoredLength; |
|
70 |
|
71 iPinReference = aPinReference; |
|
72 |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CSTSPinAttributes::ConstructL |
|
77 // Symbian 2nd phase constructor can leave. |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 void CSTSPinAttributes::ConstructL() |
|
81 { |
|
82 // creating with empty values |
|
83 iPinFlags = KNullDesC8().AllocL(); |
|
84 iPadChar = KNullDesC8().AllocL(); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CSTSPinAttributes::ConstructL |
|
89 // Symbian 2nd phase constructor can leave. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CSTSPinAttributes::ConstructL(TInt aPadChar, TInt aFlags) |
|
93 { |
|
94 // creating with empty values |
|
95 iPinFlags = HBufC8::NewL(2);//pinflags contains maximum of two bytes of data |
|
96 iPinFlags->Des().Append(aFlags); |
|
97 iPadChar = HBufC8::NewL(1); |
|
98 iPadChar->Des().Append(aPadChar); |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CSTSPinAttributes::NewLC |
|
103 // Two-phased constructor. |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 CSTSPinAttributes* CSTSPinAttributes::NewLC(TInt aPinType, TInt aMinLength, |
|
107 TInt aStoredLength, TInt aMaxLength, TInt aPinReference, TInt aPadChar, |
|
108 TInt aFlags) |
|
109 { |
|
110 CSTSPinAttributes |
|
111 * self = |
|
112 new(ELeave) CSTSPinAttributes(aPinType, aMinLength, aStoredLength, aMaxLength, aPinReference); |
|
113 CleanupStack::PushL(self); |
|
114 self->ConstructL(aPadChar, aFlags); |
|
115 return self; |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CSTSPinAttributes::NewL |
|
120 // Two-phased constructor. |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 CSTSPinAttributes* CSTSPinAttributes::NewL() |
|
124 { |
|
125 CSTSPinAttributes* self = new(ELeave) CSTSPinAttributes(); |
|
126 |
|
127 return self; |
|
128 } |
|
129 |
|
130 // Destructor |
|
131 CSTSPinAttributes::~CSTSPinAttributes() |
|
132 { |
|
133 delete iPinFlags; |
|
134 delete iPadChar; |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CSTSPinAttributes::PinType |
|
139 // Getter for PIN type |
|
140 // ----------------------------------------------------------------------------- |
|
141 CSTSPinAttributes::TPinType CSTSPinAttributes::PinType() const |
|
142 { |
|
143 return iPinType; |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CSTSPinAttributes::MinLength |
|
148 // Getter for PIN minimum length |
|
149 // ----------------------------------------------------------------------------- |
|
150 TInt CSTSPinAttributes::MinLength() const |
|
151 { |
|
152 return iMinLength; |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CSTSPinAttributes::StoredLength |
|
157 // Getter for PIN stored lenght |
|
158 // ----------------------------------------------------------------------------- |
|
159 |
|
160 TInt CSTSPinAttributes::StoredLength() const |
|
161 { |
|
162 return iStoredLength; |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CSTSPinAttributes::MaxLength |
|
167 // Getter for PIN maximum length |
|
168 // ----------------------------------------------------------------------------- |
|
169 |
|
170 TInt CSTSPinAttributes::MaxLength() const |
|
171 { |
|
172 return iMaxLength; |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CSTSPinAttributes::PinReference |
|
177 // Getter for PIN reference |
|
178 // ----------------------------------------------------------------------------- |
|
179 |
|
180 TUint8 CSTSPinAttributes::PinReference() const |
|
181 { |
|
182 return iPinReference; |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CSTSPinAttributes::PadChar |
|
187 // Getter for padding character |
|
188 // ----------------------------------------------------------------------------- |
|
189 |
|
190 const TDesC8& CSTSPinAttributes::PadChar() const |
|
191 { |
|
192 return *iPadChar; |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // CSTSPinAttributes::CopyL |
|
197 // Takes information from parameter and sets it, takes copy |
|
198 // ----------------------------------------------------------------------------- |
|
199 void CSTSPinAttributes::CopyL(const CSTSPinAttributes& aPinAttributes) |
|
200 { |
|
201 HBufC8* tmpPinFlags = aPinAttributes.iPinFlags->AllocL(); |
|
202 delete iPinFlags; |
|
203 iPinFlags = tmpPinFlags; |
|
204 |
|
205 iPinType = aPinAttributes.PinType(); |
|
206 iMinLength = aPinAttributes.MinLength(); |
|
207 iStoredLength = aPinAttributes.StoredLength(); |
|
208 iMaxLength = aPinAttributes.MaxLength(); |
|
209 iPinReference = aPinAttributes.PinReference(); |
|
210 |
|
211 HBufC8* tmpPadChar = aPinAttributes.PadChar().AllocL(); |
|
212 delete iPadChar; |
|
213 iPadChar = tmpPadChar; |
|
214 } |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // CSTSPinAttributes::IsPinFlagSet |
|
218 // Uses mask to find out is flag set or not. Mask is already set in header file |
|
219 // where TFlagType is defined. Supports only case sensitive and needs-padding |
|
220 // flags. |
|
221 // ----------------------------------------------------------------------------- |
|
222 TBool CSTSPinAttributes::IsPinFlagSet(TFlagType aFlagType) const |
|
223 { |
|
224 |
|
225 TBool returnValue = EFalse; |
|
226 TInt8 correctByte = 0x00; |
|
227 |
|
228 //case sensitive, needs-padding, change-disabled and unblock-disabled |
|
229 //information will be found from first byte |
|
230 TInt index = 0; |
|
231 |
|
232 //disable allowed information will be found from second byte |
|
233 if (aFlagType == EDisableAllowed) |
|
234 { |
|
235 //special case because value is in second byte of iPinFlags |
|
236 //and thats why when presenting flagtype in one byte form |
|
237 //DisableAllowed has same value than ECaseSensitive flag. |
|
238 //Thats why own constant for disable allowed. |
|
239 aFlagType = (TFlagType) KSTSDisableAllowed; |
|
240 } |
|
241 |
|
242 if (iPinFlags->Length() > index) |
|
243 { |
|
244 correctByte = iPinFlags->Ptr()[index]; |
|
245 //check is wanted bit set or not |
|
246 returnValue = ((aFlagType & correctByte) == aFlagType); |
|
247 } |
|
248 //if correctByte is missing, we return EFalse |
|
249 return returnValue; |
|
250 } |
|
251 |
|
252 } // namespace satsa |
|
253 } // namespace java |
|
254 // End of File |