upnpavcontroller/upnpxmlparser/src/upnpitemtoxml.cpp
branchnew development branch with rendering state machine and other goodies
changeset 38 5360b7ddc251
parent 0 7f85d04be362
equal deleted inserted replaced
32:3785f754ee62 38:5360b7ddc251
    24 // System
    24 // System
    25 #include <e32base.h>
    25 #include <e32base.h>
    26 
    26 
    27 // upnp stack api
    27 // upnp stack api
    28 #include <upnpstring.h>
    28 #include <upnpstring.h>
       
    29 
       
    30 // dlnasrv / mediaserver api
    29 #include <upnpitem.h>
    31 #include <upnpitem.h>
    30 #include <upnpdlnaprotocolinfo.h>
    32 #include <upnpdlnaprotocolinfo.h>
    31 
    33 
    32 // upnpframework / avcontroller helper api
    34 // dlnasrv / avcontroller helper api
    33 #include "upnpconstantdefs.h" // for upnp definitions
    35 #include "upnpconstantdefs.h" // for upnp definitions
    34 #include "upnpitemutility.h"
    36 #include "upnpitemutility.h"
    35 
    37 
    36 // xmlparser internal
    38 // xmlparser internal
    37 #include "upnpitemtoxml.h"
    39 #include "upnpitemtoxml.h"
    57 _LIT8(KItemPInfoBegin,          "<res protocolInfo=\"");
    59 _LIT8(KItemPInfoBegin,          "<res protocolInfo=\"");
    58 _LIT8(KItemPInfoMiddle,         ">");
    60 _LIT8(KItemPInfoMiddle,         ">");
    59 _LIT8(KItemPInfoEnd,            "</res>");
    61 _LIT8(KItemPInfoEnd,            "</res>");
    60 _LIT8(KItemPInfoEnd2,            "\"></res>");
    62 _LIT8(KItemPInfoEnd2,            "\"></res>");
    61 _LIT8(KItemEnd,                 "</item>");
    63 _LIT8(KItemEnd,                 "</item>");
       
    64 _LIT8(KEqual,                   "=");
    62 
    65 
    63 _LIT8(KQuotationMark,           "\" ");
    66 _LIT8(KQuotationMark,           "\" ");
    64 _LIT8(KItemSize,                "size=\"");
    67 _LIT8(KItemSize,                "size=\"");
    65 _LIT8(KItemDuration,            "duration=\"");
    68 _LIT8(KItemDuration,            "duration=\"");
    66 _LIT8(KItemResolution,          "resolution=\"");
    69 _LIT8(KItemResolution,          "resolution=\"");
    73 _LIT8(KItemAlbumBegin,          "<upnp:album>");
    76 _LIT8(KItemAlbumBegin,          "<upnp:album>");
    74 _LIT8(KItemAlbumEnd,            "</upnp:album>");
    77 _LIT8(KItemAlbumEnd,            "</upnp:album>");
    75 _LIT8(KItemGenreBegin,          "<upnp:genre>");
    78 _LIT8(KItemGenreBegin,          "<upnp:genre>");
    76 _LIT8(KItemGenreEnd,            "</upnp:genre>");
    79 _LIT8(KItemGenreEnd,            "</upnp:genre>");
    77 _LIT8(KItemAlbumArtURIBegin,    "<upnp:albumArtURI>");
    80 _LIT8(KItemAlbumArtURIBegin,    "<upnp:albumArtURI>");
       
    81 _LIT8(KItemAlbumArtURI,         "<upnp:albumArtURI ");
    78 _LIT8(KItemAlbumArtURIEnd,      "</upnp:albumArtURI>");
    82 _LIT8(KItemAlbumArtURIEnd,      "</upnp:albumArtURI>");
    79 
    83 
    80 _LIT8(KDIDLBeginXmlEscaped,
    84 _LIT8(KDIDLBeginXmlEscaped,
    81     "&lt;DIDL-Lite "
    85     "&lt;DIDL-Lite "
    82     "xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot; "
    86     "xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot; "
   294         CleanupStack::PopAndDestroy( encodeTemp );
   298         CleanupStack::PopAndDestroy( encodeTemp );
   295         encodeTemp = NULL;
   299         encodeTemp = NULL;
   296         //stream.WriteL( Genre() );
   300         //stream.WriteL( Genre() );
   297         stream.WriteL( KItemGenreEnd );
   301         stream.WriteL( KItemGenreEnd );
   298         } 
   302         } 
   299     const TDesC8& albumarturi = GetValueFromElement( KElementAlbumArtUri );     
   303     const TDesC8& albumarturi = GetValueFromElement( KElementAlbumArtUri );
   300     if ( albumarturi != KNullDesC8 )
   304     if ( albumarturi != KNullDesC8 )
   301         {
   305         {
   302         stream.WriteL( KItemAlbumArtURIBegin );
   306         CUpnpElement* elem = 
       
   307         (CUpnpElement*)(UPnPItemUtility::FindElementByName( *iItem, KElementAlbumArtUri() ));
       
   308         if( elem )
       
   309             {
       
   310             stream.WriteL( KItemAlbumArtURI );
       
   311             const RUPnPAttributesArray& attrArray = elem->GetAttributes();
       
   312             for( TInt i(0); i < attrArray.Count(); ++i )
       
   313                 {
       
   314                 stream.WriteL( attrArray.operator [](i)->Name() );
       
   315                 stream.WriteL( KEqual );
       
   316                 stream.WriteL( KCriteriaQuot );
       
   317                 stream.WriteL( attrArray.operator [](i)->Value() ); 
       
   318                 stream.WriteL( KCriteriaQuot );
       
   319                 }            
       
   320             stream.WriteL( KItemPInfoMiddle );
       
   321             }
       
   322         else
       
   323             {
       
   324             stream.WriteL( KItemAlbumArtURIBegin );
       
   325             }
   303         // xml encoding added
   326         // xml encoding added
   304         encodeTemp = HBufC8::NewLC( albumarturi.Length() );
   327         encodeTemp = HBufC8::NewLC( albumarturi.Length() );
   305         encodeTemp->Des().Copy( albumarturi );
   328         encodeTemp->Des().Copy( albumarturi );
   306 
   329 
   307         tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
   330         tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
   376             stream.WriteL( attrresolution->Value() );
   399             stream.WriteL( attrresolution->Value() );
   377             stream.WriteL( KCriteriaQuot );
   400             stream.WriteL( KCriteriaQuot );
   378             stream.WriteL( KCriteriaSpace );                        
   401             stream.WriteL( KCriteriaSpace );                        
   379             }        
   402             }        
   380         const CUpnpAttribute* attrduration = UPnPItemUtility
   403         const CUpnpAttribute* attrduration = UPnPItemUtility
   381             ::FindAttributeByName( *elArray[ i ], KAttributeDuration );        
   404             ::FindAttributeByName( *elArray[ i ], KAttributeDuration );
   382         if ( attrduration )
   405         if ( attrduration )
   383             {           
   406             {           
   384             if( ValidateDurationL( attrduration->Value() ) )
   407             if( ValidateDurationL( attrduration->Value() ) )
   385                 {
   408                 {
   386                 stream.WriteL( KAttributeDuration );
   409                 stream.WriteL( KAttributeDuration );
   444     CleanupStack::PopAndDestroy( pBuf );
   467     CleanupStack::PopAndDestroy( pBuf );
   445     
   468     
   446     return retBuffer;
   469     return retBuffer;
   447     }
   470     }
   448 
   471 
       
   472 void CUpnpItemToXML::FillMetaDataL(RBufWriteStream& aStream)
       
   473     {
       
   474     HBufC8* encodeTemp = NULL;
       
   475     HBufC8* tempPtr = NULL;
       
   476     const TDesC8& artist = GetValueFromElement( KElementArtist ); 
       
   477     if ( artist != KNullDesC8 )
       
   478         {
       
   479         aStream.WriteL( KItemArtistBegin );
       
   480         // xml encoding added
       
   481         encodeTemp = HBufC8::NewLC( artist.Length() );
       
   482         encodeTemp->Des().Copy( artist );
       
   483 
       
   484         tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
       
   485         CleanupStack::PushL( tempPtr );
       
   486 
       
   487         aStream.WriteL( *tempPtr );
       
   488         CleanupStack::PopAndDestroy( tempPtr );
       
   489         tempPtr = NULL;
       
   490         
       
   491         CleanupStack::PopAndDestroy( encodeTemp );
       
   492         encodeTemp = NULL;
       
   493 
       
   494         aStream.WriteL( KItemArtistEnd );
       
   495         }
       
   496     const TDesC8& creator = GetValueFromElement( KElementCreator ); 
       
   497     if ( creator != KNullDesC8 )
       
   498         {
       
   499         aStream.WriteL( KItemCreatorBegin );
       
   500         // xml encoding added
       
   501         encodeTemp = HBufC8::NewLC( creator.Length() );
       
   502         encodeTemp->Des().Copy( creator );
       
   503 
       
   504         tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
       
   505         CleanupStack::PushL( tempPtr );
       
   506 
       
   507         aStream.WriteL( *tempPtr );
       
   508         CleanupStack::PopAndDestroy( tempPtr );
       
   509         tempPtr = NULL;
       
   510         
       
   511         CleanupStack::PopAndDestroy( encodeTemp );
       
   512         encodeTemp = NULL;
       
   513 
       
   514         aStream.WriteL( KItemCreatorEnd );        
       
   515         }
       
   516     const TDesC8& album = GetValueFromElement( KElementAlbum ); 
       
   517     if ( album != KNullDesC8 )
       
   518         {
       
   519         aStream.WriteL( KItemAlbumBegin );
       
   520         // xml encoding added
       
   521         encodeTemp = HBufC8::NewLC( album.Length() );
       
   522         encodeTemp->Des().Copy( album );
       
   523         
       
   524         tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
       
   525         CleanupStack::PushL( tempPtr );
       
   526 
       
   527         aStream.WriteL( *tempPtr );
       
   528         CleanupStack::PopAndDestroy( tempPtr );
       
   529         tempPtr = NULL;
       
   530 
       
   531         CleanupStack::PopAndDestroy( encodeTemp );
       
   532         encodeTemp = NULL;
       
   533         //aStream.WriteL( Album() );
       
   534         aStream.WriteL( KItemAlbumEnd );        
       
   535         }
       
   536     const TDesC8& genre = GetValueFromElement( KElementGenre );     
       
   537     if ( genre != KNullDesC8 )
       
   538         {
       
   539         aStream.WriteL( KItemGenreBegin );
       
   540         // xml encoding added
       
   541         encodeTemp = HBufC8::NewLC( genre.Length() );
       
   542         encodeTemp->Des().Copy( genre );
       
   543 
       
   544         tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
       
   545         CleanupStack::PushL( tempPtr );
       
   546 
       
   547         aStream.WriteL( *tempPtr );
       
   548         CleanupStack::PopAndDestroy( tempPtr );
       
   549         tempPtr = NULL;
       
   550 
       
   551         CleanupStack::PopAndDestroy( encodeTemp );
       
   552         encodeTemp = NULL;
       
   553         //aStream.WriteL( Genre() );
       
   554         aStream.WriteL( KItemGenreEnd );        
       
   555         }
       
   556     const TDesC8& albumarturi = GetValueFromElement( KElementAlbumArtUri );
       
   557     if ( albumarturi != KNullDesC8 )
       
   558         {
       
   559         aStream.WriteL( KItemAlbumArtURIBegin );
       
   560         // xml encoding added
       
   561         encodeTemp = HBufC8::NewLC( albumarturi.Length() );
       
   562         encodeTemp->Des().Copy( albumarturi );
       
   563 
       
   564         tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
       
   565         CleanupStack::PushL( tempPtr );
       
   566 
       
   567         aStream.WriteL( *tempPtr );
       
   568         CleanupStack::PopAndDestroy( tempPtr );
       
   569         tempPtr = NULL;
       
   570 
       
   571         CleanupStack::PopAndDestroy( encodeTemp );
       
   572         encodeTemp = NULL;       
       
   573         aStream.WriteL( KItemAlbumArtURIEnd );        
       
   574         }
       
   575     const TDesC8& date = GetValueFromElement( KElementDate );         
       
   576     if ( date != KNullDesC8 )
       
   577         {
       
   578         if( ValidateDateL( date ) )
       
   579             {
       
   580             aStream.WriteL( KItemDateBegin );
       
   581             // xml encoding added
       
   582             encodeTemp = HBufC8::NewLC( date.Length() );
       
   583             encodeTemp->Des().Copy( date );
       
   584 
       
   585             tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
       
   586             CleanupStack::PushL( tempPtr );
       
   587 
       
   588             aStream.WriteL( *tempPtr );
       
   589             CleanupStack::PopAndDestroy( tempPtr );
       
   590             tempPtr = NULL;
       
   591 
       
   592             CleanupStack::PopAndDestroy( encodeTemp );
       
   593             encodeTemp = NULL;
       
   594             aStream.WriteL( KItemDateEnd );
       
   595             }       
       
   596         }
       
   597     }
   449 // --------------------------------------------------------------------------
   598 // --------------------------------------------------------------------------
   450 // CUpnpItemToXML::AsXmlEmptyL
   599 // CUpnpItemToXML::AsXmlEmptyL
   451 // Returns object's XML description. This version of the method is used to
   600 // Returns object's XML description. This version of the method is used to
   452 // create the XML with empty <res> tag.
   601 // create the XML with empty <res> tag.
   453 // (other items were commented in a header).
   602 // (other items were commented in a header).
   482     stream.WriteL( KItemTitleEnd() );
   631     stream.WriteL( KItemTitleEnd() );
   483     stream.WriteL( KItemClassBegin() );
   632     stream.WriteL( KItemClassBegin() );
   484     
   633     
   485     stream.WriteL( iItem->ObjectClass() );
   634     stream.WriteL( iItem->ObjectClass() );
   486     stream.WriteL( KItemClassEnd() );
   635     stream.WriteL( KItemClassEnd() );
   487     
   636 
   488     // Music meta data information
   637     FillMetaDataL(stream);    
   489     const TDesC8& artist = GetValueFromElement( KElementArtist ); 
       
   490     if ( artist != KNullDesC8 )
       
   491         {
       
   492         stream.WriteL( KItemArtistBegin );
       
   493         // xml encoding added
       
   494         encodeTemp = HBufC8::NewLC( artist.Length() );
       
   495         encodeTemp->Des().Copy( artist );
       
   496 
       
   497         tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
       
   498         CleanupStack::PushL( tempPtr );
       
   499 
       
   500         stream.WriteL( *tempPtr );
       
   501         CleanupStack::PopAndDestroy( tempPtr );
       
   502         tempPtr = NULL;
       
   503         
       
   504         CleanupStack::PopAndDestroy( encodeTemp );
       
   505         encodeTemp = NULL;
       
   506 
       
   507         stream.WriteL( KItemArtistEnd );
       
   508         }
       
   509     const TDesC8& creator = GetValueFromElement( KElementCreator ); 
       
   510     if ( creator != KNullDesC8 )
       
   511         {
       
   512         stream.WriteL( KItemCreatorBegin );
       
   513         // xml encoding added
       
   514         encodeTemp = HBufC8::NewLC( creator.Length() );
       
   515         encodeTemp->Des().Copy( creator );
       
   516 
       
   517         tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
       
   518         CleanupStack::PushL( tempPtr );
       
   519 
       
   520         stream.WriteL( *tempPtr );
       
   521         CleanupStack::PopAndDestroy( tempPtr );
       
   522         tempPtr = NULL;
       
   523         
       
   524         CleanupStack::PopAndDestroy( encodeTemp );
       
   525         encodeTemp = NULL;
       
   526 
       
   527         stream.WriteL( KItemCreatorEnd );        
       
   528         }
       
   529     const TDesC8& album = GetValueFromElement( KElementAlbum ); 
       
   530     if ( album != KNullDesC8 )
       
   531         {
       
   532         stream.WriteL( KItemAlbumBegin );
       
   533         // xml encoding added
       
   534         encodeTemp = HBufC8::NewLC( album.Length() );
       
   535         encodeTemp->Des().Copy( album );
       
   536         
       
   537         tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
       
   538         CleanupStack::PushL( tempPtr );
       
   539 
       
   540         stream.WriteL( *tempPtr );
       
   541         CleanupStack::PopAndDestroy( tempPtr );
       
   542         tempPtr = NULL;
       
   543     
       
   544         CleanupStack::PopAndDestroy( encodeTemp );
       
   545         encodeTemp = NULL;
       
   546         //stream.WriteL( Album() );
       
   547         stream.WriteL( KItemAlbumEnd );        
       
   548         }
       
   549     const TDesC8& genre = GetValueFromElement( KElementGenre );     
       
   550     if ( genre != KNullDesC8 )
       
   551         {
       
   552         stream.WriteL( KItemGenreBegin );
       
   553         // xml encoding added
       
   554         encodeTemp = HBufC8::NewLC( genre.Length() );
       
   555         encodeTemp->Des().Copy( genre );
       
   556 
       
   557         tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
       
   558         CleanupStack::PushL( tempPtr );
       
   559 
       
   560         stream.WriteL( *tempPtr );
       
   561         CleanupStack::PopAndDestroy( tempPtr );
       
   562         tempPtr = NULL;
       
   563     
       
   564         CleanupStack::PopAndDestroy( encodeTemp );
       
   565         encodeTemp = NULL;
       
   566         //stream.WriteL( Genre() );
       
   567         stream.WriteL( KItemGenreEnd );        
       
   568         }
       
   569     const TDesC8& albumarturi = GetValueFromElement( KElementAlbumArtUri );     
       
   570     if ( albumarturi != KNullDesC8 )
       
   571         {
       
   572         stream.WriteL( KItemAlbumArtURIBegin );
       
   573         // xml encoding added
       
   574         encodeTemp = HBufC8::NewLC( albumarturi.Length() );
       
   575         encodeTemp->Des().Copy( albumarturi );
       
   576 
       
   577         tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
       
   578         CleanupStack::PushL( tempPtr );
       
   579 
       
   580         stream.WriteL( *tempPtr );
       
   581         CleanupStack::PopAndDestroy( tempPtr );
       
   582         tempPtr = NULL;
       
   583     
       
   584         CleanupStack::PopAndDestroy( encodeTemp );
       
   585         encodeTemp = NULL;       
       
   586         stream.WriteL( KItemAlbumArtURIEnd );        
       
   587         }
       
   588     const TDesC8& date = GetValueFromElement( KElementDate );         
       
   589     if ( date != KNullDesC8 )
       
   590         {
       
   591         if( ValidateDateL( date ) )
       
   592             {
       
   593             stream.WriteL( KItemDateBegin );
       
   594             // xml encoding added
       
   595             encodeTemp = HBufC8::NewLC( date.Length() );
       
   596             encodeTemp->Des().Copy( date );
       
   597 
       
   598             tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
       
   599             CleanupStack::PushL( tempPtr );
       
   600 
       
   601             stream.WriteL( *tempPtr );
       
   602             CleanupStack::PopAndDestroy( tempPtr );
       
   603             tempPtr = NULL;
       
   604 
       
   605             CleanupStack::PopAndDestroy( encodeTemp );
       
   606             encodeTemp = NULL;
       
   607             stream.WriteL( KItemDateEnd );
       
   608             }       
       
   609         }
       
   610     
   638     
   611     // Create dlna compliant protocolinfo
   639     // Create dlna compliant protocolinfo
   612     const RUPnPElementsArray& elms = iItem->GetElements();
   640     const RUPnPElementsArray& elms = iItem->GetElements();
   613     CUpnpDlnaProtocolInfo* pInfo = NULL; 
   641     CUpnpDlnaProtocolInfo* pInfo = NULL; 
   614     HBufC8* duration  = NULL;
   642     HBufC8* duration  = NULL;
   618     for( TInt i = 0; i < elms.Count(); i++)
   646     for( TInt i = 0; i < elms.Count(); i++)
   619         {
   647         {
   620         if( elms[ i ]->Name() == KElementRes )
   648         if( elms[ i ]->Name() == KElementRes )
   621             {
   649             {
   622             const RUPnPAttributesArray& attr = elms[ i ]->GetAttributes();
   650             const RUPnPAttributesArray& attr = elms[ i ]->GetAttributes();
       
   651             //pInfo must be checked first
   623             for( TInt j = 0; j < attr.Count(); j++ )
   652             for( TInt j = 0; j < attr.Count(); j++ )
   624                 {
   653                 {
   625                 if( attr[ j ]->Name() == KAttributeProtocolInfo )
   654                 if( attr[ j ]->Name() == KAttributeProtocolInfo )
   626                     {
   655                     {
   627                     pInfo = CUpnpDlnaProtocolInfo::NewL( attr[ j ]->Value() );
   656                     pInfo = CUpnpDlnaProtocolInfo::NewL(
       
   657                             attr[ j ]->Value() );
   628                     if ( pInfo )
   658                     if ( pInfo )
   629                         {
   659                         {
   630                         CleanupStack::PushL( pInfo );
   660                         CleanupStack::PushL( pInfo );
   631                         info = HBufC8::NewLC( KBufLen );
   661                         info = HBufC8::NewLC( KBufLen );
       
   662 
       
   663                         info->Des().Copy( KItemPInfoEmptyDlna );
       
   664                         info->Des().Append( pInfo->ThirdField() ); // Third param )
       
   665                         info->Des().Append( KColon );
       
   666                         if( pInfo->PnParameter().Length() > 0 )
       
   667                             {
       
   668                             info->Des().Append( KDlnaPn );
       
   669                             info->Des().Append( pInfo->PnParameter() ); // Fourth param )
       
   670                             }
       
   671                         else
       
   672                             {
       
   673                             info->Des().Append( KAsterisk );
       
   674                             }   
       
   675                         break;
   632                         }
   676                         }
   633                     }
   677                     }
   634                 if ( attr[ j ]->Name() == KAttributeDuration )
   678                 }
       
   679             //if there is pInfo we can continue with other elements
       
   680                 if (pInfo)
   635                     {
   681                     {
   636                     duration= HBufC8::NewLC( attr[ j ]->Value().Length() );
   682                     for (TInt j = 0; j < attr.Count(); j++)
   637                     duration->Des().Copy( attr[ j ]->Value() );
   683                         {
       
   684                         if ( attr[ j ]->Name() == KAttributeDuration )
       
   685                             {
       
   686                             duration= HBufC8::NewLC( attr[ j ]->Value().Length() );
       
   687                             duration->Des().Copy( attr[ j ]->Value() );
       
   688                             info->Des().Append( KQuotationMark );
       
   689                             info->Des().Append( KItemDuration );
       
   690                             info->Des().Append( *duration );
       
   691                             CleanupStack::PopAndDestroy( duration );
       
   692                             duration = NULL;
       
   693                             }
       
   694                         if ( attr[ j ]->Name() == KAttributeSize )
       
   695                             {
       
   696                             size = HBufC8::NewLC( attr[ j ]->Value().Length() );
       
   697                             size->Des().Copy( attr[ j ]->Value() );
       
   698                             info->Des().Append( KQuotationMark );
       
   699                             info->Des().Append( KItemSize );
       
   700                             info->Des().Append( *size );
       
   701                             CleanupStack::PopAndDestroy( size );
       
   702                             size = NULL;
       
   703                             }
       
   704                         if ( attr[ j ]->Name() == KAttributeResolution )
       
   705                             {
       
   706                             resolution = HBufC8::NewLC( attr[ j ]->Value().Length() );
       
   707                             resolution->Des().Copy( attr[ j ]->Value() );
       
   708                             info->Des().Append( KQuotationMark );
       
   709                             info->Des().Append( KItemResolution );
       
   710                             info->Des().Append( *resolution );
       
   711                             CleanupStack::PopAndDestroy( resolution );
       
   712                             resolution = NULL;
       
   713                             }
       
   714                         }
   638                     }
   715                     }
   639                 if ( attr[ j ]->Name() == KAttributeSize )
       
   640                     {
       
   641                     size = HBufC8::NewLC( attr[ j ]->Value().Length() );
       
   642                     size->Des().Copy( attr[ j ]->Value() );
       
   643                     }
       
   644                 if ( attr[ j ]->Name() == KAttributeResolution )
       
   645                     {
       
   646                     resolution = HBufC8::NewLC( attr[ j ]->Value().Length() );
       
   647                     resolution->Des().Copy( attr[ j ]->Value() );
       
   648                     }
       
   649                 }
       
   650             i = elms.Count();
   716             i = elms.Count();
   651             }
   717             }
   652         }
   718         }
   653     
   719     
   654     if( pInfo )
   720     if( pInfo )
   655         {
   721         {
   656         info->Des().Copy( KItemPInfoEmptyDlna );
       
   657         info->Des().Append( pInfo->ThirdField() ); // Third param )
       
   658         info->Des().Append( KColon );
       
   659         if( pInfo->PnParameter().Length() > 0 )
       
   660             {
       
   661             info->Des().Append( KDlnaPn );
       
   662             info->Des().Append( pInfo->PnParameter() ); // Fourth param )
       
   663             }
       
   664         else
       
   665             {
       
   666             info->Des().Append( KAsterisk );
       
   667             }    
       
   668         if ( resolution )
       
   669             {
       
   670             info->Des().Append( KQuotationMark );
       
   671             info->Des().Append( KItemResolution );
       
   672             info->Des().Append( *resolution );
       
   673             CleanupStack::PopAndDestroy( resolution );
       
   674             resolution = NULL;
       
   675             }
       
   676         if ( duration )
       
   677             {
       
   678             info->Des().Append( KQuotationMark );
       
   679             info->Des().Append( KItemDuration );
       
   680             info->Des().Append( *duration );
       
   681             CleanupStack::PopAndDestroy( duration );
       
   682             duration = NULL;
       
   683             }
       
   684         if ( size )
       
   685             {
       
   686             info->Des().Append( KQuotationMark );
       
   687             info->Des().Append( KItemSize );
       
   688             info->Des().Append( *size );
       
   689             CleanupStack::PopAndDestroy( size );
       
   690             size = NULL;
       
   691             }
       
   692         
   722         
   693         info->Des().Append( KItemPInfoEnd2 );
   723         info->Des().Append( KItemPInfoEnd2 );
   694         stream.WriteL( *info );
   724         stream.WriteL( *info );
   695         CleanupStack::PopAndDestroy( info );
   725         CleanupStack::PopAndDestroy( info );
   696         CleanupStack::PopAndDestroy( pInfo );
   726         CleanupStack::PopAndDestroy( pInfo );
   715     }
   745     }
   716 
   746 
   717 // --------------------------------------------------------------------------
   747 // --------------------------------------------------------------------------
   718 // CUpnpItemToXML::AsResultArgumentL
   748 // CUpnpItemToXML::AsResultArgumentL
   719 // Returns object's XML description that is embedded inside a DIDL-LITE tag. 
   749 // Returns object's XML description that is embedded inside a DIDL-LITE tag. 
   720 // The <res> tag of xml description is empty.The returned value is xml encoded
   750 // The <res> tag of xml description is empty.The returned value is xml
   721 // can therefore be used for example when creating a CreateObject action.
   751 // encoded can therefore be used for example when creating a CreateObject
   722 // (other items were commented in a header).
   752 // action. (other items were commented in a header).
   723 // --------------------------------------------------------------------------
   753 // --------------------------------------------------------------------------
   724 HBufC8* CUpnpItemToXML::AsResultArgumentL()
   754 HBufC8* CUpnpItemToXML::AsResultArgumentL()
   725     {
   755     {
   726     __LOG( "CUpnpItemToXML::AsResultArgumentL" );
   756     __LOG( "CUpnpItemToXML::AsResultArgumentL" );
   727     
   757