Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Commit

Permalink
pvr/epg: fix EPG clean up for PVR EPG tables
Browse files Browse the repository at this point in the history
  • Loading branch information
opdenkamp committed May 10, 2011
1 parent 4c26155 commit 0efc402
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 26 deletions.
8 changes: 7 additions & 1 deletion xbmc/epg/Epg.cpp
Expand Up @@ -228,6 +228,8 @@ void CEpg::RemoveTagsBetween(time_t start, time_t end, bool bRemoveFromDb /* = f
bMatch = false;
if (end > 0 && tagEnd > end)
bMatch = false;
if (!IsRemovableTag(tag))
bMatch = false;

if (bMatch)
{
Expand All @@ -239,13 +241,17 @@ void CEpg::RemoveTagsBetween(time_t start, time_t end, bool bRemoveFromDb /* = f
}

Sort();
UpdateFirstAndLastDates();

if (bRemoveFromDb)
{
CEpgDatabase *database = g_EpgContainer.GetDatabase();
if (database && database->Open())
{
database->Delete(*this, start, end);
time_t newStart, newEnd;
GetFirstDate().GetAsTime(newStart);
GetLastDate().GetAsTime(newEnd);
database->Delete(*this, newStart, newEnd);
database->Close();
}
}
Expand Down
2 changes: 2 additions & 0 deletions xbmc/epg/Epg.h
Expand Up @@ -126,6 +126,8 @@ namespace EPG
*/
virtual void UpdateFirstAndLastDates(void);

virtual bool IsRemovableTag(const EPG::CEpgInfoTag *tag) const { return true; }

public:
/*!
* @brief Update this table's info with the given info. Doesn't change the EpgID.
Expand Down
21 changes: 3 additions & 18 deletions xbmc/pvr/epg/PVREpg.cpp
Expand Up @@ -48,25 +48,10 @@ bool PVR::CPVREpg::HasValidEntries(void) const
return m_Channel != NULL && m_Channel->ChannelID() > 0 && CEpg::HasValidEntries();
}

void PVR::CPVREpg::Cleanup(const CDateTime &Time)
bool PVR::CPVREpg::IsRemovableTag(const CEpgInfoTag *tag) const
{
CSingleLock lock(m_critSection);

CDateTime firstDate = Time.GetAsUTCDateTime() - CDateTimeSpan(0, g_advancedSettings.m_iEpgLingerTime / 60, g_advancedSettings.m_iEpgLingerTime % 60, 0);

unsigned int iSize = size();
for (unsigned int iTagPtr = 0; iTagPtr < iSize; iTagPtr++)
{
CPVREpgInfoTag *tag = (CPVREpgInfoTag *) at(iTagPtr);
if ( tag && /* valid tag */
!tag->HasTimer() && /* no timer set */
tag->EndAsLocalTime() < firstDate)
{
DeleteInfoTag(tag);
iTagPtr--;
iSize--;
}
}
const CPVREpgInfoTag *epgTag = (CPVREpgInfoTag *) tag;
return (!epgTag || !epgTag->HasTimer());
}

void PVR::CPVREpg::Clear(void)
Expand Down
9 changes: 2 additions & 7 deletions xbmc/pvr/epg/PVREpg.h
Expand Up @@ -59,6 +59,8 @@ namespace PVR
*/
bool Update(const CEpg &epg, bool bUpdateDb = false);

bool IsRemovableTag(const EPG::CEpgInfoTag *tag) const;

public:
/*!
* @brief Create a new EPG instance for a channel.
Expand All @@ -73,13 +75,6 @@ namespace PVR
*/
bool HasValidEntries(void) const;

/*!
* @brief Remove all entries from this EPG that finished before the given time
* and that have no timers set.
* @param Time Delete entries with an end time before this time.
*/
void Cleanup(const CDateTime &Time);

/*!
* @brief Remove all entries from this EPG.
*/
Expand Down

0 comments on commit 0efc402

Please sign in to comment.