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) );
703 storage.appendChild(total);
704 int num_elements = fsXML.size();
705 for (
int fs_index = 0; fs_index < num_elements; fs_index++)
707 storage.appendChild(fsXML[fs_index]);
713 load.setAttribute(
"avg1", 0);
714 load.setAttribute(
"avg2", 1);
715 load.setAttribute(
"avg3", 2);
718 if (rgdAverages[0] != -1)
720 load.setAttribute(
"avg1", rgdAverages[0]);
721 load.setAttribute(
"avg2", rgdAverages[1]);
722 load.setAttribute(
"avg3", rgdAverages[2]);
728 QDateTime GuideDataThrough;
731 query.
prepare(
"SELECT MAX(endtime) FROM program WHERE manualid = 0;");
738 guide.setAttribute(
"start",
740 guide.setAttribute(
"end",
742 guide.setAttribute(
"status",
746 guide.setAttribute(
"next",
750 if (!GuideDataThrough.isNull())
752 guide.setAttribute(
"guideThru",
754 guide.setAttribute(
"guideDays", qdtNow.daysTo(GuideDataThrough));
760 if ((!info_script.isEmpty()) && (info_script !=
"none"))
762 QDomElement misc = pDoc->createElement(
"Miscellaneous");
763 root.appendChild(misc);
770 LOG(VB_GENERAL, LOG_ERR,
771 QString(
"Error running miscellaneous "
772 "status information script: %1").arg(info_script));
776 QByteArray input = ms.
ReadAll();
778 QStringList
output = QString(input).split(
'\n',
780 for (
const auto & line : std::as_const(
output))
782 QDomElement info = pDoc->createElement(
"Information");
784 QStringList list = line.split(
"[]:[]");
785 unsigned int size = list.size();
786 unsigned int hasAttributes = 0;
788 if ((size > 0) && (!list[0].isEmpty()))
790 info.setAttribute(
"display", list[0]);
793 if ((size > 1) && (!list[1].isEmpty()))
795 info.setAttribute(
"name", list[1]);
798 if ((size > 2) && (!list[2].isEmpty()))
800 info.setAttribute(
"value", list[2]);
804 if (hasAttributes > 0)
805 misc.appendChild(info);
816 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
817 os.setCodec(
"UTF-8");
819 os.setEncoding(QStringConverter::Utf8);
824 QDomElement docElem = pDoc->documentElement();
826 os <<
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
827 <<
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n"
828 <<
"<html xmlns=\"http://www.w3.org/1999/xhtml\""
829 <<
" xml:lang=\"en\" lang=\"en\">\r\n"
831 <<
" <meta http-equiv=\"Content-Type\""
832 <<
"content=\"text/html; charset=UTF-8\" />\r\n"
833 <<
" <link rel=\"stylesheet\" href=\"/css/Status.css\" type=\"text/css\">\r\n"
834 <<
" <title>MythTV Status - "
838 << docElem.attribute(
"version", MYTH_BINARY_VERSION ) <<
"</title>\r\n"
840 <<
"<body bgcolor=\"#fff\">\r\n"
841 <<
"<div class=\"status\">\r\n"
842 <<
" <h1 class=\"status\">MythTV Status</h1>\r\n";
846 QDomNode node = docElem.namedItem(
"Encoders" );
853 node = docElem.namedItem(
"Scheduled" );
860 node = docElem.namedItem(
"Frontends" );
867 node = docElem.namedItem(
"Backends" );
874 node = docElem.namedItem(
"JobQueue" );
881 node = docElem.namedItem(
"MachineInfo" );
888 node = docElem.namedItem(
"Miscellaneous" );
893 os <<
"\r\n</div>\r\n</body>\r\n</html>\r\n";
903 int nNumEncoders = 0;
905 if (encoders.isNull())
908 os <<
" <div class=\"content\">\r\n"
909 <<
" <h2 class=\"status\">Encoder Status</h2>\r\n";
911 QDomNode node = encoders.firstChild();
913 while (!node.isNull())
915 QDomElement e = node.toElement();
919 if (e.tagName() ==
"Encoder")
921 QString sIsLocal = (e.attribute(
"local" ,
"remote" )==
"1")
922 ?
"local" :
"remote";
923 QString sCardId = e.attribute(
"id" ,
"0" );
924 QString sHostName = e.attribute(
"hostname" ,
"Unknown");
925 bool bConnected=
static_cast<bool>(e.attribute(
"connected",
"0" ).toInt());
927 bool bIsLowOnFreeSpace=
static_cast<bool>(e.attribute(
"lowOnFreeSpace",
"0").toInt());
929 QString sDevlabel = e.attribute(
"devlabel",
"[ UNKNOWN ]");
931 os <<
" Encoder " << sCardId <<
" " << sDevlabel
932 <<
" is " << sIsLocal <<
" on " << sHostName;
934 if ((sIsLocal ==
"remote") && !bConnected)
941 os <<
" (currently asleep).<br />";
943 os <<
" (currently not connected).<br />";
945 node = node.nextSibling();
956 os <<
" and is watching Live TV";
961 os <<
" and is recording";
965 os <<
" and is not recording.";
971 QDomNode tmpNode = e.namedItem(
"Program" );
973 if (!tmpNode.isNull())
975 QDomElement program = tmpNode.toElement();
977 if (!program.isNull())
979 os <<
" '" << program.attribute(
"title",
"Unknown" ) <<
"'";
983 tmpNode = program.namedItem(
"Channel" );
985 if (!tmpNode.isNull())
987 QDomElement channel = tmpNode.toElement();
989 if (!channel.isNull())
991 << channel.attribute(
"callSign",
"unknown" );
996 tmpNode = program.namedItem(
"Recording" );
998 if (!tmpNode.isNull())
1000 QDomElement recording = tmpNode.toElement();
1002 if (!recording.isNull())
1005 recording.attribute(
"recEndTs",
"" ));
1007 os <<
". This recording ";
1013 os <<
"scheduled to end at "
1023 if (bIsLowOnFreeSpace)
1025 os <<
" <strong>WARNING</strong>:"
1026 <<
" This backend is low on free disk space!";
1033 node = node.nextSibling();
1036 os <<
" </div>\r\n\r\n";
1038 return( nNumEncoders );
1049 if (scheduled.isNull())
1052 int nNumRecordings= scheduled.attribute(
"count",
"0" ).toInt();
1054 os <<
" <div class=\"content\">\r\n"
1055 <<
" <h2 class=\"status\">Schedule</h2>\r\n";
1057 if (nNumRecordings == 0)
1059 os <<
" There are no shows scheduled for recording.\r\n"
1064 os <<
" The next " << nNumRecordings <<
" show" << (nNumRecordings == 1 ?
"" :
"s" )
1065 <<
" that " << (nNumRecordings == 1 ?
"is" :
"are")
1066 <<
" scheduled for recording:\r\n";
1068 os <<
" <div class=\"schedule\">\r\n";
1072 QDomNode node = scheduled.firstChild();
1074 while (!node.isNull())
1076 QDomElement e = node.toElement();
1080 QDomNode recNode = e.namedItem(
"Recording" );
1081 QDomNode chanNode = e.namedItem(
"Channel" );
1083 if ((e.tagName() ==
"Program") && !recNode.isNull() &&
1086 QDomElement r = recNode.toElement();
1087 QDomElement c = chanNode.toElement();
1089 QString sTitle = e.attribute(
"title" ,
"" );
1090 QString sSubTitle = e.attribute(
"subTitle",
"" );
1096 int nPreRollSecs = r.attribute(
"preRollSeconds",
"0" ).toInt();
1097 int nEncoderId = r.attribute(
"encoderId" ,
"0" ).toInt();
1098 QString sProfile = r.attribute(
"recProfile" ,
"" );
1099 QString sChanName = c.attribute(
"channelName" ,
"" );
1102 QDomText text = e.firstChild().toText();
1104 sDesc = text.nodeValue();
1108 int nTotalSecs = qdtNow.secsTo( recStartTs ) - nPreRollSecs;
1114 int nTotalDays = nTotalSecs / 86400;
1115 int nTotalHours = (nTotalSecs / 3600)
1116 - (nTotalDays * 24);
1117 int nTotalMins = (nTotalSecs / 60) % 60;
1119 QString sTimeToStart =
"in";
1121 sTimeToStart += QObject::tr(
" %n day(s),",
"", nTotalDays );
1122 sTimeToStart += QObject::tr(
" %n hour(s) and",
"", nTotalHours);
1123 sTimeToStart += QObject::tr(
" %n minute(s)",
"", nTotalMins);
1125 if ( nTotalHours == 0 && nTotalMins == 0)
1126 sTimeToStart = QObject::tr(
"within one minute",
"Recording starting");
1128 if ( nTotalSecs < 0)
1129 sTimeToStart = QObject::tr(
"soon",
"Recording starting");
1133 os <<
" <a href=\"#\">";
1141 os <<
"Encoder " << nEncoderId <<
" - ";
1143 os << sChanName <<
" - " << sTitle <<
"<br />"
1144 <<
"<span><strong>" << sTitle <<
"</strong> ("
1148 if ( !sSubTitle.isEmpty())
1149 os <<
"<em>" << sSubTitle <<
"</em><br /><br />";
1151 if ( airDate.isValid())
1153 os <<
"Orig. Airdate: "
1159 os << sDesc <<
"<br /><br />"
1160 <<
"This recording will start " << sTimeToStart
1161 <<
" using encoder " << nEncoderId <<
" with the '"
1162 << sProfile <<
"' profile.</span></a><hr />\r\n";
1166 node = node.nextSibling();
1168 os <<
" </div>\r\n";
1169 os <<
" </div>\r\n\r\n";
1171 return( nNumRecordings );
1180 if (frontends.isNull())
1183 int nNumFES= frontends.attribute(
"count",
"0" ).toInt();
1189 os <<
" <div class=\"content\">\r\n"
1190 <<
" <h2 class=\"status\">Frontends</h2>\r\n";
1192 QDomNode node = frontends.firstChild();
1193 while (!node.isNull())
1195 QDomElement e = node.toElement();
1199 QString name = e.attribute(
"name" ,
"" );
1200 QString url = e.attribute(
"url" ,
"" );
1201 os << name <<
" (<a href=\"" << url <<
"\">Status page</a>)<br />";
1204 node = node.nextSibling();
1207 os <<
" </div>\r\n\r\n";
1218 if (backends.isNull())
1221 int nNumBES= backends.attribute(
"count",
"0" ).toInt();
1227 os <<
" <div class=\"content\">\r\n"
1228 <<
" <h2 class=\"status\">Other Backends</h2>\r\n";
1230 QDomNode node = backends.firstChild();
1231 while (!node.isNull())
1233 QDomElement e = node.toElement();
1237 QString
type = e.attribute(
"type",
"" );
1238 QString name = e.attribute(
"name" ,
"" );
1239 QString url = e.attribute(
"url" ,
"" );
1240 os <<
type <<
": " << name <<
" (<a href=\"" << url <<
"\">Status page</a>)<br />";
1243 node = node.nextSibling();
1246 os <<
" </div>\r\n\r\n";
1260 int nNumJobs= jobs.attribute(
"count",
"0" ).toInt();
1262 os <<
" <div class=\"content\">\r\n"
1263 <<
" <h2 class=\"status\">Job Queue</h2>\r\n";
1267 QString statusColor;
1270 os <<
" Jobs currently in Queue or recently ended:\r\n<br />"
1271 <<
" <div class=\"schedule\">\r\n";
1274 QDomNode node = jobs.firstChild();
1276 while (!node.isNull())
1278 QDomElement e = node.toElement();
1282 QDomNode progNode = e.namedItem(
"Program" );
1284 if ((e.tagName() ==
"Job") && !progNode.isNull() )
1286 QDomElement
p = progNode.toElement();
1288 QDomNode recNode =
p.namedItem(
"Recording" );
1289 QDomNode chanNode =
p.namedItem(
"Channel" );
1291 QDomElement r = recNode.toElement();
1292 QDomElement c = chanNode.toElement();
1294 int nType = e.attribute(
"type" ,
"0" ).toInt();
1295 int nStatus = e.attribute(
"status",
"0" ).toInt();
1300 statusColor =
" class=\"jobaborted\"";
1305 statusColor =
" class=\"joberrored\"";
1306 jobColor =
" class=\"joberrored\"";
1310 statusColor =
" class=\"jobfinished\"";
1311 jobColor =
" class=\"jobfinished\"";
1315 statusColor =
" class=\"jobrunning\"";
1316 jobColor =
" class=\"jobrunning\"";
1320 statusColor =
" class=\"jobqueued\"";
1321 jobColor =
" class=\"jobqueued\"";
1325 QString sTitle =
p.attribute(
"title" ,
"" );
1326 QString sSubTitle =
p.attribute(
"subTitle",
"" );
1332 QString sHostname = e.attribute(
"hostname",
"master" );
1333 QString sComment =
"";
1335 QDomText text = e.firstChild().toText();
1337 sComment = text.nodeValue();
1339 os <<
"<a href=\"javascript:void(0)\">"
1343 << sTitle <<
" - <font" << jobColor <<
">"
1345 <<
"<span><strong>" << sTitle <<
"</strong> ("
1349 if (!sSubTitle.isEmpty())
1350 os <<
"<em>" << sSubTitle <<
"</em><br /><br />";
1356 os <<
"Scheduled Run Time: "
1363 os <<
"Status: <font" << statusColor <<
">"
1371 if ( nStatus != JOB_QUEUED)
1372 os <<
"Host: " << sHostname <<
"<br />";
1374 if (!sComment.isEmpty())
1375 os <<
"<br />Comments:<br />" << sComment <<
"<br />";
1377 os <<
"</span></a><hr />\r\n";
1381 node = node.nextSibling();
1383 os <<
" </div>\r\n";
1386 os <<
" Job Queue is currently empty.\r\n\r\n";
1388 os <<
" </div>\r\n\r\n ";
1405 os <<
"<div class=\"content\">\r\n"
1406 <<
" <h2 class=\"status\">Machine Information</h2>\r\n";
1410 QDomNode node = info.namedItem(
"Load" );
1414 QDomElement e = node.toElement();
1418 double dAvg1 = e.attribute(
"avg1" ,
"0" ).toDouble();
1419 double dAvg2 = e.attribute(
"avg2" ,
"0" ).toDouble();
1420 double dAvg3 = e.attribute(
"avg3" ,
"0" ).toDouble();
1422 os <<
" <div class=\"loadstatus\">\r\n"
1423 <<
" This machine's load average:"
1424 <<
"\r\n <ul>\r\n <li>"
1425 <<
"1 Minute: " << dAvg1 <<
"</li>\r\n"
1426 <<
" <li>5 Minutes: " << dAvg2 <<
"</li>\r\n"
1427 <<
" <li>15 Minutes: " << dAvg3
1428 <<
"</li>\r\n </ul>\r\n"
1434 node = info.namedItem(
"Storage" );
1435 QDomElement storage = node.toElement();
1436 node = storage.firstChild();
1441 while (!node.isNull())
1443 QDomElement g = node.toElement();
1445 if (!g.isNull() && g.tagName() ==
"Group")
1447 QString
id = g.attribute(
"id",
"" );
1451 int nFree = g.attribute(
"free" ,
"0" ).toInt();
1452 int nTotal = g.attribute(
"total",
"0" ).toInt();
1453 int nUsed = g.attribute(
"used" ,
"0" ).toInt();
1454 int nLiveTV = g.attribute(
"livetv" ,
"0" ).toInt();
1455 int nDeleted = g.attribute(
"deleted",
"0" ).toInt();
1456 int nExpirable = g.attribute(
"expirable" ,
"0" ).toInt();
1457 QString nDir = g.attribute(
"dir" ,
"" );
1459 nDir.replace(
",",
", ");
1461 os <<
" Disk Usage Summary:<br />\r\n";
1464 os <<
" <li>Total Disk Space:\r\n"
1467 os <<
" <li>Total Space: ";
1468 sRep = QString(
"%L1").arg(nTotal) +
" MB";
1469 os << sRep <<
"</li>\r\n";
1471 os <<
" <li>Space Used: ";
1472 sRep = QString(
"%L1").arg(nUsed) +
" MB";
1473 os << sRep <<
"</li>\r\n";
1475 os <<
" <li>Space Free: ";
1476 sRep = QString(
"%L1").arg(nFree) +
" MB";
1477 os << sRep <<
"</li>\r\n";
1479 if ((nLiveTV + nDeleted + nExpirable) > 0)
1481 os <<
" <li>Space Available "
1482 "After Auto-expire: ";
1483 sRep = QString(
"%L1").arg(nUsed) +
" MB";
1484 sRep = QString(
"%L1").arg(nFree + nLiveTV +
1485 nDeleted + nExpirable) +
" MB";
1486 os << sRep <<
"\r\n";
1488 os <<
" <li>Space Used by LiveTV: ";
1489 sRep = QString(
"%L1").arg(nLiveTV) +
" MB";
1490 os << sRep <<
"</li>\r\n";
1491 os <<
" <li>Space Used by "
1492 "Deleted Recordings: ";
1493 sRep = QString(
"%L1").arg(nDeleted) +
" MB";
1494 os << sRep <<
"</li>\r\n";
1495 os <<
" <li>Space Used by "
1496 "Auto-expirable Recordings: ";
1497 sRep = QString(
"%L1").arg(nExpirable) +
" MB";
1498 os << sRep <<
"</li>\r\n";
1511 node = node.nextSibling();
1515 node = storage.firstChild();
1517 os <<
" Disk Usage Details:<br />\r\n";
1521 while (!node.isNull())
1523 QDomElement g = node.toElement();
1525 if (!g.isNull() && g.tagName() ==
"Group")
1527 int nFree = g.attribute(
"free" ,
"0" ).toInt();
1528 int nTotal = g.attribute(
"total",
"0" ).toInt();
1529 int nUsed = g.attribute(
"used" ,
"0" ).toInt();
1530 QString nDir = g.attribute(
"dir" ,
"" );
1531 QString
id = g.attribute(
"id" ,
"" );
1533 nDir.replace(
",",
", ");
1539 os <<
" <li>MythTV Drive #" <<
id <<
":"
1543 if (nDir.contains(
','))
1544 os <<
" <li>Directories: ";
1546 os <<
" <li>Directory: ";
1548 os << nDir <<
"</li>\r\n";
1550 os <<
" <li>Total Space: ";
1551 sRep = QString(
"%L1").arg(nTotal) +
" MB";
1552 os << sRep <<
"</li>\r\n";
1554 os <<
" <li>Space Used: ";
1555 sRep = QString(
"%L1").arg(nUsed) +
" MB";
1556 os << sRep <<
"</li>\r\n";
1558 os <<
" <li>Space Free: ";
1559 sRep = QString(
"%L1").arg(nFree) +
" MB";
1560 os << sRep <<
"</li>\r\n";
1568 node = node.nextSibling();
1575 node = info.namedItem(
"Guide" );
1579 QDomElement e = node.toElement();
1583 int nDays = e.attribute(
"guideDays",
"0" ).toInt();
1584 QString sStart = e.attribute(
"start" ,
"" );
1585 QString sEnd = e.attribute(
"end" ,
"" );
1586 QString sStatus = e.attribute(
"status" ,
"" );
1588 QString sNext = next.isNull() ?
"" :
1594 QDomText text = e.firstChild().toText();
1601 sMsg = text.nodeValue();
1603 os <<
" Last mythfilldatabase run started on " << sStart
1609 os <<
"ended on " << sEnd <<
". ";
1611 os << sStatus <<
"<br />\r\n";
1613 if (!next.isNull() && next >= lastrunstart)
1615 os <<
" Suggested next mythfilldatabase run: "
1616 << sNext <<
".<br />\r\n";
1621 os <<
" There's guide data until "
1625 os <<
" " << QObject::tr(
"(%n day(s))",
"", nDays);
1630 os <<
" <strong>WARNING</strong>: is mythfilldatabase running?";
1633 os <<
" There's <strong>no guide data</strong> available! "
1634 <<
"Have you run mythfilldatabase?";
1637 os <<
"\r\n </div>\r\n";
1649 QDomNodeList nodes = info.elementsByTagName(
"Information");
1650 uint count = nodes.count();
1656 os <<
"<div class=\"content\">\r\n"
1657 <<
" <h2 class=\"status\">Miscellaneous</h2>\r\n";
1658 for (
unsigned int i = 0; i < count; i++)
1660 QDomNode node = nodes.item(i);
1664 QDomElement e = node.toElement();
1668 display = e.attribute(
"display",
"");
1672 if (display.isEmpty())
1677 if (display.contains(
"<p>", Qt::CaseInsensitive) ||
1678 display.contains(
"<br", Qt::CaseInsensitive))
1684 linebreak =
"<br />\r\n";
1686 os <<
" " << display << linebreak;
1700 if ((pDoc ==
nullptr) || (pInfo ==
nullptr))
1705 QDomElement program = pDoc->createElement(
"Program" );
1706 node.appendChild( program );
1708 program.setAttribute(
"startTime" ,
1711 program.setAttribute(
"title" , pInfo->
GetTitle() );
1712 program.setAttribute(
"subTitle" , pInfo->
GetSubtitle());
1713 program.setAttribute(
"category" , pInfo->
GetCategory());
1715 program.setAttribute(
"repeat" ,
static_cast<int>(pInfo->
IsRepeat()));
1720 program.setAttribute(
"seriesId" , pInfo->
GetSeriesID() );
1721 program.setAttribute(
"programId" , pInfo->
GetProgramID() );
1722 program.setAttribute(
"stars" , pInfo->
GetStars() );
1723 program.setAttribute(
"fileSize" ,
1725 program.setAttribute(
"lastModified",
1728 program.setAttribute(
"hostname" , pInfo->
GetHostname() );
1731 program.setAttribute(
1734 QDomText textNode = pDoc->createTextNode( pInfo->
GetDescription() );
1735 program.appendChild( textNode );
1743 QDomElement channel = pDoc->createElement(
"Channel" );
1744 program.appendChild( channel );
1753 QDomElement recording = pDoc->createElement(
"Recording" );
1754 program.appendChild( recording );
1756 recording.setAttribute(
"recStatus" ,
1758 recording.setAttribute(
"recPriority" ,
1760 recording.setAttribute(
"recStartTs" ,
1762 recording.setAttribute(
"recEndTs" ,
1767 recording.setAttribute(
"recordId" ,
1769 recording.setAttribute(
"recGroup" ,
1771 recording.setAttribute(
"playGroup" ,
1773 recording.setAttribute(
"recType" ,
1775 recording.setAttribute(
"dupInType" ,
1777 recording.setAttribute(
"dupMethod" ,
1779 recording.setAttribute(
"encoderId" ,
1782 recording.setAttribute(
"recProfile" ,
1809 channel.setAttribute(
"chanId" , pInfo->
GetChanID() );
1810 channel.setAttribute(
"chanNum" , pInfo->
GetChanNum());
1817 channel.setAttribute(
"chanFilters",
1819 channel.setAttribute(
"sourceId" , pInfo->
GetSourceID() );
1820 channel.setAttribute(
"inputId" , pInfo->
GetInputID() );
1821 channel.setAttribute(
"commFree" ,