aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xbmc/dialogs/GUIDialogKaiToast.cpp8
-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
5 files changed, 48 insertions, 16 deletions
diff --git a/xbmc/dialogs/GUIDialogKaiToast.cpp b/xbmc/dialogs/GUIDialogKaiToast.cpp
index 239afaca31..68d1f4823e 100644
--- a/xbmc/dialogs/GUIDialogKaiToast.cpp
+++ b/xbmc/dialogs/GUIDialogKaiToast.cpp
@@ -72,6 +72,14 @@ void CGUIDialogKaiToast::AddToQueue(const std::string& aImageFile, const eMessag
{
CSingleLock lock(m_critical);
+ if (!m_notifications.empty())
+ {
+ const auto& last = m_notifications.back();
+ if (last.eType == eType && last.imagefile == aImageFile && last.caption == aCaption &&
+ last.description == aDescription)
+ return; // avoid duplicates in a row.
+ }
+
Notification toast;
toast.eType = eType;
toast.imagefile = aImageFile;
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;
};
}