14 #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
15 #include <QStringConverter>
19 #include <QTextStream>
26 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
28 #define QT_FLUSH flush
30 #define QT_ENDL Qt::endl
31 #define QT_FLUSH Qt::flush
34 inline QString
GetBool(
bool bVal ) {
return( (bVal) ?
"1" :
"0" ); }
45 const QString &sTitle,
46 const QString &sParentId )
107 QList<Property*> props;
124 const QString &sType )
129 if ((*it)->m_bMultiValue)
131 LOG(VB_UPNP, LOG_WARNING,
132 QString(
"SetPropValue(%1) called on property with bAllowMulti. "
133 "Only the last inserted property will be updated.").arg(sName));
135 (*it)->SetValue(sValue);
137 if (!sType.isEmpty())
138 (*it)->AddAttribute(
"type", sType );
141 LOG(VB_UPNP, LOG_WARNING,
142 QString(
"SetPropValue(%1) called with non-existent property.").arg(sName));
151 Properties::const_iterator it =
m_properties.find(sName);
155 if ((*it)->m_bMultiValue)
157 LOG(VB_UPNP, LOG_WARNING,
158 QString(
"GetPropValue(%1) called on property with bAllowMulti. "
159 "Only the last inserted property will be return."));
161 return (*it)->GetValue().toUtf8();
193 CDSObjects::iterator it;
200 if (pChild->
m_sId == sID)
213 auto *pRes =
new Resource( sProtocol, sURI );
271 bool ignoreChildren )
const
274 QTextStream os( &sXML, QIODevice::WriteOnly );
275 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
276 os.setCodec(QTextCodec::codecForName(
"UTF-8"));
278 os.setEncoding(QStringConverter::Utf8);
280 toXml(os, filter, ignoreChildren);
290 bool ignoreChildren )
const
292 QString sEndTag =
"";
320 if (filter.contains(
"*"))
327 if (bFilter && filter.contains(
"container#"))
330 os <<
"<container id=\"" <<
m_sId
334 if (!bFilter || filter.contains(
"@searchable"))
337 if (!bFilter || filter.contains(
"@childCount"))
340 if (!bFilter || filter.contains(
"@childContainerCount"))
345 sEndTag =
"</container>";
351 if (bFilter && filter.contains(
"item#"))
354 os <<
"<item id=\"" <<
m_sId
375 if (pProp->m_bRequired || (!pProp->GetValue().isEmpty()))
379 if (!pProp->m_sNameSpace.isEmpty())
380 sName = pProp->m_sNameSpace +
':' + pProp->m_sName;
382 sName = pProp->m_sName;
384 if (pProp->m_bRequired ||
388 bool filterAttributes =
true;
389 if (!bFilter || filter.contains(QString(
"%1#").arg(sName)))
390 filterAttributes =
false;
394 for (
const auto & attr : qAsConst(pProp->m_lstAttributes))
396 QString filterName = QString(
"%1@%2").arg(sName,
398 if (attr.m_bRequired || !filterAttributes ||
399 filter.contains(filterName))
400 os <<
" " << attr.m_sName <<
"=\"" << attr.m_sValue <<
"\"";
404 os << pProp->GetEncodedValue();
405 os <<
"</" << sName <<
">" <<
QT_ENDL;
414 if (!bFilter || filter.contains(
"res"))
416 bool filterAttributes =
true;
417 if (!bFilter || filter.contains(
"res#"))
418 filterAttributes =
false;
421 os <<
"<res protocolInfo=\"" << resource->m_sProtocolInfo <<
"\" ";
424 for (
const auto & attr : qAsConst(resource->m_lstAttributes))
426 filterName = QString(
"res@%1").arg(attr.m_sName);
427 if (attr.m_bRequired || !filterAttributes ||
428 filter.contains(filterName))
429 os << attr.m_sName <<
"=\"" << attr.m_sValue <<
"\" ";
432 os <<
">" << resource->m_sURI;
444 cit->toXml(os, filter);
462 if (pObject ==
nullptr)
464 pObject =
new CDSObject( sId, sTitle, sParentId );
480 if (pObject ==
nullptr)
482 pObject =
new CDSObject( sId, sTitle, sParentId );
483 pObject->
m_sClass =
"object.container";
507 if (pObject ==
nullptr)
509 pObject =
new CDSObject( sId, sTitle, sParentId );
510 pObject->
m_sClass =
"object.item.audioItem";
513 CreateItem( sId, sTitle, sParentId, pObject );
533 if (pObject ==
nullptr)
535 pObject =
new CDSObject( sId, sTitle, sParentId );
536 pObject->
m_sClass =
"object.item.audioItem.musicTrack";
575 if (pObject ==
nullptr)
577 pObject =
new CDSObject( sId, sTitle, sParentId );
578 pObject->
m_sClass =
"object.item.audioItem.audioBroadcast";
596 if (pObject ==
nullptr)
598 pObject =
new CDSObject( sId, sTitle, sParentId );
599 pObject->
m_sClass =
"object.item.audioItem.audioBook";
615 if (pObject ==
nullptr)
617 pObject =
new CDSObject( sId, sTitle, sParentId );
618 pObject->
m_sClass =
"object.item.videoItem";
621 CreateItem( sId, sTitle, sParentId, pObject );
673 if (pObject ==
nullptr)
675 pObject =
new CDSObject( sId, sTitle, sParentId );
676 pObject->
m_sClass =
"object.item.videoItem.movie";
691 if (pObject ==
nullptr)
693 pObject =
new CDSObject( sId, sTitle, sParentId );
694 pObject->
m_sClass =
"object.item.videoItem.videoBroadcast";
709 if (pObject ==
nullptr)
711 pObject =
new CDSObject( sId, sTitle, sParentId );
712 pObject->
m_sClass =
"object.item.videoItem.musicVideoClip";
729 if (pObject ==
nullptr)
731 pObject =
new CDSObject( sId, sTitle, sParentId );
732 pObject->
m_sClass =
"object.item.imageItem";
735 CreateItem( sId, sTitle, sParentId, pObject );
754 if (pObject ==
nullptr)
756 pObject =
new CDSObject( sId, sTitle, sParentId );
757 pObject->
m_sClass =
"object.item.imageItem.photo";
771 if (pObject ==
nullptr)
773 pObject =
new CDSObject( sId, sTitle, sParentId );
774 pObject->
m_sClass =
"object.item.playlistItem";
777 CreateItem( sId, sTitle, sParentId, pObject );
793 if (pObject ==
nullptr)
795 pObject =
new CDSObject( sId, sTitle, sParentId );
796 pObject->
m_sClass =
"object.item.textItem";
799 CreateItem( sId, sTitle, sParentId, pObject );
820 if (pObject ==
nullptr)
822 pObject =
new CDSObject( sId, sTitle, sParentId );
823 pObject->
m_sClass =
"object.container.album";
847 if (pObject ==
nullptr)
849 pObject =
new CDSObject( sId, sTitle, sParentId );
850 pObject->
m_sClass =
"object.container.album.musicAlbum";
867 if (pObject ==
nullptr)
869 pObject =
new CDSObject( sId, sTitle, sParentId );
870 pObject->
m_sClass =
"object.container.album.photoAlbum";
882 if (pObject ==
nullptr)
884 pObject =
new CDSObject( sId, sTitle, sParentId );
885 pObject->
m_sClass =
"object.container.genre";
897 if (pObject ==
nullptr)
899 pObject =
new CDSObject( sId, sTitle, sParentId );
900 pObject->
m_sClass =
"object.container.genre.musicGenre";
912 if (pObject ==
nullptr)
914 pObject =
new CDSObject( sId, sTitle, sParentId );
915 pObject->
m_sClass =
"object.container.genre.movieGenre";
927 if (pObject ==
nullptr)
929 pObject =
new CDSObject( sId, sTitle, sParentId );
930 pObject->
m_sClass =
"object.container.playlistContainer";
950 if (pObject ==
nullptr)
952 pObject =
new CDSObject( sId, sTitle, sParentId );
953 pObject->
m_sClass =
"object.container.person";
967 if (pObject ==
nullptr)
969 pObject =
new CDSObject( sId, sTitle, sParentId );
970 pObject->
m_sClass =
"object.container.person.musicArtist";
985 if (pObject ==
nullptr)
987 pObject =
new CDSObject( sId, sTitle, sParentId );
988 pObject->
m_sClass =
"object.container.storageSystem";
1006 if (pObject ==
nullptr)
1008 pObject =
new CDSObject( sId, sTitle, sParentId );
1009 pObject->
m_sClass =
"object.container.storageVolume";
1026 if (pObject ==
nullptr)
1028 pObject =
new CDSObject( sId, sTitle, sParentId );
1029 pObject->
m_sClass =
"object.container.storageFolder";
1045 if (filter.contains(name, Qt::CaseInsensitive))
1052 QString dependentAttribute = QString(
"%1@").arg(name);
1053 QStringList matches = filter.filter(name, Qt::CaseInsensitive);
1054 QStringList::iterator it;
1055 for (it = matches.begin(); it != matches.end(); ++it)
1057 if ((*it).startsWith(dependentAttribute))