summaryrefslogtreecommitdiff
path: root/status.c
blob: 7fa101914957a14902ee78f388dc0a61eeeaf66c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* 
 * status.c: 'EnigmaNG' skin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 */

#include "common.h"
#include "status.h"

#include <vdr/timers.h>
#include <vdr/plugin.h>
#include <vdr/menu.h>

const char *ReplayNames[7] =
  { "", "recordings", "mp3", "mplayer", "dvd", "vcd", "image" };

cEnigmaStatus EnigmaStatus;

cEnigmaStatus::cEnigmaStatus(void) : mReplayMode(replayNone),
                                     mReplayIsLoop(false),
                                     mReplayIsShuffle(false)
{}

void cEnigmaStatus::Replaying(const cControl * /*Control */ , const char *Name,
                              const char *FileName, bool /* On */)
{
  debug("cEnigmaStatus::Replaying(%s)", Name);

  if (Name != NULL) {
#if VDRVERSNUM >= 20301
    LOCK_RECORDINGS_READ
#endif
    mReplayMode = replayMPlayer;
    if (strlen(Name) > 6 && Name[0] == '[' && Name[3] == ']' && Name[5] == '(') {
      int i;
      for (i = 6; Name[i]; ++i) {
        if (Name[i] == ' ' && Name[i - 1] == ')')
          break;
      }
      if (Name[i]) {            // replaying mp3
        mReplayMode = replayMP3;
        mReplayIsLoop = Name[1] == 'L';
        mReplayIsShuffle = Name[2] == 'S';
      }
#if VDRVERSNUM >= 20301
    } else if (FileName ? Recordings->GetByName(FileName) : NULL) {
#else
    } else if (FileName ? Recordings.GetByName(FileName) : NULL) {
#endif
      mReplayMode = replayNormal;
    } else if (strcmp(Name, "DVD") == 0)
      mReplayMode = replayDVD;
    else if (strcmp(Name, "VCD") == 0)
      mReplayMode = replayVCD;
    else if (access(Name, F_OK) == 0)
      mReplayMode = replayMPlayer;
    else if (strncmp(Name, "[image]", 7) == 0)
      mReplayMode = replayImage;
    else if (strlen(Name) > 7) {
      int i, n;
      for (i = 0, n = 0; Name[i]; ++i) {
        if (Name[i] == ' ' && Name[i - 1] == ',' && ++n == 4)
          break;
      }
      if (Name[i]) {            // replaying DVD
        mReplayMode = replayDVD;
      }
    }
  } else {
    mReplayMode = replayNone;
    mReplayIsLoop = false;
    mReplayIsShuffle = false;
  }
}

void cEnigmaStatus::Recording(const cDevice * /* Device */, const char * /* Name */, const char * /* FileName */, bool /* On */)
{
}

void cEnigmaStatus::OsdClear(void)
{
}

void cEnigmaStatus::OsdCurrentItem(const char * /* Text */)
{
}

void cEnigmaStatus::OsdItem(const char * /* Text */, int /* ItemIndex */)
{
}

void cEnigmaStatus::UpdateActiveTimers(void)
{
  mTimers.Clear();
#if VDRVERSNUM >= 20301
  LOCK_TIMERS_READ
  for (const cTimer * tim = Timers->First(); tim; tim = Timers->Next(tim)) {
#else
  Timers.IncBeingEdited();
  for (cTimer * tim = Timers.First(); tim; tim = Timers.Next(tim)) {
#endif
    if (tim->HasFlags(tfActive)) {
      int i = 0;
      cTimer dummy;
      dummy = *tim;

      do {
        mTimers.Add(new tTimer(&dummy));

        if (!dummy.IsSingleEvent())     // add 4 additional rep. timer
        {
          int j = 0;
          do {
            j++;                // just to avoid a endless loop
            dummy.Skip();
            dummy.Matches();    // Refresh start- and end-time
          } while (!dummy.DayMatches(dummy.StartTime()) && (j < 7));
        }

        i++;
      } while (!dummy.IsSingleEvent() && i < 5);
    }
  }

#if VDRVERSNUM < 20301
  Timers.DecBeingEdited();
#endif
  mTimers.Sort();
}
// vim:et:sw=2:ts=2: