|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32std.h> |
|
17 #include <ecom/implementationproxy.h> |
|
18 #include <xml/xmlframeworkerrors.h> |
|
19 |
|
20 #include <xml/plugins/dictionarycodepage.h> |
|
21 #include "DRMStringDict00.h" |
|
22 #include "drmstringdict00tagtable.h" |
|
23 #include "drmstringdict00attributetable.h" |
|
24 #include "drmstringdict00attributevaluetable.h" |
|
25 |
|
26 using namespace Xml; |
|
27 |
|
28 MStringDictionary* DRMStringDict00::NewL(TAny* aStringPool) |
|
29 { |
|
30 DRMStringDict00* self = new(ELeave) DRMStringDict00(reinterpret_cast<RStringPool*>(aStringPool)); |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(); |
|
33 CleanupStack::Pop(self); |
|
34 return (static_cast<MStringDictionary*>(self)); |
|
35 } |
|
36 |
|
37 DRMStringDict00::DRMStringDict00(RStringPool* aStringPool): iStringPool(*aStringPool) |
|
38 { |
|
39 // do nothing; |
|
40 } |
|
41 |
|
42 void DRMStringDict00::ConstructL() |
|
43 { |
|
44 // we don't own this stringpool |
|
45 iStringPool.OpenL(DRMStringDict00TagTable::Table); |
|
46 iStringPool.OpenL(DRMStringDict00AttributeTable::Table); |
|
47 iStringPool.OpenL(DRMStringDict00AttributeValueTable::Table); |
|
48 |
|
49 iCodepage00Table = CDictionaryCodePage::NewL( |
|
50 &DRMStringDict00TagTable::Table, |
|
51 &DRMStringDict00AttributeTable::Table, |
|
52 &DRMStringDict00AttributeValueTable::Table, |
|
53 0); // codepage |
|
54 |
|
55 // Construct the correlation mapping |
|
56 iCodepage00Table->ConstructIndexMappingL(iTagCodePage00, CDictionaryCodePage::EStringTypeElement); |
|
57 iCodepage00Table->ConstructIndexMappingL(iAttributeCodePage00, CDictionaryCodePage::EStringTypeAttribute); |
|
58 iCodepage00Table->ConstructIndexMappingL(iAttributeValueCodePage00, CDictionaryCodePage::EStringTypeAttributeValue); |
|
59 } |
|
60 |
|
61 void DRMStringDict00::Release() |
|
62 { |
|
63 delete (this); |
|
64 } |
|
65 |
|
66 DRMStringDict00::~DRMStringDict00() |
|
67 { |
|
68 delete iCodepage00Table; |
|
69 } |
|
70 |
|
71 void DRMStringDict00::ElementL(TInt aToken, RString& aElement) const |
|
72 { |
|
73 TInt index = iCodepage00Table->StringPoolIndexFromToken(aToken, CDictionaryCodePage::EStringTypeElement); |
|
74 |
|
75 if (index == KErrXmlStringPoolTableNotFound) |
|
76 { |
|
77 User::Leave(KErrXmlUnsupportedElement); |
|
78 } |
|
79 |
|
80 // when we have multiple codepages per string dictionary we'd do something like iCodepageTable[n]->StringTable() |
|
81 aElement = iStringPool.String( |
|
82 index, |
|
83 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement))); |
|
84 } |
|
85 |
|
86 void DRMStringDict00::AttributeL(TInt aToken, RString& aAttribute) const |
|
87 { |
|
88 TInt index = iCodepage00Table->StringPoolIndexFromToken(aToken, CDictionaryCodePage::EStringTypeAttribute); |
|
89 |
|
90 if (index == KErrXmlStringPoolTableNotFound) |
|
91 { |
|
92 User::Leave(KErrXmlUnsupportedAttribute); |
|
93 } |
|
94 |
|
95 // when we have multiple codepages per string dictionary we'd do something like iCodepageTable[n]->StringTable() |
|
96 aAttribute = iStringPool.String( |
|
97 index, |
|
98 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeAttribute))); |
|
99 } |
|
100 |
|
101 void DRMStringDict00::AttributeValuePairL(TInt aToken, RString& aAttribute, RString& aValue) const |
|
102 { |
|
103 AttributeL(aToken, aAttribute); |
|
104 AttributeValueL(aToken, aValue); |
|
105 } |
|
106 |
|
107 void DRMStringDict00::AttributeValueL(TInt aToken, RString& aValue) const |
|
108 { |
|
109 //We dont have any optional attribute. So check only for actual attributes. |
|
110 if(aToken>128) |
|
111 { |
|
112 TInt index = iCodepage00Table->StringPoolIndexFromToken(aToken, CDictionaryCodePage::EStringTypeAttributeValue); |
|
113 if (index == KErrXmlStringPoolTableNotFound) |
|
114 { |
|
115 User::Leave(KErrXmlUnsupportedAttributeValue); |
|
116 } |
|
117 // when we have multiple codepages per string dictionary we'd do something like iCodepageTable[n]->StringTable() |
|
118 aValue = iStringPool.String(index, |
|
119 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeAttributeValue))); |
|
120 } |
|
121 } |
|
122 |
|
123 TBool DRMStringDict00::CompareThisDictionary(const RString& aDictionaryDescription) const |
|
124 { |
|
125 // If this string dictionary has many codepages then all these comparisons should go here. |
|
126 // Remember, the string dictionary loads up all the RStringTables into its RStringPool |
|
127 // on construction. So if the comparison fails we do not have it. |
|
128 return ( |
|
129 (aDictionaryDescription == iStringPool.String(DRMStringDict00TagTable::EUri, DRMStringDict00TagTable::Table)) || |
|
130 (aDictionaryDescription == iStringPool.String(DRMStringDict00TagTable::EPublicId, DRMStringDict00TagTable::Table))|| |
|
131 (aDictionaryDescription == iStringPool.String(DRMStringDict00TagTable::EFormalPublicId, DRMStringDict00TagTable::Table))); |
|
132 } |
|
133 |
|
134 TInt DRMStringDict00::SwitchCodePage(TInt aCodePage) |
|
135 { |
|
136 // We only have one codepage. can't switch |
|
137 if (aCodePage != iCodePage) |
|
138 { |
|
139 return KErrXmlMissingStringDictionary; |
|
140 } |
|
141 return iCodePage; |
|
142 } |
|
143 |
|
144 /** |
|
145 This method obtains the public identifier from the StringTable. |
|
146 Either the formal or non formal public id will do. |
|
147 The stringDictionary .rss files must list both these as wbxml |
|
148 documents have one or the other. |
|
149 |
|
150 @param aPubId The public identifier for this string |
|
151 dictionary. |
|
152 */ |
|
153 |
|
154 void DRMStringDict00::PublicIdentifier(RString& aPubId) |
|
155 { |
|
156 aPubId = iStringPool.String( |
|
157 DRMStringDict00TagTable::EFormalPublicId, |
|
158 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement))); |
|
159 } |
|
160 |
|
161 /** |
|
162 The element types in the Device Information DTD are defined within |
|
163 a namespace associated with the Uri/Urn available from the StringTable. |
|
164 The RString need not be closed, but closing is harmless. |
|
165 |
|
166 @param aUri The associated namespace for this string |
|
167 dictionary. |
|
168 */ |
|
169 |
|
170 void DRMStringDict00::NamespaceUri(RString& aUri) |
|
171 { |
|
172 aUri = iStringPool.String( |
|
173 DRMStringDict00TagTable::EUri, |
|
174 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement))); |
|
175 } |
|
176 |
|
177 const TInt KUidSLStringDictPlugin = 0x10282764; |
|
178 |
|
179 // __________________________________________________________________________ |
|
180 // Exported proxy for instantiation method resolution |
|
181 // Define the interface UIDs |
|
182 const TImplementationProxy ImplementationTable[] = { |
|
183 IMPLEMENTATION_PROXY_ENTRY(KUidSLStringDictPlugin, DRMStringDict00::NewL) |
|
184 }; |
|
185 |
|
186 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
187 { |
|
188 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
189 |
|
190 return ImplementationTable; |
|
191 } |
|
192 |
|
193 #ifndef EKA2 |
|
194 /** DLL Entry point */ |
|
195 GLDEF_C TInt E32Dll(TDllReason /*aReason*/) |
|
196 { |
|
197 return(KErrNone); |
|
198 } |
|
199 #endif |