/
epgview.cpp
1780 lines (1618 loc) · 53.6 KB
/
epgview.cpp
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
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Copyright (C) 2007-2014 Stefan Seyfried
Copyright (C) 2018 Thilo Graf
License: GPL
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <algorithm>
#include <unistd.h>
#include "adzap.h"
#include "epgview.h"
#include "eventlist.h"
#include "rate_banner.h"
#include <gui/widget/buttons.h>
#include <gui/widget/hintbox.h>
#include <gui/widget/icons.h>
#include <gui/widget/msgbox.h>
#include <gui/widget/mountchooser.h>
#include "timerlist.h"
#include <zapit/zapit.h>
#include <system/helpers.h>
#include <system/mdb-tools.h>
#include <global.h>
#include <neutrino.h>
#include <driver/screen_max.h>
#include <driver/fade.h>
#include <gui/filebrowser.h>
#include <gui/followscreenings.h>
#include <gui/moviebrowser/mb.h>
#include <gui/movieplayer.h>
#include <gui/pictureviewer.h>
#include <driver/record.h>
#include <driver/fontrenderer.h>
#include <zapit/bouquets.h>
#include <zapit/getservices.h>
#include <eitd/sectionsd.h>
#include <timerdclient/timerdclient.h>
extern CPictureViewer * g_PicViewer;
#define ICON_LARGE_WIDTH 26
int findItem(std::string strItem, std::vector<std::string> & vecItems) {
for (std::vector<std::string>::size_type nCnt = 0; nCnt < vecItems.size(); nCnt++) {
std::string strThisItem = vecItems[nCnt];
if (strItem == strThisItem) {
return nCnt;
}
}
return -1;
}
// 21.07.2005 - rainerk
// Merge multiple extended event strings into one description and localize the label
// Examples:
// Actor1-ActorX -> Darsteller 1, 2, 3
// Year of production -> Produktionsjahr
// Director -> Regisseur
// Guests -> Gäste
void reformatExtendedEvents(std::string strItem, std::string strLabel, bool bUseRange, CEPGData & epgdata) {
std::vector<std::string> & vecDescriptions = epgdata.itemDescriptions;
std::vector<std::string> & vecItems = epgdata.items;
// Merge multiple events into 1 (Actor1-)
if (bUseRange) {
bool bHasItems = false;
char index[3];
// Maximum of 10 items should suffice
for (int nItem = 1; nItem < 11; nItem++) {
sprintf(index, "%d", nItem);
// Look for matching items
int nPos = findItem(std::string(strItem) + std::string(index), vecDescriptions);
if (nPos != -1) {
std::string item = std::string(vecItems[nPos]);
vecDescriptions.erase(vecDescriptions.begin() + nPos);
vecItems.erase(vecItems.begin() + nPos);
if (false == bHasItems) {
// First item added, so create new label item
vecDescriptions.push_back(strLabel);
vecItems.push_back(item + ", ");
bHasItems = true;
} else {
vecItems.back().append(item).append(", ");
}
}
}
// Remove superfluous ", "
if (bHasItems) {
vecItems.back().resize(vecItems.back().length() - 2);
}
} else { // Single string event (e.g. Director)
// Look for matching items
int nPos = findItem(strItem, vecDescriptions);
if (nPos != -1) {
vecDescriptions[nPos] = strLabel;
}
}
}
CEpgData::CEpgData()
{
bigFonts = false;
frameBuffer = CFrameBuffer::getInstance();
mp_movie_info = NULL;
header = NULL;
Bottombox = NULL;
pb = NULL;
font_title = NULL;
imdb = CIMDB::getInstance();
tmdb = CTMDB::getInstance();
ResetMDb();
movie_filename.clear();
}
CEpgData::~CEpgData()
{
ResetModules();
}
void CEpgData::start()
{
ox = frameBuffer->getWindowWidth(bigFonts ? false /* big */ : true /* small */);
oy = frameBuffer->getWindowHeight(bigFonts ? false /* big */ : true /* small */);
font_title = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE];
topheight = font_title->getHeight();
topboxheight = topheight + 6;
botboxheight = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->getHeight() + 2*OFFSET_INNER_MIN;
// not really a CComponentsFooter but let's take its height
CComponentsFooter footer;
buttonheight = footer.getHeight();
oy-=buttonheight/2;
/* this is the text box height - and the height of the scroll bar */
sb = oy - topboxheight - botboxheight - buttonheight;
/* button box is handled separately (why?) */
oy -= buttonheight;
medlineheight = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->getHeight();
medlinecount = sb / medlineheight;
toph = topboxheight;
sx = getScreenStartX(ox);
sy = getScreenStartY(oy + buttonheight); /* button box is handled separately (why?) */
}
void CEpgData::addTextToArray(const std::string & text, int screening) // UTF-8
{
//printf("line: >%s<\n", text.c_str() );
if (text==" ")
{
emptyLineCount ++;
if (emptyLineCount<2)
{
epgText.push_back(epg_pair(text,screening));
}
}
else
{
emptyLineCount = 0;
epgText.push_back(epg_pair(text,screening));
}
}
void CEpgData::processTextToArray(std::string text, int screening, bool has_cover) // UTF-8
{
std::string aktLine = "";
std::string aktWord = "";
int aktWidth = 0;
text += ' ';
char* text_= (char*) text.c_str();
while (*text_!=0)
{
if ( (*text_==' ') || (*text_=='\n') || (*text_=='-') || (*text_=='.') )
{
// Houdini: if there is a newline (especially in the Premiere Portal EPGs) do not forget to add aktWord to aktLine
// after width check, if width check failes do newline, add aktWord to next line
// and "reinsert" i.e. reloop for the \n
if (*text_!='\n')
aktWord += *text_;
// check the wordwidth - add to this line if size ok
int aktWordWidth = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->getRenderWidth(aktWord);
if ((aktWordWidth+aktWidth)<(ox - 2*OFFSET_INNER_MID - SCROLLBAR_WIDTH - (has_cover ? ((ox/4)+OFFSET_INNER_MID) : 0)))
{//space ok, add
aktWidth += aktWordWidth;
aktLine += aktWord;
if (*text_=='\n')
{ //enter-handler
addTextToArray( aktLine, screening );
aktLine = "";
aktWidth= 0;
}
aktWord = "";
}
else
{//new line needed
addTextToArray( aktLine, screening);
aktLine = aktWord;
aktWidth = aktWordWidth;
aktWord = "";
// Houdini: in this case where we skipped \n and space is too low, exec newline and rescan \n
// otherwise next word comes direct after aktLine
if (*text_=='\n')
continue;
}
}
else
{
aktWord += *text_;
}
text_++;
}
//add the rest
addTextToArray( aktLine + aktWord, screening );
}
void CEpgData::showText(int startPos, int ypos, bool has_cover, bool fullClear)
{
Font* font = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2];
std::string cover = "";
int cover_max_width = ox/4; //25%
int cover_max_height = sb-(2*OFFSET_INNER_MID);
int cover_width = 0;
int cover_height = 0;
int cover_offset = 0;
if (has_cover)
{
if (imdb_active)
cover = imdb->getPoster();
else if (tmdb_active)
cover = tmdb->getPoster();
g_PicViewer->getSize(cover.c_str(), &cover_width, &cover_height);
if (cover_width && cover_height)
{
g_PicViewer->rescaleImageDimensions(&cover_width, &cover_height, cover_max_width, cover_max_height);
cover_offset = cover_width + OFFSET_INNER_MID;
}
}
int textSize = epgText.size();
int y=ypos;
const char tok = ' ';
int offset = 0, count = 0;
int max_mon_w = 0, max_wday_w = 0;
int digi = font->getRenderWidth("29..");
for(int i = 0; i < 12;i++){
max_mon_w = std::max(max_mon_w, font->getRenderWidth(std::string(g_Locale->getText(CLocaleManager::getMonth(i))) + " "));
if(i > 6)
continue;
max_wday_w = std::max(max_wday_w, font->getRenderWidth(std::string(g_Locale->getText(CLocaleManager::getWeekday(i))) + " "));
}
int offs = fullClear ? 0 : cover_offset;
frameBuffer->paintBoxRel(sx+offs, y, ox-SCROLLBAR_WIDTH-offs, sb, COL_MENUCONTENT_PLUS_0); // background of the text box
if (has_cover)
{
if (!g_PicViewer->DisplayImage(cover ,sx+OFFSET_INNER_MID ,y+OFFSET_INNER_MID, cover_width, cover_height, CFrameBuffer::TM_NONE))
{
cover_offset = 0;
frameBuffer->paintBoxRel(sx, y, ox-SCROLLBAR_WIDTH, sb, COL_MENUCONTENT_PLUS_0); // background of the text box
}
/* FIXME
else
{
char hint[1024];
snprintf(hint, sizeof(hint), g_Locale->getText(LOCALE_MDB_SAVE_POSTER_HINT), g_RCInput->getKeyName((neutrino_msg_t) g_settings.mbkey_cover).c_str());
int dynfont_width = cover_width;
int dynfont_height = font->getHeight();
Font *dynfont = *CNeutrinoFonts::getInstance()->getDynFont(dynfont_width, dynfont_height, hint);
dynfont->RenderString(sx+OFFSET_INNER_MID, y+OFFSET_INNER_MID+cover_height+OFFSET_INNER_MID+dynfont->getHeight(), dynfont_width, hint, COL_MENUCONTENT_TEXT);
}
*/
}
// recalculate
medlineheight = font->getHeight();
medlinecount = sb / medlineheight;
if (startPos == 0 && (imdb_active || tmdb_active))
{
std::string provider_logo = "";
int stars = 0;
if (imdb_active)
{
provider_logo = NEUTRINO_ICON_IMDB;
stars = imdb_stars;
}
else if (tmdb_active)
{
provider_logo = NEUTRINO_ICON_TMDB;
stars = tmdb_stars;
}
int logo_offset = 0;
int logo_w = 0;
int logo_h = 0;
if (!provider_logo.empty())
{
frameBuffer->getIconSize(provider_logo.c_str(), &logo_w, &logo_h);
frameBuffer->paintIcon(provider_logo.c_str(), sx+OFFSET_INNER_MID+cover_offset, y, medlineheight);
logo_offset = logo_w + OFFSET_INNER_MID;
}
// show ranking
if (stars > 0)
{
int stars_w = 0, stars_h = 0;
frameBuffer->getIconSize(NEUTRINO_ICON_STARS_BG, &stars_w, &stars_h);
//create starbar item
CProgressBar *cc_starbar = new CProgressBar();
cc_starbar->setProgress(sx+OFFSET_INNER_MID+cover_offset+logo_offset, y+(medlineheight-stars_h)/2, stars_w, medlineheight, stars, 100);
cc_starbar->setType(CProgressBar::PB_STARBAR);
cc_starbar->paint();
medlinecount = (sb - cc_starbar->getHeight()) / medlineheight;
delete cc_starbar;
}
y += medlineheight;
}
for (int i = startPos; i < textSize && i < startPos + medlinecount; i++, y += medlineheight)
{
if(epgText[i].second){ // screening
std::string::size_type pos1 = epgText[i].first.find_first_not_of(tok, 0);
std::string::size_type pos2 = epgText[i].first.find_first_of(tok, pos1);
while( pos2 != std::string::npos || pos1 != std::string::npos ){
switch(count){
case 1:
offset += max_wday_w;
break;
case 3:
offset += max_mon_w;
break;
default:
offset += digi;
break;
}
font->RenderString(sx+OFFSET_INNER_MID+offset, y+medlineheight, ox - SCROLLBAR_WIDTH - 2*OFFSET_INNER_MID - offset, epgText[i].first.substr(pos1, pos2 - pos1), (epgText[i].second==2)? COL_MENUCONTENTINACTIVE_TEXT: COL_MENUCONTENT_TEXT);
count++;
pos1 = epgText[i].first.find_first_not_of(tok, pos2);
pos2 = epgText[i].first.find_first_of(tok, pos1);
}
offset = 0;
count = 0;
}
else{ // epgtext
g_Font[( i< info1_lines ) ?SNeutrinoSettings::FONT_TYPE_EPG_INFO1:SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->RenderString(sx+OFFSET_INNER_MID+cover_offset, y+medlineheight, ox - SCROLLBAR_WIDTH - 2*OFFSET_INNER_MID - cover_offset, epgText[i].first, COL_MENUCONTENT_TEXT);
}
}
int total_pages;
int current_page;
getScrollBarData(&total_pages, ¤t_page, textSize, medlinecount, startPos + 1);
paintScrollBar(sx + ox - SCROLLBAR_WIDTH, ypos, SCROLLBAR_WIDTH, sb, total_pages, current_page);
}
#define GENRE_MOVIE_COUNT 9
const neutrino_locale_t genre_movie[GENRE_MOVIE_COUNT] =
{
LOCALE_GENRE_MOVIE_0,
LOCALE_GENRE_MOVIE_1,
LOCALE_GENRE_MOVIE_2,
LOCALE_GENRE_MOVIE_3,
LOCALE_GENRE_MOVIE_4,
LOCALE_GENRE_MOVIE_5,
LOCALE_GENRE_MOVIE_6,
LOCALE_GENRE_MOVIE_7,
LOCALE_GENRE_MOVIE_8
};
#define GENRE_NEWS_COUNT 5
const neutrino_locale_t genre_news[GENRE_NEWS_COUNT] =
{
LOCALE_GENRE_NEWS_0,
LOCALE_GENRE_NEWS_1,
LOCALE_GENRE_NEWS_2,
LOCALE_GENRE_NEWS_3,
LOCALE_GENRE_NEWS_4
};
#define GENRE_SHOW_COUNT 4
const neutrino_locale_t genre_show[GENRE_SHOW_COUNT] =
{
LOCALE_GENRE_SHOW_0,
LOCALE_GENRE_SHOW_1,
LOCALE_GENRE_SHOW_2,
LOCALE_GENRE_SHOW_3
};
#define GENRE_SPORTS_COUNT 12
const neutrino_locale_t genre_sports[GENRE_SPORTS_COUNT] =
{
LOCALE_GENRE_SPORTS_0,
LOCALE_GENRE_SPORTS_1,
LOCALE_GENRE_SPORTS_2,
LOCALE_GENRE_SPORTS_3,
LOCALE_GENRE_SPORTS_4,
LOCALE_GENRE_SPORTS_5,
LOCALE_GENRE_SPORTS_6,
LOCALE_GENRE_SPORTS_7,
LOCALE_GENRE_SPORTS_8,
LOCALE_GENRE_SPORTS_9,
LOCALE_GENRE_SPORTS_10,
LOCALE_GENRE_SPORTS_11
};
#define GENRE_CHILDRENS_PROGRAMMES_COUNT 6
const neutrino_locale_t genre_childrens_programmes[GENRE_CHILDRENS_PROGRAMMES_COUNT] =
{
LOCALE_GENRE_CHILDRENS_PROGRAMMES_0,
LOCALE_GENRE_CHILDRENS_PROGRAMMES_1,
LOCALE_GENRE_CHILDRENS_PROGRAMMES_2,
LOCALE_GENRE_CHILDRENS_PROGRAMMES_3,
LOCALE_GENRE_CHILDRENS_PROGRAMMES_4,
LOCALE_GENRE_CHILDRENS_PROGRAMMES_5
};
#define GENRE_MUSIC_DANCE_COUNT 7
const neutrino_locale_t genre_music_dance[GENRE_MUSIC_DANCE_COUNT] =
{
LOCALE_GENRE_MUSIC_DANCE_0,
LOCALE_GENRE_MUSIC_DANCE_1,
LOCALE_GENRE_MUSIC_DANCE_2,
LOCALE_GENRE_MUSIC_DANCE_3,
LOCALE_GENRE_MUSIC_DANCE_4,
LOCALE_GENRE_MUSIC_DANCE_5,
LOCALE_GENRE_MUSIC_DANCE_6
};
#define GENRE_ARTS_COUNT 12
const neutrino_locale_t genre_arts_dance[GENRE_ARTS_COUNT] =
{
LOCALE_GENRE_ARTS_0,
LOCALE_GENRE_ARTS_1,
LOCALE_GENRE_ARTS_2,
LOCALE_GENRE_ARTS_3,
LOCALE_GENRE_ARTS_4,
LOCALE_GENRE_ARTS_5,
LOCALE_GENRE_ARTS_6,
LOCALE_GENRE_ARTS_7,
LOCALE_GENRE_ARTS_8,
LOCALE_GENRE_ARTS_9,
LOCALE_GENRE_ARTS_10,
LOCALE_GENRE_ARTS_11
};
#define GENRE_SOCIAL_POLITICAL_COUNT 4
const neutrino_locale_t genre_social_political[GENRE_SOCIAL_POLITICAL_COUNT] =
{
LOCALE_GENRE_SOCIAL_POLITICAL_0,
LOCALE_GENRE_SOCIAL_POLITICAL_1,
LOCALE_GENRE_SOCIAL_POLITICAL_2,
LOCALE_GENRE_SOCIAL_POLITICAL_3
};
#define GENRE_DOCUS_MAGAZINES_COUNT 8
const neutrino_locale_t genre_docus_magazines[GENRE_DOCUS_MAGAZINES_COUNT] =
{
LOCALE_GENRE_DOCUS_MAGAZINES_0,
LOCALE_GENRE_DOCUS_MAGAZINES_1,
LOCALE_GENRE_DOCUS_MAGAZINES_2,
LOCALE_GENRE_DOCUS_MAGAZINES_3,
LOCALE_GENRE_DOCUS_MAGAZINES_4,
LOCALE_GENRE_DOCUS_MAGAZINES_5,
LOCALE_GENRE_DOCUS_MAGAZINES_6,
LOCALE_GENRE_DOCUS_MAGAZINES_7
};
#define GENRE_TRAVEL_HOBBIES_COUNT 8
const neutrino_locale_t genre_travel_hobbies[GENRE_TRAVEL_HOBBIES_COUNT] =
{
LOCALE_GENRE_TRAVEL_HOBBIES_0,
LOCALE_GENRE_TRAVEL_HOBBIES_1,
LOCALE_GENRE_TRAVEL_HOBBIES_2,
LOCALE_GENRE_TRAVEL_HOBBIES_3,
LOCALE_GENRE_TRAVEL_HOBBIES_4,
LOCALE_GENRE_TRAVEL_HOBBIES_5,
LOCALE_GENRE_TRAVEL_HOBBIES_6,
LOCALE_GENRE_TRAVEL_HOBBIES_7
};
const unsigned char genre_sub_classes[10] =
{
GENRE_MOVIE_COUNT,
GENRE_NEWS_COUNT,
GENRE_SHOW_COUNT,
GENRE_SPORTS_COUNT,
GENRE_CHILDRENS_PROGRAMMES_COUNT,
GENRE_MUSIC_DANCE_COUNT,
GENRE_ARTS_COUNT,
GENRE_SOCIAL_POLITICAL_COUNT,
GENRE_DOCUS_MAGAZINES_COUNT,
GENRE_TRAVEL_HOBBIES_COUNT
};
const neutrino_locale_t * genre_sub_classes_list[10] =
{
genre_movie,
genre_news,
genre_show,
genre_sports,
genre_childrens_programmes,
genre_music_dance,
genre_arts_dance,
genre_social_political,
genre_docus_magazines,
genre_travel_hobbies
};
const char * GetGenre(const unsigned char contentClassification) // UTF-8
{
neutrino_locale_t res;
//unsigned char i = (contentClassification & 0x0F0);
int i = (contentClassification & 0xF0);
//printf("GetGenre: contentClassification %X i %X bool %s\n", contentClassification, i, i < 176 ? "yes" : "no"); fflush(stdout);
if ((i >= 0x010) && (i < 0x0B0))
{
i >>= 4;
i--;
//printf("GetGenre: i %d content %d\n", i, contentClassification & 0x0F); fflush(stdout);
res = genre_sub_classes_list[i][((contentClassification & 0x0F) < genre_sub_classes[i]) ? (contentClassification & 0x0F) : 0];
}
else
res = LOCALE_GENRE_UNKNOWN;
return g_Locale->getText(res);
}
static bool sortByDateTime (const CChannelEvent& a, const CChannelEvent& b)
{
return a.startTime< b.startTime;
}
bool CEpgData::isCurrentEPG(const t_channel_id channel_id)
{
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
if(( epg_done!= -1 ) && live_channel_id == channel_id){
return true;
}
return false;
}
int CEpgData::show_mp(MI_MOVIE_INFO *mi, int mp_position, int mp_duration, bool doLoop)
{
int res = menu_return::RETURN_REPAINT;
mp_movie_info = mi;
if (mp_movie_info == NULL)
return res;
if (mp_movie_info->epgTitle.empty()) /* no epg info found */
{
ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_EPGVIEWER_NOTFOUND)); // UTF-8
hide();
return res;
}
epgText.clear();
epgData.title = mp_movie_info->epgTitle;
epgData.info1 = mp_movie_info->epgInfo1;
epgData.info2 = mp_movie_info->epgInfo2;
movie_filename = mp_movie_info->file.Name;
epgData.itemDescriptions.clear();
epgData.items.clear();
epgData.fsk = mp_movie_info->parentalLockAge;
epgData.table_id = mp_movie_info->epgId;
#ifdef FULL_CONTENT_CLASSIFICATION
epgData.contentClassification.clear();
#else
epgData.contentClassification = 0;
#endif
epgData.epg_times.dauer = mp_movie_info->length * 60; // we need the seconds
extMovieInfo.clear();
if ( !mp_movie_info->productionCountry.empty() || mp_movie_info->productionDate != 0)
{
extMovieInfo += mp_movie_info->productionCountry;
extMovieInfo += " ";
extMovieInfo += to_string(mp_movie_info->productionDate);
extMovieInfo += "\n";
}
if (!mp_movie_info->serieName.empty())
{
extMovieInfo += "\n";
extMovieInfo += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_SERIE);
extMovieInfo += ": ";
extMovieInfo += mp_movie_info->serieName;
extMovieInfo += "\n";
}
if (!mp_movie_info->channelName.empty())
{
extMovieInfo += "\n";
extMovieInfo += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_CHANNEL);
extMovieInfo += ": ";
extMovieInfo += mp_movie_info->channelName;
extMovieInfo += "\n";
}
if (mp_movie_info->rating != 0)
{
extMovieInfo += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_RATING);
extMovieInfo += ": ";
extMovieInfo += to_string(mp_movie_info->rating / 10);
extMovieInfo += ",";
extMovieInfo += to_string(mp_movie_info->rating % 10);
extMovieInfo += "/10";
extMovieInfo += "\n";
}
if (mp_movie_info->quality != 0)
{
extMovieInfo += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_QUALITY);
extMovieInfo += ": ";
extMovieInfo += to_string(mp_movie_info->quality);
extMovieInfo += "\n";
}
if (mp_movie_info->parentalLockAge != 0)
{
extMovieInfo += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_PARENTAL_LOCKAGE);
extMovieInfo += ": ";
extMovieInfo += to_string(mp_movie_info->parentalLockAge);
extMovieInfo += " ";
extMovieInfo += g_Locale->getText(LOCALE_UNIT_LONG_YEARS);
extMovieInfo += "\n";
}
if (!mp_movie_info->audioPids.empty())
{
extMovieInfo += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_AUDIO);
extMovieInfo += ": ";
for (unsigned int i = 0; i < mp_movie_info->audioPids.size(); i++)
{
if (i)
extMovieInfo += ", ";
extMovieInfo += mp_movie_info->audioPids[i].AudioPidName;
}
extMovieInfo += "\n";
}
if (mp_movie_info->genreMajor != 0)
{
neutrino_locale_t locale_genre;
unsigned char i = (mp_movie_info->genreMajor & 0x0F0);
if (i >= 0x010 && i < 0x0B0)
{
i >>= 4;
i--;
locale_genre = genre_sub_classes_list[i][((mp_movie_info->genreMajor & 0x0F) < genre_sub_classes[i]) ? (mp_movie_info->genreMajor & 0x0F) : 0];
}
else
locale_genre = LOCALE_GENRE_UNKNOWN;
extMovieInfo += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_GENRE_MAJOR);
extMovieInfo += ": ";
extMovieInfo += g_Locale->getText(locale_genre);
extMovieInfo += "\n";
}
extMovieInfo += "\n";
tm *date_tm = localtime(&mp_movie_info->file.Time);
extMovieInfo += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_RECORDDATE);
extMovieInfo += ": ";
extMovieInfo += strftime("%F", date_tm);
extMovieInfo += "\n";
date_tm = localtime(&mp_movie_info->dateOfLastPlay);
extMovieInfo += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_PREVPLAYDATE);
extMovieInfo += ": ";
if (mp_movie_info->dateOfLastPlay == 0)
extMovieInfo += "---";
else
extMovieInfo += strftime("%F", date_tm);
extMovieInfo += "\n";
extMovieInfo += "\n";
if (mp_movie_info->file.Size != 0)
{
extMovieInfo += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_SIZE);
extMovieInfo += ": ";
extMovieInfo += to_string(mp_movie_info->file.Size >> 20);
extMovieInfo += "\n";
}
extMovieInfo += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_PATH);
extMovieInfo += ": ";
extMovieInfo += mp_movie_info->file.getPath();
extMovieInfo += "\n";
extMovieInfo += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_FILE);
extMovieInfo += ": ";
extMovieInfo += mp_movie_info->file.getFileName();
extMovieInfo += "\n";
// this calculation is taken from timeosd.cpp
epg_done = (mp_duration && mp_duration > 100) ? (mp_position * 100 / mp_duration) : -1;
if (epg_done > 100)
epg_done = 100;
//printf("[%s:%d] epg_done: %d\n", __func__, __LINE__, epg_done);
res = show(mp_movie_info->epgId >> 16, 0, 0, doLoop, false, true);
if(!epgTextSwitch.empty())
{
mp_movie_info->epgInfo2 = epgTextSwitch;
CMovieInfo m_movieInfo;
//printf("#####[%s:%d] saveMovieInfo\n", __func__, __LINE__);
m_movieInfo.saveMovieInfo(*mp_movie_info);
}
return res;
}
int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_startzeit, bool doLoop, bool callFromfollowlist, bool mp_info )
{
int res = menu_return::RETURN_REPAINT;
static uint64_t id = 0;
static time_t startzeit = 0;
call_fromfollowlist = callFromfollowlist;
if (a_startzeit)
startzeit=*a_startzeit;
id=a_id;
ResetMDb();
t_channel_id epg_id = channel_id;
CZapitChannel * channel = CServiceManager::getInstance()->FindChannel(channel_id);
if (channel)
epg_id = channel->getEpgID();
if (!mp_info)
GetEPGData(epg_id, id, &startzeit);
epgTextSwitch.clear();
if (!mp_info)
extMovieInfo.clear();
if (doLoop)
{
if (!bigFonts && g_settings.bigFonts) {
g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->setSize((int)(g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->getSize() * BIGFONT_FACTOR));
g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->setSize((int)(g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->getSize() * BIGFONT_FACTOR));
}
bigFonts = g_settings.bigFonts;
start();
CEitManager::getInstance()->getEventsServiceKey(epg_id, evtlist);
// Houdini added for Private Premiere EPG start sorted by start date/time 2005-08-15
sort(evtlist.begin(),evtlist.end(),sortByDateTime);
}
if (epgData.title.empty()) /* no epg info found */
{
ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_EPGVIEWER_NOTFOUND)); // UTF-8
hide();
return res;
}
const int pic_h = 39;
toph = std::max(toph, pic_h);
std::string lname;
std::string channel_name;
if (mp_info)
channel_name = mp_movie_info->channelName;
else
channel_name = g_Zapit->getChannelName(channel_id);
if (!topboxheight)
start();
sb = oy - toph - botboxheight;
// 21.07.2005 - rainerk
// Only show info1 if it's not included in info2!
std::string strEpisode = ""; // Episode title in case info1 gets stripped
if (!epgData.info1.empty()) {
bool bHide = false;
if (false == epgData.info2.empty()) {
// Look for the first . in info1, usually this is the title of an episode.
std::string::size_type nPosDot = epgData.info1.find('.');
if (std::string::npos != nPosDot) {
nPosDot += 2; // Skip dot and first blank
/* Houdini: changed for safty reason (crashes with some events at WDR regional)
if (nPosDot < epgData.info2.length()) { // Make sure we don't overrun the buffer
*/
if (nPosDot < epgData.info2.length() && nPosDot < epgData.info1.length()) { // Make sure we don't overrun the buffer
// Check if the stuff after the dot equals the beginning of info2
if (epgData.info2.find(epgData.info1.substr(nPosDot, epgData.info1.length() - nPosDot)) == 0) {
strEpisode = epgData.info1.substr(0, nPosDot) + "\n";
bHide = true;
}
}
}
// Compare strings normally if not positively found to be equal before
if (false == bHide && epgData.info2.find(epgData.info1) == 0) {
bHide = true;
}
}
if (false == bHide) {
processTextToArray(epgData.info1);
}
}
info1_lines = epgText.size();
//scan epg-data - sort to list
if ((epgData.info2.empty()) && (info1_lines == 0))
processTextToArray(g_Locale->getText(LOCALE_EPGVIEWER_NODETAILED)); // UTF-8
else
processTextToArray(strEpisode + epgData.info2);
// Add a blank line
processTextToArray("");
// 21.07.2005 - rainerk
// Show extended information
if ( !epgData.itemDescriptions.empty() && !epgData.items.empty()) {
char line[256];
std::vector<std::string>::iterator description;
std::vector<std::string>::iterator item;
for (description = epgData.itemDescriptions.begin(), item = epgData.items.begin(); description != epgData.itemDescriptions.end(), item != epgData.items.end(); ++description, ++item) {
sprintf(line, "%s: %s", (*(description)).c_str(), (*(item)).c_str());
processTextToArray(line);
}
}
// Show FSK information
if (epgData.fsk > 0)
{
char fskInfo[4];
sprintf(fskInfo, "%d", epgData.fsk);
processTextToArray(std::string(g_Locale->getText(LOCALE_EPGVIEWER_AGE_RATING)) + ": " + fskInfo); // UTF-8
}
// Show length information
char lengthInfo[11];
sprintf(lengthInfo, "%d", epgData.epg_times.dauer / 60);
processTextToArray(std::string(g_Locale->getText(LOCALE_EPGVIEWER_LENGTH)) + ": " + lengthInfo); // UTF-8
if (!mp_info)
{
// Show audio information
std::string audioInfo = "";
CSectionsdClient::ComponentTagList tags;
bool hasComponentTags = CEitManager::getInstance()->getComponentTagsUniqueKey( epgData.eventID, tags);
if (hasComponentTags)
{
for (unsigned int i = 0; i < tags.size(); i++)
if ((tags[i].streamContent == 2 || tags[i].streamContent == 4) && !tags[i].component.empty())
audioInfo += tags[i].component + ", ";
if (!audioInfo.empty())
{
audioInfo.erase(audioInfo.size()-2);
processTextToArray(std::string(g_Locale->getText(LOCALE_EPGVIEWER_AUDIO)) + ": " + audioInfo); // UTF-8
}
}
}
// Show genre information
#ifdef FULL_CONTENT_CLASSIFICATION
if (!epgData.contentClassification.empty())
processTextToArray(std::string(g_Locale->getText(LOCALE_EPGVIEWER_GENRE)) + ": " + GetGenre(epgData.contentClassification[0])); // UTF-8
// processTextToArray( epgData.userClassification.c_str() );
#else
if (epgData.contentClassification)
processTextToArray(std::string(g_Locale->getText(LOCALE_EPGVIEWER_GENRE)) + ": " + GetGenre(epgData.contentClassification)); // UTF-8
#endif
// -- display more screenings on the same channel
// -- 2002-05-03 rasc
has_follow_screenings = false;
if (!mp_info && hasFollowScreenings(channel_id, epgData.title)) {
processTextToArray(""); // UTF-8
processTextToArray(std::string(g_Locale->getText(LOCALE_EPGVIEWER_MORE_SCREENINGS)) + ':'); // UTF-8
FollowScreenings(channel_id, epgData.title);
has_follow_screenings = true;
}
// show extended movie info
if (mp_info && !extMovieInfo.empty())
processTextToArray(extMovieInfo);
#if 0
/* neat for debugging duplicate event issues etc. */
char *epgid;
if (asprintf(&epgid, "EPG ID:%04X.%02X", (int)((epgData.eventID)&0x0FFFF), epgData.table_id) >= 0)
{
processTextToArray(""); // UTF-8
processTextToArray(epgid);
free(epgid);
}
#endif
COSDFader fader(g_settings.theme.menu_Content_alpha);
fader.StartFadeIn();
// show the epg
// header + logo
if (!header)
{
header = new CComponentsHeader();
header->setColorBody(COL_MENUHEAD_PLUS_0);
header->enableColBodyGradient(g_settings.theme.menu_Head_gradient, COL_MENUCONTENT_PLUS_0, g_settings.theme.menu_Head_gradient_direction);
header->enableClock();
header->getClockObject()->enableForceSegmentPaint();
}
header->setDimensionsAll(sx, sy, ox, toph);
header->setCaptionFont(font_title);
header->setCaption(epgData.title);
if (header->isPainted())
header->hideCCItems();
// set channel logo
if (g_settings.channellist_show_channellogo)
header->setChannelLogo(channel_id, channel_name, (CCHeaderTypes::cc_logo_alignment_t)g_settings.channellist_show_channellogo);
//paint head
header->paint(CC_SAVE_SCREEN_NO);
int showPos = 0;
textCount = epgText.size();
showText(showPos, sy + toph);
// small bottom box with left/right navigation
if (!Bottombox)
Bottombox = new CNaviBar(sx, sy+oy-botboxheight, ox, botboxheight);
if (!mp_info){
std::string fromto = epg_start + " - " + epg_end;
time_t epg_start_time = epgData.epg_times.startzeit;
GetPrevNextEPGData(epgData.eventID, &epg_start_time);
Bottombox->enableArrows(prev_id && !call_fromfollowlist, next_id && !call_fromfollowlist);
Bottombox->setText(fromto, epg_date);
}
//paint bottombox contents
Bottombox->paint(false);
showProgressBar();
// show Timer Event Buttons
showTimerEventBar(true, isCurrentEPG(channel_id), mp_info);
if ( doLoop )
{
neutrino_msg_t msg = 0;
neutrino_msg_data_t data = 0;
int scrollCount = 0;
bool loop = true;
bool epgTextSwitchClear = true;
int timeout = g_settings.timing[SNeutrinoSettings::TIMING_EPG];
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(timeout);
while (loop)
{
g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
if ( msg <= CRCInput::RC_MaxRC )
timeoutEnd = CRCInput::calcTimeoutEnd(timeout);
scrollCount = medlinecount;
switch ( msg )
{
case NeutrinoMessages::EVT_TIMER:
if (data == fader.GetFadeTimer()) {
if (fader.FadeDone())
loop = false;
}
else
CNeutrinoApp::getInstance()->handleMsg(msg, data);
if (!mp_info)
{
if (data == g_InfoViewer->getUpdateTimer())
{
GetEPGData(channel_id, id, &startzeit, false);
showProgressBar();
}
}
else if (epg_done != -1)
{