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