From c04dcc2e7d834218ef2d4194331e383402495ae1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 20:07:22 +0200 Subject: Adding upstream version 2:20.4+dfsg. Signed-off-by: Daniel Baumann --- xbmc/pvr/PVRItem.cpp | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 xbmc/pvr/PVRItem.cpp (limited to 'xbmc/pvr/PVRItem.cpp') diff --git a/xbmc/pvr/PVRItem.cpp b/xbmc/pvr/PVRItem.cpp new file mode 100644 index 0000000..5eee911 --- /dev/null +++ b/xbmc/pvr/PVRItem.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2016-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "PVRItem.h" + +#include "FileItem.h" +#include "ServiceBroker.h" +#include "pvr/PVRManager.h" +#include "pvr/channels/PVRChannel.h" +#include "pvr/channels/PVRChannelGroupsContainer.h" +#include "pvr/epg/EpgInfoTag.h" +#include "pvr/recordings/PVRRecording.h" +#include "pvr/recordings/PVRRecordings.h" +#include "pvr/timers/PVRTimerInfoTag.h" +#include "pvr/timers/PVRTimers.h" +#include "utils/URIUtils.h" +#include "utils/log.h" + +#include + +namespace PVR +{ +std::shared_ptr CPVRItem::GetEpgInfoTag() const +{ + if (m_item->IsEPG()) + { + return m_item->GetEPGInfoTag(); + } + else if (m_item->IsPVRChannel()) + { + return m_item->GetPVRChannelInfoTag()->GetEPGNow(); + } + else if (m_item->IsPVRTimer()) + { + return m_item->GetPVRTimerInfoTag()->GetEpgInfoTag(); + } + else if (URIUtils::IsPVR(m_item->GetDynPath())) + { + CLog::LogF(LOGERROR, "Unsupported item type!"); + } + return {}; +} + +std::shared_ptr CPVRItem::GetNextEpgInfoTag() const +{ + if (m_item->IsEPG()) + { + const std::shared_ptr channel = + CServiceBroker::GetPVRManager().ChannelGroups()->GetChannelForEpgTag( + m_item->GetEPGInfoTag()); + if (channel) + return channel->GetEPGNext(); + } + else if (m_item->IsPVRChannel()) + { + return m_item->GetPVRChannelInfoTag()->GetEPGNext(); + } + else if (m_item->IsPVRTimer()) + { + const std::shared_ptr channel = m_item->GetPVRTimerInfoTag()->Channel(); + if (channel) + return channel->GetEPGNext(); + } + else if (URIUtils::IsPVR(m_item->GetDynPath())) + { + CLog::LogF(LOGERROR, "Unsupported item type!"); + } + return {}; +} + +std::shared_ptr CPVRItem::GetChannel() const +{ + if (m_item->IsPVRChannel()) + { + return m_item->GetPVRChannelInfoTag(); + } + else if (m_item->IsEPG()) + { + return CServiceBroker::GetPVRManager().ChannelGroups()->GetChannelForEpgTag( + m_item->GetEPGInfoTag()); + } + else if (m_item->IsPVRTimer()) + { + return m_item->GetPVRTimerInfoTag()->Channel(); + } + else if (m_item->IsPVRRecording()) + { + return m_item->GetPVRRecordingInfoTag()->Channel(); + } + else if (URIUtils::IsPVR(m_item->GetDynPath())) + { + CLog::LogF(LOGERROR, "Unsupported item type!"); + } + return {}; +} + +std::shared_ptr CPVRItem::GetTimerInfoTag() const +{ + if (m_item->IsPVRTimer()) + { + return m_item->GetPVRTimerInfoTag(); + } + else if (m_item->IsEPG()) + { + return CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(m_item->GetEPGInfoTag()); + } + else if (m_item->IsPVRChannel()) + { + return CServiceBroker::GetPVRManager().Timers()->GetActiveTimerForChannel( + m_item->GetPVRChannelInfoTag()); + } + else if (URIUtils::IsPVR(m_item->GetDynPath())) + { + CLog::LogF(LOGERROR, "Unsupported item type!"); + } + return {}; +} + +std::shared_ptr CPVRItem::GetRecording() const +{ + if (m_item->IsPVRRecording()) + { + return m_item->GetPVRRecordingInfoTag(); + } + else if (m_item->IsEPG()) + { + return CServiceBroker::GetPVRManager().Recordings()->GetRecordingForEpgTag( + m_item->GetEPGInfoTag()); + } + else if (URIUtils::IsPVR(m_item->GetDynPath())) + { + CLog::LogF(LOGERROR, "Unsupported item type!"); + } + return {}; +} + +bool CPVRItem::IsRadio() const +{ + if (m_item->IsPVRChannel()) + { + return m_item->GetPVRChannelInfoTag()->IsRadio(); + } + else if (m_item->IsEPG()) + { + return m_item->GetEPGInfoTag()->IsRadio(); + } + else if (m_item->IsPVRRecording()) + { + return m_item->GetPVRRecordingInfoTag()->IsRadio(); + } + else if (m_item->IsPVRTimer()) + { + return m_item->GetPVRTimerInfoTag()->IsRadio(); + } + else if (URIUtils::IsPVR(m_item->GetDynPath())) + { + CLog::LogF(LOGERROR, "Unsupported item type!"); + } + return false; +} + +} // namespace PVR -- cgit v1.2.3