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: CXcapPocGroupUsage |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <XdmErrors.h> |
|
22 #include <XdmDocumentNode.h> |
|
23 #include <XdmNodeAttribute.h> |
|
24 #include "XcapPocGroupUsage.h" |
|
25 |
|
26 |
|
27 |
|
28 // Used specification |
|
29 // OMA-TS-PoC_XDM-V1_0-20060609-A, 09 June 2006 |
|
30 // ---------------------------------------------------- |
|
31 // CXcapPocGroupUsage::CXcapPocGroupUsage |
|
32 // |
|
33 // ---------------------------------------------------- |
|
34 // |
|
35 CXcapPocGroupUsage::CXcapPocGroupUsage( const CXdmEngine& aXdmEngine ) : |
|
36 CXcapAppUsage( aXdmEngine ), |
|
37 iIetfCommonPolicies( NULL ), |
|
38 iOmaCommonPolicies( NULL ), |
|
39 iResourceLists( NULL ) |
|
40 { |
|
41 } |
|
42 |
|
43 // ---------------------------------------------------- |
|
44 // CXcapPocGroupUsage::NewL |
|
45 // |
|
46 // ---------------------------------------------------- |
|
47 // |
|
48 CXcapPocGroupUsage* CXcapPocGroupUsage::NewL( const TXcapAppUsageParams& aParameters ) |
|
49 { |
|
50 CXcapPocGroupUsage* self = new ( ELeave ) CXcapPocGroupUsage( aParameters.iXdmEngine ); |
|
51 CleanupStack::PushL( self ); // << self |
|
52 self->ConstructL(); |
|
53 CleanupStack::Pop( self ); // >> self |
|
54 return self; |
|
55 } |
|
56 |
|
57 // ---------------------------------------------------- |
|
58 // CXcapPocGroupUsage::~CXcapPocGroupUsage |
|
59 // |
|
60 // ---------------------------------------------------- |
|
61 // |
|
62 CXcapPocGroupUsage::~CXcapPocGroupUsage() |
|
63 { |
|
64 delete iIetfCommonPolicies; |
|
65 delete iOmaCommonPolicies; |
|
66 delete iResourceLists; |
|
67 } |
|
68 |
|
69 // ---------------------------------------------------- |
|
70 // CXcapPocGroupUsage::ConstructL |
|
71 // |
|
72 // ---------------------------------------------------- |
|
73 // |
|
74 void CXcapPocGroupUsage::ConstructL() |
|
75 { |
|
76 iIetfCommonPolicies = CXcapAppUsage::NewL( iXdmEngine, EXdmIetfCommonPolicy ); |
|
77 iOmaCommonPolicies = CXcapAppUsage::NewL( iXdmEngine, EXdmOmaCommonPolicy ); |
|
78 iResourceLists = CXcapAppUsage::NewL( iXdmEngine, EXdmResourceLists ); |
|
79 } |
|
80 |
|
81 // ---------------------------------------------------- |
|
82 // CXcapPocGroupUsage::AUID |
|
83 // |
|
84 // ---------------------------------------------------- |
|
85 // |
|
86 TPtrC8 CXcapPocGroupUsage::AUID() const |
|
87 { |
|
88 return TPtrC8( KXdmPocGroupUsageAUID ); |
|
89 } |
|
90 |
|
91 // ---------------------------------------------------- |
|
92 // CXcapPocGroupUsage::ContentType |
|
93 // |
|
94 // ---------------------------------------------------- |
|
95 // |
|
96 TPtrC8 CXcapPocGroupUsage::ContentType() const |
|
97 { |
|
98 return TPtrC8( KXdmPocGroupUsageContType ); |
|
99 } |
|
100 |
|
101 // ---------------------------------------------------- |
|
102 // CXcapPocGroupUsage::DefaultNamespace |
|
103 // |
|
104 // ---------------------------------------------------- |
|
105 // |
|
106 TPtrC8 CXcapPocGroupUsage::DefaultNamespace() const |
|
107 { |
|
108 return TPtrC8( KXdmPocGroupNamespace ); |
|
109 } |
|
110 |
|
111 // ---------------------------------------------------- |
|
112 // CXcapPocGroupUsage::ValidateNodeL |
|
113 // |
|
114 // ---------------------------------------------------- |
|
115 // |
|
116 TBool CXcapPocGroupUsage::ValidateNodeL( CXdmDocumentNode& aXdmNode ) |
|
117 { |
|
118 // This method is called by base class for each element |
|
119 // in document, here we have to declare every element, check element |
|
120 // datatype, restrictions for values and also do all checking that concerns |
|
121 // the structure of the element. If the datatype is some of |
|
122 // the common datatypes defined in xcapappusage.h, the node |
|
123 // can pe passed to the base class for value validation. |
|
124 // If the node belongs to this namespace, the return value |
|
125 // should be true, false otherwise. |
|
126 |
|
127 TBool found( EFalse ); |
|
128 TDataType dataType ( EDataTypeUndefined ); |
|
129 TPtrC element = aXdmNode.NodeName(); |
|
130 |
|
131 // <group> |
|
132 if ( Match( element, KXdmGroup ) ) |
|
133 { |
|
134 // no other elements than <list-service> |
|
135 TInt count( aXdmNode.NodeCount() ); |
|
136 for ( TInt i(0); i < count; i++ ) |
|
137 { |
|
138 if ( !Match( aXdmNode.ChileNode(i)->NodeName(), KXdmListService ) ) |
|
139 { |
|
140 LeaveWithErrorL( KXcapErrorSchemaViolation ); |
|
141 } |
|
142 } |
|
143 found = ETrue; |
|
144 } |
|
145 // <list-service> |
|
146 else if ( Match( element, KXdmListService ) ) |
|
147 { |
|
148 // required attribute uri |
|
149 if ( !aXdmNode.HasAttribute( KXdmUri ) ) |
|
150 { |
|
151 LeaveWithErrorL( KXcapErrorMissingRequiredAttribute ); |
|
152 } |
|
153 found = ETrue; |
|
154 } |
|
155 // <display-name> |
|
156 else if ( Match( element, KXdmDisplayName ) ) |
|
157 { |
|
158 CXdmDocumentNode* parent = aXdmNode.Parent(); |
|
159 if ( parent && !parent->NodeName().CompareF( KXdmEntry ) ) |
|
160 { |
|
161 found = iResourceLists->ValidateNodeL( aXdmNode ); |
|
162 if ( found ) |
|
163 { |
|
164 SetPrefixL( aXdmNode, KXdmResourceListsNsPrefix ); |
|
165 } |
|
166 } |
|
167 else |
|
168 { |
|
169 dataType = EDataTypeString; |
|
170 found = ETrue; |
|
171 } |
|
172 } |
|
173 // <invite-members> |
|
174 else if ( Match( element, KXdmInviteMembers ) ) |
|
175 { |
|
176 dataType = EDataTypeBoolean; |
|
177 found = ETrue; |
|
178 } |
|
179 // <max-participant-count> |
|
180 else if ( Match( element, KXdmMaxParticipantCount ) ) |
|
181 { |
|
182 dataType = EDataTypeNonNegativeInteger; |
|
183 found = ETrue; |
|
184 } |
|
185 // <is-list-member> |
|
186 else if ( Match( element, KXdmIsListMember ) ) |
|
187 { |
|
188 // dataType = EDataTypeBoolean; // OMA-TS-PoC_XDM-V1_0-20050317-C, 17 March 2005 |
|
189 // changed 4-Nov-2005 PoC XDM |
|
190 dataType = EDataTypeEmpty; |
|
191 found = ETrue; |
|
192 } |
|
193 // <allow-conference-state> |
|
194 else if ( Match( element, KXdmAllowConfState ) ) |
|
195 { |
|
196 dataType = EDataTypeBoolean; |
|
197 found = ETrue; |
|
198 } |
|
199 // <allow-invite-users-dynamically> |
|
200 else if ( Match( element, KXdmAllowInvUsersDyn ) ) |
|
201 { |
|
202 dataType = EDataTypeBoolean; |
|
203 found = ETrue; |
|
204 } |
|
205 // <join-handling> |
|
206 else if ( Match( element, KXdmJoinHandling ) ) |
|
207 { |
|
208 // OMA-TS-PoC_XDM-V1_0-20050317-C, 17 March 2005 |
|
209 // the value must be "allow" or "block" |
|
210 // 0 (block) and 1 (allow) |
|
211 /* TPtrC8 data = aXdmNode.LeafNodeContent(); |
|
212 if ( data.CompareF( KXdmAllow ) |
|
213 && data.CompareF( KXdmBlock ) ) |
|
214 { |
|
215 LeaveWithErrorL( KXcapErrorEnumerationRule ); |
|
216 } |
|
217 */ |
|
218 // changed OMA-TS-PoC_XDM-V1_0-20060127-C, 27 January 2006 |
|
219 dataType = EDataTypeBoolean; |
|
220 found = ETrue; |
|
221 } |
|
222 // <allow-initiate-conference> |
|
223 else if ( Match( element, KXdmAllowInitiateConf ) ) |
|
224 { |
|
225 dataType = EDataTypeBoolean; |
|
226 found = ETrue; |
|
227 } |
|
228 // <allow-anonymity> |
|
229 else if ( Match( element, KXdmAllowAnonymity ) ) |
|
230 { |
|
231 dataType = EDataTypeBoolean; |
|
232 found = ETrue; |
|
233 } |
|
234 // <is-key-participant> |
|
235 else if ( Match( element, KXdmIsKeyParticipant ) ) |
|
236 { |
|
237 dataType = EDataTypeBoolean; |
|
238 found = ETrue; |
|
239 } |
|
240 // <external> |
|
241 // type = rl:externalType from urn:ietf:params:xml:ns:resource-lists |
|
242 // pass to the appropriate usage for validation |
|
243 // but use default namespace |
|
244 else if ( Match( element, KXdmExternal ) ) |
|
245 { |
|
246 found = iResourceLists->ValidateNodeL( aXdmNode ); |
|
247 } |
|
248 // <entry> |
|
249 // type = rl:entryType from urn:ietf:params:xml:ns:resource-lists |
|
250 // pass to the appropriate usage for validation |
|
251 // but use default namespace |
|
252 else if ( Match( element, KXdmEntry ) ) |
|
253 { |
|
254 found = iResourceLists->ValidateNodeL( aXdmNode ); |
|
255 } |
|
256 |
|
257 // urn:ietf:params:xml:ns:common-policy |
|
258 if ( !found ) |
|
259 { |
|
260 found = iIetfCommonPolicies->ValidateNodeL( aXdmNode ); |
|
261 if ( found ) |
|
262 { |
|
263 SetPrefixL( aXdmNode, KXdmIetfCommonPolicyNsPrefix ); |
|
264 } |
|
265 } |
|
266 // urn:oma:params:xml:ns:common-policy |
|
267 if ( !found ) |
|
268 { |
|
269 found = iOmaCommonPolicies->ValidateNodeL( aXdmNode ); |
|
270 if ( found ) |
|
271 { |
|
272 SetPrefixL( aXdmNode, KXdmOmaCommonPolicyNsPrefix ); |
|
273 } |
|
274 } |
|
275 |
|
276 // if the node is some of the basic types, |
|
277 // pass it to the base class for data validation |
|
278 if ( dataType != EDataTypeUndefined ) |
|
279 { |
|
280 ValidateDataL( dataType, aXdmNode ); |
|
281 } |
|
282 return found; |
|
283 } |
|
284 |
|
285 // ---------------------------------------------------- |
|
286 // CXcapPocGroupUsage::ValidateAttributeL |
|
287 // |
|
288 // ---------------------------------------------------- |
|
289 // |
|
290 void CXcapPocGroupUsage::ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr ) |
|
291 { |
|
292 // This method is called by base class for each attribute |
|
293 // in document, here we have to define data types |
|
294 // for attributes, and pass them to the base class |
|
295 // for the actual data checking. |
|
296 |
|
297 TPtrC attribute = aXdmNodeAttr.NodeName(); |
|
298 |
|
299 // uri |
|
300 if ( Match( attribute, KXdmUri ) ) |
|
301 { |
|
302 // pass to base class for data validation |
|
303 // check if this should be SIP uri |
|
304 ValidateDataL( EDataTypeAnyURI, aXdmNodeAttr ); |
|
305 } |
|
306 else |
|
307 { |
|
308 // add parent element namespace checking when available, |
|
309 // now we don't know the attribute's namespace |
|
310 iIetfCommonPolicies->ValidateAttributeL( aXdmNodeAttr ); |
|
311 iOmaCommonPolicies->ValidateAttributeL( aXdmNodeAttr ); |
|
312 } |
|
313 } |
|
314 |
|
315 // ---------------------------------------------------- |
|
316 // CXcapPocGroupUsage::AddNamespaceInformationL |
|
317 // |
|
318 // ---------------------------------------------------- |
|
319 // |
|
320 void CXcapPocGroupUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument ) |
|
321 { |
|
322 aXdmDocument.AppendNamespaceL( KXdmPocGroupNamespace, KNullDesC8 ); |
|
323 aXdmDocument.AppendNamespaceL( KXdmResourceListsNamespace, KXdmResourceListsNsPrefix ); |
|
324 aXdmDocument.AppendNamespaceL( KXdmIetfCommonPolicyNamespace, KXdmIetfCommonPolicyNsPrefix ); |
|
325 aXdmDocument.AppendNamespaceL( KXdmOmaCommonPolicyNamespace, KXdmOmaCommonPolicyNsPrefix ); |
|
326 } |
|
327 |
|
328 |
|
329 // End of File |
|
330 |
|