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);
51 // set a timer for deleting view
52 Timers::getInstance()->setTimer(this, 1, (struct timespec){4, 0});
55 VLiveBanner::~VLiveBanner()
60 void VLiveBanner::delData()
64 int eventListSize = eventList->size();
65 for(int i = 0; i < eventListSize; i++)
67 delete (*eventList)[i];
76 void VLiveBanner::setChannel(Channel* tChannel)
79 currentChannel = tChannel;
82 setTitleText(currentChannel->name);
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)
140 if (!takeCommands) return 0; // banner was auto, old remote
141 } // else drop through
150 case Remote::DF_DOWN:
152 if (!takeCommands) return 0; // banner was auto, old remote
153 } // else drop through
162 case Remote::CHANNELUP:
164 ViewMan::getInstance()->timedDelete(this, 0, 0); // cancel timer so this view is still here later
166 Message* m = new Message();
169 m->message = Message::CHANNEL_UP;
170 ViewMan::getInstance()->postMessage(m);
173 case Remote::CHANNELDOWN:
175 ViewMan::getInstance()->timedDelete(this, 0, 0);
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()->addNoLock(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);