]> git.vomp.tv Git - vompclient.git/blob - vepglistadvanced.cc
Rename TCP class to TCPOld
[vompclient.git] / vepglistadvanced.cc
1 /*
2     Copyright 2004-2007 Chris Tallon, 2014 Marten Richter
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #include "vepglistadvanced.h"
21
22 #include "boxstack.h"
23 #include "input.h"
24 #include "wsymbol.h"
25 #include "boxstack.h"
26 #include "vdr.h"
27 #include "colour.h"
28 #include "video.h"
29 #include "i18n.h"
30 #include "messagequeue.h"
31 #include "log.h"
32 #include "movieinfo.h"
33 #include "seriesinfo.h"
34 #include "event.h"
35 #include "channel.h"
36 #include "vepgsummary.h"
37 #include "vepgsettimer.h"
38 #include "vepg.h"
39 #include "staticartwork.h"
40
41 #include <sstream>
42
43
44 VEpgListAdvanced::VEpgListAdvanced(VVideoLiveTV *tvideolive, ChannelList* tchanList,ULONG initialChannelNumber)
45 {
46         channelNumber = initialChannelNumber;
47         chanList = tchanList;
48         videolive = tvideolive;
49         boxstack = BoxStack::getInstance();
50
51         mode = OneChannel;
52
53         setSize(640+40, 500+40); //old   setSize(570, 420);
54         createBuffer();
55
56         setPosition(20, 20);
57
58         setTitleBarOn(1);
59         setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
60         TVMediaInfo *info= new TVMediaInfo();
61         info->setChannelLogo(channelNumber);
62         info->setStaticFallback(sa_tv);
63         setTitleBarIcon(info);
64
65         sl.setPosition(10, 30 + 5);
66         sl.setSize(area.w*42/100 - 20, area.h - 30 - 15 - 30);
67         sl.setLinesPerOption(2.4f);
68         add(&sl);
69
70         Region slarea=sl.getRegionR();
71
72         epg.setParaMode(true);
73         epg.setPosition(slarea.x  +slarea.w+10 ,30+5);
74         epg.setSize(area.w -slarea.x -slarea.w -10, area.h - 30 - 15 - 30);
75         add(&epg);
76         epg.setText("");
77         epg.setVideoBackground();
78         epg.setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND);
79
80         epgTVmedia.setPosition(epg.getRegionR().w-100-10,10);
81         epgTVmedia.setSize(100,(UINT)(150/Osd::getInstance()->getPixelAspect()));
82         epg.add(&epgTVmedia);
83
84         boxRed.setBackgroundColour(DrawStyle::RED);
85         boxRed.setPosition(165 /*54*/, sl.getY2()+8);
86         boxRed.setSize(18, 16);
87         add(&boxRed);
88
89         textRed.setPosition(boxRed.getX2(), sl.getY2()+4);
90         textRed.setSize(116, 30);
91
92         add(&textRed);
93
94         boxGreen.setBackgroundColour(DrawStyle::GREEN);
95         boxGreen.setPosition(165 +1*110, sl.getY2()+8);
96         boxGreen.setSize(18, 16);
97         add(&boxGreen);
98
99         textGreen.setPosition(boxGreen.getX2(), sl.getY2()+4);
100         textGreen.setSize(116, 30);
101         add(&textGreen);
102
103         boxYellow.setBackgroundColour(DrawStyle::YELLOW);
104         boxYellow.setPosition(165 +2*110, sl.getY2()+8);
105         boxYellow.setSize(18, 16);
106         add(&boxYellow);
107
108         textYellow.setPosition(boxYellow.getX2(), sl.getY2()+4);
109         textYellow.setSize(116, 30);
110         add(&textYellow);
111
112         boxBlue.setBackgroundColour(DrawStyle::BLUE);
113         boxBlue.setPosition(165 +3*110, sl.getY2()+8);
114         boxBlue.setSize(18, 16);
115         add(&boxBlue);
116
117         textBlue.setPosition(boxBlue.getX2(), sl.getY2()+4);
118         textBlue.setSize(116, 30);
119         add(&textBlue);
120
121         setButtonText();
122
123
124         updateEpgDataChannel();
125 }
126
127 VEpgListAdvanced::~VEpgListAdvanced()
128 {
129         clearEventList();
130 }
131
132
133 void VEpgListAdvanced::setButtonText()
134 {
135         switch (mode)
136         {
137         case OneChannel: {
138                 textRed.setText(tr("Record"));
139                 textGreen.setText(tr("Now"));
140                 textYellow.setText(tr("Next"));
141                 textBlue.setText(tr("Guide"));
142
143         } break;
144         case Now: {
145                 textRed.setText(tr("Record"));
146                 textGreen.setText(tr("Next"));
147                 textYellow.setText(tr("Schedule"));
148                 textBlue.setText(tr("Switch"));
149         } break;
150         case Next: {
151                 textRed.setText(tr("Record"));
152                 textGreen.setText(tr("Now"));
153                 textYellow.setText(tr("Schedule"));
154                 textBlue.setText(tr("Switch"));
155         } break;
156
157         };
158 }
159
160 void VEpgListAdvanced::doRed()
161 {
162         doRecord();
163 }
164
165 void VEpgListAdvanced::doGreen()
166 {
167         switch (mode)
168         {
169         case Now: {
170                 doNext();
171         } break;
172         case OneChannel:
173         case Next: {
174                 doNow();
175         } break;
176         };
177 }
178
179 void VEpgListAdvanced::doYellow()
180 {
181         switch (mode)
182         {
183         case OneChannel: {
184                 doNext();
185         } break;
186         case Next:
187         case Now: {
188                 doProgramm();
189         } break;
190         };
191 }
192
193 void VEpgListAdvanced::doBlue()
194 {
195         switch (mode)
196         {
197         case OneChannel: {
198                 doGrid();
199         } break;
200         case Next:
201         case Now: {
202                 doSwitch();
203         } break;
204         };
205 }
206
207 void VEpgListAdvanced::doNext()
208 {
209         Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "doNext");
210     ULONG slCurrentOption = reinterpret_cast<ULONG>(sl.getCurrentOptionData());
211         if (mode!=OneChannel) {
212                 Channel * chan=(*chanList)[slCurrentOption];
213                 channelNumber = chan->number;
214         }
215         mode=Next;
216         updateEpgDataNowNext(true);
217         setButtonText();
218         TVMediaInfo *info= new TVMediaInfo();
219         info->setStaticArtwork(sa_tv);
220         setTitleBarIcon(info);
221         draw(true);
222         boxstack->update(this);
223 }
224 void VEpgListAdvanced::doNow()
225 {
226         Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "doNow");
227     ULONG slCurrentOption = reinterpret_cast<ULONG>(sl.getCurrentOptionData());
228         if (mode!=OneChannel) {
229                 Channel * chan=(*chanList)[slCurrentOption];
230                 channelNumber = chan->number;
231         }
232         mode=Now;
233         updateEpgDataNowNext(true);
234         setButtonText();
235         TVMediaInfo *info= new TVMediaInfo();
236         info->setStaticArtwork(sa_tv);
237         setTitleBarIcon(info);
238         draw(true);
239         boxstack->update(this);
240 }
241
242 void VEpgListAdvanced::doProgramm()
243 {
244         Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "doProgram");
245         mode=OneChannel;
246     ULONG slCurrentOption = reinterpret_cast<ULONG>(sl.getCurrentOptionData());
247         Channel * chan=(*chanList)[slCurrentOption];
248         channelNumber = chan->number;
249         updateEpgDataChannel();
250         setButtonText();
251         TVMediaInfo *info= new TVMediaInfo();
252         info->setChannelLogo(channelNumber);
253         info->setStaticFallback(sa_tv);
254         setTitleBarIcon(info);
255         draw(true);
256         boxstack->update(this);
257 }
258
259 void VEpgListAdvanced::doSwitch()
260 {
261
262         if (videolive)
263         {
264                 if (mode!=OneChannel) {
265             ULONG slCurrentOption = reinterpret_cast<ULONG>(sl.getCurrentOptionData());
266                         Channel * chan=(*chanList)[slCurrentOption];
267                         channelNumber = chan->number;
268                 }
269                 Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "doSwitch %d", channelNumber);
270                 Message* m = new Message(); // Must be done after this view deleted
271                 m->from = this;
272                 m->to = videolive;
273                 m->message = Message::CHANNEL_CHANGE;
274                 m->parameter = channelNumber;
275                 m->tag = 0;
276                 MessageQueue::getInstance()->postMessage(m);
277         }
278 }
279
280 #if WIN32
281 // FIXME win pragma
282 #pragma warning(disable : 4703)
283 #endif
284
285 void VEpgListAdvanced::doRecord()
286 {
287         int channel;
288         Event* current = getCurrentOptionEvent(channel);
289         if (current)
290         {
291                 Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "Found the option you pointed at. %s %d", current->title, current->id);
292                 unsigned int chanlistsize=chanList->size();
293                 Channel * chan;
294                 UINT listIndex;
295                 for(listIndex = 0; listIndex < chanlistsize; listIndex++)
296                 {
297                         chan = (*chanList)[listIndex];
298                         if ((int)chan->number == channel) break;
299                 }
300
301                 Log::getInstance()->log("VEpgSummary", Log::DEBUG, "ID %lu TIME %lu DURATION %lu TITLE %s", current->id, current->time,
302                                 current->duration, current->title);
303                 VEpgSetTimer* vs = new VEpgSetTimer(current, chan);
304                 vs->draw();
305                 boxstack->add(vs);
306                 boxstack->update(vs);
307         }
308
309 }
310
311 void VEpgListAdvanced::doGrid()
312 {
313
314         if (mode!=OneChannel) {
315         ULONG slCurrentOption = reinterpret_cast<ULONG>(sl.getCurrentOptionData());
316                 Channel * chan=(*chanList)[slCurrentOption];
317                 channelNumber = chan->number;
318         }
319         UINT listIndex;
320         unsigned int chanlistsize=chanList->size();
321         Channel *chan;
322         for(listIndex = 0; listIndex < chanlistsize; listIndex++)
323         {
324                 chan = (*chanList)[listIndex];
325                 if (chan->number == channelNumber) break;
326         }
327
328         VEpg* vepg = new VEpg(videolive, listIndex, chanList);
329         vepg->draw();
330         boxstack->add(vepg);
331         boxstack->update(vepg);
332
333 }
334
335 void VEpgListAdvanced::clearEventList()
336 {
337         std::vector<EventList*>::iterator itty = eventLista.begin();
338         while (itty!= eventLista.end()) {
339                 if (*itty) {
340                         (*itty)->clear();
341                         delete (*itty);
342                 }
343                 itty++;
344         }
345         eventLista.clear();
346
347 }
348
349
350 /* Prototype
351  *
352  *   if (!chanList) return;
353   Channel* chan;
354   for(UINT listIndex = 0; listIndex < gridRows; listIndex++)
355   {
356     if(listTop + listIndex >= UINT(chanListbox.getBottomOption()))
357       continue;
358     chan = (*chanList)[listTop + listIndex];
359     eventLista[listIndex] = VDR::getInstance()->getChannelSchedule(chan->number, ltime - 1, window_width * 60 + 2); // ltime - 1 to get prog before window (allows cursor left past ltime). + 2 to get prog after window
360   }
361
362  */
363
364 void VEpgListAdvanced::updateEpgData()
365 {
366         switch (mode)
367         {
368         case OneChannel: {
369                 //updateEpgDataChannel();
370         } break;
371         case Next:
372         case Now: {
373                 updateEpgDataNowNext(false);
374         } break;
375         };
376
377 }
378
379 void VEpgListAdvanced::updateEpgDataNowNext(bool changeState)
380 {
381         int startupdate=0;
382         int endupdate=0;
383
384         unsigned int chanlistsize=chanList->size();
385         if (changeState) {
386                 clearEventList();
387                 eventLista.resize(chanList->size());
388                 Channel* chan;
389                 for(UINT listIndex = 0; listIndex < chanlistsize; listIndex++)
390                 {
391                         if (listIndex < 0) continue;
392                         if (listIndex >= chanlistsize) continue;
393                         chan = (*chanList)[listIndex];
394                         if (chan->number == channelNumber) {
395                                 startupdate = listIndex-sl.getNumOptionsDisplayable()-2;
396                                 endupdate = listIndex+sl.getNumOptionsDisplayable()+2;
397                                 break;
398                         }
399                 }
400         } else {
401                 startupdate=sl.getTopOption()-2;
402                 endupdate=sl.getBottomOption()+1;
403         }
404
405         time_t now;
406         time(&now);
407
408         Channel* chan;
409         for(int listIndex = startupdate; listIndex < endupdate; listIndex++)
410         {
411                 if (listIndex < 0) continue;
412                 if (listIndex >= (int)chanlistsize) continue;
413
414             chan = (*chanList)[listIndex];
415                 if (!eventLista[listIndex]) eventLista[listIndex] = VDR::getInstance()->getChannelSchedule(chan->number, now, 4 * 60 *60);
416
417         }
418
419 }
420
421 void VEpgListAdvanced::updateEpgDataChannel()
422 {
423         clearEventList();
424         eventLista.resize(1);
425         time_t now;
426         time(&now);
427         eventLista[0] = VDR::getInstance()->getChannelSchedule(channelNumber, now, 24 * 60 *60 *30); // one month
428         Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "Eventlist %x %d", eventLista[0],channelNumber);
429
430 }
431
432 void VEpgListAdvanced::drawData(bool doIndexPop)
433 {
434         switch (mode)
435         {
436         case OneChannel: {
437                 drawDataChannel(doIndexPop);
438         } break;
439         case Next: {
440                 drawDataNowNext(true, doIndexPop);
441         } break;
442         case Now: {
443                 drawDataNowNext(false, doIndexPop);
444         } break;
445         };
446
447 }
448
449 void VEpgListAdvanced::drawDataChannel(bool doIndexPop)
450 {
451   int saveIndex = sl.getCurrentOption();
452   int saveTop = sl.getTopOption();
453   sl.clear();
454   sl.addColumn(0);
455   sl.addColumn(25 );
456   sl.addColumn(25 + 7);
457   sl.addColumn(25 + 7+ 7);
458   //sl.addColumn(118);
459
460   int first = 1;
461
462   char tempA[300]; // FIXME  this is guesswork!
463   char tempB[300]; // FIXME
464   char tempC[300]; // FIXME
465   struct tm btime;
466
467
468
469
470   Event* currentEvent = NULL;
471   EventList::iterator j;
472   EventList* eventList = eventLista[0];
473   if (eventList) {
474           for (j = eventList->begin(); j != eventList->end(); j++)
475           {
476                   currentEvent = *j;
477                   time_t eventStartTime = (time_t)currentEvent->time;
478                   time_t eventEndTime = (time_t)(currentEvent->time + currentEvent->duration);
479
480                   LOCALTIME_R(&eventStartTime, &btime);
481                   strftime(tempA, 300, "%d/%m/%y %H:%M ", &btime);
482                   LOCALTIME_R(&eventEndTime, &btime);
483                   strftime(tempB, 300, "- %H:%M ", &btime);
484                   int check = SNPRINTF(tempC, 300, "\t %s\n \t \t%s%s", currentEvent->title,tempA,tempB);
485           if ((check < 0) || (check > 299)) Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "String too big");
486                   // New TVMedia stuff
487                   TVMediaInfo *info= new TVMediaInfo();
488                   info->setPosterThumb(channelNumber, currentEvent->id);
489                   info->setStaticFallback(sa_defposter);
490                   currentEvent->index = sl.addOption(tempC, reinterpret_cast<void*>(currentEvent->id), first, info);
491                   first = 0;
492           }
493   }
494
495   if (doIndexPop)
496   {
497     sl.hintSetCurrent(0);
498   }
499   else
500   {
501     sl.hintSetCurrent(saveIndex);
502     sl.hintSetTop(saveTop);
503   }
504   updateSelection();
505
506 }
507
508 void VEpgListAdvanced::drawDataNowNext(bool next, bool doIndexPop)
509 {
510   int saveIndex = sl.getCurrentOption();
511   int saveTop = sl.getTopOption();
512   sl.clear();
513   sl.addColumn(0);
514   sl.addColumn(42 );
515   sl.addColumn(160);
516
517   int first = 1;
518
519   char tempA[300]; // FIXME  this is guesswork!
520   char tempB[300]; // FIXME
521   char tempC[300]; // FIXME
522   struct tm btime;
523
524
525
526
527   Event* currentEvent = NULL;
528   EventList::iterator j;
529   int minevents=1;
530   if (next) minevents++;
531   int setcurrenthelper =0;
532
533   unsigned int chanlistsize=chanList->size();
534   for(UINT listIndex = 0; listIndex < chanlistsize; listIndex++)
535   {
536           Channel* chan;
537           chan = (*chanList)[listIndex];
538
539           EventList* eventList = eventLista[listIndex];
540           if (eventList && ((int)eventList->size() >= minevents)) {
541                   j = eventList->begin();
542
543                   currentEvent = j[minevents-1];
544                   time_t eventStartTime = (time_t)currentEvent->time;
545                   time_t eventEndTime = (time_t)(currentEvent->time + currentEvent->duration);
546
547                   LOCALTIME_R(&eventStartTime, &btime);
548                   strftime(tempA, 300, "%H:%M ", &btime);
549                   LOCALTIME_R(&eventEndTime, &btime);
550                   strftime(tempB, 300, "- %H:%M ", &btime);
551                   int check = SNPRINTF(tempC, 300, "%s\n%s\t %s%s", currentEvent->title, chan->name,tempA,tempB);
552           if ((check < 0) || (check > 299)) Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "String too big");
553           } else {
554                   sprintf(tempC, "\n%s", chan->name);
555
556           }
557           TVMediaInfo *info= new TVMediaInfo();
558           if ((*chanList)[listIndex]->number == channelNumber) {
559                   first = 1;
560                   setcurrenthelper = listIndex;
561           }
562           info->setChannelLogo((*chanList)[listIndex]->number);
563           info->setStaticFallback(sa_tv);
564           int index = sl.addOption(tempC, reinterpret_cast<void*>(listIndex), first, info);
565           if (currentEvent) currentEvent->index = index;
566           first = 0;
567   }
568
569   if (doIndexPop)
570   {
571     sl.hintSetCurrent(setcurrenthelper);
572   }
573   else
574   {
575     sl.hintSetCurrent(saveIndex);
576     sl.hintSetTop(saveTop);
577   }
578   updateSelection();
579 }
580
581 void VEpgListAdvanced::draw(bool doIndexPop)
582 {
583
584         // Single channel mode
585         switch (mode) {
586         case OneChannel: {
587                 char tempA[300];
588                  unsigned int chanlistsize=chanList->size();
589                  Channel * chan;
590                  UINT listIndex;
591                  for(listIndex = 0; listIndex < chanlistsize; listIndex++)
592                  {
593                          chan = (*chanList)[listIndex];
594                          if (chan->number == channelNumber) break;
595                  }
596                 sprintf(tempA, tr("Schedule - %s"), (*chanList)[listIndex]->name);
597                 setTitleText(tempA);
598         } break;
599         case Now: {
600                 setTitleText(tr("Now"));
601         } break;
602         case Next: {
603                 setTitleText(tr("Next"));
604         } break;
605         };
606
607
608
609         drawData(doIndexPop);
610
611         TBBoxx::draw();
612
613
614
615
616
617
618
619         char freeSpace[50];
620         struct tm btime;
621         time_t now;
622         time(&now);
623         LOCALTIME_R(&now, &btime);
624         strftime(freeSpace, 299, "%d/%m/%y", &btime);
625
626         drawTextRJ(freeSpace, getWidth(), 5, DrawStyle::LIGHTTEXT);
627
628         // Symbols
629
630         WSymbol w;
631         TEMPADD(&w);
632         w.nextSymbol = WSymbol::UP;
633         w.setPosition(20, area.h-35);
634         w.draw();
635         w.nextSymbol = WSymbol::DOWN;
636         w.setPosition(50, area.h-35);
637         w.draw();
638         w.nextSymbol = WSymbol::SKIPBACK;
639         w.setPosition(85, area.h-35);
640         w.draw();
641         w.nextSymbol = WSymbol::SKIPFORWARD;
642         w.setPosition(115, area.h-35);
643         w.draw();
644
645         drawTextRJ(tr("[ok] = info"), 560+70, sl.getY2()+4, DrawStyle::LIGHTTEXT);
646
647         // All static stuff done
648
649
650 }
651
652 Event* VEpgListAdvanced::getCurrentOptionEvent(int& channel)
653 {
654         // version for channel
655         Event* currentEvent = NULL;
656         EventList::iterator j;
657         EventList* eventList = NULL;
658     ULONG slCurrentOption = reinterpret_cast<ULONG>(sl.getCurrentOptionData());
659
660         switch (mode)
661         {
662         case OneChannel: {
663                 eventList = eventLista[0];
664                 if (eventList) {
665                         channel = channelNumber;
666                         for (j = eventList->begin(); j != eventList->end(); j++)
667                         {
668                                 currentEvent = *j;
669                                 if (currentEvent->index == slCurrentOption) return currentEvent;
670                         }
671
672
673                 } break;
674         case Next: {
675                 eventList = eventLista[slCurrentOption];
676                 channel = (*chanList)[slCurrentOption]->number;
677
678
679                 if (eventList && eventList->size()>1) {
680                         j = eventList->begin();
681                         currentEvent = j[1];
682                 } else {
683                         currentEvent = NULL;
684                 }
685         } break;
686         case Now: {
687                 eventList = eventLista[slCurrentOption];
688                 channel = (*chanList)[slCurrentOption]->number;
689
690                 if (eventList && eventList->size()>0) {
691                         j = eventList->begin();
692                         currentEvent = j[0];
693                 } else {
694                         currentEvent = NULL;
695                 }
696         } break;
697         };
698
699
700   }
701   return currentEvent;
702 }
703
704
705
706 void VEpgListAdvanced::updateSelection()
707 {
708         int channel=0;
709         if (mode==OneChannel) {
710                 TVMediaInfo *info= new TVMediaInfo();
711                 info->setChannelLogo(channelNumber);
712                 info->setStaticFallback(sa_tv);
713                 setTitleBarIcon(info);
714         }
715         Event* toShow = getCurrentOptionEvent(channel);
716         if (toShow)
717         {
718                 toShow->loadinfos(channel);
719                 std::stringstream description;
720
721                 description << "\n"<< toShow->title  << "\n\n";
722                 description << toShow->subtitle <<"\n";
723                 description << toShow->description;
724
725                 TVMedia poster;
726                 poster.height=0;
727                 if (toShow->movieInfo) {
728                         poster=toShow->movieInfo->poster;
729                 }
730                 if (toShow->seriesInfo) {
731                         if (toShow->seriesInfo->seasonposter.height) {
732                                 poster=toShow->seriesInfo->seasonposter;
733                         }
734                         else if (toShow->seriesInfo->posters.size()) {
735                                 poster=toShow->seriesInfo->posters[0];
736                         }
737                 }
738                 if (poster.height) {
739                         epgTVmedia.setTVMedia(poster.info, WTVMedia::ZoomHorizontal);
740                         epgTVmedia.setVisible(true);
741                 } else {
742                         if (toShow->epgImage)
743                         {
744                                 TVMediaInfo info;
745                                 info.setPosterThumb(channel,toShow->id);
746                                 epgTVmedia.setTVMedia(info, WTVMedia::ZoomHorizontal);
747                                 epgTVmedia.setVisible(true);
748                         }else if (mode!=OneChannel) {
749                                 TVMediaInfo info;
750                                 info.setChannelLogo(channel);
751                                 epgTVmedia.setTVMedia(info, WTVMedia::ZoomHorizontal);
752                                 epgTVmedia.setVisible(true);
753                         } else {
754                                 epgTVmedia.setVisible(false);
755                         }
756                 }
757
758                 epg.setText(description.str().c_str());
759         } else {
760                 epg.setText("");
761                 if (mode!=OneChannel) {
762                         TVMediaInfo info;
763                         info.setChannelLogo(channel);
764                         epgTVmedia.setTVMedia(info, WTVMedia::ZoomHorizontal);
765                         epgTVmedia.setVisible(true);
766                 } else {
767                         epgTVmedia.setVisible(false);
768                 }
769         }
770
771 }
772
773 int VEpgListAdvanced::handleCommand(int command)
774 {
775   switch(command)
776   {
777     case Input::UP:
778     {
779       sl.up();
780       quickUpdate();
781
782       boxstack->update(this);
783       return 2;
784     }
785     case Input::DOWN:
786     {
787       sl.down();
788       quickUpdate();
789
790       boxstack->update(this);
791       return 2;
792     }
793     case Input::SKIPBACK:
794     {
795       sl.pageUp();
796       quickUpdate();
797
798       boxstack->update(this);
799       return 2;
800     }
801     case Input::SKIPFORWARD:
802     {
803       sl.pageDown();
804       quickUpdate();
805
806       boxstack->update(this);
807       return 2;
808     }
809     case Input::RED:
810     {
811         doRed();
812         return 2;
813     }
814     case Input::GREEN:
815     {
816         doGreen();
817         return 2;
818     }
819     case Input::YELLOW:
820     {
821         doYellow();
822         return 2;
823     }
824     case Input::BLUE:
825     {
826         doBlue();
827         return 2;
828     }
829     case Input::OK:
830     {
831       if (sl.getNumOptions() == 0) return 2;
832
833
834       int channel;
835       Event* current = getCurrentOptionEvent(channel);
836       if (current)
837       {
838           Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "Found the option you pointed at. %s %d", current->title, current->id);
839           unsigned int chanlistsize=chanList->size();
840           Channel * chan;
841           UINT listIndex;
842           for(listIndex = 0; listIndex < chanlistsize; listIndex++)
843           {
844                   chan = (*chanList)[listIndex];
845                   if ((int)chan->number == channel) break;
846           }
847
848           VEpgSummary* vr = new VEpgSummary(current, (*chanList)[listIndex]);
849           vr->draw();
850           boxstack->add(vr);
851           boxstack->update(vr);
852
853           return 2;
854       }
855       // should not get to here
856       return 1;
857     }
858     case Input::BACK:
859     {
860         return 4;
861     }
862   }
863   // stop command getting to any more views
864   return 1;
865 }
866
867 void VEpgListAdvanced::processMessage(Message* m)
868 {
869   Log::getInstance()->log("VEpgListAdvanced", Log::DEBUG, "Got message value %lu", m->message);
870
871   if (m->message == Message::MOUSE_MOVE)
872   {
873     if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
874     {
875       quickUpdate();
876       boxstack->update(this);
877     }
878   }
879   else if (m->message == Message::MOUSE_LBDOWN)
880   {
881     if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
882     {
883       boxstack->handleCommand(Input::OK); //simulate OK press
884     }
885         else if (boxRed.mouseLBDOWN((m->parameter >> 16) - getScreenX(), (m->parameter & 0xFFFF) - getScreenY()))
886         {
887                 boxstack->handleCommand(Input::RED);
888         }
889         else if (boxGreen.mouseLBDOWN((m->parameter >> 16) - getScreenX(), (m->parameter & 0xFFFF) - getScreenY()))
890         {
891                 boxstack->handleCommand(Input::GREEN);
892         }
893         else if (boxYellow.mouseLBDOWN((m->parameter >> 16) - getScreenX(), (m->parameter & 0xFFFF) - getScreenY()))
894         {
895                 boxstack->handleCommand(Input::GREEN);
896         }
897         else if (boxBlue.mouseLBDOWN((m->parameter >> 16) - getScreenX(), (m->parameter & 0xFFFF) - getScreenY()))
898         {
899                 boxstack->handleCommand(Input::GREEN);
900         }
901     else
902     {
903       if (coordsOutsideBox(m))
904       {
905         boxstack->handleCommand(Input::BACK); //simulate cancel press
906       }
907     }
908   }
909 }
910
911
912
913 void VEpgListAdvanced::quickUpdate() { //only quick for plattform that need it!
914         updateEpgData();
915         updateSelection();
916 #ifdef GRADIENT_DRAWING
917       draw();
918 #else
919       sl.draw();
920       epg.draw();
921 #endif
922 }