|
1 /* |
|
2 * Copyright (c) 2002 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 the License "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 * Implementation of class TDdParser. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include "DdParser.h" |
|
24 #include "CodData.h" |
|
25 #include "CodError.h" |
|
26 #include "CodPanic.h" |
|
27 #include "CodLogger.h" |
|
28 #include "NwUtil.h" |
|
29 #include "DdDummyDict.h" |
|
30 #include "HttpDownloadData.h" |
|
31 #include <nw_dom_document.h> |
|
32 #include <utf.h> |
|
33 |
|
34 // ================= CONSTANTS ======================= |
|
35 |
|
36 // Attribute names. |
|
37 _LIT( KDdName, "name" ); ///< name. |
|
38 _LIT( KDdVendor, "vendor" ); ///< vendor. |
|
39 _LIT( KDdDescription, "description" ); ///< description. |
|
40 _LIT( KDdUrl, "objectURI" ); ///< objectURI. |
|
41 _LIT( KDdSize, "size" ); ///< size. |
|
42 _LIT( KDdType, "type" ); ///< type. |
|
43 _LIT( KDdInstallNotify, "installNotifyURI" ); ///< installNotifyURI. |
|
44 _LIT( KDdNextUrl, "nextURL" ); ///< nextURL. |
|
45 _LIT( KDdInfoUrl, "infoURL" ); ///< infoURL. |
|
46 _LIT( KDdIcon, "iconURI" ); ///< iconURI. |
|
47 _LIT( KDdVersion, "DDVersion" ); ///< DDVersion. |
|
48 _LIT( KDdMedia, "media" ); ///< media. |
|
49 // Attribute names for OMA v2 |
|
50 _LIT( KDdProduct, "product" ); ///< media. |
|
51 _LIT( KDdMediaObject, "mediaObject" ); ///< mediaObject. |
|
52 _LIT( KDdMeta, "meta" ); ///< meta. |
|
53 _LIT( KDdProgressiveDl, "progressiveDownloadFlag" ); ///< progressiveDownloadFlag. |
|
54 _LIT( KDdLicense, "license" ); ///< license. |
|
55 _LIT( KDdOrder, "order" ); ///< order. |
|
56 _LIT( KDdSuppressUserConfirmation, "suppressUserConfirmation" ); ///< suppressUserConfirmation. |
|
57 _LIT( KDdServer, "server" ); ///< server. |
|
58 _LIT( KDdText, "text" ); ///< text. |
|
59 _LIT( KDdTrue, "true" ); ///< true. |
|
60 _LIT( KDdFalse, "false" ); ///< false. |
|
61 _LIT( KDdAlways, "Always" ); ///< Always. |
|
62 _LIT( KDdUserConfirmStepOnly, "UserConfirmaStepOnly" ); ///< UserConfirmStepOnly. |
|
63 _LIT( KDdNever, "Never" ); ///< Never. |
|
64 _LIT( KDdPost, "post" ); ///< post. |
|
65 _LIT( KDdAny, "any" ); ///< any. |
|
66 _LIT( KDdUpdatedDDURI, "updatedDDURI" );//updatedDDURI |
|
67 |
|
68 |
|
69 #define INDENT_SPACE 2 |
|
70 |
|
71 // ================= MEMBER FUNCTIONS ======================= |
|
72 |
|
73 // --------------------------------------------------------- |
|
74 // TDdParser::ParseL() |
|
75 // --------------------------------------------------------- |
|
76 // |
|
77 void TDdParser::ParseL( const TDesC& aBuf, CCodData& aData, const TBool aIsDd2, TBool& aIsLicenseTag ) |
|
78 { |
|
79 CLOG(( EParse, 2, _L("-> TDdParser::ParseL") )); |
|
80 CDUMP(( EParse, 2, _S("Buf:"), _S(" "), \ |
|
81 (const TUint8*)aBuf.Ptr(), aBuf.Size() )); |
|
82 iError = KErrNone; |
|
83 iData = &aData; |
|
84 // XML Parser expects the buffer contain a BOM and be in |
|
85 // network byte order (this is hard-coded into cXmlParser). |
|
86 // We already have the buffer converted to UCS-2, native byte order, BOM |
|
87 // removed, and this cannot be changed without changing API. |
|
88 // So we have to re-add BOM and convert the buffer back to network byte |
|
89 // order. This is an annoying a waste, luckily a DD file is small |
|
90 // enough not to be significant. |
|
91 HBufC* buf = HBufC::NewLC( aBuf.Length() + 1 ); |
|
92 buf->Des().Append( 0xFFFE ); // Add BOM, little endian as aBuf. |
|
93 buf->Des().Append( aBuf ); // Append buffer. |
|
94 // Now turn the whole buffer big-endian. |
|
95 TUint8* ptr = (TUint8*)buf->Ptr(); |
|
96 for ( TInt i = 0; i < buf->Size(); i += 2 ) |
|
97 { |
|
98 TUint8 tmp = ptr[i]; |
|
99 ptr[i] = ptr[i + 1]; |
|
100 ptr[i + 1] = tmp; |
|
101 } |
|
102 NW_WBXML_Dictionary_t* dictArray[ 1 ] = |
|
103 { (NW_WBXML_Dictionary_t*)&NW_DdDummy_WBXMLDictionary }; |
|
104 RNwWbxmlDictionary wbxmlDict; |
|
105 User::LeaveIfError( wbxmlDict.Initialize( 1, dictArray ) ); |
|
106 CleanupClosePushL<RNwWbxmlDictionary>( wbxmlDict ); |
|
107 |
|
108 NW_TinyDom_Handle_t domHandle; |
|
109 NW_Status_t stat; |
|
110 CNwDomDocumentNode* docNode = new (ELeave) CNwDomDocumentNode(); |
|
111 CleanupStack::PushL( docNode ); |
|
112 docNode->iDocNode = CXML_DOM_DocumentNode_BuildTree |
|
113 ( |
|
114 &domHandle, |
|
115 (NW_Byte*)buf->Ptr(), |
|
116 (NW_Int32)buf->Size(), |
|
117 /*encoded=*/NW_FALSE, |
|
118 /*publicID=*/NW_DdDummy_PublicId, |
|
119 /*extTNotStringTable=*/NW_FALSE, |
|
120 &stat |
|
121 ); |
|
122 LeaveIfNwErrorL( stat ); |
|
123 User::LeaveIfNull( docNode->iDocNode ); // Safety code. |
|
124 if (!aIsDd2) |
|
125 { |
|
126 DocNodeL( docNode->iDocNode ); |
|
127 } |
|
128 else |
|
129 { |
|
130 iIsLicenseTag = EFalse; |
|
131 ParseDd2DocNodeL( docNode->iDocNode ); |
|
132 } |
|
133 CleanupStack::PopAndDestroy( 3, buf ); // docNode, close wbxmlDict, buf |
|
134 |
|
135 #ifdef __TEST_COD_LOG |
|
136 TPtrC ptr16; |
|
137 TPtrC8 ptr8; |
|
138 CLOG(( EParse, 3, _L("TCodParser::ParseL data:") )); |
|
139 ptr16.Set( aData.Name() ); |
|
140 CLOG(( EParse, 3, _L(" Name<%S>"), &ptr16 )); |
|
141 ptr16.Set( aData.Vendor() ); |
|
142 CLOG(( EParse, 3, _L(" Vendor<%S>"), &ptr16 )); |
|
143 ptr16.Set( aData.Description() ); |
|
144 CLOG(( EParse, 3, _L(" Desc<%S>"), &ptr16 )); |
|
145 CLOG(( EParse, 3, _L(" Size(%d)"), aData.Size() )); |
|
146 ptr8.Set( aData.InstallNotify() ); |
|
147 CLOG(( EParse, 3, _L8(" InstNotif<%S>"), &ptr8 )); |
|
148 ptr8.Set( aData.NextUrl() ); |
|
149 CLOG(( EParse, 3, _L8(" NextUrl<%S>"), &ptr8 )); |
|
150 ptr8.Set( aData.NextUrlAtError() ); |
|
151 CLOG(( EParse, 3, _L8(" NextUrlAtErr<%S>"), &ptr8 )); |
|
152 ptr8.Set( aData.InfoUrl() ); |
|
153 CLOG(( EParse, 3, _L8(" InfoUrl<%S>"), &ptr8 )); |
|
154 ptr16.Set( aData.Price() ); |
|
155 CLOG(( EParse, 3, _L(" Price<%S>"), &ptr16 )); |
|
156 ptr8.Set( aData.Icon() ); |
|
157 CLOG(( EParse, 3, _L8(" Icon<%S>"), &ptr8 )); |
|
158 |
|
159 //TODO add logs for OMA 2 |
|
160 #endif /* def __TEST_COD_LOG */ |
|
161 |
|
162 //If there are no media objects present to download, |
|
163 if( !iData->Count() ) |
|
164 { |
|
165 User::Leave( KErrCodInvalidDescriptor ); |
|
166 } |
|
167 |
|
168 // NULL data for clarity. These are never used later, but don't keep |
|
169 // pointers to objects which are out of reach. |
|
170 iData = NULL; |
|
171 User::LeaveIfError( iError ); |
|
172 aIsLicenseTag = iIsLicenseTag; |
|
173 CLOG(( EParse, 2, _L("<- TDdParser::ParseL") )); |
|
174 } |
|
175 |
|
176 // --------------------------------------------------------- |
|
177 // TDdParser::DocNodeL() |
|
178 // --------------------------------------------------------- |
|
179 // |
|
180 void TDdParser::DocNodeL( NW_DOM_DocumentNode_t* aDocNode ) |
|
181 { |
|
182 CLOG(( EParse, 2, _L("-> TDdParser::DocNodeL") )); |
|
183 __ASSERT_DEBUG( aDocNode, CodPanic( ECodInternal ) ); |
|
184 // Validity checking of root element (media). |
|
185 NW_DOM_ElementNode_t* elmt = |
|
186 NW_DOM_DocumentNode_getDocumentElement( aDocNode ); |
|
187 if ( !elmt || NW_DOM_Node_getNodeType( elmt ) != NW_DOM_ELEMENT_NODE ) |
|
188 { |
|
189 User::Leave( KErrCodInvalidDescriptor ); |
|
190 } |
|
191 NW_String_t str; |
|
192 LeaveIfNwErrorL( NW_DOM_Node_getNodeName( elmt, &str ) ); |
|
193 CleanupNwStringStoragePushL( &str ); |
|
194 iEncoding = NW_DOM_DocumentNode_getCharacterEncoding( aDocNode ); |
|
195 NW_Ucs2* name; |
|
196 LeaveIfNwErrorL( NW_String_stringToUCS2Char( &str, iEncoding, &name ) ); |
|
197 CleanupNwUcs2PushL( name ); |
|
198 if ( TPtrC( name ).Compare( KDdMedia() ) ) |
|
199 { |
|
200 User::Leave( KErrCodInvalidDescriptor ); |
|
201 } |
|
202 CleanupStack::PopAndDestroy( 2 ); // clean up name, str->storage |
|
203 |
|
204 // Process child element nodes. |
|
205 NW_DOM_Node_t* node = NW_DOM_Node_getFirstChild( elmt ); |
|
206 CMediaObjectData *mediaObject = CMediaObjectData::NewL(); |
|
207 while ( node ) |
|
208 { |
|
209 if ( NW_DOM_Node_getNodeType( node ) == NW_DOM_ELEMENT_NODE ) |
|
210 { |
|
211 ElementNodeL( STATIC_CAST( NW_DOM_ElementNode_t*, node ), mediaObject ); |
|
212 } |
|
213 node = NW_DOM_Node_getNextSibling( node ); |
|
214 } |
|
215 iData->AppendMediaObjectL( mediaObject ); |
|
216 CLOG(( EParse, 2, _L("<- TDdParser::DocNodeL") )); |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------- |
|
220 // TDdParser::ParseDd2DocNodeL() |
|
221 // --------------------------------------------------------- |
|
222 // |
|
223 void TDdParser::ParseDd2DocNodeL( NW_DOM_DocumentNode_t* aDocNode ) |
|
224 { |
|
225 CLOG(( EParse, 2, _L("-> TDdParser::ParseDd2DocNodeL") )); |
|
226 __ASSERT_DEBUG( aDocNode, CodPanic( ECodInternal ) ); |
|
227 // Validity checking of root element (media). |
|
228 NW_DOM_ElementNode_t* elmt = |
|
229 NW_DOM_DocumentNode_getDocumentElement( aDocNode ); |
|
230 if ( !elmt || NW_DOM_Node_getNodeType( elmt ) != NW_DOM_ELEMENT_NODE ) |
|
231 { |
|
232 User::Leave( KErrCodInvalidDescriptor ); |
|
233 } |
|
234 NW_String_t str; |
|
235 LeaveIfNwErrorL( NW_DOM_Node_getNodeName( elmt, &str ) ); |
|
236 CleanupNwStringStoragePushL( &str ); |
|
237 iEncoding = NW_DOM_DocumentNode_getCharacterEncoding( aDocNode ); |
|
238 NW_Ucs2* name; |
|
239 LeaveIfNwErrorL( NW_String_stringToUCS2Char( &str, iEncoding, &name ) ); |
|
240 CleanupNwUcs2PushL( name ); |
|
241 if ( TPtrC( name ).Compare( KDdMedia() ) ) |
|
242 { |
|
243 User::Leave( KErrCodInvalidDescriptor ); |
|
244 } |
|
245 CleanupStack::PopAndDestroy( 2 ); // clean up name, str->storage |
|
246 ParseMediaElementsL( elmt ); |
|
247 CLOG(( EParse, 2, _L("<- TDdParser::ParseDd2DocNodeL") )); |
|
248 } |
|
249 |
|
250 // --------------------------------------------------------- |
|
251 // TDdParser::ParseMediaElementsL() |
|
252 // --------------------------------------------------------- |
|
253 // |
|
254 void TDdParser::ParseMediaElementsL( NW_DOM_ElementNode_t* aElement) |
|
255 { |
|
256 CLOG(( EParse, 2, _L("-> TDdParser::ParseMediaElementsL") )); |
|
257 |
|
258 // Process child elements for Media Object |
|
259 NW_DOM_Node_t* node = NW_DOM_Node_getFirstChild( aElement ); |
|
260 while ( node ) |
|
261 { |
|
262 if ( NW_DOM_Node_getNodeType( node ) == NW_DOM_ELEMENT_NODE ) |
|
263 { |
|
264 MediaElementNodeL( STATIC_CAST( NW_DOM_ElementNode_t*, node ) ); |
|
265 } |
|
266 node = NW_DOM_Node_getNextSibling( node ); |
|
267 } |
|
268 |
|
269 // Get Attributs for this node |
|
270 NW_Status_t stat = NW_STAT_SUCCESS; |
|
271 |
|
272 if ( NW_DOM_ElementNode_hasAttributes( aElement ) ) |
|
273 { |
|
274 |
|
275 NW_DOM_AttributeListIterator_t attrIter; |
|
276 stat = NW_DOM_ElementNode_getAttributeListIterator |
|
277 ( aElement, &attrIter ); |
|
278 |
|
279 User::LeaveIfError( NwStatus2Error( stat ) ); |
|
280 NW_DOM_AttributeHandle_t attrHandle; |
|
281 while( NW_DOM_AttributeListIterator_getNextAttribute( &attrIter, &attrHandle ) == NW_STAT_WBXML_ITERATE_MORE ) |
|
282 { |
|
283 ParseNodeAttributesL( &attrHandle ); |
|
284 } |
|
285 } |
|
286 |
|
287 CLOG(( EParse, 2, _L("<- TDdParser::ParseMediaElementsL") )); |
|
288 } |
|
289 |
|
290 // --------------------------------------------------------- |
|
291 // TDdParser::ParseProductElementsL() |
|
292 // --------------------------------------------------------- |
|
293 // |
|
294 void TDdParser::ParseProductElementsL( NW_DOM_ElementNode_t* aElement) |
|
295 { |
|
296 CLOG(( EParse, 2, _L("-> TDdParser::ParseProductElementsL") )); |
|
297 // Process child elements for Product Object |
|
298 NW_DOM_Node_t* node = NW_DOM_Node_getFirstChild( aElement ); |
|
299 while ( node ) |
|
300 { |
|
301 if ( NW_DOM_Node_getNodeType( node ) == NW_DOM_ELEMENT_NODE ) |
|
302 { |
|
303 ProductElementNodeL( STATIC_CAST( NW_DOM_ElementNode_t*, node ) ); |
|
304 } |
|
305 node = NW_DOM_Node_getNextSibling( node ); |
|
306 } |
|
307 CLOG(( EParse, 2, _L("<- TDdParser::ParseProductElementsL") )); |
|
308 } |
|
309 |
|
310 // --------------------------------------------------------- |
|
311 // TDdParser::ParseMediaObjectElementsL() |
|
312 // --------------------------------------------------------- |
|
313 // |
|
314 void TDdParser::ParseMediaObjectElementsL( NW_DOM_ElementNode_t* aElement) |
|
315 { |
|
316 CLOG(( EParse, 2, _L("-> TDdParser::ParseMediaObjectElementsL") )); |
|
317 //Create a media object and append it to Cod Data array |
|
318 CMediaObjectData *mediaObject = CMediaObjectData::NewL(); |
|
319 |
|
320 // Process child elements for MediaObject |
|
321 NW_DOM_Node_t* node = NW_DOM_Node_getFirstChild( aElement ); |
|
322 while ( node ) |
|
323 { |
|
324 if ( NW_DOM_Node_getNodeType( node ) == NW_DOM_ELEMENT_NODE ) |
|
325 { |
|
326 MediaObjElementNodeL( STATIC_CAST( NW_DOM_ElementNode_t*, node), mediaObject ); |
|
327 } |
|
328 node = NW_DOM_Node_getNextSibling( node ); |
|
329 } |
|
330 |
|
331 if(!mediaObject->Name().Compare(KNullDesC) && mediaObject->Url().Compare(KNullDesC8)) |
|
332 { |
|
333 ParseNameFromUrlL( mediaObject ); |
|
334 } |
|
335 iData->AppendMediaObjectL( mediaObject ); |
|
336 |
|
337 CLOG(( EParse, 2, _L("<- TDdParser::ParseMediaObjectElementsL") )); |
|
338 } |
|
339 |
|
340 // --------------------------------------------------------- |
|
341 // TDdParser::ParseMetaElementsL() |
|
342 // --------------------------------------------------------- |
|
343 // |
|
344 void TDdParser::ParseMetaElementsL( NW_DOM_ElementNode_t* aElement) |
|
345 { |
|
346 CLOG(( EParse, 2, _L("-> TDdParser::ParseMetaElementsL") )); |
|
347 // Process child elements foe Media Object |
|
348 NW_DOM_Node_t* node = NW_DOM_Node_getFirstChild( aElement ); |
|
349 while ( node ) |
|
350 { |
|
351 if ( NW_DOM_Node_getNodeType( node ) == NW_DOM_ELEMENT_NODE ) |
|
352 { |
|
353 MetaElementNodeL( STATIC_CAST( NW_DOM_ElementNode_t*, node ) ); |
|
354 } |
|
355 node = NW_DOM_Node_getNextSibling( node ); |
|
356 } |
|
357 CLOG(( EParse, 2, _L("<- TDdParser::ParseMetaElementsL") )); |
|
358 } |
|
359 |
|
360 // --------------------------------------------------------- |
|
361 // TDdParser::ParseMetaElementsL() |
|
362 // --------------------------------------------------------- |
|
363 // |
|
364 void TDdParser::ParseMetaElementsL( NW_DOM_ElementNode_t* aElement, CMediaObjectData *& aMediaObject ) |
|
365 { |
|
366 CLOG(( EParse, 2, _L("-> TDdParser::ParseMetaElementsL") )); |
|
367 // Process child elements foe Media Object |
|
368 NW_DOM_Node_t* node = NW_DOM_Node_getFirstChild( aElement ); |
|
369 while ( node ) |
|
370 { |
|
371 if ( NW_DOM_Node_getNodeType( node ) == NW_DOM_ELEMENT_NODE ) |
|
372 { |
|
373 MetaElementNodeL( STATIC_CAST( NW_DOM_ElementNode_t*, node ), aMediaObject ); |
|
374 } |
|
375 node = NW_DOM_Node_getNextSibling( node ); |
|
376 } |
|
377 CLOG(( EParse, 2, _L("<- TDdParser::ParseMetaElementsL") )); |
|
378 } |
|
379 |
|
380 // --------------------------------------------------------- |
|
381 // TDdParser::ParseObjectUriElementsL() |
|
382 // --------------------------------------------------------- |
|
383 // |
|
384 void TDdParser::ParseObjectUriElementsL( NW_DOM_ElementNode_t* aElement, CMediaObjectData *& aMediaObject ) |
|
385 { |
|
386 CLOG(( EParse, 2, _L("-> TDdParser::ParseObjectUriElementsL") )); |
|
387 // Process child elements for Media Object |
|
388 NW_DOM_Node_t* node = NW_DOM_Node_getFirstChild( aElement ); |
|
389 while ( node ) |
|
390 { |
|
391 if ( NW_DOM_Node_getNodeType( node ) == NW_DOM_ELEMENT_NODE ) |
|
392 { |
|
393 ObjUriElementNodeL( STATIC_CAST( NW_DOM_ElementNode_t*, node ), aMediaObject ); |
|
394 } |
|
395 node = NW_DOM_Node_getNextSibling( node ); |
|
396 } |
|
397 CLOG(( EParse, 2, _L("<- TDdParser::ParseObjectUriElementsL") )); |
|
398 } |
|
399 |
|
400 // --------------------------------------------------------- |
|
401 // TDdParser::MediaElementNodeL() |
|
402 // --------------------------------------------------------- |
|
403 // |
|
404 void TDdParser::MediaElementNodeL( NW_DOM_ElementNode_t* aElmtNode ) |
|
405 { |
|
406 CLOG(( EParse, 2, _L("-> TDdParser::MediaElementNodeL") )); |
|
407 __ASSERT_DEBUG( aElmtNode, CodPanic( ECodInternal ) ); |
|
408 |
|
409 NW_String_t str; |
|
410 LeaveIfNwErrorL( NW_DOM_Node_getNodeName( aElmtNode, &str ) ); |
|
411 CleanupNwStringStoragePushL( &str ); |
|
412 NW_Ucs2* ucs2; |
|
413 LeaveIfNwErrorL( NW_String_stringToUCS2Char( &str, iEncoding, &ucs2 ) ); |
|
414 CleanupNwUcs2PushL( ucs2 ); |
|
415 TPtrC attrName( ucs2 ); |
|
416 TDdAttr attr = MediaAttribute( attrName ); |
|
417 CLOG(( EParse, 4, _L(" attribute <%S> (%d)"), &attrName, attr )); |
|
418 CleanupStack::PopAndDestroy( 2 ); // Clean up ucs2, str->storage |
|
419 if ( attr == EDdProduct ) |
|
420 { |
|
421 if( iData && !iData->Count() ) |
|
422 { |
|
423 ParseProductElementsL(aElmtNode); |
|
424 } |
|
425 return; |
|
426 } |
|
427 if ( attr != EDdUnknownAttr ) // Unknown attribute is ignored. |
|
428 { |
|
429 ucs2 = PcDataLC( aElmtNode ); |
|
430 if ( ucs2 ) |
|
431 { |
|
432 SetMediaAttrL( attr, TPtrC( ucs2 ) ); |
|
433 } |
|
434 CleanupStack::PopAndDestroy(); // Clean up ucs2. |
|
435 } |
|
436 CLOG(( EParse, 2, _L("<- TDdParser::MediaElementNodeL") )); |
|
437 } |
|
438 |
|
439 // --------------------------------------------------------- |
|
440 // TDdParser::ParseNodeAttributesL() |
|
441 // --------------------------------------------------------- |
|
442 // |
|
443 void TDdParser::ParseNodeAttributesL( NW_DOM_AttributeHandle_t* aAttrHandle ) |
|
444 { |
|
445 CLOG(( EParse, 2, _L("-> TDdParser::ParseNodeAttributesL") )); |
|
446 NW_Status_t stat = NW_STAT_SUCCESS; |
|
447 NW_String_t str; |
|
448 // Get the name of the attribute. |
|
449 stat = NW_DOM_AttributeHandle_getName( aAttrHandle, &str ); |
|
450 User::LeaveIfError( NwStatus2Error( stat ) ); |
|
451 |
|
452 CleanupNwStringStoragePushL( &str ); |
|
453 NW_Ucs2* ucs2; |
|
454 LeaveIfNwErrorL( NW_String_stringToUCS2Char( &str, iEncoding, &ucs2 ) ); |
|
455 CleanupNwUcs2PushL( ucs2 ); |
|
456 |
|
457 TPtrC attrName( ucs2 ); |
|
458 TDdAttr attr = DdVersionAttribute( attrName ); |
|
459 CleanupStack::PopAndDestroy( 2 ); // Clean up ucs2, str->storage |
|
460 if ( attr != EDdUnknownAttr ) // Unknown attribute is ignored. |
|
461 { |
|
462 LeaveIfNwErrorL(NW_DOM_AttributeHandle_getValue(aAttrHandle, &str) ); |
|
463 LeaveIfNwErrorL( NW_String_stringToUCS2Char(&str, iEncoding, &ucs2) ); |
|
464 if ( ucs2 ) |
|
465 { |
|
466 if ( (attr == EDdVersion)) |
|
467 { |
|
468 iData->SetVersionL( TPtrC ( ucs2 )); |
|
469 } |
|
470 } |
|
471 } |
|
472 CLOG(( EParse, 2, _L("<- TDdParser::ParseNodeAttributesL") )); |
|
473 } |
|
474 |
|
475 // --------------------------------------------------------- |
|
476 // TDdParser::ObjUriElementNodeL() |
|
477 // --------------------------------------------------------- |
|
478 // |
|
479 void TDdParser::ObjUriElementNodeL( NW_DOM_ElementNode_t* aElmtNode, CMediaObjectData *& aMediaObject ) |
|
480 { |
|
481 CLOG(( EParse, 2, _L("-> TDdParser::ObjUriElementNodeL") )); |
|
482 __ASSERT_DEBUG( aElmtNode, CodPanic( ECodInternal ) ); |
|
483 NW_String_t str; |
|
484 LeaveIfNwErrorL( NW_DOM_Node_getNodeName( aElmtNode, &str ) ); |
|
485 CleanupNwStringStoragePushL( &str ); |
|
486 NW_Ucs2* ucs2; |
|
487 LeaveIfNwErrorL( NW_String_stringToUCS2Char( &str, iEncoding, &ucs2 ) ); |
|
488 CleanupNwUcs2PushL( ucs2 ); |
|
489 |
|
490 TPtrC attrName( ucs2 ); |
|
491 TDdAttr attr = ObjUriAttribute( attrName ); |
|
492 CleanupStack::PopAndDestroy( 2 ); // Clean up ucs2, str->storage |
|
493 TInt ok( EFalse ); |
|
494 if ( attr != EDdUnknownAttr ) // Unknown attribute is ignored. |
|
495 { |
|
496 ucs2 = PcDataLC( aElmtNode ); |
|
497 if ( ucs2 ) |
|
498 { |
|
499 /* composite objects (multiple server elements) are not supported in 3.2 |
|
500 So, it takes last ObjectUri |
|
501 */ |
|
502 if ( (attr == EDdUrl)) |
|
503 { |
|
504 ok = aMediaObject->SetUrlL( TPtrC ( ucs2 )); |
|
505 } |
|
506 } |
|
507 CleanupStack::PopAndDestroy(); // Clean up ucs2. |
|
508 } |
|
509 if ( !ok ) |
|
510 { |
|
511 Error( KErrCodInvalidDescriptor ); |
|
512 } |
|
513 CLOG(( EParse, 2, _L("<- TDdParser::ObjUriElementNodeL") )); |
|
514 } |
|
515 |
|
516 // --------------------------------------------------------- |
|
517 // TDdParser::MediaObjElementNodeL() |
|
518 // --------------------------------------------------------- |
|
519 // |
|
520 void TDdParser::MediaObjElementNodeL( NW_DOM_ElementNode_t* aElmtNode, CMediaObjectData *& aMediaObject ) |
|
521 { |
|
522 CLOG(( EParse, 2, _L("-> TDdParser::MediaObjElementNodeL") )); |
|
523 __ASSERT_DEBUG( aElmtNode, CodPanic( ECodInternal ) ); |
|
524 NW_String_t str; |
|
525 LeaveIfNwErrorL( NW_DOM_Node_getNodeName( aElmtNode, &str ) ); |
|
526 CleanupNwStringStoragePushL( &str ); |
|
527 NW_Ucs2* ucs2; |
|
528 LeaveIfNwErrorL( NW_String_stringToUCS2Char( &str, iEncoding, &ucs2 ) ); |
|
529 CleanupNwUcs2PushL( ucs2 ); |
|
530 TPtrC attrName( ucs2 ); |
|
531 TDdAttr attr = MediaObjAttribute( attrName ); |
|
532 CLOG(( EParse, 4, _L(" attribute <%S> (%d)"), &attrName, attr )); |
|
533 CleanupStack::PopAndDestroy( 2 ); // Clean up ucs2, str->storage |
|
534 if ( attr == EDdMeta ) |
|
535 { |
|
536 ParseMetaElementsL(aElmtNode, aMediaObject ); |
|
537 return; |
|
538 } |
|
539 if ( attr == EDdUrl ) |
|
540 { |
|
541 ParseObjectUriElementsL(aElmtNode, aMediaObject ); |
|
542 return; |
|
543 } |
|
544 if ( attr != EDdUnknownAttr ) // Unknown attribute is ignored. |
|
545 { |
|
546 ucs2 = PcDataLC( aElmtNode ); |
|
547 if ( ucs2 ) |
|
548 { |
|
549 SetMediaObjAttrL( attr, TPtrC( ucs2 ), aMediaObject ); |
|
550 } |
|
551 CleanupStack::PopAndDestroy(); // Clean up ucs2. |
|
552 } |
|
553 CLOG(( EParse, 2, _L("<- TDdParser::MediaObjElementNodeL") )); |
|
554 } |
|
555 |
|
556 // --------------------------------------------------------- |
|
557 // TDdParser::ProductElementNodeL() |
|
558 // --------------------------------------------------------- |
|
559 // |
|
560 void TDdParser::ProductElementNodeL( NW_DOM_ElementNode_t* aElmtNode ) |
|
561 { |
|
562 CLOG(( EParse, 2, _L("-> TDdParser::ProductElementNodeL") )); |
|
563 __ASSERT_DEBUG( aElmtNode, CodPanic( ECodInternal ) ); |
|
564 NW_String_t str; |
|
565 LeaveIfNwErrorL( NW_DOM_Node_getNodeName( aElmtNode, &str ) ); |
|
566 CleanupNwStringStoragePushL( &str ); |
|
567 NW_Ucs2* ucs2; |
|
568 LeaveIfNwErrorL( NW_String_stringToUCS2Char( &str, iEncoding, &ucs2 ) ); |
|
569 CleanupNwUcs2PushL( ucs2 ); |
|
570 TPtrC attrName( ucs2 ); |
|
571 TDdAttr attr = ProductAttribute( attrName ); |
|
572 CLOG(( EParse, 4, _L(" attribute <%S> (%d)"), &attrName, attr )); |
|
573 CleanupStack::PopAndDestroy( 2 ); // Clean up ucs2, str->storage |
|
574 if ( attr == EDdMeta ) |
|
575 { |
|
576 ParseMetaElementsL(aElmtNode); |
|
577 } |
|
578 if ( attr == EDdMediaObject ) |
|
579 { |
|
580 ParseMediaObjectElementsL(aElmtNode); |
|
581 } |
|
582 CLOG(( EParse, 2, _L("<- TDdParser::ProductElementNodeL") )); |
|
583 } |
|
584 |
|
585 // --------------------------------------------------------- |
|
586 // TDdParser::MetaElementNodeL() |
|
587 // --------------------------------------------------------- |
|
588 // |
|
589 void TDdParser::MetaElementNodeL( NW_DOM_ElementNode_t* aElmtNode ) |
|
590 { |
|
591 CLOG(( EParse, 2, _L("-> TDdParser::MetaElementNodeL") )); |
|
592 __ASSERT_DEBUG( aElmtNode, CodPanic( ECodInternal ) ); |
|
593 NW_String_t str; |
|
594 LeaveIfNwErrorL( NW_DOM_Node_getNodeName( aElmtNode, &str ) ); |
|
595 CleanupNwStringStoragePushL( &str ); |
|
596 NW_Ucs2* ucs2; |
|
597 LeaveIfNwErrorL( NW_String_stringToUCS2Char( &str, iEncoding, &ucs2 ) ); |
|
598 CleanupNwUcs2PushL( ucs2 ); |
|
599 TPtrC attrName( ucs2 ); |
|
600 TDdAttr attr = MetaAttribute( attrName ); |
|
601 CLOG(( EParse, 4, _L(" attribute <%S> (%d)"), &attrName, attr )); |
|
602 CleanupStack::PopAndDestroy( 2 ); // Clean up ucs2, str->storage |
|
603 if ( attr == EDdLicense ) |
|
604 { |
|
605 iIsLicenseTag = ETrue; |
|
606 return; |
|
607 } |
|
608 if ( attr != EDdUnknownAttr ) // Unknown attribute is ignored. |
|
609 { |
|
610 ucs2 = PcDataLC( aElmtNode ); |
|
611 if ( ucs2 ) |
|
612 { |
|
613 SetMetaAttrL( attr, TPtrC( ucs2 ) ); |
|
614 } |
|
615 CleanupStack::PopAndDestroy(); // Clean up ucs2. |
|
616 } |
|
617 CLOG(( EParse, 2, _L("<- TDdParser::MetaElementNodeL") )); |
|
618 } |
|
619 |
|
620 // --------------------------------------------------------- |
|
621 // TDdParser::MetaElementNodeL() |
|
622 // --------------------------------------------------------- |
|
623 // |
|
624 void TDdParser::MetaElementNodeL( NW_DOM_ElementNode_t* aElmtNode, CMediaObjectData *& aMediaObject ) |
|
625 { |
|
626 CLOG(( EParse, 2, _L("-> TDdParser::MetaElementNodeL") )); |
|
627 __ASSERT_DEBUG( aElmtNode, CodPanic( ECodInternal ) ); |
|
628 NW_String_t str; |
|
629 LeaveIfNwErrorL( NW_DOM_Node_getNodeName( aElmtNode, &str ) ); |
|
630 CleanupNwStringStoragePushL( &str ); |
|
631 NW_Ucs2* ucs2; |
|
632 LeaveIfNwErrorL( NW_String_stringToUCS2Char( &str, iEncoding, &ucs2 ) ); |
|
633 CleanupNwUcs2PushL( ucs2 ); |
|
634 TPtrC attrName( ucs2 ); |
|
635 TDdAttr attr = MetaAttribute( attrName ); |
|
636 CLOG(( EParse, 4, _L(" attribute <%S> (%d)"), &attrName, attr )); |
|
637 CleanupStack::PopAndDestroy( 2 ); // Clean up ucs2, str->storage |
|
638 if ( attr == EDdLicense ) |
|
639 { |
|
640 iIsLicenseTag = ETrue; |
|
641 return; |
|
642 } |
|
643 if ( attr != EDdUnknownAttr ) // Unknown attribute is ignored. |
|
644 { |
|
645 ucs2 = PcDataLC( aElmtNode ); |
|
646 if ( ucs2 ) |
|
647 { |
|
648 SetMetaAttrL( attr, TPtrC( ucs2 ), aMediaObject ); |
|
649 } |
|
650 CleanupStack::PopAndDestroy(); // Clean up ucs2. |
|
651 } |
|
652 CLOG(( EParse, 2, _L("<- TDdParser::MetaElementNodeL") )); |
|
653 }// --------------------------------------------------------- |
|
654 // TDdParser::ElementNodeL() |
|
655 // --------------------------------------------------------- |
|
656 // |
|
657 void TDdParser::ElementNodeL( NW_DOM_ElementNode_t* aElmtNode, CMediaObjectData *& aMediaObject ) |
|
658 { |
|
659 CLOG(( EParse, 2, _L("-> TDdParser::ElementNodeL") )); |
|
660 __ASSERT_DEBUG( aElmtNode, CodPanic( ECodInternal ) ); |
|
661 NW_String_t str; |
|
662 LeaveIfNwErrorL( NW_DOM_Node_getNodeName( aElmtNode, &str ) ); |
|
663 CleanupNwStringStoragePushL( &str ); |
|
664 NW_Ucs2* ucs2; |
|
665 LeaveIfNwErrorL( NW_String_stringToUCS2Char( &str, iEncoding, &ucs2 ) ); |
|
666 CleanupNwUcs2PushL( ucs2 ); |
|
667 TPtrC attrName( ucs2 ); |
|
668 TDdAttr attr = Attribute( attrName ); |
|
669 CLOG(( EParse, 4, _L(" attribute <%S> (%d)"), &attrName, attr )); |
|
670 CleanupStack::PopAndDestroy( 2 ); // Clean up ucs2, str->storage |
|
671 if ( attr != EDdUnknownAttr ) // Unknown attribute is ignored. |
|
672 { |
|
673 ucs2 = PcDataLC( aElmtNode ); |
|
674 if ( ucs2 ) |
|
675 { |
|
676 SetAttrL( attr, TPtrC( ucs2 ), aMediaObject ); |
|
677 } |
|
678 CleanupStack::PopAndDestroy(); // Clean up ucs2. |
|
679 } |
|
680 CLOG(( EParse, 2, _L("<- TDdParser::ElementNodeL") )); |
|
681 } |
|
682 |
|
683 // --------------------------------------------------------- |
|
684 // TDdParser::PcDataLC() |
|
685 // --------------------------------------------------------- |
|
686 // |
|
687 NW_Ucs2* TDdParser::PcDataLC( NW_DOM_ElementNode_t* aElmtNode ) |
|
688 { |
|
689 __ASSERT_DEBUG( aElmtNode, CodPanic( ECodInternal ) ); |
|
690 NW_Ucs2* ucs2 = NULL; |
|
691 NW_DOM_TextNode_t* textNode = NW_DOM_Node_getFirstChild( aElmtNode ); |
|
692 if ( textNode && NW_DOM_Node_getNodeType( textNode ) == NW_DOM_TEXT_NODE ) |
|
693 { |
|
694 NW_String_t str; |
|
695 LeaveIfNwErrorL( NW_DOM_TextNode_getData( textNode, &str ) ); |
|
696 CleanupNwStringStoragePushL( &str ); |
|
697 LeaveIfNwErrorL |
|
698 ( NW_String_stringToUCS2Char( &str, iEncoding, &ucs2 ) ); |
|
699 CleanupStack::PopAndDestroy(); // Clean up str->storage. |
|
700 CleanupNwUcs2PushL( ucs2 ); |
|
701 } |
|
702 if ( !ucs2 ) |
|
703 { |
|
704 // Push the NULL. |
|
705 CleanupStack::PushL( ucs2 ); |
|
706 } |
|
707 return ucs2; |
|
708 } |
|
709 |
|
710 // --------------------------------------------------------- |
|
711 // TDdParser::GetAttrValueLC() |
|
712 // --------------------------------------------------------- |
|
713 // |
|
714 /* |
|
715 NW_Ucs2* TDdParser::GetAttrValueLC( NW_DOM_ElementNode_t* aElmtNode, NW_DOM_AttributeHandle_t* aAttrHandle ) |
|
716 { |
|
717 __ASSERT_DEBUG( aElmtNode, CodPanic( ECodInternal ) ); |
|
718 NW_Ucs2* ucs2 = NULL; |
|
719 NW_DOM_TextNode_t* textNode = NW_DOM_Node_getFirstChild( aElmtNode ); |
|
720 if ( textNode && NW_DOM_Node_getNodeType( textNode ) == NW_DOM_TEXT_NODE ) |
|
721 { |
|
722 NW_String_t str; |
|
723 LeaveIfNwErrorL( NW_DOM_TextNode_getData( textNode, &str ) ); |
|
724 CleanupNwStringStoragePushL( &str ); |
|
725 LeaveIfNwErrorL |
|
726 ( NW_String_stringToUCS2Char( &str, iEncoding, &ucs2 ) ); |
|
727 CleanupStack::PopAndDestroy(); // Clean up str->storage. |
|
728 CleanupNwUcs2PushL( ucs2 ); |
|
729 } |
|
730 if ( !ucs2 ) |
|
731 { |
|
732 // Push the NULL. |
|
733 CleanupStack::PushL( ucs2 ); |
|
734 } |
|
735 return ucs2; |
|
736 } |
|
737 */ |
|
738 // --------------------------------------------------------- |
|
739 // TDdParser::Attribute() // for OMA v1 |
|
740 // --------------------------------------------------------- |
|
741 // |
|
742 TDdParser::TDdAttr TDdParser::Attribute( const TDesC& aAttrName ) const |
|
743 { |
|
744 TDdAttr attr = EDdUnknownAttr; |
|
745 if ( !aAttrName.Compare( KDdName ) ) |
|
746 { |
|
747 attr = EDdName; |
|
748 } |
|
749 else if ( !aAttrName.Compare( KDdVendor ) ) |
|
750 { |
|
751 attr = EDdVendor; |
|
752 } |
|
753 else if ( !aAttrName.Compare( KDdDescription ) ) |
|
754 { |
|
755 attr = EDdDescription; |
|
756 } |
|
757 else if ( !aAttrName.Compare( KDdUrl ) ) |
|
758 { |
|
759 attr = EDdUrl; |
|
760 } |
|
761 else if ( !aAttrName.Compare( KDdSize ) ) |
|
762 { |
|
763 attr = EDdSize; |
|
764 } |
|
765 else if ( !aAttrName.Compare( KDdType ) ) |
|
766 { |
|
767 attr = EDdType; |
|
768 } |
|
769 else if ( !aAttrName.Compare( KDdInstallNotify ) ) |
|
770 { |
|
771 attr = EDdInstallNotify; |
|
772 } |
|
773 else if ( !aAttrName.Compare( KDdNextUrl ) ) |
|
774 { |
|
775 attr = EDdNextUrl; |
|
776 } |
|
777 else if ( !aAttrName.Compare( KDdInfoUrl ) ) |
|
778 { |
|
779 attr = EDdInfoUrl; |
|
780 } |
|
781 else if ( !aAttrName.Compare( KDdIcon ) ) |
|
782 { |
|
783 attr = EDdIcon; |
|
784 } |
|
785 else if ( !aAttrName.Compare( KDdVersion ) ) |
|
786 { |
|
787 attr = EDdVersion; |
|
788 } |
|
789 return attr; |
|
790 } |
|
791 |
|
792 // --------------------------------------------------------- |
|
793 // TDdParser::MediaAttribute() // for OMA v2 |
|
794 // --------------------------------------------------------- |
|
795 // |
|
796 TDdParser::TDdAttr TDdParser::MediaAttribute( const TDesC& aAttrName ) const |
|
797 { |
|
798 TDdAttr attr = EDdUnknownAttr; |
|
799 |
|
800 if ( !aAttrName.Compare( KDdVersion ) ) |
|
801 { |
|
802 attr = EDdVersion; |
|
803 } |
|
804 else if ( !aAttrName.Compare( KDdVendor ) ) |
|
805 { |
|
806 attr = EDdVendor; |
|
807 } |
|
808 else if ( !aAttrName.Compare( KDdName ) ) |
|
809 { |
|
810 attr = EDdName; |
|
811 } |
|
812 else if ( !aAttrName.Compare( KDdNextUrl ) ) |
|
813 { |
|
814 attr = EDdNextUrl; |
|
815 } |
|
816 else if ( !aAttrName.Compare( KDdProduct ) ) |
|
817 { |
|
818 attr = EDdProduct; |
|
819 } |
|
820 else if ( !aAttrName.Compare( KDdUpdatedDDURI ) ) |
|
821 { |
|
822 attr = EDdUpdatedDDURI; |
|
823 } |
|
824 return attr; |
|
825 } |
|
826 |
|
827 // --------------------------------------------------------- |
|
828 // TDdParser::MediaObjAttribute() // for OMA v2 |
|
829 // --------------------------------------------------------- |
|
830 // |
|
831 TDdParser::TDdAttr TDdParser::MediaObjAttribute( const TDesC& aAttrName ) const |
|
832 { |
|
833 TDdAttr attr = EDdUnknownAttr; |
|
834 |
|
835 if ( !aAttrName.Compare( KDdUrl ) ) |
|
836 { |
|
837 attr = EDdUrl; |
|
838 } |
|
839 else if ( !aAttrName.Compare( KDdSize ) ) |
|
840 { |
|
841 attr = EDdSize; |
|
842 } |
|
843 else if ( !aAttrName.Compare( KDdType ) ) |
|
844 { |
|
845 attr = EDdType; |
|
846 } |
|
847 else if ( !aAttrName.CompareF( KDdProgressiveDl ) ) |
|
848 { |
|
849 attr = EDdProgressiveDl; |
|
850 } |
|
851 else if ( !aAttrName.CompareF( KDdSuppressUserConfirmation ) ) |
|
852 { |
|
853 attr = EDdSuppressUserConfirmation; |
|
854 } |
|
855 else if ( !aAttrName.Compare( KDdMeta ) ) |
|
856 { |
|
857 attr = EDdMeta; |
|
858 } |
|
859 |
|
860 return attr; |
|
861 } |
|
862 |
|
863 // --------------------------------------------------------- |
|
864 // TDdParser::ObjUriAttribute() // for OMA v2 |
|
865 // --------------------------------------------------------- |
|
866 // |
|
867 TDdParser::TDdAttr TDdParser::ObjUriAttribute( const TDesC& aAttrName ) const |
|
868 { |
|
869 TDdAttr attr = EDdUnknownAttr; |
|
870 |
|
871 if ( !aAttrName.Compare( KDdServer ) ) |
|
872 { |
|
873 attr = EDdUrl; |
|
874 } |
|
875 return attr; |
|
876 } |
|
877 |
|
878 // --------------------------------------------------------- |
|
879 // TDdParser::DdVersionAttribute() // for OMA v2 |
|
880 // --------------------------------------------------------- |
|
881 // |
|
882 TDdParser::TDdAttr TDdParser::DdVersionAttribute( const TDesC& aAttrName ) const |
|
883 { |
|
884 TDdAttr attr = EDdUnknownAttr; |
|
885 |
|
886 if ( !aAttrName.Compare( KDdVersion ) ) |
|
887 { |
|
888 attr = EDdVersion; |
|
889 } |
|
890 return attr; |
|
891 } |
|
892 |
|
893 // --------------------------------------------------------- |
|
894 // TDdParser::MetaAttribute() // for OMA v2 |
|
895 // --------------------------------------------------------- |
|
896 // |
|
897 TDdParser::TDdAttr TDdParser::MetaAttribute( const TDesC& aAttrName ) const |
|
898 { |
|
899 TDdAttr attr = EDdUnknownAttr; |
|
900 if ( !aAttrName.Compare( KDdName ) ) |
|
901 { |
|
902 attr = EDdName; |
|
903 } |
|
904 if ( !aAttrName.Compare( KDdText ) ) |
|
905 { |
|
906 attr = EDdText; |
|
907 } |
|
908 else if ( !aAttrName.Compare( KDdDescription ) ) |
|
909 { |
|
910 attr = EDdDescription; |
|
911 } |
|
912 else if ( !aAttrName.Compare( KDdInstallNotify ) ) |
|
913 { |
|
914 attr = EDdInstallNotify; |
|
915 } |
|
916 else if ( !aAttrName.Compare( KDdLicense ) ) |
|
917 { |
|
918 attr = EDdLicense; |
|
919 } |
|
920 else if ( !aAttrName.Compare( KDdOrder ) ) |
|
921 { |
|
922 attr = EDdOrder; |
|
923 } |
|
924 return attr; |
|
925 } |
|
926 |
|
927 // --------------------------------------------------------- |
|
928 // TDdParser::ProductAttribute() // for OMA v2 |
|
929 // --------------------------------------------------------- |
|
930 // |
|
931 TDdParser::TDdAttr TDdParser::ProductAttribute( const TDesC& aAttrName ) const |
|
932 { |
|
933 TDdAttr attr = EDdUnknownAttr; |
|
934 if ( !aAttrName.Compare( KDdMeta ) ) |
|
935 { |
|
936 attr = EDdMeta; |
|
937 } |
|
938 if ( !aAttrName.Compare( KDdMediaObject ) ) |
|
939 { |
|
940 attr = EDdMediaObject; |
|
941 } |
|
942 return attr; |
|
943 } |
|
944 |
|
945 // --------------------------------------------------------- |
|
946 // TDdParser::SetAttrL() // for OMA v1 |
|
947 // --------------------------------------------------------- |
|
948 // |
|
949 void TDdParser::SetAttrL( TDdAttr aAttr, const TDesC& aValue, CMediaObjectData *& aMediaObject ) |
|
950 { |
|
951 TInt ok( ETrue ); |
|
952 switch( aAttr ) |
|
953 { |
|
954 case EDdName: |
|
955 { |
|
956 if ( !aMediaObject->Name().Length() ) |
|
957 { |
|
958 ok = aMediaObject->SetNameL( aValue ); |
|
959 } |
|
960 break; |
|
961 } |
|
962 |
|
963 case EDdDescription: |
|
964 { |
|
965 if ( !aMediaObject->Description().Length() ) |
|
966 { |
|
967 ok = aMediaObject->SetDescriptionL( aValue ); |
|
968 } |
|
969 break; |
|
970 } |
|
971 |
|
972 case EDdUrl: |
|
973 { |
|
974 if ( !aMediaObject->Url().Length() ) |
|
975 { |
|
976 ok = aMediaObject->SetUrlL( aValue ); |
|
977 } |
|
978 break; |
|
979 } |
|
980 |
|
981 case EDdSize: |
|
982 { |
|
983 if ( !aMediaObject->Size() ) |
|
984 { |
|
985 // Parse as TUint - negative not allowed. |
|
986 TUint size; |
|
987 TLex lex( aValue ); |
|
988 if ( !lex.Val( size ) ) |
|
989 { |
|
990 aMediaObject->SetSize( size ); |
|
991 } |
|
992 else |
|
993 { |
|
994 ok = EFalse; |
|
995 } |
|
996 } |
|
997 break; |
|
998 } |
|
999 |
|
1000 case EDdType: |
|
1001 { |
|
1002 ok = aMediaObject->AddTypeL( aValue ); |
|
1003 break; |
|
1004 } |
|
1005 |
|
1006 case EDdInstallNotify: |
|
1007 { |
|
1008 if ( !aMediaObject->InstallNotify().Length() ) |
|
1009 { |
|
1010 ok = aMediaObject->SetInstallNotifyL( aValue ); |
|
1011 } |
|
1012 break; |
|
1013 } |
|
1014 |
|
1015 case EDdInfoUrl: |
|
1016 { |
|
1017 if ( !aMediaObject->InfoUrl().Length() ) |
|
1018 { |
|
1019 ok = aMediaObject->SetInfoUrlL( aValue ); |
|
1020 } |
|
1021 break; |
|
1022 } |
|
1023 |
|
1024 case EDdIcon: |
|
1025 { |
|
1026 if ( !aMediaObject->Icon().Length() ) |
|
1027 { |
|
1028 ok = aMediaObject->SetIconL( aValue ); |
|
1029 } |
|
1030 break; |
|
1031 } |
|
1032 |
|
1033 case EDdVersion: |
|
1034 { |
|
1035 if ( !iData->Version().Length() ) |
|
1036 { |
|
1037 ok = iData->SetVersionL( aValue ); |
|
1038 } |
|
1039 break; |
|
1040 } |
|
1041 |
|
1042 case EDdNextUrl: |
|
1043 { |
|
1044 if ( !iData->NextUrl().Length() ) |
|
1045 { |
|
1046 ok = iData->SetNextUrlL( aValue ); |
|
1047 } |
|
1048 break; |
|
1049 } |
|
1050 |
|
1051 case EDdVendor: |
|
1052 { |
|
1053 if ( !iData->Vendor().Length() ) |
|
1054 { |
|
1055 ok = iData->SetVendorL( aValue ); |
|
1056 } |
|
1057 break; |
|
1058 } |
|
1059 |
|
1060 default: |
|
1061 { |
|
1062 // Unexpected value. |
|
1063 CodPanic( ECodInternal ); |
|
1064 } |
|
1065 } |
|
1066 if ( !ok ) |
|
1067 { |
|
1068 Error( KErrCodInvalidDescriptor ); |
|
1069 } |
|
1070 } |
|
1071 |
|
1072 |
|
1073 // --------------------------------------------------------- |
|
1074 // TDdParser::SetMediaAttrL() |
|
1075 // --------------------------------------------------------- |
|
1076 // |
|
1077 void TDdParser::SetMediaAttrL( TDdAttr aAttr, const TDesC& aValue ) |
|
1078 { |
|
1079 TInt ok( ETrue ); |
|
1080 switch( aAttr ) |
|
1081 { |
|
1082 case EDdName: |
|
1083 { |
|
1084 if ( !iData->Name().Length() ) |
|
1085 { |
|
1086 ok = iData->SetNameL( aValue ); |
|
1087 } |
|
1088 break; |
|
1089 } |
|
1090 case EDdVersion: |
|
1091 { |
|
1092 if ( !iData->Version().Length() ) |
|
1093 { |
|
1094 ok = iData->SetVersionL( aValue ); |
|
1095 } |
|
1096 break; |
|
1097 } |
|
1098 |
|
1099 case EDdVendor: |
|
1100 { |
|
1101 if ( !iData->Vendor().Length() ) |
|
1102 { |
|
1103 ok = iData->SetVendorL( aValue ); |
|
1104 } |
|
1105 break; |
|
1106 } |
|
1107 |
|
1108 case EDdNextUrl: |
|
1109 { |
|
1110 if ( !iData->NextUrl().Length() ) |
|
1111 { |
|
1112 // Unlike COD, DD has no separate URL-s for success and error |
|
1113 // service flow. Since we have a common data structore for |
|
1114 // both (which contains separate URLs for those), we fill both |
|
1115 // URLs with this value. |
|
1116 ok = iData->SetNextUrlL( aValue ) && |
|
1117 iData->SetNextUrlAtErrorL( aValue ); |
|
1118 } |
|
1119 break; |
|
1120 } |
|
1121 |
|
1122 case EDdUpdatedDDURI: |
|
1123 { |
|
1124 if(!iData->UpdatedDDUriL().Length()) |
|
1125 { |
|
1126 iData->SetUpdatedDDURI( aValue ); |
|
1127 } |
|
1128 |
|
1129 break; |
|
1130 } |
|
1131 |
|
1132 default: |
|
1133 { |
|
1134 // Unexpected value. |
|
1135 CodPanic( ECodInternal ); |
|
1136 } |
|
1137 } |
|
1138 if ( !ok ) |
|
1139 { |
|
1140 Error( KErrCodInvalidDescriptor ); |
|
1141 } |
|
1142 } |
|
1143 |
|
1144 // --------------------------------------------------------- |
|
1145 // TDdParser::SetMediaObjAttrL() |
|
1146 // --------------------------------------------------------- |
|
1147 // |
|
1148 void TDdParser::SetMediaObjAttrL( TDdAttr aAttr, const TDesC& aValue, CMediaObjectData *& aMediaObject ) |
|
1149 { |
|
1150 TInt ok( ETrue ); |
|
1151 switch( aAttr ) |
|
1152 { |
|
1153 case EDdSize: |
|
1154 { |
|
1155 if ( !aMediaObject->Size() ) |
|
1156 { |
|
1157 // Parse as TUint - negative not allowed. |
|
1158 TUint size; |
|
1159 TLex lex( aValue ); |
|
1160 if ( !lex.Val( size ) ) |
|
1161 { |
|
1162 aMediaObject->SetSize( size ); |
|
1163 } |
|
1164 else |
|
1165 { |
|
1166 ok = EFalse; |
|
1167 } |
|
1168 } |
|
1169 break; |
|
1170 } |
|
1171 |
|
1172 case EDdType: |
|
1173 { |
|
1174 ok = aMediaObject->AddTypeL( aValue ); |
|
1175 break; |
|
1176 } |
|
1177 |
|
1178 case EDdProgressiveDl: |
|
1179 { |
|
1180 TBool pd( EFalse ); |
|
1181 if ( !aValue.CompareF( KDdTrue ) ) |
|
1182 { |
|
1183 pd = ETrue; |
|
1184 } |
|
1185 else if ( aValue.CompareF( KDdFalse ) ) |
|
1186 { |
|
1187 // Expected 'true' or 'false' |
|
1188 Error( KErrCodInvalidDescriptor ); |
|
1189 break; |
|
1190 } |
|
1191 aMediaObject->SetProgressiveDownload( pd ); |
|
1192 break; |
|
1193 } |
|
1194 |
|
1195 case EDdSuppressUserConfirmation: |
|
1196 { |
|
1197 TInt confirm = CCodData::ENever; |
|
1198 if ( !aValue.CompareF(KDdNever) ) |
|
1199 { |
|
1200 confirm = CCodData::ENever; |
|
1201 } |
|
1202 else if ( aValue.CompareF(KDdUserConfirmStepOnly) ) |
|
1203 { |
|
1204 confirm = CCodData::EUserConfirmStepOnly; |
|
1205 } |
|
1206 else if ( aValue.CompareF(KDdAlways) ) |
|
1207 { |
|
1208 confirm = CCodData::EAlways; |
|
1209 } |
|
1210 else |
|
1211 { |
|
1212 Error( KErrCodInvalidDescriptor ); |
|
1213 } |
|
1214 iData->SetSuppressConfirm( confirm ); |
|
1215 break; |
|
1216 } |
|
1217 case EDdUpdatedDDURI: |
|
1218 { |
|
1219 if(!iData->UpdatedDDUriL().Length()) |
|
1220 { |
|
1221 iData->SetUpdatedDDURI( aValue ); |
|
1222 } |
|
1223 |
|
1224 break; |
|
1225 } |
|
1226 default: |
|
1227 { |
|
1228 // Unexpected value. |
|
1229 CodPanic( ECodInternal ); |
|
1230 } |
|
1231 } |
|
1232 if ( !ok ) |
|
1233 { |
|
1234 Error( KErrCodInvalidDescriptor ); |
|
1235 } |
|
1236 } |
|
1237 |
|
1238 |
|
1239 // --------------------------------------------------------- |
|
1240 // TDdParser::SetMetaAttrL() |
|
1241 // --------------------------------------------------------- |
|
1242 // |
|
1243 void TDdParser::SetMetaAttrL( TDdAttr aAttr, const TDesC& aValue ) |
|
1244 { |
|
1245 TInt ok( ETrue ); |
|
1246 switch( aAttr ) |
|
1247 { |
|
1248 case EDdName: |
|
1249 { |
|
1250 if ( !iData->Name().Length() ) |
|
1251 { |
|
1252 ok = iData->SetNameL( aValue ); |
|
1253 } |
|
1254 break; |
|
1255 } |
|
1256 |
|
1257 case EDdDescription: |
|
1258 { |
|
1259 if ( !iData->Description().Length() ) |
|
1260 { |
|
1261 ok = iData->SetDescriptionL( aValue ); |
|
1262 } |
|
1263 break; |
|
1264 } |
|
1265 |
|
1266 case EDdInstallNotify: |
|
1267 { |
|
1268 if ( !iData->InstallNotify().Length() ) |
|
1269 { |
|
1270 ok = iData->SetInstallNotifyL( aValue ); |
|
1271 } |
|
1272 break; |
|
1273 } |
|
1274 |
|
1275 case EDdInfoUrl: |
|
1276 { |
|
1277 if ( !iData->InfoUrl().Length() ) |
|
1278 { |
|
1279 ok = iData->SetInfoUrlL( aValue ); |
|
1280 } |
|
1281 break; |
|
1282 } |
|
1283 |
|
1284 case EDdIcon: |
|
1285 { |
|
1286 if ( !iData->Icon().Length() ) |
|
1287 { |
|
1288 ok = iData->SetIconL( aValue ); |
|
1289 } |
|
1290 break; |
|
1291 } |
|
1292 |
|
1293 case EDdOrder: |
|
1294 { |
|
1295 TBool isPostOrder( EFalse ); |
|
1296 if ( !aValue.CompareF( KDdPost ) ) |
|
1297 { |
|
1298 isPostOrder = ETrue; |
|
1299 } |
|
1300 else if ( aValue.CompareF( KDdAny ) ) |
|
1301 { |
|
1302 // Expected 'post' or 'any' |
|
1303 Error( KErrCodInvalidDescriptor ); |
|
1304 break; |
|
1305 } |
|
1306 iData->SetOrderIsPost( isPostOrder ); |
|
1307 break; |
|
1308 } |
|
1309 |
|
1310 case EDdText: |
|
1311 { |
|
1312 |
|
1313 break; |
|
1314 } |
|
1315 default: |
|
1316 { |
|
1317 // Unexpected value. |
|
1318 CodPanic( ECodInternal ); |
|
1319 } |
|
1320 } |
|
1321 if ( !ok ) |
|
1322 { |
|
1323 Error( KErrCodInvalidDescriptor ); |
|
1324 } |
|
1325 } |
|
1326 |
|
1327 |
|
1328 // --------------------------------------------------------- |
|
1329 // TDdParser::SetMetaAttrL() |
|
1330 // --------------------------------------------------------- |
|
1331 // |
|
1332 void TDdParser::SetMetaAttrL( TDdAttr aAttr, const TDesC& aValue, CMediaObjectData *& aMediaObject ) |
|
1333 { |
|
1334 TInt ok( ETrue ); |
|
1335 switch( aAttr ) |
|
1336 { |
|
1337 case EDdName: |
|
1338 { |
|
1339 if ( !aMediaObject->Name().Length() ) |
|
1340 { |
|
1341 ok = aMediaObject->SetNameL( aValue ); |
|
1342 } |
|
1343 break; |
|
1344 } |
|
1345 |
|
1346 case EDdDescription: |
|
1347 { |
|
1348 if ( !aMediaObject->Description().Length() ) |
|
1349 { |
|
1350 ok = aMediaObject->SetDescriptionL( aValue ); |
|
1351 } |
|
1352 break; |
|
1353 } |
|
1354 |
|
1355 case EDdInstallNotify: |
|
1356 { |
|
1357 if ( !aMediaObject->InstallNotify().Length() ) |
|
1358 { |
|
1359 ok = aMediaObject->SetInstallNotifyL( aValue ); |
|
1360 } |
|
1361 break; |
|
1362 } |
|
1363 |
|
1364 case EDdInfoUrl: |
|
1365 { |
|
1366 if ( !aMediaObject->InfoUrl().Length() ) |
|
1367 { |
|
1368 ok = aMediaObject->SetInfoUrlL( aValue ); |
|
1369 } |
|
1370 break; |
|
1371 } |
|
1372 |
|
1373 case EDdIcon: |
|
1374 { |
|
1375 if ( !aMediaObject->Icon().Length() ) |
|
1376 { |
|
1377 ok = aMediaObject->SetIconL( aValue ); |
|
1378 } |
|
1379 break; |
|
1380 } |
|
1381 |
|
1382 case EDdOrder: |
|
1383 { |
|
1384 TBool isPostOrder( EFalse ); |
|
1385 if ( !aValue.CompareF( KDdPost ) ) |
|
1386 { |
|
1387 isPostOrder = ETrue; |
|
1388 } |
|
1389 else if ( aValue.CompareF( KDdAny ) ) |
|
1390 { |
|
1391 // Expected 'post' or 'any' |
|
1392 Error( KErrCodInvalidDescriptor ); |
|
1393 break; |
|
1394 } |
|
1395 aMediaObject->SetOrderIsPost( isPostOrder ); |
|
1396 break; |
|
1397 } |
|
1398 |
|
1399 case EDdText: |
|
1400 { |
|
1401 //TODO for OMA2 |
|
1402 /* |
|
1403 if ( !iData->Text().Length() ) |
|
1404 { |
|
1405 ok = iData->SetTextL( aValue ); |
|
1406 } |
|
1407 */ |
|
1408 break; |
|
1409 } |
|
1410 |
|
1411 default: |
|
1412 { |
|
1413 // Unexpected value. |
|
1414 CodPanic( ECodInternal ); |
|
1415 } |
|
1416 } |
|
1417 if ( !ok ) |
|
1418 { |
|
1419 Error( KErrCodInvalidDescriptor ); |
|
1420 } |
|
1421 } |
|
1422 |
|
1423 // --------------------------------------------------------- |
|
1424 // TDdParser::ParseNameFromUrlL() |
|
1425 // --------------------------------------------------------- |
|
1426 void TDdParser::ParseNameFromUrlL( CMediaObjectData *& aMediaObject ) |
|
1427 { |
|
1428 TBuf16<COD_URL_MAX_LEN> buf16; |
|
1429 CnvUtfConverter::ConvertToUnicodeFromUtf8(buf16,aMediaObject->Url()); |
|
1430 TInt lastSlashPos = buf16.LocateReverse('/'); |
|
1431 aMediaObject->SetNameL(buf16.MidTPtr( lastSlashPos + 1)); |
|
1432 } |
|
1433 |