void CGUIWindowPVRTimers::GetContextButtons(int itemNumber, CContextButtons &buttons) const { if (itemNumber < 0 || itemNumber >= m_parent->m_vecItems->Size()) return; CFileItemPtr pItem = m_parent->m_vecItems->Get(itemNumber); /* Check for a empty file item list, means only a file item with the name "Add timer..." is present */ if (pItem->GetPath() == "pvr://timers/add.timer") { buttons.Add(CONTEXT_BUTTON_ADD, 19056); /* new timer */ if (m_parent->m_vecItems->Size() > 1) { buttons.Add(CONTEXT_BUTTON_SORTBY_NAME, 103); /* sort by name */ buttons.Add(CONTEXT_BUTTON_SORTBY_DATE, 104); /* sort by date */ } } else { buttons.Add(CONTEXT_BUTTON_EDIT, 19057); /* edit timer */ buttons.Add(CONTEXT_BUTTON_ADD, 19056); /* new timer */ buttons.Add(CONTEXT_BUTTON_ACTIVATE, 19058); /* activate/deactivate */ buttons.Add(CONTEXT_BUTTON_RENAME, 118); /* rename timer */ buttons.Add(CONTEXT_BUTTON_DELETE, 117); /* delete timer */ buttons.Add(CONTEXT_BUTTON_SORTBY_NAME, 103); /* sort by name */ buttons.Add(CONTEXT_BUTTON_SORTBY_DATE, 104); /* sort by date */ if (g_PVRClients->HasMenuHooks(pItem->GetPVRTimerInfoTag()->m_iClientId)) buttons.Add(CONTEXT_BUTTON_MENU_HOOKS, 19195); /* PVR client specific action */ } }
void CGUIWindowPVRTimers::GetContextButtons(int itemNumber, CContextButtons &buttons) { if (itemNumber < 0 || itemNumber >= m_vecItems->Size()) return; CFileItemPtr pItem = m_vecItems->Get(itemNumber); /* Check for a empty file item list, means only a file item with the name "Add timer..." is present */ if (URIUtils::PathEquals(pItem->GetPath(), "pvr://timers/addtimer/")) { buttons.Add(CONTEXT_BUTTON_ADD, 19056); /* new timer */ } else { buttons.Add(CONTEXT_BUTTON_FIND, 19003); /* Find similar program */ buttons.Add(CONTEXT_BUTTON_ACTIVATE, 19058); /* activate/deactivate */ buttons.Add(CONTEXT_BUTTON_DELETE, 117); /* delete timer */ buttons.Add(CONTEXT_BUTTON_EDIT, 19057); /* edit timer */ buttons.Add(CONTEXT_BUTTON_RENAME, 118); /* rename timer */ buttons.Add(CONTEXT_BUTTON_ADD, 19056); /* new timer */ if (g_PVRClients->HasMenuHooks(pItem->GetPVRTimerInfoTag()->m_iClientId, PVR_MENUHOOK_TIMER)) buttons.Add(CONTEXT_BUTTON_MENU_HOOKS, 19195); /* PVR client specific action */ } CGUIWindowPVRBase::GetContextButtons(itemNumber, buttons); CContextMenuManager::Get().AddVisibleItems(pItem, buttons); }
int EpgSearchFilter::FilterTimers(CFileItemList &results) { int iRemoved(0); if (!g_PVRManager.IsStarted()) return iRemoved; vector<CFileItemPtr> timers = g_PVRTimers->GetActiveTimers(); // TODO inefficient! for (unsigned int iTimerPtr = 0; iTimerPtr < timers.size(); iTimerPtr++) { CFileItemPtr fileItem = timers.at(iTimerPtr); if (!fileItem || !fileItem->HasPVRTimerInfoTag()) continue; CPVRTimerInfoTag *timer = fileItem->GetPVRTimerInfoTag(); if (!timer) continue; for (int iResultPtr = 0; iResultPtr < results.Size(); iResultPtr++) { const CEpgInfoTagPtr epgentry(results.Get(iResultPtr)->GetEPGInfoTag()); if (!epgentry || *epgentry->ChannelTag() != *timer->ChannelTag() || epgentry->StartAsUTC() < timer->StartAsUTC() || epgentry->EndAsUTC() > timer->EndAsUTC()) continue; results.Remove(iResultPtr); iResultPtr--; ++iRemoved; } } return iRemoved; }
bool CPVRManager::AllLocalBackendsIdle(CPVRTimerInfoTagPtr& causingEvent) const { if (m_timers) { // active recording on local backend? std::vector<CFileItemPtr> recordings = m_timers->GetActiveRecordings(); for (std::vector<CFileItemPtr>::const_iterator timerIt = recordings.begin(); timerIt != recordings.end(); ++timerIt) { if (EventOccursOnLocalBackend(*timerIt)) { causingEvent = (*timerIt)->GetPVRTimerInfoTag(); return false; } } // soon recording on local backend? if (IsNextEventWithinBackendIdleTime()) { CFileItemPtr item = m_timers->GetNextActiveTimer(); if (item.get() == NULL) { // Next event is due to automatic daily wakeup of PVR! causingEvent.reset(); return false; } if (EventOccursOnLocalBackend(item)) { causingEvent = item->GetPVRTimerInfoTag(); return false; } } } return true; }
void CPVRGUIInfo::TimerInfo::UpdateNextTimer() { std::string strNextRecordingTitle; std::string strNextRecordingChannelName; std::string strNextRecordingChannelIcon; std::string strNextRecordingTime; std::string strNextTimerInfo; CFileItemPtr tag = GetNextActiveTimer(); if (tag && tag->HasPVRTimerInfoTag()) { CPVRTimerInfoTagPtr timer = tag->GetPVRTimerInfoTag(); strNextRecordingTitle = StringUtils::Format("%s", timer->Title().c_str()); strNextRecordingChannelName = StringUtils::Format("%s", timer->ChannelName().c_str()); strNextRecordingChannelIcon = StringUtils::Format("%s", timer->ChannelIcon().c_str()); strNextRecordingTime = StringUtils::Format("%s", timer->StartAsLocalTime().GetAsLocalizedDateTime(false, false).c_str()); strNextTimerInfo = StringUtils::Format("%s %s %s %s", g_localizeStrings.Get(19106).c_str(), timer->StartAsLocalTime().GetAsLocalizedDate(true).c_str(), g_localizeStrings.Get(19107).c_str(), timer->StartAsLocalTime().GetAsLocalizedTime("HH:mm", false).c_str()); } CSingleLock lock(m_critSection); m_strNextRecordingTitle = strNextRecordingTitle; m_strNextRecordingChannelName = strNextRecordingChannelName; m_strNextRecordingChannelIcon = strNextRecordingChannelIcon; m_strNextRecordingTime = strNextRecordingTime; m_strNextTimerInfo = strNextTimerInfo; }
void CGUIWindowPVRGuide::GetContextButtons(int itemNumber, CContextButtons &buttons) const { if (itemNumber < 0 || itemNumber >= m_parent->m_vecItems->Size()) return; CFileItemPtr pItem = m_parent->m_vecItems->Get(itemNumber); CFileItemPtr timer = g_PVRTimers->GetTimerForEpgTag(pItem.get()); if (timer && timer->HasPVRTimerInfoTag()) { if (timer->GetPVRTimerInfoTag()->IsRecording()) buttons.Add(CONTEXT_BUTTON_STOP_RECORD, 19059); /* stop recording */ else buttons.Add(CONTEXT_BUTTON_STOP_RECORD, 19060); /* delete timer */ } else if (pItem->GetEPGInfoTag()->EndAsLocalTime() > CDateTime::GetCurrentDateTime()) { if (pItem->GetEPGInfoTag()->StartAsLocalTime() < CDateTime::GetCurrentDateTime()) buttons.Add(CONTEXT_BUTTON_START_RECORD, 264); /* record */ else buttons.Add(CONTEXT_BUTTON_START_RECORD, 19061); /* add timer */ } buttons.Add(CONTEXT_BUTTON_INFO, 19047); /* epg info */ buttons.Add(CONTEXT_BUTTON_PLAY_ITEM, 19000); /* switch channel */ buttons.Add(CONTEXT_BUTTON_FIND, 19003); /* find similar program */ if (m_iGuideView == GUIDE_VIEW_TIMELINE) { buttons.Add(CONTEXT_BUTTON_BEGIN, 19063); /* go to begin */ buttons.Add(CONTEXT_BUTTON_END, 19064); /* go to end */ } if (pItem->GetEPGInfoTag()->HasPVRChannel() && g_PVRClients->HasMenuHooks(pItem->GetEPGInfoTag()->ChannelTag()->ClientID(), PVR_MENUHOOK_EPG)) buttons.Add(CONTEXT_BUTTON_MENU_HOOKS, 19195); /* PVR client specific action */ }
void CPVRGUIInfo::UpdateNextTimer(void) { CStdString strNextRecordingTitle; CStdString strNextRecordingChannelName; CStdString strNextRecordingChannelIcon; CStdString strNextRecordingTime; CStdString strNextTimerInfo; CFileItemPtr tag = g_PVRTimers->GetNextActiveTimer(); if (tag && tag->HasPVRTimerInfoTag()) { CPVRTimerInfoTag *timer = tag->GetPVRTimerInfoTag(); strNextRecordingTitle.Format("%s", timer->Title()); strNextRecordingChannelName.Format("%s", timer->ChannelName()); strNextRecordingChannelIcon.Format("%s", timer->ChannelIcon()); strNextRecordingTime.Format("%s", timer->StartAsLocalTime().GetAsLocalizedDateTime(false, false)); strNextTimerInfo.Format("%s %s %s %s", g_localizeStrings.Get(19106), timer->StartAsLocalTime().GetAsLocalizedDate(true), g_localizeStrings.Get(19107), timer->StartAsLocalTime().GetAsLocalizedTime("HH:mm", false)); } CSingleLock lock(m_critSection); m_strNextRecordingTitle = strNextRecordingTitle; m_strNextRecordingChannelName = strNextRecordingChannelName; m_strNextRecordingChannelIcon = strNextRecordingChannelIcon; m_strNextRecordingTime = strNextRecordingTime; m_strNextTimerInfo = strNextTimerInfo; }
bool CGUIDialogPVRGuideInfo::ActionCancelTimer(CFileItemPtr timer) { bool bReturn = false; if (!timer || !timer->HasPVRTimerInfoTag()) { return bReturn; } // prompt user for confirmation of timer deletion CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (pDialog) { pDialog->SetHeading(265); pDialog->SetLine(0, ""); pDialog->SetLine(1, timer->GetPVRTimerInfoTag()->m_strTitle); pDialog->SetLine(2, ""); pDialog->DoModal(); if (pDialog->IsConfirmed()) { Close(); bReturn = CPVRTimers::DeleteTimer(*timer); } } return bReturn; }
void CGUIWindowPVRGuide::GetContextButtons(int itemNumber, CContextButtons &buttons) { if (itemNumber < 0 || itemNumber >= m_vecItems->Size()) return; CFileItemPtr pItem = m_vecItems->Get(itemNumber); buttons.Add(CONTEXT_BUTTON_PLAY_ITEM, 19000); /* switch channel */ if (pItem->HasEPGInfoTag() && pItem->GetEPGInfoTag()->HasRecording()) buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 19687); /* play recording */ CFileItemPtr timer = g_PVRTimers->GetTimerForEpgTag(pItem.get()); if (timer && timer->HasPVRTimerInfoTag()) { if (timer->GetPVRTimerInfoTag()->IsRecording()) buttons.Add(CONTEXT_BUTTON_STOP_RECORD, 19059); /* stop recording */ else if (timer->GetPVRTimerInfoTag()->HasTimerType() && !timer->GetPVRTimerInfoTag()->GetTimerType()->IsReadOnly()) buttons.Add(CONTEXT_BUTTON_STOP_RECORD, 19060); /* delete timer */ } else if (pItem->HasEPGInfoTag() && pItem->GetEPGInfoTag()->EndAsLocalTime() > CDateTime::GetCurrentDateTime()) { if (pItem->GetEPGInfoTag()->StartAsLocalTime() < CDateTime::GetCurrentDateTime()) buttons.Add(CONTEXT_BUTTON_START_RECORD, 264); /* record */ buttons.Add(CONTEXT_BUTTON_START_RECORD, 19061); /* add timer */ buttons.Add(CONTEXT_BUTTON_ADVANCED_RECORD, 841); /* add custom timer */ } buttons.Add(CONTEXT_BUTTON_INFO, 19047); /* epg info */ buttons.Add(CONTEXT_BUTTON_FIND, 19003); /* find similar program */ if (m_viewControl.GetCurrentControl() == GUIDE_VIEW_TIMELINE) { buttons.Add(CONTEXT_BUTTON_BEGIN, 19063); /* go to begin */ buttons.Add(CONTEXT_BUTTON_NOW, 19070); /* go to now */ buttons.Add(CONTEXT_BUTTON_END, 19064); /* go to end */ } if (pItem->HasEPGInfoTag() && pItem->GetEPGInfoTag()->HasPVRChannel() && g_PVRClients->HasMenuHooks(pItem->GetEPGInfoTag()->ChannelTag()->ClientID(), PVR_MENUHOOK_EPG)) buttons.Add(CONTEXT_BUTTON_MENU_HOOKS, 19195); /* PVR client specific action */ CGUIWindowPVRBase::GetContextButtons(itemNumber, buttons); CContextMenuManager::Get().AddVisibleItems(pItem, buttons); }
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); } }
CDateTime CPVRTimers::GetNextEventTime(void) const { const bool dailywakup = CSettings::Get().GetBool("pvrpowermanagement.dailywakeup"); const CDateTime now = CDateTime::GetUTCDateTime(); const CDateTimeSpan prewakeup(0, 0, CSettings::Get().GetInt("pvrpowermanagement.prewakeup"), 0); const CDateTimeSpan idle(0, 0, CSettings::Get().GetInt("pvrpowermanagement.backendidletime"), 0); CDateTime wakeuptime; /* Check next active time */ CFileItemPtr item = GetNextActiveTimer(); if (item && item->HasPVRTimerInfoTag()) { const CDateTimeSpan prestart(0, 0, item->GetPVRTimerInfoTag()->MarginStart(), 0); const CDateTime start = item->GetPVRTimerInfoTag()->StartAsUTC(); wakeuptime = ((start - prestart - prewakeup - idle) > now) ? start - prestart - prewakeup : now + idle; } /* check daily wake up */ if (dailywakup) { CDateTime dailywakeuptime; dailywakeuptime.SetFromDBTime(CSettings::Get().GetString("pvrpowermanagement.dailywakeuptime")); dailywakeuptime = dailywakeuptime.GetAsUTCDateTime(); dailywakeuptime.SetDateTime( now.GetYear(), now.GetMonth(), now.GetDay(), dailywakeuptime.GetHour(), dailywakeuptime.GetMinute(), dailywakeuptime.GetSecond() ); if ((dailywakeuptime - idle) < now) { const CDateTimeSpan oneDay(1,0,0,0); dailywakeuptime += oneDay; } if (!wakeuptime.IsValid() || dailywakeuptime < wakeuptime) wakeuptime = dailywakeuptime; } const CDateTime retVal(wakeuptime); return retVal; }
CDateTime CPVRTimers::GetNextEventTime(void) const { const bool dailywakup = CSettings::GetInstance().GetBool(CSettings::SETTING_PVRPOWERMANAGEMENT_DAILYWAKEUP); const CDateTime now = CDateTime::GetUTCDateTime(); const CDateTimeSpan prewakeup(0, 0, CSettings::GetInstance().GetInt(CSettings::SETTING_PVRPOWERMANAGEMENT_PREWAKEUP), 0); const CDateTimeSpan idle(0, 0, CSettings::GetInstance().GetInt(CSettings::SETTING_PVRPOWERMANAGEMENT_BACKENDIDLETIME), 0); CDateTime wakeuptime; /* Check next active time */ CFileItemPtr item = GetNextActiveTimer(); if (item && item->HasPVRTimerInfoTag()) { const CDateTimeSpan prestart(0, 0, item->GetPVRTimerInfoTag()->MarginStart(), 0); const CDateTime start = item->GetPVRTimerInfoTag()->StartAsUTC(); wakeuptime = ((start - prestart - prewakeup - idle) > now) ? start - prestart - prewakeup : now + idle; } /* check daily wake up */ if (dailywakup) { CDateTime dailywakeuptime; dailywakeuptime.SetFromDBTime(CSettings::GetInstance().GetString(CSettings::SETTING_PVRPOWERMANAGEMENT_DAILYWAKEUPTIME)); dailywakeuptime = dailywakeuptime.GetAsUTCDateTime(); dailywakeuptime.SetDateTime( now.GetYear(), now.GetMonth(), now.GetDay(), dailywakeuptime.GetHour(), dailywakeuptime.GetMinute(), dailywakeuptime.GetSecond() ); if ((dailywakeuptime - idle) < now) { const CDateTimeSpan oneDay(1,0,0,0); dailywakeuptime += oneDay; } if (!wakeuptime.IsValid() || dailywakeuptime < wakeuptime) wakeuptime = dailywakeuptime; } const CDateTime retVal(wakeuptime); return retVal; }
bool CGUIWindowPVRBase::DeleteTimer(CFileItem *item, bool bIsRecording) { CFileItemPtr timer; if (item->IsPVRTimer()) { timer.reset(new CFileItem(*item)); } else if (item->IsEPG()) { timer = g_PVRTimers->GetTimerForEpgTag(item); } else if (item->IsPVRChannel()) { CPVRChannelPtr channel(item->GetPVRChannelInfoTag()); if (!channel) return false; CFileItemPtr epgNow(new CFileItem(channel->GetEPGNow())); timer = g_PVRTimers->GetTimerForEpgTag(epgNow.get()); } if (!timer || !timer->HasPVRTimerInfoTag()) return false; if (bIsRecording) { if (ConfirmStopRecording(timer.get())) return CPVRTimers::DeleteTimer(*timer, true, false); } else if (timer->GetPVRTimerInfoTag()->HasTimerType() && timer->GetPVRTimerInfoTag()->GetTimerType()->IsReadOnly()) { return false; } else { bool bDeleteSchedule(false); if (ConfirmDeleteTimer(timer.get(), bDeleteSchedule)) return CPVRTimers::DeleteTimer(*timer, false, bDeleteSchedule); } return false; }
bool CPVRManager::EventOccursOnLocalBackend(const CFileItemPtr& item) const { if (item && item->HasPVRTimerInfoTag()) { CPVRTimerInfoTagPtr tag(item->GetPVRTimerInfoTag()); std::string hostname(m_addons->GetBackendHostnameByClientId(tag->m_iClientId)); if (!hostname.empty() && g_application.getNetwork().IsLocalHost(hostname)) return true; } return false; }
void CGUIWindowPVRTimersBase::GetContextButtons(int itemNumber, CContextButtons &buttons) { if (itemNumber < 0 || itemNumber >= m_vecItems->Size()) return; CFileItemPtr pItem = m_vecItems->Get(itemNumber); if (!URIUtils::PathEquals(pItem->GetPath(), CPVRTimersPath::PATH_ADDTIMER)) { CPVRTimerInfoTagPtr timer(pItem->GetPVRTimerInfoTag()); if (timer) { if (timer->GetEpgInfoTag()) buttons.Add(CONTEXT_BUTTON_INFO, 19047); /* Programme information */ CPVRTimerTypePtr timerType(timer->GetTimerType()); if (timerType) { if (timerType->SupportsEnableDisable()) { if (timer->m_state == PVR_TIMER_STATE_DISABLED) buttons.Add(CONTEXT_BUTTON_ACTIVATE, 843); /* Activate */ else buttons.Add(CONTEXT_BUTTON_ACTIVATE, 844); /* Deactivate */ } if (timer->GetTimerRuleId() != PVR_TIMER_NO_PARENT) { buttons.Add(CONTEXT_BUTTON_EDIT_TIMER_RULE, 19243); /* Edit timer rule */ buttons.Add(CONTEXT_BUTTON_DELETE_TIMER_RULE, 19295); /* Delete timer rule */ } if (timerType && !timerType->IsReadOnly() && timer->GetTimerRuleId() == PVR_TIMER_NO_PARENT) buttons.Add(CONTEXT_BUTTON_EDIT_TIMER, 21450); /* Edit */ else buttons.Add(CONTEXT_BUTTON_EDIT_TIMER, 19241); /* View timer information */ // As epg-based timers will get it's title from the epg tag, they should not be renamable. if (timer->IsManual() && !timerType->IsReadOnly()) buttons.Add(CONTEXT_BUTTON_RENAME, 118); /* Rename */ if (timer->IsRecording()) buttons.Add(CONTEXT_BUTTON_STOP_RECORD, 19059); /* Stop recording */ else if (timerType && !timerType->IsReadOnly()) buttons.Add(CONTEXT_BUTTON_DELETE, 117); /* Delete */ } if (g_PVRClients->HasMenuHooks(timer->m_iClientId, PVR_MENUHOOK_TIMER)) buttons.Add(CONTEXT_BUTTON_MENU_HOOKS, 19195); /* PVR client specific action */ } } CGUIWindowPVRBase::GetContextButtons(itemNumber, buttons); }
bool CGUIDialogPVRGuideInfo::ActionCancelTimer(CFileItemPtr timer) { bool bReturn(false); if (!timer || !timer->HasPVRTimerInfoTag()) return bReturn; bool bDelete(false); bool bDeleteScheduled(false); if (timer->GetPVRTimerInfoTag()->IsRepeating()) { // prompt user for confirmation for deleting the complete repeating timer, including scheduled timers. bool bCancel(false); bDeleteScheduled = CGUIDialogYesNo::ShowAndGetInput( CVariant{122}, // "Confirm delete" CVariant{840}, // "You are about to delete a repeating timer. Do you also want to delete all timers currently scheduled by this timer?" CVariant{""}, CVariant{timer->GetPVRTimerInfoTag()->Title()}, bCancel); bDelete = !bCancel; } else { // prompt user for confirmation for deleting the timer bDelete = CGUIDialogYesNo::ShowAndGetInput( CVariant{122}, // "Confirm delete" CVariant{19040}, // Timer CVariant{""}, CVariant{timer->GetPVRTimerInfoTag()->Title()}); bDeleteScheduled = false; } if (bDelete) { Close(); bReturn = CPVRTimers::DeleteTimer(*timer, false, bDeleteScheduled); } return bReturn; }
bool CPVRGUIActions::ToggleTimerState(const CFileItemPtr &item) const { if (!item->HasPVRTimerInfoTag()) return false; const CPVRTimerInfoTagPtr timer(item->GetPVRTimerInfoTag()); if (timer->m_state == PVR_TIMER_STATE_DISABLED) timer->m_state = PVR_TIMER_STATE_SCHEDULED; else timer->m_state = PVR_TIMER_STATE_DISABLED; return g_PVRTimers->UpdateTimer(timer); }
void SSortFileItem::ByDate(CFileItemPtr &item) { if (!item) return; CStdString label; if (item->IsEPG()) label.Format("%s %s", item->GetEPGInfoTag()->Start().GetAsDBDateTime().c_str(), item->GetLabel().c_str()); else if (item->IsPVRTimer()) label.Format("%s %s", item->GetPVRTimerInfoTag()->m_StartTime.GetAsDBDateTime().c_str(), item->GetLabel().c_str()); else label.Format("%s %s", item->m_dateTime.GetAsDBDateTime().c_str(), item->GetLabel().c_str()); item->SetSortLabel(label); }
bool CGUIDialogPVRGuideInfo::ActionCancelTimer(const CFileItemPtr &timer) { bool bReturn = false; if (timer->GetPVRTimerInfoTag()->IsRecording()) bReturn = CGUIWindowPVRBase::StopRecordFile(timer.get()); else bReturn = CGUIWindowPVRBase::DeleteTimer(timer.get()); if (bReturn) Close(); return bReturn; }
bool CGUIWindowPVRBase::StopRecordFile(const CFileItem &item) { if (!item.HasEPGInfoTag()) return false; const CEpgInfoTagPtr tag(item.GetEPGInfoTag()); if (!tag || !tag->HasPVRChannel()) return false; CFileItemPtr timer = g_PVRTimers->GetTimerForEpgTag(&item); if (!timer || !timer->HasPVRTimerInfoTag() || timer->GetPVRTimerInfoTag()->m_bIsRepeating) return false; return g_PVRTimers->DeleteTimer(*timer); }
bool CGUIWindowPVRCommon::StopRecordFile(CFileItem *item) { if (!item->HasEPGInfoTag()) return false; CEpgInfoTag *tag = item->GetEPGInfoTag(); if (!tag || !tag->HasPVRChannel()) return false; CFileItemPtr timer = g_PVRTimers->GetTimerForEpgTag(item); if (!timer || !timer->HasPVRTimerInfoTag() || timer->GetPVRTimerInfoTag()->m_bIsRepeating) return false; return g_PVRTimers->DeleteTimer(*timer); }
CFileItemPtr CPVRTimers::GetTimerRule(const CFileItemPtr &item) const { CPVRTimerInfoTagPtr timer; if (item && item->HasEPGInfoTag()) timer = GetTimerForEpgTag(item->GetEPGInfoTag()); else if (item && item->HasPVRTimerInfoTag()) timer = item->GetPVRTimerInfoTag(); if (timer) { timer = GetTimerRule(timer); if (timer) return CFileItemPtr(new CFileItem(timer)); } return CFileItemPtr(); }
CDateTime CPVRTimers::GetNextEventTime(void) const { const CStdString wakeupcmd = g_guiSettings.GetString("pvrpowermanagement.setwakeupcmd", false); const bool dailywakup = g_guiSettings.GetBool("pvrpowermanagement.dailywakeup"); const CDateTime now = CDateTime::GetUTCDateTime(); const CDateTimeSpan prewakeup(0, 0, g_guiSettings.GetInt("pvrpowermanagement.prewakeup"), 0); const CDateTimeSpan idle(0, 0, g_guiSettings.GetInt("pvrpowermanagement.backendidletime"), 0); CDateTime wakeuptime; /* Check next active time */ CFileItemPtr item = GetNextActiveTimer(); if (item && item->HasPVRTimerInfoTag()) { const CDateTime start = item->GetPVRTimerInfoTag()->StartAsUTC(); if ((start - idle) > now) { wakeuptime = start - prewakeup; } else { wakeuptime = now + idle; } } /* check daily wake up */ if (dailywakup) { CDateTime dailywakeuptime; dailywakeuptime.SetFromDBTime(g_guiSettings.GetString("pvrpowermanagement.dailywakeuptime", false)); dailywakeuptime = dailywakeuptime.GetAsUTCDateTime(); dailywakeuptime.SetDateTime( now.GetYear(), now.GetMonth(), now.GetDay(), dailywakeuptime.GetHour(), dailywakeuptime.GetMinute(), dailywakeuptime.GetSecond() ); if ((dailywakeuptime - idle) < now) { const CDateTimeSpan oneDay(1,0,0,0); dailywakeuptime += oneDay; } if (dailywakeuptime < wakeuptime) wakeuptime = dailywakeuptime; } const CDateTime retVal(wakeuptime); return retVal; }
void CGUIWindowPVRTimers::GetContextButtons(int itemNumber, CContextButtons &buttons) { if (itemNumber < 0 || itemNumber >= m_vecItems->Size()) return; CFileItemPtr pItem = m_vecItems->Get(itemNumber); /* Check for a empty file item list, means only a file item with the name "Add timer..." is present */ if (URIUtils::PathEquals(pItem->GetPath(), CPVRTimersPath::PATH_ADDTIMER)) { buttons.Add(CONTEXT_BUTTON_ADD, 19056); /* new timer */ } else { if (pItem->GetPVRTimerInfoTag()->GetEpgInfoTag()) buttons.Add(CONTEXT_BUTTON_INFO, 19047); /* epg info */ buttons.Add(CONTEXT_BUTTON_FIND, 19003); /* Find similar program */ if (pItem->GetPVRTimerInfoTag()->HasTimerType()) { if (pItem->GetPVRTimerInfoTag()->GetTimerType()->SupportsEnableDisable()) { if (pItem->GetPVRTimerInfoTag()->m_state == PVR_TIMER_STATE_DISABLED) buttons.Add(CONTEXT_BUTTON_ACTIVATE, 843); /* activate timer */ else buttons.Add(CONTEXT_BUTTON_ACTIVATE, 844); /* deactivate timer */ } if (!pItem->GetPVRTimerInfoTag()->GetTimerType()->IsReadOnly()) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); /* delete */ buttons.Add(CONTEXT_BUTTON_EDIT, 19057); /* edit timer */ // As epg-based timers will get it's title from the epg tag, they should not be renamable. if (pItem->GetPVRTimerInfoTag()->IsManual()) buttons.Add(CONTEXT_BUTTON_RENAME, 118); /* rename */ } } buttons.Add(CONTEXT_BUTTON_ADD, 19056); /* new timer */ if (g_PVRClients->HasMenuHooks(pItem->GetPVRTimerInfoTag()->m_iClientId, PVR_MENUHOOK_TIMER)) buttons.Add(CONTEXT_BUTTON_MENU_HOOKS, 19195); /* PVR client specific action */ } CGUIWindowPVRBase::GetContextButtons(itemNumber, buttons); CContextMenuManager::GetInstance().AddVisibleItems(pItem, buttons); }
bool CGUIWindowPVRBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button) { bool bReturn = false; switch(button) { case CONTEXT_BUTTON_MENU_HOOKS: if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) { CFileItemPtr item = m_vecItems->Get(itemNumber); if (item->IsEPG() && item->GetEPGInfoTag()->HasPVRChannel()) g_PVRClients->ProcessMenuHooks(item->GetEPGInfoTag()->ChannelTag()->ClientID(), PVR_MENUHOOK_EPG, item.get()); else if (item->IsPVRChannel()) g_PVRClients->ProcessMenuHooks(item->GetPVRChannelInfoTag()->ClientID(), PVR_MENUHOOK_CHANNEL, item.get()); else if (item->IsDeletedPVRRecording()) g_PVRClients->ProcessMenuHooks(item->GetPVRRecordingInfoTag()->m_iClientId, PVR_MENUHOOK_DELETED_RECORDING, item.get()); else if (item->IsUsablePVRRecording()) g_PVRClients->ProcessMenuHooks(item->GetPVRRecordingInfoTag()->m_iClientId, PVR_MENUHOOK_RECORDING, item.get()); else if (item->IsPVRTimer()) g_PVRClients->ProcessMenuHooks(item->GetPVRTimerInfoTag()->m_iClientId, PVR_MENUHOOK_TIMER, item.get()); bReturn = true; } break; case CONTEXT_BUTTON_FIND: { int windowSearchId = m_bRadio ? WINDOW_RADIO_SEARCH : WINDOW_TV_SEARCH; CGUIWindowPVRBase *windowSearch = (CGUIWindowPVRBase*) g_windowManager.GetWindow(windowSearchId); if (windowSearch && itemNumber >= 0 && itemNumber < m_vecItems->Size()) { CFileItemPtr item = m_vecItems->Get(itemNumber); g_windowManager.ActivateWindow(windowSearchId); bReturn = windowSearch->OnContextButton(*item.get(), button); } break; } default: bReturn = false; } return bReturn || CGUIMediaWindow::OnContextButton(itemNumber, button); }
bool CGUIWindowPVRBase::EditTimer(CFileItem *item) { CFileItemPtr timer; if (item->IsPVRTimer()) { timer.reset(new CFileItem(*item)); } else if (item->IsEPG()) { timer = g_PVRTimers->GetTimerForEpgTag(item); } if (!timer || !timer->HasPVRTimerInfoTag()) return false; if (ShowTimerSettings(timer.get()) && !timer->GetPVRTimerInfoTag()->GetTimerType()->IsReadOnly()) return g_PVRTimers->UpdateTimer(*timer); return false; }
void CGUIWindowPVRTimers::GetContextButtons(int itemNumber, CContextButtons &buttons) { if (itemNumber < 0 || itemNumber >= m_vecItems->Size()) return; CFileItemPtr pItem = m_vecItems->Get(itemNumber); if (!URIUtils::PathEquals(pItem->GetPath(), CPVRTimersPath::PATH_ADDTIMER)) { if (pItem->GetPVRTimerInfoTag()->GetEpgInfoTag()) buttons.Add(CONTEXT_BUTTON_INFO, 19047); /* Programme information */ if (pItem->GetPVRTimerInfoTag()->HasTimerType()) { if (pItem->GetPVRTimerInfoTag()->GetTimerType()->SupportsEnableDisable()) { if (pItem->GetPVRTimerInfoTag()->m_state == PVR_TIMER_STATE_DISABLED) buttons.Add(CONTEXT_BUTTON_ACTIVATE, 843); /* Activate */ else buttons.Add(CONTEXT_BUTTON_ACTIVATE, 844); /* Deactivate */ } if (!pItem->GetPVRTimerInfoTag()->GetTimerType()->IsReadOnly()) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); /* Delete */ buttons.Add(CONTEXT_BUTTON_EDIT, 21450); /* Edit */ // As epg-based timers will get it's title from the epg tag, they should not be renamable. if (pItem->GetPVRTimerInfoTag()->IsManual()) buttons.Add(CONTEXT_BUTTON_RENAME, 118); /* Rename */ } } if (g_PVRClients->HasMenuHooks(pItem->GetPVRTimerInfoTag()->m_iClientId, PVR_MENUHOOK_TIMER)) buttons.Add(CONTEXT_BUTTON_MENU_HOOKS, 19195); /* PVR client specific action */ } CGUIWindowPVRBase::GetContextButtons(itemNumber, buttons); CContextMenuManager::GetInstance().AddVisibleItems(pItem, buttons); }
bool CPVRGUIActions::RenameTimer(const CFileItemPtr &item) const { if (!item->HasPVRTimerInfoTag()) return false; const CPVRTimerInfoTagPtr timer(item->GetPVRTimerInfoTag()); std::string strNewName(timer->m_strTitle); if (CGUIKeyboardFactory::ShowAndGetInput(strNewName, CVariant{g_localizeStrings.Get(19042)}, // "Are you sure you want to rename this timer?" false)) { if (!g_PVRTimers->RenameTimer(*item, strNewName)) return false; } CGUIWindowPVRBase *pvrWindow = dynamic_cast<CGUIWindowPVRBase *>(g_windowManager.GetWindow(g_windowManager.GetActiveWindow())); if (pvrWindow) pvrWindow->DoRefresh(); else CLog::Log(LOGERROR, "CPVRGUIActions - %s - called on non-pvr window. no refresh possible.", __FUNCTION__); return true; }
void CFileItemHandler::HandleFileItem(const char *ID, bool allowFile, const char *resultname, CFileItemPtr item, const CVariant ¶meterObject, const std::set<std::string> &validFields, CVariant &result, bool append /* = true */, CThumbLoader *thumbLoader /* = NULL */) { CVariant object; std::set<std::string> fields(validFields.begin(), validFields.end()); if (item.get()) { std::set<std::string>::const_iterator fileField = fields.find("file"); if (fileField != fields.end()) { if (allowFile) { if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->GetPath().empty()) object["file"] = item->GetVideoInfoTag()->GetPath().c_str(); if (item->HasMusicInfoTag() && !item->GetMusicInfoTag()->GetURL().empty()) object["file"] = item->GetMusicInfoTag()->GetURL().c_str(); if (item->HasPVRRecordingInfoTag() && !item->GetPVRRecordingInfoTag()->GetPath().empty()) object["file"] = item->GetPVRRecordingInfoTag()->GetPath().c_str(); if (item->HasPVRTimerInfoTag() && !item->GetPVRTimerInfoTag()->m_strFileNameAndPath.empty()) object["file"] = item->GetPVRTimerInfoTag()->m_strFileNameAndPath.c_str(); if (!object.isMember("file")) object["file"] = item->GetPath().c_str(); } fields.erase(fileField); } if (ID) { if (item->HasPVRChannelInfoTag() && item->GetPVRChannelInfoTag()->ChannelID() > 0) object[ID] = item->GetPVRChannelInfoTag()->ChannelID(); else if (item->HasEPGInfoTag() && item->GetEPGInfoTag()->UniqueBroadcastID() > 0) object[ID] = item->GetEPGInfoTag()->UniqueBroadcastID(); else if (item->HasPVRRecordingInfoTag() && item->GetPVRRecordingInfoTag()->m_iRecordingId > 0) object[ID] = item->GetPVRRecordingInfoTag()->m_iRecordingId; else if (item->HasPVRTimerInfoTag() && item->GetPVRTimerInfoTag()->m_iTimerId > 0) object[ID] = item->GetPVRTimerInfoTag()->m_iTimerId; else if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDatabaseId() > 0) object[ID] = (int)item->GetMusicInfoTag()->GetDatabaseId(); else if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iDbId > 0) object[ID] = item->GetVideoInfoTag()->m_iDbId; if (stricmp(ID, "id") == 0) { if (item->HasPVRChannelInfoTag()) object["type"] = "channel"; else if (item->HasMusicInfoTag()) { std::string type = item->GetMusicInfoTag()->GetType(); if (type == MediaTypeAlbum || type == MediaTypeSong || type == MediaTypeArtist) object["type"] = type; else if (!item->m_bIsFolder) object["type"] = MediaTypeSong; } else if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_type.empty()) { std::string type = item->GetVideoInfoTag()->m_type; if (type == MediaTypeMovie || type == MediaTypeTvShow || type == MediaTypeEpisode || type == MediaTypeMusicVideo) object["type"] = type; } else if (item->HasPictureInfoTag()) object["type"] = "picture"; if (!object.isMember("type")) object["type"] = "unknown"; if (fields.find("filetype") != fields.end()) { if (item->m_bIsFolder) object["filetype"] = "directory"; else object["filetype"] = "file"; } } } bool deleteThumbloader = false; if (thumbLoader == NULL) { if (item->HasVideoInfoTag()) thumbLoader = new CVideoThumbLoader(); else if (item->HasMusicInfoTag()) thumbLoader = new CMusicThumbLoader(); if (thumbLoader != NULL) { deleteThumbloader = true; thumbLoader->OnLoaderStart(); } } if (item->HasPVRChannelInfoTag()) FillDetails(item->GetPVRChannelInfoTag().get(), item, fields, object, thumbLoader); if (item->HasEPGInfoTag()) FillDetails(item->GetEPGInfoTag().get(), item, fields, object, thumbLoader); if (item->HasPVRRecordingInfoTag()) FillDetails(item->GetPVRRecordingInfoTag().get(), item, fields, object, thumbLoader); if (item->HasPVRTimerInfoTag()) FillDetails(item->GetPVRTimerInfoTag().get(), item, fields, object, thumbLoader); if (item->HasVideoInfoTag()) FillDetails(item->GetVideoInfoTag(), item, fields, object, thumbLoader); if (item->HasMusicInfoTag()) FillDetails(item->GetMusicInfoTag(), item, fields, object, thumbLoader); if (item->HasPictureInfoTag()) FillDetails(item->GetPictureInfoTag(), item, fields, object, thumbLoader); FillDetails(item.get(), item, fields, object, thumbLoader); if (deleteThumbloader) delete thumbLoader; object["label"] = item->GetLabel().c_str(); } else object = CVariant(CVariant::VariantTypeNull); if (resultname) { if (append) result[resultname].append(object); else result[resultname] = object; } }