Skip to content

Commit

Permalink
Backport of [25363] to 0.23-fixes.
Browse files Browse the repository at this point in the history
Fixed a regression in handling the "delete, but allow re-record"
functionality.  When the playbackbox was reworked to make the GUI more
responsive, the delete action was made asynchronous.  If the program
was still being recorded when the user chose to delete but allow
re-record,, this resulted in the history getting rewritten by the
backend when the recording was stopped.  This change fixed the problem
by passing the desire to allow re-record in the DELETE_RECORDING
command so the backend can fix up the history after the program has
been stopped.

Note: this changes the ABI and protocol versions, so it's probably a
good idea to make clean before compiling.


git-svn-id: http://svn.mythtv.org/svn/branches/release-0-23-fixes@25364 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
gigem committed Jul 17, 2010
1 parent 8ee9aa1 commit 40012a4
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 47 deletions.
3 changes: 2 additions & 1 deletion mythtv/libs/libmyth/programinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ bool ProgramInfo::LoadProgramFromRecorded(
" r.editing, r.bookmark, r.watched, "//31-33
" r.preserve, r.transcoded, r.deletepending, "//34-36
" p.audioprop+0, p.videoprop+0, p.subtitletypes+0, "//37-39
" p.airdate "//40
" p.airdate, r.findid "//40-41
"FROM recorded AS r "
"LEFT JOIN (channel AS c, recordedprogram AS p) "
"ON (r.chanid = c.chanid AND "
Expand Down Expand Up @@ -1474,6 +1474,7 @@ bool ProgramInfo::LoadProgramFromRecorded(
storagegroup = query.value(27).toString();
playgroup = query.value(21).toString();
recpriority = query.value(22).toInt();
findid = query.value(41).toInt();

QString old_basename = pathname.section('/', -1);
QString new_basename = query.value(25).toString();
Expand Down
8 changes: 5 additions & 3 deletions mythtv/libs/libmyth/remoteutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,16 @@ bool RemoteCheckFile(const ProgramInfo *pginfo, bool checkSlaves)
}

bool RemoteDeleteRecording(
uint chanid, const QDateTime &recstartts, bool forceMetadataDelete)
uint chanid, const QDateTime &recstartts, bool forceMetadataDelete,
bool forgetHistory)
{
bool result = true;
QString cmd =
QString("DELETE_RECORDING %1 %2 %3")
QString("DELETE_RECORDING %1 %2 %3 %4")
.arg(chanid)
.arg(recstartts.toString(Qt::ISODate))
.arg(forceMetadataDelete ? "FORCE" : "NO_FORCE");
.arg(forceMetadataDelete ? "FORCE" : "NO_FORCE")
.arg(forgetHistory ? "FORGET" : "NO_FORGET");
QStringList strlist(cmd);

if (!gContext->SendReceiveStringList(strlist) || strlist.empty())
Expand Down
3 changes: 2 additions & 1 deletion mythtv/libs/libmyth/remoteutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ bool RemoteGetMemStats(int &totalMB, int &freeMB, int &totalVM, int &freeVM);
MPUBLIC bool RemoteCheckFile(
const ProgramInfo *pginfo, bool checkSlaves = true);
MPUBLIC bool RemoteDeleteRecording(
uint chanid, const QDateTime &recstartts, bool forceMetadataDelete);
uint chanid, const QDateTime &recstartts, bool forceMetadataDelete,
bool forgetHistory);
MPUBLIC
bool RemoteUndeleteRecording(uint chanid, const QDateTime &recstartts);
MPUBLIC
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythdb/mythversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/// Update this whenever the plug-in API changes.
/// Including changes in the libmythdb, libmyth, libmythtv, libmythav* and
/// libmythui class methods used by plug-ins.
#define MYTH_BINARY_VERSION "0.23.201000617-1"
#define MYTH_BINARY_VERSION "0.23.201000710-1"

