2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
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.
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.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "vlivebanner.h"
23 VLiveBanner::VLiveBanner(View* tparent, Channel* channel, bool bannerTakesCommands)
27 takeCommands = bannerTakesCommands;
30 if (Video::getInstance()->getFormat() == Video::PAL)
32 setScreenPos(125, 410);
36 setScreenPos(115, 320);
40 setBackgroundColour(Colour::VIEWBACKGROUND);
42 setTitleBarColour(Colour::TITLEBARBACKGROUND);
44 sl.setSurface(surface);
45 sl.setSurfaceOffset(0, 30);
46 sl.setDimensions(area.w, area.h - 60);
52 VLiveBanner::~VLiveBanner()
57 void VLiveBanner::delData()
61 int eventListSize = eventList->size();
62 for(int i = 0; i < eventListSize; i++)
64 delete (*eventList)[i];
73 void VLiveBanner::setChannel(Channel* tChannel)
76 currentChannel = tChannel;
80 snprintf(ttitleText, 99, "%03lu - %s", currentChannel->number, currentChannel->name);
82 setTitleText(ttitleText);
83 eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
87 sl.addOption(tr("No channel data available"), 1);
92 Log::getInstance()->log("Banner", Log::DEBUG, "Start sort");
93 sort(eventList->begin(), eventList->end(), EventSorter());
94 Log::getInstance()->log("Banner", Log::DEBUG, "End sort");
97 char tempString2[300];
101 int eventListSize = eventList->size();
102 for(int i = 0; i < eventListSize; i++)
104 event = (*eventList)[i];
106 btime = localtime((time_t*)&event->time);
107 strftime(tempString2, 299, "%0H:%0M ", btime);
108 snprintf(tempString, 299, "%s %s", tempString2, event->title);
109 event->index = sl.addOption(tempString, first);
113 // Reset the timer as it probably took 1-2 seconds to change the channel
114 Timers::getInstance()->cancelTimer(this, 1); // if it exists
115 Timers::getInstance()->setTimer(this, 1, (struct timespec){4, 0});
119 void VLiveBanner::draw()
123 rectangle(0, area.h - 30, area.w, 30, titleBarColour);
125 rectangle(7, area.h - 24, 18, 16, Colour::RED);
126 drawText(tr("info"), 32, area.h - 25, Colour::LIGHTTEXT);
129 int VLiveBanner::handleCommand(int command)
136 Timers::getInstance()->cancelTimer(this, 1); // if it exists
141 if (!takeCommands) return 0; // banner was auto, old remote
142 } // else drop through
151 case Remote::DF_DOWN:
153 if (!takeCommands) return 0; // banner was auto, old remote
154 } // else drop through
163 case Remote::CHANNELUP:
165 // cancel timer so this view is still here later
166 Timers::getInstance()->cancelTimer(this, 1); // if it exists
168 Message* m = new Message();
171 m->message = Message::CHANNEL_UP;
172 ViewMan::getInstance()->postMessage(m);
175 case Remote::CHANNELDOWN:
177 // cancel timer so this view is still here later
178 Timers::getInstance()->cancelTimer(this, 1); // if it exists
180 Message* m = new Message();
183 m->message = Message::CHANNEL_DOWN;
184 ViewMan::getInstance()->postMessage(m);
190 if (!eventList) return 2;
192 int eventListSize = eventList->size();
193 for(int i = 0; i < eventListSize; i++)
195 event = (*eventList)[i];
196 if (event->index == sl.getCurrentOption())
198 Log::getInstance()->log("VLiveBanner", Log::DEBUG, "Found the option you pointed at. %s", event->title);
199 // First, cancel my delete timer
200 Timers::getInstance()->cancelTimer(this, 1); // if it exists
202 VInfo* vi = new VInfo();
203 vi->setTitleText(event->title);
206 if (event->description) vi->setMainText(event->description);
207 else vi->setMainText(tr("Summary unavailable"));
208 if (Video::getInstance()->getFormat() == Video::PAL)
210 vi->setScreenPos(120, 130);
214 vi->setScreenPos(110, 90);
216 vi->create(510, 270);
218 ViewMan::getInstance()->add(vi);
226 return 2; // should not get here
233 void VLiveBanner::timercall(int clientReference)
236 Message* m = new Message();
237 m->message = Message::CLOSE_ME;
238 m->to = ViewMan::getInstance();
240 ViewMan::getInstance()->postMessage(m);