aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Sommerfeld <kai.sommerfeld@gmx.com>2019-02-16 10:56:35 +0100
committerKai Sommerfeld <kai.sommerfeld@gmx.com>2019-03-14 09:42:22 +0100
commite90861306cd2c50621c11aa78cdf6c362d0e7f8a (patch)
treefe05c88ebec87dee2ffc4106d96942eae5052e55
parenta65d9a94767b0b695de28243a8fc1dde5c2d69d3 (diff)
[PVR] Fix PVR inter component dependencies: epg must not depend on timers.
-rw-r--r--xbmc/interfaces/json-rpc/PVROperations.cpp4
-rw-r--r--xbmc/pvr/PVRContextMenus.cpp11
-rw-r--r--xbmc/pvr/PVRGUIActions.cpp2
-rw-r--r--xbmc/pvr/PVRGUIInfo.cpp2
-rw-r--r--xbmc/pvr/PVRItem.cpp12
-rw-r--r--xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp12
-rw-r--r--xbmc/pvr/epg/Epg.cpp26
-rw-r--r--xbmc/pvr/epg/Epg.h8
-rw-r--r--xbmc/pvr/epg/EpgContainer.cpp17
-rw-r--r--xbmc/pvr/epg/EpgContainer.h7
-rw-r--r--xbmc/pvr/epg/EpgInfoTag.cpp41
-rw-r--r--xbmc/pvr/epg/EpgInfoTag.h31
-rw-r--r--xbmc/pvr/timers/PVRTimerInfoTag.cpp18
-rw-r--r--xbmc/pvr/timers/PVRTimerInfoTag.h5
-rw-r--r--xbmc/pvr/timers/PVRTimers.cpp54
-rw-r--r--xbmc/pvr/timers/PVRTimers.h2
-rw-r--r--xbmc/pvr/windows/GUIWindowPVRGuide.cpp3
17 files changed, 29 insertions, 226 deletions
diff --git a/xbmc/interfaces/json-rpc/PVROperations.cpp b/xbmc/interfaces/json-rpc/PVROperations.cpp
index 9442fa443d..afd05aeb62 100644
--- a/xbmc/interfaces/json-rpc/PVROperations.cpp
+++ b/xbmc/interfaces/json-rpc/PVROperations.cpp
@@ -326,7 +326,7 @@ JSONRPC_STATUS CPVROperations::AddTimer(const std::string &method, ITransportLay
if (!epgTag)
return InvalidParams;
- if (epgTag->HasTimer())
+ if (CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(epgTag))
return InvalidParams;
CPVRTimerInfoTagPtr newTimer = CPVRTimerInfoTag::CreateFromEpg(epgTag, parameterObject["timerrule"].asBoolean(false));
@@ -370,7 +370,7 @@ JSONRPC_STATUS CPVROperations::ToggleTimer(const std::string &method, ITransport
bool timerrule = parameterObject["timerrule"].asBoolean(false);
bool sentOkay = false;
- CPVRTimerInfoTagPtr timer(epgTag->Timer());
+ std::shared_ptr<CPVRTimerInfoTag> timer = CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(epgTag);
if (timer)
{
if (timerrule)
diff --git a/xbmc/pvr/PVRContextMenus.cpp b/xbmc/pvr/PVRContextMenus.cpp
index 8b47141912..f819dc8d3e 100644
--- a/xbmc/pvr/PVRContextMenus.cpp
+++ b/xbmc/pvr/PVRContextMenus.cpp
@@ -86,7 +86,7 @@ namespace PVR
const CPVREpgInfoTagPtr epg(item.GetEPGInfoTag());
if (epg)
- timer = epg->Timer();
+ timer = CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(epg);
if (!timer)
timer = item.GetPVRTimerInfoTag();
@@ -219,7 +219,10 @@ namespace PVR
return !channel->IsRecording() && client && client->GetClientCapabilities().SupportsTimers();
const CPVREpgInfoTagPtr epg = item.GetEPGInfoTag();
- if (epg && !epg->Timer() && epg->Channel() && epg->IsRecordable())
+ if (epg &&
+ !CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(epg) &&
+ epg->Channel() &&
+ epg->IsRecordable())
return client && client->GetClientCapabilities().SupportsTimers();
return false;
@@ -377,7 +380,9 @@ namespace PVR
bool AddTimerRule::IsVisible(const CFileItem &item) const
{
const CPVREpgInfoTagPtr epg = item.GetEPGInfoTag();
- if (epg && epg->Channel() && !epg->Timer())
+ if (epg &&
+ epg->Channel() &&
+ !CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(epg))
{
const CPVRClientPtr client = CServiceBroker::GetPVRManager().GetClient(item);
return client && client->GetClientCapabilities().SupportsTimers();
diff --git a/xbmc/pvr/PVRGUIActions.cpp b/xbmc/pvr/PVRGUIActions.cpp
index 8cd08e1852..acb06a5e77 100644
--- a/xbmc/pvr/PVRGUIActions.cpp
+++ b/xbmc/pvr/PVRGUIActions.cpp
@@ -308,7 +308,7 @@ namespace PVR
return false;
}
- CPVRTimerInfoTagPtr timer(bCreateRule || !epgTag ? nullptr : epgTag->Timer());
+ CPVRTimerInfoTagPtr timer(bCreateRule || !epgTag ? nullptr : CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(epgTag));
CPVRTimerInfoTagPtr rule (bCreateRule ? CServiceBroker::GetPVRManager().Timers()->GetTimerRule(timer) : nullptr);
if (timer || rule)
{
diff --git a/xbmc/pvr/PVRGUIInfo.cpp b/xbmc/pvr/PVRGUIInfo.cpp
index 047300ce65..bd0863c122 100644
--- a/xbmc/pvr/PVRGUIInfo.cpp
+++ b/xbmc/pvr/PVRGUIInfo.cpp
@@ -1133,7 +1133,7 @@ bool CPVRGUIInfo::GetListItemAndPlayerBool(const CFileItem *item, const CGUIInfo
{
const CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag();
if (epgTag)
- bValue = epgTag->HasTimer();
+ bValue = !!CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(epgTag);
return true;
}
break;
diff --git a/xbmc/pvr/PVRItem.cpp b/xbmc/pvr/PVRItem.cpp
index 28326d258e..2dcd48208b 100644
--- a/xbmc/pvr/PVRItem.cpp
+++ b/xbmc/pvr/PVRItem.cpp
@@ -97,19 +97,11 @@ namespace PVR
}
else if (m_item->IsEPG())
{
- return m_item->GetEPGInfoTag()->Timer();
+ return CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(m_item->GetEPGInfoTag());
}
else if (m_item->IsPVRChannel())
{
- CPVRTimerInfoTagPtr timer;
- const CPVREpgInfoTagPtr epgTag(m_item->GetPVRChannelInfoTag()->GetEPGNow());
- if (epgTag)
- timer = epgTag->Timer(); // cheap method, but not reliable as timers get set at epg tags asynchronously
-
- if (timer)
- return timer;
-
- return CServiceBroker::GetPVRManager().Timers()->GetActiveTimerForChannel(m_item->GetPVRChannelInfoTag()); // more expensive, but reliable and works even for channels with no epg data
+ return CServiceBroker::GetPVRManager().Timers()->GetActiveTimerForChannel(m_item->GetPVRChannelInfoTag());
}
else
{
diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp b/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp
index 357e0a14e9..4db83d06ad 100644
--- a/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp
+++ b/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp
@@ -27,6 +27,7 @@
#include "pvr/epg/EpgInfoTag.h"
#include "pvr/recordings/PVRRecordings.h"
#include "pvr/timers/PVRTimerInfoTag.h"
+#include "pvr/timers/PVRTimers.h"
#include "pvr/windows/GUIWindowPVRSearch.h"
using namespace PVR;
@@ -76,7 +77,7 @@ bool CGUIDialogPVRGuideInfo::OnClickButtonRecord(CGUIMessage &message)
return bReturn;
}
- const CPVRTimerInfoTagPtr timerTag(m_progItem->Timer());
+ const std::shared_ptr<CPVRTimerInfoTag> timerTag = CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(m_progItem);
if (timerTag)
{
const CFileItemPtr item(new CFileItem(timerTag));
@@ -104,7 +105,7 @@ bool CGUIDialogPVRGuideInfo::OnClickButtonAddTimer(CGUIMessage &message)
if (message.GetSenderId() == CONTROL_BTN_ADD_TIMER)
{
- if (m_progItem && !m_progItem->Timer())
+ if (m_progItem && !CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(m_progItem))
{
const CFileItemPtr item(new CFileItem(m_progItem));
bReturn = CServiceBroker::GetPVRManager().GUIActions()->AddTimerRule(item, true);
@@ -201,14 +202,15 @@ void CGUIDialogPVRGuideInfo::OnInitWindow()
bool bHideRecord(true);
bool bHideAddTimer(true);
- if (m_progItem->HasTimer())
+ const std::shared_ptr<CPVRTimerInfoTag> timer = CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(m_progItem);
+ if (timer)
{
- if (m_progItem->Timer()->IsRecording())
+ if (timer->IsRecording())
{
SET_CONTROL_LABEL(CONTROL_BTN_RECORD, 19059); /* Stop recording */
bHideRecord = false;
}
- else if (m_progItem->Timer()->HasTimerType() && !m_progItem->Timer()->GetTimerType()->IsReadOnly())
+ else if (timer->HasTimerType() && !timer->GetTimerType()->IsReadOnly())
{
SET_CONTROL_LABEL(CONTROL_BTN_RECORD, 19060); /* Delete timer */
bHideRecord = false;
diff --git a/xbmc/pvr/epg/Epg.cpp b/xbmc/pvr/epg/Epg.cpp
index 7efa62fddf..d40bc524d6 100644
--- a/xbmc/pvr/epg/Epg.cpp
+++ b/xbmc/pvr/epg/Epg.cpp
@@ -22,7 +22,6 @@
#include "utils/log.h"
#include "pvr/PVRManager.h"
-#include "pvr/timers/PVRTimers.h"
using namespace PVR;
@@ -89,7 +88,6 @@ void CPVREpg::Cleanup(const CDateTime &time)
if (m_nowActiveStart == it->first)
m_nowActiveStart.SetValid(false);
- it->second->ClearTimer();
it = m_tags.erase(it);
}
else
@@ -252,25 +250,6 @@ CPVREpgInfoTagPtr CPVREpg::GetTagBetween(const CDateTime &beginTime, const CDate
return tag;
}
-std::vector<CPVREpgInfoTagPtr> CPVREpg::GetTagsBetween(const CDateTime &beginTime, const CDateTime &endTime) const
-{
- std::vector<CPVREpgInfoTagPtr> epgTags;
-
- CSingleLock lock(m_critSection);
- for (const auto &infoTag : m_tags)
- {
- if (infoTag.second->StartAsUTC() >= beginTime)
- {
- if (infoTag.second->EndAsUTC() <= endTime)
- epgTags.emplace_back(infoTag.second);
- else
- break; // done.
- }
- }
-
- return epgTags;
-}
-
void CPVREpg::AddEntry(const CPVREpgInfoTag &tag)
{
CPVREpgInfoTagPtr newTag;
@@ -294,7 +273,6 @@ void CPVREpg::AddEntry(const CPVREpgInfoTag &tag)
newTag->Update(tag);
newTag->SetChannel(channel);
newTag->SetEpg(this);
- newTag->SetTimer(CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(newTag));
}
}
@@ -411,8 +389,6 @@ bool CPVREpg::UpdateEntry(const CPVREpgInfoTagPtr &tag, bool bUpdateDatabase)
m_changedTags.insert(std::make_pair(infoTag->UniqueBroadcastID(), infoTag));
}
- infoTag->SetTimer(CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(infoTag));
-
return true;
}
@@ -449,7 +425,6 @@ bool CPVREpg::UpdateEntry(const CPVREpgInfoTagPtr &tag, EPG_EVENT_STATE newState
if (bUpdateDatabase)
m_deletedTags.insert(std::make_pair(it->second->UniqueBroadcastID(), it->second));
- it->second->ClearTimer();
m_tags.erase(it);
}
else
@@ -637,7 +612,6 @@ bool CPVREpg::FixOverlappingEvents(bool bUpdateDb /* = false */)
if (m_nowActiveStart == it->first)
m_nowActiveStart.SetValid(false);
- it->second->ClearTimer();
m_tags.erase(it++);
}
else if (previousTag->EndAsUTC() > currentTag->StartAsUTC())
diff --git a/xbmc/pvr/epg/Epg.h b/xbmc/pvr/epg/Epg.h
index c1f9fda627..9fb9150085 100644
--- a/xbmc/pvr/epg/Epg.h
+++ b/xbmc/pvr/epg/Epg.h
@@ -154,14 +154,6 @@ namespace PVR
CPVREpgInfoTagPtr GetTagBetween(const CDateTime &beginTime, const CDateTime &endTime, bool bUpdateFromClient = false);
/*!
- * @brief Get all events occurring between the given begin and end time.
- * @param beginTime Minimum start time in UTC of the event.
- * @param endTime Maximum end time in UTC of the event.
- * @return The tags found or an empty vector if none was found.
- */
- std::vector<CPVREpgInfoTagPtr> GetTagsBetween(const CDateTime &beginTime, const CDateTime &endTime) const;
-
- /*!
* @brief Get the event matching the given unique broadcast id
* @param iUniqueBroadcastId The uid to look up
* @return The matching event or NULL if it wasn't found.
diff --git a/xbmc/pvr/epg/EpgContainer.cpp b/xbmc/pvr/epg/EpgContainer.cpp
index d7408bb775..a486becb22 100644
--- a/xbmc/pvr/epg/EpgContainer.cpp
+++ b/xbmc/pvr/epg/EpgContainer.cpp
@@ -25,7 +25,6 @@
#include "pvr/channels/PVRChannelGroupsContainer.h"
#include "pvr/epg/Epg.h"
#include "pvr/epg/EpgSearchFilter.h"
-#include "pvr/timers/PVRTimerInfoTag.h"
namespace PVR
{
@@ -472,22 +471,6 @@ CPVREpgInfoTagPtr CPVREpgContainer::GetTagById(const CPVRChannelPtr &channel, un
return retval;
}
-std::vector<CPVREpgInfoTagPtr> CPVREpgContainer::GetEpgTagsForTimer(const CPVRTimerInfoTagPtr &timer) const
-{
- CPVRChannelPtr channel = timer->Channel();
-
- if (!channel)
- channel = timer->UpdateChannel();
-
- if (channel)
- {
- const CPVREpgPtr epg = channel->GetEPG();
- if (epg)
- return epg->GetTagsBetween(timer->StartAsUTC(), timer->EndAsUTC());
- }
- return std::vector<CPVREpgInfoTagPtr>();
-}
-
void CPVREpgContainer::InsertFromDB(const CPVREpgPtr &newEpg)
{
// table might already have been created when pvr channels were loaded
diff --git a/xbmc/pvr/epg/EpgContainer.h b/xbmc/pvr/epg/EpgContainer.h
index cd43345ab8..0fbfb46d2d 100644
--- a/xbmc/pvr/epg/EpgContainer.h
+++ b/xbmc/pvr/epg/EpgContainer.h
@@ -126,13 +126,6 @@ namespace PVR
CPVREpgInfoTagPtr GetTagById(const CPVRChannelPtr &channel, unsigned int iBroadcastId) const;
/*!
- * @brief Get the EPG events matching the given timer
- * @param timer The timer to get the matching events for.
- * @return The matching events, or an empty vector when no matching tag was found
- */
- std::vector<CPVREpgInfoTagPtr> GetEpgTagsForTimer(const CPVRTimerInfoTagPtr &timer) const;
-
- /*!
* @brief Check whether data should be persisted to the EPG database.
* @return True if data should not be persisted to the EPG database, false otherwise.
*/
diff --git a/xbmc/pvr/epg/EpgInfoTag.cpp b/xbmc/pvr/epg/EpgInfoTag.cpp
index fe4ec8a767..1d63d9ab46 100644
--- a/xbmc/pvr/epg/EpgInfoTag.cpp
+++ b/xbmc/pvr/epg/EpgInfoTag.cpp
@@ -24,7 +24,6 @@
#include "pvr/epg/Epg.h"
#include "pvr/epg/EpgContainer.h"
#include "pvr/epg/EpgDatabase.h"
-#include "pvr/timers/PVRTimers.h"
using namespace PVR;
@@ -160,8 +159,8 @@ void CPVREpgInfoTag::Serialize(CVariant &value) const
value["episodename"] = m_strEpisodeName;
value["episodenum"] = m_iEpisodeNumber;
value["episodepart"] = m_iEpisodePart;
- value["hastimer"] = HasTimer();
- value["hastimerrule"] = HasTimerRule();
+ value["hastimer"] = false; // compat
+ value["hastimerrule"] = false; // compat
value["hasrecording"] = false; // compat
value["recording"] = ""; // compat
value["isactive"] = IsActive();
@@ -524,24 +523,6 @@ std::string CPVREpgInfoTag::Path(void) const
return m_strFileNameAndPath;
}
-bool CPVREpgInfoTag::HasTimer(void) const
-{
- CSingleLock lock(m_critSection);
- return m_timer != nullptr;
-}
-
-bool CPVREpgInfoTag::HasTimerRule(void) const
-{
- CSingleLock lock(m_critSection);
- return m_timer && (m_timer->GetTimerRuleId() != PVR_TIMER_NO_PARENT);
-}
-
-CPVRTimerInfoTagPtr CPVREpgInfoTag::Timer(void) const
-{
- CSingleLock lock(m_critSection);
- return m_timer;
-}
-
void CPVREpgInfoTag::SetChannel(const CPVRChannelPtr &channel)
{
CSingleLock lock(m_critSection);
@@ -706,24 +687,6 @@ int CPVREpgInfoTag::EpgID(void) const
return m_epg ? m_epg->EpgID() : -1;
}
-void CPVREpgInfoTag::SetTimer(const CPVRTimerInfoTagPtr &timer)
-{
- CSingleLock lock(m_critSection);
- m_timer = timer;
-}
-
-void CPVREpgInfoTag::ClearTimer(void)
-{
- CPVRTimerInfoTagPtr previousTag;
- {
- CSingleLock lock(m_critSection);
- previousTag = std::move(m_timer);
- }
-
- if (previousTag)
- previousTag->ClearEpgTag();
-}
-
bool CPVREpgInfoTag::IsRecordable(void) const
{
bool bIsRecordable = false;
diff --git a/xbmc/pvr/epg/EpgInfoTag.h b/xbmc/pvr/epg/EpgInfoTag.h
index 3d57ff60b8..9cb376e9a5 100644
--- a/xbmc/pvr/epg/EpgInfoTag.h
+++ b/xbmc/pvr/epg/EpgInfoTag.h
@@ -19,7 +19,6 @@
#include "pvr/PVRTypes.h"
#include "pvr/channels/PVRChannel.h"
-#include "pvr/timers/PVRTimerInfoTag.h"
class CVariant;
@@ -339,35 +338,6 @@ namespace PVR
std::string Path(void) const;
/*!
- * @brief Set a timer for this event.
- * @param timer The timer.
- */
- void SetTimer(const CPVRTimerInfoTagPtr &timer);
-
- /*!
- * @brief Clear the timer for this event.
- */
- void ClearTimer(void);
-
- /*!
- * @brief Check whether this event has a timer tag.
- * @return True if it has a timer tag, false if not.
- */
- bool HasTimer(void) const;
-
- /*!
- * @brief Check whether this event has a timer rule.
- * @return True if it has a timer rule, false if not.
- */
- bool HasTimerRule(void) const;
-
- /*!
- * @brief Get the timer for this event, if any.
- * @return The timer or nullptr if there is none.
- */
- CPVRTimerInfoTagPtr Timer(void) const;
-
- /*!
* @brief Check if this event can be recorded.
* @return True if it can be recorded, false otherwise.
*/
@@ -508,6 +478,5 @@ namespace PVR
mutable CCriticalSection m_critSection;
CPVREpg *m_epg = nullptr;
CPVRChannelPtr m_channel;
- CPVRTimerInfoTagPtr m_timer;
};
}
diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.cpp b/xbmc/pvr/timers/PVRTimerInfoTag.cpp
index a4fbaaead5..c673fc187b 100644
--- a/xbmc/pvr/timers/PVRTimerInfoTag.cpp
+++ b/xbmc/pvr/timers/PVRTimerInfoTag.cpp
@@ -986,7 +986,7 @@ CPVREpgInfoTagPtr CPVRTimerInfoTag::GetEpgInfoTag(bool bCreate /* = true */) con
if (!bTagMatches)
{
// Check whether the tag actually is an event that belongs to a child of this timer rule
- const CPVRTimerInfoTagPtr timer = epgTag->Timer();
+ const std::shared_ptr<CPVRTimerInfoTag> timer = CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(epgTag);
if (timer && (timer->GetTimerRuleId() == m_iClientIndex))
{
bTagMatches = true;
@@ -1009,20 +1009,8 @@ CPVREpgInfoTagPtr CPVRTimerInfoTag::GetEpgInfoTag(bool bCreate /* = true */) con
void CPVRTimerInfoTag::SetEpgTag(const CPVREpgInfoTagPtr &tag)
{
- CPVREpgInfoTagPtr previousTag;
- {
- CSingleLock lock(m_critSection);
- previousTag = m_epgTag;
- m_epgTag = tag;
- }
-
- if (previousTag)
- previousTag->ClearTimer();
-}
-
-void CPVRTimerInfoTag::ClearEpgTag(void)
-{
- SetEpgTag(CPVREpgInfoTagPtr());
+ CSingleLock lock(m_critSection);
+ m_epgTag = tag;
}
bool CPVRTimerInfoTag::HasChannel() const
diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.h b/xbmc/pvr/timers/PVRTimerInfoTag.h
index 6099d1c9c8..9e4f912235 100644
--- a/xbmc/pvr/timers/PVRTimerInfoTag.h
+++ b/xbmc/pvr/timers/PVRTimerInfoTag.h
@@ -253,11 +253,6 @@ namespace PVR
void SetEpgTag(const CPVREpgInfoTagPtr &tag);
/*!
- * @brief Clear the epg tag associated with this timer; before, clear this timer at associated epg tag, if any.
- */
- void ClearEpgTag(void);
-
- /*!
* @brief Update the channel associated with this timer.
* @return the channel for the timer. Can be empty for epg based repeating timers (e.g. "match any channel" rules)
*/
diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp
index 7091a18934..084fe231a4 100644
--- a/xbmc/pvr/timers/PVRTimers.cpp
+++ b/xbmc/pvr/timers/PVRTimers.cpp
@@ -140,42 +140,6 @@ bool CPVRTimers::IsRecording(void) const
return false;
}
-bool CPVRTimers::SetEpgTagTimer(const CPVRTimerInfoTagPtr &timer)
-{
- if (timer->IsTimerRule() || timer->m_bStartAnyTime || timer->m_bEndAnyTime)
- return false;
-
- std::vector<CPVREpgInfoTagPtr> tags(CServiceBroker::GetPVRManager().EpgContainer().GetEpgTagsForTimer(timer));
-
- if (tags.empty())
- return false;
-
- // assign first matching epg tag to the timer.
- timer->SetEpgTag(tags.front());
-
- // assign timer to every matching epg tag.
- for (const auto &tag : tags)
- tag->SetTimer(timer);
-
- return true;
-}
-
-bool CPVRTimers::ClearEpgTagTimer(const CPVRTimerInfoTagPtr &timer)
-{
- if (timer->IsTimerRule() || timer->m_bStartAnyTime || timer->m_bEndAnyTime)
- return false;
-
- std::vector<CPVREpgInfoTagPtr> tags(CServiceBroker::GetPVRManager().EpgContainer().GetEpgTagsForTimer(timer));
-
- if (tags.empty())
- return false;
-
- for (const auto &tag : tags)
- tag->ClearTimer();
-
- return true;
-}
-
bool CPVRTimers::UpdateEntries(const CPVRTimersContainer &timers, const std::vector<int> &failedClients)
{
bool bChanged(false);
@@ -195,11 +159,8 @@ bool CPVRTimers::UpdateEntries(const CPVRTimersContainer &timers, const std::vec
{
/* if it's present, update the current tag */
bool bStateChanged(existingTimer->m_state != (*timerIt)->m_state);
- ClearEpgTagTimer(existingTimer);
if (existingTimer->UpdateEntry(*timerIt))
{
- SetEpgTagTimer(existingTimer);
-
bChanged = true;
existingTimer->ResetChildState();
@@ -220,7 +181,6 @@ bool CPVRTimers::UpdateEntries(const CPVRTimersContainer &timers, const std::vec
CPVRTimerInfoTagPtr newTimer = CPVRTimerInfoTagPtr(new CPVRTimerInfoTag);
newTimer->UpdateEntry(*timerIt);
newTimer->m_iTimerId = ++m_iLastId;
- SetEpgTagTimer(newTimer);
InsertTimer(newTimer);
bChanged = true;
@@ -269,8 +229,6 @@ bool CPVRTimers::UpdateEntries(const CPVRTimersContainer &timers, const std::vec
timerNotifications.push_back(std::make_pair(timer->m_iClientId, timer->GetDeletedNotificationText()));
- ClearEpgTagTimer(timer);
-
it2 = it->second.erase(it2);
bChanged = true;
@@ -283,8 +241,6 @@ bool CPVRTimers::UpdateEntries(const CPVRTimersContainer &timers, const std::vec
CLog::LogFC(LOGDEBUG, LOGPVR, "Changed start time timer %d on client %d",
timer->m_iClientIndex, timer->m_iClientId);
- ClearEpgTagTimer(timer);
-
/* remember timer */
timersToMove.push_back(timer);
@@ -307,10 +263,7 @@ bool CPVRTimers::UpdateEntries(const CPVRTimersContainer &timers, const std::vec
/* reinsert timers with changed timer start */
for (VecTimerInfoTag::const_iterator timerIt = timersToMove.begin(); timerIt != timersToMove.end(); ++timerIt)
- {
- SetEpgTagTimer(*timerIt);
InsertTimer(*timerIt);
- }
/* update child information for all parent timers */
for (const auto &tagsEntry : m_tags)
@@ -742,11 +695,6 @@ CPVRTimerInfoTagPtr CPVRTimers::GetTimerForEpgTag(const CPVREpgInfoTagPtr &epgTa
{
if (epgTag)
{
- // already a timer assigned to tag?
- const CPVRTimerInfoTagPtr timer(epgTag->Timer());
- if (timer)
- return timer;
-
// try to find a matching timer for the tag.
const CPVRChannelPtr channel(epgTag->Channel());
if (channel)
@@ -847,7 +795,7 @@ CFileItemPtr CPVRTimers::GetTimerRule(const CFileItemPtr &item) const
{
CPVRTimerInfoTagPtr timer;
if (item && item->HasEPGInfoTag())
- timer = item->GetEPGInfoTag()->Timer();
+ timer = GetTimerForEpgTag(item->GetEPGInfoTag());
else if (item && item->HasPVRTimerInfoTag())
timer = item->GetPVRTimerInfoTag();
diff --git a/xbmc/pvr/timers/PVRTimers.h b/xbmc/pvr/timers/PVRTimers.h
index 32231e6656..e323d29f49 100644
--- a/xbmc/pvr/timers/PVRTimers.h
+++ b/xbmc/pvr/timers/PVRTimers.h
@@ -287,8 +287,6 @@ namespace PVR
bool UpdateEntries(const CPVRTimersContainer &timers, const std::vector<int> &failedClients);
bool GetRootDirectory(const CPVRTimersPath &path, CFileItemList &items) const;
bool GetSubDirectory(const CPVRTimersPath &path, CFileItemList &items) const;
- bool SetEpgTagTimer(const CPVRTimerInfoTagPtr &timer);
- bool ClearEpgTagTimer(const CPVRTimerInfoTagPtr &timer);
enum TimerKind
{
diff --git a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp
index 84bb83dee6..f22ca1db40 100644
--- a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp
+++ b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp
@@ -28,6 +28,7 @@
#include "pvr/channels/PVRChannelGroupsContainer.h"
#include "pvr/epg/EpgContainer.h"
#include "pvr/recordings/PVRRecordings.h"
+#include "pvr/timers/PVRTimers.h"
#include "pvr/windows/GUIEPGGridContainer.h"
using namespace KODI::MESSAGING;
@@ -436,7 +437,7 @@ bool CGUIWindowPVRGuideBase::OnMessage(CGUIMessage& message)
else if (now < start)
{
// future event
- if (tag->HasTimer())
+ if (CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(tag))
CServiceBroker::GetPVRManager().GUIActions()->EditTimer(pItem);
else
{