summaryrefslogtreecommitdiff
path: root/recording.c
diff options
context:
space:
mode:
Diffstat (limited to 'recording.c')
-rw-r--r--recording.c91
1 files changed, 72 insertions, 19 deletions
diff --git a/recording.c b/recording.c
index fe56a6e6..2ce0cf78 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.42 2001/10/20 10:28:28 kls Exp $
+ * $Id: recording.c 1.43 2002/01/20 12:14:25 kls Exp $
*/
#include "recording.h"
@@ -184,6 +184,8 @@ void cResumeFile::Delete(void)
// --- cRecording ------------------------------------------------------------
+#define RESUME_NOT_INITIALIZED (-2)
+
struct tCharExchange { char a; char b; };
tCharExchange CharExchange[] = {
{ '~', '/' },
@@ -213,6 +215,7 @@ char *ExchangeChars(char *s, bool ToFileSystem)
cRecording::cRecording(cTimer *Timer, const char *Subtitle, const char *Summary)
{
+ resume = RESUME_NOT_INITIALIZED;
titleBuffer = NULL;
sortBuffer = NULL;
fileName = NULL;
@@ -242,6 +245,7 @@ cRecording::cRecording(cTimer *Timer, const char *Subtitle, const char *Summary)
cRecording::cRecording(const char *FileName)
{
+ resume = RESUME_NOT_INITIALIZED;
titleBuffer = NULL;
sortBuffer = NULL;
fileName = strdup(FileName);
@@ -342,6 +346,15 @@ char *cRecording::SortName(void)
return sortBuffer;
}
+int cRecording::GetResume(void)
+{
+ if (resume == RESUME_NOT_INITIALIZED) {
+ cResumeFile ResumeFile(FileName());
+ resume = ResumeFile.Read();
+ }
+ return resume;
+}
+
bool cRecording::operator< (const cListObject &ListObject)
{
cRecording *r = (cRecording *)&ListObject;
@@ -360,27 +373,47 @@ const char *cRecording::FileName(void)
return fileName;
}
-const char *cRecording::Title(char Delimiter, bool NewIndicator)
+const char *cRecording::Title(char Delimiter, bool NewIndicator, int Level)
{
- char New = ' ';
- if (NewIndicator) {
- cResumeFile ResumeFile(FileName());
- if (ResumeFile.Read() <= 0)
- New = '*';
- }
+ char New = NewIndicator && IsNew() ? '*' : ' ';
delete titleBuffer;
titleBuffer = NULL;
- struct tm tm_r;
- struct tm *t = localtime_r(&start, &tm_r);
- asprintf(&titleBuffer, "%02d.%02d%c%02d:%02d%c%c%s",
- t->tm_mday,
- t->tm_mon + 1,
- Delimiter,
- t->tm_hour,
- t->tm_min,
- New,
- Delimiter,
- name);
+ if (Level < 0 || Level == HierarchyLevels()) {
+ struct tm tm_r;
+ struct tm *t = localtime_r(&start, &tm_r);
+ const char *s;
+ if (Level > 0 && (s = strrchr(name, '~')) != NULL)
+ s++;
+ else
+ s = name;
+ asprintf(&titleBuffer, "%02d.%02d%c%02d:%02d%c%c%s",
+ t->tm_mday,
+ t->tm_mon + 1,
+ Delimiter,
+ t->tm_hour,
+ t->tm_min,
+ New,
+ Delimiter,
+ s);
+ }
+ else if (Level < HierarchyLevels()) {
+ const char *s = name;
+ const char *p = s;
+ while (*++s) {
+ if (*s == '~') {
+ if (Level--)
+ p = s + 1;
+ else
+ break;
+ }
+ }
+ titleBuffer = new char[s - p + 3];
+ *titleBuffer = Delimiter;
+ *(titleBuffer + 1) = Delimiter;
+ strn0cpy(titleBuffer + 2, p, s - p + 1);
+ }
+ else
+ return "";
return titleBuffer;
}
@@ -395,6 +428,17 @@ const char *cRecording::PrefixFileName(char Prefix)
return NULL;
}
+int cRecording::HierarchyLevels(void)
+{
+ const char *s = name;
+ int level = 0;
+ while (*++s) {
+ if (*s == '~')
+ level++;
+ }
+ return level;
+}
+
bool cRecording::WriteSummary(void)
{
if (summary) {
@@ -461,6 +505,15 @@ bool cRecordings::Load(bool Deleted)
return result;
}
+cRecording *cRecordings::GetByName(const char *FileName)
+{
+ for (cRecording *recording = First(); recording; recording = Next(recording)) {
+ if (strcmp(recording->FileName(), FileName) == 0)
+ return recording;
+ }
+ return NULL;
+}
+
// --- cMark -----------------------------------------------------------------
char *cMark::buffer = NULL;