]> git.vomp.tv Git - vompclient.git/blob - vepglistadvanced.cc
20 CWFs, fix some snprintf calls
[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, 299, "%d/%m/%y %H:%M ", &btime);
482                   LOCALTIME_R(&eventEndTime, &btime);
483                   strftime(tempB, 299, "- %H:%M ", &btime);
484                   //#endif
485                   sprintf(tempC, "\t %s\n \t \t%s%s", currentEvent->title,tempA,tempB);
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, 299, "%H:%M ", &btime);
549                   LOCALTIME_R(&eventEndTime, &btime);
550                   strftime(tempB, 299, "- %H:%M ", &btime);
551                   //#endif
552                   sprintf(tempC, "%s\n%s\t %s%s", currentEvent->title, chan->name,tempA,tempB);
553
554           } else {
555                   sprintf(tempC, "\n%s", chan->name);
556
557           }
558           TVMediaInfo *info= new TVMediaInfo();
559           if ((*chanList)[listIndex]->number == channelNumber) {
560                   first = 1;
561                   setcurrenthelper = listIndex;
562           }
563           info->setChannelLogo((*chanList)[listIndex]->number);
564           info->setStaticFallback(sa_tv);
565           int index = sl.addOption(tempC, reinterpret_cast<void*>(listIndex), first, info);
566           if (currentEvent) currentEvent->index = index;
567           first = 0;
568   }
569
570   if (doIndexPop)
571   {
572     sl.hintSetCurrent(setcurrenthelper);
573   }
574   else
575   {
576     sl.hintSetCurrent(saveIndex);
577     sl.hintSetTop(saveTop);
578   }
579   updateSelection();
580 }
581
582 void VEpgListAdvanced::draw(bool doIndexPop)
583 {
584
585         // Single channel mode
586         switch (mode) {
587         case OneChannel: {
588                 char tempA[300];
589                  unsigned int chanlistsize=chanList->size();
590                  Channel * chan;
591                  UINT listIndex;
592                  for(listIndex = 0; listIndex < chanlistsize; listIndex++)
593                  {
594                          chan = (*chanList)[listIndex];
595                          if (chan->number == channelNumber) break;
596                  }
597                 sprintf(tempA, tr("Schedule - %s"), (*chanList)[listIndex]->name);
598                 setTitleText(tempA);
599         } break;
600         case Now: {
601                 setTitleText(tr("Now"));
602         } break;
603         case Next: {
604                 setTitleText(tr("Next"));
605         } break;
606         };
607
608
609
610         drawData(doIndexPop);
611
612         TBBoxx::draw();
613
614
615
616
617
618
619
620         char freeSpace[50];
621         struct tm btime;
622         time_t now;
623         time(&now);
624         LOCALTIME_R(&now, &btime);
625         strftime(freeSpace, 299, "%d/%m/%y", &btime);
626
627         drawTextRJ(freeSpace, getWidth(), 5, DrawStyle::LIGHTTEXT);
628
629         // Symbols
630
631         WSymbol w;
632         TEMPADD(&w);
633         w.nextSymbol = WSymbol::UP;
634         w.setPosition(20, area.h-35);
635         w.draw();
636         w.nextSymbol = WSymbol::DOWN;
637         w.setPosition(50, area.h-35);
638         w.draw();
639         w.nextSymbol = WSymbol::SKIPBACK;
640         w.setPosition(85, area.h-35);
641         w.draw();
642         w.nextSymbol = WSymbol::SKIPFORWARD;
643         w.setPosition(115, area.h-35);
644         w.draw();
645
646         drawTextRJ(tr("[ok] = info"), 560+70, sl.getY2()+4, DrawStyle::LIGHTTEXT);
647
648         // All static stuff done
649
650
651 }
652
653 Event* VEpgListAdvanced::getCurrentOptionEvent(int& channel)
654 {
655         // version for channel
656         Event* currentEvent = NULL;
657         EventList::iterator j;
658         EventList* eventList = NULL;
659     ULONG slCurrentOption = reinterpret_cast<ULONG>(sl.getCurrentOptionData());
660
661         switch (mode)
662         {
663         case OneChannel: {
664                 eventList = eventLista[0];
665                 if (eventList) {
666                         channel = channelNumber;
667                         for (j = eventList->begin(); j != eventList->end(); j++)
668                         {
669                                 currentEvent = *j;
670                                 if (currentEvent->index == slCurrentOption) return currentEvent;
671                         }
672
673
674                 } break;
675         case Next: {
676                 eventList = eventLista[slCurrentOption];
677                 channel = (*chanList)[slCurrentOption]->number;
678
679
680                 if (eventList && eventList->size()>1) {
681                         j = eventList->begin();
682                         currentEvent = j[1];
683                 } else {
684                         currentEvent = NULL;
685                 }
686         } break;
687         case Now: {
688                 eventList = eventLista[slCurrentOption];
689                 channel = (*chanList)[slCurrentOption]->number;
690
691                 if (eventList && eventList->size()>0) {
692                         j = eventList->begin();
693                         currentEvent = j[0];
694                 } else {
695                         currentEvent = NULL;
696                 }
697         } break;
698         };
699
700
701   }
702   return currentEvent;
703 }
704
705
706
707 void VEpgListAdvanced::updateSelection()
708 {
709         int channel=0;
710         if (mode==OneChannel) {
711                 TVMediaInfo *info= new TVMediaInfo();
712                 info->setChannelLogo(channelNumber);
713                 info->setStaticFallback(sa_tv);
714                 setTitleBarIcon(info);
715         }
716         Event* toShow = getCurrentOptionEvent(channel);
717         if (toShow)
718         {
719                 toShow->loadinfos(channel);
720                 std::stringstream description;
721
722                 description << "\n"<< toShow->title  << "\n\n";
723                 description << toShow->subtitle <<"\n";
724                 description << toShow->description;
725
726                 TVMedia poster;
727                 poster.height=0;
728                 if (toShow->movieInfo) {
729                         poster=toShow->movieInfo->poster;
730                 }
731                 if (toShow->seriesInfo) {
732                         if (toShow->seriesInfo->seasonposter.height) {
733                                 poster=toShow->seriesInfo->seasonposter;
734                         }
735                         else if (toShow->seriesInfo->posters.size()) {
736                                 poster=toShow->seriesInfo->posters[0];
737                         }
738                 }
739                 if (poster.height) {
740                         epgTVmedia.setTVMedia(poster.info, WTVMedia::ZoomHorizontal);
741                         epgTVmedia.setVisible(true);
742                 } else {
743                         if (toShow->epgImage)
744                         {
745                                 TVMediaInfo info;
746                                 info.setPosterThumb(channel,toShow->id);
747                                 epgTVmedia.setTVMedia(info, WTVMedia::ZoomHorizontal);
748                                 epgTVmedia.setVisible(true);
749                         }else if (mode!=OneChannel) {
750                                 TVMediaInfo info;
751                                 info.setChannelLogo(channel);
752                                 epgTVmedia.setTVMedia(info, WTVMedia::ZoomHorizontal);
753                                 epgTVmedia.setVisible(true);
754                         } else {
755                                 epgTVmedia.setVisible(false);
756                         }
757                 }
758
759                 epg.setText(description.str().c_str());
760         } else {
761                 epg.setText("");
762                 if (mode!=OneChannel) {
763                         TVMediaInfo info;
764                         info.setChannelLogo(channel);
765                         epgTVmedia.setTVMedia(info, WTVMedia::ZoomHorizontal);
766                         epgTVmedia.setVisible(true);
767                 } else {
768                         epgTVmedia.setVisible(false);
769                 }
770         }
771
772 }
773
774 int VEpgListAdvanced::handleCommand(int command)
775 {
776   switch(command)
777   {
778     case Input::UP:
779     {
780       sl.up();
781       quickUpdate();
782
783       boxstack->update(this);
784       return 2;
785     }
786     case Input::DOWN:
787     {
788       sl.down();
789       quickUpdate();
790
791       boxstack->update(this);
792       return 2;
793     }
794     case Input::SKIPBACK:
795     {
796       sl.pageUp();
797       quickUpdate();
798
799       boxstack->update(this);
800       return 2;
801     }
802     case Input::SKIPFORWARD:
803     {
804       sl.pageDown();
805       quickUpdate();
806
807       boxstack->update(this);
808       return 2;
809     }
810     case Input::RED:
811     {
812         doRed();
813         return 2;
814     }
815     case Input::GREEN:
816     {
817         doGreen();
818         return 2;
819     }
820     case Input::YELLOW:
821     {
822         doYellow();
823         return 2;
824     }
825     case Input::BLUE:
826     {
827         doBlue();
828         return 2;
829     }
830     case Input::OK:
831     {
832       if (sl.getNumOptions() == 0) return 2;
833
834
835       int channel;
836       Event* current = getCurrentOptionEvent(channel);
837       if (current)
838       {
839           Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "Found the option you pointed at. %s %d", current->title, current->id);
840           unsigned int chanlistsize=chanList->size();
841           Channel * chan;
842           UINT listIndex;
843           for(listIndex = 0; listIndex < chanlistsize; listIndex++)
844           {
845                   chan = (*chanList)[listIndex];
846                   if ((int)chan->number == channel) break;
847           }
848
849           VEpgSummary* vr = new VEpgSummary(current, (*chanList)[listIndex]);
850           vr->draw();
851           boxstack->add(vr);
852           boxstack->update(vr);
853
854           return 2;
855       }
856       // should not get to here
857       return 1;
858     }
859     case Input::BACK:
860     {
861         return 4;
862     }
863   }
864   // stop command getting to any more views
865   return 1;
866 }
867
868 void VEpgListAdvanced::processMessage(Message* m)
869 {
870   Log::getInstance()->log("VEpgListAdvanced", Log::DEBUG, "Got message value %lu", m->message);
871
872   if (m->message == Message::MOUSE_MOVE)
873   {
874     if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
875     {
876       quickUpdate();
877       boxstack->update(this);
878     }
879   }
880   else if (m->message == Message::MOUSE_LBDOWN)
881   {
882     if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
883     {
884       boxstack->handleCommand(Input::OK); //simulate OK press
885     }
886         else if (boxRed.mouseLBDOWN((m->parameter >> 16) - getScreenX(), (m->parameter & 0xFFFF) - getScreenY()))
887         {
888                 boxstack->handleCommand(Input::RED);
889         }
890         else if (boxGreen.mouseLBDOWN((m->parameter >> 16) - getScreenX(), (m->parameter & 0xFFFF) - getScreenY()))
891         {
892                 boxstack->handleCommand(Input::GREEN);
893         }
894         else if (boxYellow.mouseLBDOWN((m->parameter >> 16) - getScreenX(), (m->parameter & 0xFFFF) - getScreenY()))
895         {
896                 boxstack->handleCommand(Input::GREEN);
897         }
898         else if (boxBlue.mouseLBDOWN((m->parameter >> 16) - getScreenX(), (m->parameter & 0xFFFF) - getScreenY()))
899         {
900                 boxstack->handleCommand(Input::GREEN);
901         }
902     else
903     {
904       if (coordsOutsideBox(m))
905       {
906         boxstack->handleCommand(Input::BACK); //simulate cancel press
907       }
908     }
909   }
910 }
911
912
913
914 void VEpgListAdvanced::quickUpdate() { //only quick for plattform that need it!
915         updateEpgData();
916         updateSelection();
917 #ifdef GRADIENT_DRAWING
918       draw();
919 #else
920       sl.draw();
921       epg.draw();
922 #endif
923 }