diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2005-05-22 10:43:10 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2005-05-22 10:43:10 +0200 |
commit | 2d3702b8507361c3c9f17fe290fc1d6af0cef983 (patch) | |
tree | 4f178fb14ea41540d15fb2c24a9872bf56426e15 /recording.c | |
parent | a0e65853042dacd888921a435d7b3d549e7d894e (diff) | |
download | vdr-2d3702b8507361c3c9f17fe290fc1d6af0cef983.tar.gz vdr-2d3702b8507361c3c9f17fe290fc1d6af0cef983.tar.bz2 |
Fall back to 'summary.vdr' if there is no 'info.vdr'
Diffstat (limited to 'recording.c')
-rw-r--r-- | recording.c | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/recording.c b/recording.c index a946fca4..347962bf 100644 --- a/recording.c +++ b/recording.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.c 1.101 2005/05/22 09:13:26 kls Exp $ + * $Id: recording.c 1.102 2005/05/22 10:43:10 kls Exp $ */ #include "recording.h" @@ -23,6 +23,8 @@ #include "tools.h" #include "videodir.h" +#define SUMMARYFALLBACK + #define RECEXT ".rec" #define DELEXT ".del" /* This was the original code, which works fine in a Linux only environment. @@ -45,6 +47,9 @@ // end of implementation for brain dead systems #define RESUMEFILESUFFIX "/resume%s%s.vdr" +#ifdef SUMMARYFALLBACK +#define SUMMARYFILESUFFIX "/summary.vdr" +#endif #define INFOFILESUFFIX "/info.vdr" #define MARKSFILESUFFIX "/marks.vdr" @@ -230,10 +235,12 @@ cRecordingInfo::~cRecordingInfo() delete ownEvent; } -void cRecordingInfo::SetTitleAndDescription(const char *Title, const char *Description) +void cRecordingInfo::SetData(const char *Title, const char *ShortText, const char *Description) { - if (isempty(event->Title()) && !isempty(Title)) + if (!isempty(Title)) ((cEvent *)event)->SetTitle(Title); + if (!isempty(ShortText)) + ((cEvent *)event)->SetShortText(ShortText); if (!isempty(Description)) ((cEvent *)event)->SetDescription(Description); } @@ -422,7 +429,7 @@ cRecording::cRecording(cTimer *Timer, const cEvent *Event) // timer into the recording info, but it saves us from having to actually // copy the entire event data: if (!isempty(Timer->Summary())) - info->SetTitleAndDescription(Timer->File(), Timer->Summary()); + info->SetData(isempty(info->Title()) ? Timer->File() : NULL, NULL, Timer->Summary()); } cRecording::cRecording(const char *FileName) @@ -462,6 +469,46 @@ cRecording::cRecording(const char *FileName) else if (errno != ENOENT) LOG_ERROR_STR(InfoFileName); free(InfoFileName); +#ifdef SUMMARYFALLBACK + // fall back to the old 'summary.vdr' if there was no 'info.vdr': + if (isempty(info->Title())) { + char *SummaryFileName = NULL; + asprintf(&SummaryFileName, "%s%s", fileName, SUMMARYFILESUFFIX); + FILE *f = fopen(SummaryFileName, "r"); + if (f) { + int line = 0; + char *data[3] = { NULL }; + cReadLine ReadLine; + char *s; + while ((s = ReadLine.Read(f)) != NULL && line < 3) { + if (*s) { + if (data[line]) { + int len = strlen(s); + len += strlen(data[line]) + 1; + data[line] = (char *)realloc(data[line], len + 1); + strcat(data[line], "\n"); + strcat(data[line], s); + } + else + data[line] = strdup(s); + } + else + line++; + } + fclose(f); + if (line == 1) { + data[2] = data[1]; + data[1] = NULL; + } + info->SetData(data[0], data[1], data[2]); + for (int i = 0; i < 3; i ++) + free(data[i]); + } + else if (errno != ENOENT) + LOG_ERROR_STR(SummaryFileName); + free(SummaryFileName); + } +#endif } } |