vdr/config.h
Klaus Schmidinger 1d22145c42 Version 0.6
- Added support for LIRC remote control (thanks to Carsten Koch!).
  There are now three different remote control modes: KBD (PC-Keyboard), RCU
  and LIRC. See the INSTALL file for information on how to enable either of
  these modes. The default mode is now KBD, not RCU as before (to make it
  work immediately even if there is no actual remote control).
- Fixed small bug in dvbapi.c that was causing some channels (many on hotbird)
  not to be correctly tuned (thanks to Plamen Ganev!).
- Now clearing the replay buffer in search forward/back, which results in
  faster reaction.
- The 'Recordings' menu is now listed alphabetically (thanks to Carsten Koch!).
- The new 'epg2timers' tool (thanks to Carsten Koch!) can be used to convert
  an EPG "merkliste" page (http://www.tvtv.de) to vdr timer entries.
- The new 'xtvrc2vdr' tool (thanks to Plamen Ganev!) can be used to convert
  'xtvrc' channel files into 'vdr' format.
- When more than one timer matches at the same time, the first one in the list
  with the highest 'Priority' is selected.
- The MANUAL section on "Programming the Timer" has been filled in.
- The year in the "Recordings" menu as well as in the progress display during
  replay has been reduced to 2 digits to allow more space for the recording's
  title. In the internal file structure the year is still stored with 4 digits,
  so there will be no problem at the next turn of the century ;-)
- Channel names and timer filenames can now contain blanks. To avoid problems
  with file names that contain blanks, all blanks in recording file names are
  converted to underscores.
- The polarization can now be given in uppercase or lowercase characters in
  channels.conf.
- Fixed buffer initialization to work with DVB driver version 0.6.
- Implemented the "Simple Video Disk Recorder Protocol" (SVDRP) to control
  the VDR over a network connection.
- Implemented command line option handling.
- The program can now run in full background mode by using the --daemon option.
- Added a "summary" field to the timers (thanks to Carsten Koch!).
  This field can contain a descriptive text of the programme and will be
  displayed when the "Blue" key is pressed on a recording that was created by
  this timer. If the text contains the special character '|', a newline will
  be inserted at that place.  When pressing "Ok" on a timer that contains a
  summary field, the summary will be displayed. To edit such a timer the "Red"
  key must be pressed. Timers without a summary still go into Edit mode when
  pressing "Ok".  The summary field can only be filled in directly by editing
  the 'timers.conf' file with a text editor, or by defining/modifying the timer
  via the SVDRP interface.
2000-07-25 18:00:00 +02:00

193 lines
4.1 KiB
C++

/*
* config.h: Configuration file handling
*
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: config.h 1.11 2000/07/23 17:17:10 kls Exp $
*/
#ifndef __CONFIG_H
#define __CONFIG_H
#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "dvbapi.h"
#include "tools.h"
#define MaxBuffer 10000
enum eKeys { // "Up" and "Down" must be the first two keys!
kUp,
kDown,
kMenu,
kOk,
kBack,
kLeft,
kRight,
kRed,
kGreen,
kYellow,
kBlue,
k0, k1, k2, k3, k4, k5, k6, k7, k8, k9,
kNone
};
struct tKey {
eKeys type;
char *name;
unsigned int code;
};
class cKeys {
private:
char *fileName;
public:
unsigned char code;
unsigned short address;
tKey *keys;
cKeys(void);
void Clear(void);
void SetDummyValues(void);
bool Load(const char *FileName = NULL);
bool Save(void);
unsigned int Encode(const char *Command);
eKeys Get(unsigned int Code);
void Set(eKeys Key, unsigned int Code);
};
class cChannel : public cListObject {
private:
static char *buffer;
static const char *ToText(cChannel *Channel);
public:
enum { MaxChannelName = 32 }; // 31 chars + terminating 0!
char name[MaxChannelName];
int frequency; // MHz
char polarization;
int diseqc;
int srate;
int vpid;
int apid;
int ca;
int pnr;
cChannel(void);
cChannel(const cChannel *Channel);
const char *ToText(void);
bool Parse(const char *s);
bool Save(FILE *f);
bool Switch(cDvbApi *DvbApi = NULL);
static bool SwitchTo(int i, cDvbApi *DvbApi = NULL);
static const char *GetChannelName(int i);
};
class cTimer : public cListObject {
private:
time_t startTime, stopTime;
static char *buffer;
static const char *ToText(cTimer *Timer);
public:
enum { MaxFileName = 256 };
bool recording;
int active;
int channel;
int day;
int start;
int stop;
//TODO VPS???
int priority;
int lifetime;
char file[MaxFileName];
char *summary;
cTimer(bool Instant = false);
~cTimer();
cTimer& operator= (const cTimer &Timer);
const char *ToText(void);
bool Parse(const char *s);
bool Save(FILE *f);
bool IsSingleEvent(void);
bool Matches(time_t t = 0);
time_t StartTime(void);
time_t StopTime(void);
void SetRecording(bool Recording);
static cTimer *GetMatch(void);
static int TimeToInt(int t);
static time_t Day(time_t t);
static int ParseDay(const char *s);
static const char *PrintDay(int d);
};
template<class T> class cConfig : public cList<T> {
private:
char *fileName;
void Clear(void)
{
delete fileName;
cList<T>::Clear();
}
public:
bool Load(const char *FileName)
{
isyslog(LOG_INFO, "loading %s", FileName);
bool result = true;
Clear();
fileName = strdup(FileName);
FILE *f = fopen(fileName, "r");
if (f) {
int line = 0;
char buffer[MaxBuffer];
while (fgets(buffer, sizeof(buffer), f) > 0) {
line++;
T *l = new T;
if (l->Parse(buffer))
Add(l);
else {
esyslog(LOG_ERR, "error in %s, line %d\n", fileName, line);
delete l;
result = false;
break;
}
}
fclose(f);
}
else {
esyslog(LOG_ERR, "can't open '%s'\n", fileName);
result = false;
}
return result;
}
bool Save(void)
{
//TODO make backup copies???
bool result = true;
T *l = (T *)First();
FILE *f = fopen(fileName, "w");
if (f) {
while (l) {
if (!l->Save(f)) {
result = false;
break;
}
l = (T *)l->Next();
}
fclose(f);
}
else
result = false;
return result;
}
};
class cChannels : public cConfig<cChannel> {};
class cTimers : public cConfig<cTimer> {};
extern int CurrentChannel;
extern cChannels Channels;
extern cTimers Timers;
extern cKeys Keys;
#endif //__CONFIG_H