18 QString str =
"QUERY_RECORDINGS ";
26 QStringList strlist(str);
28 vector<ProgramInfo *> *info =
new vector<ProgramInfo *>;
41 QStringList strlist(QString(
"QUERY_LOAD"));
45 load[0] = strlist[0].toFloat();
46 load[1] = strlist[1].toFloat();
47 load[2] = strlist[2].toFloat();
56 QStringList strlist(QString(
"QUERY_UPTIME"));
61 if (strlist[0].isEmpty() || !strlist[0].at(0).isNumber())
64 if (
sizeof(time_t) ==
sizeof(int))
65 uptime = strlist[0].toUInt();
66 else if (
sizeof(time_t) ==
sizeof(
long))
67 uptime = strlist[0].toULong();
68 else if (
sizeof(time_t) ==
sizeof(
long long))
69 uptime = strlist[0].toULongLong();
76 QStringList strlist(QString(
"QUERY_MEMSTATS"));
80 totalMB = strlist[0].toInt();
81 freeMB = strlist[1].toInt();
82 totalVM = strlist[2].toInt();
83 freeVM = strlist[3].toInt();
92 QStringList strlist(
"QUERY_CHECKFILE");
93 strlist << QString::number((
int)checkSlaves);
97 (strlist.size() < 2) || !strlist[0].toInt())
102 QString localpath = strlist[1];
103 QFile checkFile(localpath);
104 if (checkFile.exists())
117 QString(
"DELETE_RECORDING %1 %2 %3 %4")
118 .arg(QString::number(recInfo.
GetChanID()))
120 .arg(forceMetadataDelete ?
"FORCE" :
"NO_FORCE")
121 .arg(forgetHistory ?
"FORGET" :
"NO_FORGET");
122 QStringList strlist(cmd);
126 else if (strlist[0].toInt() == -2)
131 LOG(VB_GENERAL, LOG_ALERT,
132 QString(
"Failed to delete recording %1:%2")
151 QStringList strlist(QString(
"UNDELETE_RECORDING"));
152 strlist.push_back(QString::number(recInfo.
GetChanID()));
157 if (!strlist.isEmpty() && strlist[0].toInt() == 0)
165 QStringList strList(QString(
"QUERY_GETALLSCHEDULED"));
171 QStringList strList(QString(
"QUERY_GETEXPIRING"));
176 vector<ProgramInfo *> &reclist, QStringList &strList)
181 int numrecordings = strList[0].toInt();
182 if (numrecordings <= 0)
187 LOG(VB_GENERAL, LOG_ERR,
188 "RemoteGetRecordingList() list size appears to be incorrect.");
192 uint reclist_initial_size = (
uint) reclist.size();
193 QStringList::const_iterator it = strList.begin() + 1;
194 for (
int i = 0; i < numrecordings; i++)
197 reclist.push_back(pginfo);
200 return ((
uint) reclist.size()) - reclist_initial_size;
205 QString cmd = QString(
"QUERY_GETCONFLICTING");
206 QStringList strlist( cmd );
209 vector<ProgramInfo *> *retlist =
new vector<ProgramInfo *>;
217 QStringList strlist(
"QUERY_PIXMAP_LASTMODIFIED" );
223 if (!strlist.isEmpty() && !strlist[0].isEmpty() && (strlist[0] !=
"BAD"))
225 #if QT_VERSION < QT_VERSION_CHECK(5,8,0) 226 uint timet = strlist[0].toUInt();
227 return MythDate::fromTime_t(timet);
229 qint64 timet = strlist[0].toLongLong();
240 const ProgramInfo &pginfo,
const QString &cachefile)
242 QString loc(
"RemoteGetPreviewIfModified: ");
243 QDateTime cacheLastModified;
244 QFileInfo cachefileinfo(cachefile);
245 if (cachefileinfo.exists())
246 cacheLastModified = cachefileinfo.lastModified();
248 QStringList strlist(
"QUERY_PIXMAP_GET_IF_MODIFIED");
249 strlist << ((cacheLastModified.isValid()) ?
250 #
if QT_VERSION < QT_VERSION_CHECK(5,8,0)
251 QString::number(cacheLastModified.toTime_t()) :
253 QString::number(cacheLastModified.toSecsSinceEpoch()) :
256 strlist << QString::number(200 * 1024);
260 strlist.isEmpty() || strlist[0] ==
"ERROR")
262 LOG(VB_GENERAL, LOG_ERR, loc +
"Remote error" +
263 ((strlist.size() >= 2) ? (
":\n\t\t\t" + strlist[1]) :
""));
268 if (strlist[0] ==
"WARNING")
270 LOG(VB_NETWORK, LOG_WARNING, loc +
"Remote warning" +
271 ((strlist.size() >= 2) ? (
":\n\t\t\t" + strlist[1]) :
""));
276 QDateTime retdatetime;
277 qlonglong timet = strlist[0].toLongLong();
279 #if QT_VERSION < QT_VERSION_CHECK(5,8,0) 280 retdatetime = MythDate::fromTime_t(timet);
285 if (strlist.size() < 4)
290 size_t length = strlist[1].toULongLong();
291 quint16 checksum16 = strlist[2].toUInt();
292 QByteArray data = QByteArray::fromBase64(strlist[3].toLatin1());
293 if ((
size_t) data.size() < length)
295 LOG(VB_GENERAL, LOG_ERR, loc +
296 QString(
"Preview size check failed %1 < %2")
297 .arg(data.size()).arg(length));
302 if (checksum16 != qChecksum(data.constData(), data.size()))
304 LOG(VB_GENERAL, LOG_ERR, loc +
"Preview checksum failed");
308 QString pdir(cachefile.section(
"/", 0, -2));
310 if (!cfd.exists() && !cfd.mkdir(pdir))
312 LOG(VB_GENERAL, LOG_ERR, loc +
313 QString(
"Unable to create remote cache directory '%1'")
319 QFile file(cachefile);
320 if (!file.open(QIODevice::WriteOnly|QIODevice::Truncate))
322 LOG(VB_GENERAL, LOG_ERR, loc +
323 QString(
"Unable to open cached preview file for writing '%1'")
330 size_t remaining = length;
331 uint failure_cnt = 0;
332 while ((remaining > 0) && (failure_cnt < 5))
334 ssize_t written = file.write(data.data() + offset, remaining);
344 remaining -= written;
349 LOG(VB_GENERAL, LOG_ERR, loc +
350 QString(
"Failed to write cached preview file '%1'")
365 QStringList strlist(
"FILL_PROGRAM_INFO" );
366 strlist << playbackhost;
372 if (
tmp.HasPathname() ||
tmp.GetChanID())
384 QStringList strlist(
"QUERY_ISRECORDING");
400 QString cmd =
"QUERY_ISRECORDING";
402 QStringList strlist( cmd );
407 int recCount = strlist[0].toInt();
409 for (
int i = 0, j = 0; j < recCount; i++)
411 cmd = QString(
"QUERY_RECORDER %1").arg(i + 1);
413 strlist = QStringList( cmd );
414 strlist <<
"IS_RECORDING";
418 if (strlist[0].toInt())
434 QString sgroup,
bool fileNamesOnly)
440 if (sgroup.isEmpty())
443 *list <<
"QUERY_SG_GETFILELIST";
447 *list << QString::number(fileNamesOnly);
458 QString ann = QString(
"ANN Playback %1 0")
462 bool mismatch =
false;
465 addr, port, ann, &mismatch);
488 QStringList strlist( QString(
"CHECK_RECORDING") );
492 return strlist[0].toInt();
506 const ProgramInfo *pginfo,
int overrecsecs,
int underrecsecs)
520 else if (curtime < pginfo->GetScheduledStartTime() &&
537 QString str =
"QUERY_RECORDINGS ";
539 QStringList strlist( str );
541 vector<ProgramInfo *> *reclist =
new vector<ProgramInfo *>;
542 vector<ProgramInfo *> *info =
new vector<ProgramInfo *>;
550 vector<ProgramInfo *>::iterator it = info->begin();
553 for ( ; it != info->end(); ++it)
566 while (!info->empty())
582 *list <<
"QUERY_ACTIVE_BACKENDS";
int RemoteCheckForRecording(const ProgramInfo *pginfo)
Get recorder for a programme.
vector< ProgramInfo * > * RemoteGetCurrentlyRecordingList(void)
return list of currently recording shows
void SetPathname(const QString &) const
QString GetBackendServerIP(void)
Returns the IP address of the locally defined backend IP.
void ToStringList(QStringList &list) const
Serializes ProgramInfo into a QStringList which can be passed over a socket.
bool RemoteGetMemStats(int &totalMB, int &freeMB, int &totalVM, int &freeVM)
void RemoteGetAllExpiringRecordings(vector< ProgramInfo * > &expiringlist)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
bool RemoteFillProgramInfo(ProgramInfo &pginfo, const QString &playbackhost)
bool RemoteDeleteRecording(uint recordingID, bool forceMetadataDelete, bool forgetHistory)
int GetBackendServerPort(void)
Returns the locally defined backend control port.
QDateTime GetScheduledStartTime(void) const
The scheduled start time of program.
Holds information on recordings and videos.
bool RemoteGetActiveBackends(QStringList *list)
return list of backends currently connected to the master
MythSocket * ConnectCommandSocket(const QString &hostname, int port, const QString &announcement, bool *proto_mismatch=nullptr, int maxConnTry=-1, int setup_timeout=-1)
bool SendReceiveStringList(QStringList &strlist, bool quickTimeout=false, bool block=true)
Send a message to the backend and wait for a response.
MBASE_PUBLIC QDateTime fromSecsSinceEpoch(uint seconds)
This function takes the number of seconds since the start of the epoch and returns a QDateTime with t...
QDateTime RemoteGetPreviewIfModified(const ProgramInfo &pginfo, const QString &cachefile)
Download preview & get timestamp if newer than cachefile's last modified time, otherwise just get the...
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
void RemoteGetAllScheduledRecordings(vector< ProgramInfo * > &scheduledlist)
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
QString GetRecordingGroup(void) const
QDateTime GetScheduledEndTime(void) const
The scheduled end time of the program.
bool RemoteGetFileList(QString host, QString path, QStringList *list, QString sgroup, bool fileNamesOnly)
QDateTime RemoteGetPreviewLastModified(const ProgramInfo *pginfo)
vector< ProgramInfo * > * RemoteGetConflictList(const ProgramInfo *pginfo)
int GetNumSetting(const QString &key, int defaultval=0)
#define LOG(_MASK_, _LEVEL_, _STRING_)
static QString GetGroupToUse(const QString &host, const QString &sgroup)
RecStatus::Type GetRecordingStatus(void) const
bool RemoteGetLoad(float load[3])
uint RemoteGetRecordingList(vector< ProgramInfo * > &reclist, QStringList &strList)
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
bool RemoteUndeleteRecording(uint recordingID)
int RemoteGetRecordingMask(void)
bool RemoteCheckFile(const ProgramInfo *pginfo, bool checkSlaves)
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
Class for communcating between myth backends and frontends.
bool SendReceiveStringList(QStringList &list, uint min_reply_length=0, uint timeoutMS=kLongTimeout)
bool RemoteGetUptime(time_t &uptime)
bool IsMasterBackend(void)
is this the actual MBE process
int RemoteGetRecordingStatus(const ProgramInfo *pginfo, int overrecsecs, int underrecsecs)
Get status of an individual programme (with pre-post roll?).
vector< ProgramInfo * > * RemoteGetRecordedList(int sort)
QString GetHostName(void)
QStringList RemoteRecordings(void)