summaryrefslogtreecommitdiff
path: root/shutdown.h
diff options
context:
space:
mode:
authorKlaus Schmidinger <kls (at) cadsoft (dot) de>2007-02-25 18:00:00 +0100
committerKlaus Schmidinger <kls (at) cadsoft (dot) de>2007-02-25 18:00:00 +0100
commit9f42c33ef6793482a5c2515f9a87c13c0d189c60 (patch)
tree45025e95c0774761760c9bc6a44f4e69a1baf43b /shutdown.h
parent66ab78a40f5b57e20142a33484e32c785a0c4017 (diff)
downloadvdr-patch-lnbsharing-9f42c33ef6793482a5c2515f9a87c13c0d189c60.tar.gz
vdr-patch-lnbsharing-9f42c33ef6793482a5c2515f9a87c13c0d189c60.tar.bz2
Version 1.5.1vdr-1.5.1
- Added cDevice::HasCi() so that devices with Common Interface can be avoided when tuning to an FTA channel, thus preserving the CAM resources even on budget DVB cards (suggested by Petri Helin). - Fixed i18n characters for the Hungarian texts (thanks to Thomas Günther). - Now using cPipe instead of popen() in cCommand::Execute() to avoid problems with open file handles when starting background commands (thanks to Reinhard Nissl). - Removed 'assert(0)' from cDvbSpuDecoder::setTime() (thanks to Marco Schlüßler). - Fixed a possible crash when loading an invalid XPM file (thanks to Martin Wache). - Updated satellite names in 'sources.conf' (thanks to Thilo Wunderlich). - Adapted 'libsi' to DVB-S2 (thanks to Marco Schlüßler). - Fixed handling error status in cDvbTuner::GetFrontendStatus() (thanks to Reinhard Nissl). - Shutdown handling has been rewritten (thanks to Udo Richter). - Plugins can now implement the new function WakeupTime() to request VDR to wake up at a particular time (thanks to Udo Richter). - The HUP signal now forces a restart of VDR (thanks to Udo Richter). - cThread::EmergencyExit() has been replaced by ShutdownHandler.RequestEmergencyExit(). - Several references to "button" in a remote control context have been changed to "key" (based on a report from Marko Mäkelä regarding the "Menu button closes" text). The "MenuButtonCloses" parameter in 'setup.conf' has therefore been renamed to "MenuKeyCloses", accordingly. This will result in an "unknown config parameter: MenuButtonCloses" error message in the log file, so you may want to remove that entry from your 'setup.conf' file. - Simplified the error handling in cDvbTuner::GetFrontendStatus() (based on a discussion with Reinhard Nissl). - Updated the Finnish OSD texts (thanks to Rolf Ahrenberg). - Increased the maximum number of DVB devices to 8 (thanks to Rolf Ahrenberg). - The new Setup parameter "Channel entry timeout" can be used to customize the time since the last keypress until a numerically entered channel number is considered complete, and the channel is switched (suggested by Helmut Auer). Setting this parameter to 0 turns off the automatic channel switching, and the user will have to confirm the entry by pressing the "Ok" key.
Diffstat (limited to 'shutdown.h')
-rw-r--r--shutdown.h112
1 files changed, 112 insertions, 0 deletions
diff --git a/shutdown.h b/shutdown.h
new file mode 100644
index 0000000..4dff8ea
--- /dev/null
+++ b/shutdown.h
@@ -0,0 +1,112 @@
+/*
+ * shutdown.h: Handling of shutdown and inactivity
+ *
+ * See the main source file 'vdr.c' for copyright information and
+ * how to reach the author.
+ *
+ * Original version written by Udo Richter <udo_richter@gmx.de>.
+ *
+ * $Id: shutdown.h 1.1 2007/02/24 17:23:59 kls Exp $
+ */
+
+#ifndef __SHUTDOWN_H
+#define __SHUTDOWN_H
+
+#include <time.h>
+
+class cCountdown {
+private:
+ time_t timeout; ///< 5-minute countdown timer
+ int counter; ///< last shown time in 10s units
+ bool timedOut; ///< countdown did run down to 0 and was not canceled
+ const char *message; ///< message to display, %s is placeholder for time
+public:
+ cCountdown(void);
+ void Start(const char *Message, int Seconds);
+ ///< Start the 5 minute shutdown warning countdown.
+ void Cancel(void);
+ ///< Cancel the 5 minute shutdown warning countdown.
+ bool Done(void);
+ ///< Check if countdown timer has run out without canceling.
+ operator bool(void) const { return timeout != 0; }
+ ///< Check if countdown is running.
+ bool Update(void);
+ ///< Update status display of the countdown.
+ ///< Returns true on actual update.
+ };
+
+class cShutdownHandler {
+private:
+ time_t activeTimeout;
+ ///< Time when VDR will become non-interactive. 0 means never.
+ time_t retry;
+ ///< Time for retrying the shutdown.
+ char *shutdownCommand;
+ ///< Command for shutting down VDR.
+ int exitCode;
+ ///< Exit code, if VDR exit was requested, or -1 if not requested.
+ bool emergencyExitRequested;
+ ///< The requested exit is an emergency exit.
+public:
+ cCountdown countdown;
+ cShutdownHandler(void);
+ ~cShutdownHandler();
+ void Exit(int ExitCode) { exitCode = ExitCode; }
+ ///< Set VDR exit code and initiate end of VDR main loop.
+ ///< This will exit VDR without any confirmation.
+ bool DoExit(void) { return exitCode >= 0; }
+ ///< Check if an exit code was set, and VDR should exit.
+ int GetExitCode(void) { return exitCode >= 0 ? exitCode : 0; }
+ ///< Get the currently set exit code of VDR.
+ bool EmergencyExitRequested(void) { return emergencyExitRequested; }
+ ///< Returns true if an emergency exit was requested.
+ void RequestEmergencyExit(void);
+ ///< Requests an emergency exit of the VDR main loop.
+ void CheckManualStart(int ManualStart);
+ ///< Check whether the next timer is in ManualStart time window.
+ ///< If yes, assume non-interactive use.
+ void SetShutdownCommand(const char *ShutdownCommand);
+ ///< Set the command string for shutdown command.
+ void CallShutdownCommand(time_t WakeupTime, int Channel, const char *File, bool UserShutdown);
+ ///< Call the shutdown command with the given parameters.
+ bool IsUserInactive(time_t AtTime = 0) { return activeTimeout && activeTimeout <= (AtTime ? AtTime : time(NULL)); }
+ ///< Check whether VDR is in interactive mode or non-interactive mode (waiting for shutdown).
+ ///< AtTime checks whether VDR will probably be inactive at that time.
+ time_t GetUserInactiveTime(void) { return activeTimeout; }
+ ///< Time when user will become non-inactive, or 0 if never.
+ void SetUserInactiveTimeout(int Seconds = -1, bool Force = false);
+ ///< Set the time when VDR will switch into non-interactive mode or power down.
+ ///< -1 means Setup.MinUserInactivity in the future.
+ ///< Otherwise, seconds in the future.
+ ///< If MinUserInactivity = 0 and Force = false, Seconds is ignored and VDR will
+ ///< stay interactive forever.
+ void SetUserInactive(void) { SetUserInactiveTimeout(0, true); }
+ ///< Set VDR manually into non-interactive mode.
+ bool Retry(time_t AtTime = 0) { return retry <= (AtTime ? AtTime : time(NULL)); }
+ ///< Check whether its time to re-try the shutdown.
+ ///< AtTime checks whether VDR will probably be inactive at that time.
+ time_t GetRetry(void) { return retry; }
+ ///< Time when shutdown retry block ends.
+ void SetRetry(int Seconds) { retry = time(NULL) + Seconds; }
+ ///< Set shutdown retry so that VDR will not try to automatically shut down
+ ///< within Seconds.
+ bool ConfirmShutdown(bool Ask);
+ ///< Check for background activity that blocks shutdown.
+ ///< Returns immediately and without user interaction if Ask = false.
+ ///< Asks for confirmation if Ask = true.
+ ///< Returns true if ready for shutdown.
+ bool ConfirmRestart(bool Ask);
+ ///< Check for background activity that blocks restart.
+ ///< Returns immediately and without user interaction if Ask = false.
+ ///< Asks for confirmation if Ask = true.
+ ///< Returns true if ready for restart.
+ bool DoShutdown(bool Force);
+ ///< Call the shutdown script with data of the next pending timer.
+ ///< Fails if Force = false and a timer is running or within MinEventTimeout.
+ ///< Always calls shutdown on Force = true.
+ ///< Returns true on success.
+ };
+
+extern cShutdownHandler ShutdownHandler;
+
+#endif