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
23 VWelcome* VWelcome::instance = NULL;
35 if (Video::getInstance()->getFormat() == Video::PAL)
37 setScreenPos(140, 170);
41 setScreenPos(130, 140);
44 setBackgroundColour(Colour::VIEWBACKGROUND);
46 setTitleBarColour(Colour::TITLEBARBACKGROUND);
48 sl.setSurface(surface);
49 sl.setSurfaceOffset(20, 40);
50 sl.setDimensions(170, 140);
52 jpeg.setSurface(surface);
53 jpeg.setSurfaceOffset(240, 60);
60 Timers::getInstance()->cancelTimer(this, 1);
64 VWelcome* VWelcome::getInstance()
69 void VWelcome::setup()
72 setTitleText(tr("Welcome"));
73 sl.addOption(tr("1. Live TV"), 1);
74 sl.addOption(tr("2. Radio"), 0);
75 sl.addOption(tr("3. Recordings"), 0);
76 sl.addOption(tr("4. Options"), 0);
77 sl.addOption(tr("5. Stand by"), 0);
78 sl.addOption(tr("6. Reboot"), 0);
85 jpeg.init("/vdr.jpg");
90 void VWelcome::drawClock()
92 // Blank the area first
93 rectangle(area.w - 60, 0, 60, 30, titleBarColour);
98 struct tm* tms = localtime(&t);
99 strftime(timeString, 19, "%H:%M", tms);
100 drawTextRJ(timeString, 450, 5, Colour::LIGHTTEXT);
101 time_t dt = 60 - (t % 60);
102 if (dt == 0) dt = 60;
103 Timers::getInstance()->setTimer(this, 1, (struct timespec){dt, 0});
106 void VWelcome::timercall(int clientReference)
109 ViewMan::getInstance()->updateView(this, &clockRegion);
112 int VWelcome::handleCommand(int command)
118 VInfo* viewWait = new VInfo();
119 viewWait->create(100, 100);
120 viewWait->setScreenPos(485, 185);
121 viewWait->setTitleBarOn(0);
122 viewWait->setBackgroundColour(Colour::DANGER);
125 ViewMan::getInstance()->add(viewWait);
138 case Remote::DF_DOWN:
168 Message* m = new Message();
169 m->message = Message::STANDBY;
170 Command::getInstance()->postMessage(m);
175 Command::getInstance()->doReboot();
179 int option = sl.getCurrentOption();
185 else if (option == 1)
190 else if (option == 2)
195 else if (option == 3)
200 else if (option == 4)
202 Message* m = new Message();
203 m->message = Message::STANDBY;
204 Command::getInstance()->postMessage(m);
207 else if (option == 5)
209 Command::getInstance()->doReboot();
212 return 2; // never gets here
220 void VWelcome::doChannelsList()
222 ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::VIDEO);
226 VChannelList* vchan = new VChannelList(VDR::VIDEO);
227 vchan->setList(chanList);
229 ViewMan::getInstance()->add(vchan);
234 // Message* m = new Message();
236 // m->to = ViewMan::getInstance();
237 // m->message = Message::SWAP_ME_FOR;
238 // m->parameter = (ULONG)vchan;
239 // ViewMan::getInstance()->postMessage(m);
243 void VWelcome::doRadioList()
245 ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::RADIO);
249 VChannelList* vchan = new VChannelList(VDR::RADIO);
250 vchan->setList(chanList);
252 ViewMan::getInstance()->add(vchan);
258 void VWelcome::doRecordingsList()
260 ViewMan* viewman = ViewMan::getInstance();
262 VInfo* viewWait = new VInfo();
263 viewWait->create(460, 190);
264 if (Video::getInstance()->getFormat() == Video::PAL)
266 viewWait->setScreenPos(140, 170);
270 viewWait->setScreenPos(130, 140);
272 viewWait->setOneLiner(tr("Downloading recordings list"));
275 viewman->add(viewWait);
278 VDR* vdr = VDR::getInstance();
279 Directory* recDir = vdr->getRecordingsList();
283 VRecordingList* vrec = new VRecordingList(NULL);
284 vrec->setDir(recDir);
286 ViewMan::getInstance()->add(vrec);
292 Log::getInstance()->log("VWelcome", Log::DEBUG, "possible delay start");
293 viewman->removeView(viewWait);
294 Log::getInstance()->log("VWelcome", Log::DEBUG, "possible delay end");
297 void VWelcome::doOptions()
299 VOptions* voptions = new VOptions();
300 ViewMan::getInstance()->add(voptions);
305 void VWelcome::processMessage(Message* m)
307 if (m->message == Message::REDRAW_LANG)
309 Log::getInstance()->log("VWelcome", Log::DEBUG, "Got redraw lang message");
312 show(); // careful, this only works properly because the only place
313 // this is called from is voptions and that disappears before
314 // this message is delivered