|
1 /* |
|
2 * Copyright (c) 2002 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: SyncML Obex client |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <btsdp.h> |
|
20 #include "StaticArrayC.h" |
|
21 |
|
22 |
|
23 #ifndef __SDP_ATTRIBUTE_PARSER_PAN__ |
|
24 #define __SDP_ATTRIBUTE_PARSER_PAN__ |
|
25 |
|
26 /** BTPointToPoint application panic codes */ |
|
27 enum TSdpAttributeParserPanics |
|
28 { |
|
29 ESdpAttributeParserInvalidCommand = 1, |
|
30 ESdpAttributeParserNoValue, |
|
31 ESdpAttributeParserValueIsList, |
|
32 ESdpAttributeParserValueTypeUnsupported |
|
33 }; |
|
34 |
|
35 inline void Panic(TSdpAttributeParserPanics aReason) |
|
36 { |
|
37 User::Panic(_L("SAP"), aReason); |
|
38 } |
|
39 |
|
40 |
|
41 #endif // __SDP_ATTRIBUTE_PARSER_PAN__ |
|
42 |
|
43 |
|
44 |
|
45 #ifndef __NSML_SDP_ATTRIBUTE_PARSER_H__ |
|
46 #define __NSML_SDP_ATTRIBUTE_PARSER_H__ |
|
47 |
|
48 |
|
49 class MSdpAttributeNotifier; |
|
50 |
|
51 /*! |
|
52 @class TSdpAttributeParser |
|
53 |
|
54 @discussion An instance of TSdpAttributeParser is used to check an SDP |
|
55 attribute value, and read selected parts |
|
56 */ |
|
57 class TSdpAttributeParser : public MSdpAttributeValueVisitor |
|
58 { |
|
59 public: |
|
60 |
|
61 /*! |
|
62 @enum TNodeCommand |
|
63 |
|
64 @discussion The command to be carried out at a node |
|
65 @value ECheckType check the type of the value |
|
66 @value ECheckValue check the type and the value |
|
67 @value ECheckEnd check that a list ends at this point |
|
68 @value ESkip do not check this value - can not match a list end |
|
69 @value EReadValue pass the value onto the observer |
|
70 @value EFinished marks the end of the node list |
|
71 */ |
|
72 enum TNodeCommand |
|
73 { |
|
74 ECheckType, |
|
75 ECheckValue, |
|
76 ECheckEnd, |
|
77 ESkip, |
|
78 EReadValue, |
|
79 EFinished |
|
80 }; |
|
81 |
|
82 /*! |
|
83 struct SSdpAttributeNode |
|
84 |
|
85 @discussion An instance of SSdpAttributeNode is used to determine how |
|
86 to parse an SDP attribute value data element |
|
87 */ |
|
88 struct SSdpAttributeNode |
|
89 { |
|
90 /*! @var iCommand the command for the node */ |
|
91 TNodeCommand iCommand; |
|
92 |
|
93 /*! @var iType the expected type */ |
|
94 TSdpElementType iType; |
|
95 |
|
96 /*! @var iValue the expected value for ECheckValue, the value of aKey |
|
97 passed to the observer for EReadValue */ |
|
98 TInt iValue; |
|
99 }; |
|
100 |
|
101 typedef const TStaticArrayC<SSdpAttributeNode> TSdpAttributeList; |
|
102 |
|
103 /*! |
|
104 @function TSdpAttributeParser |
|
105 |
|
106 @discussion Construct a TSdpAttributeParser |
|
107 @param aNodeList the list of expected nodes |
|
108 @param aObserver an observer to read specified node values |
|
109 */ |
|
110 TSdpAttributeParser(TSdpAttributeList& aNodeList, MSdpAttributeNotifier& aObserver); |
|
111 |
|
112 /*! |
|
113 @function HasFinished |
|
114 |
|
115 @discussion Check if parsing processed the whole list |
|
116 @result true is the index refers to the EFinished node |
|
117 */ |
|
118 TBool HasFinished() const; |
|
119 |
|
120 public: // from MSdpAttributeValueVisitor |
|
121 |
|
122 /*! |
|
123 @function VisitAttributeValueL |
|
124 |
|
125 @discussion Process a data element |
|
126 @param aValue the data element |
|
127 @param aType the type of the data element |
|
128 */ |
|
129 void VisitAttributeValueL(CSdpAttrValue& aValue, TSdpElementType aType); |
|
130 |
|
131 /*! |
|
132 @function StartListL |
|
133 |
|
134 @discussion Process the start of a data element list |
|
135 @param aList the data element list |
|
136 */ |
|
137 void StartListL(CSdpAttrValueList& aList); |
|
138 |
|
139 /*! |
|
140 @function EndListL |
|
141 |
|
142 @discussion Process the end of a data element list |
|
143 */ |
|
144 void EndListL(); |
|
145 |
|
146 private: |
|
147 |
|
148 /*! |
|
149 @function CheckTypeL |
|
150 |
|
151 @discussion Check the type of the current node is the same as the specified type |
|
152 @param aElementType the type of the current data element |
|
153 */ |
|
154 void CheckTypeL(TSdpElementType aElementType) const; |
|
155 |
|
156 /*! |
|
157 @function CheckValueL |
|
158 |
|
159 @discussion Check the value of the current node is the same as the specified value |
|
160 @param aValue the value of the current data element. |
|
161 */ |
|
162 void CheckValueL(CSdpAttrValue& aValue) const; |
|
163 |
|
164 /*! |
|
165 @function ReadValueL |
|
166 |
|
167 @discussion Pass the data element value to the observer |
|
168 @param aValue the value of the current data element. |
|
169 */ |
|
170 void ReadValueL(CSdpAttrValue& aValue) const; |
|
171 |
|
172 /*! |
|
173 @function CurrentNode |
|
174 |
|
175 @discussion Get the current node |
|
176 @result the current node |
|
177 */ |
|
178 const SSdpAttributeNode& CurrentNode() const; |
|
179 |
|
180 /*! |
|
181 @function AdvanceL |
|
182 |
|
183 @discussion Advance to the next node. Leaves with KErrEof if at the finished node. |
|
184 */ |
|
185 void AdvanceL(); |
|
186 |
|
187 private: |
|
188 |
|
189 /*! @var iObserver the observer to read values */ |
|
190 MSdpAttributeNotifier& iObserver; |
|
191 |
|
192 /*! @var iNodeList a list defining the expected structure of the value */ |
|
193 TSdpAttributeList& iNodeList; |
|
194 |
|
195 /*! @var iCurrentNodeIndex the index of the current node in iNodeList */ |
|
196 TInt iCurrentNodeIndex; |
|
197 }; |
|
198 |
|
199 #endif // __NSML_SDP_ATTRIBUTE_PARSER_H__ |