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;
79 setTitleText(currentChannel->name);
80 eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
84 sl.addOption(tr("No channel data available"), 1);
89 Log::getInstance()->log("Banner", Log::DEBUG, "Start sort");
90 sort(eventList->begin(), eventList->end(), EventSorter());
91 Log::getInstance()->log("Banner", Log::DEBUG, "End sort");
94 char tempString2[300];
98 int eventListSize = eventList->size();
99 for(int i = 0; i < eventListSize; i++)
101 event = (*eventList)[i];
103 btime = localtime((time_t*)&event->time);
104 strftime(tempString2, 299, "%0H:%0M ", btime);
105 snprintf(tempString, 299, "%s %s", tempString2, event->title);
106 event->index = sl.addOption(tempString, first);
110 // Reset the timer as it probably took 1-2 seconds to change the channel
111 Timers::getInstance()->cancelTimer(this, 1); // if it exists
112 Timers::getInstance()->setTimer(this, 1, (struct timespec){4, 0});
116 void VLiveBanner::draw()
120 rectangle(0, area.h - 30, area.w, 30, titleBarColour);
122 rectangle(7, area.h - 24, 18, 16, Colour::RED);
123 drawText(tr("info"), 32, area.h - 25, Colour::LIGHTTEXT);
126 int VLiveBanner::handleCommand(int command)
133 Timers::getInstance()->cancelTimer(this, 1); // if it exists
138 if (!takeCommands) return 0; // banner was auto, old remote
139 } // else drop through
148 case Remote::DF_DOWN:
150 if (!takeCommands) return 0; // banner was auto, old remote
151 } // else drop through
160 case Remote::CHANNELUP:
162 // cancel timer so this view is still here later
163 Timers::getInstance()->cancelTimer(this, 1); // if it exists
165 Message* m = new Message();
168 m->message = Message::CHANNEL_UP;
169 ViewMan::getInstance()->postMessage(m);
172 case Remote::CHANNELDOWN:
174 // cancel timer so this view is still here later
175 Timers::getInstance()->cancelTimer(this, 1); // if it exists
177 Message* m = new Message();
180 m->message = Message::CHANNEL_DOWN;
181 ViewMan::getInstance()->postMessage(m);
187 if (!eventList) return 2;
189 int eventListSize = eventList->size();
190 for(int i = 0; i < eventListSize; i++)
192 event = (*eventList)[i];
193 if (event->index == sl.getCurrentOption())
195 Log::getInstance()->log("VLiveBanner", Log::DEBUG, "Found the option you pointed at. %s", event->title);
196 // First, cancel my delete timer
197 Timers::getInstance()->cancelTimer(this, 1); // if it exists
199 VInfo* vi = new VInfo();
200 vi->setTitleText(event->title);
203 if (event->description) vi->setMainText(event->description);
204 else vi->setMainText(tr("Summary unavailable"));
205 if (Video::getInstance()->getFormat() == Video::PAL)
207 vi->setScreenPos(120, 130);
211 vi->setScreenPos(110, 90);
213 vi->create(510, 270);
215 ViewMan::getInstance()->add(vi);
223 return 2; // should not get here
230 void VLiveBanner::timercall(int clientReference)
233 Message* m = new Message();
234 m->message = Message::CLOSE_ME;
235 m->to = ViewMan::getInstance();
237 ViewMan::getInstance()->postMessage(m);