1 /* |
|
2 * Copyright (c) 2003 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 |
|
20 #ifndef CONFORMANCECHECKER_H |
|
21 #define CONFORMANCECHECKER_H |
|
22 |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <e32std.h> |
|
27 |
|
28 #include <gmxmldocument.h> |
|
29 #include <gmxmlelement.h> |
|
30 |
|
31 |
|
32 // CONSTANTS |
|
33 _LIT(KMetaTag,"meta"); |
|
34 _LIT(KPercent,"%"); |
|
35 _LIT(KPx,"px"); |
|
36 _LIT(KMs,"ms"); |
|
37 _LIT(KImage,"Image"); |
|
38 _LIT(KText,"Text"); |
|
39 |
|
40 const TInt KUSAsciiMinCode = 0; |
|
41 const TInt KUSAsciiMaxCode = 127; |
|
42 |
|
43 //Type for the version of the Conformance Document |
|
44 enum TMmsSmilVersion |
|
45 { |
|
46 EMmsSmil_v2_0=2, |
|
47 EMmsSmil_v3_0 |
|
48 }; |
|
49 |
|
50 |
|
51 enum TFlags |
|
52 { |
|
53 EAllowVideoTag=1, //Allowing video tag as media |
|
54 EAllowAllAttributes=2, //Not checking the attribute name of the elements |
|
55 EAllowNonMilliseconds=4, //Allows other timing specifications then 'ms' (e.g. 's') |
|
56 EAllowNonUsAscii=8, //Allows other than us-ascii values for src attribute |
|
57 //for media elements |
|
58 EAllowMixedRegionDimensions=16, //Allows mixed region dimensions (pixel and percent) |
|
59 EAllowSeqTag=32, //Allows one <seq> tag right after the <body> tag |
|
60 EAllowAnyRegionNames=64 //Allows any name for the regions |
|
61 }; |
|
62 |
|
63 |
|
64 |
|
65 // CLASS DECLARATION |
|
66 |
|
67 /** |
|
68 * Class for checking the the content of a DOM tree against the Conformance Document. |
|
69 * (Checking legacy content.) |
|
70 * |
|
71 * @lib smileng.lib |
|
72 * @since 2.0 |
|
73 */ |
|
74 class CConformanceChecker : public CBase |
|
75 { |
|
76 |
|
77 public: // Constructors and destructor |
|
78 |
|
79 /** |
|
80 * Two-phased constructor. |
|
81 * @param aStrict - value of the checking mode flag |
|
82 */ |
|
83 static CConformanceChecker* NewL(); |
|
84 |
|
85 /** |
|
86 * Destructor. |
|
87 */ |
|
88 ~CConformanceChecker(); |
|
89 |
|
90 public: // New functions |
|
91 |
|
92 /** |
|
93 * Checks if the DOM tree's content is legacy content or not. |
|
94 * @param aXmldoc - the root of the DOM tree |
|
95 * @aVersion - the version of the Conformance Document |
|
96 * @aFlags - the flags to gide the checking (combination of TFlags values) |
|
97 * @return - true if the content is legacy |
|
98 - false if the content is not legacy |
|
99 */ |
|
100 TBool Check(CMDXMLDocument* aXmldoc, TMmsSmilVersion aVersion, TInt aFlags); |
|
101 |
|
102 private: |
|
103 |
|
104 /** Checks the structure of the head element: allowed to contain only layout and meta element |
|
105 * @param aHead - the root of head subtree |
|
106 * @param aStrict - flag for checking mode (true strict checking, false loose checking) |
|
107 * @return - true - if head has legacy structure |
|
108 * - false - otherwise |
|
109 */ |
|
110 TBool CheckHeadStructure(CMDXMLNode* aHead); |
|
111 |
|
112 |
|
113 /** Checks the structure of the body element: |
|
114 - allowed to contain only par elements |
|
115 * (one including seq element right after the body is allowed) |
|
116 * @param aBody - the root of body subtree |
|
117 * @return - true - if body has legacy structure |
|
118 * - false - otherwise |
|
119 */ |
|
120 TBool CheckBodyStructure(CMDXMLNode* aBody); |
|
121 |
|
122 |
|
123 /** Checks the content of the layout element |
|
124 * - root-layout and max. 2 region elements are allowed |
|
125 * @param aLayout - the root of layout subtree |
|
126 * @return - true - if layout has legacy content |
|
127 * - false - otherwise |
|
128 */ |
|
129 TBool CheckLayoutContent(CMDXMLNode* aLayout); |
|
130 |
|
131 |
|
132 /** Checks the content of the body element |
|
133 * @param aBody - the root of body subtree |
|
134 * @return - true - if body has legacy content |
|
135 * - false - otherwise |
|
136 */ |
|
137 TBool CheckBodyContent(CMDXMLNode* aBody); |
|
138 |
|
139 |
|
140 /** Checks the content of the par element |
|
141 * @param aPar - the root of par subtree |
|
142 * @return - true - if par has legacy content |
|
143 * - false - otherwise |
|
144 */ |
|
145 TBool CheckParContent(CMDXMLNode* aPar); |
|
146 |
|
147 |
|
148 /** Checks if a descriptor is ending with 'ms' |
|
149 * @param aValue - value to check |
|
150 * @return - true if the ending is ms |
|
151 * - false otherwise |
|
152 */ |
|
153 |
|
154 TBool IsInMilliseconds(TDesC& aValue) const; |
|
155 |
|
156 |
|
157 /** Checks if the given value is ending with percent or pixel |
|
158 * and if this is conforming to the already set pixel and percent values. |
|
159 * @param aValue - value to check, |
|
160 * - should be the value of 'width', 'height', 'top', 'left' |
|
161 * attributes for a region |
|
162 * @param aPercent - true if the value should end with percent |
|
163 * @param aPixel - true if the value should be in pixel |
|
164 * @return true - if the value is not mixed (regarding aPercent,aPixel) |
|
165 * false - if mixed |
|
166 */ |
|
167 TBool CheckMixedRegionAttribute(TDesC& aValue,TBool& aPercent,TBool& aPixel) const; |
|
168 |
|
169 /** Checks if the given value is exactly "Image" or "Text" and if it |
|
170 * is duplicated (checking the transmitted boolean parameters). |
|
171 * @param aValue - value to check, |
|
172 * @param aFoundImage - true if the "Image" value will be duplicate |
|
173 * @param aFoundText - true if the "Text" value will be duplicate |
|
174 * @return true - if the value is "Image" or "Text" and it's not duplicated |
|
175 * false - otherwise |
|
176 */ |
|
177 TBool CheckRegionNames(TDesC& aValue,TBool& aFoundImage,TBool& aFoundText) const; |
|
178 |
|
179 |
|
180 private: // Data |
|
181 |
|
182 |
|
183 TInt iFlags; //contains the flags to guide the checking |
|
184 }; |
|
185 |
|
186 #endif // CONFORMANCECHECKER_H |
|
187 |
|
188 // End of File |
|