]> git.vomp.tv Git - vompclient.git/blob - vwelcome.cc
Options view files added, new remote type supported
[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(200, 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(140, 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. Options", 0);
48   sl.addOption("5. Stand by", 0);
49   sl.addOption("6. Reboot", 0);
50
51   jpeg.setScreenPos(screenX + 240, screenY + 60);
52 }
53
54 VWelcome::~VWelcome()
55 {
56 }
57
58 void VWelcome::draw()
59 {
60
61   View::draw();
62   sl.draw();
63
64   char timeString[20];
65   time_t t;
66   time(&t);
67   struct tm* tm = localtime(&t);
68   strftime(timeString, 19, "%H:%M", tm);
69
70   drawTextRJ(timeString, 450, 5, Colour::LIGHTTEXT);
71
72   jpeg.init("/vdr.jpg");
73   jpeg.draw();
74 }
75
76 int VWelcome::handleCommand(int command)
77 {
78   switch(command)
79   {
80     case Remote::DF_UP:
81     case Remote::UP:
82     {
83       sl.up();
84       sl.draw();
85       show();
86       return 2;
87     }
88     case Remote::DF_DOWN:
89     case Remote::DOWN:
90     {
91       sl.down();
92       sl.draw();
93       show();
94       return 2;
95     }
96     case Remote::ONE:
97     {
98       doChannelsList();
99       return 2;
100     }
101     case Remote::TWO:
102     {
103       doRadioList();
104       return 2;
105     }
106     case Remote::THREE:
107     {
108       doRecordingsList();
109       return 2;
110     }
111     case Remote::FOUR:
112     {
113       doOptions();
114       return 2;
115     }
116     case Remote::FIVE:
117     {
118       Message* m = new Message();
119       m->message = Message::STANDBY;
120       Command::getInstance()->postMessage(m);
121       return 4;
122     }
123     case Remote::SIX:
124     {
125       Command::getInstance()->doReboot();
126     }
127     case Remote::OK:
128     {
129       int option = sl.getCurrentOption();
130       if (option == 0)
131       {
132         doChannelsList();
133         return 2;
134       }
135       else if (option == 1)
136       {
137         doRadioList();
138         return 2;
139       }
140       else if (option == 2)
141       {
142         doRecordingsList();
143         return 2;
144       }
145       else if (option == 3)
146       {
147         doOptions();
148         return 2;
149       }
150       else if (option == 4)
151       {
152         Message* m = new Message();
153         m->message = Message::STANDBY;
154         Command::getInstance()->postMessage(m);
155         return 4;
156       }
157       else if (option == 5)
158       {
159         Command::getInstance()->doReboot();
160         return 2;
161       }
162       return 2; // never gets here
163     }
164   }
165
166   return 1;
167 }
168
169
170 void VWelcome::doChannelsList()
171 {
172   List* chanList = VDR::getInstance()->getChannelsList(VDR::VIDEO);
173
174   if (chanList)
175   {
176     VChannelList* vchan = new VChannelList(VDR::VIDEO);
177     vchan->setList(chanList);
178
179     ViewMan::getInstance()->addNoLock(vchan);
180     vchan->draw();
181     vchan->show();
182
183 //        Message* m = new Message();
184 //        m->from = this;
185 //        m->to = ViewMan::getInstance();
186 //        m->message = Message::SWAP_ME_FOR;
187 //        m->parameter = (ULONG)vchan;
188 //        ViewMan::getInstance()->postMessage(m);
189   }
190 }
191
192 void VWelcome::doRadioList()
193 {
194   List* chanList = VDR::getInstance()->getChannelsList(VDR::RADIO);
195
196   if (chanList)
197   {
198     VChannelList* vchan = new VChannelList(VDR::RADIO);
199     vchan->setList(chanList);
200
201     ViewMan::getInstance()->addNoLock(vchan);
202     vchan->draw();
203     vchan->show();
204   }
205 }
206
207 void VWelcome::doRecordingsList()
208 {
209   ViewMan* viewman = ViewMan::getInstance();
210
211   VInfo* viewWait = new VInfo();
212   viewWait->setDimensions(190, 460);
213   if (Video::getInstance()->getFormat() == Video::PAL)
214   {
215     viewWait->setScreenPos(140, 170);
216   }
217   else
218   {
219     viewWait->setScreenPos(130, 140);
220   }
221   viewWait->setMainText("\n                  Downloading recordings list");
222   viewWait->draw();
223   viewWait->show();
224   viewman->addNoLock(viewWait);
225
226
227   VDR* vdr = VDR::getInstance();
228   Directory* recDir = vdr->getRecordingsList();
229
230   if (recDir)
231   {
232     VRecordingList* vrec = new VRecordingList();
233     vrec->setDir(recDir);
234
235     ViewMan::getInstance()->addNoLock(vrec);
236
237     vrec->draw();
238     vrec->show();
239   }
240
241   Log::getInstance()->log("VWelcome", Log::DEBUG, "possible delay start");
242   viewman->removeView(viewWait, 1, 1);
243   Log::getInstance()->log("VWelcome", Log::DEBUG, "possible delay end");
244 }
245
246 void VWelcome::doOptions()
247 {
248   VOptions* voptions = new VOptions();
249   ViewMan::getInstance()->addNoLock(voptions);
250   voptions->draw();
251   voptions->show();
252 }