19 int numrecordings = strList[0].toInt();
20 if (numrecordings <= 0)
25 LOG(VB_GENERAL, LOG_ERR,
26 "RemoteGetRecordingList() list size appears to be incorrect.");
30 uint reclist_initial_size = (
uint) reclist.size();
31 QStringList::const_iterator it = strList.cbegin() + 1;
32 for (
int i = 0; i < numrecordings; i++)
35 reclist.push_back(pginfo);
38 return ((
uint) reclist.size()) - reclist_initial_size;
43 QString str =
"QUERY_RECORDINGS ";
51 QStringList strlist(str);
53 auto *
info =
new std::vector<ProgramInfo *>;
71 QString(
"DELETE_RECORDING %1 %2 %3 %4")
72 .arg(QString::number(recInfo.
GetChanID()),
74 forceMetadataDelete ?
"FORCE" :
"NO_FORCE",
75 forgetHistory ?
"FORGET" :
"NO_FORGET");
76 QStringList strlist(cmd);
79 (strlist[0].toInt() == -2))
84 LOG(VB_GENERAL, LOG_ALERT,
85 QString(
"Failed to delete recording %1:%2")
104 QStringList strlist(QString(
"UNDELETE_RECORDING"));
105 strlist.push_back(QString::number(recInfo.
GetChanID()));
110 if (!strlist.isEmpty() && strlist[0].toInt() == 0)
118 QStringList strList(QString(
"QUERY_GETALLSCHEDULED"));
124 QStringList strList(QString(
"QUERY_GETEXPIRING"));
130 QString cmd = QString(
"QUERY_GETCONFLICTING");
131 QStringList strlist( cmd );
134 auto *retlist =
new std::vector<ProgramInfo *>;
143 const ProgramInfo &pginfo,
const QString &cachefile)
145 QString loc(
"RemoteGetPreviewIfModified: ");
146 QDateTime cacheLastModified;
147 QFileInfo cachefileinfo(cachefile);
148 if (cachefileinfo.exists())
149 cacheLastModified = cachefileinfo.lastModified();
151 QStringList strlist(
"QUERY_PIXMAP_GET_IF_MODIFIED");
152 strlist << ((cacheLastModified.isValid()) ?
153 QString::number(cacheLastModified.toSecsSinceEpoch()) :
155 strlist << QString::number(200 * 1024);
159 strlist.isEmpty() || strlist[0] ==
"ERROR")
161 LOG(VB_GENERAL, LOG_ERR, loc +
"Remote error" +
162 ((strlist.size() >= 2) ? (
":\n\t\t\t" + strlist[1]) :
""));
167 if (strlist[0] ==
"WARNING")
169 LOG(VB_NETWORK, LOG_WARNING, loc +
"Remote warning" +
170 ((strlist.size() >= 2) ? (
":\n\t\t\t" + strlist[1]) :
""));
175 QDateTime retdatetime;
176 qlonglong timet = strlist[0].toLongLong();
182 if (strlist.size() < 4)
187 size_t length = strlist[1].toULongLong();
188 quint16 checksum16 = strlist[2].toUInt();
189 QByteArray data = QByteArray::fromBase64(strlist[3].toLatin1());
190 if ((
size_t) data.size() < length)
192 LOG(VB_GENERAL, LOG_ERR, loc +
193 QString(
"Preview size check failed %1 < %2")
194 .arg(data.size()).arg(length));
199#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
200 quint16 calculated = qChecksum(data.constData(), data.size());
202 quint16 calculated = qChecksum(data);
204 if (checksum16 != calculated)
206 LOG(VB_GENERAL, LOG_ERR, loc +
"Preview checksum failed");
210 QString pdir(cachefile.section(
"/", 0, -2));
212 if (!cfd.exists() && !cfd.mkdir(pdir))
214 LOG(VB_GENERAL, LOG_ERR, loc +
215 QString(
"Unable to create remote cache directory '%1'")
221 QFile
file(cachefile);
222 if (!
file.open(QIODevice::WriteOnly|QIODevice::Truncate))
224 LOG(VB_GENERAL, LOG_ERR, loc +
225 QString(
"Unable to open cached preview file for writing '%1'")
232 size_t remaining = length;
233 uint failure_cnt = 0;
234 while ((remaining > 0) && (failure_cnt < 5))
236 ssize_t written =
file.write(data.data() + offset, remaining);
246 remaining -= written;
251 LOG(VB_GENERAL, LOG_ERR, loc +
252 QString(
"Failed to write cached preview file '%1'")
bool SendReceiveStringList(QStringList &strlist, bool quickTimeout=false, bool block=true)
Send a message to the backend and wait for a response.
int GetNumSetting(const QString &key, int defaultval=0)
Holds information on recordings and videos.
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
void ToStringList(QStringList &list) const
Serializes ProgramInfo into a QStringList which can be passed over a socket.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MBASE_PUBLIC QDateTime fromSecsSinceEpoch(int64_t seconds)
This function takes the number of seconds since the start of the epoch and returns a QDateTime with t...
static constexpr int8_t NUMPROGRAMLINES
void RemoteGetAllScheduledRecordings(std::vector< ProgramInfo * > &scheduledlist)
QDateTime RemoteGetPreviewIfModified(const ProgramInfo &pginfo, const QString &cachefile)
Download preview & get timestamp if newer than cachefile's last modified time, otherwise just get the...
std::vector< ProgramInfo * > * RemoteGetConflictList(const ProgramInfo *pginfo)
bool RemoteDeleteRecording(uint recordingID, bool forceMetadataDelete, bool forgetHistory)
std::vector< ProgramInfo * > * RemoteGetRecordedList(int sort)
static uint RemoteGetRecordingList(std::vector< ProgramInfo * > &reclist, QStringList &strList)
void RemoteGetAllExpiringRecordings(std::vector< ProgramInfo * > &expiringlist)
bool RemoteUndeleteRecording(uint recordingID)