|
1 /* |
|
2 * Copyright (c) 2007-2009 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: Implementation class for OMA 2.1 Drm String Dictionary |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <ecom/implementationproxy.h> |
|
21 #include <xml/plugins/dictionarycodepage.h> |
|
22 #include <xml/xmlframeworkerrors.h> |
|
23 |
|
24 #include "drmrel2_1stringdict00.h" |
|
25 #include "drmrel2_1stringdict00tagtable.h" |
|
26 #include "drmrel2_1stringdict00attributetable.h" |
|
27 #include "drmrel2_1stringdict00attributevaluetable.h" |
|
28 |
|
29 using namespace Xml; |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CDrmRel2_1StringDict00::NewL |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 MStringDictionary* CDrmRel2_1StringDict00::NewL( TAny* aStringPool ) |
|
36 { |
|
37 CDrmRel2_1StringDict00* self( |
|
38 new(ELeave) CDrmRel2_1StringDict00( |
|
39 reinterpret_cast<RStringPool*>( aStringPool ) ) ); |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop( self ); |
|
43 return ( static_cast<MStringDictionary*>( self ) ); |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CDrmRel2_1StringDict00::CDrmRel2_1StringDict00 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CDrmRel2_1StringDict00::CDrmRel2_1StringDict00( RStringPool* aStringPool ) |
|
51 : iStringPool( *aStringPool ), iCodePage( 0 ) |
|
52 { |
|
53 // do nothing; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CDrmRel2_1StringDict00::ConstructL |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 void CDrmRel2_1StringDict00::ConstructL() |
|
61 { |
|
62 // we don't own this stringpool |
|
63 iStringPool.OpenL( DrmRel2_1StringDict00TagTable::Table ); |
|
64 iStringPool.OpenL( DrmRel2_1StringDict00AttributeTable::Table ); |
|
65 iStringPool.OpenL( DrmRel2_1StringDict00AttributeValueTable::Table ); |
|
66 |
|
67 iCodepage00Table = CDictionaryCodePage::NewL( |
|
68 &DrmRel2_1StringDict00TagTable::Table, |
|
69 &DrmRel2_1StringDict00AttributeTable::Table, |
|
70 &DrmRel2_1StringDict00AttributeValueTable::Table, |
|
71 0 ); // codepage |
|
72 |
|
73 // Construct the correlation mapping |
|
74 iCodepage00Table->ConstructIndexMappingL( |
|
75 iTagCodePage00, |
|
76 CDictionaryCodePage::EStringTypeElement ); |
|
77 |
|
78 iCodepage00Table->ConstructIndexMappingL( |
|
79 iAttributeCodePage00, |
|
80 CDictionaryCodePage::EStringTypeAttribute ); |
|
81 |
|
82 iCodepage00Table->ConstructIndexMappingL( |
|
83 iAttributeValueCodePage00, |
|
84 CDictionaryCodePage::EStringTypeAttributeValue ); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CDrmRel2_1StringDict00::Release |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CDrmRel2_1StringDict00::Release() |
|
92 { |
|
93 delete ( this ); |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CDrmRel2_1StringDict00::~CCDrmRel2_1StringDict00 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 CDrmRel2_1StringDict00::~CDrmRel2_1StringDict00() |
|
101 { |
|
102 if ( iCodepage00Table ) |
|
103 { |
|
104 delete iCodepage00Table; |
|
105 } |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CDrmRel2_1StringDict00::ElementL |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 void CDrmRel2_1StringDict00::ElementL( |
|
113 TInt aToken, |
|
114 RString& aElement) const |
|
115 { |
|
116 TInt index( iCodepage00Table->StringPoolIndexFromToken( |
|
117 aToken, |
|
118 CDictionaryCodePage::EStringTypeElement ) ); |
|
119 |
|
120 if ( index == KErrXmlStringPoolTableNotFound ) |
|
121 { |
|
122 User::Leave( KErrXmlUnsupportedElement ); |
|
123 } |
|
124 |
|
125 aElement = iStringPool.String( |
|
126 index, |
|
127 *( iCodepage00Table->StringTable( |
|
128 CDictionaryCodePage::EStringTypeElement ) ) ); |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CDrmRel2_1StringDict00::AttributeL |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void CDrmRel2_1StringDict00::AttributeL( |
|
136 TInt aToken, |
|
137 RString& aAttribute) const |
|
138 { |
|
139 TInt index( iCodepage00Table->StringPoolIndexFromToken( |
|
140 aToken, |
|
141 CDictionaryCodePage::EStringTypeAttribute ) ); |
|
142 |
|
143 if ( index == KErrXmlStringPoolTableNotFound ) |
|
144 { |
|
145 User::Leave( KErrXmlUnsupportedAttribute ); |
|
146 } |
|
147 |
|
148 aAttribute = iStringPool.String( |
|
149 index, |
|
150 *(iCodepage00Table->StringTable( |
|
151 CDictionaryCodePage::EStringTypeAttribute ) ) ); |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CDrmRel2_1StringDict00::AttributeValuePairL |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 void CDrmRel2_1StringDict00::AttributeValuePairL( |
|
159 TInt aToken, |
|
160 RString& aAttribute, |
|
161 RString& aValue) const |
|
162 { |
|
163 AttributeL( aToken, aAttribute ); |
|
164 AttributeValueL( aToken, aValue ); |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CDrmRel2_1StringDict00::AttributeValueL |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 void CDrmRel2_1StringDict00::AttributeValueL( |
|
172 TInt aToken, |
|
173 RString& aValue ) const |
|
174 { |
|
175 |
|
176 TInt index( iCodepage00Table->StringPoolIndexFromToken( |
|
177 aToken, CDictionaryCodePage::EStringTypeAttributeValue ) ); |
|
178 |
|
179 if ( index == KErrXmlStringPoolTableNotFound ) |
|
180 { |
|
181 User::Leave( KErrXmlUnsupportedAttributeValue ); |
|
182 } |
|
183 |
|
184 aValue = iStringPool.String( |
|
185 index, |
|
186 *(iCodepage00Table->StringTable( |
|
187 CDictionaryCodePage::EStringTypeAttributeValue ) ) ); |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // CDrmRel2_1StringDict00::CompareThisDictionary |
|
192 // ----------------------------------------------------------------------------- |
|
193 // |
|
194 TBool CDrmRel2_1StringDict00::CompareThisDictionary( |
|
195 const RString& aDictionaryDescription ) const |
|
196 { |
|
197 // If this string dictionary has many codepages then all these comparisons |
|
198 // should go here.Remember, the string dictionary loads up all the |
|
199 // RStringTables into its RStringPool on construction. So if the comparison |
|
200 // fails we do not have it. |
|
201 return ( ( aDictionaryDescription == |
|
202 iStringPool.String( |
|
203 DrmRel2_1StringDict00TagTable::EUri, |
|
204 DrmRel2_1StringDict00TagTable::Table ) ) || |
|
205 |
|
206 ( aDictionaryDescription == |
|
207 iStringPool.String( |
|
208 DrmRel2_1StringDict00TagTable::EPublicId, |
|
209 DrmRel2_1StringDict00TagTable::Table ) ) || |
|
210 |
|
211 ( aDictionaryDescription == |
|
212 iStringPool.String( |
|
213 DrmRel2_1StringDict00TagTable::EFormalPublicId, |
|
214 DrmRel2_1StringDict00TagTable::Table ) ) ); |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CDrmRel2_1StringDict00::SwitchCodePage |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 TInt CDrmRel2_1StringDict00::SwitchCodePage(TInt aCodePage) |
|
222 { |
|
223 // We only have one codepage so can't switch |
|
224 if ( aCodePage != iCodePage ) |
|
225 { |
|
226 return KErrXmlMissingStringDictionary; |
|
227 } |
|
228 return iCodePage; |
|
229 } |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // CDrmRel2_1StringDict00::PublicIdentifier |
|
233 // This method obtains the public identifier from the StringTable. |
|
234 // Either the formal or non formal public id will do. |
|
235 // The stringDictionary .rss files must list both these as Wbxml |
|
236 // documents have one or the other. |
|
237 // |
|
238 // @param aPubId The public identifier for this string dictionary. |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 void CDrmRel2_1StringDict00::PublicIdentifier( RString& aPubId ) |
|
242 { |
|
243 aPubId = iStringPool.String( |
|
244 DrmRel2_1StringDict00TagTable::EFormalPublicId, |
|
245 *( iCodepage00Table->StringTable( |
|
246 CDictionaryCodePage::EStringTypeElement ) ) ); |
|
247 } |
|
248 |
|
249 // ----------------------------------------------------------------------------- |
|
250 // CDrmRel2_1StringDict00::NamespaceUri |
|
251 // The element types in the Device Information DTD are defined within |
|
252 // a namespace associated with the Uri/Urn available from the StringTable. |
|
253 // The RString need not be closed, but closing is harmless. |
|
254 // |
|
255 // @param aUri The associated namespace for this string dictionary. |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 void CDrmRel2_1StringDict00::NamespaceUri( RString& aUri ) |
|
259 { |
|
260 aUri = iStringPool.String( |
|
261 DrmRel2_1StringDict00TagTable::EUri, |
|
262 *( iCodepage00Table->StringTable( |
|
263 CDictionaryCodePage::EStringTypeElement ) ) ); |
|
264 } |
|
265 |
|
266 // Exported proxy for instantiation method resolution |
|
267 // Define the interface UIDs |
|
268 const TImplementationProxy ImplementationTable[] = { |
|
269 IMPLEMENTATION_PROXY_ENTRY( 0x2000B490, |
|
270 CDrmRel2_1StringDict00::NewL ) }; |
|
271 |
|
272 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( |
|
273 TInt& aTableCount ) |
|
274 { |
|
275 aTableCount = sizeof( ImplementationTable ) / |
|
276 sizeof( TImplementationProxy ); |
|
277 |
|
278 return ImplementationTable; |
|
279 } |