14 #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
15 #include <QStringConverter>
19 #include <QTextStream>
26 inline QString
GetBool(
bool bVal ) {
return( (bVal) ?
"1" :
"0" ); }
37 const QString &sTitle,
38 const QString &sParentId )
99 QList<Property*> props;
116 const QString &sType )
121 if ((*it)->m_bMultiValue)
123 LOG(VB_UPNP, LOG_WARNING,
124 QString(
"SetPropValue(%1) called on property with bAllowMulti. "
125 "Only the last inserted property will be updated.").arg(sName));
127 (*it)->SetValue(sValue);
129 if (!sType.isEmpty())
130 (*it)->AddAttribute(
"type", sType );
134 LOG(VB_UPNP, LOG_WARNING,
135 QString(
"SetPropValue(%1) called with non-existent property.").arg(sName));
145 Properties::const_iterator it =
m_properties.find(sName);
149 if ((*it)->m_bMultiValue)
151 LOG(VB_UPNP, LOG_WARNING,
152 QString(
"GetPropValue(%1) called on property with bAllowMulti. "
153 "Only the last inserted property will be return."));
155 return (*it)->GetValue().toUtf8();
187 CDSObjects::iterator it;
194 if (pChild->
m_sId == sID)
207 auto *pRes =
new Resource( sProtocol, sURI );
265 bool ignoreChildren )
const
268 QTextStream os( &sXML, QIODevice::WriteOnly );
269 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
270 os.setCodec(QTextCodec::codecForName(
"UTF-8"));
272 os.setEncoding(QStringConverter::Utf8);
274 toXml(os, filter, ignoreChildren);
284 bool ignoreChildren )
const
286 QString sEndTag =
"";
314 if (filter.contains(
"*"))
321 if (bFilter && filter.contains(
"container#"))
324 os <<
"<container id=\"" <<
m_sId
328 if (!bFilter || filter.contains(
"@searchable"))
331 if (!bFilter || filter.contains(
"@childCount"))
334 if (!bFilter || filter.contains(
"@childContainerCount"))
337 os <<
"\" >" << Qt::endl;
339 sEndTag =
"</container>";
345 if (bFilter && filter.contains(
"item#"))
348 os <<
"<item id=\"" <<
m_sId
351 <<
"\" >" << Qt::endl;
360 os <<
"<dc:title>" <<
m_sTitle <<
"</dc:title>" << Qt::endl;
361 os <<
"<upnp:class>" <<
m_sClass <<
"</upnp:class>" << Qt::endl;
369 if (pProp->m_bRequired || (!pProp->GetValue().isEmpty()))
373 if (!pProp->m_sNameSpace.isEmpty())
374 sName = pProp->m_sNameSpace +
':' + pProp->m_sName;
376 sName = pProp->m_sName;
378 if (pProp->m_bRequired ||
382 bool filterAttributes =
true;
383 if (!bFilter || filter.contains(QString(
"%1#").arg(sName)))
384 filterAttributes =
false;
388 for (
const auto & attr : std::as_const(pProp->m_lstAttributes))
390 QString filterName = QString(
"%1@%2").arg(sName,
392 if (attr.m_bRequired || !filterAttributes ||
393 filter.contains(filterName))
394 os <<
" " << attr.m_sName <<
"=\"" << attr.m_sValue <<
"\"";
398 os << pProp->GetEncodedValue();
399 os <<
"</" << sName <<
">" << Qt::endl;
408 if (!bFilter || filter.contains(
"res"))
410 bool filterAttributes =
true;
411 if (!bFilter || filter.contains(
"res#"))
412 filterAttributes =
false;
415 os <<
"<res protocolInfo=\"" << resource->m_sProtocolInfo <<
"\" ";
418 for (
const auto & attr : std::as_const(resource->m_lstAttributes))
420 filterName = QString(
"res@%1").arg(attr.m_sName);
421 if (attr.m_bRequired || !filterAttributes ||
422 filter.contains(filterName))
423 os << attr.m_sName <<
"=\"" << attr.m_sValue <<
"\" ";
426 os <<
">" << resource->m_sURI;
427 os <<
"</res>" << Qt::endl;
438 cit->toXml(os, filter);
445 os << sEndTag << Qt::endl;
456 if (pObject ==
nullptr)
458 pObject =
new CDSObject( sId, sTitle, sParentId );
474 if (pObject ==
nullptr)
476 pObject =
new CDSObject( sId, sTitle, sParentId );
477 pObject->
m_sClass =
"object.container";
501 if (pObject ==
nullptr)
503 pObject =
new CDSObject( sId, sTitle, sParentId );
504 pObject->
m_sClass =
"object.item.audioItem";
507 CreateItem( sId, sTitle, sParentId, pObject );
527 if (pObject ==
nullptr)
529 pObject =
new CDSObject( sId, sTitle, sParentId );
530 pObject->
m_sClass =
"object.item.audioItem.musicTrack";
569 if (pObject ==
nullptr)
571 pObject =
new CDSObject( sId, sTitle, sParentId );
572 pObject->
m_sClass =
"object.item.audioItem.audioBroadcast";
590 if (pObject ==
nullptr)
592 pObject =
new CDSObject( sId, sTitle, sParentId );
593 pObject->
m_sClass =
"object.item.audioItem.audioBook";
609 if (pObject ==
nullptr)
611 pObject =
new CDSObject( sId, sTitle, sParentId );
612 pObject->
m_sClass =
"object.item.videoItem";
615 CreateItem( sId, sTitle, sParentId, pObject );
667 if (pObject ==
nullptr)
669 pObject =
new CDSObject( sId, sTitle, sParentId );
670 pObject->
m_sClass =
"object.item.videoItem.movie";
685 if (pObject ==
nullptr)
687 pObject =
new CDSObject( sId, sTitle, sParentId );
688 pObject->
m_sClass =
"object.item.videoItem.videoBroadcast";
703 if (pObject ==
nullptr)
705 pObject =
new CDSObject( sId, sTitle, sParentId );
706 pObject->
m_sClass =
"object.item.videoItem.musicVideoClip";
723 if (pObject ==
nullptr)
725 pObject =
new CDSObject( sId, sTitle, sParentId );
726 pObject->
m_sClass =
"object.item.imageItem";
729 CreateItem( sId, sTitle, sParentId, pObject );
748 if (pObject ==
nullptr)
750 pObject =
new CDSObject( sId, sTitle, sParentId );
751 pObject->
m_sClass =
"object.item.imageItem.photo";
765 if (pObject ==
nullptr)
767 pObject =
new CDSObject( sId, sTitle, sParentId );
768 pObject->
m_sClass =
"object.item.playlistItem";
771 CreateItem( sId, sTitle, sParentId, pObject );
787 if (pObject ==
nullptr)
789 pObject =
new CDSObject( sId, sTitle, sParentId );
790 pObject->
m_sClass =
"object.item.textItem";
793 CreateItem( sId, sTitle, sParentId, pObject );
814 if (pObject ==
nullptr)
816 pObject =
new CDSObject( sId, sTitle, sParentId );
817 pObject->
m_sClass =
"object.container.album";
841 if (pObject ==
nullptr)
843 pObject =
new CDSObject( sId, sTitle, sParentId );
844 pObject->
m_sClass =
"object.container.album.musicAlbum";
861 if (pObject ==
nullptr)
863 pObject =
new CDSObject( sId, sTitle, sParentId );
864 pObject->
m_sClass =
"object.container.album.photoAlbum";
876 if (pObject ==
nullptr)
878 pObject =
new CDSObject( sId, sTitle, sParentId );
879 pObject->
m_sClass =
"object.container.genre";
891 if (pObject ==
nullptr)
893 pObject =
new CDSObject( sId, sTitle, sParentId );
894 pObject->
m_sClass =
"object.container.genre.musicGenre";
906 if (pObject ==
nullptr)
908 pObject =
new CDSObject( sId, sTitle, sParentId );
909 pObject->
m_sClass =
"object.container.genre.movieGenre";
921 if (pObject ==
nullptr)
923 pObject =
new CDSObject( sId, sTitle, sParentId );
924 pObject->
m_sClass =
"object.container.playlistContainer";
944 if (pObject ==
nullptr)
946 pObject =
new CDSObject( sId, sTitle, sParentId );
947 pObject->
m_sClass =
"object.container.person";
961 if (pObject ==
nullptr)
963 pObject =
new CDSObject( sId, sTitle, sParentId );
964 pObject->
m_sClass =
"object.container.person.musicArtist";
979 if (pObject ==
nullptr)
981 pObject =
new CDSObject( sId, sTitle, sParentId );
982 pObject->
m_sClass =
"object.container.storageSystem";
1000 if (pObject ==
nullptr)
1002 pObject =
new CDSObject( sId, sTitle, sParentId );
1003 pObject->
m_sClass =
"object.container.storageVolume";
1020 if (pObject ==
nullptr)
1022 pObject =
new CDSObject( sId, sTitle, sParentId );
1023 pObject->
m_sClass =
"object.container.storageFolder";
1039 if (filter.contains(name, Qt::CaseInsensitive))
1046 QString dependentAttribute = QString(
"%1@").arg(name);
1047 QStringList matches = filter.filter(name, Qt::CaseInsensitive);
1048 QStringList::iterator it;
1049 for (it = matches.begin(); it != matches.end(); ++it)
1051 if ((*it).startsWith(dependentAttribute))