vdr
1.7.31
Main Page
Namespaces
Classes
Files
File List
File Members
include
vdr
include/vdr/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.0 2007/02/24 17:23:59 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
38
class
cShutdownHandler
{
39
private
:
40
time_t
activeTimeout
;
42
time_t
retry
;
44
char
*
shutdownCommand
;
46
int
exitCode
;
48
bool
emergencyExitRequested
;
50
public
:
51
cCountdown
countdown
;
52
cShutdownHandler
(
void
);
53
~cShutdownHandler
();
54
void
Exit
(
int
ExitCode) {
exitCode
= ExitCode; }
57
bool
DoExit
(
void
) {
return
exitCode
>= 0; }
59
int
GetExitCode
(
void
) {
return
exitCode
>= 0 ?
exitCode
: 0; }
61
bool
EmergencyExitRequested
(
void
) {
return
emergencyExitRequested
; }
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
);
83
void
SetUserInactive
(
void
) {
SetUserInactiveTimeout
(0,
true
); }
85
bool
Retry
(time_t AtTime = 0) {
return
retry
<= (AtTime ? AtTime : time(NULL)); }
88
time_t
GetRetry
(
void
) {
return
retry
; }
90
void
SetRetry
(
int
Seconds) {
retry
= time(NULL) + Seconds; }
93
bool
ConfirmShutdown
(
bool
Ask);
98
bool
ConfirmRestart
(
bool
Ask);
103
bool
DoShutdown
(
bool
Force);
108
};
109
110
extern
cShutdownHandler
ShutdownHandler
;
111
112
#endif
Generated by
1.8.1.2