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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
|
#include "recmenumanager.h"
cRecMenuManager::cRecMenuManager(void) {
active = false;
activeMenu = NULL;
activeMenuBuffer = NULL;
recManager = new cRecManager();
recManager->SetEPGSearchPlugin();
instantRecord = false;
currentConflict = -1;
templateID = -1;
timer = NULL;
searchWithOptions = false;
detailViewActive = false;
}
cRecMenuManager::~cRecMenuManager(void) {
if (activeMenu) {
active = false;
delete activeMenu;
activeMenu = NULL;
}
delete recManager;
}
void cRecMenuManager::Start(const cEvent *event) {
active = true;
activeMenuBuffer = NULL;
instantRecord = false;
currentConflict = -1;
templateID = -1;
timer = NULL;
searchWithOptions = false;
detailViewActive = false;
SetBackground();
this->event = event;
activeMenu = new cRecMenuMain(recManager->EpgSearchAvailable(), event->HasTimer(), SwitchTimers.EventInSwitchList(event));
activeMenu->Display();
osdManager.flush();
}
void cRecMenuManager::Close(void) {
event = NULL;
active = false;
if (activeMenu) {
delete activeMenu;
activeMenu = NULL;
}
DeleteBackground();
}
void cRecMenuManager::SetBackground(void) {
int backgroundWidth = tvguideConfig.osdWidth;
int backgroundHeight = tvguideConfig.osdHeight;
pixmapBackground = osdManager.requestPixmap(3, cRect(0, 0, backgroundWidth, backgroundHeight));
pixmapBackground->Fill(theme.Color(clrRecMenuBackground));
if (tvguideConfig.scaleVideo) {
int tvHeight = tvguideConfig.statusHeaderHeight;
int tvWidth = tvHeight * 16 / 9;
int tvX = tvguideConfig.osdWidth - tvWidth;
pixmapBackground->DrawRectangle(cRect(tvX, 0, tvWidth, tvHeight), clrTransparent);
}
}
void cRecMenuManager::DeleteBackground(void) {
osdManager.releasePixmap(pixmapBackground);
}
eOSState cRecMenuManager::StateMachine(eRecMenuState nextState) {
eOSState state = osContinue;
switch (nextState) {
/*
* --------- INSTANT RECORDING ---------------------------
*/
case rmsInstantRecord: {
//Creating timer for active Event
//if no conflict, confirm and exit
instantRecord = true;
delete activeMenu;
cTimer *timer = recManager->createTimer(event);
if (!displayTimerConflict(timer)) {
activeMenu = new cRecMenuConfirmTimer(event);
activeMenu->Display();
}
break; }
case rmsIgnoreTimerConflict:
//Confirming created Timer
if (instantRecord) {
delete activeMenu;
activeMenu = new cRecMenuConfirmTimer(event);
activeMenu->Display();
} else {
state = osEnd;
Close();
}
break;
case rmsTimerConflictShowInfo: {
int timerIndex = activeMenu->GetActive(true);
int timerID = conflictList[currentConflict].timerIDs[timerIndex];
cTimer *t = Timers.Get(timerID);
if (t) {
const cEvent *ev = t->Event();
if (ev) {
activeMenu->Hide();
detailView = new cDetailView(ev);
detailView->drawHeader();
detailView->drawContent();
detailView->drawScrollbar();
detailViewActive = true;
}
}
break;}
case rmsDeleteTimerConflictMenu: {
//delete timer out of current timer conflict
//active menu: cRecMenuTimerConflict
int timerIndex = activeMenu->GetActive(true);
int timerID = conflictList[currentConflict].timerIDs[timerIndex];
recManager->DeleteTimer(timerID);
delete activeMenu;
if (!displayTimerConflict(timerID)) {
activeMenu = new cRecMenuConfirmTimer(event);
activeMenu->Display();
}
break; }
case rmsEditTimerConflictMenu: {
//edit timer out of current timer conflict
//active menu: cRecMenuTimerConflict
int activeItem = activeMenu->GetActive(true);
int timerID = conflictList[currentConflict].timerIDs[activeItem];
timer = Timers.Get(timerID);
if (timer) {
delete activeMenu;
activeMenu = new cRecMenuEditTimer(timer, rmsSaveTimerConflictMenu);
activeMenu->Display();
}
break; }
case rmsSaveTimerConflictMenu: {
//save timer from current timer conflict
recManager->SaveTimer(timer, activeMenu);
delete activeMenu;
if (!displayTimerConflict(timer)) {
activeMenu = new cRecMenuConfirmTimer(event);
activeMenu->Display();
}
break; }
case rmsDeleteTimer:
//delete timer for active event
delete activeMenu;
if (recManager->IsRecorded(event)) {
activeMenu = new cRecMenuAskDeleteTimer(event);
} else {
recManager->DeleteTimer(event);
activeMenu = new cRecMenuConfirmDeleteTimer(event);
}
activeMenu->Display();
break;
case rmsDeleteTimerConfirmation:
//delete running timer for active event
recManager->DeleteTimer(event);
delete activeMenu;
activeMenu = new cRecMenuConfirmDeleteTimer(event);
activeMenu->Display();
break;
case rmsEditTimer: {
//edit timer for active event
timer = Timers.GetMatch(event);
if (timer) {
delete activeMenu;
activeMenu = new cRecMenuEditTimer(timer, rmsSaveTimer);
activeMenu->Display();
}
break; }
case rmsSaveTimer: {
//save timer for active event
recManager->SaveTimer(timer, activeMenu);
state = osEnd;
Close();
break; }
/*
* --------- SERIES TIMER ---------------------------------
*/
case rmsSeriesTimer: {
delete activeMenu;
cChannel *channel = Channels.GetByChannelID(event->ChannelID());
activeMenu = new cRecMenuSeriesTimer(channel, event);
activeMenu->Display();
break; }
case rmsSeriesTimerCreate: {
cTimer *seriesTimer = recManager->CreateSeriesTimer(activeMenu);
delete activeMenu;
activeMenu = new cRecMenuConfirmSeriesTimer(seriesTimer);
activeMenu->Display();
break; }
/*
* --------- SEARCH TIMER ---------------------------------
*/
case rmsSearchTimer:
delete activeMenu;
activeMenu = new cRecMenuSearchTimer(event);
activeMenu->Display();
break;
case rmsSearchTimerOptions: {
searchString = *activeMenu->GetStringValue(1);
delete activeMenu;
if (isempty(*searchString)) {
activeMenu = new cRecMenuSearchTimer(event);
} else {
epgSearchTemplates = recManager->ReadEPGSearchTemplates();
int numTemplates = epgSearchTemplates.size();
if (numTemplates > 0) {
activeMenu = new cRecMenuSearchTimerTemplates(searchString, epgSearchTemplates);
} else {
activeMenu = new cRecMenuSearchTimerOptions(searchString);
}
}
activeMenu->Display();
break; }
case rmsSearchTimerOptionsReload: {
int numTemplates = epgSearchTemplates.size();
delete activeMenu;
activeMenu = new cRecMenuSearchTimerTemplates(searchString, epgSearchTemplates);
activeMenu->Display();
break; }
case rmsSearchTimerUseTemplate: {
templateID = activeMenu->GetActive(true) - 1;
delete activeMenu;
activeMenu = new cRecMenuSearchTimerTemplatesCreate(searchString, epgSearchTemplates[templateID].name.c_str());
activeMenu->Display();
break; }
case rmsSearchTimerOptionsManually:
delete activeMenu;
activeMenu = new cRecMenuSearchTimerOptions(searchString);
activeMenu->Display();
break;
case rmsSearchTimerTestTemplate: {
std::string epgSearchString = recManager->BuildEPGSearchString(searchString, epgSearchTemplates[templateID].templValue);
int numSearchResults = 0;
const cEvent **searchResult = recManager->PerformSearchTimerSearch(epgSearchString, numSearchResults);
if (searchResult) {
activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide();
activeMenu = new cRecMenuSearchTimerResults(searchString, searchResult, numSearchResults, epgSearchTemplates[templateID].name);
activeMenu->Display();
} else {
activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide();
activeMenu = new cRecMenuSearchTimerNothingFound(searchString, epgSearchTemplates[templateID].name);
activeMenu->Display();
}
break; }
case rmsSearchTimerTestManually: {
std::string epgSearchString = recManager->BuildEPGSearchString(searchString, activeMenu);
int numSearchResults = 0;
const cEvent **searchResult = recManager->PerformSearchTimerSearch(epgSearchString, numSearchResults);
if (searchResult) {
activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide();
activeMenu = new cRecMenuSearchTimerResults(searchString, searchResult, numSearchResults, "");
activeMenu->Display();
} else {
activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide();
activeMenu = new cRecMenuSearchTimerNothingFound(searchString, "");
activeMenu->Display();
}
break; }
case rmsSearchTimerNothingFoundConfirm:
delete activeMenu;
activeMenu = activeMenuBuffer;
activeMenuBuffer = NULL;
activeMenu->Show();
break;
case rmsSearchTimerCreateManually:
case rmsSearchTimerCreateTemplate: {
std::string epgSearchString;
if (nextState == rmsSearchTimerCreateManually) {
epgSearchString = recManager->BuildEPGSearchString(searchString, activeMenu);
} else if (nextState = rmsSearchTimerCreateTemplate) {
epgSearchString = recManager->BuildEPGSearchString(searchString, epgSearchTemplates[templateID].templValue);
}
bool success = createSearchTimer(epgSearchString);
delete activeMenu;
activeMenu = new cRecMenuSearchTimerCreateConfirm(success);
activeMenu->Display();
break; }
/*
* --------- SWITCH TIMER ---------------------------------
*/
case rmsSwitchTimer:
delete activeMenu;
activeMenu = new cRecMenuSwitchTimer();
activeMenu->Display();
break;
case rmsSwitchTimerCreate: {
bool success = recManager->CreateSwitchTimer(event, activeMenu);
delete activeMenu;
activeMenu = new cRecMenuSwitchTimerConfirm(success);
activeMenu->Display();
break; }
case rmsSwitchTimerDelete:
recManager->DeleteSwitchTimer(event);
delete activeMenu;
activeMenu = new cRecMenuSwitchTimerDelete();
activeMenu->Display();
break;
/*
* --------- RECORDINGS SEARCH ---------------------------------
*/
case rmsRecordingSearch:
delete activeMenu;
activeMenu = new cRecMenuRecordingSearch(event);
activeMenu->Display();
break;
case rmsRecordingSearchResult: {
searchString = activeMenu->GetStringValue(1);
delete activeMenu;
if (isempty(*searchString)) {
activeMenu = new cRecMenuRecordingSearch(event);
} else {
int numSearchResults = 0;
cRecording **searchResult = recManager->SearchForRecordings(searchString, numSearchResults);
if (numSearchResults == 0) {
activeMenu = new cRecMenuRecordingSearchNotFound(searchString);
} else {
activeMenu = new cRecMenuRecordingSearchResults(searchString, searchResult, numSearchResults);
}
}
activeMenu->Display();
break; }
/*
* --------- SEARCH ---------------------------------
*/
case rmsSearch:
delete activeMenu;
activeMenu = new cRecMenuSearch(event);
activeMenu->Display();
searchWithOptions = false;
break;
case rmsSearchWithOptions: {
cString searchString = activeMenu->GetStringValue(1);
delete activeMenu;
if (isempty(*searchString)) {
activeMenu = new cRecMenuSearch(event);
} else {
activeMenu = new cRecMenuSearch(event, *searchString);
searchWithOptions = true;
}
activeMenu->Display();
break; }
case rmsSearchPerform: {
cString searchString = activeMenu->GetStringValue(1);
if (isempty(*searchString)) {
delete activeMenu;
activeMenu = new cRecMenuSearch(event);
} else {
int numSearchResults = 0;
const cEvent **searchResult = recManager->PerformSearch(activeMenu, searchWithOptions, numSearchResults);
if (searchResult) {
delete activeMenu;
activeMenu = new cRecMenuSearchResults(searchString, searchResult, numSearchResults);
} else {
activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide();
activeMenu = new cRecMenuSearchNothingFound(searchString);
}
}
activeMenu->Display();
break; }
case rmsSearchNothingFoundConfirm:
delete activeMenu;
activeMenu = activeMenuBuffer;
activeMenuBuffer = NULL;
activeMenu->Show();
break;
case rmsSearchShowInfo: {
const cEvent *ev = activeMenu->GetEventValue(activeMenu->GetActive(false));
if (ev) {
activeMenu->Hide();
detailView = new cDetailView(ev);
detailView->drawHeader();
detailView->drawContent();
detailView->drawScrollbar();
detailViewActive = true;
}
break;}
case rmsSearchRecord: {
const cEvent *ev = activeMenu->GetEventValue(activeMenu->GetActive(false));
cTimer *timer = recManager->createTimer(ev);
activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide();
activeMenu = new cRecMenuSearchConfirmTimer(ev);
activeMenu->Display();
break;}
case rmsSearchRecordConfirm:
delete activeMenu;
activeMenu = activeMenuBuffer;
activeMenuBuffer = NULL;
activeMenu->Show();
break;
/*
* --------- CHECK FOR TIMER CONFLICTS ---------------------------------
*/
case rmsTimerConflicts: {
//Show timer conflict
//active menu: cRecMenuTimerConflicts
conflictList = recManager->CheckTimerConflict();
delete activeMenu;
int numConflicts = conflictList.size();
if (numConflicts > 0) {
activeMenu = new cRecMenuTimerConflicts(conflictList);
} else {
activeMenu = new cRecMenuNoTimerConflict();
}
activeMenu->Display();
break; }
case rmsTimerConflict:
//Show timer conflict
//active menu: cRecMenuTimerConflicts
currentConflict = activeMenu->GetActive(true);
delete activeMenu;
activeMenu = new cRecMenuTimerConflict(conflictList[currentConflict]);
activeMenu->Display();
break;
/*
* --------- COMMON ---------------------------------
*/
case rmsClose: {
if (activeMenuBuffer == NULL) {
state = osEnd;
Close();
} else {
delete activeMenu;
activeMenu = activeMenuBuffer;
activeMenuBuffer = NULL;
activeMenu->Show();
state = osContinue;
}
break; }
default:
break;
}
return state;
}
bool cRecMenuManager::displayTimerConflict(cTimer *timer) {
int timerID = 0;
for (cTimer *t = Timers.First(); t; t = Timers.Next(t)) {
if (t == timer)
return displayTimerConflict(timerID);
timerID++;
}
return false;
}
bool cRecMenuManager::displayTimerConflict(int timerID) {
conflictList = recManager->CheckTimerConflict();
int numConflicts = conflictList.size();
int showTimerConflict = -1;
if (numConflicts > 0) {
for (int i=0; i<numConflicts; i++) {
if (conflictList[i].timerInvolved(timerID)) {
showTimerConflict = i;
break;
}
}
}
if (showTimerConflict > -1) {
currentConflict = showTimerConflict;
activeMenu = new cRecMenuTimerConflict(conflictList[currentConflict]);
activeMenu->Display();
return true;
}
return false;
}
bool cRecMenuManager::createSearchTimer(std::string epgSearchString) {
int newTimerID = recManager->CreateSearchTimer(epgSearchString);
bool success = false;
if (newTimerID > -1) {
recManager->UpdateSearchTimers();
success = true;
}
return success;
}
eOSState cRecMenuManager::ProcessKey(eKeys Key) {
eOSState state = osContinue;
eRecMenuState nextState = rmsContinue;
if (!activeMenu)
return state;
if (detailViewActive) {
state = detailView->ProcessKey(Key);
if (state == osEnd) {
delete detailView;
detailView = NULL;
detailViewActive = false;
activeMenu->Show();
state = osContinue;
}
} else {
nextState = activeMenu->ProcessKey(Key);
if ((nextState == rmsClose) || ((nextState == rmsNotConsumed)&&(Key == kBack))){
if (activeMenuBuffer == NULL) {
state = osEnd;
Close();
} else {
delete activeMenu;
activeMenu = activeMenuBuffer;
activeMenuBuffer = NULL;
activeMenu->Show();
state = osContinue;
osdManager.flush();
}
return state;
}
state = StateMachine(nextState);
}
osdManager.flush();
return state;
}
|