From dce6bb864be5f29c03d341493d05274652cdd0f7 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 1 Sep 2001 11:44:08 +0200 Subject: [PATCH] New remote control key 'Power' --- HISTORY | 3 ++- INSTALL | 10 ++++++++ MANUAL | 1 + config.c | 3 ++- config.h | 3 ++- i18n.c | 29 ++++++++++++++++++++- interface.c | 4 +-- keys-pc.conf | Bin 283 -> 300 bytes vdr.c | 70 ++++++++++++++++++++++++++++++--------------------- 9 files changed, 89 insertions(+), 34 deletions(-) diff --git a/HISTORY b/HISTORY index b63ad74b..3a7257d7 100644 --- a/HISTORY +++ b/HISTORY @@ -682,4 +682,5 @@ Video Disk Recorder Revision History - Changed version number notation. - Implemented automatic shutdown (see INSTALL and MANUAL for details). - New SVDRP command NEXT to show the next timer event. - +- The new remote control key "Power" can be used to turn the VDR machine + off (this requires the presence of the '-s' option). diff --git a/INSTALL b/INSTALL index cca0f21a..e15f13ee 100644 --- a/INSTALL +++ b/INSTALL @@ -120,6 +120,12 @@ receives a SIGTERM when the computer is actually shut down. So in case the shutdown fails, or the shutdown program for some reason decides not to perform a shutdown, VDR will stay up and running. +If there are currently no timers active, both parameters will be '0'. +In that case the program shall not set the hardware for automatic restart +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'. + 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 @@ -140,6 +146,9 @@ that event. The 'sudo halt' command then shuts down the computer. You will have to substitute both commands with whatever applies to your particular hard- and software environment. +If the '-s' option is present, the VDR machine can be turned off by pressing +the "Power" key on the remote control. + Command line options: --------------------- @@ -281,6 +290,7 @@ The default PC key assignments are: Back 'End' in numeric block Red, Green, Yellow, Blue 'F1'..'F4' 0..9 '0'..'9' in top row + Power 'P' If you prefer different key assignments, or if the default doesn't work for your keyboard, simply delete the file 'keys-pc.conf' and restart 'vdr' to get diff --git a/MANUAL b/MANUAL index 1983c1b9..5b3fa808 100644 --- a/MANUAL +++ b/MANUAL @@ -22,6 +22,7 @@ Video Disk Recorder User's Manual Yellow - Eject DVD Delete Delete - Delete Skip +60s Blue - Resume Mark Mark(1) - Summary Stop 0..9 Ch select - - - Numeric inp. - Editing + Power Shutdown - - - - - - (1) The "Mark" button in the "Timers" menu only works if sorting the timers has been disabled in the "Setup" menu. diff --git a/config.c b/config.c index 788f044e..4ae79d26 100644 --- a/config.c +++ b/config.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.c 1.60 2001/08/31 13:46:26 kls Exp $ + * $Id: config.c 1.61 2001/09/01 10:02:21 kls Exp $ */ #include "config.h" @@ -38,6 +38,7 @@ tKey keyTable[] = { // "Up" and "Down" must be the first two keys! { k7, "7", 0 }, { k8, "8", 0 }, { k9, "9", 0 }, + { kPower, "Power", 0 }, { kNone, "", 0 }, }; diff --git a/config.h b/config.h index 78502e1b..fa0794b9 100644 --- a/config.h +++ b/config.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.h 1.67 2001/09/01 07:15:26 kls Exp $ + * $Id: config.h 1.68 2001/09/01 10:01:51 kls Exp $ */ #ifndef __CONFIG_H @@ -44,6 +44,7 @@ enum eKeys { // "Up" and "Down" must be the first two keys! kYellow, kBlue, k0, k1, k2, k3, k4, k5, k6, k7, k8, k9, + kPower, kNone, // The following flags are OR'd with the above codes: k_Repeat = 0x8000, diff --git a/i18n.c b/i18n.c index f991b25e..39c15535 100644 --- a/i18n.c +++ b/i18n.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: i18n.c 1.36 2001/08/31 15:37:05 kls Exp $ + * $Id: i18n.c 1.37 2001/09/01 10:52:35 kls Exp $ * * Slovenian translations provided by Miha Setina * Italian translations provided by Alberto Carraro @@ -385,6 +385,15 @@ const tPhrase Phrases[] = { "Annuler les modifications?", "Avbryte redigering", }, + { "Recording - shut down anyway?", + "Aufnahme läuft - trotzdem ausschalten?", + "", // TODO + "", // TODO + "", // TODO + "", // TODO + "", // TODO + "", // TODO + }, { "Press any key to cancel shutdown", "Taste drücken um Shutdown abzubrechen", "", // TODO @@ -667,6 +676,15 @@ const tPhrase Phrases[] = { "Montage déjà en cours!", "Redigeringsprosessen er allerede aktiv!", }, + { "Can't shutdown - option '-s' not given!", + "Shutdown unmöglich - Option '-s' fehlt!", + "", // TODO + "", // TODO + "", // TODO + "", // TODO + "", // TODO + "", // TODO + }, // Setup parameters: { "OSD-Language", "OSD-Sprache", @@ -1139,6 +1157,15 @@ const tPhrase Phrases[] = { "Bleu", "Blå", }, + { "Power", + "Ausschalten", + "", // TODO + "", // TODO + "", // TODO + "", // TODO + "", // TODO + "", // TODO + }, // Miscellaneous: { "yes", "ja", diff --git a/interface.c b/interface.c index b7cb457c..a6c9451e 100644 --- a/interface.c +++ b/interface.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: interface.c 1.42 2001/09/01 07:30:37 kls Exp $ + * $Id: interface.c 1.43 2001/09/01 10:33:03 kls Exp $ */ #include "interface.h" @@ -356,7 +356,7 @@ void cInterface::QueryKeys(void) WriteText(1, 5, tr("Press any key on the RC unit")); Flush(); #ifndef REMOTE_KBD - unsigned char Code = 0; + unsigned char Code = '0'; unsigned short Address; #endif for (;;) { diff --git a/keys-pc.conf b/keys-pc.conf index cb0192be3fcc6e296bcd6efd69c099dfd7fdf664..899633b4944a5f9b84f3cd6304cdc596ef0002c8 100644 GIT binary patch delta 33 lcmbQuw1$bzIX@+p(_kZ;D5GFNetBwJx0RWTl2jBnz delta 15 WcmZ3(G@FUdIX@+plVKy9C?fzO7XzaJ diff --git a/vdr.c b/vdr.c index 322b50cb..d8a94770 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.65 2001/09/01 08:57:11 kls Exp $ + * $Id: vdr.c 1.66 2001/09/01 11:44:08 kls Exp $ */ #define _GNU_SOURCE @@ -303,6 +303,7 @@ int main(int argc, char *argv[]) int PreviousChannel = cDvbApi::CurrentChannel(); time_t LastActivity = 0; int MaxLatencyTime = 0; + bool ForceShutdown = false; if (WatchdogTimeout > 0) { dsyslog(LOG_INFO, "setting watchdog timer to %d seconds", WatchdogTimeout); @@ -427,6 +428,18 @@ int main(int argc, char *argv[]) case kMenu: Menu = new cMenuMain(ReplayControl); break; // Viewing Control: case kOk: LastChannel = -1; break; // forces channel display + // Power off: + case kPower: isyslog(LOG_INFO, "Power button pressed"); + if (!Shutdown) { + Interface->Error(tr("Can't shutdown - option '-s' not given!")); + break; + } + if (cRecordControls::Active()) { + if (Interface->Confirm(tr("Recording - shut down anyway?"))) + ForceShutdown = true; + } + LastActivity = 1; // not 0, see below! + break; default: break; } } @@ -434,39 +447,40 @@ int main(int argc, char *argv[]) EITScanner.Process(); cVideoCutter::Active(); } - if (!*Interact && !cRecordControls::Active()) { + if (!*Interact && (!cRecordControls::Active() || ForceShutdown)) { time_t Now = time(NULL); if (Now - LastActivity > ACTIVITYTIMEOUT) { // Shutdown: - if (Shutdown && Setup.MinUserInactivity && Now - LastActivity > Setup.MinUserInactivity * 60) { + if (Shutdown && (Setup.MinUserInactivity && Now - LastActivity > Setup.MinUserInactivity * 60 || ForceShutdown)) { + ForceShutdown = false; cTimer *timer = Timers.GetNextActiveTimer(); - if (timer) { - time_t Next = timer->StartTime(); - time_t Delta = Next - Now; + time_t Next = timer ? timer->StartTime() : 0; + time_t Delta = timer ? Next - Now : 0; + if (timer) dsyslog(LOG_INFO, "next timer event at %s", ctime(&Next)); - if (Delta > Setup.MinEventTimeout * 60) { - if (!LastActivity) { - // Apparently the user started VDR manually - dsyslog(LOG_INFO, "assuming manual start of VDR"); - LastActivity = Now; - continue; - } - if (WatchdogTimeout > 0) - signal(SIGALRM, SIG_IGN); - if (Interface->Confirm(tr("Press any key to cancel shutdown"), SHUTDOWNWAIT, true)) { - char *cmd; - asprintf(&cmd, "%s %ld %ld", Shutdown, Next, Delta); - isyslog(LOG_INFO, "executing '%s'", cmd); - system(cmd); - delete cmd; - } - else if (WatchdogTimeout > 0) { - alarm(WatchdogTimeout); - if (signal(SIGALRM, Watchdog) == SIG_IGN) - signal(SIGALRM, SIG_IGN); - } - LastActivity = Now; // don't try again too soon + if (!Next || Delta > Setup.MinEventTimeout * 60) { + if (!LastActivity) { + // Apparently the user started VDR manually + dsyslog(LOG_INFO, "assuming manual start of VDR"); + LastActivity = Now; + continue; // skip the rest of the housekeeping for now } + if (WatchdogTimeout > 0) + signal(SIGALRM, SIG_IGN); + if (Interface->Confirm(tr("Press any key to cancel shutdown"), LastActivity == 1 ? 5 : SHUTDOWNWAIT, true)) { + char *cmd; + asprintf(&cmd, "%s %ld %ld", Shutdown, Next, Delta); + isyslog(LOG_INFO, "executing '%s'", cmd); + system(cmd); + delete cmd; + } + else if (WatchdogTimeout > 0) { + alarm(WatchdogTimeout); + if (signal(SIGALRM, Watchdog) == SIG_IGN) + signal(SIGALRM, SIG_IGN); + } + LastActivity = Now; // don't try again too soon + continue; // skip the rest of the housekeeping for now } } // Disk housekeeping: