21 #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
22 #include <QStringConverter>
24 #include <QTextStream>
30 #include "libmythbase/mythconfig.h"
37 #include "libmythbase/mythversion.h"
60 qRegisterMetaType<Preformat*>(
"Preformat");
61 qRegisterMetaType<V2MachineInfo*>(
"V2MachineInfo");
62 qRegisterMetaType<V2BackendStatus*>(
"V2BackendStatus");
63 qRegisterMetaType<V2Encoder*>(
"V2Encoder");
64 qRegisterMetaType<V2Program*>(
"V2Program");
65 qRegisterMetaType<V2Frontend*>(
"V2Frontend");
66 qRegisterMetaType<V2StorageGroup*>(
"V2StorageGroup");
67 qRegisterMetaType<V2Job*>(
"V2Job");
68 qRegisterMetaType<V2ChannelInfo*>(
"V2ChannelInfo");
69 qRegisterMetaType<V2RecordingInfo*>(
"V2RecordingInfo");
70 qRegisterMetaType<V2ArtworkInfoList*>(
"V2ArtworkInfoList");
71 qRegisterMetaType<V2ArtworkInfo*>(
"V2ArtworkInfo");
72 qRegisterMetaType<V2CastMemberList*>(
"V2CastMemberList");
73 qRegisterMetaType<V2CastMember*>(
"V2CastMember");
74 qRegisterMetaType<V2Input*>(
"V2Input");
75 qRegisterMetaType<V2Backend*>(
"V2Backend");
103 QDomDocument doc(
"Status" );
105 QDomProcessingInstruction encoding =
106 doc.createProcessingInstruction(
"xml",
107 R
"(version="1.0" encoding="UTF-8")");
108 doc.appendChild(encoding);
111 pResult->setmimetype(
"application/xml");
112 pResult->setbuffer(doc.toString());
119 QDomDocument doc(
"Status" );
122 QTextStream stream( &html );
125 pResult->setmimetype(
"text/html");
126 pResult->setbuffer(html);
149 pStatus->setVersion ( MYTH_BINARY_VERSION );
150 pStatus->setProtoVer ( MYTH_PROTO_VERSION );
170 backend = pStatus->AddNewBackend();
172 backend->setName(thisHost);
177 backend->setType(
"Master");
178 QStringList backends;
180 for (
const QString&
hostname : std::as_const(backends))
185 backend = pStatus->AddNewBackend();
187 backend->setType(
"Slave");
197 backend->setType(
"Slave");
200 backend = pStatus->AddNewBackend();
201 backend->setName(masterhost);
202 backend->setIP(masterip);
203 backend->setType(
"Master");
207 QMap<int, JobQueueEntry> jobs;
208 QMap<int, JobQueueEntry>::Iterator it;
214 for (it = jobs.begin(); it != jobs.end(); ++it)
216 ProgramInfo pginfo((*it).chanid, (*it).recstartts);
220 V2Job * pJob = pStatus->AddNewJob();
222 pJob->setId( (*it).id );
223 pJob->setChanId((*it).chanid );
224 pJob->setStartTime( (*it).recstartts);
225 pJob->setStartTs( (*it).startts );
226 pJob->setInsertTime((*it).inserttime);
227 pJob->setType( (*it).type );
229 pJob->setCmds( (*it).cmds );
230 pJob->setFlags( (*it).flags );
231 pJob->setStatus( (*it).status );
233 pJob->setStatusTime( (*it).statustime);
234 pJob->setSchedRunTime( (*it).schedruntime);
235 pJob->setArgs( (*it).args );
236 if ((*it).hostname.isEmpty())
237 pJob->setHostName( QObject::tr(
"master"));
239 pJob->setHostName((*it).hostname);
240 pJob->setComment((*it).comment);
250 if (rgdAverages[0] != -1)
252 pMachineInfo->setLoadAvg1(rgdAverages[0]);
253 pMachineInfo->setLoadAvg2(rgdAverages[1]);
254 pMachineInfo->setLoadAvg3(rgdAverages[2]);
258 QDateTime GuideDataThrough;
260 query.
prepare(
"SELECT MAX(endtime) FROM program WHERE manualid = 0;");
265 pMachineInfo->setGuideStart
267 pMachineInfo->setGuideEnd(
269 pMachineInfo->setGuideStatus(
273 pMachineInfo->setGuideNext(
277 if (!GuideDataThrough.isNull())
280 pMachineInfo->setGuideThru(GuideDataThrough);
281 pMachineInfo->setGuideDays(qdtNow.daysTo(GuideDataThrough));
286 if ((!info_script.isEmpty()) && (info_script !=
"none"))
293 LOG(VB_GENERAL, LOG_ERR,
294 QString(
"Error running miscellaneous "
295 "status information script: %1").arg(info_script));
298 QByteArray input = ms.
ReadAll();
299 pStatus->setMiscellaneous(QString(input));
315 QStringList::const_iterator sit = strlist.cbegin();
316 while (sit != strlist.cend())
319 directory = *(sit++);
320 isLocalstr = *(sit++);
324 long long iTotal = (*(sit++)).toLongLong();
325 long long iUsed = (*(sit++)).toLongLong();;
326 long long iAvail = iTotal - iUsed;
332 group->setId(QString(fsID));
333 group->setTotal((
int)(iTotal>>10));
334 group->setUsed((
int)(iUsed>>10));
335 group->setFree((
int)(iAvail>>10));
336 group->setDirectory(directory);
340 long long iLiveTV = -1;
341 long long iDeleted = -1;
342 long long iExpirable = -1;
344 query.
prepare(
"SELECT SUM(filesize) FROM recorded "
345 " WHERE recgroup = :RECGROUP;");
350 iLiveTV = query.
value(0).toLongLong();
355 iDeleted = query.
value(0).toLongLong();
357 query.
prepare(
"SELECT SUM(filesize) FROM recorded "
358 " WHERE autoexpire = 1 "
359 " AND recgroup NOT IN ('LiveTV', 'Deleted');");
362 iExpirable = query.
value(0).toLongLong();
364 group->setLiveTV( (
int)(iLiveTV>>20) );
365 group->setDeleted( (
int)(iDeleted>>20) );
366 group->setExpirable ( (
int)(iExpirable>>20) );
378 QDomElement root = pDoc->createElement(
"Status");
379 pDoc->appendChild(root);
383 root.setAttribute(
"time" ,
385 root.setAttribute(
"ISODate" , qdtNow.toString(
Qt::ISODate) );
386 root.setAttribute(
"version" , MYTH_BINARY_VERSION );
387 root.setAttribute(
"protoVer", MYTH_PROTO_VERSION );
391 QDomElement encoders = pDoc->createElement(
"Encoders");
392 root.appendChild(encoders);
401 if (elink !=
nullptr)
403 TVState state = elink->GetState();
404 isLocal = elink->IsLocal();
406 QDomElement encoder = pDoc->createElement(
"Encoder");
407 encoders.appendChild(encoder);
409 encoder.setAttribute(
"id" , elink->GetInputID() );
410 encoder.setAttribute(
"local" ,
static_cast<int>(isLocal));
411 encoder.setAttribute(
"connected" ,
static_cast<int>(elink->IsConnected()));
412 encoder.setAttribute(
"state" , state );
413 encoder.setAttribute(
"sleepstatus" , elink->GetSleepStatus() );
419 encoder.setAttribute(
"hostname", elink->GetHostName());
421 encoder.setAttribute(
"devlabel",
424 if (elink->IsConnected())
452 encoders.setAttribute(
"count", numencoders);
456 QDomElement scheduled = pDoc->createElement(
"Scheduled");
457 root.appendChild(scheduled);
464 unsigned int iNum = 10;
465 unsigned int iNumRecordings = 0;
467 auto itProg = recordingList.begin();
468 for (; (itProg != recordingList.end()) && iNumRecordings < iNum; ++itProg)
471 ((*itProg)->GetRecordingStartTime() >=
479 while (!recordingList.empty())
483 recordingList.pop_back();
486 scheduled.setAttribute(
"count", iNumRecordings);
490 QDomElement frontends = pDoc->createElement(
"Frontends");
491 root.appendChild(frontends);
494 "urn:schemas-mythtv-org:service:MythFrontend:1");
502 frontends.setAttribute(
"count", map.size() );
503 for (
const auto & entry : std::as_const(map))
505 QDomElement fe = pDoc->createElement(
"Frontend");
506 frontends.appendChild(fe);
507 QUrl url(entry->m_sLocation);
508 fe.setAttribute(
"name", url.host());
509 fe.setAttribute(
"url", url.toString(QUrl::RemovePath));
516 QDomElement backends = pDoc->createElement(
"Backends");
517 root.appendChild(backends);
527 QDomElement mbe = pDoc->createElement(
"Backend");
528 backends.appendChild(mbe);
529 mbe.setAttribute(
"type",
"Master");
530 mbe.setAttribute(
"name", masterhost);
531 mbe.setAttribute(
"url" , masterip +
":" + QString::number(masterport));
535 "urn:schemas-mythtv-org:device:SlaveMediaServer:1");
539 QString ipaddress = QString();
548 for (
const auto & entry : std::as_const(map))
550 QUrl url(entry->m_sLocation);
551 if (url.host() != ipaddress)
554 QDomElement mbe = pDoc->createElement(
"Backend");
555 backends.appendChild(mbe);
556 mbe.setAttribute(
"type",
"Slave");
557 mbe.setAttribute(
"name", url.host());
558 mbe.setAttribute(
"url" , url.toString(QUrl::RemovePath));
564 backends.setAttribute(
"count", numbes);
568 QDomElement queue = pDoc->createElement(
"JobQueue");
569 root.appendChild(queue);
571 QMap<int, JobQueueEntry> jobs;
572 QMap<int, JobQueueEntry>::Iterator it;
578 for (it = jobs.begin(); it != jobs.end(); ++it)
580 ProgramInfo pginfo((*it).chanid, (*it).recstartts);
584 QDomElement job = pDoc->createElement(
"Job");
585 queue.appendChild(job);
587 job.setAttribute(
"id" , (*it).id );
588 job.setAttribute(
"chanId" , (*it).chanid );
589 job.setAttribute(
"startTime" ,
591 job.setAttribute(
"startTs" , (*it).startts );
592 job.setAttribute(
"insertTime",
594 job.setAttribute(
"type" , (*it).type );
595 job.setAttribute(
"cmds" , (*it).cmds );
596 job.setAttribute(
"flags" , (*it).flags );
597 job.setAttribute(
"status" , (*it).status );
598 job.setAttribute(
"statusTime",
600 job.setAttribute(
"schedTime" ,
602 job.setAttribute(
"args" , (*it).args );
604 if ((*it).hostname.isEmpty())
605 job.setAttribute(
"hostname", QObject::tr(
"master"));
607 job.setAttribute(
"hostname",(*it).hostname);
609 QDomText textNode = pDoc->createTextNode((*it).comment);
610 job.appendChild(textNode);
615 queue.setAttribute(
"count", jobs.size() );
619 QDomElement mInfo = pDoc->createElement(
"MachineInfo");
620 QDomElement storage = pDoc->createElement(
"Storage" );
621 QDomElement load = pDoc->createElement(
"Load" );
622 QDomElement guide = pDoc->createElement(
"Guide" );
624 root.appendChild (mInfo );
625 mInfo.appendChild(storage);
626 mInfo.appendChild(load );
627 mInfo.appendChild(guide );
644 QList<QDomElement> fsXML;
645 QStringList::const_iterator sit = strlist.cbegin();
646 while (sit != strlist.cend())
649 directory = *(sit++);
650 isLocalstr = *(sit++);
654 long long iTotal = (*(sit++)).toLongLong();
655 long long iUsed = (*(sit++)).toLongLong();;
656 long long iAvail = iTotal - iUsed;
661 QDomElement group = pDoc->createElement(
"Group");
663 group.setAttribute(
"id" , fsID );
664 group.setAttribute(
"total", (
int)(iTotal>>10) );
665 group.setAttribute(
"used" , (
int)(iUsed>>10) );
666 group.setAttribute(
"free" , (
int)(iAvail>>10) );
667 group.setAttribute(
"dir" , directory );
671 long long iLiveTV = -1;
672 long long iDeleted = -1;
673 long long iExpirable = -1;
675 query.
prepare(
"SELECT SUM(filesize) FROM recorded "
676 " WHERE recgroup = :RECGROUP;");
681 iLiveTV = query.
value(0).toLongLong();
686 iDeleted = query.
value(0).toLongLong();
688 query.
prepare(
"SELECT SUM(filesize) FROM recorded "
689 " WHERE autoexpire = 1 "
690 " AND recgroup NOT IN ('LiveTV', 'Deleted');");
693 iExpirable = query.
value(0).toLongLong();
695 group.setAttribute(
"livetv", (
int)(iLiveTV>>20) );
696 group.setAttribute(
"deleted", (
int)(iDeleted>>20) );
697 group.setAttribute(
"expirable", (
int)(iExpirable>>20) );
706 storage.appendChild(total);
707 int num_elements = fsXML.size();
708 for (
int fs_index = 0; fs_index < num_elements; fs_index++)
710 storage.appendChild(fsXML[fs_index]);
716 load.setAttribute(
"avg1", 0);
717 load.setAttribute(
"avg2", 1);
718 load.setAttribute(
"avg3", 2);
721 if (rgdAverages[0] != -1)
723 load.setAttribute(
"avg1", rgdAverages[0]);
724 load.setAttribute(
"avg2", rgdAverages[1]);
725 load.setAttribute(
"avg3", rgdAverages[2]);
731 QDateTime GuideDataThrough;
734 query.
prepare(
"SELECT MAX(endtime) FROM program WHERE manualid = 0;");
741 guide.setAttribute(
"start",
743 guide.setAttribute(
"end",
745 guide.setAttribute(
"status",
749 guide.setAttribute(
"next",
753 if (!GuideDataThrough.isNull())
755 guide.setAttribute(
"guideThru",
757 guide.setAttribute(
"guideDays", qdtNow.daysTo(GuideDataThrough));
763 if ((!info_script.isEmpty()) && (info_script !=
"none"))
765 QDomElement misc = pDoc->createElement(
"Miscellaneous");
766 root.appendChild(misc);
773 LOG(VB_GENERAL, LOG_ERR,
774 QString(
"Error running miscellaneous "
775 "status information script: %1").arg(info_script));
779 QByteArray input = ms.
ReadAll();
781 QStringList
output = QString(input).split(
'\n',
783 for (
const auto & line : std::as_const(
output))
785 QDomElement
info = pDoc->createElement(
"Information");
787 QStringList list = line.split(
"[]:[]");
788 unsigned int size = list.size();
789 unsigned int hasAttributes = 0;
791 if ((size > 0) && (!list[0].isEmpty()))
793 info.setAttribute(
"display", list[0]);
796 if ((size > 1) && (!list[1].isEmpty()))
798 info.setAttribute(
"name", list[1]);
801 if ((size > 2) && (!list[2].isEmpty()))
803 info.setAttribute(
"value", list[2]);
807 if (hasAttributes > 0)
808 misc.appendChild(
info);
819 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
820 os.setCodec(
"UTF-8");
822 os.setEncoding(QStringConverter::Utf8);
827 QDomElement docElem = pDoc->documentElement();
829 os <<
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
830 <<
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n"
831 <<
"<html xmlns=\"http://www.w3.org/1999/xhtml\""
832 <<
" xml:lang=\"en\" lang=\"en\">\r\n"
834 <<
" <meta http-equiv=\"Content-Type\""
835 <<
"content=\"text/html; charset=UTF-8\" />\r\n"
836 <<
" <link rel=\"stylesheet\" href=\"/css/Status.css\" type=\"text/css\">\r\n"
837 <<
" <title>MythTV Status - "
841 << docElem.attribute(
"version", MYTH_BINARY_VERSION ) <<
"</title>\r\n"
843 <<
"<body bgcolor=\"#fff\">\r\n"
844 <<
"<div class=\"status\">\r\n"
845 <<
" <h1 class=\"status\">MythTV Status</h1>\r\n";
849 QDomNode node = docElem.namedItem(
"Encoders" );
856 node = docElem.namedItem(
"Scheduled" );
863 node = docElem.namedItem(
"Frontends" );
870 node = docElem.namedItem(
"Backends" );
877 node = docElem.namedItem(
"JobQueue" );
884 node = docElem.namedItem(
"MachineInfo" );
891 node = docElem.namedItem(
"Miscellaneous" );
896 os <<
"\r\n</div>\r\n</body>\r\n</html>\r\n";
906 int nNumEncoders = 0;
908 if (encoders.isNull())
911 os <<
" <div class=\"content\">\r\n"
912 <<
" <h2 class=\"status\">Encoder Status</h2>\r\n";
914 QDomNode node = encoders.firstChild();
916 while (!node.isNull())
918 QDomElement e = node.toElement();
922 if (e.tagName() ==
"Encoder")
924 QString sIsLocal = (e.attribute(
"local" ,
"remote" )==
"1")
925 ?
"local" :
"remote";
926 QString sCardId = e.attribute(
"id" ,
"0" );
927 QString sHostName = e.attribute(
"hostname" ,
"Unknown");
928 bool bConnected=
static_cast<bool>(e.attribute(
"connected",
"0" ).toInt());
930 bool bIsLowOnFreeSpace=
static_cast<bool>(e.attribute(
"lowOnFreeSpace",
"0").toInt());
932 QString sDevlabel = e.attribute(
"devlabel",
"[ UNKNOWN ]");
934 os <<
" Encoder " << sCardId <<
" " << sDevlabel
935 <<
" is " << sIsLocal <<
" on " << sHostName;
937 if ((sIsLocal ==
"remote") && !bConnected)
944 os <<
" (currently asleep).<br />";
946 os <<
" (currently not connected).<br />";
948 node = node.nextSibling();
959 os <<
" and is watching Live TV";
964 os <<
" and is recording";
968 os <<
" and is not recording.";
974 QDomNode tmpNode = e.namedItem(
"Program" );
976 if (!tmpNode.isNull())
978 QDomElement program = tmpNode.toElement();
980 if (!program.isNull())
982 os <<
" '" << program.attribute(
"title",
"Unknown" ) <<
"'";
986 tmpNode = program.namedItem(
"Channel" );
988 if (!tmpNode.isNull())
990 QDomElement channel = tmpNode.toElement();
992 if (!channel.isNull())
994 << channel.attribute(
"callSign",
"unknown" );
999 tmpNode = program.namedItem(
"Recording" );
1001 if (!tmpNode.isNull())
1003 QDomElement recording = tmpNode.toElement();
1005 if (!recording.isNull())
1008 recording.attribute(
"recEndTs",
"" ));
1010 os <<
". This recording ";
1016 os <<
"scheduled to end at "
1026 if (bIsLowOnFreeSpace)
1028 os <<
" <strong>WARNING</strong>:"
1029 <<
" This backend is low on free disk space!";
1036 node = node.nextSibling();
1039 os <<
" </div>\r\n\r\n";
1041 return( nNumEncoders );
1052 if (scheduled.isNull())
1055 int nNumRecordings= scheduled.attribute(
"count",
"0" ).toInt();
1057 os <<
" <div class=\"content\">\r\n"
1058 <<
" <h2 class=\"status\">Schedule</h2>\r\n";
1060 if (nNumRecordings == 0)
1062 os <<
" There are no shows scheduled for recording.\r\n"
1067 os <<
" The next " << nNumRecordings <<
" show" << (nNumRecordings == 1 ?
"" :
"s" )
1068 <<
" that " << (nNumRecordings == 1 ?
"is" :
"are")
1069 <<
" scheduled for recording:\r\n";
1071 os <<
" <div class=\"schedule\">\r\n";
1075 QDomNode node = scheduled.firstChild();
1077 while (!node.isNull())
1079 QDomElement e = node.toElement();
1083 QDomNode recNode = e.namedItem(
"Recording" );
1084 QDomNode chanNode = e.namedItem(
"Channel" );
1086 if ((e.tagName() ==
"Program") && !recNode.isNull() &&
1089 QDomElement r = recNode.toElement();
1090 QDomElement c = chanNode.toElement();
1092 QString sTitle = e.attribute(
"title" ,
"" );
1093 QString sSubTitle = e.attribute(
"subTitle",
"" );
1099 int nPreRollSecs = r.attribute(
"preRollSeconds",
"0" ).toInt();
1100 int nEncoderId = r.attribute(
"encoderId" ,
"0" ).toInt();
1101 QString sProfile = r.attribute(
"recProfile" ,
"" );
1102 QString sChanName = c.attribute(
"channelName" ,
"" );
1105 QDomText text = e.firstChild().toText();
1107 sDesc = text.nodeValue();
1111 int nTotalSecs = qdtNow.secsTo( recStartTs ) - nPreRollSecs;
1117 int nTotalDays = nTotalSecs / 86400;
1118 int nTotalHours = (nTotalSecs / 3600)
1119 - (nTotalDays * 24);
1120 int nTotalMins = (nTotalSecs / 60) % 60;
1122 QString sTimeToStart =
"in";
1124 sTimeToStart += QObject::tr(
" %n day(s),",
"", nTotalDays );
1125 sTimeToStart += QObject::tr(
" %n hour(s) and",
"", nTotalHours);
1126 sTimeToStart += QObject::tr(
" %n minute(s)",
"", nTotalMins);
1128 if ( nTotalHours == 0 && nTotalMins == 0)
1129 sTimeToStart = QObject::tr(
"within one minute",
"Recording starting");
1131 if ( nTotalSecs < 0)
1132 sTimeToStart = QObject::tr(
"soon",
"Recording starting");
1136 os <<
" <a href=\"#\">";
1144 os <<
"Encoder " << nEncoderId <<
" - ";
1146 os << sChanName <<
" - " << sTitle <<
"<br />"
1147 <<
"<span><strong>" << sTitle <<
"</strong> ("
1151 if ( !sSubTitle.isEmpty())
1152 os <<
"<em>" << sSubTitle <<
"</em><br /><br />";
1154 if ( airDate.isValid())
1156 os <<
"Orig. Airdate: "
1162 os << sDesc <<
"<br /><br />"
1163 <<
"This recording will start " << sTimeToStart
1164 <<
" using encoder " << nEncoderId <<
" with the '"
1165 << sProfile <<
"' profile.</span></a><hr />\r\n";
1169 node = node.nextSibling();
1171 os <<
" </div>\r\n";
1172 os <<
" </div>\r\n\r\n";
1174 return( nNumRecordings );
1183 if (frontends.isNull())
1186 int nNumFES= frontends.attribute(
"count",
"0" ).toInt();
1192 os <<
" <div class=\"content\">\r\n"
1193 <<
" <h2 class=\"status\">Frontends</h2>\r\n";
1195 QDomNode node = frontends.firstChild();
1196 while (!node.isNull())
1198 QDomElement e = node.toElement();
1202 QString name = e.attribute(
"name" ,
"" );
1203 QString url = e.attribute(
"url" ,
"" );
1204 os << name <<
" (<a href=\"" << url <<
"\">Status page</a>)<br />";
1207 node = node.nextSibling();
1210 os <<
" </div>\r\n\r\n";
1221 if (backends.isNull())
1224 int nNumBES= backends.attribute(
"count",
"0" ).toInt();
1230 os <<
" <div class=\"content\">\r\n"
1231 <<
" <h2 class=\"status\">Other Backends</h2>\r\n";
1233 QDomNode node = backends.firstChild();
1234 while (!node.isNull())
1236 QDomElement e = node.toElement();
1240 QString
type = e.attribute(
"type",
"" );
1241 QString name = e.attribute(
"name" ,
"" );
1242 QString url = e.attribute(
"url" ,
"" );
1243 os <<
type <<
": " << name <<
" (<a href=\"" << url <<
"\">Status page</a>)<br />";
1246 node = node.nextSibling();
1249 os <<
" </div>\r\n\r\n";
1263 int nNumJobs= jobs.attribute(
"count",
"0" ).toInt();
1265 os <<
" <div class=\"content\">\r\n"
1266 <<
" <h2 class=\"status\">Job Queue</h2>\r\n";
1270 QString statusColor;
1273 os <<
" Jobs currently in Queue or recently ended:\r\n<br />"
1274 <<
" <div class=\"schedule\">\r\n";
1277 QDomNode node = jobs.firstChild();
1279 while (!node.isNull())
1281 QDomElement e = node.toElement();
1285 QDomNode progNode = e.namedItem(
"Program" );
1287 if ((e.tagName() ==
"Job") && !progNode.isNull() )
1289 QDomElement
p = progNode.toElement();
1291 QDomNode recNode =
p.namedItem(
"Recording" );
1292 QDomNode chanNode =
p.namedItem(
"Channel" );
1294 QDomElement r = recNode.toElement();
1295 QDomElement c = chanNode.toElement();
1297 int nType = e.attribute(
"type" ,
"0" ).toInt();
1298 int nStatus = e.attribute(
"status",
"0" ).toInt();
1303 statusColor =
" class=\"jobaborted\"";
1308 statusColor =
" class=\"joberrored\"";
1309 jobColor =
" class=\"joberrored\"";
1313 statusColor =
" class=\"jobfinished\"";
1314 jobColor =
" class=\"jobfinished\"";
1318 statusColor =
" class=\"jobrunning\"";
1319 jobColor =
" class=\"jobrunning\"";
1323 statusColor =
" class=\"jobqueued\"";
1324 jobColor =
" class=\"jobqueued\"";
1328 QString sTitle =
p.attribute(
"title" ,
"" );
1329 QString sSubTitle =
p.attribute(
"subTitle",
"" );
1335 QString sHostname = e.attribute(
"hostname",
"master" );
1336 QString sComment =
"";
1338 QDomText text = e.firstChild().toText();
1340 sComment = text.nodeValue();
1342 os <<
"<a href=\"javascript:void(0)\">"
1346 << sTitle <<
" - <font" << jobColor <<
">"
1348 <<
"<span><strong>" << sTitle <<
"</strong> ("
1352 if (!sSubTitle.isEmpty())
1353 os <<
"<em>" << sSubTitle <<
"</em><br /><br />";
1359 os <<
"Scheduled Run Time: "
1366 os <<
"Status: <font" << statusColor <<
">"
1374 if ( nStatus != JOB_QUEUED)
1375 os <<
"Host: " << sHostname <<
"<br />";
1377 if (!sComment.isEmpty())
1378 os <<
"<br />Comments:<br />" << sComment <<
"<br />";
1380 os <<
"</span></a><hr />\r\n";
1384 node = node.nextSibling();
1386 os <<
" </div>\r\n";
1390 os <<
" Job Queue is currently empty.\r\n\r\n";
1393 os <<
" </div>\r\n\r\n ";
1410 os <<
"<div class=\"content\">\r\n"
1411 <<
" <h2 class=\"status\">Machine Information</h2>\r\n";
1415 QDomNode node =
info.namedItem(
"Load" );
1419 QDomElement e = node.toElement();
1423 double dAvg1 = e.attribute(
"avg1" ,
"0" ).toDouble();
1424 double dAvg2 = e.attribute(
"avg2" ,
"0" ).toDouble();
1425 double dAvg3 = e.attribute(
"avg3" ,
"0" ).toDouble();
1427 os <<
" <div class=\"loadstatus\">\r\n"
1428 <<
" This machine's load average:"
1429 <<
"\r\n <ul>\r\n <li>"
1430 <<
"1 Minute: " << dAvg1 <<
"</li>\r\n"
1431 <<
" <li>5 Minutes: " << dAvg2 <<
"</li>\r\n"
1432 <<
" <li>15 Minutes: " << dAvg3
1433 <<
"</li>\r\n </ul>\r\n"
1439 node =
info.namedItem(
"Storage" );
1440 QDomElement storage = node.toElement();
1441 node = storage.firstChild();
1446 while (!node.isNull())
1448 QDomElement g = node.toElement();
1450 if (!g.isNull() && g.tagName() ==
"Group")
1452 QString
id = g.attribute(
"id",
"" );
1456 int nFree = g.attribute(
"free" ,
"0" ).toInt();
1457 int nTotal = g.attribute(
"total",
"0" ).toInt();
1458 int nUsed = g.attribute(
"used" ,
"0" ).toInt();
1459 int nLiveTV = g.attribute(
"livetv" ,
"0" ).toInt();
1460 int nDeleted = g.attribute(
"deleted",
"0" ).toInt();
1461 int nExpirable = g.attribute(
"expirable" ,
"0" ).toInt();
1462 QString nDir = g.attribute(
"dir" ,
"" );
1464 nDir.replace(
",",
", ");
1466 os <<
" Disk Usage Summary:<br />\r\n";
1469 os <<
" <li>Total Disk Space:\r\n"
1472 os <<
" <li>Total Space: ";
1473 sRep = QString(
"%L1").arg(nTotal) +
" MB";
1474 os << sRep <<
"</li>\r\n";
1476 os <<
" <li>Space Used: ";
1477 sRep = QString(
"%L1").arg(nUsed) +
" MB";
1478 os << sRep <<
"</li>\r\n";
1480 os <<
" <li>Space Free: ";
1481 sRep = QString(
"%L1").arg(nFree) +
" MB";
1482 os << sRep <<
"</li>\r\n";
1484 if ((nLiveTV + nDeleted + nExpirable) > 0)
1486 os <<
" <li>Space Available "
1487 "After Auto-expire: ";
1488 sRep = QString(
"%L1").arg(nUsed) +
" MB";
1489 sRep = QString(
"%L1").arg(nFree + nLiveTV +
1490 nDeleted + nExpirable) +
" MB";
1491 os << sRep <<
"\r\n";
1493 os <<
" <li>Space Used by LiveTV: ";
1494 sRep = QString(
"%L1").arg(nLiveTV) +
" MB";
1495 os << sRep <<
"</li>\r\n";
1496 os <<
" <li>Space Used by "
1497 "Deleted Recordings: ";
1498 sRep = QString(
"%L1").arg(nDeleted) +
" MB";
1499 os << sRep <<
"</li>\r\n";
1500 os <<
" <li>Space Used by "
1501 "Auto-expirable Recordings: ";
1502 sRep = QString(
"%L1").arg(nExpirable) +
" MB";
1503 os << sRep <<
"</li>\r\n";
1516 node = node.nextSibling();
1520 node = storage.firstChild();
1522 os <<
" Disk Usage Details:<br />\r\n";
1526 while (!node.isNull())
1528 QDomElement g = node.toElement();
1530 if (!g.isNull() && g.tagName() ==
"Group")
1532 int nFree = g.attribute(
"free" ,
"0" ).toInt();
1533 int nTotal = g.attribute(
"total",
"0" ).toInt();
1534 int nUsed = g.attribute(
"used" ,
"0" ).toInt();
1535 QString nDir = g.attribute(
"dir" ,
"" );
1536 QString
id = g.attribute(
"id" ,
"" );
1538 nDir.replace(
",",
", ");
1544 os <<
" <li>MythTV Drive #" <<
id <<
":"
1548 if (nDir.contains(
','))
1549 os <<
" <li>Directories: ";
1551 os <<
" <li>Directory: ";
1553 os << nDir <<
"</li>\r\n";
1555 os <<
" <li>Total Space: ";
1556 sRep = QString(
"%L1").arg(nTotal) +
" MB";
1557 os << sRep <<
"</li>\r\n";
1559 os <<
" <li>Space Used: ";
1560 sRep = QString(
"%L1").arg(nUsed) +
" MB";
1561 os << sRep <<
"</li>\r\n";
1563 os <<
" <li>Space Free: ";
1564 sRep = QString(
"%L1").arg(nFree) +
" MB";
1565 os << sRep <<
"</li>\r\n";
1573 node = node.nextSibling();
1580 node =
info.namedItem(
"Guide" );
1584 QDomElement e = node.toElement();
1588 int nDays = e.attribute(
"guideDays",
"0" ).toInt();
1589 QString sStart = e.attribute(
"start" ,
"" );
1590 QString sEnd = e.attribute(
"end" ,
"" );
1591 QString sStatus = e.attribute(
"status" ,
"" );
1593 QString sNext = next.isNull() ?
"" :
1599 QDomText text = e.firstChild().toText();
1606 sMsg = text.nodeValue();
1608 os <<
" Last mythfilldatabase run started on " << sStart
1614 os <<
"ended on " << sEnd <<
". ";
1616 os << sStatus <<
"<br />\r\n";
1618 if (!next.isNull() && next >= lastrunstart)
1620 os <<
" Suggested next mythfilldatabase run: "
1621 << sNext <<
".<br />\r\n";
1626 os <<
" There's guide data until "
1630 os <<
" " << QObject::tr(
"(%n day(s))",
"", nDays);
1635 os <<
" <strong>WARNING</strong>: is mythfilldatabase running?";
1639 os <<
" There's <strong>no guide data</strong> available! "
1640 <<
"Have you run mythfilldatabase?";
1644 os <<
"\r\n </div>\r\n";
1656 QDomNodeList nodes =
info.elementsByTagName(
"Information");
1657 uint count = nodes.count();
1663 os <<
"<div class=\"content\">\r\n"
1664 <<
" <h2 class=\"status\">Miscellaneous</h2>\r\n";
1665 for (
unsigned int i = 0; i < count; i++)
1667 QDomNode node = nodes.item(i);
1671 QDomElement e = node.toElement();
1675 display = e.attribute(
"display",
"");
1679 if (display.isEmpty())
1684 if (display.contains(
"<p>", Qt::CaseInsensitive) ||
1685 display.contains(
"<br", Qt::CaseInsensitive))
1692 linebreak =
"<br />\r\n";
1695 os <<
" " << display << linebreak;
1709 if ((pDoc ==
nullptr) || (pInfo ==
nullptr))
1714 QDomElement program = pDoc->createElement(
"Program" );
1715 node.appendChild( program );
1717 program.setAttribute(
"startTime" ,
1720 program.setAttribute(
"title" , pInfo->
GetTitle() );
1721 program.setAttribute(
"subTitle" , pInfo->
GetSubtitle());
1722 program.setAttribute(
"category" , pInfo->
GetCategory());
1724 program.setAttribute(
"repeat" ,
static_cast<int>(pInfo->
IsRepeat()));
1729 program.setAttribute(
"seriesId" , pInfo->
GetSeriesID() );
1730 program.setAttribute(
"programId" , pInfo->
GetProgramID() );
1731 program.setAttribute(
"stars" , pInfo->
GetStars() );
1732 program.setAttribute(
"fileSize" ,
1734 program.setAttribute(
"lastModified",
1737 program.setAttribute(
"hostname" , pInfo->
GetHostname() );
1740 program.setAttribute(
1743 QDomText textNode = pDoc->createTextNode( pInfo->
GetDescription() );
1744 program.appendChild( textNode );
1752 QDomElement channel = pDoc->createElement(
"Channel" );
1753 program.appendChild( channel );
1762 QDomElement recording = pDoc->createElement(
"Recording" );
1763 program.appendChild( recording );
1765 recording.setAttribute(
"recStatus" ,
1767 recording.setAttribute(
"recPriority" ,
1769 recording.setAttribute(
"recStartTs" ,
1771 recording.setAttribute(
"recEndTs" ,
1776 recording.setAttribute(
"recordId" ,
1778 recording.setAttribute(
"recGroup" ,
1780 recording.setAttribute(
"playGroup" ,
1782 recording.setAttribute(
"recType" ,
1784 recording.setAttribute(
"dupInType" ,
1786 recording.setAttribute(
"dupMethod" ,
1788 recording.setAttribute(
"encoderId" ,
1791 recording.setAttribute(
"recProfile" ,
1818 channel.setAttribute(
"chanId" , pInfo->
GetChanID() );
1819 channel.setAttribute(
"chanNum" , pInfo->
GetChanNum());
1826 channel.setAttribute(
"chanFilters",
1828 channel.setAttribute(
"sourceId" , pInfo->
GetSourceID() );
1829 channel.setAttribute(
"inputId" , pInfo->
GetInputID() );
1830 channel.setAttribute(
"commFree" ,