15 #include <QStringList>
16 #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
17 #include <QStringConverter>
21 #include <QTextStream>
29 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
31 #define QT_FLUSH flush
33 #define QT_ENDL Qt::endl
34 #define QT_FLUSH Qt::flush
42 QTextStream &ts,
TaskTime ttLastNotified)
const
46 ts <<
"<?xml version=\"1.0\"?>" <<
QT_ENDL
47 <<
"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">" <<
QT_ENDL;
49 for (
auto *prop : qAsConst(
m_map))
51 if ( ttLastNotified < prop->m_ttLastChanged )
55 ts <<
"<e:property>" <<
QT_ENDL;
56 ts <<
"<" << prop->m_sName <<
">";
57 ts << prop->ToString();
58 ts <<
"</" << prop->m_sName <<
">";
59 ts <<
"</e:property>" <<
QT_ENDL;
63 ts <<
"</e:propertyset>" <<
QT_ENDL;
74 QString sEventMethodName,
75 const QString &sSharePath) :
77 m_sEventMethodName(
std::move(sEventMethodName)),
78 m_nSubscriptionDuration(
111 LOG(VB_GENERAL, LOG_ERR,
"Exceeded maximum guarranteed range of "
112 "m_nHoldCount short [-128..127]");
113 LOG(VB_GENERAL, LOG_ERR,
114 "UPnP may not exhibit strange behavior or crash mythtv");
147 return QStringList(
"/" );
164 LOG(VB_UPNP, LOG_INFO, QString(
"Eventing::ProcessRequest - Method (%1)")
220 if ( sCallBack.length() != 0 )
226 if ( sSID.length() != 0 )
232 if ( sNT !=
"upnp:event" )
241 sCallBack = sCallBack.mid( 1, sCallBack.indexOf(
">") - 1);
244 if ( sTimeout.startsWith(
"Second-") )
247 auto nValue = std::chrono::seconds(sTimeout.section(
"-", 1).toInt(&ok));
275 if ( sSID.length() != 0 )
277 sSID = sSID.mid( 5 );
283 if (pInfo !=
nullptr)
310 if ((sCallBack.length() != 0) || (sNT.length() != 0))
316 sSID = sSID.mid( 5 );
333 auto tt = nowAsDuration<std::chrono::microseconds>();
346 if (tt < (*it)->m_ttExpires)
369 if (pInfo ==
nullptr)
373 QTextStream tsBody( &aBody, QIODevice::WriteOnly );
375 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
376 tsBody.setCodec(QTextCodec::codecForName(
"UTF-8"));
378 tsBody.setEncoding(QStringConverter::Utf8);
391 auto *pBuffer =
new QByteArray();
392 QTextStream tsMsg( pBuffer, QIODevice::WriteOnly );
394 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
395 tsMsg.setCodec(QTextCodec::codecForName(
"UTF-8"));
397 tsMsg.setEncoding(QStringConverter::Utf8);
404 int nPort = (pInfo->
m_qURL.port()>=0) ? pInfo->
m_qURL.port() : 80;
405 QString sHost = QString(
"%1:%2" ).arg( pInfo->
m_qURL.host() )
408 tsMsg <<
"NOTIFY " << pInfo->
m_qURL.path() <<
" HTTP/1.1\r\n";
409 tsMsg <<
"HOST: " << sHost <<
"\r\n";
410 tsMsg <<
"CONTENT-TYPE: \"text/xml\"\r\n";
411 tsMsg <<
"Content-Length: " << QString::number( aBody.size() ) <<
"\r\n";
412 tsMsg <<
"NT: upnp:event\r\n";
413 tsMsg <<
"NTS: upnp:propchange\r\n";
414 tsMsg <<
"SID: uuid:" << pInfo->
m_sUUID <<
"\r\n";
415 tsMsg <<
"SEQ: " << QString::number( pInfo->
m_nKey ) <<
"\r\n";
424 LOG(VB_UPNP, LOG_INFO,
425 QString(
"UPnp::Eventing::NotifySubscriber( %1 ) : %2 Variables")
426 .arg( sHost ).arg(nCount));
433 pEventTask->DecrRef();