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
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
|
/**
* GraphTFTng plugin for the Video Disk Recorder
*
* status.c
*
* (c) 2013-2013 Jörg Wendel
*
* This code is distributed under the terms and conditions of the
* GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
*
**/
//***************************************************************************
// Includes
//***************************************************************************
#include <display.h>
//***************************************************************************
// Osd Channel Switch
//***************************************************************************
void cGraphTFTDisplay::ChannelSwitch(const cDevice* Device, int ChannelNumber, bool LiveView)
{
tell(5, "ChannelSwitch on %p: %d", Device, ChannelNumber);
if (LiveView
&& _channel != ChannelNumber
&& cDevice::CurrentChannel() != _channel)
{
needLock = yes;
cMutexLock lock(&_mutex);
_rds.title.clear();
_rds.artist.clear();
_rds.text.clear();
_channel = ChannelNumber;
_channelGroup = "";
_presentEvent.reset();
_followingEvent.reset();
_event.reset();
_presentChannel = 0;
triggerChannelUpdate = yes;
updateGroup(groupChannel);
broadcast();
}
}
//***************************************************************************
// Osd Channel
//***************************************************************************
void cGraphTFTDisplay::OsdChannel(const char* text)
{
tell(5, "OsdChannel: '%s'", text);
_channelGroup = text;
updateGroup(groupChannel);
broadcast();
}
//***************************************************************************
// Osd Set Event
//***************************************************************************
void cGraphTFTDisplay::OsdSetEvent(const cEvent* event)
{
tell(5, "OsdSetEvent: '%s'", event ? event->Title() : "");
_event.set(event);
updateGroup(groupChannel);
}
//***************************************************************************
// Osd Set Recording
//***************************************************************************
void cGraphTFTDisplay::OsdSetRecording(const cRecording* recording)
{
tell(5, "OsdSetRecording: '%s'", recording ? recording->Title() : "");
_recording = recording ? recording->FileName() : "";
}
//***************************************************************************
// Osd Programme
//***************************************************************************
void cGraphTFTDisplay::OsdProgramme(time_t PresentTime, const char* PresentTitle,
const char* PresentSubtitle, time_t FollowingTime,
const char* FollowingTitle, const char* FollowingSubtitle)
{
needLock = yes;
cMutexLock lock(&_mutex);
if (PresentTitle)
_rds.title = PresentTitle;
else
_rds.title = "";
if (PresentSubtitle)
_rds.artist = PresentSubtitle;
else
_rds.artist = "";
broadcast();
}
//***************************************************************************
// Set Volume
//***************************************************************************
void cGraphTFTDisplay::SetVolume(int, bool)
{
tell(5, "SetVolume to %d, muted is %s",
cDevice::CurrentVolume(),
cDevice::PrimaryDevice()->IsMute() ? "true" : "false");
if (_volume != cDevice::CurrentVolume()
|| _mute != cDevice::PrimaryDevice()->IsMute())
{
needLock = yes;
cMutexLock lock(&_mutex);
_volume = cDevice::CurrentVolume();
_mute = cDevice::PrimaryDevice()->IsMute();
updateGroup(groupVolume);
broadcast(yes);
}
}
//***************************************************************************
// Recording
//***************************************************************************
void cGraphTFTDisplay::Recording(const cDevice* Device, const char* Name,
const char* FileName, bool On)
{
tell(5, "Recording %s to %p", Name, Device);
triggerTimerUpdate = yes;
broadcast();
}
//***************************************************************************
// Timer Change
//***************************************************************************
void cGraphTFTDisplay::TimerChange(const cTimer *Timer, eTimerChange Change)
{
tell(5, "TimerChange %s - %d ", Timer ? Timer->File() : "", Change);
triggerTimerUpdate = yes;
broadcast();
}
//***************************************************************************
// Replaying
//***************************************************************************
void cGraphTFTDisplay::Replaying(const cControl* Control, const char* Name,
const char* FileName, bool On)
{
static const char* suffixes[] = { ".ogg", ".mpg", ".mpeg", ".mp3", ".avi", 0 };
tell(5, "Replaying '%s' of '%s' file '%s'; control* is (%p)",
On ? "start" : "stop",
Name, Str::notNull(FileName),
Control);
needLock = yes;
cMutexLock lock(&_mutex);
if (On)
{
string::size_type i, n;
if (!Name) Name = "";
_replay.control = (cControl*)Control;
_replay.lastMode = _mode;
setMode(ReplayNormal);
_replay.fileName = Str::notNull(FileName);
// OsdSetRecording(Recordings.GetByName(Str::notNull(FileName)));
if (strlen(Name) > 6 && Name[0]=='[' && Name[3]==']' && Name[5]=='(')
{
for (i = 6; Name[i]; ++i)
{
if (Name[i] == ' ' && Name[i-1] == ')')
break;
}
if (Name[i])
{
// replaying mp3
const char* name = skipspace(Name + i);
_replay.name = *name ? name : tr("Unknown title");
setMode(ReplayMP3);
}
}
else if (strcmp(Name, "image") == 0)
{
if (!FileName)
_replay.name = Name;
else
_replay.name = basename(FileName);
setMode(ReplayImage);
}
else if (strcmp(Name, "DVD") == 0)
{
_replay.name = Name;
setMode(ReplayDVD);
}
else if (strlen(Name) > 7)
{
for (i = 1, n = 0; Name[i]; ++i)
{
if (Name[i] == ' ' && Name[i-1] == ',' && ++n == 4)
break;
}
if (Name[i])
{
// replaying DVD
const char *name = skipspace(Name + i);
_replay.name = *name ? name : tr("Unknown title");
replace(_replay.name.begin(), _replay.name.end(), '_', ' ');
setMode(ReplayDVD);
}
}
if (_mode == ReplayNormal)
{
_replay.name = Name;
if ((i = _replay.name.rfind('~')) != string::npos)
_replay.name.erase(0, i + 1);
}
char* tmp;
asprintf(&tmp, "%s", _replay.name.c_str());
_replay.name = Str::allTrim(tmp);
free(tmp);
for (int l = 0; suffixes[l]; l++)
{
if ((i = _replay.name.rfind(suffixes[l])) != string::npos)
_replay.name.erase(i);
}
tell(5, "reformatted name is '%s'", _replay.name.c_str());
updateGroup(groupReplay);
broadcast();
}
else
{
_replay.control = 0;
_replay.name = "";
_replay.fileName = "";
setMode(NormalView);
broadcast();
}
}
//***************************************************************************
// Osd Status Message
//***************************************************************************
void cGraphTFTDisplay::OsdStatusMessage(const char* Message)
{
tell(5, "OsdStatusMessage %s", Message);
needLock = yes;
cMutexLock lock(&_mutex);
int force = _message != "";
_message = Message ? Message : "";
updateGroup(groupMessage);
broadcast(force);
}
//***************************************************************************
// Osd Title
//***************************************************************************
void cGraphTFTDisplay::OsdTitle(const char* Title)
{
tell(5, "OsdTitle %s", Title);
if (Title)
{
string::size_type pos;
needLock = yes;
cMutexLock lock(&_mutex);
_message = "";
_menu.title = Title;
if ((pos = _menu.title.find('\t')) != string::npos)
_menu.title.erase(pos);
}
}
//***************************************************************************
// Osd Event Item (called after corresponding OsdItem!)
//***************************************************************************
void cGraphTFTDisplay::OsdEventItem(const cEvent* Event, const char* Text,
int Index, int Count)
{
tell(5, "OsdEventItem '%s' at index (%d), count (%d)",
Event ? Event->Title() : "<null>", Index, Count);
needLock = yes;
cMutexLock lock(&_mutex);
_eventsReady = no;
if (_menu.items.size() <= (unsigned int)Index)
{
tell(1, "Got unexpected index %d, count is %ld", Index, _menu.items.size());
return;
}
if (_menu.items[Index].text != Text)
tell(0, "Fatal: Item index don't match!");
else if (Event)
_menu.items[Index].event.set(Event);
if (Index == Count-1)
{
tell(3, "OsdEventItem() Force update due to index/count (%d/%d)", Index, Count);
triggerFinalizeItemList = yes;
updateGroup(groupMenu);
broadcast();
}
}
//***************************************************************************
// Osd Item
//***************************************************************************
void cGraphTFTDisplay::OsdItem(const char* Text, int Index)
{
MenuItem item;
tell(5, "OsdItem '%s' at index (%d)", Text, Index);
needLock = yes;
cMutexLock lock(&_mutex);
_eventsReady = no;
if (!Text)
Text = "";
item.text = Text;
item.type = itNormal;
item.event.reset();
item.channel = 0;
item.tabCount = 0;
int count = 1;
char* pp;
_menu.currentRow = na;
const char* p = Text;
while (*p)
{
if (*p == '\t')
count++;
p++;
}
_message = "";
for (int i = 0; i < MaxTabs; ++i)
{
const char* tp = getTabbedText(Text, i);
if (tp)
{
char* tab;
int len;
tab = strdup(tp);
len = strlen(Str::allTrim(tab));
// bigger than last row ?
if (_menu.charInTabs[i] < len)
_menu.charInTabs[i] = len;
// detect partingLine
if (i == 0 && strstr(tab, "-----") && (pp = strchr(tab, ' ')))
{
char* e;
*pp = 0;
pp++;
item.type = itPartingLine;
if ((e = strchr(pp, ' ')))
*e = 0;
item.tabs[0] = Str::allTrim(pp);
}
else if (strstr(tab, "-----") && count < 2)
{
// arghdirector
item.type = itPartingLine;
item.tabs[0] = "";
}
else if (i == 1 && strstr(item.tabs[0].c_str(), "-----"))
{
char* p;
// some special handling for lines of epgsearch plugin like
// ---------------------------------- \t Die 24.10.2006 ------------------------
item.type = itPartingLine;
if ((p = strstr(tab, " ---")))
*p = 0;
if (!strstr(tab, "-----"))
item.tabs[0] = Str::allTrim(tab);
else
item.tabs[0] = "";
tell(5, "Detected parting line '%s'", item.tabs[0].c_str());
}
else
{
item.tabs[i] = tab;
item.recordingName = tab; // vermeintlicher name ...
}
tell(5, "tab (%d) '%s'", i, tp);
item.tabCount++;
free(tab);
}
else
break;
}
tell(4, "adding item with (%d) tabs", item.tabCount);
_menu.items.push_back(item);
}
//***************************************************************************
// Osd Current Item
//***************************************************************************
void cGraphTFTDisplay::OsdCurrentItem(const char* Text)
{
if (!Text)
Text = "";
tell(3, "OsdCurrentItem '%s'", Text);
string text = Text;
if (text != _menu.current)
{
int i;
needLock = yes;
cMutexLock lock(&_mutex);
_message = "";
_menu.current = text;
// lookup the item in the list and set the new current position
for (i = 0; i < (int)_menu.items.size(); i++)
{
if (_menu.items[i].text == _menu.current)
{
_menu.currentRow = i;
updateGroup(groupMenu);
broadcast();
return ;
}
}
// We don't have found the item, resume
// old one with changed values ...
if (_menu.currentRow < 0 || _menu.currentRow >= (int)_menu.items.size())
return ;
tell(5, "OsdCurrentItem: Text of current item changed to %s", Text);
// #if __GNUC__ < 3
// MenuItem* item = _menu.items[_menu.currentRow];
// #else
// MenuItem* item = _menu.items.at(_menu.currentRow);
// #endif
_menu.items[_menu.currentRow].text = Text;
for (int i = 0; i < MaxTabs; ++i)
{
const char* tab = getTabbedText(Text, i);
if (tab)
_menu.items[_menu.currentRow].tabs[i] = tab;
if (getTabbedText(Text, i+1) == 0)
break;
}
updateGroup(groupMenu);
broadcast();
}
}
//***************************************************************************
// Osd Clear
//***************************************************************************
void cGraphTFTDisplay::OsdClear()
{
string cg = _channelGroup;
tell(0, "OsdClear");
needLock = yes;
cMutexLock lock(&_mutex);
_menu.title = "";
_menu.items.clear();
_eventsReady = no;
_menu.text = "";
_menu.current = "";
_channelGroup = "";
_menu.charInTabs[0] = _menu.charInTabs[1] = _menu.charInTabs[2] =
_menu.charInTabs[3] = _menu.charInTabs[4] = _menu.charInTabs[5] = 0;
if (_message != "" || cg != "")
{
_message = "";
updateGroup(groupMessage);
broadcast(yes);
}
}
//***************************************************************************
// Osd Help Keys
//***************************************************************************
void cGraphTFTDisplay::OsdHelpKeys(const char* Red, const char* Green,
const char* Yellow, const char* Blue)
{
tell(5, "OsdHelpKeys: '%s', '%s', '%s', '%s'", Red, Green, Yellow, Blue);
string red = Red ? Red : "";
string green = Green ? Green : "";
string yellow = Yellow ? Yellow : "";
string blue = Blue ? Blue : "";
if (_menu.buttons[0] != red ||
_menu.buttons[1] != green ||
_menu.buttons[2] != yellow ||
_menu.buttons[3] != blue)
{
needLock = yes;
cMutexLock lock(&_mutex);
_menu.buttons[0] = red;
_menu.buttons[1] = green;
_menu.buttons[2] = yellow;
_menu.buttons[3] = blue;
updateGroup(groupButton);
broadcast();
}
}
//***************************************************************************
// Osd Text Item
//***************************************************************************
void cGraphTFTDisplay::OsdTextItem(const char* Text, bool Scroll)
{
tell(5, "OsdTextItem: '%s' scroll: %d", Text, Scroll);
if (!Text)
Text = "";
needLock = yes;
cMutexLock lock(&_mutex);
_rds.text = Text;
_menu.text = Text;
broadcast();
}
//***************************************************************************
// Osd Menu Display
//***************************************************************************
#if defined _OLD_PATCH
void cGraphTFTDisplay::OsdMenuDisplay(const char* kind)
{
tell(5, "OsdMenuDisplay - kind '%s'", kind);
if (!isModeMenu(_mode))
_menu.lastMode = _mode;
setMode(ModeMenu, kind);
}
#else
void cGraphTFTDisplay::OsdMenuDisplay(eMenuCategory category)
{
struct cCategorie
{
eMenuCategory category;
const char* name;
};
cCategorie categories[] =
{
{ mcUnknown, "Menu" },
{ mcMain, "MenuMain" },
{ mcSchedule, "MenuSchedule" },
{ mcScheduleNow, "MenuWhatsOnNow" },
{ mcScheduleNext, "MenuWhatsOnNext" },
{ mcChannel, "MenuChannels" },
{ mcChannelEdit, "MenuEditChannel" } ,
{ mcTimer, "MenuTimers" },
{ mcTimerEdit, "MneuTimerEdit" },
{ mcRecording, "MenuRecordings" },
{ mcRecordingInfo, "MenuRecording" },
{ mcRecordingEdit, "MenuRecordingEdit" },
{ mcPlugin, "MenuPlugin" },
{ mcPluginSetup, "MenuPluginSetup" },
{ mcSetup, "MenuSetup" },
{ mcSetupOsd, "MenuSetupOsd" },
{ mcSetupEpg, "MenuSetupEpg" },
{ mcSetupDvb, "MenuSetupDvb" },
{ mcSetupLnb, "MenuSetupLnb" },
{ mcSetupCam, "MenuSetupCam" },
{ mcSetupRecord, "MenuSetupRecord" },
{ mcSetupReplay, "MenuSetupReplay" },
{ mcSetupMisc, "MenuSetupMisc" },
{ mcSetupPlugins, "MenuSetupPlugins" },
{ mcCommand, "MenuCommand" },
{ mcEvent, "MenuEvent" },
{ mcText, "MenuText" },
{ mcFolder, "MenuFolder" },
{ mcCam, "MenuCam" },
{ mcUndefined, "Menu" }
};
const char* categoryName = "MenuUnknown";
if (category > mcUndefined && category <= mcCam)
categoryName = categories[category].name;
tell(0, "OsdMenuDisplay - set category (%d) to '%s'", category, categoryName);
if (!isModeMenu(_mode))
_menu.lastMode = _mode;
setMode(ModeMenu, categoryName);
}
#endif
//***************************************************************************
// Osd Menu Destroy
//***************************************************************************
void cGraphTFTDisplay::OsdMenuDestroy()
{
tell(5, "OsdMenuDestroy");
triggerTimerUpdate = yes;
// all menues closed !
if (isModeMenu(_mode)) // 'if' is needed for replay via extrecmenu
setMode(_menu.lastMode);
broadcast();
}
|