21 #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
22 #include <QStringConverter>
24 #include <QTextStream>
30 #include "libmythbase/mythconfig.h"
36 #include "libmythbase/mythversion.h"
59 qRegisterMetaType<Preformat*>(
"Preformat");
60 qRegisterMetaType<V2MachineInfo*>(
"V2MachineInfo");
61 qRegisterMetaType<V2BackendStatus*>(
"V2BackendStatus");
62 qRegisterMetaType<V2Encoder*>(
"V2Encoder");
63 qRegisterMetaType<V2Program*>(
"V2Program");
64 qRegisterMetaType<V2Frontend*>(
"V2Frontend");
65 qRegisterMetaType<V2StorageGroup*>(
"V2StorageGroup");
66 qRegisterMetaType<V2Job*>(
"V2Job");
67 qRegisterMetaType<V2ChannelInfo*>(
"V2ChannelInfo");
68 qRegisterMetaType<V2RecordingInfo*>(
"V2RecordingInfo");
69 qRegisterMetaType<V2ArtworkInfoList*>(
"V2ArtworkInfoList");
70 qRegisterMetaType<V2ArtworkInfo*>(
"V2ArtworkInfo");
71 qRegisterMetaType<V2CastMemberList*>(
"V2CastMemberList");
72 qRegisterMetaType<V2CastMember*>(
"V2CastMember");
73 qRegisterMetaType<V2Input*>(
"V2Input");
74 qRegisterMetaType<V2Backend*>(
"V2Backend");
102 QDomDocument doc(
"Status" );
104 QDomProcessingInstruction encoding =
105 doc.createProcessingInstruction(
"xml",
106 R
"(version="1.0" encoding="UTF-8")");
107 doc.appendChild(encoding);
110 pResult->setmimetype(
"application/xml");
111 pResult->setbuffer(doc.toString());
118 QDomDocument doc(
"Status" );
121 QTextStream stream( &html );
124 pResult->setmimetype(
"text/html");
125 pResult->setbuffer(html);
148 pStatus->setVersion ( MYTH_BINARY_VERSION );
149 pStatus->setProtoVer ( MYTH_PROTO_VERSION );
169 backend = pStatus->AddNewBackend();
171 backend->setName(thisHost);
176 backend->setType(
"Master");
177 QStringList backends;
179 for (
const QString&
hostname : std::as_const(backends))
184 backend = pStatus->AddNewBackend();
186 backend->setType(
"Slave");
196 backend->setType(
"Slave");
199 backend = pStatus->AddNewBackend();
200 backend->setName(masterhost);
201 backend->setIP(masterip);
202 backend->setType(
"Master");
206 QMap<int, JobQueueEntry> jobs;
207 QMap<int, JobQueueEntry>::Iterator it;
213 for (it = jobs.begin(); it != jobs.end(); ++it)
215 ProgramInfo pginfo((*it).chanid, (*it).recstartts);
219 V2Job * pJob = pStatus->AddNewJob();
221 pJob->setId( (*it).id );
222 pJob->setChanId((*it).chanid );
223 pJob->setStartTime( (*it).recstartts);
224 pJob->setStartTs( (*it).startts );
225 pJob->setInsertTime((*it).inserttime);
226 pJob->setType( (*it).type );
228 pJob->setCmds( (*it).cmds );
229 pJob->setFlags( (*it).flags );
230 pJob->setStatus( (*it).status );
232 pJob->setStatusTime( (*it).statustime);
233 pJob->setSchedRunTime( (*it).schedruntime);
234 pJob->setArgs( (*it).args );
235 if ((*it).hostname.isEmpty())
236 pJob->setHostName( QObject::tr(
"master"));
238 pJob->setHostName((*it).hostname);
239 pJob->setComment((*it).comment);
249 if (rgdAverages[0] != -1)
251 pMachineInfo->setLoadAvg1(rgdAverages[0]);
252 pMachineInfo->setLoadAvg2(rgdAverages[1]);
253 pMachineInfo->setLoadAvg3(rgdAverages[2]);
257 QDateTime GuideDataThrough;
259 query.
prepare(
"SELECT MAX(endtime) FROM program WHERE manualid = 0;");
264 pMachineInfo->setGuideStart
266 pMachineInfo->setGuideEnd(
268 pMachineInfo->setGuideStatus(
272 pMachineInfo->setGuideNext(
276 if (!GuideDataThrough.isNull())
279 pMachineInfo->setGuideThru(GuideDataThrough);
280 pMachineInfo->setGuideDays(qdtNow.daysTo(GuideDataThrough));
285 if ((!info_script.isEmpty()) && (info_script !=
"none"))
292 LOG(VB_GENERAL, LOG_ERR,
293 QString(
"Error running miscellaneous "
294 "status information script: %1").arg(info_script));
297 QByteArray input = ms.
ReadAll();
298 pStatus->setMiscellaneous(QString(input));
314 QStringList::const_iterator sit = strlist.cbegin();
315 while (sit != strlist.cend())
318 directory = *(sit++);
319 isLocalstr = *(sit++);
323 long long iTotal = (*(sit++)).toLongLong();
324 long long iUsed = (*(sit++)).toLongLong();;
325 long long iAvail = iTotal - iUsed;
331 group->setId(QString(fsID));
332 group->setTotal((
int)(iTotal>>10));
333 group->setUsed((
int)(iUsed>>10));
334 group->setFree((
int)(iAvail>>10));
335 group->setDirectory(directory);
339 long long iLiveTV = -1;
340 long long iDeleted = -1;
341 long long iExpirable = -1;
343 query.
prepare(
"SELECT SUM(filesize) FROM recorded "
344 " WHERE recgroup = :RECGROUP;");
349 iLiveTV = query.
value(0).toLongLong();
354 iDeleted = query.
value(0).toLongLong();
356 query.
prepare(
"SELECT SUM(filesize) FROM recorded "
357 " WHERE autoexpire = 1 "
358 " AND recgroup NOT IN ('LiveTV', 'Deleted');");
361 iExpirable = query.
value(0).toLongLong();
363 group->setLiveTV( (
int)(iLiveTV>>20) );
364 group->setDeleted( (
int)(iDeleted>>20) );
365 group->setExpirable ( (
int)(iExpirable>>20) );
377 QDomElement root = pDoc->createElement(
"Status");
378 pDoc->appendChild(root);
382 root.setAttribute(
"time" ,
384 root.setAttribute(
"ISODate" , qdtNow.toString(
Qt::ISODate) );
385 root.setAttribute(
"version" , MYTH_BINARY_VERSION );
386 root.setAttribute(
"protoVer", MYTH_PROTO_VERSION );
390 QDomElement encoders = pDoc->createElement(
"Encoders");
391 root.appendChild(encoders);
400 if (elink !=
nullptr)
402 TVState state = elink->GetState();
403 isLocal = elink->IsLocal();
405 QDomElement encoder = pDoc->createElement(
"Encoder");
406 encoders.appendChild(encoder);
408 encoder.setAttribute(
"id" , elink->GetInputID() );
409 encoder.setAttribute(
"local" ,
static_cast<int>(isLocal));
410 encoder.setAttribute(
"connected" ,
static_cast<int>(elink->IsConnected()));
411 encoder.setAttribute(
"state" , state );
412 encoder.setAttribute(
"sleepstatus" , elink->GetSleepStatus() );
418 encoder.setAttribute(
"hostname", elink->GetHostName());
420 encoder.setAttribute(
"devlabel",
423 if (elink->IsConnected())
451 encoders.setAttribute(
"count", numencoders);
455 QDomElement scheduled = pDoc->createElement(
"Scheduled");
456 root.appendChild(scheduled);
463 unsigned int iNum = 10;
464 unsigned int iNumRecordings = 0;
466 auto itProg = recordingList.begin();
467 for (; (itProg != recordingList.end()) && iNumRecordings < iNum; ++itProg)
470 ((*itProg)->GetRecordingStartTime() >=
478 while (!recordingList.empty())
482 recordingList.pop_back();
485 scheduled.setAttribute(
"count", iNumRecordings);
489 QDomElement frontends = pDoc->createElement(
"Frontends");
490 root.appendChild(frontends);
493 "urn:schemas-mythtv-org:service:MythFrontend:1");
501 frontends.setAttribute(
"count", map.size() );
502 for (
const auto & entry : std::as_const(map))
504 QDomElement fe = pDoc->createElement(
"Frontend");
505 frontends.appendChild(fe);
506 QUrl url(entry->m_sLocation);
507 fe.setAttribute(
"name", url.host());
508 fe.setAttribute(
"url", url.toString(QUrl::RemovePath));
515 QDomElement backends = pDoc->createElement(
"Backends");
516 root.appendChild(backends);
526 QDomElement mbe = pDoc->createElement(
"Backend");
527 backends.appendChild(mbe);
528 mbe.setAttribute(
"type",
"Master");
529 mbe.setAttribute(
"name", masterhost);
530 mbe.setAttribute(
"url" , masterip +
":" + QString::number(masterport));
534 "urn:schemas-mythtv-org:device:SlaveMediaServer:1");
538 QString ipaddress = QString();
547 for (
const auto & entry : std::as_const(map))
549 QUrl url(entry->m_sLocation);
550 if (url.host() != ipaddress)
553 QDomElement mbe = pDoc->createElement(
"Backend");
554 backends.appendChild(mbe);
555 mbe.setAttribute(
"type",
"Slave");
556 mbe.setAttribute(
"name", url.host());
557 mbe.setAttribute(
"url" , url.toString(QUrl::RemovePath));
563 backends.setAttribute(
"count", numbes);
567 QDomElement queue = pDoc->createElement(
"JobQueue");
568 root.appendChild(queue);
570 QMap<int, JobQueueEntry> jobs;
571 QMap<int, JobQueueEntry>::Iterator it;
577 for (it = jobs.begin(); it != jobs.end(); ++it)
579 ProgramInfo pginfo((*it).chanid, (*it).recstartts);
583 QDomElement job = pDoc->createElement(
"Job");
584 queue.appendChild(job);
586 job.setAttribute(
"id" , (*it).id );
587 job.setAttribute(
"chanId" , (*it).chanid );
588 job.setAttribute(
"startTime" ,
590 job.setAttribute(
"startTs" , (*it).startts );
591 job.setAttribute(
"insertTime",
593 job.setAttribute(
"type" , (*it).type );
594 job.setAttribute(
"cmds" , (*it).cmds );
595 job.setAttribute(
"flags" , (*it).flags );
596 job.setAttribute(
"status" , (*it).status );
597 job.setAttribute(
"statusTime",
599 job.setAttribute(
"schedTime" ,
601 job.setAttribute(
"args" , (*it).args );
603 if ((*it).hostname.isEmpty())
604 job.setAttribute(
"hostname", QObject::tr(
"master"));
606 job.setAttribute(
"hostname",(*it).hostname);
608 QDomText textNode = pDoc->createTextNode((*it).comment);
609 job.appendChild(textNode);
614 queue.setAttribute(
"count", jobs.size() );
618 QDomElement mInfo = pDoc->createElement(
"MachineInfo");
619 QDomElement storage = pDoc->createElement(
"Storage" );
620 QDomElement load = pDoc->createElement(
"Load" );
621 QDomElement guide = pDoc->createElement(
"Guide" );
623 root.appendChild (mInfo );
624 mInfo.appendChild(storage);
625 mInfo.appendChild(load );
626 mInfo.appendChild(guide );
643 QList<QDomElement> fsXML;
644 QStringList::const_iterator sit = strlist.cbegin();
645 while (sit != strlist.cend())
648 directory = *(sit++);
649 isLocalstr = *(sit++);
653 long long iTotal = (*(sit++)).toLongLong();
654 long long iUsed = (*(sit++)).toLongLong();;
655 long long iAvail = iTotal - iUsed;
660 QDomElement group = pDoc->createElement(
"Group");
662 group.setAttribute(
"id" , fsID );
663 group.setAttribute(
"total", (
int)(iTotal>>10) );
664 group.setAttribute(
"used" , (
int)(iUsed>>10) );
665 group.setAttribute(
"free" , (
int)(iAvail>>10) );
666 group.setAttribute(
"dir" , directory );
670 long long iLiveTV = -1;
671 long long iDeleted = -1;
672 long long iExpirable = -1;
674 query.
prepare(
"SELECT SUM(filesize) FROM recorded "
675 " WHERE recgroup = :RECGROUP;");
680 iLiveTV = query.
value(0).toLongLong();
685 iDeleted = query.
value(0).toLongLong();
687 query.
prepare(
"SELECT SUM(filesize) FROM recorded "
688 " WHERE autoexpire = 1 "
689 " AND recgroup NOT IN ('LiveTV', 'Deleted');");
692 iExpirable = query.
value(0).toLongLong();
694 group.setAttribute(
"livetv", (
int)(iLiveTV>>20) );
695 group.setAttribute(
"deleted", (
int)(iDeleted>>20) );
696 group.setAttribute(
"expirable", (
int)(iExpirable>>20) );
705 storage.appendChild(total);
706 int num_elements = fsXML.size();
707 for (
int fs_index = 0; fs_index < num_elements; fs_index++)
709 storage.appendChild(fsXML[fs_index]);
715 load.setAttribute(
"avg1", 0);
716 load.setAttribute(
"avg2", 1);
717 load.setAttribute(
"avg3", 2);
720 if (rgdAverages[0] != -1)
722 load.setAttribute(
"avg1", rgdAverages[0]);
723 load.setAttribute(
"avg2", rgdAverages[1]);
724 load.setAttribute(
"avg3", rgdAverages[2]);
730 QDateTime GuideDataThrough;
733 query.
prepare(
"SELECT MAX(endtime) FROM program WHERE manualid = 0;");
740 guide.setAttribute(
"start",
742 guide.setAttribute(
"end",
744 guide.setAttribute(
"status",
748 guide.setAttribute(
"next",
752 if (!GuideDataThrough.isNull())
754 guide.setAttribute(
"guideThru",
756 guide.setAttribute(
"guideDays", qdtNow.daysTo(GuideDataThrough));
762 if ((!info_script.isEmpty()) && (info_script !=
"none"))
764 QDomElement misc = pDoc->createElement(
"Miscellaneous");
765 root.appendChild(misc);
772 LOG(VB_GENERAL, LOG_ERR,
773 QString(
"Error running miscellaneous "
774 "status information script: %1").arg(info_script));
778 QByteArray input = ms.
ReadAll();
780 QStringList
output = QString(input).split(
'\n',
782 for (
const auto & line : std::as_const(
output))
784 QDomElement
info = pDoc->createElement(
"Information");
786 QStringList list = line.split(
"[]:[]");
787 unsigned int size = list.size();
788 unsigned int hasAttributes = 0;
790 if ((size > 0) && (!list[0].isEmpty()))
792 info.setAttribute(
"display", list[0]);
795 if ((size > 1) && (!list[1].isEmpty()))
797 info.setAttribute(
"name", list[1]);
800 if ((size > 2) && (!list[2].isEmpty()))
802 info.setAttribute(
"value", list[2]);
806 if (hasAttributes > 0)
807 misc.appendChild(
info);
818 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
819 os.setCodec(
"UTF-8");
821 os.setEncoding(QStringConverter::Utf8);
826 QDomElement docElem = pDoc->documentElement();
828 os <<
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
829 <<
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n"
830 <<
"<html xmlns=\"http://www.w3.org/1999/xhtml\""
831 <<
" xml:lang=\"en\" lang=\"en\">\r\n"
833 <<
" <meta http-equiv=\"Content-Type\""
834 <<
"content=\"text/html; charset=UTF-8\" />\r\n"
835 <<
" <link rel=\"stylesheet\" href=\"/css/Status.css\" type=\"text/css\">\r\n"
836 <<
" <title>MythTV Status - "
840 << docElem.attribute(
"version", MYTH_BINARY_VERSION ) <<
"</title>\r\n"
842 <<
"<body bgcolor=\"#fff\">\r\n"
843 <<
"<div class=\"status\">\r\n"
844 <<
" <h1 class=\"status\">MythTV Status</h1>\r\n";
848 QDomNode node = docElem.namedItem(
"Encoders" );
855 node = docElem.namedItem(
"Scheduled" );
862 node = docElem.namedItem(
"Frontends" );
869 node = docElem.namedItem(
"Backends" );
876 node = docElem.namedItem(
"JobQueue" );
883 node = docElem.namedItem(
"MachineInfo" );
890 node = docElem.namedItem(
"Miscellaneous" );
895 os <<
"\r\n</div>\r\n</body>\r\n</html>\r\n";
905 int nNumEncoders = 0;
907 if (encoders.isNull())
910 os <<
" <div class=\"content\">\r\n"
911 <<
" <h2 class=\"status\">Encoder Status</h2>\r\n";
913 QDomNode node = encoders.firstChild();
915 while (!node.isNull())
917 QDomElement e = node.toElement();
921 if (e.tagName() ==
"Encoder")
923 QString sIsLocal = (e.attribute(
"local" ,
"remote" )==
"1")
924 ?
"local" :
"remote";
925 QString sCardId = e.attribute(
"id" ,
"0" );
926 QString sHostName = e.attribute(
"hostname" ,
"Unknown");
927 bool bConnected=
static_cast<bool>(e.attribute(
"connected",
"0" ).toInt());
929 bool bIsLowOnFreeSpace=
static_cast<bool>(e.attribute(
"lowOnFreeSpace",
"0").toInt());
931 QString sDevlabel = e.attribute(
"devlabel",
"[ UNKNOWN ]");
933 os <<
" Encoder " << sCardId <<
" " << sDevlabel
934 <<
" is " << sIsLocal <<
" on " << sHostName;
936 if ((sIsLocal ==
"remote") && !bConnected)
943 os <<
" (currently asleep).<br />";
945 os <<
" (currently not connected).<br />";
947 node = node.nextSibling();
958 os <<
" and is watching Live TV";
963 os <<
" and is recording";
967 os <<
" and is not recording.";
973 QDomNode tmpNode = e.namedItem(
"Program" );
975 if (!tmpNode.isNull())
977 QDomElement program = tmpNode.toElement();
979 if (!program.isNull())
981 os <<
" '" << program.attribute(
"title",
"Unknown" ) <<
"'";
985 tmpNode = program.namedItem(
"Channel" );
987 if (!tmpNode.isNull())
989 QDomElement channel = tmpNode.toElement();
991 if (!channel.isNull())
993 << channel.attribute(
"callSign",
"unknown" );
998 tmpNode = program.namedItem(
"Recording" );
1000 if (!tmpNode.isNull())
1002 QDomElement recording = tmpNode.toElement();
1004 if (!recording.isNull())
1007 recording.attribute(
"recEndTs",
"" ));
1009 os <<
". This recording ";
1015 os <<
"scheduled to end at "
1025 if (bIsLowOnFreeSpace)
1027 os <<
" <strong>WARNING</strong>:"
1028 <<
" This backend is low on free disk space!";
1035 node = node.nextSibling();
1038 os <<
" </div>\r\n\r\n";
1040 return( nNumEncoders );
1051 if (scheduled.isNull())
1054 int nNumRecordings= scheduled.attribute(
"count",
"0" ).toInt();
1056 os <<
" <div class=\"content\">\r\n"
1057 <<
" <h2 class=\"status\">Schedule</h2>\r\n";
1059 if (nNumRecordings == 0)
1061 os <<
" There are no shows scheduled for recording.\r\n"
1066 os <<
" The next " << nNumRecordings <<
" show" << (nNumRecordings == 1 ?
"" :
"s" )
1067 <<
" that " << (nNumRecordings == 1 ?
"is" :
"are")
1068 <<
" scheduled for recording:\r\n";
1070 os <<
" <div class=\"schedule\">\r\n";
1074 QDomNode node = scheduled.firstChild();
1076 while (!node.isNull())
1078 QDomElement e = node.toElement();
1082 QDomNode recNode = e.namedItem(
"Recording" );
1083 QDomNode chanNode = e.namedItem(
"Channel" );
1085 if ((e.tagName() ==
"Program") && !recNode.isNull() &&
1088 QDomElement r = recNode.toElement();
1089 QDomElement c = chanNode.toElement();
1091 QString sTitle = e.attribute(
"title" ,
"" );
1092 QString sSubTitle = e.attribute(
"subTitle",
"" );
1098 int nPreRollSecs = r.attribute(
"preRollSeconds",
"0" ).toInt();
1099 int nEncoderId = r.attribute(
"encoderId" ,
"0" ).toInt();
1100 QString sProfile = r.attribute(
"recProfile" ,
"" );
1101 QString sChanName = c.attribute(
"channelName" ,
"" );
1104 QDomText text = e.firstChild().toText();
1106 sDesc = text.nodeValue();
1110 int nTotalSecs = qdtNow.secsTo( recStartTs ) - nPreRollSecs;
1116 int nTotalDays = nTotalSecs / 86400;
1117 int nTotalHours = (nTotalSecs / 3600)
1118 - (nTotalDays * 24);
1119 int nTotalMins = (nTotalSecs / 60) % 60;
1121 QString sTimeToStart =
"in";
1123 sTimeToStart += QObject::tr(
" %n day(s),",
"", nTotalDays );
1124 sTimeToStart += QObject::tr(
" %n hour(s) and",
"", nTotalHours);
1125 sTimeToStart += QObject::tr(
" %n minute(s)",
"", nTotalMins);
1127 if ( nTotalHours == 0 && nTotalMins == 0)
1128 sTimeToStart = QObject::tr(
"within one minute",
"Recording starting");
1130 if ( nTotalSecs < 0)
1131 sTimeToStart = QObject::tr(
"soon",
"Recording starting");
1135 os <<
" <a href=\"#\">";
1143 os <<
"Encoder " << nEncoderId <<
" - ";
1145 os << sChanName <<
" - " << sTitle <<
"<br />"
1146 <<
"<span><strong>" << sTitle <<
"</strong> ("
1150 if ( !sSubTitle.isEmpty())
1151 os <<
"<em>" << sSubTitle <<
"</em><br /><br />";
1153 if ( airDate.isValid())
1155 os <<
"Orig. Airdate: "
1161 os << sDesc <<
"<br /><br />"
1162 <<
"This recording will start " << sTimeToStart
1163 <<
" using encoder " << nEncoderId <<
" with the '"
1164 << sProfile <<
"' profile.</span></a><hr />\r\n";
1168 node = node.nextSibling();
1170 os <<
" </div>\r\n";
1171 os <<
" </div>\r\n\r\n";
1173 return( nNumRecordings );
1182 if (frontends.isNull())
1185 int nNumFES= frontends.attribute(
"count",
"0" ).toInt();
1191 os <<
" <div class=\"content\">\r\n"
1192 <<
" <h2 class=\"status\">Frontends</h2>\r\n";
1194 QDomNode node = frontends.firstChild();
1195 while (!node.isNull())
1197 QDomElement e = node.toElement();
1201 QString name = e.attribute(
"name" ,
"" );
1202 QString url = e.attribute(
"url" ,
"" );
1203 os << name <<
" (<a href=\"" << url <<
"\">Status page</a>)<br />";
1206 node = node.nextSibling();
1209 os <<
" </div>\r\n\r\n";
1220 if (backends.isNull())
1223 int nNumBES= backends.attribute(
"count",
"0" ).toInt();
1229 os <<
" <div class=\"content\">\r\n"
1230 <<
" <h2 class=\"status\">Other Backends</h2>\r\n";
1232 QDomNode node = backends.firstChild();
1233 while (!node.isNull())
1235 QDomElement e = node.toElement();
1239 QString
type = e.attribute(
"type",
"" );
1240 QString name = e.attribute(
"name" ,
"" );
1241 QString url = e.attribute(
"url" ,
"" );
1242 os <<
type <<
": " << name <<
" (<a href=\"" << url <<
"\">Status page</a>)<br />";
1245 node = node.nextSibling();
1248 os <<
" </div>\r\n\r\n";
1262 int nNumJobs= jobs.attribute(
"count",
"0" ).toInt();
1264 os <<
" <div class=\"content\">\r\n"
1265 <<
" <h2 class=\"status\">Job Queue</h2>\r\n";
1269 QString statusColor;
1272 os <<
" Jobs currently in Queue or recently ended:\r\n<br />"
1273 <<
" <div class=\"schedule\">\r\n";
1276 QDomNode node = jobs.firstChild();
1278 while (!node.isNull())
1280 QDomElement e = node.toElement();
1284 QDomNode progNode = e.namedItem(
"Program" );
1286 if ((e.tagName() ==
"Job") && !progNode.isNull() )
1288 QDomElement
p = progNode.toElement();
1290 QDomNode recNode =
p.namedItem(
"Recording" );
1291 QDomNode chanNode =
p.namedItem(
"Channel" );
1293 QDomElement r = recNode.toElement();
1294 QDomElement c = chanNode.toElement();
1296 int nType = e.attribute(
"type" ,
"0" ).toInt();
1297 int nStatus = e.attribute(
"status",
"0" ).toInt();
1302 statusColor =
" class=\"jobaborted\"";
1307 statusColor =
" class=\"joberrored\"";
1308 jobColor =
" class=\"joberrored\"";
1312 statusColor =
" class=\"jobfinished\"";
1313 jobColor =
" class=\"jobfinished\"";
1317 statusColor =
" class=\"jobrunning\"";
1318 jobColor =
" class=\"jobrunning\"";
1322 statusColor =
" class=\"jobqueued\"";
1323 jobColor =
" class=\"jobqueued\"";
1327 QString sTitle =
p.attribute(
"title" ,
"" );
1328 QString sSubTitle =
p.attribute(
"subTitle",
"" );
1334 QString sHostname = e.attribute(
"hostname",
"master" );
1335 QString sComment =
"";
1337 QDomText text = e.firstChild().toText();
1339 sComment = text.nodeValue();
1341 os <<
"<a href=\"javascript:void(0)\">"
1345 << sTitle <<
" - <font" << jobColor <<
">"
1347 <<
"<span><strong>" << sTitle <<
"</strong> ("
1351 if (!sSubTitle.isEmpty())
1352 os <<
"<em>" << sSubTitle <<
"</em><br /><br />";
1358 os <<
"Scheduled Run Time: "
1365 os <<
"Status: <font" << statusColor <<
">"
1373 if ( nStatus != JOB_QUEUED)
1374 os <<
"Host: " << sHostname <<
"<br />";
1376 if (!sComment.isEmpty())
1377 os <<
"<br />Comments:<br />" << sComment <<
"<br />";
1379 os <<
"</span></a><hr />\r\n";
1383 node = node.nextSibling();
1385 os <<
" </div>\r\n";
1389 os <<
" Job Queue is currently empty.\r\n\r\n";
1392 os <<
" </div>\r\n\r\n ";
1409 os <<
"<div class=\"content\">\r\n"
1410 <<
" <h2 class=\"status\">Machine Information</h2>\r\n";
1414 QDomNode node =
info.namedItem(
"Load" );
1418 QDomElement e = node.toElement();
1422 double dAvg1 = e.attribute(
"avg1" ,
"0" ).toDouble();
1423 double dAvg2 = e.attribute(
"avg2" ,
"0" ).toDouble();
1424 double dAvg3 = e.attribute(
"avg3" ,
"0" ).toDouble();
1426 os <<
" <div class=\"loadstatus\">\r\n"
1427 <<
" This machine's load average:"
1428 <<
"\r\n <ul>\r\n <li>"
1429 <<
"1 Minute: " << dAvg1 <<
"</li>\r\n"
1430 <<
" <li>5 Minutes: " << dAvg2 <<
"</li>\r\n"
1431 <<
" <li>15 Minutes: " << dAvg3
1432 <<
"</li>\r\n </ul>\r\n"
1438 node =
info.namedItem(
"Storage" );
1439 QDomElement storage = node.toElement();
1440 node = storage.firstChild();
1445 while (!node.isNull())
1447 QDomElement g = node.toElement();
1449 if (!g.isNull() && g.tagName() ==
"Group")
1451 QString
id = g.attribute(
"id",
"" );
1455 int nFree = g.attribute(
"free" ,
"0" ).toInt();
1456 int nTotal = g.attribute(
"total",
"0" ).toInt();
1457 int nUsed = g.attribute(
"used" ,
"0" ).toInt();
1458 int nLiveTV = g.attribute(
"livetv" ,
"0" ).toInt();
1459 int nDeleted = g.attribute(
"deleted",
"0" ).toInt();
1460 int nExpirable = g.attribute(
"expirable" ,
"0" ).toInt();
1461 QString nDir = g.attribute(
"dir" ,
"" );
1463 nDir.replace(
",",
", ");
1465 os <<
" Disk Usage Summary:<br />\r\n";
1468 os <<
" <li>Total Disk Space:\r\n"
1471 os <<
" <li>Total Space: ";
1472 sRep = QString(
"%L1").arg(nTotal) +
" MB";
1473 os << sRep <<
"</li>\r\n";
1475 os <<
" <li>Space Used: ";
1476 sRep = QString(
"%L1").arg(nUsed) +
" MB";
1477 os << sRep <<
"</li>\r\n";
1479 os <<
" <li>Space Free: ";
1480 sRep = QString(
"%L1").arg(nFree) +
" MB";
1481 os << sRep <<
"</li>\r\n";
1483 if ((nLiveTV + nDeleted + nExpirable) > 0)
1485 os <<
" <li>Space Available "
1486 "After Auto-expire: ";
1487 sRep = QString(
"%L1").arg(nUsed) +
" MB";
1488 sRep = QString(
"%L1").arg(nFree + nLiveTV +
1489 nDeleted + nExpirable) +
" MB";
1490 os << sRep <<
"\r\n";
1492 os <<
" <li>Space Used by LiveTV: ";
1493 sRep = QString(
"%L1").arg(nLiveTV) +
" MB";
1494 os << sRep <<
"</li>\r\n";
1495 os <<
" <li>Space Used by "
1496 "Deleted Recordings: ";
1497 sRep = QString(
"%L1").arg(nDeleted) +
" MB";
1498 os << sRep <<
"</li>\r\n";
1499 os <<
" <li>Space Used by "
1500 "Auto-expirable Recordings: ";
1501 sRep = QString(
"%L1").arg(nExpirable) +
" MB";
1502 os << sRep <<
"</li>\r\n";
1515 node = node.nextSibling();
1519 node = storage.firstChild();
1521 os <<
" Disk Usage Details:<br />\r\n";
1525 while (!node.isNull())
1527 QDomElement g = node.toElement();
1529 if (!g.isNull() && g.tagName() ==
"Group")
1531 int nFree = g.attribute(
"free" ,
"0" ).toInt();
1532 int nTotal = g.attribute(
"total",
"0" ).toInt();
1533 int nUsed = g.attribute(
"used" ,
"0" ).toInt();
1534 QString nDir = g.attribute(
"dir" ,
"" );
1535 QString
id = g.attribute(
"id" ,
"" );
1537 nDir.replace(
",",
", ");
1543 os <<
" <li>MythTV Drive #" <<
id <<
":"
1547 if (nDir.contains(
','))
1548 os <<
" <li>Directories: ";
1550 os <<
" <li>Directory: ";
1552 os << nDir <<
"</li>\r\n";
1554 os <<
" <li>Total Space: ";
1555 sRep = QString(
"%L1").arg(nTotal) +
" MB";
1556 os << sRep <<
"</li>\r\n";
1558 os <<
" <li>Space Used: ";
1559 sRep = QString(
"%L1").arg(nUsed) +
" MB";
1560 os << sRep <<
"</li>\r\n";
1562 os <<
" <li>Space Free: ";
1563 sRep = QString(
"%L1").arg(nFree) +
" MB";
1564 os << sRep <<
"</li>\r\n";
1572 node = node.nextSibling();
1579 node =
info.namedItem(
"Guide" );
1583 QDomElement e = node.toElement();
1587 int nDays = e.attribute(
"guideDays",
"0" ).toInt();
1588 QString sStart = e.attribute(
"start" ,
"" );
1589 QString sEnd = e.attribute(
"end" ,
"" );
1590 QString sStatus = e.attribute(
"status" ,
"" );
1592 QString sNext = next.isNull() ?
"" :
1598 QDomText text = e.firstChild().toText();
1605 sMsg = text.nodeValue();
1607 os <<
" Last mythfilldatabase run started on " << sStart
1613 os <<
"ended on " << sEnd <<
". ";
1615 os << sStatus <<
"<br />\r\n";
1617 if (!next.isNull() && next >= lastrunstart)
1619 os <<
" Suggested next mythfilldatabase run: "
1620 << sNext <<
".<br />\r\n";
1625 os <<
" There's guide data until "
1629 os <<
" " << QObject::tr(
"(%n day(s))",
"", nDays);
1634 os <<
" <strong>WARNING</strong>: is mythfilldatabase running?";
1638 os <<
" There's <strong>no guide data</strong> available! "
1639 <<
"Have you run mythfilldatabase?";
1643 os <<
"\r\n </div>\r\n";
1655 QDomNodeList nodes =
info.elementsByTagName(
"Information");
1656 uint count = nodes.count();
1662 os <<
"<div class=\"content\">\r\n"
1663 <<
" <h2 class=\"status\">Miscellaneous</h2>\r\n";
1664 for (
unsigned int i = 0; i < count; i++)
1666 QDomNode node = nodes.item(i);
1670 QDomElement e = node.toElement();
1674 display = e.attribute(
"display",
"");
1678 if (display.isEmpty())
1683 if (display.contains(
"<p>", Qt::CaseInsensitive) ||
1684 display.contains(
"<br", Qt::CaseInsensitive))
1691 linebreak =
"<br />\r\n";
1694 os <<
" " << display << linebreak;
1708 if ((pDoc ==
nullptr) || (pInfo ==
nullptr))
1713 QDomElement program = pDoc->createElement(
"Program" );
1714 node.appendChild( program );
1716 program.setAttribute(
"startTime" ,
1719 program.setAttribute(
"title" , pInfo->
GetTitle() );
1720 program.setAttribute(
"subTitle" , pInfo->
GetSubtitle());
1721 program.setAttribute(
"category" , pInfo->
GetCategory());
1723 program.setAttribute(
"repeat" ,
static_cast<int>(pInfo->
IsRepeat()));
1728 program.setAttribute(
"seriesId" , pInfo->
GetSeriesID() );
1729 program.setAttribute(
"programId" , pInfo->
GetProgramID() );
1730 program.setAttribute(
"stars" , pInfo->
GetStars() );
1731 program.setAttribute(
"fileSize" ,
1733 program.setAttribute(
"lastModified",
1736 program.setAttribute(
"hostname" , pInfo->
GetHostname() );
1739 program.setAttribute(
1742 QDomText textNode = pDoc->createTextNode( pInfo->
GetDescription() );
1743 program.appendChild( textNode );
1751 QDomElement channel = pDoc->createElement(
"Channel" );
1752 program.appendChild( channel );
1761 QDomElement recording = pDoc->createElement(
"Recording" );
1762 program.appendChild( recording );
1764 recording.setAttribute(
"recStatus" ,
1766 recording.setAttribute(
"recPriority" ,
1768 recording.setAttribute(
"recStartTs" ,
1770 recording.setAttribute(
"recEndTs" ,
1775 recording.setAttribute(
"recordId" ,
1777 recording.setAttribute(
"recGroup" ,
1779 recording.setAttribute(
"playGroup" ,
1781 recording.setAttribute(
"recType" ,
1783 recording.setAttribute(
"dupInType" ,
1785 recording.setAttribute(
"dupMethod" ,
1787 recording.setAttribute(
"encoderId" ,
1790 recording.setAttribute(
"recProfile" ,
1817 channel.setAttribute(
"chanId" , pInfo->
GetChanID() );
1818 channel.setAttribute(
"chanNum" , pInfo->
GetChanNum());
1825 channel.setAttribute(
"chanFilters",
1827 channel.setAttribute(
"sourceId" , pInfo->
GetSourceID() );
1828 channel.setAttribute(
"inputId" , pInfo->
GetInputID() );
1829 channel.setAttribute(
"commFree" ,