vdr  2.0.5
vdr.c
Go to the documentation of this file.
1 /*
2  * vdr.c: Video Disk Recorder main program
3  *
4  * Copyright (C) 2000, 2003, 2006, 2008, 2013 Klaus Schmidinger
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  *
21  * The author can be reached at vdr@tvdr.de
22  *
23  * The project's page is at http://www.tvdr.de
24  *
25  * $Id: vdr.c 2.57.1.4 2013/12/25 11:40:37 kls Exp $
26  */
27 
28 #include <getopt.h>
29 #include <grp.h>
30 #include <langinfo.h>
31 #include <locale.h>
32 #include <pwd.h>
33 #include <signal.h>
34 #include <stdlib.h>
35 #include <sys/capability.h>
36 #include <sys/prctl.h>
37 #include <termios.h>
38 #include <unistd.h>
39 #include "audio.h"
40 #include "channels.h"
41 #include "config.h"
42 #include "cutter.h"
43 #include "device.h"
44 #include "diseqc.h"
45 #include "dvbdevice.h"
46 #include "eitscan.h"
47 #include "epg.h"
48 #include "filetransfer.h"
49 #include "i18n.h"
50 #include "interface.h"
51 #include "keys.h"
52 #include "libsi/si.h"
53 #include "lirc.h"
54 #include "menu.h"
55 #include "osdbase.h"
56 #include "plugin.h"
57 #include "recording.h"
58 #include "shutdown.h"
59 #include "skinclassic.h"
60 #include "skinlcars.h"
61 #include "skinsttng.h"
62 #include "sourceparams.h"
63 #include "sources.h"
64 #include "themes.h"
65 #include "timers.h"
66 #include "tools.h"
67 #include "transfer.h"
68 #include "videodir.h"
69 
70 #define MINCHANNELWAIT 10 // seconds to wait between failed channel switchings
71 #define ACTIVITYTIMEOUT 60 // seconds before starting housekeeping
72 #define SHUTDOWNWAIT 300 // seconds to wait in user prompt before automatic shutdown
73 #define SHUTDOWNRETRY 360 // seconds before trying again to shut down
74 #define SHUTDOWNFORCEPROMPT 5 // seconds to wait in user prompt to allow forcing shutdown
75 #define SHUTDOWNCANCELPROMPT 5 // seconds to wait in user prompt to allow canceling shutdown
76 #define RESTARTCANCELPROMPT 5 // seconds to wait in user prompt before restarting on SIGHUP
77 #define MANUALSTART 600 // seconds the next timer must be in the future to assume manual start
78 #define CHANNELSAVEDELTA 600 // seconds before saving channels.conf after automatic modifications
79 #define DEVICEREADYTIMEOUT 30 // seconds to wait until all devices are ready
80 #define MENUTIMEOUT 120 // seconds of user inactivity after which an OSD display is closed
81 #define TIMERCHECKDELTA 10 // seconds between checks for timers that need to see their channel
82 #define TIMERDEVICETIMEOUT 8 // seconds before a device used for timer check may be reused
83 #define TIMERLOOKAHEADTIME 60 // seconds before a non-VPS timer starts and the channel is switched if possible
84 #define VPSLOOKAHEADTIME 24 // hours within which VPS timers will make sure their events are up to date
85 #define VPSUPTODATETIME 3600 // seconds before the event or schedule of a VPS timer needs to be refreshed
86 
87 #define EXIT(v) { ShutdownHandler.Exit(v); goto Exit; }
88 
89 static int LastSignal = 0;
90 
91 static bool SetUser(const char *UserName, bool UserDump)
92 {
93  if (UserName) {
94  struct passwd *user = getpwnam(UserName);
95  if (!user) {
96  fprintf(stderr, "vdr: unknown user: '%s'\n", UserName);
97  return false;
98  }
99  if (setgid(user->pw_gid) < 0) {
100  fprintf(stderr, "vdr: cannot set group id %u: %s\n", (unsigned int)user->pw_gid, strerror(errno));
101  return false;
102  }
103  if (initgroups(user->pw_name, user->pw_gid) < 0) {
104  fprintf(stderr, "vdr: cannot set supplemental group ids for user %s: %s\n", user->pw_name, strerror(errno));
105  return false;
106  }
107  if (setuid(user->pw_uid) < 0) {
108  fprintf(stderr, "vdr: cannot set user id %u: %s\n", (unsigned int)user->pw_uid, strerror(errno));
109  return false;
110  }
111  if (UserDump && prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0)
112  fprintf(stderr, "vdr: warning - cannot set dumpable: %s\n", strerror(errno));
113  setenv("HOME", user->pw_dir, 1);
114  setenv("USER", user->pw_name, 1);
115  setenv("LOGNAME", user->pw_name, 1);
116  setenv("SHELL", user->pw_shell, 1);
117  }
118  return true;
119 }
120 
121 static bool DropCaps(void)
122 {
123  // drop all capabilities except selected ones
124  cap_t caps = cap_from_text("= cap_sys_nice,cap_sys_time,cap_net_raw=ep");
125  if (!caps) {
126  fprintf(stderr, "vdr: cap_from_text failed: %s\n", strerror(errno));
127  return false;
128  }
129  if (cap_set_proc(caps) == -1) {
130  fprintf(stderr, "vdr: cap_set_proc failed: %s\n", strerror(errno));
131  cap_free(caps);
132  return false;
133  }
134  cap_free(caps);
135  return true;
136 }
137 
138 static bool SetKeepCaps(bool On)
139 {
140  // set keeping capabilities during setuid() on/off
141  if (prctl(PR_SET_KEEPCAPS, On ? 1 : 0, 0, 0, 0) != 0) {
142  fprintf(stderr, "vdr: prctl failed\n");
143  return false;
144  }
145  return true;
146 }
147 
148 static void SignalHandler(int signum)
149 {
150  switch (signum) {
151  case SIGPIPE:
152  break;
153  case SIGHUP:
154  LastSignal = signum;
155  break;
156  default:
157  LastSignal = signum;
158  Interface->Interrupt();
160  }
161  signal(signum, SignalHandler);
162 }
163 
164 static void Watchdog(int signum)
165 {
166  // Something terrible must have happened that prevented the 'alarm()' from
167  // being called in time, so let's get out of here:
168  esyslog("PANIC: watchdog timer expired - exiting!");
169  exit(1);
170 }
171 
172 int main(int argc, char *argv[])
173 {
174  // Save terminal settings:
175 
176  struct termios savedTm;
177  bool HasStdin = (tcgetpgrp(STDIN_FILENO) == getpid() || getppid() != (pid_t)1) && tcgetattr(STDIN_FILENO, &savedTm) == 0;
178 
179  // Initiate locale:
180 
181  setlocale(LC_ALL, "");
182 
183  // Command line options:
184 
185 #define dd(a, b) (*a ? a : b)
186 #define DEFAULTSVDRPPORT 6419
187 #define DEFAULTWATCHDOG 0 // seconds
188 #define DEFAULTVIDEODIR VIDEODIR
189 #define DEFAULTCONFDIR dd(CONFDIR, VideoDirectory)
190 #define DEFAULTCACHEDIR dd(CACHEDIR, VideoDirectory)
191 #define DEFAULTRESDIR dd(RESDIR, ConfigDirectory)
192 #define DEFAULTPLUGINDIR PLUGINDIR
193 #define DEFAULTLOCDIR LOCDIR
194 #define DEFAULTEPGDATAFILENAME "epg.data"
195 
196  bool StartedAsRoot = false;
197  const char *VdrUser = NULL;
198  bool UserDump = false;
199  int SVDRPport = DEFAULTSVDRPPORT;
200  const char *AudioCommand = NULL;
201  const char *VideoDirectory = DEFAULTVIDEODIR;
202  const char *ConfigDirectory = NULL;
203  const char *CacheDirectory = NULL;
204  const char *ResourceDirectory = NULL;
205  const char *LocaleDirectory = DEFAULTLOCDIR;
206  const char *EpgDataFileName = DEFAULTEPGDATAFILENAME;
207  bool DisplayHelp = false;
208  bool DisplayVersion = false;
209  bool DaemonMode = false;
210  int SysLogTarget = LOG_USER;
211  bool MuteAudio = false;
212  int WatchdogTimeout = DEFAULTWATCHDOG;
213  const char *Terminal = NULL;
214 
215  bool UseKbd = true;
216  const char *LircDevice = NULL;
217 #if !defined(REMOTE_KBD)
218  UseKbd = false;
219 #endif
220 #if defined(REMOTE_LIRC)
221  LircDevice = LIRC_DEVICE;
222 #endif
223 #if defined(VDR_USER)
224  VdrUser = VDR_USER;
225 #endif
226 
227  SetVideoDirectory(VideoDirectory);
228  cPluginManager PluginManager(DEFAULTPLUGINDIR);
229 
230  static struct option long_options[] = {
231  { "audio", required_argument, NULL, 'a' },
232  { "cachedir", required_argument, NULL, 'c' | 0x100 },
233  { "config", required_argument, NULL, 'c' },
234  { "daemon", no_argument, NULL, 'd' },
235  { "device", required_argument, NULL, 'D' },
236  { "dirnames", required_argument, NULL, 'd' | 0x100 },
237  { "edit", required_argument, NULL, 'e' | 0x100 },
238  { "epgfile", required_argument, NULL, 'E' },
239  { "filesize", required_argument, NULL, 'f' | 0x100 },
240  { "genindex", required_argument, NULL, 'g' | 0x100 },
241  { "grab", required_argument, NULL, 'g' },
242  { "help", no_argument, NULL, 'h' },
243  { "instance", required_argument, NULL, 'i' },
244  { "lib", required_argument, NULL, 'L' },
245  { "lirc", optional_argument, NULL, 'l' | 0x100 },
246  { "localedir",required_argument, NULL, 'l' | 0x200 },
247  { "log", required_argument, NULL, 'l' },
248  { "mute", no_argument, NULL, 'm' },
249  { "no-kbd", no_argument, NULL, 'n' | 0x100 },
250  { "plugin", required_argument, NULL, 'P' },
251  { "port", required_argument, NULL, 'p' },
252  { "record", required_argument, NULL, 'r' },
253  { "resdir", required_argument, NULL, 'r' | 0x100 },
254  { "shutdown", required_argument, NULL, 's' },
255  { "split", no_argument, NULL, 's' | 0x100 },
256  { "terminal", required_argument, NULL, 't' },
257  { "user", required_argument, NULL, 'u' },
258  { "userdump", no_argument, NULL, 'u' | 0x100 },
259  { "version", no_argument, NULL, 'V' },
260  { "vfat", no_argument, NULL, 'v' | 0x100 },
261  { "video", required_argument, NULL, 'v' },
262  { "watchdog", required_argument, NULL, 'w' },
263  { NULL, no_argument, NULL, 0 }
264  };
265 
266  int c;
267  while ((c = getopt_long(argc, argv, "a:c:dD:e:E:g:hi:l:L:mp:P:r:s:t:u:v:Vw:", long_options, NULL)) != -1) {
268  switch (c) {
269  case 'a': AudioCommand = optarg;
270  break;
271  case 'c' | 0x100:
272  CacheDirectory = optarg;
273  break;
274  case 'c': ConfigDirectory = optarg;
275  break;
276  case 'd': DaemonMode = true;
277  break;
278  case 'D': if (isnumber(optarg)) {
279  int n = atoi(optarg);
280  if (0 <= n && n < MAXDEVICES) {
282  break;
283  }
284  }
285  fprintf(stderr, "vdr: invalid DVB device number: %s\n", optarg);
286  return 2;
287  case 'd' | 0x100: {
288  char *s = optarg;
289  if (*s != ',') {
290  int n = strtol(s, &s, 10);
291  if (n <= 0 || n >= PATH_MAX) { // PATH_MAX includes the terminating 0
292  fprintf(stderr, "vdr: invalid directory path length: %s\n", optarg);
293  return 2;
294  }
295  DirectoryPathMax = n;
296  if (!*s)
297  break;
298  if (*s != ',') {
299  fprintf(stderr, "vdr: invalid delimiter: %s\n", optarg);
300  return 2;
301  }
302  }
303  s++;
304  if (!*s)
305  break;
306  if (*s != ',') {
307  int n = strtol(s, &s, 10);
308  if (n <= 0 || n > NAME_MAX) { // NAME_MAX excludes the terminating 0
309  fprintf(stderr, "vdr: invalid directory name length: %s\n", optarg);
310  return 2;
311  }
312  DirectoryNameMax = n;
313  if (!*s)
314  break;
315  if (*s != ',') {
316  fprintf(stderr, "vdr: invalid delimiter: %s\n", optarg);
317  return 2;
318  }
319  }
320  s++;
321  if (!*s)
322  break;
323  int n = strtol(s, &s, 10);
324  if (n != 0 && n != 1) {
325  fprintf(stderr, "vdr: invalid directory encoding: %s\n", optarg);
326  return 2;
327  }
328  DirectoryEncoding = n;
329  if (*s) {
330  fprintf(stderr, "vdr: unexpected data: %s\n", optarg);
331  return 2;
332  }
333  }
334  break;
335  case 'e' | 0x100:
336  return CutRecording(optarg) ? 0 : 2;
337  case 'E': EpgDataFileName = (*optarg != '-' ? optarg : NULL);
338  break;
339  case 'f' | 0x100:
340  Setup.MaxVideoFileSize = StrToNum(optarg) / MEGABYTE(1);
345  break;
346  case 'g' | 0x100:
347  return GenerateIndex(optarg) ? 0 : 2;
348  case 'g': cSVDRP::SetGrabImageDir(*optarg != '-' ? optarg : NULL);
349  break;
350  case 'h': DisplayHelp = true;
351  break;
352  case 'i': if (isnumber(optarg)) {
353  InstanceId = atoi(optarg);
354  if (InstanceId >= 0)
355  break;
356  }
357  fprintf(stderr, "vdr: invalid instance id: %s\n", optarg);
358  return 2;
359  case 'l': {
360  char *p = strchr(optarg, '.');
361  if (p)
362  *p = 0;
363  if (isnumber(optarg)) {
364  int l = atoi(optarg);
365  if (0 <= l && l <= 3) {
366  SysLogLevel = l;
367  if (!p)
368  break;
369  if (isnumber(p + 1)) {
370  int l = atoi(p + 1);
371  if (0 <= l && l <= 7) {
372  int targets[] = { LOG_LOCAL0, LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7 };
373  SysLogTarget = targets[l];
374  break;
375  }
376  }
377  }
378  }
379  if (p)
380  *p = '.';
381  fprintf(stderr, "vdr: invalid log level: %s\n", optarg);
382  return 2;
383  }
384  case 'L': if (access(optarg, R_OK | X_OK) == 0)
385  PluginManager.SetDirectory(optarg);
386  else {
387  fprintf(stderr, "vdr: can't access plugin directory: %s\n", optarg);
388  return 2;
389  }
390  break;
391  case 'l' | 0x100:
392  LircDevice = optarg ? optarg : LIRC_DEVICE;
393  break;
394  case 'l' | 0x200:
395  if (access(optarg, R_OK | X_OK) == 0)
396  LocaleDirectory = optarg;
397  else {
398  fprintf(stderr, "vdr: can't access locale directory: %s\n", optarg);
399  return 2;
400  }
401  break;
402  case 'm': MuteAudio = true;
403  break;
404  case 'n' | 0x100:
405  UseKbd = false;
406  break;
407  case 'p': if (isnumber(optarg))
408  SVDRPport = atoi(optarg);
409  else {
410  fprintf(stderr, "vdr: invalid port number: %s\n", optarg);
411  return 2;
412  }
413  break;
414  case 'P': PluginManager.AddPlugin(optarg);
415  break;
416  case 'r': cRecordingUserCommand::SetCommand(optarg);
417  break;
418  case 'r' | 0x100:
419  ResourceDirectory = optarg;
420  break;
421  case 's': ShutdownHandler.SetShutdownCommand(optarg);
422  break;
423  case 's' | 0x100:
425  break;
426  case 't': Terminal = optarg;
427  if (access(Terminal, R_OK | W_OK) < 0) {
428  fprintf(stderr, "vdr: can't access terminal: %s\n", Terminal);
429  return 2;
430  }
431  break;
432  case 'u': if (*optarg)
433  VdrUser = optarg;
434  break;
435  case 'u' | 0x100:
436  UserDump = true;
437  break;
438  case 'V': DisplayVersion = true;
439  break;
440  case 'v' | 0x100:
441  DirectoryPathMax = 250;
442  DirectoryNameMax = 40;
443  DirectoryEncoding = true;
444  break;
445  case 'v': VideoDirectory = optarg;
446  while (optarg && *optarg && optarg[strlen(optarg) - 1] == '/')
447  optarg[strlen(optarg) - 1] = 0;
448  SetVideoDirectory(VideoDirectory);
449  break;
450  case 'w': if (isnumber(optarg)) {
451  int t = atoi(optarg);
452  if (t >= 0) {
453  WatchdogTimeout = t;
454  break;
455  }
456  }
457  fprintf(stderr, "vdr: invalid watchdog timeout: %s\n", optarg);
458  return 2;
459  default: return 2;
460  }
461  }
462 
463  // Set user id in case we were started as root:
464 
465  if (VdrUser && geteuid() == 0) {
466  StartedAsRoot = true;
467  if (strcmp(VdrUser, "root")) {
468  if (!SetKeepCaps(true))
469  return 2;
470  if (!SetUser(VdrUser, UserDump))
471  return 2;
472  if (!SetKeepCaps(false))
473  return 2;
474  if (!DropCaps())
475  return 2;
476  }
477  }
478 
479  // Help and version info:
480 
481  if (DisplayHelp || DisplayVersion) {
482  if (!PluginManager.HasPlugins())
483  PluginManager.AddPlugin("*"); // adds all available plugins
484  PluginManager.LoadPlugins();
485  if (DisplayHelp) {
486  printf("Usage: vdr [OPTIONS]\n\n" // for easier orientation, this is column 80|
487  " -a CMD, --audio=CMD send Dolby Digital audio to stdin of command CMD\n"
488  " --cachedir=DIR save cache files in DIR (default: %s)\n"
489  " -c DIR, --config=DIR read config files from DIR (default: %s)\n"
490  " -d, --daemon run in daemon mode\n"
491  " -D NUM, --device=NUM use only the given DVB device (NUM = 0, 1, 2...)\n"
492  " there may be several -D options (default: all DVB\n"
493  " devices will be used)\n"
494  " --dirnames=PATH[,NAME[,ENC]]\n"
495  " set the maximum directory path length to PATH\n"
496  " (default: %d); if NAME is also given, it defines\n"
497  " the maximum directory name length (default: %d);\n"
498  " the optional ENC can be 0 or 1, and controls whether\n"
499  " special characters in directory names are encoded as\n"
500  " hex values (default: 0); if PATH or NAME are left\n"
501  " empty (as in \",,1\" to only set ENC), the defaults\n"
502  " apply\n"
503  " --edit=REC cut recording REC and exit\n"
504  " -E FILE, --epgfile=FILE write the EPG data into the given FILE (default is\n"
505  " '%s' in the cache directory)\n"
506  " '-E-' disables this\n"
507  " if FILE is a directory, the default EPG file will be\n"
508  " created in that directory\n"
509  " --filesize=SIZE limit video files to SIZE bytes (default is %dM)\n"
510  " only useful in conjunction with --edit\n"
511  " --genindex=REC generate index for recording REC and exit\n"
512  " -g DIR, --grab=DIR write images from the SVDRP command GRAB into the\n"
513  " given DIR; DIR must be the full path name of an\n"
514  " existing directory, without any \"..\", double '/'\n"
515  " or symlinks (default: none, same as -g-)\n"
516  " -h, --help print this help and exit\n"
517  " -i ID, --instance=ID use ID as the id of this VDR instance (default: 0)\n"
518  " -l LEVEL, --log=LEVEL set log level (default: 3)\n"
519  " 0 = no logging, 1 = errors only,\n"
520  " 2 = errors and info, 3 = errors, info and debug\n"
521  " if logging should be done to LOG_LOCALn instead of\n"
522  " LOG_USER, add '.n' to LEVEL, as in 3.7 (n=0..7)\n"
523  " -L DIR, --lib=DIR search for plugins in DIR (default is %s)\n"
524  " --lirc[=PATH] use a LIRC remote control device, attached to PATH\n"
525  " (default: %s)\n"
526  " --localedir=DIR search for locale files in DIR (default is\n"
527  " %s)\n"
528  " -m, --mute mute audio of the primary DVB device at startup\n"
529  " --no-kbd don't use the keyboard as an input device\n"
530  " -p PORT, --port=PORT use PORT for SVDRP (default: %d)\n"
531  " 0 turns off SVDRP\n"
532  " -P OPT, --plugin=OPT load a plugin defined by the given options\n"
533  " -r CMD, --record=CMD call CMD before and after a recording, and after\n"
534  " a recording has been edited or deleted\n"
535  " --resdir=DIR read resource files from DIR (default: %s)\n"
536  " -s CMD, --shutdown=CMD call CMD to shutdown the computer\n"
537  " --split split edited files at the editing marks (only\n"
538  " useful in conjunction with --edit)\n"
539  " -t TTY, --terminal=TTY controlling tty\n"
540  " -u USER, --user=USER run as user USER; only applicable if started as\n"
541  " root\n"
542  " --userdump allow coredumps if -u is given (debugging)\n"
543  " -v DIR, --video=DIR use DIR as video directory (default: %s)\n"
544  " -V, --version print version information and exit\n"
545  " --vfat for backwards compatibility (same as\n"
546  " --dirnames=250,40,1)\n"
547  " -w SEC, --watchdog=SEC activate the watchdog timer with a timeout of SEC\n"
548  " seconds (default: %d); '0' disables the watchdog\n"
549  "\n",
552  PATH_MAX - 1,
553  NAME_MAX,
557  LIRC_DEVICE,
563  );
564  }
565  if (DisplayVersion)
566  printf("vdr (%s/%s) - The Video Disk Recorder\n", VDRVERSION, APIVERSION);
567  if (PluginManager.HasPlugins()) {
568  if (DisplayHelp)
569  printf("Plugins: vdr -P\"name [OPTIONS]\"\n\n");
570  for (int i = 0; ; i++) {
571  cPlugin *p = PluginManager.GetPlugin(i);
572  if (p) {
573  const char *help = p->CommandLineHelp();
574  printf("%s (%s) - %s\n", p->Name(), p->Version(), p->Description());
575  if (DisplayHelp && help) {
576  printf("\n");
577  puts(help);
578  }
579  }
580  else
581  break;
582  }
583  }
584  return 0;
585  }
586 
587  // Log file:
588 
589  if (SysLogLevel > 0)
590  openlog("vdr", LOG_CONS, SysLogTarget); // LOG_PID doesn't work as expected under NPTL
591 
592  // Check the video directory:
593 
594  if (!DirectoryOk(VideoDirectory, true)) {
595  fprintf(stderr, "vdr: can't access video directory %s\n", VideoDirectory);
596  return 2;
597  }
598 
599  // Daemon mode:
600 
601  if (DaemonMode) {
602  if (daemon(1, 0) == -1) {
603  fprintf(stderr, "vdr: %m\n");
604  esyslog("ERROR: %m");
605  return 2;
606  }
607  }
608  else if (Terminal) {
609  // Claim new controlling terminal
610  stdin = freopen(Terminal, "r", stdin);
611  stdout = freopen(Terminal, "w", stdout);
612  stderr = freopen(Terminal, "w", stderr);
613  HasStdin = true;
614  tcgetattr(STDIN_FILENO, &savedTm);
615  }
616 
617  isyslog("VDR version %s started", VDRVERSION);
618  if (StartedAsRoot && VdrUser)
619  isyslog("switched to user '%s'", VdrUser);
620  if (DaemonMode)
621  dsyslog("running as daemon (tid=%d)", cThread::ThreadId());
623 
624  // Set the system character table:
625 
626  char *CodeSet = NULL;
627  if (setlocale(LC_CTYPE, ""))
628  CodeSet = nl_langinfo(CODESET);
629  else {
630  char *LangEnv = getenv("LANG"); // last resort in case locale stuff isn't installed
631  if (LangEnv) {
632  CodeSet = strchr(LangEnv, '.');
633  if (CodeSet)
634  CodeSet++; // skip the dot
635  }
636  }
637  if (CodeSet) {
638  bool known = SI::SetSystemCharacterTable(CodeSet);
639  isyslog("codeset is '%s' - %s", CodeSet, known ? "known" : "unknown");
641  }
642 
643  // Initialize internationalization:
644 
645  I18nInitialize(LocaleDirectory);
646 
647  // Main program loop variables - need to be here to have them initialized before any EXIT():
648 
649  cEpgDataReader EpgDataReader;
650  cOsdObject *Menu = NULL;
651  int LastChannel = 0;
652  int LastTimerChannel = -1;
653  int PreviousChannel[2] = { 1, 1 };
654  int PreviousChannelIndex = 0;
655  time_t LastChannelChanged = time(NULL);
656  time_t LastInteract = 0;
657  int MaxLatencyTime = 0;
658  bool InhibitEpgScan = false;
659  bool IsInfoMenu = false;
660  cSkin *CurrentSkin = NULL;
661 
662  // Load plugins:
663 
664  if (!PluginManager.LoadPlugins(true))
665  EXIT(2);
666 
667  // Directories:
668 
669  if (!ConfigDirectory)
670  ConfigDirectory = DEFAULTCONFDIR;
671  cPlugin::SetConfigDirectory(ConfigDirectory);
672  if (!CacheDirectory)
673  CacheDirectory = DEFAULTCACHEDIR;
674  cPlugin::SetCacheDirectory(CacheDirectory);
675  if (!ResourceDirectory)
676  ResourceDirectory = DEFAULTRESDIR;
677  cPlugin::SetResourceDirectory(ResourceDirectory);
678  cThemes::SetThemesDirectory("/var/lib/vdr/data/themes");
679 
680  // Configuration data:
681 
682  Setup.Load(AddDirectory(ConfigDirectory, "setup.conf"));
683  Sources.Load(AddDirectory(ConfigDirectory, "sources.conf"), true, true);
684  Diseqcs.Load(AddDirectory(ConfigDirectory, "diseqc.conf"), true, Setup.DiSEqC);
685  Scrs.Load(AddDirectory(ConfigDirectory, "scr.conf"), true);
686  Channels.Load(AddDirectory(ConfigDirectory, "channels.conf"), false, true);
687  Timers.Load(AddDirectory(ConfigDirectory, "timers.conf"));
688  Commands.Load(AddDirectory(ConfigDirectory, "commands.conf"));
689  RecordingCommands.Load(AddDirectory(ConfigDirectory, "reccmds.conf"));
690  TimerCommands.Load(AddDirectory(ConfigDirectory, "timercmds.conf"));
691  SVDRPhosts.Load(AddDirectory(ConfigDirectory, "svdrphosts.conf"), true);
692  Keys.Load(AddDirectory(ConfigDirectory, "remote.conf"));
693  KeyMacros.Load(AddDirectory(ConfigDirectory, "keymacros.conf"), true);
694  Folders.Load(AddDirectory(ConfigDirectory, "folders.conf"));
695 
697  const char *msg = "no fonts available - OSD will not show any text!";
698  fprintf(stderr, "vdr: %s\n", msg);
699  esyslog("ERROR: %s", msg);
700  }
701 
702  // Recordings:
703 
704  Recordings.Update();
706 
707  // EPG data:
708 
709  if (EpgDataFileName) {
710  const char *EpgDirectory = NULL;
711  if (DirectoryOk(EpgDataFileName)) {
712  EpgDirectory = EpgDataFileName;
713  EpgDataFileName = DEFAULTEPGDATAFILENAME;
714  }
715  else if (*EpgDataFileName != '/' && *EpgDataFileName != '.')
716  EpgDirectory = CacheDirectory;
717  if (EpgDirectory)
718  cSchedules::SetEpgDataFileName(AddDirectory(EpgDirectory, EpgDataFileName));
719  else
720  cSchedules::SetEpgDataFileName(EpgDataFileName);
721  EpgDataReader.Start();
722  }
723 
724  // DVB interfaces:
725 
728 
729  // Initialize plugins:
730 
731  if (!PluginManager.InitializePlugins())
732  EXIT(2);
733 
734  // Primary device:
735 
737  if (!cDevice::PrimaryDevice() || !cDevice::PrimaryDevice()->HasDecoder()) {
738  if (cDevice::PrimaryDevice() && !cDevice::PrimaryDevice()->HasDecoder())
739  isyslog("device %d has no MPEG decoder", cDevice::PrimaryDevice()->DeviceNumber() + 1);
740  for (int i = 0; i < cDevice::NumDevices(); i++) {
741  cDevice *d = cDevice::GetDevice(i);
742  if (d && d->HasDecoder()) {
743  isyslog("trying device number %d instead", i + 1);
744  if (cDevice::SetPrimaryDevice(i + 1)) {
745  Setup.PrimaryDVB = i + 1;
746  break;
747  }
748  }
749  }
750  if (!cDevice::PrimaryDevice()) {
751  const char *msg = "no primary device found - using first device!";
752  fprintf(stderr, "vdr: %s\n", msg);
753  esyslog("ERROR: %s", msg);
755  EXIT(2);
756  if (!cDevice::PrimaryDevice()) {
757  const char *msg = "no primary device found - giving up!";
758  fprintf(stderr, "vdr: %s\n", msg);
759  esyslog("ERROR: %s", msg);
760  EXIT(2);
761  }
762  }
763  }
764 
765  // Check for timers in automatic start time window:
766 
768 
769  // User interface:
770 
771  Interface = new cInterface(SVDRPport);
772 
773  // Default skins:
774 
775  new cSkinLCARS;
776  new cSkinSTTNG;
777  new cSkinClassic;
780  CurrentSkin = Skins.Current();
781 
782  // Start plugins:
783 
784  if (!PluginManager.StartPlugins())
785  EXIT(2);
786 
787  // Set skin and theme in case they're implemented by a plugin:
788 
789  if (!CurrentSkin || CurrentSkin == Skins.Current() && strcmp(Skins.Current()->Name(), Setup.OSDSkin) != 0) {
792  }
793 
794  // Remote Controls:
795  if (LircDevice)
796  new cLircRemote(LircDevice);
797  if (!DaemonMode && HasStdin && UseKbd)
798  new cKbdRemote;
799  Interface->LearnKeys();
800 
801  // External audio:
802 
803  if (AudioCommand)
804  new cExternalAudio(AudioCommand);
805 
806  // Channel:
807 
809  dsyslog("not all devices ready after %d seconds", DEVICEREADYTIMEOUT);
810  if (*Setup.InitialChannel) {
811  if (isnumber(Setup.InitialChannel)) { // for compatibility with old setup.conf files
812  if (cChannel *Channel = Channels.GetByNumber(atoi(Setup.InitialChannel)))
813  Setup.InitialChannel = Channel->GetChannelID().ToString();
814  }
816  Setup.CurrentChannel = Channel->Number();
817  }
818  if (Setup.InitialVolume >= 0)
821  if (MuteAudio)
823  else
825 
826  // Signal handlers:
827 
828  if (signal(SIGHUP, SignalHandler) == SIG_IGN) signal(SIGHUP, SIG_IGN);
829  if (signal(SIGINT, SignalHandler) == SIG_IGN) signal(SIGINT, SIG_IGN);
830  if (signal(SIGTERM, SignalHandler) == SIG_IGN) signal(SIGTERM, SIG_IGN);
831  if (signal(SIGPIPE, SignalHandler) == SIG_IGN) signal(SIGPIPE, SIG_IGN);
832  if (WatchdogTimeout > 0)
833  if (signal(SIGALRM, Watchdog) == SIG_IGN) signal(SIGALRM, SIG_IGN);
834 
835  // Watchdog:
836 
837  if (WatchdogTimeout > 0) {
838  dsyslog("setting watchdog timer to %d seconds", WatchdogTimeout);
839  alarm(WatchdogTimeout); // Initial watchdog timer start
840  }
841 
842  // Main program loop:
843 
844 #define DELETE_MENU ((IsInfoMenu &= (Menu == NULL)), delete Menu, Menu = NULL)
845 
846  while (!ShutdownHandler.DoExit()) {
847 #ifdef DEBUGRINGBUFFERS
848  cRingBufferLinear::PrintDebugRBL();
849 #endif
850  // Attach launched player control:
852 
853  time_t Now = time(NULL);
854 
855  // Make sure we have a visible programme in case device usage has changed:
857  static time_t lastTime = 0;
859  if (!CamMenuActive() && Now - lastTime > MINCHANNELWAIT) { // !CamMenuActive() to avoid interfering with the CAM if a CAM menu is open
861  if (Channel && (Channel->Vpid() || Channel->Apid(0) || Channel->Dpid(0))) {
862  if (cDevice::GetDeviceForTransponder(Channel, LIVEPRIORITY) && Channels.SwitchTo(Channel->Number())) // try to switch to the original channel...
863  ;
864  else if (LastTimerChannel > 0) {
865  Channel = Channels.GetByNumber(LastTimerChannel);
866  if (Channel && cDevice::GetDeviceForTransponder(Channel, LIVEPRIORITY) && Channels.SwitchTo(LastTimerChannel)) // ...or the one used by the last timer
867  ;
868  }
869  }
870  lastTime = Now; // don't do this too often
871  LastTimerChannel = -1;
872  }
873  }
874  else
875  lastTime = 0; // makes sure we immediately try again next time
876  }
877  // Update the OSD size:
878  {
879  static time_t lastOsdSizeUpdate = 0;
880  if (Now != lastOsdSizeUpdate) { // once per second
882  lastOsdSizeUpdate = Now;
883  }
884  }
885  // Restart the Watchdog timer:
886  if (WatchdogTimeout > 0) {
887  int LatencyTime = WatchdogTimeout - alarm(WatchdogTimeout);
888  if (LatencyTime > MaxLatencyTime) {
889  MaxLatencyTime = LatencyTime;
890  dsyslog("max. latency time %d seconds", MaxLatencyTime);
891  }
892  }
893  // Handle channel and timer modifications:
894  if (!Channels.BeingEdited() && !Timers.BeingEdited()) {
895  int modified = Channels.Modified();
896  static time_t ChannelSaveTimeout = 0;
897  static int TimerState = 0;
898  // Channels and timers need to be stored in a consistent manner,
899  // therefore if one of them is changed, we save both.
900  if (modified == CHANNELSMOD_USER || Timers.Modified(TimerState))
901  ChannelSaveTimeout = 1; // triggers an immediate save
902  else if (modified && !ChannelSaveTimeout)
903  ChannelSaveTimeout = Now + CHANNELSAVEDELTA;
904  bool timeout = ChannelSaveTimeout == 1 || ChannelSaveTimeout && Now > ChannelSaveTimeout && !cRecordControls::Active();
905  if ((modified || timeout) && Channels.Lock(false, 100)) {
906  if (timeout) {
907  Channels.Save();
908  Timers.Save();
909  ChannelSaveTimeout = 0;
910  }
911  for (cChannel *Channel = Channels.First(); Channel; Channel = Channels.Next(Channel)) {
912  if (Channel->Modification(CHANNELMOD_RETUNE)) {
914  if (Channel->Number() == cDevice::CurrentChannel()) {
916  if (cDevice::ActualDevice()->ProvidesTransponder(Channel)) { // avoids retune on devices that don't really access the transponder
917  isyslog("retuning due to modification of channel %d", Channel->Number());
918  Channels.SwitchTo(Channel->Number());
919  }
920  }
921  }
922  }
923  }
924  Channels.Unlock();
925  }
926  }
927  // Channel display:
928  if (!EITScanner.Active() && cDevice::CurrentChannel() != LastChannel) {
929  if (!Menu)
930  Menu = new cDisplayChannel(cDevice::CurrentChannel(), LastChannel >= 0);
931  LastChannel = cDevice::CurrentChannel();
932  LastChannelChanged = Now;
933  }
934  if (Now - LastChannelChanged >= Setup.ZapTimeout && LastChannel != PreviousChannel[PreviousChannelIndex])
935  PreviousChannel[PreviousChannelIndex ^= 1] = LastChannel;
936  // Timers and Recordings:
937  if (!Timers.BeingEdited()) {
938  // Assign events to timers:
939  Timers.SetEvents();
940  // Must do all following calls with the exact same time!
941  // Process ongoing recordings:
943  // Start new recordings:
944  cTimer *Timer = Timers.GetMatch(Now);
945  if (Timer) {
946  if (!cRecordControls::Start(Timer))
947  Timer->SetPending(true);
948  else
949  LastTimerChannel = Timer->Channel()->Number();
950  }
951  // Make sure timers "see" their channel early enough:
952  static time_t LastTimerCheck = 0;
953  if (Now - LastTimerCheck > TIMERCHECKDELTA) { // don't do this too often
954  InhibitEpgScan = false;
955  for (cTimer *Timer = Timers.First(); Timer; Timer = Timers.Next(Timer)) {
956  bool InVpsMargin = false;
957  bool NeedsTransponder = false;
958  if (Timer->HasFlags(tfActive) && !Timer->Recording()) {
959  if (Timer->HasFlags(tfVps)) {
960  if (Timer->Matches(Now, true, Setup.VpsMargin)) {
961  InVpsMargin = true;
962  Timer->SetInVpsMargin(InVpsMargin);
963  }
964  else if (Timer->Event()) {
965  InVpsMargin = Timer->Event()->StartTime() <= Now && Now < Timer->Event()->EndTime();
966  NeedsTransponder = Timer->Event()->StartTime() - Now < VPSLOOKAHEADTIME * 3600 && !Timer->Event()->SeenWithin(VPSUPTODATETIME);
967  }
968  else {
969  cSchedulesLock SchedulesLock;
970  const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock);
971  if (Schedules) {
972  const cSchedule *Schedule = Schedules->GetSchedule(Timer->Channel());
973  InVpsMargin = !Schedule; // we must make sure we have the schedule
974  NeedsTransponder = Schedule && !Schedule->PresentSeenWithin(VPSUPTODATETIME);
975  }
976  }
977  InhibitEpgScan |= InVpsMargin | NeedsTransponder;
978  }
979  else
980  NeedsTransponder = Timer->Matches(Now, true, TIMERLOOKAHEADTIME);
981  }
982  if (NeedsTransponder || InVpsMargin) {
983  // Find a device that provides the required transponder:
985  if (!Device && InVpsMargin)
987  // Switch the device to the transponder:
988  if (Device) {
989  bool HadProgramme = cDevice::PrimaryDevice()->HasProgramme();
990  if (!Device->IsTunedToTransponder(Timer->Channel())) {
991  if (Device == cDevice::ActualDevice() && !Device->IsPrimaryDevice())
992  cDevice::PrimaryDevice()->StopReplay(); // stop transfer mode
993  dsyslog("switching device %d to channel %d", Device->DeviceNumber() + 1, Timer->Channel()->Number());
994  if (Device->SwitchChannel(Timer->Channel(), false))
996  }
997  if (cDevice::PrimaryDevice()->HasDecoder() && HadProgramme && !cDevice::PrimaryDevice()->HasProgramme())
998  Skins.QueueMessage(mtInfo, tr("Upcoming recording!")); // the previous SwitchChannel() has switched away the current live channel
999  }
1000  }
1001  }
1002  LastTimerCheck = Now;
1003  }
1004  // Delete expired timers:
1006  }
1007  if (!Menu && Recordings.NeedsUpdate()) {
1008  Recordings.Update();
1010  }
1011  // CAM control:
1012  if (!Menu && !cOsd::IsOpen())
1013  Menu = CamControl();
1014  // Queued messages:
1015  if (!Skins.IsOpen())
1017  // User Input:
1018  cOsdObject *Interact = Menu ? Menu : cControl::Control();
1019  eKeys key = Interface->GetKey(!Interact || !Interact->NeedsFastResponse());
1020  if (ISREALKEY(key)) {
1021  EITScanner.Activity();
1022  // Cancel shutdown countdown:
1025  // Set user active for MinUserInactivity time in the future:
1027  }
1028  // Keys that must work independent of any interactive mode:
1029  switch (int(key)) {
1030  // Menu control:
1031  case kMenu: {
1032  key = kNone; // nobody else needs to see this key
1033  bool WasOpen = Interact != NULL;
1034  bool WasMenu = Interact && Interact->IsMenu();
1035  if (Menu)
1036  DELETE_MENU;
1037  else if (cControl::Control()) {
1038  if (cOsd::IsOpen())
1039  cControl::Control()->Hide();
1040  else
1041  WasOpen = false;
1042  }
1043  if (!WasOpen || !WasMenu && !Setup.MenuKeyCloses)
1044  Menu = new cMenuMain;
1045  }
1046  break;
1047  // Info:
1048  case kInfo: {
1049  if (IsInfoMenu) {
1050  key = kNone; // nobody else needs to see this key
1051  DELETE_MENU;
1052  }
1053  else if (!Menu) {
1054  IsInfoMenu = true;
1055  if (cControl::Control()) {
1056  cControl::Control()->Hide();
1057  Menu = cControl::Control()->GetInfo();
1058  if (Menu)
1059  Menu->Show();
1060  else
1061  IsInfoMenu = false;
1062  }
1063  else {
1064  cRemote::Put(kOk, true);
1065  cRemote::Put(kSchedule, true);
1066  }
1067  key = kNone; // nobody else needs to see this key
1068  }
1069  }
1070  break;
1071  // Direct main menu functions:
1072  #define DirectMainFunction(function)\
1073  { DELETE_MENU;\
1074  if (cControl::Control())\
1075  cControl::Control()->Hide();\
1076  Menu = new cMenuMain(function);\
1077  key = kNone; } // nobody else needs to see this key
1078  case kSchedule: DirectMainFunction(osSchedule); break;
1079  case kChannels: DirectMainFunction(osChannels); break;
1080  case kTimers: DirectMainFunction(osTimers); break;
1082  case kSetup: DirectMainFunction(osSetup); break;
1083  case kCommands: DirectMainFunction(osCommands); break;
1084  case kUser0 ... kUser9: cRemote::PutMacro(key); key = kNone; break;
1085  case k_Plugin: {
1086  const char *PluginName = cRemote::GetPlugin();
1087  if (PluginName) {
1088  DELETE_MENU;
1089  if (cControl::Control())
1090  cControl::Control()->Hide();
1091  cPlugin *plugin = cPluginManager::GetPlugin(PluginName);
1092  if (plugin) {
1093  Menu = plugin->MainMenuAction();
1094  if (Menu)
1095  Menu->Show();
1096  }
1097  else
1098  esyslog("ERROR: unknown plugin '%s'", PluginName);
1099  }
1100  key = kNone; // nobody else needs to see these keys
1101  }
1102  break;
1103  // Channel up/down:
1104  case kChanUp|k_Repeat:
1105  case kChanUp:
1106  case kChanDn|k_Repeat:
1107  case kChanDn:
1108  if (!Interact)
1109  Menu = new cDisplayChannel(NORMALKEY(key));
1110  else if (cDisplayChannel::IsOpen() || cControl::Control()) {
1111  Interact->ProcessKey(key);
1112  continue;
1113  }
1114  else
1115  cDevice::SwitchChannel(NORMALKEY(key) == kChanUp ? 1 : -1);
1116  key = kNone; // nobody else needs to see these keys
1117  break;
1118  // Volume control:
1119  case kVolUp|k_Repeat:
1120  case kVolUp:
1121  case kVolDn|k_Repeat:
1122  case kVolDn:
1123  case kMute:
1124  if (key == kMute) {
1125  if (!cDevice::PrimaryDevice()->ToggleMute() && !Menu) {
1126  key = kNone; // nobody else needs to see these keys
1127  break; // no need to display "mute off"
1128  }
1129  }
1130  else
1132  if (!Menu && !cOsd::IsOpen())
1133  Menu = cDisplayVolume::Create();
1135  key = kNone; // nobody else needs to see these keys
1136  break;
1137  // Audio track control:
1138  case kAudio:
1139  if (cControl::Control())
1140  cControl::Control()->Hide();
1141  if (!cDisplayTracks::IsOpen()) {
1142  DELETE_MENU;
1143  Menu = cDisplayTracks::Create();
1144  }
1145  else
1147  key = kNone;
1148  break;
1149  // Subtitle track control:
1150  case kSubtitles:
1151  if (cControl::Control())
1152  cControl::Control()->Hide();
1154  DELETE_MENU;
1156  }
1157  else
1159  key = kNone;
1160  break;
1161  // Pausing live video:
1162  case kPlayPause:
1163  case kPause:
1164  if (!cControl::Control()) {
1165  DELETE_MENU;
1166  if (Setup.PauseKeyHandling) {
1167  if (Setup.PauseKeyHandling > 1 || Interface->Confirm(tr("Pause live video?"))) {
1169  Skins.QueueMessage(mtError, tr("No free DVB device to record!"));
1170  }
1171  }
1172  key = kNone; // nobody else needs to see this key
1173  }
1174  break;
1175  // Instant recording:
1176  case kRecord:
1177  if (!cControl::Control()) {
1178  if (cRecordControls::Start())
1179  Skins.QueueMessage(mtInfo, tr("Recording started"));
1180  key = kNone; // nobody else needs to see this key
1181  }
1182  break;
1183  // Power off:
1184  case kPower:
1185  isyslog("Power button pressed");
1186  DELETE_MENU;
1187  // Check for activity, request power button again if active:
1188  if (!ShutdownHandler.ConfirmShutdown(false) && Skins.Message(mtWarning, tr("VDR will shut down later - press Power to force"), SHUTDOWNFORCEPROMPT) != kPower) {
1189  // Not pressed power - set VDR to be non-interactive and power down later:
1191  break;
1192  }
1193  // No activity or power button pressed twice - ask for confirmation:
1194  if (!ShutdownHandler.ConfirmShutdown(true)) {
1195  // Non-confirmed background activity - set VDR to be non-interactive and power down later:
1197  break;
1198  }
1199  // Ask the final question:
1200  if (!Interface->Confirm(tr("Press any key to cancel shutdown"), SHUTDOWNCANCELPROMPT, true))
1201  // If final question was canceled, continue to be active:
1202  break;
1203  // Ok, now call the shutdown script:
1205  // Set VDR to be non-interactive and power down again later:
1207  // Do not attempt to automatically shut down for a while:
1209  break;
1210  default: break;
1211  }
1212  Interact = Menu ? Menu : cControl::Control(); // might have been closed in the mean time
1213  if (Interact) {
1214  LastInteract = Now;
1215  eOSState state = Interact->ProcessKey(key);
1216  if (state == osUnknown && Interact != cControl::Control()) {
1217  if (ISMODELESSKEY(key) && cControl::Control()) {
1218  state = cControl::Control()->ProcessKey(key);
1219  if (state == osEnd) {
1220  // let's not close a menu when replay ends:
1222  continue;
1223  }
1224  }
1225  else if (Now - cRemote::LastActivity() > MENUTIMEOUT)
1226  state = osEnd;
1227  }
1228  switch (state) {
1229  case osPause: DELETE_MENU;
1231  Skins.QueueMessage(mtError, tr("No free DVB device to record!"));
1232  break;
1233  case osRecord: DELETE_MENU;
1234  if (cRecordControls::Start())
1235  Skins.QueueMessage(mtInfo, tr("Recording started"));
1236  break;
1237  case osRecordings:
1238  DELETE_MENU;
1240  Menu = new cMenuMain(osRecordings, true);
1241  break;
1242  case osReplay: DELETE_MENU;
1245  break;
1246  case osStopReplay:
1247  DELETE_MENU;
1249  break;
1250  case osSwitchDvb:
1251  DELETE_MENU;
1253  Skins.QueueMessage(mtInfo, tr("Switching primary DVB..."));
1255  break;
1256  case osPlugin: DELETE_MENU;
1257  Menu = cMenuMain::PluginOsdObject();
1258  if (Menu)
1259  Menu->Show();
1260  break;
1261  case osBack:
1262  case osEnd: if (Interact == Menu)
1263  DELETE_MENU;
1264  else
1266  break;
1267  default: ;
1268  }
1269  }
1270  else {
1271  // Key functions in "normal" viewing mode:
1272  if (key != kNone && KeyMacros.Get(key)) {
1273  cRemote::PutMacro(key);
1274  key = kNone;
1275  }
1276  switch (int(key)) {
1277  // Toggle channels:
1278  case kChanPrev:
1279  case k0: {
1280  if (PreviousChannel[PreviousChannelIndex ^ 1] == LastChannel || LastChannel != PreviousChannel[0] && LastChannel != PreviousChannel[1])
1281  PreviousChannelIndex ^= 1;
1282  Channels.SwitchTo(PreviousChannel[PreviousChannelIndex ^= 1]);
1283  break;
1284  }
1285  // Direct Channel Select:
1286  case k1 ... k9:
1287  // Left/Right rotates through channel groups:
1288  case kLeft|k_Repeat:
1289  case kLeft:
1290  case kRight|k_Repeat:
1291  case kRight:
1292  // Previous/Next rotates through channel groups:
1293  case kPrev|k_Repeat:
1294  case kPrev:
1295  case kNext|k_Repeat:
1296  case kNext:
1297  // Up/Down Channel Select:
1298  case kUp|k_Repeat:
1299  case kUp:
1300  case kDown|k_Repeat:
1301  case kDown:
1302  Menu = new cDisplayChannel(NORMALKEY(key));
1303  break;
1304  // Viewing Control:
1305  case kOk: LastChannel = -1; break; // forces channel display
1306  // Instant resume of the last viewed recording:
1307  case kPlay:
1311  }
1312  else
1313  DirectMainFunction(osRecordings); // no last viewed recording, so enter the Recordings menu
1314  break;
1315  default: break;
1316  }
1317  }
1318  if (!Menu) {
1319  if (!InhibitEpgScan)
1320  EITScanner.Process();
1321  if (!cCutter::Active() && cCutter::Ended()) {
1322  if (cCutter::Error())
1323  Skins.Message(mtError, tr("Editing process failed!"));
1324  else
1325  Skins.Message(mtInfo, tr("Editing process finished"));
1326  }
1328  if (cFileTransfer::Error())
1329  Skins.Message(mtError, tr("File transfer failed!"));
1330  else
1331  Skins.Message(mtInfo, tr("File transfer finished"));
1332  }
1333  }
1334 
1335  // SIGHUP shall cause a restart:
1336  if (LastSignal == SIGHUP) {
1337  if (ShutdownHandler.ConfirmRestart(true) && Interface->Confirm(tr("Press any key to cancel restart"), RESTARTCANCELPROMPT, true))
1338  EXIT(1);
1339  LastSignal = 0;
1340  }
1341 
1342  // Update the shutdown countdown:
1344  if (!ShutdownHandler.ConfirmShutdown(false))
1346  }
1347 
1349  // Handle housekeeping tasks
1350 
1351  // Shutdown:
1352  // Check whether VDR will be ready for shutdown in SHUTDOWNWAIT seconds:
1353  time_t Soon = Now + SHUTDOWNWAIT;
1355  if (ShutdownHandler.ConfirmShutdown(false))
1356  // Time to shut down - start final countdown:
1357  ShutdownHandler.countdown.Start(tr("VDR will shut down in %s minutes"), SHUTDOWNWAIT); // the placeholder is really %s!
1358  // Dont try to shut down again for a while:
1360  }
1361  // Countdown run down to 0?
1362  if (ShutdownHandler.countdown.Done()) {
1363  // Timed out, now do a final check:
1365  ShutdownHandler.DoShutdown(false);
1366  // Do this again a bit later:
1368  }
1369 
1370  // Disk housekeeping:
1374  // Plugins housekeeping:
1375  PluginManager.Housekeeping();
1376  }
1377 
1379 
1380  // Main thread hooks of plugins:
1381  PluginManager.MainThreadHook();
1382  }
1383 
1385  esyslog("emergency exit requested - shutting down");
1386 
1387 Exit:
1388 
1389  // Reset all signal handlers to default before Interface gets deleted:
1390  signal(SIGHUP, SIG_DFL);
1391  signal(SIGINT, SIG_DFL);
1392  signal(SIGTERM, SIG_DFL);
1393  signal(SIGPIPE, SIG_DFL);
1394  signal(SIGALRM, SIG_DFL);
1395 
1396  PluginManager.StopPlugins();
1399  cCutter::Stop();
1400  delete Menu;
1402  delete Interface;
1404  Remotes.Clear();
1405  Audios.Clear();
1406  Skins.Clear();
1407  SourceParams.Clear();
1408  if (ShutdownHandler.GetExitCode() != 2) {
1411  Setup.Save();
1412  }
1414  EpgHandlers.Clear();
1415  PluginManager.Shutdown(true);
1416  cSchedules::Cleanup(true);
1417  ReportEpgBugFixStats(true);
1418  if (WatchdogTimeout > 0)
1419  dsyslog("max. latency time %d seconds", MaxLatencyTime);
1420  if (LastSignal)
1421  isyslog("caught signal %d", LastSignal);
1423  esyslog("emergency exit!");
1424  isyslog("exiting, exit code %d", ShutdownHandler.GetExitCode());
1425  if (SysLogLevel > 0)
1426  closelog();
1427  if (HasStdin)
1428  tcsetattr(STDIN_FILENO, TCSANOW, &savedTm);
1429  return ShutdownHandler.GetExitCode();
1430 }
Definition: keys.h:29
cDiseqcs Diseqcs
Definition: diseqc.c:272
static void Watchdog(int signum)
Definition: vdr.c:164
void SetEvents(void)
Definition: timers.c:799
void ClearVanishedRecordings(void)
Definition: recording.c:222
bool Replaying(void) const
Returns true if we are currently replaying.
Definition: device.c:1209
int DeviceNumber(void) const
Returns the number of this device (0 ... numDevices).
Definition: device.c:160
#define MENUTIMEOUT
Definition: vdr.c:80
int Modified(void)
Returns 0 if no channels have been modified, 1 if an automatic modification has been made...
Definition: channels.c:1057
bool DirectoryEncoding
Definition: recording.c:71
int Vpid(void) const
Definition: channels.h:165
int Number(void) const
Definition: channels.h:191
bool Update(bool Wait=false)
Triggers an update of the list of recordings, which will run as a separate thread if Wait is false...
Definition: recording.c:1369
void SetOccupied(int Seconds)
Sets the occupied timeout for this device to the given number of Seconds, This can be used to tune a ...
Definition: device.c:839
cString DeviceBondings
Definition: config.h:347
Definition: keys.h:37
cChannels Channels
Definition: channels.c:845
int CurrentChannel
Definition: config.h:338
static void SetThemesDirectory(const char *ThemesDirectory)
Definition: themes.c:295
static tChannelID FromString(const char *s)
Definition: channels.c:25
bool ToggleMute(void)
Turns the volume off or on and returns the new mute state.
Definition: device.c:885
void CheckManualStart(int ManualStart)
Check whether the next timer is in ManualStart time window.
Definition: shutdown.c:108
#define dsyslog(a...)
Definition: tools.h:36
cString AddDirectory(const char *DirName, const char *FileName)
Definition: tools.c:301
#define TIMERDEVICETIMEOUT
Definition: vdr.c:82
bool isnumber(const char *s)
Definition: tools.c:263
#define SHUTDOWNFORCEPROMPT
Definition: vdr.c:74
Definition: keys.h:34
time_t EndTime(void) const
Definition: epg.h:107
bool Confirm(const char *s, int Seconds=10, bool WaitForTimeout=false)
Definition: interface.c:64
bool IsUserInactive(time_t AtTime=0)
Check whether VDR is in interactive mode or non-interactive mode (waiting for shutdown).
Definition: shutdown.h:72
cEpgHandlers EpgHandlers
Definition: epg.c:1381
static bool Initialize(void)
Initializes the DVB devices.
Definition: dvbdevice.c:1121
Definition: keys.h:23
bool LoadPlugins(bool Log=false)
Definition: plugin.c:354
#define CHANNELSAVEDELTA
Definition: vdr.c:78
bool Load(const char *SkinName)
Definition: themes.c:239
Definition: keys.h:19
virtual cOsdObject * GetInfo(void)
Returns an OSD object that displays information about the currently played programme.
Definition: player.c:58
cEITScanner EITScanner
Definition: eitscan.c:90
const char * Name(void)
Definition: plugin.h:34
void Shutdown(bool Log=false)
Definition: plugin.c:512
#define DEFAULTVIDEODIR
#define ISMODELESSKEY(k)
Definition: keys.h:78
bool DirectoryOk(const char *DirName, bool LogErrors)
Definition: tools.c:378
#define VPSLOOKAHEADTIME
Definition: vdr.c:84
Definition: keys.h:43
static void Shutdown(void)
Definition: menu.c:4894
virtual const char * Version(void)=0
int Dpid(int i) const
Definition: channels.h:172
static bool Error(void)
Definition: filetransfer.c:267
Definition: keys.h:39
cNestedItemList TimerCommands
Definition: config.c:277
static bool DropCaps(void)
Definition: vdr.c:121
Definition: keys.h:46
#define RESTARTCANCELPROMPT
Definition: vdr.c:76
void SetVideoDirectory(const char *Directory)
Definition: videodir.c:24
cTimers Timers
Definition: timers.c:694
void DeleteExpired(void)
Definition: timers.c:817
int ZapTimeout
Definition: config.h:290
int DirectoryNameMax
Definition: recording.c:70
const char * VideoDirectory
Definition: videodir.c:22
int QueueMessage(eMessageType Type, const char *s, int Seconds=0, int Timeout=0)
Like Message(), but this function may be called from a background thread.
Definition: skins.c:277
void ReportEpgBugFixStats(bool Force)
Definition: epg.c:585
virtual cOsdObject * MainMenuAction(void)
Definition: plugin.c:95
#define DEFAULTRESDIR
#define APIVERSION
Definition: config.h:30
static cDisplayVolume * Create(void)
Definition: menu.c:4325
void ProcessQueuedMessages(void)
Processes the first queued message, if any.
Definition: skins.c:333
Definition: plugin.h:20
Definition: keys.h:17
cTimer * GetMatch(time_t t)
Definition: timers.c:716
const cEvent * Event(void) const
Definition: timers.h:69
Definition: keys.h:61
#define MAXDEVICES
Definition: device.h:28
#define esyslog(a...)
Definition: tools.h:34
#define TIMERCHECKDELTA
Definition: vdr.c:81
static void ChannelDataModified(cChannel *Channel)
Definition: menu.c:4868
cNestedItemList Commands
Definition: config.c:275
bool Matches(time_t t=0, bool Directly=false, int Margin=0) const
Definition: timers.c:400
void SetUserInactive(void)
Set VDR manually into non-interactive mode from now on.
Definition: shutdown.h:86
static cDevice * GetDevice(int Index)
Gets the device with the given Index.
Definition: device.c:222
void SetInVpsMargin(bool InVpsMargin)
Definition: timers.c:600
static cControl * Control(bool Hidden=false)
Returns the current replay control (if any) in case it is currently visible.
Definition: player.c:73
static void Process(time_t t)
Definition: menu.c:4856
#define ISREALKEY(k)
Definition: keys.h:79
bool Save(void)
Definition: config.c:693
bool Load(const char *FileName=NULL, bool AllowComments=false, bool MustExist=false)
Definition: config.h:119
Definition: keys.h:49
static void Process(eKeys Key)
Definition: menu.c:4544
bool Update(void)
Update status display of the countdown.
Definition: shutdown.c:65
#define DEFAULTCACHEDIR
#define VDRVERSION
Definition: config.h:25
bool EmergencyExitRequested(void)
Returns true if an emergency exit was requested.
Definition: shutdown.h:61
static int NumDevices(void)
Returns the total number of devices.
Definition: device.h:113
void SetPending(bool Pending)
Definition: timers.c:595
bool DoShutdown(bool Force)
Call the shutdown script with data of the next pending timer.
Definition: shutdown.c:243
void Exit(int ExitCode)
Set VDR exit code and initiate end of VDR main loop.
Definition: shutdown.h:54
#define MINPRIORITY
Definition: config.h:40
bool InitializePlugins(void)
Definition: plugin.c:363
const char * Name(void)
Definition: skins.h:361
time_t StartTime(void) const
Definition: epg.h:106
int MenuKeyCloses
Definition: config.h:266
bool IsMenu(void) const
Definition: osdbase.h:82
cRemotes Remotes
Definition: remote.c:211
#define NORMALKEY(k)
Definition: keys.h:77
void MainThreadHook(void)
Definition: plugin.c:406
static bool SetKeepCaps(bool On)
Definition: vdr.c:138
#define DEFAULTSVDRPPORT
static void SetEpgDataFileName(const char *FileName)
Definition: epg.c:1206
bool PresentSeenWithin(int Seconds) const
Definition: epg.h:157
static void SetCommand(const char *Command)
Definition: recording.h:273
static const cSchedules * Schedules(cSchedulesLock &SchedulesLock)
Caller must provide a cSchedulesLock which has to survive the entire time the returned cSchedules is ...
Definition: epg.c:1201
#define MINCHANNELWAIT
Definition: vdr.c:70
int SysLogLevel
Definition: tools.c:31
cCountdown countdown
Definition: shutdown.h:51
Definition: keys.h:38
static bool IsOpen(void)
Definition: menu.h:166
cNestedItemList RecordingCommands
Definition: config.c:276
#define MAXVIDEOFILESIZEDEFAULT
Definition: recording.h:288
virtual void Clear(void)
Definition: tools.c:2018
const cChannel * Channel(void) const
Definition: timers.h:56
bool Load(const char *FileName, bool AllowComments=false, bool MustExist=false)
Definition: channels.c:874
static int CurrentVolume(void)
Definition: device.h:577
void Interrupt(void)
Definition: interface.h:27
Definition: keys.h:55
bool IsPrimaryDevice(void) const
Definition: device.h:199
Definition: keys.h:58
void Unlock(void)
Definition: thread.c:170
Definition: timers.h:27
#define TIMERLOOKAHEADTIME
Definition: vdr.c:83
virtual const char * Description(void)=0
bool GenerateIndex(const char *FileName)
Definition: recording.c:2199
#define SHUTDOWNWAIT
Definition: vdr.c:72
virtual const char * CommandLineHelp(void)
Definition: plugin.c:48
bool Transferring(void) const
Returns true if we are currently in Transfer Mode.
Definition: device.c:1214
eOSState
Definition: osdbase.h:18
void Start(const char *Message, int Seconds)
Start the 5 minute shutdown warning countdown.
Definition: shutdown.c:38
bool Active(void)
Definition: eitscan.h:33
bool Recording(void) const
Definition: timers.h:52
static int CurrentChannel(void)
Returns the number of the current channel on the primary device.
Definition: device.h:313
cSVDRPhosts SVDRPhosts
Definition: config.c:281
static bool PutMacro(eKeys Key)
Definition: remote.c:110
T * Next(const T *object) const
Definition: tools.h:485
int InitialVolume
Definition: config.h:341
void Activity(void)
Definition: eitscan.c:118
Definition: keys.h:54
static bool BondDevices(const char *Bondings)
Bonds the devices as defined in the given Bondings string.
Definition: dvbdevice.c:1267
bool Modified(int &State)
Returns true if any of the timers have been modified, which is detected by State being different than...
Definition: timers.c:792
Definition: keys.h:40
Definition: osdbase.h:36
cAudios Audios
Definition: audio.c:27
cTheme * Theme(void)
Definition: skins.h:362
void SetVolume(int Volume, bool Absolute=false)
Sets the volume to the given value, either absolutely or relative to the current volume.
Definition: device.c:914
int GetExitCode(void)
Get the currently set exit code of VDR.
Definition: shutdown.h:59
bool Save(void)
Definition: config.h:166
Definition: keys.h:44
virtual void Clear(void)
Free up all registered skins.
Definition: skins.c:381
bool SwitchChannel(const cChannel *Channel, bool LiveView)
Switches the device to the given Channel, initiating transfer mode if necessary.
Definition: device.c:695
Definition: keys.h:48
static void Stop(void)
Definition: cutter.c:696
static bool SetUser(const char *UserName, bool UserDump)
Definition: vdr.c:91
#define SHUTDOWNRETRY
Definition: vdr.c:73
char FontOsd[MAXFONTNAME]
Definition: config.h:317
#define DEFAULTPLUGINDIR
void RemoveDeletedRecordings(void)
Definition: recording.c:122
Definition: keys.h:54
bool HasFlags(uint Flags) const
Definition: timers.c:664
bool DoExit(void)
Check if an exit code was set, and VDR should exit.
Definition: shutdown.h:57
cSources Sources
Definition: sources.c:105
int main(int argc, char *argv[])
Definition: vdr.c:172
const cKeyMacro * Get(eKeys Key)
Definition: keys.c:269
Definition: keys.h:18
void Process(void)
Definition: eitscan.c:127
cKeys Keys
Definition: keys.c:156
void bool Start(void)
Actually starts the thread.
Definition: thread.c:273
Definition: keys.h:50
static void UpdateOsdSize(bool Force=false)
Inquires the actual size of the video display and adjusts the OSD and font sizes accordingly.
Definition: osd.c:1992
#define DEFAULTLOCDIR
cSourceParams SourceParams
Definition: sourceparams.c:34
#define ACTIVITYTIMEOUT
Definition: vdr.c:71
static bool Ended(void)
Definition: filetransfer.c:275
Definition: keys.h:52
Definition: keys.h:28
Definition: skins.h:23
virtual bool HasProgramme(void) const
Returns true if the device is currently showing any programme to the user, either through replaying o...
Definition: device.c:855
static bool Active(void)
Definition: menu.c:4885
bool ConfirmShutdown(bool Ask)
Check for background activity that blocks shutdown.
Definition: shutdown.c:161
cSetup Setup
Definition: config.c:373
int PauseKeyHandling
Definition: config.h:296
bool Put(uint64_t Code, bool Repeat=false, bool Release=false)
Definition: remote.c:124
Definition: keys.h:20
static void Cleanup(bool Force=false)
Definition: epg.c:1219
cShutdownHandler ShutdownHandler
Definition: shutdown.c:28
bool Lock(bool Write, int TimeoutMs=0)
Definition: thread.c:155
static int IsOpen(void)
Returns true if there is currently a level 0 OSD open.
Definition: osd.h:790
static const char * GetPlugin(void)
Returns the name of the plugin that was set with a previous call to PutMacro() or CallPlugin()...
Definition: remote.c:162
static void SetSystemCharacterTable(const char *CharacterTable)
Definition: tools.c:883
int SplitEditedFiles
Definition: config.h:327
static bool WaitForAllDevicesReady(int Timeout=0)
Waits until all devices have become ready, or the given Timeout (seconds) has expired.
Definition: device.c:126
static tThreadId ThreadId(void)
Definition: thread.c:341
int InstanceId
Definition: recording.c:72
static cDisplaySubtitleTracks * Create(void)
Definition: menu.c:4533
Definition: keys.h:45
#define MINVIDEOFILESIZE
Definition: recording.h:287
Definition: skins.h:342
Definition: menu.h:99
#define DEVICEREADYTIMEOUT
Definition: vdr.c:79
bool IsOpen(void)
Returns true if there is currently a skin display object active.
Definition: skins.h:410
cChannel * GetByChannelID(tChannelID ChannelID, bool TryWithoutRid=false, bool TryWithoutPolarization=false)
Definition: channels.c:972
static void Launch(cControl *Control)
Definition: player.c:79
virtual bool ProvidesTransponder(const cChannel *Channel) const
Returns true if this device can provide the transponder of the given Channel (which implies that it c...
Definition: device.c:641
static const char * LastReplayed(void)
Definition: menu.c:4994
eKeys Message(eMessageType Type, const char *s, int Seconds=0)
Displays the given message, either through a currently visible display object that is capable of doin...
Definition: skins.c:234
virtual void Show(void)
Definition: osdbase.c:70
bool SetSystemCharacterTable(const char *CharacterTable)
Definition: si.c:321
int MaxVideoFileSize
Definition: config.h:326
#define DEFAULTWATCHDOG
cNestedItemList Folders
Definition: config.c:274
cRecordings DeletedRecordings
int BeingEdited(void)
Definition: timers.h:121
static bool HasPlugins(void)
Definition: plugin.c:452
static cDevice * GetDeviceForTransponder(const cChannel *Channel, int Priority)
Returns a device that is not currently "occupied" and can be tuned to the transponder of the given Ch...
Definition: device.c:335
int PrimaryDVB
Definition: config.h:261
virtual eOSState ProcessKey(eKeys Key)
Definition: osdbase.h:84
Definition: skins.h:23
bool HasSVDRPConnection(void)
Definition: interface.h:26
int64_t StrToNum(const char *s)
Converts the given string to a number.
Definition: tools.c:274
const cSchedule * GetSchedule(tChannelID ChannelID) const
Definition: epg.c:1328
int DirectoryPathMax
Definition: recording.c:69
static bool Active(const char *FileName=NULL)
Returns true if the cutter is currently active.
Definition: cutter.c:715
int VpsMargin
Definition: config.h:299
void Housekeeping(void)
Definition: plugin.c:390
#define MEGABYTE(n)
Definition: tools.h:44
static void SetMainThreadId(void)
Definition: thread.c:346
#define DEFAULTEPGDATAFILENAME
#define CHANNELMOD_RETUNE
Definition: channels.h:28
T * First(void) const
Definition: tools.h:482
static time_t LastActivity(void)
Absolute time when last key was delivered by Get().
Definition: remote.h:68
static void Attach(void)
Definition: player.c:87
static void Process(eKeys Key)
Definition: menu.c:4332
#define MANUALSTART
Definition: vdr.c:77
static void SetCacheDirectory(const char *Dir)
Definition: plugin.c:149
static void Process(eKeys Key)
Definition: menu.c:4426
static cString GetFontFileName(const char *FontName)
Returns the actual font file name for the given FontName.
Definition: font.c:473
cChannel * GetByNumber(int Number, int SkipGap=0)
Definition: channels.c:944
bool CutRecording(const char *FileName)
Definition: cutter.c:750
eKeys GetKey(bool Wait=true)
Definition: interface.c:32
static cDevice * PrimaryDevice(void)
Returns the primary device.
Definition: device.h:132
static bool IsOpen(void)
Definition: menu.h:184
static bool Ended(void)
Definition: cutter.c:740
bool Load(const char *FileName)
Definition: config.c:522
static int LastSignal
Definition: vdr.c:89
Definition: epg.h:143
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:145
cKeyMacros KeyMacros
Definition: keys.c:267
Definition: timers.h:21
void AddPlugin(const char *Args)
Definition: plugin.c:318
bool NeedsUpdate(void)
Definition: recording.c:1361
#define DELETE_MENU
static bool SetPrimaryDevice(int n)
Sets the primary device to 'n'.
Definition: device.c:187
static cDisplayTracks * Create(void)
Definition: menu.c:4415
void StopReplay(void)
Stops the current replay session (if any).
Definition: device.c:1257
int Apid(int i) const
Definition: channels.h:171
#define tr(s)
Definition: i18n.h:85
cScrs Scrs
Definition: diseqc.c:69
virtual bool NeedsFastResponse(void)
Definition: osdbase.h:81
bool Retry(time_t AtTime=0)
Check whether its time to re-try the shutdown.
Definition: shutdown.h:88
cRecordings Recordings
Any access to Recordings that loops through the list of recordings needs to hold a thread lock on thi...
Definition: recording.c:1247
bool ConfirmRestart(bool Ask)
Check for background activity that blocks restart.
Definition: shutdown.c:216
#define CHANNELSMOD_USER
Definition: channels.h:32
static void SetGrabImageDir(const char *GrabImageDir)
Definition: svdrp.c:1821
void SetDirectory(const char *Directory)
Definition: plugin.c:312
#define isyslog(a...)
Definition: tools.h:35
virtual bool IsTunedToTransponder(const cChannel *Channel) const
Returns true if this device is currently tuned to the given Channel's transponder.
Definition: device.c:685
Definition: keys.h:42
static void SignalHandler(int signum)
Definition: vdr.c:148
static cPlugin * GetPlugin(int Index)
Definition: plugin.c:457
int CurrentVolume
Definition: config.h:339
static void Shutdown(void)
Closes down all devices.
Definition: device.c:365
Definition: keys.h:32
static cDevice * ActualDevice(void)
Returns the actual receiving device in case of Transfer Mode, or the primary device otherwise...
Definition: device.c:214
Definition: keys.h:31
#define DEFAULTCONFDIR
bool SwitchTo(int Number)
Definition: channels.c:1023
Definition: keys.h:28
#define VPSUPTODATETIME
Definition: vdr.c:85
static cOsdObject * PluginOsdObject(void)
Definition: menu.c:3767
#define SHUTDOWNCANCELPROMPT
Definition: vdr.c:75
virtual bool HasDecoder(void) const
Tells whether this device has an MPEG decoder.
Definition: device.c:204
bool Load(const char *FileName)
Definition: config.c:234
bool StartPlugins(void)
Definition: plugin.c:376
bool SeenWithin(int Seconds) const
Definition: epg.h:111
Definition: osdbase.h:35
#define EXIT(v)
Definition: vdr.c:87
cInterface * Interface
Definition: interface.c:17
void SetRetry(int Seconds)
Set shutdown retry so that VDR will not try to automatically shut down within Seconds.
Definition: shutdown.h:93
char OSDTheme[MaxThemeName]
Definition: config.h:260
void SetShutdownCommand(const char *ShutdownCommand)
Set the command string for shutdown command.
Definition: shutdown.c:125
static bool Active(void)
Definition: filetransfer.c:252
cString InitialChannel
Definition: config.h:346
#define MAXVIDEOFILESIZETS
Definition: recording.h:285
char OSDSkin[MaxSkinName]
Definition: config.h:259
#define LIVEPRIORITY
Definition: config.h:41
void StopPlugins(void)
Definition: plugin.c:500
static bool PauseLiveVideo(void)
Definition: menu.c:4808
cSkin * Current(void)
Returns a pointer to the current skin.
Definition: skins.h:408
Definition: keys.h:28
static bool Error(void)
Definition: cutter.c:732
static void SetResourceDirectory(const char *Dir)
Definition: plugin.c:163
Definition: keys.h:53
static bool IsOpen(void)
Definition: menu.h:137
bool SetCurrent(const char *Name=NULL)
Sets the current skin to the one indicated by name.
Definition: skins.c:215
static void Stop(void)
Definition: filetransfer.c:234
static void Shutdown(void)
Definition: player.c:100
#define VOLUMEDELTA
Definition: device.h:32
int BeingEdited(void)
Definition: channels.h:242
#define DirectMainFunction(function)
eKeys
Definition: keys.h:16
static void SetUseDevice(int n)
Sets the 'useDevice' flag of the given device.
Definition: device.c:142
void I18nInitialize(const char *LocaleDir)
Detects all available locales and loads the language names and codes.
Definition: i18n.c:103
The cDevice class is the base from which actual devices can be derived.
Definition: device.h:104
static void Shutdown(void)
Shuts down the OSD provider facility by deleting the current OSD provider.
Definition: osd.c:2069
Definition: keys.h:41
void Cancel(void)
Cancel the 5 minute shutdown warning countdown.
Definition: shutdown.c:47
static void SetConfigDirectory(const char *Dir)
Definition: plugin.c:135
virtual void Hide(void)=0
bool Done(void)
Check if countdown timer has run out without canceling.
Definition: shutdown.c:56
void LearnKeys(void)
Definition: interface.c:152
Definition: keys.h:22
cSkins Skins
Definition: skins.c:203
static bool Start(cTimer *Timer=NULL, bool Pause=false)
Definition: menu.c:4737
int DiSEqC
Definition: config.h:273