CPVRTimerInfoTag *CPVRTimerInfoTag::CreateFromEpg(const CEpgInfoTag &tag) { /* create a new timer */ CPVRTimerInfoTag *newTag = new CPVRTimerInfoTag(); if (!newTag) { CLog::Log(LOGERROR, "%s - couldn't create new timer", __FUNCTION__); return NULL; } /* check if a valid channel is set */ CPVRChannel *channel = (CPVRChannel *) tag.ChannelTag(); if (channel == NULL) { CLog::Log(LOGERROR, "%s - no channel set", __FUNCTION__); return NULL; } /* check if the epg end date is in the future */ if (tag.EndAsLocalTime() < CDateTime::GetCurrentDateTime()) { CLog::Log(LOGERROR, "%s - end time is in the past", __FUNCTION__); return NULL; } /* set the timer data */ CDateTime newStart = tag.StartAsUTC(); CDateTime newEnd = tag.EndAsUTC(); newTag->m_iClientIndex = -1; newTag->m_strTitle = tag.Title().IsEmpty() ? channel->ChannelName() : tag.Title(); newTag->m_iChannelNumber = channel->ChannelNumber(); newTag->m_iClientChannelUid = channel->UniqueID(); newTag->m_iClientId = channel->ClientID(); newTag->m_bIsRadio = channel->IsRadio(); newTag->SetStartFromUTC(newStart); newTag->SetEndFromUTC(newEnd); if (tag.Plot().IsEmpty()) { newTag->m_strSummary.Format("%s %s %s %s %s", newTag->StartAsLocalTime().GetAsLocalizedDate(), g_localizeStrings.Get(19159), newTag->StartAsLocalTime().GetAsLocalizedTime("", false), g_localizeStrings.Get(19160), newTag->EndAsLocalTime().GetAsLocalizedTime("", false)); } else { newTag->m_strSummary = tag.Plot(); } /* we might have a copy of the tag here, so get the real one from the pvrmanager */ const CEpg *epgTable = channel->GetEPG(); newTag->m_epgInfo = epgTable ? epgTable->GetTag(tag.UniqueBroadcastID(), tag.StartAsUTC()) : NULL; /* unused only for reference */ newTag->m_strFileNameAndPath = "pvr://timers/new"; return newTag; }
CPVRTimerInfoTag *CPVRTimers::InstantTimer(const CPVRChannel &channel, bool bStartTimer /* = true */) { if (!g_PVRManager.CheckParentalLock(channel)) return NULL; CEpgInfoTag epgTag; bool bHasEpgNow = channel.GetEPGNow(epgTag); CPVRTimerInfoTag *newTimer = bHasEpgNow ? CPVRTimerInfoTag::CreateFromEpg(epgTag) : NULL; if (!newTimer) { newTimer = new CPVRTimerInfoTag; /* set the timer data */ newTimer->m_iClientIndex = -1; newTimer->m_strTitle = channel.ChannelName(); newTimer->m_strSummary = g_localizeStrings.Get(19056); newTimer->m_iChannelNumber = channel.ChannelNumber(); newTimer->m_iClientChannelUid = channel.UniqueID(); newTimer->m_iClientId = channel.ClientID(); newTimer->m_bIsRadio = channel.IsRadio(); /* generate summary string */ newTimer->m_strSummary.Format("%s %s %s %s %s", newTimer->StartAsLocalTime().GetAsLocalizedDate(), g_localizeStrings.Get(19159), newTimer->StartAsLocalTime().GetAsLocalizedTime(StringUtils::EmptyString, false), g_localizeStrings.Get(19160), newTimer->EndAsLocalTime().GetAsLocalizedTime(StringUtils::EmptyString, false)); } CDateTime startTime(0); newTimer->SetStartFromUTC(startTime); newTimer->m_iMarginStart = 0; /* set the start margin to 0 for instant timers */ int iDuration = g_guiSettings.GetInt("pvrrecord.instantrecordtime"); CDateTime endTime = CDateTime::GetUTCDateTime() + CDateTimeSpan(0, 0, iDuration ? iDuration : 120, 0); newTimer->SetEndFromUTC(endTime); /* unused only for reference */ newTimer->m_strFileNameAndPath = "pvr://timers/new"; if (bStartTimer && !newTimer->AddToClient()) { CLog::Log(LOGERROR, "PVRTimers - %s - unable to add an instant timer on the client", __FUNCTION__); delete newTimer; newTimer = NULL; } return newTimer; }
CPVRTimerInfoTag *CPVRTimerInfoTag::CreateFromEpg(const CEpgInfoTag &tag) { /* create a new timer */ CPVRTimerInfoTag *newTag = new CPVRTimerInfoTag(); if (!newTag) { CLog::Log(LOGERROR, "%s - couldn't create new timer", __FUNCTION__); return NULL; } /* check if a valid channel is set */ CPVRChannelPtr channel = tag.ChannelTag(); if (!channel) { CLog::Log(LOGERROR, "%s - no channel set", __FUNCTION__); delete newTag; return NULL; } /* check if the epg end date is in the future */ if (tag.EndAsLocalTime() < CDateTime::GetCurrentDateTime()) { CLog::Log(LOGERROR, "%s - end time is in the past", __FUNCTION__); delete newTag; return NULL; } /* set the timer data */ CDateTime newStart = tag.StartAsUTC(); CDateTime newEnd = tag.EndAsUTC(); newTag->m_iClientIndex = -1; newTag->m_strTitle = tag.Title().empty() ? channel->ChannelName() : tag.Title(); newTag->m_iChannelNumber = channel->ChannelNumber(); newTag->m_iClientChannelUid = channel->UniqueID(); newTag->m_iClientId = channel->ClientID(); newTag->m_bIsRadio = channel->IsRadio(); newTag->m_iGenreType = tag.GenreType(); newTag->m_iGenreSubType = tag.GenreSubType(); newTag->m_channel = channel; newTag->SetStartFromUTC(newStart); newTag->SetEndFromUTC(newEnd); if (tag.Plot().empty()) { newTag->m_strSummary= StringUtils::Format("%s %s %s %s %s", newTag->StartAsLocalTime().GetAsLocalizedDate().c_str(), g_localizeStrings.Get(19159).c_str(), newTag->StartAsLocalTime().GetAsLocalizedTime("", false).c_str(), g_localizeStrings.Get(19160).c_str(), newTag->EndAsLocalTime().GetAsLocalizedTime("", false).c_str()); } else { newTag->m_strSummary = tag.Plot(); } newTag->m_epgTag = g_EpgContainer.GetById(tag.EpgID())->GetTag(tag.StartAsUTC()); /* unused only for reference */ newTag->m_strFileNameAndPath = "pvr://timers/new"; return newTag; }