Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pvr] Improved content of pvr shutdown warning dialog. #6734

Merged
merged 1 commit into from Mar 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 39 additions & 7 deletions addons/resource.language.en_gb/resources/strings.po
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
8 changes: 5 additions & 3 deletions xbmc/dialogs/GUIDialogYesNo.cpp
Expand Up @@ -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);
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions xbmc/dialogs/GUIDialogYesNo.h
Expand Up @@ -36,8 +36,8 @@ class CGUIDialogYesNo :
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;

Expand Down
88 changes: 85 additions & 3 deletions xbmc/pvr/PVRManager.cpp
Expand Up @@ -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).
Expand All @@ -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)
{
Expand All @@ -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?
Expand All @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions xbmc/pvr/PVRManager.h
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion xbmc/pvr/timers/PVRTimers.cpp
Expand Up @@ -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;
}
Expand Down