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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
/*
* menu.c: The actual menu implementations
*/
#include <stdlib.h>
#include <time.h>
#include <vdr/interface.h>
#include <vdr/plugin.h>
#include <vdr/remote.h>
#include <vdr/thread.h>
#include "config.h"
#include "logger.h"
#include "menu.h"
#include "tools.h"
enum {
TYPE_NONE,
TYPE_IMAGE,
TYPE_VIDEO,
TYPE_MUSIC
};
class cHistoryRecordingMenu : public cOsdMenu {
private:
const cRecording *recording;
public:
cHistoryRecordingMenu(const cRecording *Recording);
virtual void Display(void);
virtual eOSState ProcessKey(eKeys Key);
};
cHistoryRecordingMenu::cHistoryRecordingMenu(const cRecording *Recording)
:cOsdMenu(trVDR("Recording info"))
{
#if VDRVERSNUM >= 10728
SetMenuCategory(mcRecording);
#endif
recording = Recording;
SetHelp(trVDR("Button$Play"),trVDR("Button$Rewind"));
}
void cHistoryRecordingMenu::Display(void)
{
cOsdMenu::Display();
DisplayMenu()->SetRecording(recording);
if (recording->Info()->Description())
cStatus::MsgOsdTextItem(recording->Info()->Description());
}
eOSState cHistoryRecordingMenu::ProcessKey(eKeys Key)
{
eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) {
switch (Key) {
case kPlay:
case kRed: cRemote::Put(Key, true);
case kOk: return osBack;
default: break;
}
}
return state;
}
class cHistoryRecordingMenuItem : public cOsdItem
{
private:
char *filename;
char *name;
bool active;
public:
cHistoryRecordingMenuItem(const char *Name, const char *Filename);
~cHistoryRecordingMenuItem() { free(filename); free(name); }
const char *GetFilename() { return filename; }
const char *GetName() { return name; }
bool IsActive() { return active; }
};
// Use name only if not a VDR recording
cHistoryRecordingMenuItem::cHistoryRecordingMenuItem(const char *Name, const char *Filename)
{
active = false;
filename = Filename ? strdup(Filename) : NULL;
name = Name ? strdup(Name) : NULL;
if (filename) {
if (!name) {
cThreadLock RecordingsLock(&Recordings);
cRecording *recording = Recordings.GetByName(filename);
if (recording) {
active = true;
SetText(recording->Title('\t'));
}
else
SetText(tr("Deleted or not available"));
}
else {
active = true;
SetText(name);
}
}
else
SetText(tr("Deleted or not available"));
}
cHistoryMainMenu::cHistoryMainMenu(cHistoryLogger *HistoryLogger) : cOsdMenu(tr("Replay history"), 9, 6, 6)
{
history_logger = HistoryLogger;
SetMenu();
SetHelpKeys();
Display();
}
void cHistoryMainMenu::SetHelpKeys()
{
if (history_logger->GetReplayHistory()->Count() > 0) {
int curr = Current();
if (curr == -1) {
for (cOsdItem *item = First(); item; item = Next(item)) {
if (item->Selectable()) {
curr = item->Index();
break;
}
}
}
cHistoryRecordingMenuItem *ri = (cHistoryRecordingMenuItem *)Get(curr);
if (ri && ri->IsActive() && !ri->GetName())
SetHelp(trVDR("Button$Play"), trVDR("Button$Rewind"), trVDR("Button$Delete"), trVDR("Button$Info"));
else if (ri && ri->IsActive())
SetHelp(trVDR("Button$Play"), NULL, trVDR("Button$Delete"), NULL);
else
SetHelp(NULL, NULL, trVDR("Button$Delete"), NULL);
}
}
void cHistoryMainMenu::SetMenu()
{
Clear();
#if VDRVERSNUM >= 10728
SetMenuCategory(mcRecording);
#endif
cList<cHistoryRecordingItem> *replay_history = history_logger->GetReplayHistory();
cHistoryRecordingItem *item = replay_history->First();
while (item != NULL) {
char *time = item->GetReplayTimeString();
Add(new cOsdItem(time, osUnknown, false));
free(time);
Add(new cHistoryRecordingMenuItem(item->GetName(), item->GetFilename()));
item = (cHistoryRecordingItem *)item->Next();
}
}
cRecording *cHistoryMainMenu::GetRecording(cHistoryRecordingMenuItem *Item)
{
cThreadLock RecordingsLock(&Recordings);
cRecording *recording = Recordings.GetByName(Item->GetFilename());
if (!recording)
Skins.Message(mtError, trVDR("Error while accessing recording!"));
return recording;
}
eOSState cHistoryMainMenu::Delete()
{
cHistoryRecordingMenuItem *ri = (cHistoryRecordingMenuItem *)Get(Current());
if (HistorySetup.allow_delete && ri && ri->IsActive() && ((!ri->GetName() && Interface->Confirm(tr("Delete also recording?"))) || (ri->GetName() && Interface->Confirm(tr("Delete also file?"))))) {
if (!ri->GetName()) {
cRecording *recording = GetRecording(ri);
if (recording && !recording->Delete())
Skins.Message(mtError, tr("Unable to delete recording"));
}
else
if (!RemoveFileOrDir(ri->GetFilename()))
Skins.Message(mtError, tr("Unable to delete file"));
}
history_logger->DeleteRecordingItem(Current()/2);
return osContinue;
}
eOSState cHistoryMainMenu::Info()
{
cHistoryRecordingMenuItem *ri = (cHistoryRecordingMenuItem *)Get(Current());
if (ri) {
cRecording *recording = GetRecording(ri);
if (recording && recording->Info()->Title())
return AddSubMenu(new cHistoryRecordingMenu(recording));
}
return osContinue;
}
eOSState cHistoryMainMenu::Play()
{
cHistoryRecordingMenuItem *ri = (cHistoryRecordingMenuItem *)Get(Current());
if (!ri->GetName()) {
cReplayControl::SetRecording(ri->GetFilename());
return osReplay;
}
else {
const char *filename = ri->GetFilename();
int type;
if (isvideo(filename))
type = TYPE_VIDEO;
else if (ismusic(filename))
type = TYPE_MUSIC;
else if (isimage(filename))
type = TYPE_IMAGE;
else
type = TYPE_NONE;
switch (type) {
case TYPE_VIDEO:
cPluginManager::CallFirstService("MediaPlayer-1.0", (void *)filename);
break;
case TYPE_MUSIC:
cPluginManager::CallFirstService("MusicPlayer-1.0", (void *)filename);
break;
case TYPE_IMAGE:
cPluginManager::CallFirstService("ImagePlayer-1.0", (void *)filename);
break;
case TYPE_NONE:
default:
break;
}
return osEnd;
}
}
eOSState cHistoryMainMenu::Rewind()
{
cHistoryRecordingMenuItem *ri = (cHistoryRecordingMenuItem *)Get(Current());
cRecording *recording = GetRecording(ri);
if (recording) {
cDevice::PrimaryDevice()->StopReplay(); // must do this first to be able to rewind the currently replayed recording
cResumeFile ResumeFile(ri->GetFilename(), recording->IsPesRecording());
ResumeFile.Delete();
return Play();
}
return osContinue;
}
eOSState cHistoryMainMenu::ProcessKey(eKeys Key)
{
eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) {
cHistoryRecordingMenuItem *ri = (cHistoryRecordingMenuItem *)Get(Current());
if (ri) {
switch (int(Key)) {
case kOk:
case kPlay:
case kRed:
state = Play();
break;
case kGreen:
if (!ri->GetName())
state = Rewind();
break;
case kYellow:
state = Delete();
SetMenu();
SetHelpKeys();
Display();
break;
case kBlue:
case kInfo:
if (!ri->GetName())
state = Info();
break;
default:
break;
}
}
}
else {
switch (int(Key)) {
case kUp:
case kDown:
case kLeft:
case kRight:
SetHelpKeys();
Display();
break;
default:
break;
}
}
return state;
}
|