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

Commit

Permalink
pvr: set to start time of instant timers to 0/invalid. clean up CPVRT…
Browse files Browse the repository at this point in the history
…imers::InstantTimer() and CPVRTimerInfoTag::CreateFromEpg()
  • Loading branch information
opdenkamp committed Apr 11, 2011
1 parent d05afdd commit 6d0615e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 35 deletions.
8 changes: 6 additions & 2 deletions xbmc/pvr/timers/PVRTimerInfoTag.cpp
Expand Up @@ -423,7 +423,7 @@ CPVRTimerInfoTag *CPVRTimerInfoTag::CreateFromEpg(const CPVREpgInfoTag &tag)
}

/* check if a valid channel is set */
const CPVRChannel *channel = tag.ChannelTag();
CPVRChannel *channel = (CPVRChannel *) tag.ChannelTag();
if (channel == NULL)
{
CLog::Log(LOGERROR, "%s - no channel set", __FUNCTION__);
Expand Down Expand Up @@ -456,7 +456,7 @@ CPVRTimerInfoTag *CPVRTimerInfoTag::CreateFromEpg(const CPVREpgInfoTag &tag)
/* set the timer data */
CDateTime newStart = tag.StartAsUTC();
CDateTime newEnd = tag.EndAsUTC();
newTag->m_iClientIndex = (tag.UniqueBroadcastID() > 0 ? tag.UniqueBroadcastID() : channel->ClientID());
newTag->m_iClientIndex = -1;
newTag->m_bIsActive = true;
newTag->m_strTitle = tag.Title().IsEmpty() ? channel->ChannelName() : tag.Title();
newTag->m_iChannelNumber = channel->ChannelNumber();
Expand All @@ -470,6 +470,10 @@ CPVRTimerInfoTag *CPVRTimerInfoTag::CreateFromEpg(const CPVREpgInfoTag &tag)
newTag->m_iMarginStart = iMarginStart;
newTag->m_iMarginEnd = iMarginStop;

/* we might have a copy of the tag here, so get the real one from the pvrmanager */
const CPVREpg *epgTable = channel->GetEPG();
newTag->m_epgInfo = epgTable ? (CPVREpgInfoTag *) epgTable->GetTag(tag.UniqueBroadcastID(), tag.StartAsUTC()) : NULL;

/* generate summary string */
newTag->m_strSummary.Format("%s %s %s %s %s",
newTag->StartAsLocalTime().GetAsLocalizedDate(),
Expand Down
64 changes: 31 additions & 33 deletions xbmc/pvr/timers/PVRTimers.cpp
Expand Up @@ -352,42 +352,40 @@ CPVRTimerInfoTag *CPVRTimers::InstantTimer(CPVRChannel *channel, bool bStartTime
return NULL;
}

CPVRTimerInfoTag *newTimer = new CPVRTimerInfoTag();

const CPVREpgInfoTag *epgTag = channel->GetEPGNow();
int iMarginEnd = g_guiSettings.GetInt("pvrrecord.marginend");
int iPriority = g_guiSettings.GetInt("pvrrecord.defaultpriority");
int iLifetime = g_guiSettings.GetInt("pvrrecord.defaultlifetime");
int iDuration = g_guiSettings.GetInt("pvrrecord.instantrecordtime");
if (!iDuration)
iDuration = 180; /* default to 180 minutes */

int iPriority = g_guiSettings.GetInt("pvrrecord.defaultpriority");
if (!iPriority)
iPriority = 50; /* default to 50 */
CPVRTimerInfoTag *newTimer = CPVRTimerInfoTag::CreateFromEpg(*epgTag);
if (!newTimer)
{
newTimer = new CPVRTimerInfoTag;
/* set the timer data */
newTimer->m_iClientIndex = -1;
newTimer->m_bIsActive = true;
newTimer->m_strTitle = channel->ChannelName();
newTimer->m_strSummary = g_localizeStrings.Get(19056);
newTimer->m_iMarginEnd = iMarginEnd ? iMarginEnd : 5; /* use 5 minutes as default */
newTimer->m_iChannelNumber = channel->ChannelNumber();
newTimer->m_iClientChannelUid = channel->UniqueID();
newTimer->m_iClientId = channel->ClientID();
newTimer->m_bIsRadio = channel->IsRadio();
newTimer->m_iPriority = iPriority ? iPriority : 50; /* default to 50 */
newTimer->m_iLifetime = iLifetime ? iLifetime : 30; /* default to 30 days */

/* generate summary string */
newTimer->m_strSummary.Format("%s %s %s %s %s",
newTimer->StartAsLocalTime().GetAsLocalizedDate(),
g_localizeStrings.Get(19159),
newTimer->StartAsLocalTime().GetAsLocalizedTime("", false),
g_localizeStrings.Get(19160),
newTimer->EndAsLocalTime().GetAsLocalizedTime("", false));
}

int iLifetime = g_guiSettings.GetInt("pvrrecord.defaultlifetime");
if (!iLifetime)
iLifetime = 30; /* default to 30 days */

/* set the timer data */
CDateTime now = CDateTime::GetCurrentDateTime();
newTimer->m_iClientIndex = -1;
newTimer->m_bIsActive = true;
newTimer->m_strTitle = channel->ChannelName();
newTimer->m_strTitle = g_localizeStrings.Get(19056);
newTimer->m_iChannelNumber = channel->ChannelNumber();
newTimer->m_iClientChannelUid = channel->UniqueID();
newTimer->m_iClientId = channel->ClientID();
newTimer->m_bIsRadio = channel->IsRadio();
newTimer->SetStartFromLocalTime(now);
newTimer->SetDuration(iDuration);
newTimer->m_iPriority = iPriority;
newTimer->m_iLifetime = iLifetime;

/* generate summary string */
newTimer->m_strSummary.Format("%s %s %s %s %s",
newTimer->StartAsLocalTime().GetAsLocalizedDate(),
g_localizeStrings.Get(19159),
newTimer->StartAsLocalTime().GetAsLocalizedTime("", false),
g_localizeStrings.Get(19160),
newTimer->EndAsLocalTime().GetAsLocalizedTime("", false));
newTimer->m_iMarginStart = 0;
newTimer->SetDuration(iDuration ? iDuration : 120); /* use 120 minutes as default */

/* unused only for reference */
newTimer->m_strFileNameAndPath = "pvr://timers/new";
Expand Down

0 comments on commit 6d0615e

Please sign in to comment.