|
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 #ifndef CSTSURI_H |
|
20 #define CSTSURI_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 |
|
25 namespace java |
|
26 { |
|
27 namespace satsa |
|
28 { |
|
29 |
|
30 // CLASS DECLARATION |
|
31 /** |
|
32 * Class for parsing BNF syntax URI. |
|
33 * |
|
34 * URI can be for example: "apdu:0;target=A0.0.0.67.4.7.1F.3.2C.3" |
|
35 * or "apdu:0;target=SAT" |
|
36 * |
|
37 * <APDU_connection_string>::= "apdu:"<targetAddress> |
|
38 * <targetAddress> ::= [slot];target |
|
39 * <slot> ::= smart card slot number. (optional. Hexadecimal |
|
40 * number identifying the smart card slot. Default |
|
41 * slot assumed if left empty) |
|
42 * <target> ::= "target="<AID>|"SAT" |
|
43 * <AID> ::= < 5 - 16 bytes > |
|
44 * An AID (Application Identifier) uniquely |
|
45 * identifies a smart card application. It is |
|
46 * represented by 5 to 16 hexadecimal bytes where |
|
47 * each byte value is seperated by a ".". |
|
48 * |
|
49 */ |
|
50 NONSHARABLE_CLASS(CSTSURI): public CBase |
|
51 { |
|
52 public: // Type definition |
|
53 enum TURIType |
|
54 { |
|
55 EAID, |
|
56 ESAT |
|
57 }; |
|
58 |
|
59 private: // Type definition |
|
60 enum TAidParserState |
|
61 { |
|
62 EFirstDigit, |
|
63 ESecondDigit, |
|
64 EDot, |
|
65 EERROR |
|
66 }; |
|
67 |
|
68 public: // Constructors and destructor |
|
69 |
|
70 static CSTSURI* NewLC(const TDesC& aURIString); |
|
71 |
|
72 virtual ~CSTSURI(); |
|
73 |
|
74 public: |
|
75 |
|
76 /** |
|
77 * Getter for AID. Returns AID value, if URI type was AID, otherwice |
|
78 * returns KNullDesC8 reference. |
|
79 * @return AID in TDesC reference |
|
80 */ |
|
81 const TDesC8& AID() const; |
|
82 |
|
83 /** |
|
84 * Getter for slot number |
|
85 * @return slot number |
|
86 */ |
|
87 TUint8 Slot() const; |
|
88 |
|
89 /** |
|
90 * Getter for URI type |
|
91 * @return type of URI |
|
92 */ |
|
93 TURIType Type() const; |
|
94 |
|
95 protected: // New functions |
|
96 |
|
97 // Protected construction to allow derivation |
|
98 void ConstructL(const TDesC& aURIString); |
|
99 |
|
100 /** |
|
101 * C++ default constructor. |
|
102 */ |
|
103 CSTSURI(); |
|
104 |
|
105 /** |
|
106 * Cheks is URI string in correct form. |
|
107 */ |
|
108 TBool CheckURIL(const TDesC& aURI); |
|
109 |
|
110 /** |
|
111 * Returns integer value of the character, or 255 if |
|
112 * the character is not a hexadecimal digit. |
|
113 * @param aDigit hexadecimal character (0-9, a-f) |
|
114 * @return integer value of the character of 255. |
|
115 */ |
|
116 TUint8 GetHexValue(const TChar& aDigit); |
|
117 |
|
118 /** |
|
119 * parses AID from aURI. Note that this method may append |
|
120 * characters to aAID even when the parsing fails. |
|
121 * @param aURI uri which the AID is parsed from |
|
122 * @param aPos position to AID in aURI. |
|
123 * @param aAID AID is appended to this descriptor. |
|
124 * @return ETrue if AID was parsed successfully. EFalse if the |
|
125 * parsing fails, in which case the contents of aAID is undefined. |
|
126 */ |
|
127 TBool ParseAID(const TDesC& aURI, TInt aPos, TDes8& aAID); |
|
128 |
|
129 /** |
|
130 * Implements the state machine of parsing the AID. |
|
131 * @param aDigit current character to parse |
|
132 * @param aState state of the state machine |
|
133 * @param aAIDDigit currently parsed digit |
|
134 */ |
|
135 void ParseAIDCharacter(const TChar& aDigit, |
|
136 TAidParserState& aState, |
|
137 TUint8& aAIDDigit); |
|
138 |
|
139 protected: // Data |
|
140 |
|
141 // slot number |
|
142 TUint8 iSlot; |
|
143 // AID, owned |
|
144 HBufC8* iAID; |
|
145 |
|
146 // Type of URI |
|
147 TURIType iURIType; |
|
148 |
|
149 }; |
|
150 |
|
151 } // namespace satsa |
|
152 } // namespace java |
|
153 #endif // CSTSURI_H |
|
154 // End of File |