]> git.vomp.tv Git - vompclient.git/blob - vwelcome.cc
Clean up of all video init system, NTSC/PAL, screen size functions.
[vompclient.git] / vwelcome.cc
1 /*
2     Copyright 2004-2005 Chris Tallon
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, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #include "vwelcome.h"
22
23 VWelcome::VWelcome()
24 {
25   setDimensions(190, 460);
26
27   if (Video::getInstance()->getFormat() == Video::PAL)
28   {
29     setScreenPos(140, 170);
30   }
31   else
32   {
33     setScreenPos(130, 140);
34   }
35
36   setBackgroundColour(Colour::VIEWBACKGROUND);
37   setTitleBarOn(1);
38   setTitleBarColour(Colour::TITLEBARBACKGROUND);
39   setTitleText("Welcome");
40
41   sl.setScreenPos(screenX + 20, screenY + 40);
42   sl.setDimensions(130, 170);
43
44   sl.addOption("1. Live TV", 1);
45   sl.addOption("2. Radio", 0);
46   sl.addOption("3. Recordings", 0);
47   sl.addOption("4. Stand by", 0);
48   sl.addOption("5. Reboot", 0);
49
50   jpeg.setScreenPos(screenX + 240, screenY + 50);
51 }
52
53 VWelcome::~VWelcome()
54 {
55 }
56
57 void VWelcome::draw()
58 {
59
60   View::draw();
61   sl.draw();
62
63   char timeString[20];
64   time_t t;
65   time(&t);
66   struct tm* tm = localtime(&t);
67   strftime(timeString, 19, "%H:%M", tm);
68
69   drawTextRJ(timeString, 450, 5, Colour::LIGHTTEXT);
70
71   jpeg.init("/vdr.jpg");
72   jpeg.draw();
73 }
74
75 int VWelcome::handleCommand(int command)
76 {
77   if (command == Remote::UP)
78   {
79     sl.up();
80     sl.draw();
81     show();
82     return 2;
83   }
84   else if (command == Remote::DOWN)
85   {
86     sl.down();
87     sl.draw();
88     show();
89     return 2;
90   }
91   else if (command == Remote::ONE)
92   {
93     doChannelsList();
94     return 2;
95   }
96   else if (command == Remote::TWO)
97   {
98     doRadioList();
99     return 2;
100   }
101   else if (command == Remote::THREE)
102   {
103     doRecordingsList();
104     return 2;
105   }
106   else if (command == Remote::FOUR)
107   {
108     Message* m = new Message();
109     m->message = Message::STANDBY;
110     Command::getInstance()->postMessage(m);
111     return 4;
112   }
113   else if (command == Remote::FIVE)
114   {
115     Command::getInstance()->doReboot();
116   }
117   else if (command == Remote::OK)
118   {
119     int option = sl.getCurrentOption();
120     if (option == 0)
121     {
122       doChannelsList();
123       return 2;
124     }
125     else if (option == 1)
126     {
127       doRadioList();
128       return 2;
129     }
130     else if (option == 2)
131     {
132       doRecordingsList();
133       return 2;
134     }
135     else if (option == 3)
136     {
137       Message* m = new Message();
138       m->message = Message::STANDBY;
139       Command::getInstance()->postMessage(m);
140       return 4;
141     }
142     else if (option == 4)
143     {
144       Command::getInstance()->doReboot();
145       return 2;
146     }
147   }
148
149   return 1;
150 }
151
152
153 void VWelcome::doChannelsList()
154 {
155   List* chanList = VDR::getInstance()->getChannelsList(VDR::VIDEO);
156
157   if (chanList)
158   {
159     VChannelList* vchan = new VChannelList(VDR::VIDEO);
160     vchan->setList(chanList);
161
162     ViewMan::getInstance()->addNoLock(vchan);
163     vchan->draw();
164     vchan->show();
165
166 //        Message* m = new Message();
167 //        m->from = this;
168 //        m->to = ViewMan::getInstance();
169 //        m->message = Message::SWAP_ME_FOR;
170 //        m->parameter = (ULONG)vchan;
171 //        ViewMan::getInstance()->postMessage(m);
172   }
173 }
174
175 void VWelcome::doRadioList()
176 {
177   List* chanList = VDR::getInstance()->getChannelsList(VDR::RADIO);
178
179   if (chanList)
180   {
181     VChannelList* vchan = new VChannelList(VDR::RADIO);
182     vchan->setList(chanList);
183
184     ViewMan::getInstance()->addNoLock(vchan);
185     vchan->draw();
186     vchan->show();
187   }
188 }
189
190 void VWelcome::doRecordingsList()
191 {
192   ViewMan* viewman = ViewMan::getInstance();
193
194   VInfo* viewWait = new VInfo();
195   viewWait->setDimensions(190, 460);
196   if (Video::getInstance()->getFormat() == Video::PAL)
197   {
198     viewWait->setScreenPos(140, 170);
199   }
200   else
201   {
202     viewWait->setScreenPos(130, 140);
203   }
204   viewWait->setMainText("\n                  Downloading recordings list");
205   viewWait->draw();
206   viewWait->show();
207   viewman->addNoLock(viewWait);
208
209
210   VDR* vdr = VDR::getInstance();
211   Directory* recDir = vdr->getRecordingsList();
212
213   if (recDir)
214   {
215     VRecordingList* vrec = new VRecordingList();
216     vrec->setDir(recDir);
217
218     ViewMan::getInstance()->addNoLock(vrec);
219
220     vrec->draw();
221     vrec->show();
222   }
223
224   Log::getInstance()->log("VWelcome", Log::DEBUG, "possible delay start");
225   viewman->removeView(viewWait, 1, 1);
226   Log::getInstance()->log("VWelcome", Log::DEBUG, "possible delay end");
227 }