2 Copyright 2004-2020 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, see <https://www.gnu.org/licenses/>.
27 #include "remotewin.h"
31 #include "remoteandroid.h"
39 #include "vserverselect.h"
45 #include "timerreceiver.h"
55 #include "vsleeptimer.h"
57 #include "osdvector.h"
60 Command* Command::instance = NULL;
73 Command* Command::getInstance()
78 int Command::init(bool tcrashed, char* tServer)
80 if (initted) return 0;
85 logger = Log::getInstance();
86 boxstack = BoxStack::getInstance();
87 remote = Remote::getInstance();
89 remote->InitHWCListwithDefaults();
91 if (!logger || !boxstack || !remote)
97 SkinFactory::InitSkin(0);
100 pthread_mutex_init(&masterLock, NULL);
102 masterLock = CreateMutex(NULL, FALSE, NULL);
108 int Command::shutdown()
110 if (!initted) return 0;
117 logger->log("Command", Log::NOTICE, "stop");
122 void Command::doWallpaper()
124 Video* video = Video::getInstance();
127 Boxx* bbg = new Boxx();
128 bbg->setSize(video->getScreenWidth(), video->getScreenHeight());
130 bbg->fillColour(DrawStyle::WALLPAPER);
132 boxstack->update(bbg);
133 boxstack->remove(bbg);
136 wallpaper = new Boxx();
137 wallpaper->setSize(video->getScreenWidth(), video->getScreenHeight());
138 wallpaper->createBuffer();
139 wallpaper->setBackgroundColour(DrawStyle::WALLPAPER);
141 wallpaper_pict = new WJpegTYPE();
142 wallpaper_pict->setSize(video->getScreenWidth(), video->getScreenHeight());
144 if (video->getFormat() == Video::PAL)
146 logger->log("Command", Log::DEBUG, "PAL wallpaper selected");
148 wallpaper_pict->init("/wallpaperPAL.jpg");
150 wallpaper_pict->init("wallpaperPAL.jpg");
155 logger->log("Command", Log::DEBUG, "NTSC wallpaper selected");
156 wallpaper_pict->init("/wallpaperNTSC.jpg");
159 if (DrawStyle::WALLPAPER.alpha)
160 wallpaper_pict->setVisible(true);
162 wallpaper_pict->setVisible(false);
164 wallpaper->add(wallpaper_pict);
167 boxstack->add(wallpaper);
168 boxstack->update(wallpaper);
170 OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
171 if (osdv) osdv->updateBackgroundColor(DrawStyle::WALLPAPER);
176 if (!initted) return;
183 Video::getInstance()->signalOn();
184 Led::getInstance()->on();
188 // End of startup. Lock the mutex and put the first view up
190 pthread_mutex_lock(&masterLock);
192 WaitForSingleObject(masterLock, INFINITE );
201 VConnect* vconnect = new VConnect(server);
202 boxstack->add(vconnect);
206 // Start method 2 of getting commands in...
214 pthread_mutex_unlock(&masterLock);
216 ReleaseMutex(masterLock);
218 button = remote->getButtonPress(2); // Don't block (0) in case a signal arrives after checking signals but before this line
219 // something happened, lock and process
220 if (signals) processSignals(); // If a signal arrived process now.
223 pthread_mutex_lock(&masterLock);
225 WaitForSingleObject(masterLock, INFINITE );
228 if (button == Remote::NA_NONE) continue;
230 if (button != Remote::NA_SIGNAL) handleCommand(button);
231 processMessageQueue();
235 pthread_mutex_unlock(&masterLock);
237 ReleaseMutex(masterLock);
240 boxstack->removeAllExceptWallpaper();
241 boxstack->remove(wallpaper);
242 delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL;
245 void Command::setSignal(int signalReceived)
248 if (signalReceived == SIGINT)
250 else if (signalReceived == SIGTERM)
252 else if (signalReceived == SIGUSR1)
254 else if (signalReceived == SIGUSR2)
256 else if (signalReceived == SIGURG)
261 void Command::processSignals()
264 if (signals & SIG_INT)
266 signals = signals & ~SIG_INT;
267 logger->log("Command", Log::NOTICE, "INT signal, shutting down...");
271 if (signals & SIG_TERM)
273 signals = signals & ~SIG_TERM;
274 logger->log("Command", Log::NOTICE, "TERM signal, shutting down...");
278 if (signals & SIG_USR1)
280 logger->log("Command", Log::NOTICE, "USR1 signal");
281 signals = signals & ~SIG_USR1;
284 if (signals & SIG_USR2)
286 logger->log("Command", Log::NOTICE, "USR2 signal");
287 signals = signals & ~SIG_USR2;
290 if (signals & SIG_URG)
292 logger->log("Command", Log::NOTICE, "URG signal"); // This is used to break from getButtonPress to process the message queue
293 signals = signals & ~SIG_URG;
298 void Command::postMessage(Message* m)
300 // This is locked here in case the main loop is not waiting for an event, but is processing one
301 // it could be killed but then not react to it because the signal wouldn't cause
302 // remote->getButtonPress to break
303 // locking the mutex ensures that the master thread is waiting on getButtonPress
306 pthread_mutex_lock(&masterLock);
308 WaitForSingleObject(masterLock, INFINITE );
310 MessageQueue::postMessage(m);
314 kill(mainPid, SIGURG);
316 ((RemoteAndroid*)Remote::getInstance())->Signal();
318 pthread_mutex_unlock(&masterLock);
320 ((RemoteWin*)Remote::getInstance())->Signal();
321 ReleaseMutex(masterLock);
325 void Command::postMessageNoLock(Message* m) // FIXME - get rid of this if the sending-to-MessageQueue idea pans out
327 // As above but use this one if this message is being posted because of a button press
328 // the mutex is already locked, locking around postMessage is not needed as the
329 // queue is guaranteed to be run when the button has been processed
330 MessageQueue::postMessage(m);
333 bool Command::postMessageIfNotBusy(Message* m)
335 // Used for Windows mouse events
338 if (pthread_mutex_trylock(&masterLock) != EBUSY)
340 MessageQueue::postMessage(m);
342 kill(mainPid, SIGURG);
344 ((RemoteAndroid*)Remote::getInstance())->Signal();
346 pthread_mutex_unlock(&masterLock);
354 switch (WaitForSingleObject(masterLock, 0 ))
355 { //FIXME this is not "if not busy" check
356 case WAIT_OBJECT_0: //but with proper argument 0 this did not work
357 // case WAIT_ABANDONED:
358 MessageQueue::postMessage(m);
359 ((RemoteWin*)Remote::getInstance())->Signal();
360 ReleaseMutex(masterLock);
363 case WAIT_ABANDONED: return false;
364 case WAIT_TIMEOUT: return false;
370 void Command::postMessageFromOuterSpace(Message* m)
373 Yet another way of getting messages into Command. This one is for events that
374 are not standard button presses (or UDP generated buttons). It is also not for
375 events that are generated as a result of other events (events that can safely
376 call postMessageNoLock and be guaranteed that the message will be processed
377 because it is known that the queue is currently being processed).
378 This is for events that come from outer space and can occur when the master
379 mutex is locked or not, they need to be queued and executed but it doesn't
381 Actually so far it is for events caused by the video stream - aspect ratio
382 changes. These can occur when the master mutex is locked and so postMessage
383 doesn't work. postMessageNoLock doesn't work because if the mutex *isn't*
384 locked at the time then the message could be sat around a while before
386 The whole message system was at first supposed to prevent the problem of
387 calling a function on an object that had just been deleted, by ordering
388 messages such that all calls are done before object deletion. However,
389 because of the new centralised messaging system and the fact that BoxStack
390 locates the destination object before calling it, the messaging system now
391 allows the kind of sloppy calls it was supposed to stop. Weird huh. This
392 is mentioned here because the video stream might generate an event just as
393 the user hits stop. The mutex is locked, and by the time the message
394 is examined the vvideorec/live has been deleted. This doesn't matter because
395 boxstack will drop the message if it can't find the matching object to
397 Finally, all this is fine and dandy, except that I'm not 100% sure that
398 this sloppy postMessage and hope a queued signal will force it to be processed
399 thingy will actually work. Hmmm.
400 Lastly <g>, I will consider making the naming system a little more sane
404 logger->log("Command", Log::DEBUG, "PMFOS called");
405 MessageQueue::postMessage(m);
409 kill(mainPid, SIGURG);
411 ((RemoteAndroid*)Remote::getInstance())->Signal();
414 ((RemoteWin*)Remote::getInstance())->Signal();
418 void Command::processMessage(Message* m)
420 // FIXME - a slight modification - how if messagereceivers were to register
421 // themselves as receivers to avoid the calling-a-deleted-object problem
422 // then only deliver/register/unregister would have to be protected
424 logger->log("Command", Log::DEBUG, "processing message %i", m->message);
432 case Message::STOP_PLAYBACK:
434 handleCommand(Remote::STOP); // an odd way of doing it, but so simple
437 // Also connection_lost comes from player - anywhere else?
441 case Message::VDR_CONNECTED:
443 doJustConnected(static_cast<VConnect*>(m->from));
446 case Message::SCREENSHOT:
448 logger->log("Osd", Log::NOTICE, "Screenshot Message arrived");
449 Osd::getInstance()->screenShot("out.jpg");
452 case Message::CONNECTION_LOST:
457 case Message::UDP_BUTTON:
459 handleCommand(m->parameter);
462 case Message::CHANGE_LANGUAGE:
464 boxstack->removeAllExceptWallpaper();
465 boxstack->update(wallpaper);
467 if (!VDR::getInstance()->isConnected()) { connectionLost(); break; }
468 VWelcome* vw = new VWelcome();
471 boxstack->update(vw);
474 case Message::LAST_VIEW_CLOSE:
476 // Shouldn't be done like this. Some generic message pass back from vinfo perhaps
483 // VWelcome* vw = new VWelcome();
485 // boxstack->add(vw);
486 // boxstack->update(vw);
490 case Message::NEW_PICTURE:
492 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE");
493 OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
494 if (osdv) osdv->informPicture(m->tag, reinterpret_cast<ImageIndex>(m->data));
497 case Message::NEW_PICTURE_STATIC:
499 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE %x %x",m->tag,m->parameter);
500 OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
501 if (osdv) osdv->informPicture(static_cast<unsigned long long>(m->tag) << 32LL, reinterpret_cast<ImageIndex>(m->data));
510 Instead of sending through the boxstack, implement a more generic MessageReceiver interface
511 and have potential receivers register with something
512 When a message needs to be delivered, check if the receiver is still registered, if so, deliver the message
513 This could all be done using the existing big command mutex to keep it simple
516 logger->log("Command", Log::DEBUG, "Sending message to boxstack");
517 boxstack->processMessage(m);
521 void Command::handleCommand(int button)
523 if (isStandby && (button != Remote::POWER)
524 && (button != Remote::POWERON)
525 && (button != Remote::POWEROFF)) return;
527 if (!connLost && boxstack->handleCommand(button)) return; // don't send to boxstack if connLost
529 // command was not handled
533 case Remote::DF_LEFT:
534 case Remote::DF_RIGHT:
535 case Remote::VOLUMEUP:
536 case Remote::VOLUMEDOWN:
538 if (remote->handlesVolume())
540 if (button==Remote::DF_LEFT || button==Remote::VOLUMEDOWN)
541 remote->volumeDown();
547 VVolume* v = new VVolume();
549 v->handleCommand(button); // this will draw+show
555 if (remote->handlesVolume())
557 remote->volumeMute();
561 VMute* v = new VMute();
573 case Remote::POWERON:
578 case Remote::POWEROFF:
586 if (!connLost) return; // if connLost, handle Remote::OK
592 VSleeptimer* sleep = new VSleeptimer();
593 boxstack->add(sleep);
594 sleep->handleCommand(button); // this will draw+show
603 Message* m = new Message(); // break into master mutex
604 m->message = Message::SCREENSHOT;
610 void Command::doStandby()
623 void Command::doPowerOn()
627 Video::getInstance()->signalOn();
628 Led::getInstance()->on();
629 Remote::getInstance()->changePowerState(true);
632 VConnect* vconnect = new VConnect(server);
633 boxstack->add(vconnect);
638 void Command::doPowerOff()
642 VDR::getInstance()->shutdownVDR();
643 boxstack->removeAllExceptWallpaper();
644 Video::getInstance()->signalOff();
645 boxstack->update(wallpaper);
647 VDR::getInstance()->configSave("General", "Last Power State", "Off");
648 logger->unsetExternLogger();
649 VDR::getInstance()->disconnect();
650 Led::getInstance()->off();
651 Remote::getInstance()->changePowerState(false);
653 Sleeptimer::getInstance()->shutdown();
655 stop(); //different behavoiur on windows, we exit
660 void Command::doFromTheTop(bool which)
662 if (isStandby) return;
667 logger->log("Command", Log::NOTICE, "Connection lost dialog already present");
671 logger->log("Command", Log::NOTICE, "Doing connection lost dialog");
672 connLost = new VInfo();
673 connLost->setSize(360, 200);
674 connLost->createBuffer();
675 if (Video::getInstance()->getFormat() == Video::PAL)
676 connLost->setPosition(190, 170);
678 connLost->setPosition(180, 120);
679 connLost->setOneLiner(tr("Connection lost"));
680 connLost->setDropThrough();
681 connLost->setBorderOn(1);
682 connLost->setTitleBarColour(DrawStyle::DANGER);
683 connLost->okButton();
685 boxstack->add(connLost);
686 boxstack->update(connLost);
687 remote->clearBuffer();
691 logger->unsetExternLogger();
692 VDR::getInstance()->disconnect();
693 boxstack->removeAllExceptWallpaper();
694 boxstack->update(wallpaper);
698 remote->clearBuffer();
700 // at this point, everything should be reset to first-go
702 VConnect* vconnect = new VConnect(server);
703 boxstack->add(vconnect);
708 void Command::doReboot()
711 logger->unsetExternLogger();
712 VDR::getInstance()->disconnect();
714 logger->log("Command", Log::NOTICE, "Reboot");
716 #ifndef VOMP_HAS_EXIT
717 // some plattforms, want a proper deinitialisation of their hardware before reboot
718 Osd::getInstance()->shutdown();
719 Audio::getInstance()->shutdown();
720 Video::getInstance()->shutdown();
721 Remote::getInstance()->shutdown();
723 reboot(LINUX_REBOOT_CMD_RESTART);
724 // if reboot is not allowed -> stop
736 #endif //Would we support this on windows?
739 void Command::connectionLost()
741 logger->unsetExternLogger();
742 Message* m = new Message(); // break into master mutex
743 m->message = Message::CONNECTION_LOST;
745 postMessageFromOuterSpace(m);
748 void Command::buildCrashedBox()
750 VInfo* crash = new VInfo();
751 crash->setSize(360, 250);
752 crash->createBuffer();
753 if (Video::getInstance()->getFormat() == Video::PAL)
754 crash->setPosition(190, 146);
756 crash->setPosition(180, 96);
757 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.");
758 crash->setBorderOn(1);
759 crash->setTitleBarColour(DrawStyle::DANGER);
761 crash->setExitable();
763 boxstack->add(crash);
764 boxstack->update(crash);
767 int Command::getLangPref(bool subtitle, const char* langcode)
769 std::vector<struct ASLPref>::iterator itty=langcodes.begin();
770 char templangcode[4];
771 templangcode[0] = langcode[0];
772 templangcode[1] = langcode[1];
773 templangcode[2] = langcode[2];
774 templangcode[3] = '\0';
776 while (itty != langcodes.end())
778 size_t pos = (*itty).langcode.find(templangcode);
779 if (pos != std::string::npos)
781 //vector<struct ASLPref>::iterator itty2=langcodes.begin();
782 for (unsigned int i = 0; i < langcodes.size(); i++)
786 pref = langcodes[i].subtitlepref;
788 pref = langcodes[i].audiopref;
793 if (langcodes[i].subtitlepref==langpos) return i;
797 if (langcodes[i].audiopref==langpos) return i;
805 return langcodes.size(); //neutral
808 void Command::doJustConnected(VConnect* vconnect)
811 if (!VDR::getInstance()->isConnected()) { connectionLost(); return; }
812 logger->log("Command", Log::INFO, "Entering doJustConnected");
814 Video* video = Video::getInstance();
815 Audio* audio = Audio::getInstance();
816 boxstack->remove(vconnect);
818 VInfo* vi = new VInfo();
819 vi->setSize(400, 200);
821 if (video->getFormat() == Video::PAL)
822 vi->setPosition(170, 200);
824 vi->setPosition(160, 150);
825 vi->setOneLiner(tr("Connected, loading config"));
828 boxstack->update(vi);
830 VDR* vdr = VDR::getInstance();
833 // See if we're supposed to do network logging
834 config = vdr->configLoad("Advanced", "Network logging");
835 if (config && !STRCASECMP(config, "On"))
837 logger->log("Command", Log::INFO, "Turning on network logging");
838 logger->setExternLogger(vdr);
842 logger->unsetExternLogger();
843 logger->log("Command", Log::INFO, "Turned off network logging");
845 if (config) delete[] config;
847 config = vdr->configLoad("Advanced", "Skin Name");
850 const char **skinnames=SkinFactory::getSkinNames();
851 for (int i=0;i<SkinFactory::getNumberofSkins();i++)
853 if (!STRCASECMP(config, skinnames[i]))
855 SkinFactory::InitSkin(i);
861 if (wallpaper && wallpaper_pict)
863 if (DrawStyle::WALLPAPER.alpha)
864 wallpaper_pict->setVisible(true);
866 wallpaper_pict->setVisible(false);
869 boxstack->update(wallpaper);
874 SkinFactory::InitSkin(0);
877 // See if config says to override video format (PAL/NTSC)
878 config = vdr->configLoad("General", "Override Video Format");
881 logger->log("Command", Log::DEBUG, "Override Video Format is present");
883 if ( (!strcmp(config, "PAL") && (video->getFormat() != Video::PAL))
884 || (!strcmp(config, "NTSC") && (video->getFormat() != Video::NTSC))
885 || (!strcmp(config, "PAL_M") && (video->getFormat() != Video::PAL_M))
886 || (!strcmp(config, "NTSC_J") && (video->getFormat() != Video::NTSC_J))
889 // Oh sheesh, need to switch format. Bye bye TV...
891 // Take everything down
892 boxstack->removeAllExceptWallpaper();
893 boxstack->remove(wallpaper);
894 delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL;
896 Osd* osd = Osd::getInstance();
902 remote->shutdown(); // need on raspberry shut not do any harm, hopefully
903 remote->init(RemoteStartDev);
905 // Get video and osd back up with the new mode
906 if (!strcmp(config, "PAL"))
908 logger->log("Command", Log::DEBUG, "Switching to PAL");
909 video->init(Video::PAL);
911 else if (!strcmp(config, "NTSC"))
913 logger->log("Command", Log::DEBUG, "Switching to NTSC");
914 video->init(Video::NTSC);
915 } else if (!strcmp(config, "PAL_M"))
917 logger->log("Command", Log::DEBUG, "Switching to PAL_M");
918 video->init(Video::PAL_M);
919 } else if (!strcmp(config, "NTSC_J"))
921 logger->log("Command", Log::DEBUG, "Switching to NTSC_J");
922 video->init(Video::NTSC_J);
927 //we do not init twice
931 // Put the wallpaper back
936 vi->setSize(400, 200);
938 if (video->getFormat() == Video::PAL)
939 vi->setPosition(170, 200);
941 vi->setPosition(160, 150);
943 vi->setOneLiner(tr("Connected, loading config"));
946 boxstack->update(vi);
950 logger->log("Command", Log::DEBUG, "Already in requested mode, or request was not 'PAL' or 'NTSC'");
955 logger->log("Command", Log::DEBUG, "Phew, no dangerous on-the-fly mode switching to do!");
958 // Power off if first boot and config says so
963 logger->log("Command", Log::DEBUG, "Load power after boot");
965 config = vdr->configLoad("General", "Power After Boot");
969 if (!STRCASECMP(config, "On"))
971 logger->log("Command", Log::INFO, "Config says Power After Boot = On");
973 else if (!STRCASECMP(config, "Off"))
975 logger->log("Command", Log::INFO, "Config says Power After Boot = Off");
980 else if (!STRCASECMP(config, "Last state"))
982 char* lastPowerState = vdr->configLoad("General", "Last Power State");
985 if (!STRCASECMP(lastPowerState, "On"))
987 logger->log("Command", Log::INFO, "Config says Last Power State = On");
989 else if (!STRCASECMP(lastPowerState, "Off"))
991 logger->log("Command", Log::INFO, "Config says Last Power State = Off");
998 logger->log("Command", Log::INFO, "Config General/Last Power State not understood");
1003 logger->log("Command", Log::INFO, "Config General/Last Power State not found");
1008 logger->log("Command", Log::INFO, "Config/Power After Boot not understood");
1014 logger->log("Command", Log::INFO, "Config General/Power After Boot not found");
1019 // Go S-Video if config says so
1021 config = vdr->configLoad("TV", "Connection");
1025 if (!STRCASECMP(config, "S-Video"))
1027 logger->log("Command", Log::INFO, "Switching to S-Video as Connection=%s", config);
1028 video->setConnection(Video::SVIDEO);
1029 } else if (!STRCASECMP(config, "HDMI"))
1031 logger->log("Command", Log::INFO, "Switching to HDMI as Connection=%s", config);
1032 video->setConnection(Video::HDMI);
1033 } else if (!STRCASECMP(config, "HDMI3D"))
1035 logger->log("Command", Log::INFO, "Switching to HDMI3D as Connection=%s", config);
1036 video->setConnection(Video::HDMI3D);
1040 logger->log("Command", Log::INFO, "Switching to RGB/Composite as Connection=%s", config);
1041 video->setConnection(Video::COMPOSITERGB);
1047 logger->log("Command", Log::INFO, "Config TV/S-Video not found");
1050 // Set to shutdown VDR if config says
1052 config = vdr->configLoad("General", "VDR shutdown");
1055 if (!STRCASECMP(config, "On"))
1057 logger->log("Command", Log::INFO, "Shutdown VDR when shutting down vomp");
1058 vdr->setVDRShutdown(true);
1060 else if (!STRCASECMP(config, "Off"))
1062 logger->log("Command", Log::INFO, "Shutdown only vomp");
1063 vdr->setVDRShutdown(false);
1068 logger->log("Command", Log::INFO, "Default shutdown only vomp");
1069 vdr->setVDRShutdown(false); // Default
1074 config = vdr->configLoad("General", "Remote type");
1078 if (!STRCASECMP(config, "New"))
1080 logger->log("Command", Log::INFO, "Switching to New remote type");
1081 remote->setRemoteType(Remote::NEWREMOTE);
1085 logger->log("Command", Log::INFO, "Switching to Old remote type");
1086 remote->setRemoteType(Remote::OLDREMOTE);
1092 logger->log("Command", Log::INFO, "Config General/Remote type not found");
1093 remote->setRemoteType(Remote::OLDREMOTE);
1098 // Get TV aspect ratio
1100 config = vdr->configLoad("TV", "Aspect");
1103 if (!STRCASECMP(config, "16:9"))
1105 logger->log("Command", Log::INFO, "/// Switching to TV aspect 16:9");
1106 video->setTVsize(Video::ASPECT16X9);
1110 logger->log("Command", Log::INFO, "/// Switching to TV aspect 4:3");
1111 video->setTVsize(Video::ASPECT4X3);
1117 logger->log("Command", Log::INFO, "Config TV/Aspect type not found, going 4:3");
1118 video->setTVsize(Video::ASPECT4X3);
1121 config = vdr->configLoad("TV", "Widemode");
1124 if (!STRCASECMP(config, "Letterbox"))
1126 logger->log("Command", Log::INFO, "Setting letterbox mode");
1127 video->setMode(Video::LETTERBOX);
1131 logger->log("Command", Log::INFO, "Setting chop-sides mode");
1132 video->setMode(Video::NORMAL);
1139 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting letterbox mode");
1140 video->setMode(Video::LETTERBOX);
1142 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting chop-sides mode");
1143 video->setMode(Video::NORMAL);
1147 config = vdr->configLoad("Advanced", "TCP receive window");
1150 size_t newTCPsize = atoi(config);
1153 logger->log("Command", Log::INFO, "Setting TCP window size %i", newTCPsize);
1154 vdr->setReceiveWindow(newTCPsize);
1158 logger->log("Command", Log::INFO, "TCP window size not found, setting 2048");
1159 if (DEFAULT_TCP_WINDOWSIZE) vdr->setReceiveWindow(2048); // Default
1162 config = vdr->configLoad("Advanced", "Font Name");
1165 Osd::getInstance()->setFont(config);
1166 logger->log("Command", Log::INFO, "Setting Font to %s", config);
1172 // Set recording list type
1174 #ifdef ADVANCED_MENUES
1175 config = vdr->configLoad("Advanced", "Menu type");
1179 if (!STRCASECMP(config, "Advanced"))
1181 logger->log("Command", Log::INFO, "Switching to Advanced menu");
1186 logger->log("Command", Log::INFO, "Switching to Classic menu");
1193 logger->log("Command", Log::INFO, "Config General/menu type not found");
1198 config = vdr->configLoad("Advanced", "Disable WOL");
1201 if (!STRCASECMP(config, "Yes"))
1203 logger->log("Command", Log::INFO, "Config says disable WOL");
1204 Wol::getInstance()->setEnabled(false);
1208 logger->log("Command", Log::INFO, "Config says enable WOL");
1209 Wol::getInstance()->setEnabled(true);
1216 logger->log("Command", Log::INFO, "By default, enable WOL");
1217 Wol::getInstance()->setEnabled(true);
1219 /* device dependend config */
1220 audio->loadOptionsfromServer(vdr);
1221 video->loadOptionsfromServer(vdr);
1222 remote->loadOptionsfromServer(vdr);
1224 video->executePendingModeChanges();
1227 // Save power state = on
1229 vdr->configSave("General", "Last Power State", "On");
1231 // Make sure connection didn't die
1232 if (!vdr->isConnected())
1234 Command::getInstance()->connectionLost();
1238 boxstack->remove(vi);
1240 VWelcome* vw = new VWelcome();
1243 boxstack->update(vw);
1245 // Enter pre-keys here
1246 // handleCommand(Remote::OK);
1247 // handleCommand(Remote::THREE);
1248 // handleCommand(Remote::SIX);
1249 // handleCommand(Remote::OK);
1250 // handleCommand(Remote::UP);
1251 // handleCommand(Remote::PLAY);
1252 // handleCommand(Remote::DOWN);
1253 // handleCommand(Remote::DOWN);
1254 // handleCommand(Remote::DOWN);
1255 // handleCommand(Remote::OK);
1256 // handleCommand(Remote::RED);