vdr  2.0.4
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 
17 class cCountdown {
18 private:
19  time_t timeout;
20  int counter;
21  bool timedOut;
22  const char *message;
23 public:
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 
39 private:
40  time_t activeTimeout;
42  time_t retry;
44  char *shutdownCommand;
46  int exitCode;
50 public:
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
116