4636
void MainServer::HandlePixmapGetIfModified(
4637
const QStringList &slist, PlaybackSock *pbs)
4639
QStringList strlist;
4641
MythSocket *pbssock = pbs->getSocket();
4642
if (slist.size() < (3 + NUMPROGRAMLINES))
4644
strlist = QStringList("ERROR");
4645
strlist += "1: Parameter list too short";
4646
SendResponse(pbssock, strlist);
4650
QDateTime cachemodified;
4651
if (slist[1].toInt() != -1)
4652
cachemodified.setTime_t(slist[1].toInt());
4654
int max_file_size = slist[2].toInt();
4658
if (!pginfo.FromStringList(slist, 3))
4660
strlist = QStringList("ERROR");
4661
strlist += "2: Invalid ProgramInfo";
4662
SendResponse(pbssock, strlist);
4666
pginfo.pathname = GetPlaybackURL(&pginfo) + ".png";
4667
if (pginfo.pathname.left(1) == "/")
4669
QFileInfo finfo(pginfo.pathname);
4672
size_t fsize = finfo.size();
4673
QDateTime lastmodified = finfo.lastModified();
4674
bool out_of_date = !cachemodified.isValid() ||
4675
(lastmodified > cachemodified);
4677
if (out_of_date && (fsize > 0) && ((ssize_t)fsize < max_file_size))
4680
QFile file(pginfo.pathname);
4681
bool open_ok = file.open(QIODevice::ReadOnly);
4683
data = file.readAll();
4687
VERBOSE(VB_FILE, QString("Read preview file '%1'")
4688
.arg(pginfo.pathname));
4689
strlist += QString::number(lastmodified.toTime_t());
4690
strlist += QString::number(data.size());
4691
strlist += QString::number(
4692
qChecksum(data.constData(), data.size()));
4693
strlist += QString(data.toBase64());
4697
VERBOSE(VB_IMPORTANT,
4698
QString("Failed to read preview file '%1'")
4699
.arg(pginfo.pathname));
4701
strlist = QStringList("ERROR");
4703
QString("3: Failed to read preview file '%1'%2")
4704
.arg(pginfo.pathname)
4705
.arg((open_ok) ? "" : " open failed");
4708
else if (out_of_date && (max_file_size > 0))
4710
if (fsize >= (size_t) max_file_size)
4712
strlist = QStringList("WARNING");
4713
strlist += QString("1: Preview file too big %1 > %2")
4714
.arg(fsize).arg(max_file_size);
4718
strlist = QStringList("ERROR");
4719
strlist += "4: Preview file is invalid";
4724
strlist += QString::number(lastmodified.toTime_t());
4727
SendResponse(pbssock, strlist);
4732
// handle remote ...
4733
if (ismaster && pginfo.hostname != gContext->GetHostName())
4735
PlaybackSock *slave = getSlaveByHostname(pginfo.hostname);
4738
strlist = QStringList("ERROR");
4740
"5: Could not locate mythbackend that made this recording";
4741
SendResponse(pbssock, strlist);
4745
strlist = slave->ForwardRequest(slist);
4747
slave->DownRef(); slave = NULL;
4749
if (!strlist.empty())
4751
SendResponse(pbssock, strlist);
4756
strlist = QStringList("WARNING");
4757
strlist += "2: Could not locate requested file";
4758
SendResponse(pbssock, strlist);
4620
4761
void MainServer::HandleBackendRefresh(MythSocket *socket)
4622
4763
gContext->RefreshBackendConfig();