15 #include <QStringList>
16 #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
17 #include <QStringConverter>
21 #include <QTextStream>
34 QTextStream &ts,
TaskTime ttLastNotified)
const
38 ts <<
"<?xml version=\"1.0\"?>" << Qt::endl
39 <<
"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">" << Qt::endl;
41 for (
auto *prop : std::as_const(
m_map))
43 if ( ttLastNotified < prop->m_ttLastChanged )
47 ts <<
"<e:property>" << Qt::endl;
48 ts <<
"<" << prop->m_sName <<
">";
49 ts << prop->ToString();
50 ts <<
"</" << prop->m_sName <<
">";
51 ts <<
"</e:property>" << Qt::endl;
55 ts <<
"</e:propertyset>" << Qt::endl;
66 QString sEventMethodName,
67 const QString &sSharePath) :
69 m_sEventMethodName(
std::move(sEventMethodName)),
70 m_nSubscriptionDuration(
103 LOG(VB_GENERAL, LOG_ERR,
"Exceeded maximum guarranteed range of "
104 "m_nHoldCount short [-128..127]");
105 LOG(VB_GENERAL, LOG_ERR,
106 "UPnP may not exhibit strange behavior or crash mythtv");
139 return QStringList(
"/" );
156 LOG(VB_UPNP, LOG_INFO, QString(
"Eventing::ProcessRequest - Method (%1)")
212 if ( sCallBack.length() != 0 )
218 if ( sSID.length() != 0 )
224 if ( sNT !=
"upnp:event" )
233 sCallBack = sCallBack.mid( 1, sCallBack.indexOf(
">") - 1);
236 if ( sTimeout.startsWith(
"Second-") )
239 auto nValue = std::chrono::seconds(sTimeout.section(
"-", 1).toInt(&ok));
267 if ( sSID.length() != 0 )
269 sSID = sSID.mid( 5 );
275 if (pInfo !=
nullptr)
302 if ((sCallBack.length() != 0) || (sNT.length() != 0))
308 sSID = sSID.mid( 5 );
325 auto tt = nowAsDuration<std::chrono::microseconds>();
338 if (tt < (*it)->m_ttExpires)
361 if (pInfo ==
nullptr)
365 QTextStream tsBody( &aBody, QIODevice::WriteOnly );
367 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
368 tsBody.setCodec(QTextCodec::codecForName(
"UTF-8"));
370 tsBody.setEncoding(QStringConverter::Utf8);
383 auto *pBuffer =
new QByteArray();
384 QTextStream tsMsg( pBuffer, QIODevice::WriteOnly );
386 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
387 tsMsg.setCodec(QTextCodec::codecForName(
"UTF-8"));
389 tsMsg.setEncoding(QStringConverter::Utf8);
396 int nPort = (pInfo->
m_qURL.port()>=0) ? pInfo->
m_qURL.port() : 80;
397 QString sHost = QString(
"%1:%2" ).arg( pInfo->
m_qURL.host() )
400 tsMsg <<
"NOTIFY " << pInfo->
m_qURL.path() <<
" HTTP/1.1\r\n";
401 tsMsg <<
"HOST: " << sHost <<
"\r\n";
402 tsMsg <<
"CONTENT-TYPE: \"text/xml\"\r\n";
403 tsMsg <<
"Content-Length: " << QString::number( aBody.size() ) <<
"\r\n";
404 tsMsg <<
"NT: upnp:event\r\n";
405 tsMsg <<
"NTS: upnp:propchange\r\n";
406 tsMsg <<
"SID: uuid:" << pInfo->
m_sUUID <<
"\r\n";
407 tsMsg <<
"SEQ: " << QString::number( pInfo->
m_nKey ) <<
"\r\n";
416 LOG(VB_UPNP, LOG_INFO,
417 QString(
"UPnp::Eventing::NotifySubscriber( %1 ) : %2 Variables")
418 .arg( sHost ).arg(nCount));
425 pEventTask->DecrRef();