aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Sommerfeld <kai.sommerfeld@gmx.com>2015-03-20 21:58:05 +0100
committerKai Sommerfeld <kai.sommerfeld@gmx.com>2015-03-20 21:58:05 +0100
commitf8fb150b7f76f43fa1ae909342f644a02963f903 (patch)
treef517900ad474512629e8a858cf024a664a0a687b
parent08f9a0b1258ea17c05b7e14d244955669d2b2da0 (diff)
parentec98a2e38101b9c22ed6bf2c1b0b8c6829cb2968 (diff)
Merge pull request #6734 from ksooo/improve-no-shutdown-if-pvr-busy
[pvr] Improved content of pvr shutdown warning dialog.
-rw-r--r--addons/resource.language.en_gb/resources/strings.po46
-rw-r--r--xbmc/dialogs/GUIDialogYesNo.cpp8
-rw-r--r--xbmc/dialogs/GUIDialogYesNo.h4
-rw-r--r--xbmc/pvr/PVRManager.cpp88
-rw-r--r--xbmc/pvr/PVRManager.h8
-rw-r--r--xbmc/pvr/timers/PVRTimers.cpp2
6 files changed, 137 insertions, 19 deletions
diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po
index a0defd8e4f..e9c961094e 100644
--- a/addons/resource.language.en_gb/resources/strings.po
+++ b/addons/resource.language.en_gb/resources/strings.po
@@ -9383,16 +9383,12 @@ msgid "Adult"
msgstr ""
#. Title for shutdown confirmation dialog
-#: xbmc/ApplicationMessenger.cpp
+#: xbmc/pvr/PVRManager.cpp
msgctxt "#19685"
msgid "Confirm shutdown"
msgstr ""
-#. Text for shutdown confirmation dialog
-#: xbmc/ApplicationMessenger.cpp
-msgctxt "#19686"
-msgid "The PVR backend is busy. Shutdown anyway?"
-msgstr ""
+#empty string with id 19686
#: xbmc/pvr/windows/GUIWindowPVRGuide.cpp
msgctxt "#19687"
@@ -9414,7 +9410,43 @@ msgctxt "#19690"
msgid "Do you want to use this service?"
msgstr ""
-#empty strings from id 19691 to 19999
+#. Text for shutdown confirmation dialog.
+#: xbmc/pvr/PVRManager.cpp
+msgctxt "#19691"
+msgid "PVR is currently recording '%s' on channel '%s'."
+msgstr ""
+
+#. Text for shutdown confirmation dialog
+#: xbmc/pvr/PVRManager.cpp
+msgctxt "#19692"
+msgid "PVR will start recording '%s' on channel '%s' in %s."
+msgstr ""
+
+#. Text for shutdown confirmation dialog
+#: xbmc/pvr/PVRManager.cpp
+msgctxt "#19693"
+msgid "Daily wakeup is due in %s."
+msgstr ""
+
+#. Text for shutdown confirmation dialog
+#: xbmc/pvr/PVRManager.cpp
+msgctxt "#19694"
+msgid "%d minutes"
+msgstr ""
+
+#. Text for shutdown confirmation dialog
+#: xbmc/pvr/PVRManager.cpp
+msgctxt "#19695"
+msgid "about a minute"
+msgstr ""
+
+#. Yes button label for shutdown confirmation dialog
+#: xbmc/pvr/PVRManager.cpp
+msgctxt "#19696"
+msgid "Shutdown anyway"
+msgstr ""
+
+#empty strings from id 19697 to 19999
#: system/settings/settings.xml
msgctxt "#20000"
diff --git a/xbmc/dialogs/GUIDialogYesNo.cpp b/xbmc/dialogs/GUIDialogYesNo.cpp
index 460acf4574..56ab129c49 100644
--- a/xbmc/dialogs/GUIDialogYesNo.cpp
+++ b/xbmc/dialogs/GUIDialogYesNo.cpp
@@ -115,12 +115,14 @@ bool CGUIDialogYesNo::ShowAndGetInput(const std::string& heading, const std::str
return ShowAndGetInput(heading,line0,line1,line2,bDummy,noLabel,yesLabel);
}
-bool CGUIDialogYesNo::ShowAndGetInput(const std::string& heading, const std::string& text, bool& bCanceled, const std::string& noLabel, const std::string& yesLabel)
+bool CGUIDialogYesNo::ShowAndGetInput(const std::string& heading, const std::string& text, bool& bCanceled, const std::string& noLabel, const std::string& yesLabel, unsigned int autoCloseTime)
{
CGUIDialogYesNo *dialog = (CGUIDialogYesNo *)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
if (!dialog) return false;
dialog->SetHeading(heading);
dialog->SetText(text);
+ if (autoCloseTime)
+ dialog->SetAutoClose(autoCloseTime);
dialog->m_bCanceled = false;
if (!noLabel.empty())
dialog->SetChoice(0,noLabel);
@@ -135,10 +137,10 @@ bool CGUIDialogYesNo::ShowAndGetInput(const std::string& heading, const std::str
return (dialog->IsConfirmed()) ? true : false;
}
-bool CGUIDialogYesNo::ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, const std::string& line2, bool& bCanceled, const std::string& noLabel, const std::string& yesLabel)
+bool CGUIDialogYesNo::ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, const std::string& line2, bool& bCanceled, const std::string& noLabel, const std::string& yesLabel, unsigned int autoCloseTime)
{
std::string text = line0 + "\n" + line1 + "\n" + line2;
- return ShowAndGetInput(heading, text, bCanceled, noLabel, yesLabel);
+ return ShowAndGetInput(heading, text, bCanceled, noLabel, yesLabel, autoCloseTime);
}
int CGUIDialogYesNo::GetDefaultLabelID(int controlId) const
diff --git a/xbmc/dialogs/GUIDialogYesNo.h b/xbmc/dialogs/GUIDialogYesNo.h
index 770c6c9639..3b5f2a435f 100644
--- a/xbmc/dialogs/GUIDialogYesNo.h
+++ b/xbmc/dialogs/GUIDialogYesNo.h
@@ -36,8 +36,8 @@ public:
static bool ShowAndGetInput(int heading, int line0, int line1, int line2, bool& bCanceled);
static bool ShowAndGetInput(int heading, int line0, int line1, int line2, int iNoLabel, int iYesLabel, bool& bCanceled, unsigned int autoCloseTime = 0);
static bool ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, const std::string& line2, const std::string& noLabel="", const std::string& yesLabel="");
- static bool ShowAndGetInput(const std::string& heading, const std::string& text, bool& bCanceled, const std::string& noLabel, const std::string& yesLabel);
- static bool ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, const std::string& line2, bool &bCanceled, const std::string& noLabel="", const std::string& yesLabel="");
+ static bool ShowAndGetInput(const std::string& heading, const std::string& text, bool& bCanceled, const std::string& noLabel, const std::string& yesLabel, unsigned int autoCloseTime = 0);
+ static bool ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, const std::string& line2, bool &bCanceled, const std::string& noLabel="", const std::string& yesLabel="", unsigned int autoCloseTime = 0);
protected:
virtual int GetDefaultLabelID(int controlId) const;
diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp
index 3dcd90e6cf..0e1d69bcb9 100644
--- a/xbmc/pvr/PVRManager.cpp
+++ b/xbmc/pvr/PVRManager.cpp
@@ -1412,13 +1412,88 @@ bool CPVRManager::CanSystemPowerdown(bool bAskUser /*= true*/) const
bool bReturn(true);
if (IsStarted())
{
- if (!AllLocalBackendsIdle())
+ CPVRTimerInfoTagPtr cause;
+ if (!AllLocalBackendsIdle(cause))
{
if (bAskUser)
{
+ std::string text;
+
+ if (cause)
+ {
+ if (cause->IsRecording())
+ {
+ text = StringUtils::Format(g_localizeStrings.Get(19691).c_str(), // "PVR is currently recording...."
+ cause->Title().c_str(),
+ cause->ChannelName().c_str());
+ }
+ else
+ {
+ // Next event is due to a local recording.
+
+ const CDateTime now(CDateTime::GetUTCDateTime());
+ const CDateTime start(cause->StartAsUTC());
+ const CDateTimeSpan prestart(0, 0, cause->MarginStart(), 0);
+ const CDateTimeSpan prewakeup(0, 0, CSettings::Get().GetInt("pvrpowermanagement.prewakeup"), 0);
+
+ CDateTimeSpan diff(start - now);
+ diff -= prestart - prewakeup;
+ int mins = diff.GetSecondsTotal() / 60;
+
+ std::string dueStr;
+ if (mins > 1)
+ {
+ // "%d minutes"
+ dueStr = StringUtils::Format(g_localizeStrings.Get(19694).c_str(), mins);
+ }
+ else
+ {
+ // "about a minute"
+ dueStr = g_localizeStrings.Get(19695);
+ }
+
+ text = StringUtils::Format(g_localizeStrings.Get(19692).c_str(), // "PVR will start recording...."
+ cause->Title().c_str(),
+ cause->ChannelName().c_str(),
+ dueStr.c_str());
+ }
+ }
+ else
+ {
+ // Next event is due to automatic daily wakeup of PVR.
+ const CDateTime now(CDateTime::GetUTCDateTime());
+
+ CDateTime dailywakeuptime;
+ dailywakeuptime.SetFromDBTime(CSettings::Get().GetString("pvrpowermanagement.dailywakeuptime"));
+ dailywakeuptime = dailywakeuptime.GetAsUTCDateTime();
+
+ const CDateTimeSpan diff(dailywakeuptime - now);
+ int mins = diff.GetSecondsTotal() / 60;
+
+ std::string dueStr;
+ if (mins > 1)
+ {
+ // "%d minutes"
+ dueStr = StringUtils::Format(g_localizeStrings.Get(19694).c_str(), mins);
+ }
+ else
+ {
+ // "about a minute"
+ dueStr = g_localizeStrings.Get(19695);
+ }
+
+ text = StringUtils::Format(g_localizeStrings.Get(19693).c_str(), // "Daily wakeup is due in...."
+ dueStr.c_str());
+ }
+
// Inform user about PVR being busy. Ask if user wants to powerdown anyway.
bool bCanceled = false;
- bReturn = CGUIDialogYesNo::ShowAndGetInput(19685, 19686, 0, 0, -1, -1, bCanceled, 10000);
+ bReturn = CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(19685), // "Confirm shutdown"
+ text,
+ bCanceled,
+ g_localizeStrings.Get(222), // "Cancel"
+ g_localizeStrings.Get(19696), // "Shutdown anyway"
+ 10000);
}
else
bReturn = false; // do not powerdown (busy, but no user interaction requested).
@@ -1427,7 +1502,7 @@ bool CPVRManager::CanSystemPowerdown(bool bAskUser /*= true*/) const
return bReturn;
}
-bool CPVRManager::AllLocalBackendsIdle(void) const
+bool CPVRManager::AllLocalBackendsIdle(CPVRTimerInfoTagPtr& causingEvent) const
{
if (m_timers)
{
@@ -1436,7 +1511,10 @@ bool CPVRManager::AllLocalBackendsIdle(void) const
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?
@@ -1446,11 +1524,15 @@ bool CPVRManager::AllLocalBackendsIdle(void) const
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;
diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h
index d1c4ce9cf5..00b8461b2e 100644
--- a/xbmc/pvr/PVRManager.h
+++ b/xbmc/pvr/PVRManager.h
@@ -44,11 +44,13 @@ namespace PVR
{
class CPVRClients;
class CPVRChannel;
- typedef std::shared_ptr<PVR::CPVRChannel> CPVRChannelPtr;
+ typedef std::shared_ptr<CPVRChannel> CPVRChannelPtr;
class CPVRChannelGroupsContainer;
class CPVRChannelGroup;
class CPVRRecordings;
class CPVRTimers;
+ class CPVRTimerInfoTag;
+ typedef std::shared_ptr<CPVRTimerInfoTag> CPVRTimerInfoTagPtr;
class CPVRGUIInfo;
class CPVRDatabase;
class CGUIWindowPVRCommon;
@@ -369,7 +371,7 @@ namespace PVR
* @brief Check whether the system Kodi is running on can be powered down
* (shutdown/reboot/suspend/hibernate) without stopping any active
* recordings and/or without preventing the start of recordings
- * sheduled for now + pvrpowermanagement.backendidletime.
+ * scheduled for now + pvrpowermanagement.backendidletime.
* @param bAskUser True to informs user in case of potential
* data loss. User can decide to allow powerdown anyway. False to
* not to ask user and to not confirm power down.
@@ -637,7 +639,7 @@ namespace PVR
void SetState(ManagerState state);
- bool AllLocalBackendsIdle(void) const;
+ bool AllLocalBackendsIdle(CPVRTimerInfoTagPtr& causingEvent) const;
bool EventOccursOnLocalBackend(const CFileItemPtr& item) const;
bool IsNextEventWithinBackendIdleTime(void) const;
diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp
index d1dca8c96f..20989924d2 100644
--- a/xbmc/pvr/timers/PVRTimers.cpp
+++ b/xbmc/pvr/timers/PVRTimers.cpp
@@ -675,7 +675,7 @@ CDateTime CPVRTimers::GetNextEventTime(void) const
{
const CDateTimeSpan prestart(0, 0, item->GetPVRTimerInfoTag()->MarginStart(), 0);
const CDateTime start = item->GetPVRTimerInfoTag()->StartAsUTC();
- wakeuptime = ((start - idle) > now) ?
+ wakeuptime = ((start - prestart - prewakeup - idle) > now) ?
start - prestart - prewakeup :
now + idle;
}