|
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: CXcapTestAppUsage |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "XcapTestAppUsage.h" |
|
22 |
|
23 // ---------------------------------------------------- |
|
24 // CXcapTestAppUsage::CXcapTestAppUsage |
|
25 // |
|
26 // ---------------------------------------------------- |
|
27 // |
|
28 CXcapTestAppUsage::CXcapTestAppUsage( const CXdmEngine& aXdmEngine ) : |
|
29 CXcapAppUsage( aXdmEngine ) |
|
30 { |
|
31 } |
|
32 |
|
33 // ---------------------------------------------------- |
|
34 // CXcapTestAppUsage::NewL |
|
35 // |
|
36 // ---------------------------------------------------- |
|
37 // |
|
38 CXcapTestAppUsage* CXcapTestAppUsage::NewL( const TXcapAppUsageParams& aParameters ) |
|
39 { |
|
40 CXcapTestAppUsage* self = new ( ELeave ) CXcapTestAppUsage( aParameters.iXdmEngine ); |
|
41 CleanupStack::PushL( self ); // << self |
|
42 self->ConstructL(); |
|
43 CleanupStack::Pop( self ); // >> self |
|
44 return self; |
|
45 } |
|
46 |
|
47 // ---------------------------------------------------- |
|
48 // CXcapTestAppUsage::~CXcapTestAppUsage |
|
49 // |
|
50 // ---------------------------------------------------- |
|
51 // |
|
52 CXcapTestAppUsage::~CXcapTestAppUsage() |
|
53 { |
|
54 } |
|
55 |
|
56 // ---------------------------------------------------- |
|
57 // CXcapTestAppUsage::ConstructL |
|
58 // |
|
59 // ---------------------------------------------------- |
|
60 // |
|
61 void CXcapTestAppUsage::ConstructL() |
|
62 { |
|
63 } |
|
64 |
|
65 // ---------------------------------------------------- |
|
66 // CXcapTestAppUsage::AUID |
|
67 // |
|
68 // ---------------------------------------------------- |
|
69 // |
|
70 TPtrC8 CXcapTestAppUsage::AUID() const |
|
71 { |
|
72 return TPtrC8( KXdmTestAppUsageAUID ); |
|
73 } |
|
74 |
|
75 // ---------------------------------------------------- |
|
76 // CXcapTestAppUsage::ContentType |
|
77 // |
|
78 // ---------------------------------------------------- |
|
79 // |
|
80 TPtrC8 CXcapTestAppUsage::ContentType() const |
|
81 { |
|
82 return TPtrC8( KXdmTestAppUsageContType ); |
|
83 } |
|
84 |
|
85 // ---------------------------------------------------- |
|
86 // CXcapTestAppUsage::DefaultNamespace |
|
87 // |
|
88 // ---------------------------------------------------- |
|
89 // |
|
90 TPtrC8 CXcapTestAppUsage::DefaultNamespace() const |
|
91 { |
|
92 return TPtrC8( KXdmTestAppUsageDefaultNamespace ); |
|
93 } |
|
94 |
|
95 // ---------------------------------------------------- |
|
96 // CXcapTestAppUsage::ValidateNodeL |
|
97 // |
|
98 // ---------------------------------------------------- |
|
99 // |
|
100 TBool CXcapTestAppUsage::ValidateNodeL( CXdmDocumentNode& /*aXdmNode*/ ) |
|
101 { |
|
102 // This method is called by base class for each element |
|
103 // in document, here we have to declare every element, check element |
|
104 // datatype, restrictions for values and also do all checking that concerns |
|
105 // the structure of the element. If the datatype is some of |
|
106 // the common datatypes defined in xcapappusage.h, the node |
|
107 // can pe passed to the base class for value validation. |
|
108 // If the node belongs to this namespace, the return value |
|
109 // should be true, false otherwise. |
|
110 |
|
111 |
|
112 // TBool found ( EFalse ); |
|
113 // TDataType dataType ( EDataTypeUndefined ); |
|
114 // TPtrC element = aXdmNode.NodeName(); |
|
115 |
|
116 // <example-element> |
|
117 // if ( Match( element, KExampleElement ) ) |
|
118 // { |
|
119 // supported data types are defined in AppUsageDef |
|
120 // dataType = EDataTypeBoolean; |
|
121 // found = ETrue; |
|
122 // } |
|
123 // <example-element2> |
|
124 // else if ( Match( element, KExampleElement2 ) ) |
|
125 // { |
|
126 // required attribute attribute |
|
127 // if ( !aXdmNode.HasAttribute( KAttribute ) ) |
|
128 // { |
|
129 // LeaveWithErrorL( KXcapErrorMissingRequiredAttribute ); |
|
130 // } |
|
131 // found = ETrue; |
|
132 // } |
|
133 // <example-element3> |
|
134 // else if ( Match( element, KExampleElement3 ) ) |
|
135 // { |
|
136 // TInt count( aXdmNode.NodeCount() ); |
|
137 // for ( TInt i(0); i < count; i++ ) |
|
138 // { |
|
139 // there should not be any other elements than <example> |
|
140 // if ( !Match( aXdmNode.ChileNode(i)->NodeName(), KExample ) ) |
|
141 // { |
|
142 // LeaveWithErrorL( KXcapErrorSchemaViolation ); |
|
143 // } |
|
144 // } |
|
145 // found = ETrue; |
|
146 // } |
|
147 |
|
148 // if ( dataType != EDataTypeUndefined ) |
|
149 // { |
|
150 // pass to the base class for data validation |
|
151 // ValidateDataL( dataType, aXdmNode ); |
|
152 // } |
|
153 // return found; |
|
154 |
|
155 return EFalse; |
|
156 } |
|
157 |
|
158 // ---------------------------------------------------- |
|
159 // CXcapTestAppUsage::ValidateAttributeL |
|
160 // |
|
161 // ---------------------------------------------------- |
|
162 // |
|
163 void CXcapTestAppUsage::ValidateAttributeL( const CXdmNodeAttribute& /*aXdmNodeAttr*/ ) |
|
164 { |
|
165 // This method is called by base class for each attribute |
|
166 // in document, here we have to define data types |
|
167 // for attributes, and pass them to the base class |
|
168 // for the actual data checking. |
|
169 |
|
170 // TDataType dataType ( EDataTypeUndefined ); |
|
171 // TPtrC attribute = aXdmNodeAttr.NodeName(); |
|
172 |
|
173 // exampleAttr1 |
|
174 // if ( Match( attribute, KExampleAttr1 ) ) |
|
175 // { |
|
176 // dataType = EDataTypeString; |
|
177 // } |
|
178 // exampleAttr2 |
|
179 // else if ( Match( attribute, KExampleAttr2 ) ) |
|
180 // { |
|
181 // dataType = EDataTypeString; |
|
182 // } |
|
183 |
|
184 // if ( dataType != EDataTypeUndefined ) |
|
185 // { |
|
186 // pass to base class for data validation |
|
187 // ValidateDataL( dataType, aXdmNodeAttr ); |
|
188 // } |
|
189 } |
|
190 |
|
191 // ---------------------------------------------------- |
|
192 // CXcapTestAppUsage::AddNamespaceInformationL |
|
193 // |
|
194 // ---------------------------------------------------- |
|
195 // |
|
196 void CXcapTestAppUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument ) |
|
197 { |
|
198 // default namespace prefix should be empty |
|
199 aXdmDocument.AppendNamespaceL( KXdmTestAppUsageDefaultNamespace, KNullDesC8 ); |
|
200 } |
|
201 |
|
202 // End of File |
|
203 |