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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include <linux/errno.h>
28 #include "remotewin.h"
32 #include "remoteandroid.h"
41 #include "vserverselect.h"
47 #include "timerreceiver.h"
57 #include "vsleeptimer.h"
61 Command* Command::instance = NULL;
73 wallpaper = wallpaper_pict = NULL;
81 Command* Command::getInstance()
86 int Command::init(bool tcrashed, char* tServer)
88 if (initted) return 0;
93 logger = Log::getInstance();
94 boxstack = BoxStack::getInstance();
95 remote = Remote::getInstance();
97 remote->InitHWCListwithDefaults();
99 if (!logger || !boxstack || !remote)
105 SkinFactory::InitSkin(0);
108 pthread_mutex_init(&masterLock, NULL);
110 masterLock=CreateMutex(NULL,FALSE,NULL);
116 int Command::shutdown()
118 if (!initted) return 0;
125 // VDR::getInstance()->cancelFindingServer();
126 logger->log("Command", Log::NOTICE, "Command stop1...");
129 logger->log("Command", Log::NOTICE, "Command stop2...");
133 void Command::doWallpaper()
135 Video* video = Video::getInstance();
138 Boxx* bbg = new Boxx();
139 bbg->setSize(video->getScreenWidth(), video->getScreenHeight());
141 bbg->fillColour(DrawStyle::WALLPAPER);
143 boxstack->update(bbg);
144 boxstack->remove(bbg);
147 wallpaper = new Boxx();
148 wallpaper->setSize(video->getScreenWidth(), video->getScreenHeight());
149 wallpaper->createBuffer();
150 wallpaper ->setBackgroundColour(DrawStyle::WALLPAPER);
155 wallpaper_pict = new WJpegTYPE();
156 wallpaper_pict->setSize(video->getScreenWidth(), video->getScreenHeight());
159 if (video->getFormat() == Video::PAL)
161 logger->log("Command", Log::DEBUG, "PAL wallpaper selected");
163 wallpaper_pict->init("/wallpaperPAL.jpg");
165 wallpaper_pict->init("wallpaperPAL.jpg");
170 logger->log("Command", Log::DEBUG, "NTSC wallpaper selected");
171 wallpaper_pict->init("/wallpaperNTSC.jpg");
173 if (DrawStyle::WALLPAPER.alpha) {
174 wallpaper_pict->setVisible(true);
176 wallpaper_pict->setVisible(false);
178 wallpaper->add(wallpaper_pict);
181 boxstack->add(wallpaper);
182 boxstack->update(wallpaper);
184 OsdVector* osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
187 osdv->updateBackgroundColor(DrawStyle::WALLPAPER);
196 if (!initted) return;
203 Video::getInstance()->signalOn();
204 Led::getInstance()->on();
208 // End of startup. Lock the mutex and put the first view up
209 // logger->log("Command", Log::DEBUG, "WANT LOCK");
211 pthread_mutex_lock(&masterLock);
213 WaitForSingleObject(masterLock, INFINITE );
215 //logger->log("Command", Log::DEBUG, "LOCKED");
223 VConnect* vconnect = new VConnect(server);
224 boxstack->add(vconnect);
228 // Start method 2 of getting commands in...
235 //logger->log("Command", Log::DEBUG, "UNLOCK");
237 pthread_mutex_unlock(&masterLock);
239 ReleaseMutex(masterLock);
242 button = remote->getButtonPress(2); // FIXME why is this set to 2 and not 0? so it can quit
243 // something happened, lock and process
245 // logger->log("Command", Log::DEBUG, "WANT LOCK");
247 pthread_mutex_lock(&masterLock);
249 WaitForSingleObject(masterLock, INFINITE );
251 // logger->log("Command", Log::DEBUG, "LOCK");
253 if ((button == Remote::NA_NONE) /*|| (button == Remote::NA_UNKNOWN)*/) continue;
255 if (button != Remote::NA_SIGNAL) handleCommand(button);
256 processMessageQueue();
260 //logger->log("Command", Log::DEBUG, "UNLOCK");
262 pthread_mutex_unlock(&masterLock);
264 ReleaseMutex(masterLock);
270 void Command::postMessage(Message* m)
272 // This is locked here in case the main loop is not waiting for an event, but is processing one
273 // it could be killed but then not react to it because the signal wouldn't cause
274 // remote->getButtonPress to break
275 // locking the mutex ensures that the master thread is waiting on getButtonPress
278 //logger->log("Command", Log::DEBUG, "WANT LOCK");
280 pthread_mutex_lock(&masterLock);
282 WaitForSingleObject(masterLock, INFINITE );
284 //logger->log("Command", Log::DEBUG, "LOCK");
285 MessageQueue::postMessage(m);
289 kill(mainPid, SIGURG);
291 ((RemoteAndroid*)Remote::getInstance())->Signal();
293 pthread_mutex_unlock(&masterLock);
295 ((RemoteWin*)Remote::getInstance())->Signal();
296 ReleaseMutex(masterLock);
298 //logger->log("Command", Log::DEBUG, "UNLOCK");
301 void Command::postMessageNoLock(Message* m)
303 // As above but use this one if this message is being posted because of a button press
304 // the mutex is already locked, locking around postMessage is not needed as the
305 // queue is guaranteed to be run when the button has been processed
306 MessageQueue::postMessage(m);
309 bool Command::postMessageIfNotBusy(Message* m)
311 // Used for Windows mouse events
313 //logger->log("Command", Log::DEBUG, "TRY LOCK");
315 if (pthread_mutex_trylock(&masterLock) != EBUSY)
317 //logger->log("Command", Log::DEBUG, "LOCK");
318 MessageQueue::postMessage(m);
320 kill(mainPid, SIGURG);
322 ((RemoteAndroid*)Remote::getInstance())->Signal();
324 pthread_mutex_unlock(&masterLock);
325 //logger->log("Command", Log::DEBUG, "UNLOCK");
333 switch (WaitForSingleObject(masterLock, 0 ))
334 { //FIXME this is not "if not busy" check
335 case WAIT_OBJECT_0: //but with proper argument 0 this did not work
336 // case WAIT_ABANDONED:
337 MessageQueue::postMessage(m);
338 ((RemoteWin*)Remote::getInstance())->Signal();
339 ReleaseMutex(masterLock);
342 case WAIT_ABANDONED: return false;
343 case WAIT_TIMEOUT: return false;
349 void Command::postMessageFromOuterSpace(Message* m)
352 Yet another way of getting messages into Command. This one is for events that
353 are not standard button presses (or UDP generated buttons). It is also not for
354 events that are generated as a result of other events (events that can safely
355 call postMessageNoLock and be guaranteed that the message will be processed
356 because it is known that the queue is currently being processed).
357 This is for events that come from outer space and can occur when the master
358 mutex is locked or not, they need to be queued and executed but it doesn't
360 Actually so far it is for events caused by the video stream - aspect ratio
361 changes. These can occur when the master mutex is locked and so postMessage
362 doesn't work. postMessageNoLock doesn't work because if the mutex *isn't*
363 locked at the time then the message could be sat around a while before
365 The whole message system was at first supposed to prevent the problem of
366 calling a function on an object that had just been deleted, by ordering
367 messages such that all calls are done before object deletion. However,
368 because of the new centralised messaging system and the fact that BoxStack
369 locates the destination object before calling it, the messaging system now
370 allows the kind of sloppy calls it was supposed to stop. Weird huh. This
371 is mentioned here because the video stream might generate an event just as
372 the user hits stop. The mutex is locked, and by the time the message
373 is examined the vvideorec/live has been deleted. This doesn't matter because
374 boxstack will drop the message if it can't find the matching object to
376 Finally, all this is fine and dandy, except that I'm not 100% sure that
377 this sloppy postMessage and hope a queued signal will force it to be processed
378 thingy will actually work. Hmmm.
379 Lastly <g>, I will consider making the naming system a little more sane
383 logger->log("Command", Log::DEBUG, "PMFOS called");
384 MessageQueue::postMessage(m);
388 kill(mainPid, SIGURG);
390 ((RemoteAndroid*)Remote::getInstance())->Signal();
393 ((RemoteWin*)Remote::getInstance())->Signal();
397 void Command::processMessage(Message* m)
399 // FIXME - a slight modification - how if messagereceivers were to register
400 // themselves as receivers to avoid the calling-a-deleted-object problem
401 // then only deliver/register/unregister would have to be protected
403 logger->log("Command", Log::DEBUG, "processing message %i", m->message);
411 case Message::STOP_PLAYBACK:
413 handleCommand(Remote::STOP); // an odd way of doing it, but so simple
416 // Also connection_lost comes from player - anywhere else?
420 case Message::VDR_CONNECTED:
422 doJustConnected((VConnect*)m->from);
425 case Message::SCREENSHOT:
427 #ifdef VOMP_PLATTFORM_MVP
428 Osd::getInstance()->screenShot("/out.jpg");
430 logger->log("Osd", Log::NOTICE, "Screenshot Message arrived");
431 Osd::getInstance()->screenShot("out.jpg");
435 case Message::CONNECTION_LOST:
440 case Message::UDP_BUTTON:
442 handleCommand(m->parameter.num);
445 case Message::CHANGE_LANGUAGE:
447 boxstack->removeAll();
448 boxstack->update(wallpaper);
450 if (!VDR::getInstance()->isConnected()) { connectionLost(); break; }
451 VWelcome* vw = new VWelcome();
454 boxstack->update(vw);
457 case Message::LAST_VIEW_CLOSE:
459 // Shouldn't be done like this. Some generic message pass back from vinfo perhaps
466 // VWelcome* vw = new VWelcome();
468 // boxstack->add(vw);
469 // boxstack->update(vw);
473 case Message::NEW_PICTURE:
475 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE");
476 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
478 osdv->informPicture(m->tag,m->parameter.handle);
482 case Message::NEW_PICTURE_STATIC:
484 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE %x %x",m->tag,m->parameter.num);
485 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
487 osdv->informPicture(((unsigned long long)m->tag)<<32LL,m->parameter.handle);
497 Instead of sending through the boxstack, implement a more generic MessageReceiver interface
498 and have potential receivers register with something
499 When a message needs to be delivered, check if the receiver is still registered, if so, deliver the message
500 This could all be done using the existing big command mutex to keep it simple
503 logger->log("Command", Log::DEBUG, "Sending message to boxstack");
504 boxstack->processMessage(m);
508 void Command::handleCommand(int button)
510 if (isStandby && (button != Remote::POWER)
511 && (button != Remote::POWERON) && (button != Remote::POWEROFF)) return;
512 if (!connLost && boxstack->handleCommand(button)) return; // don't send to boxstack if connLost
514 // command was not handled
518 case Remote::DF_LEFT:
519 case Remote::DF_RIGHT:
520 case Remote::VOLUMEUP:
521 case Remote::VOLUMEDOWN:
523 if (remote->handlesVolume()) {
524 if (button==Remote::DF_LEFT || button==Remote::VOLUMEDOWN)
525 remote->volumeDown();
526 else remote->volumeUp();
528 VVolume* v = new VVolume();
530 v->handleCommand(button); // this will draw+show
536 if (remote->handlesVolume()) {
537 remote->volumeMute();
539 VMute* v = new VMute();
551 case Remote::POWERON:
556 case Remote::POWEROFF:
564 if (!connLost) return; // if connLost, handle Remote::OK
570 VSleeptimer* sleep = new VSleeptimer();
571 boxstack->add(sleep);
572 sleep->handleCommand(button); // this will draw+show
581 Message* m = new Message(); // break into master mutex
582 m->message = Message::SCREENSHOT;
588 void Command::doStandby()
601 void Command::doPowerOn()
605 Video::getInstance()->signalOn();
606 Led::getInstance()->on();
607 Remote::getInstance()->changePowerState(true);
611 VConnect* vconnect = new VConnect(server);
612 boxstack->add(vconnect);
617 void Command::doPowerOff()
621 VDR::getInstance()->shutdownVDR();
622 boxstack->removeAll();
623 Video::getInstance()->signalOff();
624 boxstack->update(wallpaper);
626 VDR::getInstance()->configSave("General", "Last Power State", "Off");
627 logger->unsetExternLogger();
628 VDR::getInstance()->disconnect();
629 Led::getInstance()->off();
630 Remote::getInstance()->changePowerState(false);
632 Sleeptimer::getInstance()->shutdown();
634 stop(); //different behavoiur on windows, we exit
639 void Command::doFromTheTop(bool which)
641 if (isStandby) return;
646 logger->log("Command", Log::NOTICE, "Connection lost dialog already present");
650 logger->log("Command", Log::NOTICE, "Doing connection lost dialog");
651 connLost = new VInfo();
652 connLost->setSize(360, 200);
653 connLost->createBuffer();
654 if (Video::getInstance()->getFormat() == Video::PAL)
655 connLost->setPosition(190, 170);
657 connLost->setPosition(180, 120);
658 connLost->setOneLiner(tr("Connection lost"));
659 connLost->setDropThrough();
660 connLost->setBorderOn(1);
661 connLost->setTitleBarColour(DrawStyle::DANGER);
662 connLost->okButton();
664 boxstack->add(connLost);
665 boxstack->update(connLost);
666 remote->clearBuffer();
670 logger->unsetExternLogger();
671 VDR::getInstance()->disconnect();
672 boxstack->removeAll();
673 boxstack->update(wallpaper);
677 remote->clearBuffer();
679 // at this point, everything should be reset to first-go
681 VConnect* vconnect = new VConnect(server);
682 boxstack->add(vconnect);
687 void Command::doReboot()
690 logger->unsetExternLogger();
691 VDR::getInstance()->disconnect();
693 logger->log("Command", Log::NOTICE, "Reboot");
695 #ifndef VOMP_HAS_EXIT
696 // some plattforms, want a proper deinitialisation of their hardware before reboot
697 Osd::getInstance()->shutdown();
698 Audio::getInstance()->shutdown();
699 Video::getInstance()->shutdown();
700 Remote::getInstance()->shutdown();
702 reboot(LINUX_REBOOT_CMD_RESTART);
703 // if reboot is not allowed -> stop
715 #endif //Would we support this on windows?
718 void Command::connectionLost()
720 logger->unsetExternLogger();
721 Message* m = new Message(); // break into master mutex
722 m->message = Message::CONNECTION_LOST;
724 postMessageFromOuterSpace(m);
727 void Command::buildCrashedBox()
729 VInfo* crash = new VInfo();
730 crash->setSize(360, 250);
731 crash->createBuffer();
732 if (Video::getInstance()->getFormat() == Video::PAL)
733 crash->setPosition(190, 146);
735 crash->setPosition(180, 96);
736 crash->setMainText("Oops, vomp crashed.. :(\nPlease report this crash to the author, with as much detail as possible about what you were doing at the time that might have caused the crash.");
737 crash->setBorderOn(1);
738 crash->setTitleBarColour(DrawStyle::DANGER);
740 crash->setExitable();
742 boxstack->add(crash);
743 boxstack->update(crash);
746 int Command::getLangPref(bool subtitle,const char* langcode)
748 vector<struct ASLPref>::iterator itty=langcodes.begin();
749 char templangcode[4];
750 templangcode[0]=langcode[0];
751 templangcode[1]=langcode[1];
752 templangcode[2]=langcode[2];
753 templangcode[3]='\0';
755 while (itty != langcodes.end()) {
756 size_t pos=(*itty).langcode.find(templangcode);
757 if (pos != string::npos) {
758 vector<struct ASLPref>::iterator itty2=langcodes.begin();
759 for (int i=0; i<langcodes.size();i++) {
762 pref=langcodes[i].subtitlepref;
764 pref=langcodes[i].audiopref;
769 if (langcodes[i].subtitlepref==langpos) {
773 if (langcodes[i].audiopref==langpos) {
783 return langcodes.size(); //neutral
786 void Command::doJustConnected(VConnect* vconnect)
789 if (!VDR::getInstance()->isConnected()) { connectionLost(); return; }
790 logger->log("Command", Log::INFO, "Entering doJustConnected");
792 Video* video = Video::getInstance();
793 Audio* audio = Audio::getInstance();
794 boxstack->remove(vconnect);
796 VInfo* vi = new VInfo();
797 vi->setSize(400, 200);
799 if (video->getFormat() == Video::PAL)
800 vi->setPosition(170, 200);
802 vi->setPosition(160, 150);
803 vi->setOneLiner(tr("Connected, loading config"));
806 boxstack->update(vi);
808 VDR* vdr = VDR::getInstance();
811 // See if we're supposed to do network logging
812 config = vdr->configLoad("Advanced", "Network logging");
813 if (config && !STRCASECMP(config, "On"))
815 logger->log("Command", Log::INFO, "Turning on network logging");
816 logger->setExternLogger(vdr);
820 logger->unsetExternLogger();
821 logger->log("Command", Log::INFO, "Turned off network logging");
823 if (config) delete[] config;
825 config = vdr->configLoad("Advanced", "Skin Name");
827 const char **skinnames=SkinFactory::getSkinNames();
828 for (int i=0;i<SkinFactory::getNumberofSkins();i++) {
829 if (!STRCASECMP(config, skinnames[i])) {
830 SkinFactory::InitSkin(i);
835 if (wallpaper && wallpaper_pict) {
836 if (DrawStyle::WALLPAPER.alpha) {
837 wallpaper_pict->setVisible(true);
839 wallpaper_pict->setVisible(false);
842 boxstack->update(wallpaper);
846 SkinFactory::InitSkin(0);
849 // See if config says to override video format (PAL/NTSC)
850 config = vdr->configLoad("General", "Override Video Format");
853 logger->log("Command", Log::DEBUG, "Override Video Format is present");
855 if ( (!strcmp(config, "PAL") && (video->getFormat() != Video::PAL))
856 || (!strcmp(config, "NTSC") && (video->getFormat() != Video::NTSC))
857 || (!strcmp(config, "PAL_M") && (video->getFormat() != Video::PAL_M))
858 || (!strcmp(config, "NTSC_J") && (video->getFormat() != Video::NTSC_J))
861 // Oh sheesh, need to switch format. Bye bye TV...
863 // Take everything down
864 boxstack->removeAll();
865 boxstack->remove(wallpaper);
866 Osd* osd = Osd::getInstance();
872 remote->shutdown(); // need on raspberry shut not do any harm, hopefully
873 remote->init(RemoteStartDev);
875 // Get video and osd back up with the new mode
876 if (!strcmp(config, "PAL"))
878 logger->log("Command", Log::DEBUG, "Switching to PAL");
879 video->init(Video::PAL);
881 else if (!strcmp(config, "NTSC"))
883 logger->log("Command", Log::DEBUG, "Switching to NTSC");
884 video->init(Video::NTSC);
885 } else if (!strcmp(config, "PAL_M"))
887 logger->log("Command", Log::DEBUG, "Switching to PAL_M");
888 video->init(Video::PAL_M);
889 } else if (!strcmp(config, "NTSC_J"))
891 logger->log("Command", Log::DEBUG, "Switching to NTSC_J");
892 video->init(Video::NTSC_J);
897 //we do not init twice
898 osd->init((char*)("/dev/stbgfx"));
901 // Put the wallpaper back
906 vi->setSize(400, 200);
908 if (video->getFormat() == Video::PAL)
909 vi->setPosition(170, 200);
911 vi->setPosition(160, 150);
913 vi->setOneLiner(tr("Connected, loading config"));
916 boxstack->update(vi);
920 logger->log("Command", Log::DEBUG, "Already in requested mode, or request was not 'PAL' or 'NTSC'");
925 logger->log("Command", Log::DEBUG, "Phew, no dangerous on-the-fly mode switching to do!");
928 // Power off if first boot and config says so
933 logger->log("Command", Log::DEBUG, "Load power after boot");
935 config = vdr->configLoad("General", "Power After Boot");
939 if (!STRCASECMP(config, "On"))
941 logger->log("Command", Log::INFO, "Config says Power After Boot = On");
943 else if (!STRCASECMP(config, "Off"))
945 logger->log("Command", Log::INFO, "Config says Power After Boot = Off");
950 else if (!STRCASECMP(config, "Last state"))
952 char* lastPowerState = vdr->configLoad("General", "Last Power State");
955 if (!STRCASECMP(lastPowerState, "On"))
957 logger->log("Command", Log::INFO, "Config says Last Power State = On");
959 else if (!STRCASECMP(lastPowerState, "Off"))
961 logger->log("Command", Log::INFO, "Config says Last Power State = Off");
968 logger->log("Command", Log::INFO, "Config General/Last Power State not understood");
973 logger->log("Command", Log::INFO, "Config General/Last Power State not found");
978 logger->log("Command", Log::INFO, "Config/Power After Boot not understood");
984 logger->log("Command", Log::INFO, "Config General/Power After Boot not found");
989 // Go S-Video if config says so
991 config = vdr->configLoad("TV", "Connection");
995 if (!STRCASECMP(config, "S-Video"))
997 logger->log("Command", Log::INFO, "Switching to S-Video as Connection=%s", config);
998 video->setConnection(Video::SVIDEO);
999 } else if (!STRCASECMP(config, "HDMI"))
1001 logger->log("Command", Log::INFO, "Switching to HDMI as Connection=%s", config);
1002 video->setConnection(Video::HDMI);
1003 } else if (!STRCASECMP(config, "HDMI3D"))
1005 logger->log("Command", Log::INFO, "Switching to HDMI3D as Connection=%s", config);
1006 video->setConnection(Video::HDMI3D);
1010 logger->log("Command", Log::INFO, "Switching to RGB/Composite as Connection=%s", config);
1011 video->setConnection(Video::COMPOSITERGB);
1017 logger->log("Command", Log::INFO, "Config TV/S-Video not found");
1020 // Set to shutdown VDR if config says
1022 config = vdr->configLoad("General", "VDR shutdown");
1025 if (!STRCASECMP(config, "On"))
1027 logger->log("Command", Log::INFO, "Shutdown VDR when shutting down vomp");
1028 vdr->setVDRShutdown(true);
1030 else if (!STRCASECMP(config, "Off"))
1032 logger->log("Command", Log::INFO, "Shutdown only vomp");
1033 vdr->setVDRShutdown(false);
1038 logger->log("Command", Log::INFO, "Default shutdown only vomp");
1039 vdr->setVDRShutdown(false); // Default
1044 config = vdr->configLoad("General", "Remote type");
1048 if (!STRCASECMP(config, "New"))
1050 logger->log("Command", Log::INFO, "Switching to New remote type");
1051 remote->setRemoteType(Remote::NEWREMOTE);
1055 logger->log("Command", Log::INFO, "Switching to Old remote type");
1056 remote->setRemoteType(Remote::OLDREMOTE);
1062 logger->log("Command", Log::INFO, "Config General/Remote type not found");
1063 remote->setRemoteType(Remote::OLDREMOTE);
1068 // Get TV aspect ratio
1070 config = vdr->configLoad("TV", "Aspect");
1073 if (!STRCASECMP(config, "16:9"))
1075 logger->log("Command", Log::INFO, "/// Switching to TV aspect 16:9");
1076 video->setTVsize(Video::ASPECT16X9);
1080 logger->log("Command", Log::INFO, "/// Switching to TV aspect 4:3");
1081 video->setTVsize(Video::ASPECT4X3);
1087 logger->log("Command", Log::INFO, "Config TV/Aspect type not found, going 4:3");
1088 video->setTVsize(Video::ASPECT4X3);
1091 config = vdr->configLoad("TV", "Widemode");
1094 if (!STRCASECMP(config, "Letterbox"))
1096 logger->log("Command", Log::INFO, "Setting letterbox mode");
1097 video->setMode(Video::LETTERBOX);
1101 logger->log("Command", Log::INFO, "Setting chop-sides mode");
1102 video->setMode(Video::NORMAL);
1109 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting letterbox mode");
1110 video->setMode(Video::LETTERBOX);
1112 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting chop-sides mode");
1113 video->setMode(Video::NORMAL);
1117 config = vdr->configLoad("Advanced", "TCP receive window");
1120 size_t newTCPsize = atoi(config);
1123 logger->log("Command", Log::INFO, "Setting TCP window size %i", newTCPsize);
1124 vdr->setReceiveWindow(newTCPsize);
1128 logger->log("Command", Log::INFO, "TCP window size not found, setting 2048");
1129 if (DEFAULT_TCP_WINDOWSIZE) vdr->setReceiveWindow(2048); // Default
1132 config = vdr->configLoad("Advanced", "Font Name");
1135 Osd::getInstance()->setFont(config);
1136 logger->log("Command", Log::INFO, "Setting Font to %s", config);
1142 // Set recording list type
1145 #ifdef ADVANCED_MENUES
1146 config = vdr->configLoad("Advanced", "Menu type");
1150 if (!STRCASECMP(config, "Advanced"))
1152 logger->log("Command", Log::INFO, "Switching to Advanced menu");
1158 logger->log("Command", Log::INFO, "Switching to Classic menu");
1165 logger->log("Command", Log::INFO, "Config General/menu type not found");
1170 config = vdr->configLoad("Advanced", "Disable WOL");
1173 if (!STRCASECMP(config, "Yes"))
1175 logger->log("Command", Log::INFO, "Config says disable WOL");
1176 Wol::getInstance()->setEnabled(false);
1180 logger->log("Command", Log::INFO, "Config says enable WOL");
1181 Wol::getInstance()->setEnabled(true);
1188 logger->log("Command", Log::INFO, "By default, enable WOL");
1189 Wol::getInstance()->setEnabled(true);
1191 /* device dependend config */
1192 audio->loadOptionsfromServer(vdr);
1193 video->loadOptionsfromServer(vdr);
1194 remote->loadOptionsfromServer(vdr);
1196 video->executePendingModeChanges();
1199 // Save power state = on
1201 vdr->configSave("General", "Last Power State", "On");
1203 // Make sure connection didn't die
1204 if (!vdr->isConnected())
1206 Command::getInstance()->connectionLost();
1210 boxstack->remove(vi);
1212 VWelcome* vw = new VWelcome();
1215 boxstack->update(vw);
1217 // Enter pre-keys here
1218 // handleCommand(Remote::OK);
1219 // handleCommand(Remote::THREE);
1220 // handleCommand(Remote::SIX);
1221 // handleCommand(Remote::OK);
1222 // handleCommand(Remote::UP);
1223 // handleCommand(Remote::PLAY);
1224 // handleCommand(Remote::DOWN);
1225 // handleCommand(Remote::DOWN);
1226 // handleCommand(Remote::DOWN);
1227 // handleCommand(Remote::OK);
1228 // handleCommand(Remote::RED);