void CGUIDialogPVRGuideInfo::OnInitWindow() { CGUIDialog::OnInitWindow(); const CEpgInfoTagPtr tag(m_progItem->GetEPGInfoTag()); if (!tag) { /* no epg event selected */ return; } if (!tag->HasRecording()) { /* not recording. hide the play recording button */ SET_CONTROL_HIDDEN(CONTROL_BTN_PLAY_RECORDING); } if (tag->EndAsLocalTime() <= CDateTime::GetCurrentDateTime()) { /* event has passed. hide the record button */ SET_CONTROL_HIDDEN(CONTROL_BTN_RECORD); return; } CFileItemPtr match = g_PVRTimers->GetTimerForEpgTag(m_progItem.get()); if (!match || !match->HasPVRTimerInfoTag()) { /* no timer present on this tag */ if (tag->StartAsLocalTime() < CDateTime::GetCurrentDateTime()) SET_CONTROL_LABEL(CONTROL_BTN_RECORD, 264); // Record else SET_CONTROL_LABEL(CONTROL_BTN_RECORD, 19061); // Add timer } else { /* timer present on this tag */ if (tag->StartAsLocalTime() < CDateTime::GetCurrentDateTime()) SET_CONTROL_LABEL(CONTROL_BTN_RECORD, 19059); // Stop recording else if (match->HasPVRTimerInfoTag() && match->GetPVRTimerInfoTag()->HasTimerType() && !match->GetPVRTimerInfoTag()->GetTimerType()->IsReadOnly()) SET_CONTROL_LABEL(CONTROL_BTN_RECORD, 19060); // Delete timer else SET_CONTROL_HIDDEN(CONTROL_BTN_RECORD); } }
void CGUIDialogPVRGuideInfo::OnInitWindow() { CGUIDialog::OnInitWindow(); const CEpgInfoTagPtr tag(m_progItem->GetEPGInfoTag()); if (!tag) { /* no epg event selected */ return; } if (!tag->HasRecording()) { /* not recording. hide the play recording button */ SET_CONTROL_HIDDEN(CONTROL_BTN_PLAY_RECORDING); } bool bHideRecord(true); if (tag->HasTimer()) { if (tag->Timer()->IsRecording()) { SET_CONTROL_LABEL(CONTROL_BTN_RECORD, 19059); /* Stop recording */ bHideRecord = false; } else if (tag->Timer()->HasTimerType() && !tag->Timer()->GetTimerType()->IsReadOnly()) { SET_CONTROL_LABEL(CONTROL_BTN_RECORD, 19060); /* Delete timer */ bHideRecord = false; } } else if (tag->EndAsLocalTime() > CDateTime::GetCurrentDateTime()) { SET_CONTROL_LABEL(CONTROL_BTN_RECORD, 264); /* Record */ bHideRecord = false; } if (bHideRecord) SET_CONTROL_HIDDEN(CONTROL_BTN_RECORD); }
CPVRTimerInfoTagPtr CPVRTimerInfoTag::CreateFromEpg(const CEpgInfoTagPtr &tag) { /* create a new timer */ CPVRTimerInfoTagPtr newTag(new CPVRTimerInfoTag()); if (!newTag) { CLog::Log(LOGERROR, "%s - couldn't create new timer", __FUNCTION__); return CPVRTimerInfoTagPtr(); } /* check if a valid channel is set */ CPVRChannelPtr channel = tag->ChannelTag(); if (!channel) { CLog::Log(LOGERROR, "%s - no channel set", __FUNCTION__); return CPVRTimerInfoTagPtr(); } /* 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 CPVRTimerInfoTagPtr(); } /* 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; }
CPVRTimerInfoTagPtr CPVRTimerInfoTag::CreateFromEpg(const CEpgInfoTagPtr &tag, bool bCreateRule /* = false */) { /* create a new timer */ CPVRTimerInfoTagPtr newTag(new CPVRTimerInfoTag()); /* check if a valid channel is set */ CPVRChannelPtr channel = tag->ChannelTag(); if (!channel) { CLog::Log(LOGERROR, "%s - no channel set", __FUNCTION__); return CPVRTimerInfoTagPtr(); } /* check if the epg end date is in the future */ if (tag->EndAsLocalTime() < CDateTime::GetCurrentDateTime() && !bCreateRule) { CLog::Log(LOGERROR, "%s - end time is in the past", __FUNCTION__); return CPVRTimerInfoTagPtr(); } /* set the timer data */ CDateTime newStart = tag->StartAsUTC(); CDateTime newEnd = tag->EndAsUTC(); newTag->m_iClientIndex = PVR_TIMER_NO_CLIENT_INDEX; newTag->m_iParentClientIndex = PVR_TIMER_NO_PARENT; 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_channel = channel; newTag->m_iEpgUid = tag->UniqueBroadcastID(); newTag->SetStartFromUTC(newStart); newTag->SetEndFromUTC(newEnd); CPVRTimerTypePtr timerType; if (bCreateRule) { // create epg-based timer rule timerType = CPVRTimerType::CreateFromAttributes( PVR_TIMER_TYPE_IS_REPEATING, PVR_TIMER_TYPE_IS_MANUAL | PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES, channel->ClientID()); if (timerType) { if (timerType->SupportsEpgTitleMatch()) newTag->m_strEpgSearchString = newTag->m_strTitle; if (timerType->SupportsWeekdays()) newTag->m_iWeekdays = PVR_WEEKDAY_ALLDAYS; if (timerType->SupportsStartAnyTime()) newTag->m_bStartAnyTime = true; if (timerType->SupportsEndAnyTime()) newTag->m_bEndAnyTime = true; } } else { // create one-shot epg-based timer timerType = CPVRTimerType::CreateFromAttributes( PVR_TIMER_TYPE_ATTRIBUTE_NONE, PVR_TIMER_TYPE_IS_REPEATING | PVR_TIMER_TYPE_IS_MANUAL | PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES, channel->ClientID()); } if (!timerType) { CLog::Log(LOGERROR, "%s - unable to create any epg-based timer type", __FUNCTION__); return CPVRTimerInfoTagPtr(); } newTag->SetTimerType(timerType); newTag->UpdateSummary(); newTag->UpdateEpgInfoTag(); /* unused only for reference */ newTag->m_strFileNameAndPath = CPVRTimersPath::PATH_NEW; return newTag; }
CPVRTimerInfoTagPtr CPVRTimerInfoTag::CreateFromEpg(const CEpgInfoTagPtr &tag, bool bRepeating /* = false */) { /* create a new timer */ CPVRTimerInfoTagPtr newTag(new CPVRTimerInfoTag()); /* check if a valid channel is set */ CPVRChannelPtr channel = tag->ChannelTag(); if (!channel) { CLog::Log(LOGERROR, "%s - no channel set", __FUNCTION__); return CPVRTimerInfoTagPtr(); } /* 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 CPVRTimerInfoTagPtr(); } /* set the timer data */ CDateTime newStart = tag->StartAsUTC(); CDateTime newEnd = tag->EndAsUTC(); newTag->m_iClientIndex = -1; newTag->m_iParentClientIndex = PVR_TIMER_NO_PARENT; 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); CPVRTimerTypePtr timerType; if (bRepeating) { // create repeating epg-based timer timerType = CPVRTimerType::CreateFromAttributes( PVR_TIMER_TYPE_IS_REPEATING, PVR_TIMER_TYPE_IS_MANUAL | PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES, channel->ClientID()); } if (!timerType) { // create one-shot epg-based timer timerType = CPVRTimerType::CreateFromAttributes( PVR_TIMER_TYPE_ATTRIBUTE_NONE, PVR_TIMER_TYPE_IS_REPEATING | PVR_TIMER_TYPE_IS_MANUAL | PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES, channel->ClientID()); } if (!timerType) { CLog::Log(LOGERROR, "%s - unable to create any epg-based timer type", __FUNCTION__); return CPVRTimerInfoTagPtr(); } newTag->SetTimerType(timerType); newTag->UpdateSummary(); newTag->m_epgTag = g_EpgContainer.GetById(tag->EpgID())->GetTag(tag->StartAsUTC()); /* unused only for reference */ newTag->m_strFileNameAndPath = CPVRTimersPath::PATH_NEW; return newTag; }