From c7bb0bb73964eafed5e337dc18278fa118775671 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 8 Sep 2001 13:02:05 +0200 Subject: [PATCH] Improved handling of 'Power' key --- HISTORY | 5 +++++ INSTALL | 6 ++++++ vdr.c | 11 ++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/HISTORY b/HISTORY index 6b069801..70e2c9a1 100644 --- a/HISTORY +++ b/HISTORY @@ -727,3 +727,8 @@ Video Disk Recorder Revision History is no DVB card that can access this channel). - Fixed toggling channels with the '0' key in case the "Ok" button has been pressed to display the current/next information. +- Pressing the "Power" key now always initiates the shutdown sequence (after + user confirmation in case of a recording timer), event if there is currently + a menu or a replay session active. Note the additional remarks in INSTALL + regarding the values of the two parameters given to the shutdown program + in case of a currently recording timer. diff --git a/INSTALL b/INSTALL index e15f13ee..846ddeec 100644 --- a/INSTALL +++ b/INSTALL @@ -126,6 +126,12 @@ and only perform the system shutdown. A program that uses the second parameter to set the hardware for restart must therefore also check whether the first parameter is '0'. +If a timer is currently recording, the parameters will reflect the start +time of that timer. This means that the first parameter will be a time in +the past, and the second parameter will be a negative number. This only +happens if the user presses the "Power" key while a timer is currently +recording. + Before the shutdown program is called, the user will be prompted to inform him that the system is about to shut down. If any remote control key is pressed while this prompt is visible, the shutdown will be cancelled (and diff --git a/vdr.c b/vdr.c index f71cfd12..51a841ee 100644 --- a/vdr.c +++ b/vdr.c @@ -22,7 +22,7 @@ * * The project's page is at http://www.cadsoft.de/people/kls/vdr * - * $Id: vdr.c 1.70 2001/09/08 12:15:05 kls Exp $ + * $Id: vdr.c 1.71 2001/09/08 12:49:38 kls Exp $ */ #define _GNU_SOURCE @@ -350,7 +350,7 @@ int main(int argc, char *argv[]) EITScanner.Activity(); LastActivity = time(NULL); } - if (*Interact) { + if (*Interact && key != kPower) { switch ((*Interact)->ProcessKey(key)) { case osMenu: DELETENULL(Menu); Menu = new cMenuMain(ReplayControl); @@ -434,6 +434,7 @@ int main(int argc, char *argv[]) case kOk: LastChannel = -1; break; // forces channel display // Power off: case kPower: isyslog(LOG_INFO, "Power button pressed"); + DELETENULL(*Interact); if (!Shutdown) { Interface->Error(tr("Can't shutdown - option '-s' not given!")); break; @@ -455,8 +456,7 @@ int main(int argc, char *argv[]) time_t Now = time(NULL); if (Now - LastActivity > ACTIVITYTIMEOUT) { // Shutdown: - if (Shutdown && (Setup.MinUserInactivity && Now - LastActivity > Setup.MinUserInactivity * 60 || ForceShutdown)) { - ForceShutdown = false; + if (Shutdown && Setup.MinUserInactivity && Now - LastActivity > Setup.MinUserInactivity * 60) { cTimer *timer = Timers.GetNextActiveTimer(); time_t Next = timer ? timer->StartTime() : 0; time_t Delta = timer ? Next - Now : 0; @@ -470,7 +470,8 @@ int main(int argc, char *argv[]) else LastActivity = 1; } - if (!Next || Delta > Setup.MinEventTimeout * 60) { + if (!Next || Delta > Setup.MinEventTimeout * 60 || ForceShutdown) { + ForceShutdown = false; if (timer) dsyslog(LOG_INFO, "next timer event at %s", ctime(&Next)); if (WatchdogTimeout > 0)