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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
/*
* $Id: status.c,v 1.10 2005/06/03 08:53:13 lordjaxom Exp $
*/
#include "status.h"
#include "render.h"
#include <vdr/timers.h>
#include <vdr/plugin.h>
const std::string ReplayNames[__REPLAY_COUNT__] =
{ "", "normal", "mp3", "mplayer", "dvd", "vcd", "image" };
cText2SkinStatus Text2SkinStatus;
cText2SkinStatus::cText2SkinStatus(void):
mRender(NULL),
mReplayMode(replayNone),
mReplayIsLoop(false),
mReplayIsShuffle(false),
mRecordings(),
mCurrentRecording(0),
mNextRecording(0),
mLastLanguage(0)
{
}
void cText2SkinStatus::SetRender(cText2SkinRender *Render)
{
mRender = Render;
mCurrentRecording = 0;
mNextRecording = 0;
}
void cText2SkinStatus::Replaying(const cControl* /*Control*/, const char *Name) {
Dprintf("cText2SkinStatus::Replaying(%s)\n", Name);
eReplayMode oldMode = mReplayMode;
if (mRender != NULL)
mRender->UpdateLock();
if (Name != NULL) {
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';
}
}
else if (GetRecordingByName(Name) != NULL)
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;
}
if (mRender != NULL) {
if (mReplayMode != oldMode)
mRender->SetDirty();
mRender->UpdateUnlock();
}
}
void cText2SkinStatus::Recording(const cDevice *Device, const char *Name)
{
if (mRender != NULL)
mRender->UpdateLock();
mRecordingsLock.Lock();
mRecordings.clear();
cTimer *t = Timers.First();
for (; t != NULL; t = Timers.Next(t)) {
if (t->Recording())
mRecordings.push_back(t->File());
}
mRecordingsLock.Unlock();
if (mRender != NULL) {
Dprintf("\nFlushing from cStatus\n\n");
mRender->Flush(true);
mRender->UpdateUnlock();
}
}
void cText2SkinStatus::OsdClear(void)
{
if (Setup.OSDLanguage != mLastLanguage) {
mLastLanguage = Setup.OSDLanguage;
cxString::Reparse();
}
}
cxType cText2SkinStatus::GetTokenData(const txToken &Token)
{
switch (Token.Type) {
case tReplayMode:
return ReplayNames[mReplayMode];
case tNextTimerName:
{
cTimer *tim = Timers.GetNextActiveTimer();
if (tim)
{
const char *timText = tim->File();
return timText;
}
else
{
return false;
}
}
case tNextTimerStart:
{
cTimer *tim = Timers.GetNextActiveTimer();
if (tim)
{
char *buffer = NULL;
asprintf(&buffer, "%02d:%02d", tim->Start() / 100, tim->Start() % 100);
return buffer;
}
else
{
return false;
}
}
case tNextTimerChannel:
{
cTimer *tim = Timers.GetNextActiveTimer();
if (tim)
{
const char *timChan = tim->Channel()->Name();
return timChan;
}
else
{
return false;
}
}
case tTimerConflict:
{
bool conflict = false;
if (cPluginManager::CallFirstService("CheckTimerConflict-v1.0", &conflict) )
{
return conflict;
}
else
{
return false;
}
}
case tCurrentRecordingsCount:
return (int)mRecordings.size();
case tCurrentRecording:
Dprintf("token attrib type is: %d, number: %d\n", Token.Attrib.Type, Token.Attrib.Number);
if (Token.Attrib.Type == aNumber) {
return mRecordings.size() > (uint)Token.Attrib.Number
? (cxType)mRecordings[Token.Attrib.Number]
: (cxType)false;
} else if (mRecordings.size() > 0) {
mRecordingsLock.Lock();
uint now = time_ms();
if (mNextRecording == 0)
mNextRecording = now + 2000;
else if (now >= mNextRecording) {
mCurrentRecording = (mCurrentRecording + 1) % mRecordings.size();
mNextRecording = now + 2000;
}
uint next = 0;
if (mRecordings.size() > 1) {
next = mNextRecording - now;
Dprintf("next update in %d ms\n", next);
}
cxType res = mRecordings[mCurrentRecording];
mRecordingsLock.Unlock();
res.SetUpdate(next);
return res;
}
return false;
case tReplayIsLoop:
return mReplayIsLoop;
case tReplayIsShuffle:
return mReplayIsShuffle;
default:
break;
};
return false;
}
|