/** \brief Increment this whenever the MythTV network protocol changes.
*
Expand All @@ -30,7 +30,7 @@
* mythtv/bindings/python/MythTV/MythTV.py (version number)
* mythtv/bindings/python/MythTV/MythTV.py (layout)
*/
#define MYTH_PROTO_VERSION "56"
#define MYTH_PROTO_VERSION "57"

MPUBLIC const char *GetMythSourceVersion();

Expand Down
26 changes: 17 additions & 9 deletions mythtv/programs/mythbackend/mainserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,11 @@ void MainServer::ProcessRequestWork(MythSocket *sock)
}
else if (command == "DELETE_RECORDING")
{
if (3 <= tokens.size() && tokens.size() <= 4)
if (3 <= tokens.size() && tokens.size() <= 5)
{
bool force = (tokens.size() >= 4) && (tokens[3] == "FORCE");
HandleDeleteRecording(tokens[1], tokens[2], pbs, force);
bool forget = (tokens.size() >= 5) && (tokens[4] == "FORGET");
HandleDeleteRecording(tokens[1], tokens[2], pbs, force, forget);
}
else
HandleDeleteRecording(listline, pbs, false);
Expand Down Expand Up @@ -749,7 +750,7 @@ void MainServer::customEvent(QEvent *e)
{
recInfo.ForgetHistory();
}
DoHandleDeleteRecording(recInfo, NULL, false, true);
DoHandleDeleteRecording(recInfo, NULL, false, true, false);
}
else
{
Expand Down Expand Up @@ -797,9 +798,9 @@ void MainServer::customEvent(QEvent *e)
RecordingInfo recInfo(*pinfo);
delete pinfo;
if (tokens[0] == "FORCE_DELETE_RECORDING")
DoHandleDeleteRecording(recInfo, NULL, true);
DoHandleDeleteRecording(recInfo, NULL, true, false, false);
else
DoHandleDeleteRecording(recInfo, NULL, false);
DoHandleDeleteRecording(recInfo, NULL, false, false, false);
}
else
{
Expand Down Expand Up @@ -2126,7 +2127,8 @@ void MainServer::DoHandleStopRecording(

void MainServer::HandleDeleteRecording(QString &chanid, QString &starttime,
PlaybackSock *pbs,
bool forceMetadataDelete)
bool forceMetadataDelete,
bool forgetHistory)
{
ProgramInfo *pginfo =
ProgramInfo::GetProgramFromRecorded(chanid, starttime);
Expand All @@ -2146,20 +2148,20 @@ void MainServer::HandleDeleteRecording(QString &chanid, QString &starttime,
RecordingInfo ri(*pginfo);
delete pginfo;

DoHandleDeleteRecording(ri, pbs, forceMetadataDelete);
DoHandleDeleteRecording(ri, pbs, forceMetadataDelete, false, forgetHistory);
}

void MainServer::HandleDeleteRecording(QStringList &slist, PlaybackSock *pbs,
bool forceMetadataDelete)
{
RecordingInfo recinfo;
if (recinfo.FromStringList(slist, 1))
DoHandleDeleteRecording(recinfo, pbs, forceMetadataDelete);
DoHandleDeleteRecording(recinfo, pbs, forceMetadataDelete, false, false);
}

void MainServer::DoHandleDeleteRecording(
RecordingInfo &recinfo, PlaybackSock *pbs,
bool forceMetadataDelete, bool expirer)
bool forceMetadataDelete, bool expirer, bool forgetHistory)
{
int resultCode = -1;
MythSocket *pbssock = NULL;
Expand Down Expand Up @@ -2221,6 +2223,9 @@ void MainServer::DoHandleDeleteRecording(
m_sched->UpdateRecStatus(&recinfo);
}

if (forgetHistory)
recinfo.ForgetHistory();

if (pbssock)
{
QStringList outputlist( QString::number(num) );
Expand Down Expand Up @@ -2261,6 +2266,9 @@ void MainServer::DoHandleDeleteRecording(
}
}

if (forgetHistory)
recinfo.ForgetHistory();

QFile checkFile(filename);
bool fileExists = checkFile.exists();
if (!fileExists)
Expand Down
6 changes: 4 additions & 2 deletions mythtv/programs/mythbackend/mainserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ class MainServer : public QObject, public MythSocketCBs
void HandleStopRecording(QStringList &slist, PlaybackSock *pbs);
void DoHandleStopRecording(RecordingInfo &recinfo, PlaybackSock *pbs);
void HandleDeleteRecording(QString &chanid, QString &starttime,
PlaybackSock *pbs, bool forceMetadataDelete);
PlaybackSock *pbs, bool forceMetadataDelete,
bool forgetHistory);
void HandleDeleteRecording(QStringList &slist, PlaybackSock *pbs,
bool forceMetadataDelete);
void DoHandleDeleteRecording(RecordingInfo &recinfo, PlaybackSock *pbs,
bool forceMetadataDelete, bool expirer=false);
bool forceMetadataDelete, bool expirer=false,
bool forgetHistory=false);
void HandleUndeleteRecording(QStringList &slist, PlaybackSock *pbs);
void DoHandleUndeleteRecording(RecordingInfo &recinfo, PlaybackSock *pbs);
void HandleForgetRecording(QStringList &slist, PlaybackSock *pbs);
Expand Down
35 changes: 12 additions & 23 deletions mythtv/programs/mythfrontend/playbackbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,13 @@ static void push_onto_del(QStringList &list, const ProgramInfo &pginfo)
list.push_back(pginfo.chanid);
list.push_back(pginfo.recstartts.toString(Qt::ISODate));
list.push_back(false /* force Delete */);
list.push_back(false); /* forget history */
}

static bool extract_one_del(
QStringList &list, uint &chanid, QDateTime &recstartts)
{
if (list.size() < 3)
if (list.size() < 4)
{
list.clear();
return false;
Expand All @@ -312,6 +313,7 @@ static bool extract_one_del(
list.pop_front();
list.pop_front();
list.pop_front();
list.pop_front();

if (!chanid || !recstartts.isValid())
VERBOSE(VB_IMPORTANT, LOC_ERR + "extract_one_del() invalid entry");
Expand Down Expand Up @@ -2178,19 +2180,14 @@ void PlaybackBox::RemoveProgram(

delItem->availableStatus = asPendingDelete;
m_helper.DeleteRecording(
delItem->chanid.toUInt(), delItem->recstartts, forceMetadataDelete);
delItem->chanid.toUInt(), delItem->recstartts,
forceMetadataDelete, forgetHistory);

// if the item is in the current recording list UI then delete it.
MythUIButtonListItem *uiItem =
m_recordingList->GetItemByData(qVariantFromValue(delItem));
if (uiItem)
m_recordingList->RemoveItem(uiItem);

if (forgetHistory)
{
RecordingInfo recInfo(*delItem);
recInfo.ForgetHistory();
}
}

void PlaybackBox::fanartLoad(void)
Expand Down Expand Up @@ -2407,7 +2404,7 @@ void PlaybackBox::ShowDeletePopup(DeletePopupType type)
{
push_onto_del(m_delList, *delItem);
}
else if (m_delList.size() >= 3)
else if (m_delList.size() >= 4)
{
delItem = FindProgramInUILists(
m_delList[0].toUInt(),
Expand All @@ -2417,7 +2414,7 @@ void PlaybackBox::ShowDeletePopup(DeletePopupType type)
if (!delItem)
return;

uint other_delete_cnt = (m_delList.size() / 3) - 1;
uint other_delete_cnt = (m_delList.size() / 4) - 1;

label += CreateProgramInfoString(*delItem);

Expand Down Expand Up @@ -3241,11 +3238,7 @@ void PlaybackBox::PlaylistDelete(bool forgetHistory)
list.push_back(tmpItem->chanid);
list.push_back(tmpItem->recstartts.toString(Qt::ISODate));
list.push_back(forceDeleteStr);
if (forgetHistory)
{
RecordingInfo recInfo(*tmpItem);
recInfo.ForgetHistory();
}
list.push_back(forgetHistory ? "1" : "0");

// if the item is in the current recording list UI then delete it.
MythUIButtonListItem *uiItem =
Expand Down Expand Up @@ -3865,17 +3858,13 @@ void PlaybackBox::customEvent(QEvent *event)
continue;

QString forceDeleteStr = me->ExtraDataList()[i+2];
bool forgetHistory = me->ExtraDataList()[i+3].toInt();
QString forgetHistoryStr = me->ExtraDataList()[i+3];

list.push_back(pginfo->chanid);
list.push_back(pginfo->recstartts.toString(Qt::ISODate));
list.push_back(forceDeleteStr);
list.push_back(forgetHistoryStr);
pginfo->availableStatus = asPendingDelete;
if (forgetHistory)
{
RecordingInfo recInfo(*pginfo);
recInfo.ForgetHistory();
}

// if the item is in the current recording list UI
// then delete it.
Expand All @@ -3893,10 +3882,10 @@ void PlaybackBox::customEvent(QEvent *event)
}
else if (message == "DELETE_FAILURES")
{
if (me->ExtraDataList().size() < 3)
if (me->ExtraDataList().size() < 4)
return;

for (uint i = 0; i+2 < (uint)me->ExtraDataList().size(); i+=3)
for (uint i = 0; i+3 < (uint)me->ExtraDataList().size(); i += 4)
{
ProgramInfo *pginfo = m_programInfoCache.GetProgramInfo(
me->ExtraDataList()[i+0].toUInt(),
Expand Down
11 changes: 7 additions & 4 deletions mythtv/programs/mythfrontend/playbackboxhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,19 @@ bool PBHEventHandler::event(QEvent *e)
QStringList successes;
QStringList failures;
QStringList list = me->ExtraDataList();
while (list.size() >= 3)
while (list.size() >= 4)
{
uint chanid = list[0].toUInt();
QDateTime recstartts = QDateTime::fromString(
list[1], Qt::ISODate);
bool forceDelete = list[2].toUInt();
bool forgetHistory = list[3].toUInt();

bool ok = RemoteDeleteRecording(
chanid, recstartts, forceDelete);
chanid, recstartts, forceDelete, forgetHistory);

QStringList &res = (ok) ? successes : failures;
for (uint i = 0; i < 3; i++)
for (uint i = 0; i < 4; i++)
{
res.push_back(list.front());
list.pop_front();
Expand Down Expand Up @@ -273,12 +274,14 @@ void PlaybackBoxHelper::StopRecording(const ProgramInfo &pginfo)
}

void PlaybackBoxHelper::DeleteRecording(
uint chanid, const QDateTime &recstartts, bool forceDelete)
uint chanid, const QDateTime &recstartts, bool forceDelete,
bool forgetHistory)
{
QStringList list;
list.push_back(QString::number(chanid));
list.push_back(recstartts.toString(Qt::ISODate));
list.push_back((forceDelete) ? "1" : "0");
list.push_back((forgetHistory) ? "1" : "0");
DeleteRecordings(list);
}

Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythfrontend/playbackboxhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class PlaybackBoxHelper : public QThread
void ForceFreeSpaceUpdate(void);
void StopRecording(const ProgramInfo&);
void DeleteRecording(
uint chanid, const QDateTime &recstartts, bool forceDelete);
uint chanid, const QDateTime &recstartts,
bool forceDelete, bool forgetHistory);
void DeleteRecordings(const QStringList&);
void UndeleteRecording(uint chanid, const QDateTime &recstartts);
void CheckAvailability(const ProgramInfo&,
Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/mythfrontend/statusbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ void StatusBox::customEvent(QEvent *event)
if ((buttonnum == 0) && REC_CAN_BE_DELETED(rec))
{
RemoteDeleteRecording(
rec->chanid.toUInt(), rec->recstartts, false);
rec->chanid.toUInt(), rec->recstartts, false, false);
}
else if (buttonnum == 1)
{
Expand Down

0 comments on commit 40012a4

Please sign in to comment.