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