1 /* |
|
2 * Copyright (c) 2005 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: CXcapResourceListsUsage |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <XdmErrors.h> |
|
22 #include <XdmDocumentNode.h> |
|
23 #include <XdmNodeAttribute.h> |
|
24 #include "XcapResourceListsUsage.h" |
|
25 |
|
26 // Used specification |
|
27 // draft-ietf-simple-xcap-list-usage-05, 7 February 2005 |
|
28 // expires 8 August 2005 |
|
29 |
|
30 // ---------------------------------------------------- |
|
31 // CXcapResourceListsUsage::CXcapResourceListsUsage |
|
32 // |
|
33 // ---------------------------------------------------- |
|
34 // |
|
35 CXcapResourceListsUsage::CXcapResourceListsUsage( const CXdmEngine& aXdmEngine ) : |
|
36 CXcapAppUsage( aXdmEngine ) |
|
37 { |
|
38 } |
|
39 |
|
40 // ---------------------------------------------------- |
|
41 // CXcapResourceListsUsage::NewL |
|
42 // |
|
43 // ---------------------------------------------------- |
|
44 // |
|
45 CXcapResourceListsUsage* CXcapResourceListsUsage::NewL( const TXcapAppUsageParams& aParameters ) |
|
46 { |
|
47 CXcapResourceListsUsage* self = new ( ELeave ) CXcapResourceListsUsage( aParameters.iXdmEngine ); |
|
48 CleanupStack::PushL( self ); // << self |
|
49 self->ConstructL(); |
|
50 CleanupStack::Pop( self ); // >> self |
|
51 return self; |
|
52 } |
|
53 |
|
54 // ---------------------------------------------------- |
|
55 // CXcapResourceListsUsage::~CXcapResourceListsUsage |
|
56 // |
|
57 // ---------------------------------------------------- |
|
58 // |
|
59 CXcapResourceListsUsage::~CXcapResourceListsUsage() |
|
60 { |
|
61 } |
|
62 |
|
63 // ---------------------------------------------------- |
|
64 // CXcapResourceListsUsage::ConstructL |
|
65 // |
|
66 // ---------------------------------------------------- |
|
67 // |
|
68 void CXcapResourceListsUsage::ConstructL() |
|
69 { |
|
70 } |
|
71 |
|
72 // ---------------------------------------------------- |
|
73 // CXcapResourceListsUsage::AUID |
|
74 // |
|
75 // ---------------------------------------------------- |
|
76 // |
|
77 TPtrC8 CXcapResourceListsUsage::AUID() const |
|
78 { |
|
79 return TPtrC8( KXdmResourceListsUsageAUID ); |
|
80 } |
|
81 |
|
82 // ---------------------------------------------------- |
|
83 // CXcapResourceListsUsage::ContentType |
|
84 // |
|
85 // ---------------------------------------------------- |
|
86 // |
|
87 TPtrC8 CXcapResourceListsUsage::ContentType() const |
|
88 { |
|
89 return TPtrC8( KXdmResourceListsUsageContType ); |
|
90 } |
|
91 |
|
92 // ---------------------------------------------------- |
|
93 // CXcapResourceListsUsage::DefaultNamespace |
|
94 // |
|
95 // ---------------------------------------------------- |
|
96 // |
|
97 TPtrC8 CXcapResourceListsUsage::DefaultNamespace() const |
|
98 { |
|
99 return TPtrC8( KXdmResourceListsNamespace ); |
|
100 } |
|
101 |
|
102 // ---------------------------------------------------- |
|
103 // CXcapResourceListsUsage::ValidateL |
|
104 // |
|
105 // ---------------------------------------------------- |
|
106 // |
|
107 TBool CXcapResourceListsUsage::ValidateNodeL( CXdmDocumentNode& aXdmNode ) |
|
108 { |
|
109 // This method is called by base class for each element |
|
110 // in document, here we have to declare every element, check element |
|
111 // datatype, restrictions for values and also do all checking that concerns |
|
112 // the structure of the element. If the datatype is some of |
|
113 // the common datatypes defined in xcapappusage.h, the node |
|
114 // can pe passed to the base class for value validation. |
|
115 // If the node belongs to this namespace, the return value |
|
116 // should be true, false otherwise. |
|
117 |
|
118 TBool found ( EFalse ); |
|
119 TDataType dataType ( EDataTypeUndefined ); |
|
120 TPtrC element = aXdmNode.NodeName(); |
|
121 |
|
122 // <resource-lists> |
|
123 if ( Match( element, KXdmResourceLists) ) |
|
124 { |
|
125 TInt count( aXdmNode.NodeCount() ); |
|
126 for ( TInt i(0); i < count; i++ ) |
|
127 { |
|
128 // there should not be any other elements than <list> |
|
129 if ( !Match( aXdmNode.ChileNode(i)->NodeName(), KXdmList ) ) |
|
130 { |
|
131 LeaveWithErrorL( KXcapErrorSchemaViolation ); |
|
132 } |
|
133 } |
|
134 found = ETrue; |
|
135 } |
|
136 // <list> |
|
137 else if ( Match( element, KXdmList ) ) |
|
138 { |
|
139 found = ETrue; |
|
140 } |
|
141 // <entry> |
|
142 else if ( Match( element, KXdmEntry ) ) |
|
143 { |
|
144 // required attribute uri |
|
145 if ( !aXdmNode.HasAttribute( KXdmUri ) ) |
|
146 { |
|
147 LeaveWithErrorL( KXcapErrorMissingRequiredAttribute ); |
|
148 } |
|
149 found = ETrue; |
|
150 } |
|
151 // <entry-ref> |
|
152 else if ( Match( element, KXdmEntryRef ) ) |
|
153 { |
|
154 if ( !aXdmNode.HasAttribute( KXdmRef ) ) |
|
155 { |
|
156 LeaveWithErrorL( KXcapErrorMissingRequiredAttribute ); |
|
157 } |
|
158 found = ETrue; |
|
159 } |
|
160 // <display-name> |
|
161 else if ( Match( element, KXdmDisplayName ) ) |
|
162 { |
|
163 dataType = EDataTypeString; |
|
164 found = ETrue; |
|
165 } |
|
166 |
|
167 if ( dataType != EDataTypeUndefined ) |
|
168 { |
|
169 // pass to the base class for data validation |
|
170 ValidateDataL( dataType, aXdmNode ); |
|
171 } |
|
172 return found; |
|
173 } |
|
174 |
|
175 // ---------------------------------------------------- |
|
176 // CXcapResourceListsUsage::ValidateAttributeL |
|
177 // |
|
178 // ---------------------------------------------------- |
|
179 // |
|
180 void CXcapResourceListsUsage::ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr ) |
|
181 { |
|
182 // This method is called by base class for each attribute |
|
183 // in document, here we have to define data types |
|
184 // for attributes, and pass them to the base class |
|
185 // for the actual data checking. |
|
186 |
|
187 TDataType dataType ( EDataTypeUndefined ); |
|
188 TPtrC attribute = aXdmNodeAttr.NodeName(); |
|
189 |
|
190 // name |
|
191 if ( Match( attribute, KXdmName ) ) |
|
192 { |
|
193 dataType = EDataTypeString; |
|
194 } |
|
195 // uri |
|
196 else if ( Match( attribute, KXdmUri ) ) |
|
197 { |
|
198 dataType = EDataTypeString; |
|
199 } |
|
200 // ref |
|
201 else if ( Match( attribute, KXdmRef ) ) |
|
202 { |
|
203 dataType = EDataTypeAnyURI; |
|
204 } |
|
205 // anchor |
|
206 else if ( Match( attribute, KXdmAnchor ) ) |
|
207 { |
|
208 dataType = EDataTypeAnyURI; |
|
209 } |
|
210 |
|
211 if ( dataType != EDataTypeUndefined ) |
|
212 { |
|
213 // pass to base class for data validation |
|
214 ValidateDataL( dataType, aXdmNodeAttr ); |
|
215 } |
|
216 } |
|
217 |
|
218 // ---------------------------------------------------- |
|
219 // CXcapResourceListsUsage::AddNamespaceInformationL |
|
220 // |
|
221 // ---------------------------------------------------- |
|
222 // |
|
223 void CXcapResourceListsUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument ) |
|
224 { |
|
225 aXdmDocument.AppendNamespaceL( KXdmResourceListsNamespace, KNullDesC8 ); |
|
226 } |
|
227 |
|
228 // End of File |
|
229 |
|