aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Sommerfeld <kai.sommerfeld@gmx.com>2020-11-13 12:48:27 +0100
committerGitHub <noreply@github.com>2020-11-13 12:48:27 +0100
commit6402f59b2f359a80eebfe64099befa9994384b72 (patch)
tree6c1b02b3883c2511a16ac9e1ec614ce458025231
parenta4fb12afc8ede6297bbff908dd712bef89426709 (diff)
parentb426bd764f6edf14067934f38ca23399e791e429 (diff)
Merge pull request #18775 from ksooo/pvr-fix-timer-notifications
[PVR] Prevent timer notifications if previous addon GetTimers call failed
-rw-r--r--xbmc/pvr/timers/PVRTimerInfoTag.cpp7
-rw-r--r--xbmc/pvr/timers/PVRTimerInfoTag.h7
-rw-r--r--xbmc/pvr/timers/PVRTimers.cpp34
-rw-r--r--xbmc/pvr/timers/PVRTimers.h8
4 files changed, 40 insertions, 16 deletions
diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.cpp b/xbmc/pvr/timers/PVRTimerInfoTag.cpp
index e733a402c1..b4540e9501 100644
--- a/xbmc/pvr/timers/PVRTimerInfoTag.cpp
+++ b/xbmc/pvr/timers/PVRTimerInfoTag.cpp
@@ -1123,7 +1123,7 @@ void CPVRTimerInfoTag::SetFirstDayFromLocalTime(const CDateTime& firstDay)
m_FirstDay = ConvertLocalTimeToUTC(firstDay);
}
-void CPVRTimerInfoTag::GetNotificationText(std::string& strText) const
+std::string CPVRTimerInfoTag::GetNotificationText() const
{
CSingleLock lock(m_critSection);
@@ -1160,8 +1160,11 @@ void CPVRTimerInfoTag::GetNotificationText(std::string& strText) const
default:
break;
}
+
if (stringID != 0)
- strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(stringID).c_str(), m_strTitle.c_str());
+ return StringUtils::Format("%s: '%s'", g_localizeStrings.Get(stringID).c_str(), m_strTitle.c_str());
+
+ return {};
}
std::string CPVRTimerInfoTag::GetDeletedNotificationText() const
diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.h b/xbmc/pvr/timers/PVRTimerInfoTag.h
index 75380be8d4..d8b603329a 100644
--- a/xbmc/pvr/timers/PVRTimerInfoTag.h
+++ b/xbmc/pvr/timers/PVRTimerInfoTag.h
@@ -250,13 +250,12 @@ namespace PVR
/*!
* @brief Get the text for the notification.
- * @param strText The notification.
*/
- void GetNotificationText(std::string& strText) const;
+ std::string GetNotificationText() const;
/*!
- * @brief Get the text for the notification when a timer has been deleted
- */
+ * @brief Get the text for the notification when a timer has been deleted
+ */
std::string GetDeletedNotificationText() const;
const std::string& Title() const;
diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp
index 06d1bfcc75..62b3f220b7 100644
--- a/xbmc/pvr/timers/PVRTimers.cpp
+++ b/xbmc/pvr/timers/PVRTimers.cpp
@@ -200,6 +200,23 @@ void CPVRTimers::RemoveEntry(const std::shared_ptr<CPVRTimerInfoTag>& tag)
}
}
+bool CPVRTimers::CheckAndAppendTimerNotification(
+ std::vector<std::pair<int, std::string>>& timerNotifications,
+ const std::shared_ptr<CPVRTimerInfoTag>& tag,
+ bool bDeleted) const
+{
+ // no notification on first update or if previous update failed for tag's client.
+ if (!m_bFirstUpdate && std::find(m_failedClients.cbegin(), m_failedClients.cend(),
+ tag->m_iClientId) == m_failedClients.cend())
+ {
+ const std::string strMessage =
+ bDeleted ? tag->GetDeletedNotificationText() : tag->GetNotificationText();
+ timerNotifications.emplace_back(std::make_pair(tag->m_iClientId, strMessage));
+ return true;
+ }
+ return false;
+}
+
bool CPVRTimers::UpdateEntries(const CPVRTimersContainer& timers, const std::vector<int>& failedClients)
{
bool bChanged(false);
@@ -225,11 +242,7 @@ bool CPVRTimers::UpdateEntries(const CPVRTimersContainer& timers, const std::vec
existingTimer->ResetChildState();
if (bStateChanged)
- {
- std::string strMessage;
- existingTimer->GetNotificationText(strMessage);
- timerNotifications.emplace_back(std::make_pair((*timerIt)->m_iClientId, strMessage));
- }
+ CheckAndAppendTimerNotification(timerNotifications, existingTimer, false);
CLog::LogFC(LOGDEBUG, LOGPVR, "Updated timer {} on client {}", (*timerIt)->m_iClientIndex,
(*timerIt)->m_iClientId);
@@ -246,9 +259,7 @@ bool CPVRTimers::UpdateEntries(const CPVRTimersContainer& timers, const std::vec
bChanged = true;
bAddedOrDeleted = true;
- std::string strMessage;
- newTimer->GetNotificationText(strMessage);
- timerNotifications.emplace_back(newTimer->m_iClientId, strMessage);
+ CheckAndAppendTimerNotification(timerNotifications, newTimer, false);
CLog::LogFC(LOGDEBUG, LOGPVR, "Added timer {} on client {}", (*timerIt)->m_iClientIndex,
(*timerIt)->m_iClientId);
@@ -290,7 +301,7 @@ bool CPVRTimers::UpdateEntries(const CPVRTimersContainer& timers, const std::vec
CLog::LogFC(LOGDEBUG, LOGPVR, "Deleted timer {} on client {}", timer->m_iClientIndex,
timer->m_iClientId);
- timerNotifications.emplace_back(timer->m_iClientId, timer->GetDeletedNotificationText());
+ CheckAndAppendTimerNotification(timerNotifications, timer, true);
it2 = it->second.erase(it2);
@@ -347,7 +358,10 @@ bool CPVRTimers::UpdateEntries(const CPVRTimersContainer& timers, const std::vec
}
}
+ m_failedClients = failedClients;
+ m_bFirstUpdate = false;
m_bIsUpdating = false;
+
if (bChanged)
{
UpdateChannels();
@@ -355,7 +369,7 @@ bool CPVRTimers::UpdateEntries(const CPVRTimersContainer& timers, const std::vec
NotifyTimersEvent(bAddedOrDeleted);
- if (!timerNotifications.empty() && CServiceBroker::GetPVRManager().IsStarted())
+ if (!timerNotifications.empty())
{
CPVREventLogJob* job = new CPVREventLogJob;
diff --git a/xbmc/pvr/timers/PVRTimers.h b/xbmc/pvr/timers/PVRTimers.h
index d51b7c1fbf..8d259b7edb 100644
--- a/xbmc/pvr/timers/PVRTimers.h
+++ b/xbmc/pvr/timers/PVRTimers.h
@@ -285,9 +285,17 @@ namespace PVR
std::vector<std::shared_ptr<CPVRTimerInfoTag>> GetActiveRecordings(const TimerKind& eKind) const;
int AmountActiveRecordings(const TimerKind& eKind) const;
+ bool CheckAndAppendTimerNotification(
+ std::vector<std::pair<int, std::string>>& timerNotifications,
+ const std::shared_ptr<CPVRTimerInfoTag>& tag,
+ bool bDeleted) const;
+
bool m_bIsUpdating = false;
CPVRSettings m_settings;
std::queue<std::shared_ptr<CPVRTimerInfoTag>> m_remindersToAnnounce;
bool m_bReminderRulesUpdatePending = false;
+
+ bool m_bFirstUpdate = true;
+ std::vector<int> m_failedClients;
};
}