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"
60 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);
241 button = remote->getButtonPress(2); // Don't block (0) in case a signal arrives after checking signals but before this line
242 // something happened, lock and process
243 if (signals) processSignals(); // If a signal arrived process now.
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::setSignal(int signalReceived)
272 if (signalReceived == SIGINT)
274 else if (signalReceived == SIGTERM)
276 else if (signalReceived == SIGUSR1)
278 else if (signalReceived == SIGUSR2)
280 else if (signalReceived == SIGURG)
284 void Command::processSignals()
286 if (signals & SIG_INT)
288 signals = signals & ~SIG_INT;
289 logger->log("Command", Log::NOTICE, "INT signal, shutting down...");
293 if (signals & SIG_TERM)
295 signals = signals & ~SIG_TERM;
296 logger->log("Command", Log::NOTICE, "TERM signal, shutting down...");
300 if (signals & SIG_USR1)
302 logger->log("Command", Log::NOTICE, "USR1 signal");
303 signals = signals & ~SIG_USR1;
306 if (signals & SIG_USR2)
308 logger->log("Command", Log::NOTICE, "USR2 signal");
309 signals = signals & ~SIG_USR2;
312 if (signals & SIG_URG)
314 logger->log("Command", Log::NOTICE, "URG signal"); // This is used to break from getButtonPress to process the message queue
315 signals = signals & ~SIG_URG;
319 void Command::postMessage(Message* m)
321 // This is locked here in case the main loop is not waiting for an event, but is processing one
322 // it could be killed but then not react to it because the signal wouldn't cause
323 // remote->getButtonPress to break
324 // locking the mutex ensures that the master thread is waiting on getButtonPress
327 //logger->log("Command", Log::DEBUG, "WANT LOCK");
329 pthread_mutex_lock(&masterLock);
331 WaitForSingleObject(masterLock, INFINITE );
333 //logger->log("Command", Log::DEBUG, "LOCK");
334 MessageQueue::postMessage(m);
338 kill(mainPid, SIGURG);
340 ((RemoteAndroid*)Remote::getInstance())->Signal();
342 pthread_mutex_unlock(&masterLock);
344 ((RemoteWin*)Remote::getInstance())->Signal();
345 ReleaseMutex(masterLock);
347 //logger->log("Command", Log::DEBUG, "UNLOCK");
350 void Command::postMessageNoLock(Message* m)
352 // As above but use this one if this message is being posted because of a button press
353 // the mutex is already locked, locking around postMessage is not needed as the
354 // queue is guaranteed to be run when the button has been processed
355 MessageQueue::postMessage(m);
358 bool Command::postMessageIfNotBusy(Message* m)
360 // Used for Windows mouse events
362 //logger->log("Command", Log::DEBUG, "TRY LOCK");
364 if (pthread_mutex_trylock(&masterLock) != EBUSY)
366 //logger->log("Command", Log::DEBUG, "LOCK");
367 MessageQueue::postMessage(m);
369 kill(mainPid, SIGURG);
371 ((RemoteAndroid*)Remote::getInstance())->Signal();
373 pthread_mutex_unlock(&masterLock);
374 //logger->log("Command", Log::DEBUG, "UNLOCK");
382 switch (WaitForSingleObject(masterLock, 0 ))
383 { //FIXME this is not "if not busy" check
384 case WAIT_OBJECT_0: //but with proper argument 0 this did not work
385 // case WAIT_ABANDONED:
386 MessageQueue::postMessage(m);
387 ((RemoteWin*)Remote::getInstance())->Signal();
388 ReleaseMutex(masterLock);
391 case WAIT_ABANDONED: return false;
392 case WAIT_TIMEOUT: return false;
398 void Command::postMessageFromOuterSpace(Message* m)
401 Yet another way of getting messages into Command. This one is for events that
402 are not standard button presses (or UDP generated buttons). It is also not for
403 events that are generated as a result of other events (events that can safely
404 call postMessageNoLock and be guaranteed that the message will be processed
405 because it is known that the queue is currently being processed).
406 This is for events that come from outer space and can occur when the master
407 mutex is locked or not, they need to be queued and executed but it doesn't
409 Actually so far it is for events caused by the video stream - aspect ratio
410 changes. These can occur when the master mutex is locked and so postMessage
411 doesn't work. postMessageNoLock doesn't work because if the mutex *isn't*
412 locked at the time then the message could be sat around a while before
414 The whole message system was at first supposed to prevent the problem of
415 calling a function on an object that had just been deleted, by ordering
416 messages such that all calls are done before object deletion. However,
417 because of the new centralised messaging system and the fact that BoxStack
418 locates the destination object before calling it, the messaging system now
419 allows the kind of sloppy calls it was supposed to stop. Weird huh. This
420 is mentioned here because the video stream might generate an event just as
421 the user hits stop. The mutex is locked, and by the time the message
422 is examined the vvideorec/live has been deleted. This doesn't matter because
423 boxstack will drop the message if it can't find the matching object to
425 Finally, all this is fine and dandy, except that I'm not 100% sure that
426 this sloppy postMessage and hope a queued signal will force it to be processed
427 thingy will actually work. Hmmm.
428 Lastly <g>, I will consider making the naming system a little more sane
432 logger->log("Command", Log::DEBUG, "PMFOS called");
433 MessageQueue::postMessage(m);
437 kill(mainPid, SIGURG);
439 ((RemoteAndroid*)Remote::getInstance())->Signal();
442 ((RemoteWin*)Remote::getInstance())->Signal();
446 void Command::processMessage(Message* m)
448 // FIXME - a slight modification - how if messagereceivers were to register
449 // themselves as receivers to avoid the calling-a-deleted-object problem
450 // then only deliver/register/unregister would have to be protected
452 logger->log("Command", Log::DEBUG, "processing message %i", m->message);
460 case Message::STOP_PLAYBACK:
462 handleCommand(Remote::STOP); // an odd way of doing it, but so simple
465 // Also connection_lost comes from player - anywhere else?
469 case Message::VDR_CONNECTED:
471 doJustConnected((VConnect*)m->from);
474 case Message::SCREENSHOT:
476 #ifdef VOMP_PLATTFORM_MVP
477 Osd::getInstance()->screenShot("/out.jpg");
479 logger->log("Osd", Log::NOTICE, "Screenshot Message arrived");
480 Osd::getInstance()->screenShot("out.jpg");
484 case Message::CONNECTION_LOST:
489 case Message::UDP_BUTTON:
491 handleCommand(m->parameter.num);
494 case Message::CHANGE_LANGUAGE:
496 boxstack->removeAll();
497 boxstack->update(wallpaper);
499 if (!VDR::getInstance()->isConnected()) { connectionLost(); break; }
500 VWelcome* vw = new VWelcome();
503 boxstack->update(vw);
506 case Message::LAST_VIEW_CLOSE:
508 // Shouldn't be done like this. Some generic message pass back from vinfo perhaps
515 // VWelcome* vw = new VWelcome();
517 // boxstack->add(vw);
518 // boxstack->update(vw);
522 case Message::NEW_PICTURE:
524 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE");
525 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
527 osdv->informPicture(m->tag,m->parameter.handle);
531 case Message::NEW_PICTURE_STATIC:
533 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE %x %x",m->tag,m->parameter.num);
534 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
536 osdv->informPicture(((unsigned long long)m->tag)<<32LL,m->parameter.handle);
546 Instead of sending through the boxstack, implement a more generic MessageReceiver interface
547 and have potential receivers register with something
548 When a message needs to be delivered, check if the receiver is still registered, if so, deliver the message
549 This could all be done using the existing big command mutex to keep it simple
552 logger->log("Command", Log::DEBUG, "Sending message to boxstack");
553 boxstack->processMessage(m);
557 void Command::handleCommand(int button)
559 if (isStandby && (button != Remote::POWER)
560 && (button != Remote::POWERON) && (button != Remote::POWEROFF)) return;
561 if (!connLost && boxstack->handleCommand(button)) return; // don't send to boxstack if connLost
563 // command was not handled
567 case Remote::DF_LEFT:
568 case Remote::DF_RIGHT:
569 case Remote::VOLUMEUP:
570 case Remote::VOLUMEDOWN:
572 if (remote->handlesVolume()) {
573 if (button==Remote::DF_LEFT || button==Remote::VOLUMEDOWN)
574 remote->volumeDown();
575 else remote->volumeUp();
577 VVolume* v = new VVolume();
579 v->handleCommand(button); // this will draw+show
585 if (remote->handlesVolume()) {
586 remote->volumeMute();
588 VMute* v = new VMute();
600 case Remote::POWERON:
605 case Remote::POWEROFF:
613 if (!connLost) return; // if connLost, handle Remote::OK
619 VSleeptimer* sleep = new VSleeptimer();
620 boxstack->add(sleep);
621 sleep->handleCommand(button); // this will draw+show
630 Message* m = new Message(); // break into master mutex
631 m->message = Message::SCREENSHOT;
637 void Command::doStandby()
650 void Command::doPowerOn()
654 Video::getInstance()->signalOn();
655 Led::getInstance()->on();
656 Remote::getInstance()->changePowerState(true);
660 VConnect* vconnect = new VConnect(server);
661 boxstack->add(vconnect);
666 void Command::doPowerOff()
670 VDR::getInstance()->shutdownVDR();
671 boxstack->removeAll();
672 Video::getInstance()->signalOff();
673 boxstack->update(wallpaper);
675 VDR::getInstance()->configSave("General", "Last Power State", "Off");
676 logger->unsetExternLogger();
677 VDR::getInstance()->disconnect();
678 Led::getInstance()->off();
679 Remote::getInstance()->changePowerState(false);
681 Sleeptimer::getInstance()->shutdown();
683 stop(); //different behavoiur on windows, we exit
688 void Command::doFromTheTop(bool which)
690 if (isStandby) return;
695 logger->log("Command", Log::NOTICE, "Connection lost dialog already present");
699 logger->log("Command", Log::NOTICE, "Doing connection lost dialog");
700 connLost = new VInfo();
701 connLost->setSize(360, 200);
702 connLost->createBuffer();
703 if (Video::getInstance()->getFormat() == Video::PAL)
704 connLost->setPosition(190, 170);
706 connLost->setPosition(180, 120);
707 connLost->setOneLiner(tr("Connection lost"));
708 connLost->setDropThrough();
709 connLost->setBorderOn(1);
710 connLost->setTitleBarColour(DrawStyle::DANGER);
711 connLost->okButton();
713 boxstack->add(connLost);
714 boxstack->update(connLost);
715 remote->clearBuffer();
719 logger->unsetExternLogger();
720 VDR::getInstance()->disconnect();
721 boxstack->removeAll();
722 boxstack->update(wallpaper);
726 remote->clearBuffer();
728 // at this point, everything should be reset to first-go
730 VConnect* vconnect = new VConnect(server);
731 boxstack->add(vconnect);
736 void Command::doReboot()
739 logger->unsetExternLogger();
740 VDR::getInstance()->disconnect();
742 logger->log("Command", Log::NOTICE, "Reboot");
744 #ifndef VOMP_HAS_EXIT
745 // some plattforms, want a proper deinitialisation of their hardware before reboot
746 Osd::getInstance()->shutdown();
747 Audio::getInstance()->shutdown();
748 Video::getInstance()->shutdown();
749 Remote::getInstance()->shutdown();
751 reboot(LINUX_REBOOT_CMD_RESTART);
752 // if reboot is not allowed -> stop
764 #endif //Would we support this on windows?
767 void Command::connectionLost()
769 logger->unsetExternLogger();
770 Message* m = new Message(); // break into master mutex
771 m->message = Message::CONNECTION_LOST;
773 postMessageFromOuterSpace(m);
776 void Command::buildCrashedBox()
778 VInfo* crash = new VInfo();
779 crash->setSize(360, 250);
780 crash->createBuffer();
781 if (Video::getInstance()->getFormat() == Video::PAL)
782 crash->setPosition(190, 146);
784 crash->setPosition(180, 96);
785 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.");
786 crash->setBorderOn(1);
787 crash->setTitleBarColour(DrawStyle::DANGER);
789 crash->setExitable();
791 boxstack->add(crash);
792 boxstack->update(crash);
795 int Command::getLangPref(bool subtitle,const char* langcode)
797 vector<struct ASLPref>::iterator itty=langcodes.begin();
798 char templangcode[4];
799 templangcode[0]=langcode[0];
800 templangcode[1]=langcode[1];
801 templangcode[2]=langcode[2];
802 templangcode[3]='\0';
804 while (itty != langcodes.end()) {
805 size_t pos=(*itty).langcode.find(templangcode);
806 if (pos != string::npos) {
807 vector<struct ASLPref>::iterator itty2=langcodes.begin();
808 for (int i=0; i<langcodes.size();i++) {
811 pref=langcodes[i].subtitlepref;
813 pref=langcodes[i].audiopref;
818 if (langcodes[i].subtitlepref==langpos) {
822 if (langcodes[i].audiopref==langpos) {
832 return langcodes.size(); //neutral
835 void Command::doJustConnected(VConnect* vconnect)
838 if (!VDR::getInstance()->isConnected()) { connectionLost(); return; }
839 logger->log("Command", Log::INFO, "Entering doJustConnected");
841 Video* video = Video::getInstance();
842 Audio* audio = Audio::getInstance();
843 boxstack->remove(vconnect);
845 VInfo* vi = new VInfo();
846 vi->setSize(400, 200);
848 if (video->getFormat() == Video::PAL)
849 vi->setPosition(170, 200);
851 vi->setPosition(160, 150);
852 vi->setOneLiner(tr("Connected, loading config"));
855 boxstack->update(vi);
857 VDR* vdr = VDR::getInstance();
860 // See if we're supposed to do network logging
861 config = vdr->configLoad("Advanced", "Network logging");
862 if (config && !STRCASECMP(config, "On"))
864 logger->log("Command", Log::INFO, "Turning on network logging");
865 logger->setExternLogger(vdr);
869 logger->unsetExternLogger();
870 logger->log("Command", Log::INFO, "Turned off network logging");
872 if (config) delete[] config;
874 config = vdr->configLoad("Advanced", "Skin Name");
876 const char **skinnames=SkinFactory::getSkinNames();
877 for (int i=0;i<SkinFactory::getNumberofSkins();i++) {
878 if (!STRCASECMP(config, skinnames[i])) {
879 SkinFactory::InitSkin(i);
884 if (wallpaper && wallpaper_pict) {
885 if (DrawStyle::WALLPAPER.alpha) {
886 wallpaper_pict->setVisible(true);
888 wallpaper_pict->setVisible(false);
891 boxstack->update(wallpaper);
895 SkinFactory::InitSkin(0);
898 // See if config says to override video format (PAL/NTSC)
899 config = vdr->configLoad("General", "Override Video Format");
902 logger->log("Command", Log::DEBUG, "Override Video Format is present");
904 if ( (!strcmp(config, "PAL") && (video->getFormat() != Video::PAL))
905 || (!strcmp(config, "NTSC") && (video->getFormat() != Video::NTSC))
906 || (!strcmp(config, "PAL_M") && (video->getFormat() != Video::PAL_M))
907 || (!strcmp(config, "NTSC_J") && (video->getFormat() != Video::NTSC_J))
910 // Oh sheesh, need to switch format. Bye bye TV...
912 // Take everything down
913 boxstack->removeAll();
914 boxstack->remove(wallpaper);
915 Osd* osd = Osd::getInstance();
921 remote->shutdown(); // need on raspberry shut not do any harm, hopefully
922 remote->init(RemoteStartDev);
924 // Get video and osd back up with the new mode
925 if (!strcmp(config, "PAL"))
927 logger->log("Command", Log::DEBUG, "Switching to PAL");
928 video->init(Video::PAL);
930 else if (!strcmp(config, "NTSC"))
932 logger->log("Command", Log::DEBUG, "Switching to NTSC");
933 video->init(Video::NTSC);
934 } else if (!strcmp(config, "PAL_M"))
936 logger->log("Command", Log::DEBUG, "Switching to PAL_M");
937 video->init(Video::PAL_M);
938 } else if (!strcmp(config, "NTSC_J"))
940 logger->log("Command", Log::DEBUG, "Switching to NTSC_J");
941 video->init(Video::NTSC_J);
946 //we do not init twice
947 osd->init((char*)("/dev/stbgfx"));
950 // Put the wallpaper back
955 vi->setSize(400, 200);
957 if (video->getFormat() == Video::PAL)
958 vi->setPosition(170, 200);
960 vi->setPosition(160, 150);
962 vi->setOneLiner(tr("Connected, loading config"));
965 boxstack->update(vi);
969 logger->log("Command", Log::DEBUG, "Already in requested mode, or request was not 'PAL' or 'NTSC'");
974 logger->log("Command", Log::DEBUG, "Phew, no dangerous on-the-fly mode switching to do!");
977 // Power off if first boot and config says so
982 logger->log("Command", Log::DEBUG, "Load power after boot");
984 config = vdr->configLoad("General", "Power After Boot");
988 if (!STRCASECMP(config, "On"))
990 logger->log("Command", Log::INFO, "Config says Power After Boot = On");
992 else if (!STRCASECMP(config, "Off"))
994 logger->log("Command", Log::INFO, "Config says Power After Boot = Off");
999 else if (!STRCASECMP(config, "Last state"))
1001 char* lastPowerState = vdr->configLoad("General", "Last Power State");
1004 if (!STRCASECMP(lastPowerState, "On"))
1006 logger->log("Command", Log::INFO, "Config says Last Power State = On");
1008 else if (!STRCASECMP(lastPowerState, "Off"))
1010 logger->log("Command", Log::INFO, "Config says Last Power State = Off");
1013 return; // quit here
1017 logger->log("Command", Log::INFO, "Config General/Last Power State not understood");
1022 logger->log("Command", Log::INFO, "Config General/Last Power State not found");
1027 logger->log("Command", Log::INFO, "Config/Power After Boot not understood");
1033 logger->log("Command", Log::INFO, "Config General/Power After Boot not found");
1038 // Go S-Video if config says so
1040 config = vdr->configLoad("TV", "Connection");
1044 if (!STRCASECMP(config, "S-Video"))
1046 logger->log("Command", Log::INFO, "Switching to S-Video as Connection=%s", config);
1047 video->setConnection(Video::SVIDEO);
1048 } else if (!STRCASECMP(config, "HDMI"))
1050 logger->log("Command", Log::INFO, "Switching to HDMI as Connection=%s", config);
1051 video->setConnection(Video::HDMI);
1052 } else if (!STRCASECMP(config, "HDMI3D"))
1054 logger->log("Command", Log::INFO, "Switching to HDMI3D as Connection=%s", config);
1055 video->setConnection(Video::HDMI3D);
1059 logger->log("Command", Log::INFO, "Switching to RGB/Composite as Connection=%s", config);
1060 video->setConnection(Video::COMPOSITERGB);
1066 logger->log("Command", Log::INFO, "Config TV/S-Video not found");
1069 // Set to shutdown VDR if config says
1071 config = vdr->configLoad("General", "VDR shutdown");
1074 if (!STRCASECMP(config, "On"))
1076 logger->log("Command", Log::INFO, "Shutdown VDR when shutting down vomp");
1077 vdr->setVDRShutdown(true);
1079 else if (!STRCASECMP(config, "Off"))
1081 logger->log("Command", Log::INFO, "Shutdown only vomp");
1082 vdr->setVDRShutdown(false);
1087 logger->log("Command", Log::INFO, "Default shutdown only vomp");
1088 vdr->setVDRShutdown(false); // Default
1093 config = vdr->configLoad("General", "Remote type");
1097 if (!STRCASECMP(config, "New"))
1099 logger->log("Command", Log::INFO, "Switching to New remote type");
1100 remote->setRemoteType(Remote::NEWREMOTE);
1104 logger->log("Command", Log::INFO, "Switching to Old remote type");
1105 remote->setRemoteType(Remote::OLDREMOTE);
1111 logger->log("Command", Log::INFO, "Config General/Remote type not found");
1112 remote->setRemoteType(Remote::OLDREMOTE);
1117 // Get TV aspect ratio
1119 config = vdr->configLoad("TV", "Aspect");
1122 if (!STRCASECMP(config, "16:9"))
1124 logger->log("Command", Log::INFO, "/// Switching to TV aspect 16:9");
1125 video->setTVsize(Video::ASPECT16X9);
1129 logger->log("Command", Log::INFO, "/// Switching to TV aspect 4:3");
1130 video->setTVsize(Video::ASPECT4X3);
1136 logger->log("Command", Log::INFO, "Config TV/Aspect type not found, going 4:3");
1137 video->setTVsize(Video::ASPECT4X3);
1140 config = vdr->configLoad("TV", "Widemode");
1143 if (!STRCASECMP(config, "Letterbox"))
1145 logger->log("Command", Log::INFO, "Setting letterbox mode");
1146 video->setMode(Video::LETTERBOX);
1150 logger->log("Command", Log::INFO, "Setting chop-sides mode");
1151 video->setMode(Video::NORMAL);
1158 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting letterbox mode");
1159 video->setMode(Video::LETTERBOX);
1161 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting chop-sides mode");
1162 video->setMode(Video::NORMAL);
1166 config = vdr->configLoad("Advanced", "TCP receive window");
1169 size_t newTCPsize = atoi(config);
1172 logger->log("Command", Log::INFO, "Setting TCP window size %i", newTCPsize);
1173 vdr->setReceiveWindow(newTCPsize);
1177 logger->log("Command", Log::INFO, "TCP window size not found, setting 2048");
1178 if (DEFAULT_TCP_WINDOWSIZE) vdr->setReceiveWindow(2048); // Default
1181 config = vdr->configLoad("Advanced", "Font Name");
1184 Osd::getInstance()->setFont(config);
1185 logger->log("Command", Log::INFO, "Setting Font to %s", config);
1191 // Set recording list type
1194 #ifdef ADVANCED_MENUES
1195 config = vdr->configLoad("Advanced", "Menu type");
1199 if (!STRCASECMP(config, "Advanced"))
1201 logger->log("Command", Log::INFO, "Switching to Advanced menu");
1207 logger->log("Command", Log::INFO, "Switching to Classic menu");
1214 logger->log("Command", Log::INFO, "Config General/menu type not found");
1219 config = vdr->configLoad("Advanced", "Disable WOL");
1222 if (!STRCASECMP(config, "Yes"))
1224 logger->log("Command", Log::INFO, "Config says disable WOL");
1225 Wol::getInstance()->setEnabled(false);
1229 logger->log("Command", Log::INFO, "Config says enable WOL");
1230 Wol::getInstance()->setEnabled(true);
1237 logger->log("Command", Log::INFO, "By default, enable WOL");
1238 Wol::getInstance()->setEnabled(true);
1240 /* device dependend config */
1241 audio->loadOptionsfromServer(vdr);
1242 video->loadOptionsfromServer(vdr);
1243 remote->loadOptionsfromServer(vdr);
1245 video->executePendingModeChanges();
1248 // Save power state = on
1250 vdr->configSave("General", "Last Power State", "On");
1252 // Make sure connection didn't die
1253 if (!vdr->isConnected())
1255 Command::getInstance()->connectionLost();
1259 boxstack->remove(vi);
1261 VWelcome* vw = new VWelcome();
1264 boxstack->update(vw);
1266 // Enter pre-keys here
1267 // handleCommand(Remote::OK);
1268 // handleCommand(Remote::THREE);
1269 // handleCommand(Remote::SIX);
1270 // handleCommand(Remote::OK);
1271 // handleCommand(Remote::UP);
1272 // handleCommand(Remote::PLAY);
1273 // handleCommand(Remote::DOWN);
1274 // handleCommand(Remote::DOWN);
1275 // handleCommand(Remote::DOWN);
1276 // handleCommand(Remote::OK);
1277 // handleCommand(Remote::RED);