|
1 /* |
|
2 * Copyright (c) 2006 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: CNcdEntityRefParser implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncd_parser_pp_dataentitycontent.h" |
|
20 #include "ncd_parser_pp_entitydependency.h" |
|
21 #include "ncd_pp_dataentitycontent.h" |
|
22 #include "ncd_pp_dataentitycontentimpl.h" |
|
23 #include "ncd_pp_entitydependency.h" |
|
24 #include "ncd_pp_entitydependencyimpl.h" |
|
25 #include "ncdparserobserverbundleimpl.h" |
|
26 #include "ncdunknownparser.h" |
|
27 #include "ncdprotocolwords.h" |
|
28 #include "ncdprotocolutils.h" |
|
29 #include "ncdprotocoltypes.h" |
|
30 |
|
31 #include "catalogsdebug.h" |
|
32 |
|
33 |
|
34 CNcdPreminetProtocolDataEntityContentParser* |
|
35 CNcdPreminetProtocolDataEntityContentParser::NewL( |
|
36 MNcdParserObserverBundle& aObservers, |
|
37 MNcdSubParserObserver& aSubParserObserver, |
|
38 TInt aDepth, |
|
39 const Xml::RTagInfo& aElement, |
|
40 const Xml::RAttributeArray& aAttributes, |
|
41 const TDesC& aNamespace ) |
|
42 { |
|
43 CNcdPreminetProtocolDataEntityContentParser* self |
|
44 = new(ELeave) CNcdPreminetProtocolDataEntityContentParser( |
|
45 aObservers, aSubParserObserver, aDepth ); |
|
46 CleanupStack::PushL( self ); |
|
47 self->ConstructL( aElement, aAttributes, aNamespace ); |
|
48 CleanupStack::Pop( self ); |
|
49 return self; |
|
50 } |
|
51 |
|
52 CNcdPreminetProtocolDataEntityContentParser::CNcdPreminetProtocolDataEntityContentParser( |
|
53 MNcdParserObserverBundle& aObservers, |
|
54 MNcdSubParserObserver& aSubParserObserver, |
|
55 TInt aDepth ) |
|
56 : CNcdSubParser( aObservers, aSubParserObserver, aDepth ) |
|
57 { |
|
58 |
|
59 } |
|
60 |
|
61 CNcdPreminetProtocolDataEntityContentParser::~CNcdPreminetProtocolDataEntityContentParser() |
|
62 { |
|
63 delete iContent; |
|
64 } |
|
65 |
|
66 void CNcdPreminetProtocolDataEntityContentParser::ConstructL( |
|
67 const Xml::RTagInfo& aElement, |
|
68 const Xml::RAttributeArray& aAttributes, |
|
69 const TDesC& /*aNamespace*/ ) |
|
70 { |
|
71 CNcdSubParser::ConstructL( aElement ); |
|
72 |
|
73 DLTRACEIN(("depth=%d tag=%S",iDepth,iTag)); |
|
74 |
|
75 if (!iContent) |
|
76 { |
|
77 iContent = CNcdPreminetProtocolDataEntityContentImpl::NewL(); |
|
78 } |
|
79 |
|
80 // read attributes here |
|
81 TPtrC8 timestamp = AttributeValue( KAttrTimestamp, aAttributes ); |
|
82 TPtrC8 size = AttributeValue( KAttrSize, aAttributes ); |
|
83 TPtrC8 mime = AttributeValue( KAttrMime, aAttributes ); |
|
84 TPtrC8 id = AttributeValue( KAttrId, aAttributes ); |
|
85 TPtrC8 version = AttributeValue( KAttrVersion, aAttributes ); |
|
86 |
|
87 NcdProtocolUtils::AssignDesL(iContent->iTimestamp, timestamp); |
|
88 if( size != KNullDesC8 ) |
|
89 { |
|
90 iContent->iSize = NcdProtocolUtils::DesDecToIntL(size); |
|
91 } |
|
92 NcdProtocolUtils::AssignDesL(iContent->iMime, mime); |
|
93 NcdProtocolUtils::AssignDesL(iContent->iId, id); |
|
94 NcdProtocolUtils::AssignDesL(iContent->iVersion, version); |
|
95 |
|
96 // attribute set only in subscribableContent |
|
97 TPtrC8 type = AttributeValue( KAttrType, aAttributes ); |
|
98 if ( type == KValuePeriodic ) |
|
99 iContent->iSubscriptionType = EPeriodic; |
|
100 else if ( type == KValueAutomaticContinous ) |
|
101 iContent->iSubscriptionType = EAutomaticContinous; |
|
102 else |
|
103 iContent->iSubscriptionType = ENotSubscribable; |
|
104 } |
|
105 |
|
106 |
|
107 void CNcdPreminetProtocolDataEntityContentParser::OnStartElementL( |
|
108 const Xml::RTagInfo& aElement, |
|
109 const Xml::RAttributeArray& aAttributes, |
|
110 TInt aErrorCode) |
|
111 { |
|
112 CNcdSubParser::OnStartElementL(aElement, aAttributes, aErrorCode); |
|
113 |
|
114 TPtrC8 tag( aElement.LocalName().DesC() ); |
|
115 |
|
116 if( iSubParser == 0 ) |
|
117 { |
|
118 DLTRACEIN(("dataEntity start tag=%S error=%d depth=%d", |
|
119 &aElement.LocalName().DesC(),aErrorCode,iDepth)); |
|
120 |
|
121 if( tag == KTagName || tag == KTagDescription ) |
|
122 { |
|
123 // handled in OnContentL and OnEndElementL |
|
124 } |
|
125 else if( tag == KTagContentPurposes || tag == KTagDependencies ) |
|
126 { |
|
127 // skipped |
|
128 } |
|
129 else if( tag == KTagContentPurpose ) |
|
130 { |
|
131 // read in OnContentL and OnEndElementL |
|
132 } |
|
133 else if( tag == KTagPreview || tag == KTagReview ) |
|
134 { |
|
135 // ignored for now |
|
136 } |
|
137 else if( tag == KTagValidUntil ) |
|
138 { |
|
139 TPtrC8 delta = AttributeValue( KAttrDelta, aAttributes ); |
|
140 iContent->iValidUntilDelta = NcdProtocolUtils::DesDecToIntL(delta); |
|
141 |
|
142 TPtrC8 autoUpdate = AttributeValue( KAttrAutoUpdate, aAttributes ); |
|
143 NcdProtocolUtils::DesToBool(iContent->iValidUntilAutoUpdate, autoUpdate); |
|
144 } |
|
145 else if( tag == KTagDependency ) |
|
146 { |
|
147 iSubParser = CNcdPreminetProtocolEntityDependencyParser::NewL( |
|
148 *iObservers, *this, iDepth+1, aElement, aAttributes, |
|
149 KNullDesC /*no parent id*/ ); |
|
150 } |
|
151 else if( tag == KTagChildAccessibility ) |
|
152 { |
|
153 TPtrC8 viewable = AttributeValue( KAttrViewable, aAttributes ); |
|
154 NcdProtocolUtils::DesToBool(iContent->iChildViewable, viewable); |
|
155 |
|
156 TPtrC8 separatelyPurchasable = AttributeValue( KAttrViewable, aAttributes ); |
|
157 NcdProtocolUtils::DesToBool(iContent->iChildSeparatelyPurchasable, separatelyPurchasable); |
|
158 } |
|
159 else |
|
160 { |
|
161 iSubParser = CNcdUnknownParser::NewL( |
|
162 *iObservers, *this, iDepth+1, aElement, aAttributes ); |
|
163 } |
|
164 } |
|
165 else |
|
166 { |
|
167 iSubParser->OnStartElementL( aElement, aAttributes, aErrorCode ); |
|
168 } |
|
169 } |
|
170 |
|
171 |
|
172 |
|
173 void CNcdPreminetProtocolDataEntityContentParser::OnEndElementL( |
|
174 const Xml::RTagInfo& aElement, TInt aErrorCode) |
|
175 { |
|
176 |
|
177 TPtrC8 tag( aElement.LocalName().DesC() ); |
|
178 DLTRACEIN(("%X end iTag=%S tag=%S", this, iTag, &tag)); |
|
179 |
|
180 if ( iBuffer ) |
|
181 { |
|
182 if ( tag == KTagContentPurpose ) |
|
183 { |
|
184 HBufC* purpose = 0; |
|
185 NcdProtocolUtils::AssignDesL(purpose, *iBuffer); |
|
186 iContent->iContentPurposes.Append(purpose); |
|
187 DLINFO((_L("contentPurpose=%S"),purpose)); |
|
188 } |
|
189 delete iBuffer; |
|
190 iBuffer = 0; |
|
191 } |
|
192 |
|
193 if ( iSubParser == 0 && iTag && *iTag == aElement.LocalName().DesC() ) |
|
194 { |
|
195 // dataEntity end |
|
196 DLTRACE(("end tag=%S",&aElement.LocalName().DesC())); |
|
197 iSubParserObserver->SubParserFinishedL( |
|
198 aElement.LocalName().DesC(), aErrorCode ); |
|
199 } |
|
200 else if( iSubParser ) |
|
201 { |
|
202 iSubParser->OnEndElementL( aElement, aErrorCode ); |
|
203 } |
|
204 else |
|
205 { |
|
206 DLWARNING(("end tag ignored, tag=%S",&aElement.LocalName().DesC())); |
|
207 } |
|
208 } |
|
209 void CNcdPreminetProtocolDataEntityContentParser::SubParserFinishedL( |
|
210 const TDesC8& aTag, TInt /*aErrorCode*/ ) |
|
211 { |
|
212 DLTRACEIN(("tag=%S subparser=%X",&aTag,iSubParser)); |
|
213 (void) aTag; // suppresses compiler warning |
|
214 |
|
215 if( iSubParser->Tag() == KTagDependency ) |
|
216 { |
|
217 MNcdPreminetProtocolEntityDependency* dep = |
|
218 static_cast<CNcdPreminetProtocolEntityDependencyParser*> |
|
219 ( iSubParser )->Dependency(); |
|
220 DLINFO(("subparser entityDependency=%X",dep)); |
|
221 if( dep && iContent ) |
|
222 { |
|
223 iContent->iEntityDependencies.AppendL(dep); |
|
224 } |
|
225 } |
|
226 else |
|
227 { |
|
228 DLWARNING(("Child entity %S ignored", &aTag)); |
|
229 } |
|
230 |
|
231 delete iSubParser; |
|
232 iSubParser = 0; |
|
233 } |
|
234 |
|
235 MNcdPreminetProtocolDataEntityContent* |
|
236 CNcdPreminetProtocolDataEntityContentParser::Content() |
|
237 { |
|
238 DLTRACEIN(("%X",iContent)); |
|
239 MNcdPreminetProtocolDataEntityContent* content= iContent; |
|
240 iContent = 0; |
|
241 return content; |
|
242 } |