vdr 2.6.6
shutdown.h
Go to the documentation of this file.
1/*
2 * shutdown.h: Handling of shutdown and inactivity
3 *
4 * See the main source file 'vdr.c' for copyright information and
5 * how to reach the author.
6 *
7 * Original version written by Udo Richter <udo_richter@gmx.de>.
8 *
9 * $Id: shutdown.h 2.1 2013/02/18 10:35:27 kls Exp $
10 */
11
12#ifndef __SHUTDOWN_H
13#define __SHUTDOWN_H
14
15#include <time.h>
16
18private:
19 time_t timeout;
20 int counter;
21 bool timedOut;
22 const char *message;
23public:
24 cCountdown(void);
25 void Start(const char *Message, int Seconds);
27 void Cancel(void);
29 bool Done(void);
31 operator bool(void) const { return timeout != 0; }
33 bool Update(void);
36 };
37
39private:
42 time_t retry;
50public:
52 cShutdownHandler(void);
54 void Exit(int ExitCode) { exitCode = ExitCode; }
57 bool DoExit(void) { return exitCode >= 0; }
59 int GetExitCode(void) { return exitCode >= 0 ? exitCode : 0; }
63 void RequestEmergencyExit(void);
65 void CheckManualStart(int ManualStart);
68 void SetShutdownCommand(const char *ShutdownCommand);
70 void CallShutdownCommand(time_t WakeupTime, int Channel, const char *File, bool UserShutdown);
72 bool IsUserInactive(time_t AtTime = 0) { return activeTimeout && activeTimeout <= (AtTime ? AtTime : time(NULL)); }
75 time_t GetUserInactiveTime(void) { return activeTimeout; }
77 void SetUserInactiveTimeout(int Seconds = -1, bool Force = false);
86 void SetUserInactive(void) { SetUserInactiveTimeout(0, true); }
88 bool Retry(time_t AtTime = 0) { return retry <= (AtTime ? AtTime : time(NULL)); }
91 time_t GetRetry(void) { return retry; }
93 void SetRetry(int Seconds) { retry = time(NULL) + Seconds; }
96 bool ConfirmShutdown(bool Ask);
101 bool ConfirmRestart(bool Ask);
106 bool DoShutdown(bool Force);
111 };
112
114
115#endif
time_t timeout
5-minute countdown timer
Definition shutdown.h:19
cCountdown(void)
Definition shutdown.c:29
bool timedOut
countdown did run down to 0 and was not canceled
Definition shutdown.h:21
bool Update(void)
Update status display of the countdown.
Definition shutdown.c:64
int counter
last shown time in 10s units
Definition shutdown.h:20
void Start(const char *Message, int Seconds)
Start the 5 minute shutdown warning countdown.
Definition shutdown.c:37
const char * message
message to display, s is placeholder for time
Definition shutdown.h:22
void Cancel(void)
Cancel the 5 minute shutdown warning countdown.
Definition shutdown.c:46
bool Done(void)
Check if countdown timer has run out without canceling.
Definition shutdown.c:55
void CheckManualStart(int ManualStart)
Check whether the next timer is in ManualStart time window.
Definition shutdown.c:104
time_t activeTimeout
Time when VDR will become non-interactive. 0 means never, 1 means unknown time ago.
Definition shutdown.h:40
void SetShutdownCommand(const char *ShutdownCommand)
Set the command string for shutdown command.
Definition shutdown.c:121
char * shutdownCommand
Command for shutting down VDR.
Definition shutdown.h:44
bool ConfirmShutdown(bool Ask)
Check for background activity that blocks shutdown.
Definition shutdown.c:157
time_t GetUserInactiveTime(void)
Time when user will become non-inactive, or 0 if never, 1 if a long time ago.
Definition shutdown.h:75
bool EmergencyExitRequested(void)
Returns true if an emergency exit was requested.
Definition shutdown.h:61
void SetRetry(int Seconds)
Set shutdown retry so that VDR will not try to automatically shut down within Seconds.
Definition shutdown.h:93
bool Retry(time_t AtTime=0)
Check whether its time to re-try the shutdown.
Definition shutdown.h:88
int exitCode
Exit code, if VDR exit was requested, or -1 if not requested.
Definition shutdown.h:46
bool IsUserInactive(time_t AtTime=0)
Check whether VDR is in interactive mode or non-interactive mode (waiting for shutdown).
Definition shutdown.h:72
void RequestEmergencyExit(void)
Requests an emergency exit of the VDR main loop.
Definition shutdown.c:93
cShutdownHandler(void)
Definition shutdown.c:79
bool DoShutdown(bool Force)
Call the shutdown script with data of the next pending timer.
Definition shutdown.c:233
bool ConfirmRestart(bool Ask)
Check for background activity that blocks restart.
Definition shutdown.c:209
void Exit(int ExitCode)
Set VDR exit code and initiate end of VDR main loop.
Definition shutdown.h:54
void CallShutdownCommand(time_t WakeupTime, int Channel, const char *File, bool UserShutdown)
Call the shutdown command with the given parameters.
Definition shutdown.c:127
void SetUserInactiveTimeout(int Seconds=-1, bool Force=false)
Set the time in the future when VDR will switch into non-interactive mode or power down.
Definition shutdown.c:141
bool DoExit(void)
Check if an exit code was set, and VDR should exit.
Definition shutdown.h:57
cCountdown countdown
Definition shutdown.h:51
time_t retry
Time for retrying the shutdown.
Definition shutdown.h:42
void SetUserInactive(void)
Set VDR manually into non-interactive mode from now on.
Definition shutdown.h:86
time_t GetRetry(void)
Time when shutdown retry block ends.
Definition shutdown.h:91
bool emergencyExitRequested
The requested exit is an emergency exit.
Definition shutdown.h:48
int GetExitCode(void)
Get the currently set exit code of VDR.
Definition shutdown.h:59
cShutdownHandler ShutdownHandler
Definition shutdown.c:27