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 : qAsConst(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 );
227 pJob->setCmds( (*it).cmds );
228 pJob->setFlags( (*it).flags );
229 pJob->setStatus( (*it).status );
230 pJob->setStatusTime( (*it).statustime);
231 pJob->setSchedRunTime( (*it).schedruntime);
232 pJob->setArgs( (*it).args );
233 if ((*it).hostname.isEmpty())
234 pJob->setHostName( QObject::tr(
"master"));
236 pJob->setHostName((*it).hostname);
237 pJob->setComment((*it).comment);
247 if (rgdAverages[0] != -1)
249 pMachineInfo->setLoadAvg1(rgdAverages[0]);
250 pMachineInfo->setLoadAvg2(rgdAverages[1]);
251 pMachineInfo->setLoadAvg3(rgdAverages[2]);
255 QDateTime GuideDataThrough;
257 query.
prepare(
"SELECT MAX(endtime) FROM program WHERE manualid = 0;");
262 pMachineInfo->setGuideStart
264 pMachineInfo->setGuideEnd(
266 pMachineInfo->setGuideStatus(
270 pMachineInfo->setGuideNext(
274 if (!GuideDataThrough.isNull())
277 pMachineInfo->setGuideThru(GuideDataThrough);
278 pMachineInfo->setGuideDays(qdtNow.daysTo(GuideDataThrough));
283 if ((!info_script.isEmpty()) && (info_script !=
"none"))
290 LOG(VB_GENERAL, LOG_ERR,
291 QString(
"Error running miscellaneous "
292 "status information script: %1").arg(info_script));
295 QByteArray input = ms.
ReadAll();
296 pStatus->setMiscellaneous(QString(input));
312 QStringList::const_iterator sit = strlist.cbegin();
313 while (sit != strlist.cend())
316 directory = *(sit++);
317 isLocalstr = *(sit++);
321 long long iTotal = (*(sit++)).toLongLong();
322 long long iUsed = (*(sit++)).toLongLong();;
323 long long iAvail = iTotal - iUsed;
329 group->setId(QString(fsID));
330 group->setTotal((
int)(iTotal>>10));
331 group->setUsed((
int)(iUsed>>10));
332 group->setFree((
int)(iAvail>>10));
333 group->setDirectory(directory);
337 long long iLiveTV = -1;
338 long long iDeleted = -1;
339 long long iExpirable = -1;
341 query.
prepare(
"SELECT SUM(filesize) FROM recorded "
342 " WHERE recgroup = :RECGROUP;");
347 iLiveTV = query.
value(0).toLongLong();
352 iDeleted = query.
value(0).toLongLong();
354 query.
prepare(
"SELECT SUM(filesize) FROM recorded "
355 " WHERE autoexpire = 1 "
356 " AND recgroup NOT IN ('LiveTV', 'Deleted');");
359 iExpirable = query.
value(0).toLongLong();
361 group->setLiveTV( (
int)(iLiveTV>>20) );
362 group->setDeleted( (
int)(iDeleted>>20) );
363 group->setExpirable ( (
int)(iExpirable>>20) );
375 QDomElement root = pDoc->createElement(
"Status");
376 pDoc->appendChild(root);
380 root.setAttribute(
"time" ,
382 root.setAttribute(
"ISODate" , qdtNow.toString(
Qt::ISODate) );
383 root.setAttribute(
"version" , MYTH_BINARY_VERSION );
384 root.setAttribute(
"protoVer", MYTH_PROTO_VERSION );
388 QDomElement encoders = pDoc->createElement(
"Encoders");
389 root.appendChild(encoders);
398 if (elink !=
nullptr)
400 TVState state = elink->GetState();
401 isLocal = elink->IsLocal();
403 QDomElement encoder = pDoc->createElement(
"Encoder");
404 encoders.appendChild(encoder);
406 encoder.setAttribute(
"id" , elink->GetInputID() );
407 encoder.setAttribute(
"local" ,
static_cast<int>(isLocal));
408 encoder.setAttribute(
"connected" ,
static_cast<int>(elink->IsConnected()));
409 encoder.setAttribute(
"state" , state );
410 encoder.setAttribute(
"sleepstatus" , elink->GetSleepStatus() );
416 encoder.setAttribute(
"hostname", elink->GetHostName());
418 encoder.setAttribute(
"devlabel",
421 if (elink->IsConnected())
449 encoders.setAttribute(
"count", numencoders);
453 QDomElement scheduled = pDoc->createElement(
"Scheduled");
454 root.appendChild(scheduled);
461 unsigned int iNum = 10;
462 unsigned int iNumRecordings = 0;
464 auto itProg = recordingList.begin();
465 for (; (itProg != recordingList.end()) && iNumRecordings < iNum; ++itProg)
468 ((*itProg)->GetRecordingStartTime() >=
476 while (!recordingList.empty())
480 recordingList.pop_back();
483 scheduled.setAttribute(
"count", iNumRecordings);
487 QDomElement frontends = pDoc->createElement(
"Frontends");
488 root.appendChild(frontends);
491 "urn:schemas-mythtv-org:service:MythFrontend:1");
499 frontends.setAttribute(
"count", map.size() );
500 for (
const auto & entry : qAsConst(map))
502 QDomElement fe = pDoc->createElement(
"Frontend");
503 frontends.appendChild(fe);
504 QUrl url(entry->m_sLocation);
505 fe.setAttribute(
"name", url.host());
506 fe.setAttribute(
"url", url.toString(QUrl::RemovePath));
513 QDomElement backends = pDoc->createElement(
"Backends");
514 root.appendChild(backends);
524 QDomElement mbe = pDoc->createElement(
"Backend");
525 backends.appendChild(mbe);
526 mbe.setAttribute(
"type",
"Master");
527 mbe.setAttribute(
"name", masterhost);
528 mbe.setAttribute(
"url" , masterip +
":" + QString::number(masterport));
532 "urn:schemas-mythtv-org:device:SlaveMediaServer:1");
536 QString ipaddress = QString();
545 for (
const auto & entry : qAsConst(map))
547 QUrl url(entry->m_sLocation);
548 if (url.host() != ipaddress)
551 QDomElement mbe = pDoc->createElement(
"Backend");
552 backends.appendChild(mbe);
553 mbe.setAttribute(
"type",
"Slave");
554 mbe.setAttribute(
"name", url.host());
555 mbe.setAttribute(
"url" , url.toString(QUrl::RemovePath));
561 backends.setAttribute(
"count", numbes);
565 QDomElement queue = pDoc->createElement(
"JobQueue");
566 root.appendChild(queue);
568 QMap<int, JobQueueEntry> jobs;
569 QMap<int, JobQueueEntry>::Iterator it;
575 for (it = jobs.begin(); it != jobs.end(); ++it)
577 ProgramInfo pginfo((*it).chanid, (*it).recstartts);
581 QDomElement job = pDoc->createElement(
"Job");
582 queue.appendChild(job);
584 job.setAttribute(
"id" , (*it).id );
585 job.setAttribute(
"chanId" , (*it).chanid );
586 job.setAttribute(
"startTime" ,
588 job.setAttribute(
"startTs" , (*it).startts );
589 job.setAttribute(
"insertTime",
591 job.setAttribute(
"type" , (*it).type );
592 job.setAttribute(
"cmds" , (*it).cmds );
593 job.setAttribute(
"flags" , (*it).flags );
594 job.setAttribute(
"status" , (*it).status );
595 job.setAttribute(
"statusTime",
597 job.setAttribute(
"schedTime" ,
599 job.setAttribute(
"args" , (*it).args );
601 if ((*it).hostname.isEmpty())
602 job.setAttribute(
"hostname", QObject::tr(
"master"));
604 job.setAttribute(
"hostname",(*it).hostname);
606 QDomText textNode = pDoc->createTextNode((*it).comment);
607 job.appendChild(textNode);
612 queue.setAttribute(
"count", jobs.size() );
616 QDomElement mInfo = pDoc->createElement(
"MachineInfo");
617 QDomElement storage = pDoc->createElement(
"Storage" );
618 QDomElement load = pDoc->createElement(
"Load" );
619 QDomElement guide = pDoc->createElement(
"Guide" );
621 root.appendChild (mInfo );
622 mInfo.appendChild(storage);
623 mInfo.appendChild(load );
624 mInfo.appendChild(guide );
641 QList<QDomElement> fsXML;
642 QStringList::const_iterator sit = strlist.cbegin();
643 while (sit != strlist.cend())
646 directory = *(sit++);
647 isLocalstr = *(sit++);
651 long long iTotal = (*(sit++)).toLongLong();
652 long long iUsed = (*(sit++)).toLongLong();;
653 long long iAvail = iTotal - iUsed;
658 QDomElement group = pDoc->createElement(
"Group");
660 group.setAttribute(
"id" , fsID );
661 group.setAttribute(
"total", (
int)(iTotal>>10) );
662 group.setAttribute(
"used" , (
int)(iUsed>>10) );
663 group.setAttribute(
"free" , (
int)(iAvail>>10) );
664 group.setAttribute(
"dir" , directory );
668 long long iLiveTV = -1;
669 long long iDeleted = -1;
670 long long iExpirable = -1;
672 query.
prepare(
"SELECT SUM(filesize) FROM recorded "
673 " WHERE recgroup = :RECGROUP;");
678 iLiveTV = query.
value(0).toLongLong();
683 iDeleted = query.
value(0).toLongLong();
685 query.
prepare(
"SELECT SUM(filesize) FROM recorded "
686 " WHERE autoexpire = 1 "
687 " AND recgroup NOT IN ('LiveTV', 'Deleted');");
690 iExpirable = query.
value(0).toLongLong();
692 group.setAttribute(
"livetv", (
int)(iLiveTV>>20) );
693 group.setAttribute(
"deleted", (
int)(iDeleted>>20) );
694 group.setAttribute(
"expirable", (
int)(iExpirable>>20) );
701 storage.appendChild(total);
702 int num_elements = fsXML.size();
703 for (
int fs_index = 0; fs_index < num_elements; fs_index++)
705 storage.appendChild(fsXML[fs_index]);
711 load.setAttribute(
"avg1", 0);
712 load.setAttribute(
"avg2", 1);
713 load.setAttribute(
"avg3", 2);
716 if (rgdAverages[0] != -1)
718 load.setAttribute(
"avg1", rgdAverages[0]);
719 load.setAttribute(
"avg2", rgdAverages[1]);
720 load.setAttribute(
"avg3", rgdAverages[2]);
726 QDateTime GuideDataThrough;
729 query.
prepare(
"SELECT MAX(endtime) FROM program WHERE manualid = 0;");
736 guide.setAttribute(
"start",
738 guide.setAttribute(
"end",
740 guide.setAttribute(
"status",
744 guide.setAttribute(
"next",
748 if (!GuideDataThrough.isNull())
750 guide.setAttribute(
"guideThru",
752 guide.setAttribute(
"guideDays", qdtNow.daysTo(GuideDataThrough));
758 if ((!info_script.isEmpty()) && (info_script !=
"none"))
760 QDomElement misc = pDoc->createElement(
"Miscellaneous");
761 root.appendChild(misc);
768 LOG(VB_GENERAL, LOG_ERR,
769 QString(
"Error running miscellaneous "
770 "status information script: %1").arg(info_script));
774 QByteArray input = ms.
ReadAll();
776 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
777 QStringList
output = QString(input).split(
'\n',
778 QString::SkipEmptyParts);
780 QStringList
output = QString(input).split(
'\n',
784 for (
const auto & line : qAsConst(
output))
786 QDomElement info = pDoc->createElement(
"Information");
788 QStringList list = line.split(
"[]:[]");
789 unsigned int size = list.size();
790 unsigned int hasAttributes = 0;
792 if ((size > 0) && (!list[0].isEmpty()))
794 info.setAttribute(
"display", list[0]);
797 if ((size > 1) && (!list[1].isEmpty()))
799 info.setAttribute(
"name", list[1]);
802 if ((size > 2) && (!list[2].isEmpty()))
804 info.setAttribute(
"value", list[2]);
808 if (hasAttributes > 0)
809 misc.appendChild(info);
820 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
821 os.setCodec(
"UTF-8");
823 os.setEncoding(QStringConverter::Utf8);
828 QDomElement docElem = pDoc->documentElement();
830 os <<
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
831 <<
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n"
832 <<
"<html xmlns=\"http://www.w3.org/1999/xhtml\""
833 <<
" xml:lang=\"en\" lang=\"en\">\r\n"
835 <<
" <meta http-equiv=\"Content-Type\""
836 <<
"content=\"text/html; charset=UTF-8\" />\r\n"
837 <<
" <link rel=\"stylesheet\" href=\"/css/Status.css\" type=\"text/css\">\r\n"
838 <<
" <title>MythTV Status - "
842 << docElem.attribute(
"version", MYTH_BINARY_VERSION ) <<
"</title>\r\n"
844 <<
"<body bgcolor=\"#fff\">\r\n"
845 <<
"<div class=\"status\">\r\n"
846 <<
" <h1 class=\"status\">MythTV Status</h1>\r\n";
850 QDomNode node = docElem.namedItem(
"Encoders" );
857 node = docElem.namedItem(
"Scheduled" );
864 node = docElem.namedItem(
"Frontends" );
871 node = docElem.namedItem(
"Backends" );
878 node = docElem.namedItem(
"JobQueue" );
885 node = docElem.namedItem(
"MachineInfo" );
892 node = docElem.namedItem(
"Miscellaneous" );
897 os <<
"\r\n</div>\r\n</body>\r\n</html>\r\n";
907 int nNumEncoders = 0;
909 if (encoders.isNull())
912 os <<
" <div class=\"content\">\r\n"
913 <<
" <h2 class=\"status\">Encoder Status</h2>\r\n";
915 QDomNode node = encoders.firstChild();
917 while (!node.isNull())
919 QDomElement e = node.toElement();
923 if (e.tagName() ==
"Encoder")
925 QString sIsLocal = (e.attribute(
"local" ,
"remote" )==
"1")
926 ?
"local" :
"remote";
927 QString sCardId = e.attribute(
"id" ,
"0" );
928 QString sHostName = e.attribute(
"hostname" ,
"Unknown");
929 bool bConnected=
static_cast<bool>(e.attribute(
"connected",
"0" ).toInt());
931 bool bIsLowOnFreeSpace=
static_cast<bool>(e.attribute(
"lowOnFreeSpace",
"0").toInt());
933 QString sDevlabel = e.attribute(
"devlabel",
"[ UNKNOWN ]");
935 os <<
" Encoder " << sCardId <<
" " << sDevlabel
936 <<
" is " << sIsLocal <<
" on " << sHostName;
938 if ((sIsLocal ==
"remote") && !bConnected)
945 os <<
" (currently asleep).<br />";
947 os <<
" (currently not connected).<br />";
949 node = node.nextSibling();
960 os <<
" and is watching Live TV";
965 os <<
" and is recording";
969 os <<
" and is not recording.";
975 QDomNode tmpNode = e.namedItem(
"Program" );
977 if (!tmpNode.isNull())
979 QDomElement program = tmpNode.toElement();
981 if (!program.isNull())
983 os <<
" '" << program.attribute(
"title",
"Unknown" ) <<
"'";
987 tmpNode = program.namedItem(
"Channel" );
989 if (!tmpNode.isNull())
991 QDomElement channel = tmpNode.toElement();
993 if (!channel.isNull())
995 << channel.attribute(
"callSign",
"unknown" );
1000 tmpNode = program.namedItem(
"Recording" );
1002 if (!tmpNode.isNull())
1004 QDomElement recording = tmpNode.toElement();
1006 if (!recording.isNull())
1009 recording.attribute(
"recEndTs",
"" ));
1011 os <<
". This recording ";
1017 os <<
"scheduled to end at "
1027 if (bIsLowOnFreeSpace)
1029 os <<
" <strong>WARNING</strong>:"
1030 <<
" This backend is low on free disk space!";
1037 node = node.nextSibling();
1040 os <<
" </div>\r\n\r\n";
1042 return( nNumEncoders );
1053 if (scheduled.isNull())
1056 int nNumRecordings= scheduled.attribute(
"count",
"0" ).toInt();
1058 os <<
" <div class=\"content\">\r\n"
1059 <<
" <h2 class=\"status\">Schedule</h2>\r\n";
1061 if (nNumRecordings == 0)
1063 os <<
" There are no shows scheduled for recording.\r\n"
1068 os <<
" The next " << nNumRecordings <<
" show" << (nNumRecordings == 1 ?
"" :
"s" )
1069 <<
" that " << (nNumRecordings == 1 ?
"is" :
"are")
1070 <<
" scheduled for recording:\r\n";
1072 os <<
" <div class=\"schedule\">\r\n";
1076 QDomNode node = scheduled.firstChild();
1078 while (!node.isNull())
1080 QDomElement e = node.toElement();
1084 QDomNode recNode = e.namedItem(
"Recording" );
1085 QDomNode chanNode = e.namedItem(
"Channel" );
1087 if ((e.tagName() ==
"Program") && !recNode.isNull() &&
1090 QDomElement r = recNode.toElement();
1091 QDomElement c = chanNode.toElement();
1093 QString sTitle = e.attribute(
"title" ,
"" );
1094 QString sSubTitle = e.attribute(
"subTitle",
"" );
1100 int nPreRollSecs = r.attribute(
"preRollSeconds",
"0" ).toInt();
1101 int nEncoderId = r.attribute(
"encoderId" ,
"0" ).toInt();
1102 QString sProfile = r.attribute(
"recProfile" ,
"" );
1103 QString sChanName = c.attribute(
"channelName" ,
"" );
1106 QDomText text = e.firstChild().toText();
1108 sDesc = text.nodeValue();
1112 int nTotalSecs = qdtNow.secsTo( recStartTs ) - nPreRollSecs;
1118 int nTotalDays = nTotalSecs / 86400;
1119 int nTotalHours = (nTotalSecs / 3600)
1120 - (nTotalDays * 24);
1121 int nTotalMins = (nTotalSecs / 60) % 60;
1123 QString sTimeToStart =
"in";
1125 sTimeToStart += QObject::tr(
" %n day(s),",
"", nTotalDays );
1126 sTimeToStart += QObject::tr(
" %n hour(s) and",
"", nTotalHours);
1127 sTimeToStart += QObject::tr(
" %n minute(s)",
"", nTotalMins);
1129 if ( nTotalHours == 0 && nTotalMins == 0)
1130 sTimeToStart = QObject::tr(
"within one minute",
"Recording starting");
1132 if ( nTotalSecs < 0)
1133 sTimeToStart = QObject::tr(
"soon",
"Recording starting");
1137 os <<
" <a href=\"#\">";
1145 os <<
"Encoder " << nEncoderId <<
" - ";
1147 os << sChanName <<
" - " << sTitle <<
"<br />"
1148 <<
"<span><strong>" << sTitle <<
"</strong> ("
1152 if ( !sSubTitle.isEmpty())
1153 os <<
"<em>" << sSubTitle <<
"</em><br /><br />";
1155 if ( airDate.isValid())
1157 os <<
"Orig. Airdate: "
1163 os << sDesc <<
"<br /><br />"
1164 <<
"This recording will start " << sTimeToStart
1165 <<
" using encoder " << nEncoderId <<
" with the '"
1166 << sProfile <<
"' profile.</span></a><hr />\r\n";
1170 node = node.nextSibling();
1172 os <<
" </div>\r\n";
1173 os <<
" </div>\r\n\r\n";
1175 return( nNumRecordings );
1184 if (frontends.isNull())
1187 int nNumFES= frontends.attribute(
"count",
"0" ).toInt();
1193 os <<
" <div class=\"content\">\r\n"
1194 <<
" <h2 class=\"status\">Frontends</h2>\r\n";
1196 QDomNode node = frontends.firstChild();
1197 while (!node.isNull())
1199 QDomElement e = node.toElement();
1203 QString name = e.attribute(
"name" ,
"" );
1204 QString url = e.attribute(
"url" ,
"" );
1205 os << name <<
" (<a href=\"" << url <<
"\">Status page</a>)<br />";
1208 node = node.nextSibling();
1211 os <<
" </div>\r\n\r\n";
1222 if (backends.isNull())
1225 int nNumBES= backends.attribute(
"count",
"0" ).toInt();
1231 os <<
" <div class=\"content\">\r\n"
1232 <<
" <h2 class=\"status\">Other Backends</h2>\r\n";
1234 QDomNode node = backends.firstChild();
1235 while (!node.isNull())
1237 QDomElement e = node.toElement();
1241 QString
type = e.attribute(
"type",
"" );
1242 QString name = e.attribute(
"name" ,
"" );
1243 QString url = e.attribute(
"url" ,
"" );
1244 os <<
type <<
": " << name <<
" (<a href=\"" << url <<
"\">Status page</a>)<br />";
1247 node = node.nextSibling();
1250 os <<
" </div>\r\n\r\n";
1264 int nNumJobs= jobs.attribute(
"count",
"0" ).toInt();
1266 os <<
" <div class=\"content\">\r\n"
1267 <<
" <h2 class=\"status\">Job Queue</h2>\r\n";
1271 QString statusColor;
1274 os <<
" Jobs currently in Queue or recently ended:\r\n<br />"
1275 <<
" <div class=\"schedule\">\r\n";
1278 QDomNode node = jobs.firstChild();
1280 while (!node.isNull())
1282 QDomElement e = node.toElement();
1286 QDomNode progNode = e.namedItem(
"Program" );
1288 if ((e.tagName() ==
"Job") && !progNode.isNull() )
1290 QDomElement
p = progNode.toElement();
1292 QDomNode recNode =
p.namedItem(
"Recording" );
1293 QDomNode chanNode =
p.namedItem(
"Channel" );
1295 QDomElement r = recNode.toElement();
1296 QDomElement c = chanNode.toElement();
1298 int nType = e.attribute(
"type" ,
"0" ).toInt();
1299 int nStatus = e.attribute(
"status",
"0" ).toInt();
1304 statusColor =
" class=\"jobaborted\"";
1309 statusColor =
" class=\"joberrored\"";
1310 jobColor =
" class=\"joberrored\"";
1314 statusColor =
" class=\"jobfinished\"";
1315 jobColor =
" class=\"jobfinished\"";
1319 statusColor =
" class=\"jobrunning\"";
1320 jobColor =
" class=\"jobrunning\"";
1324 statusColor =
" class=\"jobqueued\"";
1325 jobColor =
" class=\"jobqueued\"";
1329 QString sTitle =
p.attribute(
"title" ,
"" );
1330 QString sSubTitle =
p.attribute(
"subTitle",
"" );
1336 QString sHostname = e.attribute(
"hostname",
"master" );
1337 QString sComment =
"";
1339 QDomText text = e.firstChild().toText();
1341 sComment = text.nodeValue();
1343 os <<
"<a href=\"javascript:void(0)\">"
1347 << sTitle <<
" - <font" << jobColor <<
">"
1349 <<
"<span><strong>" << sTitle <<
"</strong> ("
1353 if (!sSubTitle.isEmpty())
1354 os <<
"<em>" << sSubTitle <<
"</em><br /><br />";
1360 os <<
"Scheduled Run Time: "
1367 os <<
"Status: <font" << statusColor <<
">"
1375 if ( nStatus != JOB_QUEUED)
1376 os <<
"Host: " << sHostname <<
"<br />";
1378 if (!sComment.isEmpty())
1379 os <<
"<br />Comments:<br />" << sComment <<
"<br />";
1381 os <<
"</span></a><hr />\r\n";
1385 node = node.nextSibling();
1387 os <<
" </div>\r\n";
1390 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?";
1637 os <<
" There's <strong>no guide data</strong> available! "
1638 <<
"Have you run mythfilldatabase?";
1641 os <<
"\r\n </div>\r\n";
1653 QDomNodeList nodes = info.elementsByTagName(
"Information");
1654 uint count = nodes.count();
1660 os <<
"<div class=\"content\">\r\n"
1661 <<
" <h2 class=\"status\">Miscellaneous</h2>\r\n";
1662 for (
unsigned int i = 0; i < count; i++)
1664 QDomNode node = nodes.item(i);
1668 QDomElement e = node.toElement();
1672 display = e.attribute(
"display",
"");
1676 if (display.isEmpty())
1681 if (display.contains(
"<p>", Qt::CaseInsensitive) ||
1682 display.contains(
"<br", Qt::CaseInsensitive))
1688 linebreak =
"<br />\r\n";
1690 os <<
" " << display << linebreak;
1704 if ((pDoc ==
nullptr) || (pInfo ==
nullptr))
1709 QDomElement program = pDoc->createElement(
"Program" );
1710 node.appendChild( program );
1712 program.setAttribute(
"startTime" ,
1715 program.setAttribute(
"title" , pInfo->
GetTitle() );
1716 program.setAttribute(
"subTitle" , pInfo->
GetSubtitle());
1717 program.setAttribute(
"category" , pInfo->
GetCategory());
1719 program.setAttribute(
"repeat" ,
static_cast<int>(pInfo->
IsRepeat()));
1724 program.setAttribute(
"seriesId" , pInfo->
GetSeriesID() );
1725 program.setAttribute(
"programId" , pInfo->
GetProgramID() );
1726 program.setAttribute(
"stars" , pInfo->
GetStars() );
1727 program.setAttribute(
"fileSize" ,
1729 program.setAttribute(
"lastModified",
1732 program.setAttribute(
"hostname" , pInfo->
GetHostname() );
1735 program.setAttribute(
1738 QDomText textNode = pDoc->createTextNode( pInfo->
GetDescription() );
1739 program.appendChild( textNode );
1747 QDomElement channel = pDoc->createElement(
"Channel" );
1748 program.appendChild( channel );
1757 QDomElement recording = pDoc->createElement(
"Recording" );
1758 program.appendChild( recording );
1760 recording.setAttribute(
"recStatus" ,
1762 recording.setAttribute(
"recPriority" ,
1764 recording.setAttribute(
"recStartTs" ,
1766 recording.setAttribute(
"recEndTs" ,
1771 recording.setAttribute(
"recordId" ,
1773 recording.setAttribute(
"recGroup" ,
1775 recording.setAttribute(
"playGroup" ,
1777 recording.setAttribute(
"recType" ,
1779 recording.setAttribute(
"dupInType" ,
1781 recording.setAttribute(
"dupMethod" ,
1783 recording.setAttribute(
"encoderId" ,
1786 recording.setAttribute(
"recProfile" ,
1813 channel.setAttribute(
"chanId" , pInfo->
GetChanID() );
1814 channel.setAttribute(
"chanNum" , pInfo->
GetChanNum());
1821 channel.setAttribute(
"chanFilters",
1823 channel.setAttribute(
"sourceId" , pInfo->
GetSourceID() );
1824 channel.setAttribute(
"inputId" , pInfo->
GetInputID() );
1825 channel.setAttribute(
"commFree" ,