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
307 pthread_mutex_lock(&masterLock);
309 WaitForSingleObject(masterLock, INFINITE );
311 MessageQueue::postMessage(m);
315 kill(mainPid, SIGURG);
317 ((RemoteAndroid*)Remote::getInstance())->Signal();
319 pthread_mutex_unlock(&masterLock);
321 ((RemoteWin*)Remote::getInstance())->Signal();
322 ReleaseMutex(masterLock);
326 void Command::postMessageNoLock(Message* m) // FIXME - get rid of this if the sending-to-MessageQueue idea pans out
328 // As above but use this one if this message is being posted because of a button press
329 // the mutex is already locked, locking around postMessage is not needed as the
330 // queue is guaranteed to be run when the button has been processed
331 MessageQueue::postMessage(m);
334 bool Command::postMessageIfNotBusy(Message* m)
336 // Used for Windows mouse events
339 if (pthread_mutex_trylock(&masterLock) != EBUSY)
341 MessageQueue::postMessage(m);
343 kill(mainPid, SIGURG);
345 ((RemoteAndroid*)Remote::getInstance())->Signal();
347 pthread_mutex_unlock(&masterLock);
355 switch (WaitForSingleObject(masterLock, 0 ))
356 { //FIXME this is not "if not busy" check
357 case WAIT_OBJECT_0: //but with proper argument 0 this did not work
358 // case WAIT_ABANDONED:
359 MessageQueue::postMessage(m);
360 ((RemoteWin*)Remote::getInstance())->Signal();
361 ReleaseMutex(masterLock);
364 case WAIT_ABANDONED: return false;
365 case WAIT_TIMEOUT: return false;
371 void Command::postMessageFromOuterSpace(Message* m)
374 Yet another way of getting messages into Command. This one is for events that
375 are not standard button presses (or UDP generated buttons). It is also not for
376 events that are generated as a result of other events (events that can safely
377 call postMessageNoLock and be guaranteed that the message will be processed
378 because it is known that the queue is currently being processed).
379 This is for events that come from outer space and can occur when the master
380 mutex is locked or not, they need to be queued and executed but it doesn't
382 Actually so far it is for events caused by the video stream - aspect ratio
383 changes. These can occur when the master mutex is locked and so postMessage
384 doesn't work. postMessageNoLock doesn't work because if the mutex *isn't*
385 locked at the time then the message could be sat around a while before
387 The whole message system was at first supposed to prevent the problem of
388 calling a function on an object that had just been deleted, by ordering
389 messages such that all calls are done before object deletion. However,
390 because of the new centralised messaging system and the fact that BoxStack
391 locates the destination object before calling it, the messaging system now
392 allows the kind of sloppy calls it was supposed to stop. Weird huh. This
393 is mentioned here because the video stream might generate an event just as
394 the user hits stop. The mutex is locked, and by the time the message
395 is examined the vvideorec/live has been deleted. This doesn't matter because
396 boxstack will drop the message if it can't find the matching object to
398 Finally, all this is fine and dandy, except that I'm not 100% sure that
399 this sloppy postMessage and hope a queued signal will force it to be processed
400 thingy will actually work. Hmmm.
401 Lastly <g>, I will consider making the naming system a little more sane
405 logger->log("Command", Log::DEBUG, "PMFOS called");
406 MessageQueue::postMessage(m);
410 kill(mainPid, SIGURG);
412 ((RemoteAndroid*)Remote::getInstance())->Signal();
415 ((RemoteWin*)Remote::getInstance())->Signal();
419 void Command::processMessage(Message* m)
421 // FIXME - a slight modification - how if messagereceivers were to register
422 // themselves as receivers to avoid the calling-a-deleted-object problem
423 // then only deliver/register/unregister would have to be protected
425 logger->log("Command", Log::DEBUG, "processing message %i", m->message);
433 case Message::STOP_PLAYBACK:
435 handleCommand(Remote::STOP); // an odd way of doing it, but so simple
438 // Also connection_lost comes from player - anywhere else?
442 case Message::VDR_CONNECTED:
444 doJustConnected(static_cast<VConnect*>(m->from));
447 case Message::SCREENSHOT:
449 logger->log("Osd", Log::NOTICE, "Screenshot Message arrived");
450 Osd::getInstance()->screenShot("out.jpg");
453 case Message::CONNECTION_LOST:
458 case Message::UDP_BUTTON:
460 handleCommand(m->parameter.num);
463 case Message::CHANGE_LANGUAGE:
465 boxstack->removeAllExceptWallpaper();
466 boxstack->update(wallpaper);
468 if (!VDR::getInstance()->isConnected()) { connectionLost(); break; }
469 VWelcome* vw = new VWelcome();
472 boxstack->update(vw);
475 case Message::LAST_VIEW_CLOSE:
477 // Shouldn't be done like this. Some generic message pass back from vinfo perhaps
484 // VWelcome* vw = new VWelcome();
486 // boxstack->add(vw);
487 // boxstack->update(vw);
491 case Message::NEW_PICTURE:
493 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE");
494 OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
495 if (osdv) osdv->informPicture(m->tag, m->parameter.handle);
498 case Message::NEW_PICTURE_STATIC:
500 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE %x %x",m->tag,m->parameter.num);
501 OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
502 if (osdv) osdv->informPicture(((unsigned long long)m->tag)<<32LL,m->parameter.handle);
511 Instead of sending through the boxstack, implement a more generic MessageReceiver interface
512 and have potential receivers register with something
513 When a message needs to be delivered, check if the receiver is still registered, if so, deliver the message
514 This could all be done using the existing big command mutex to keep it simple
517 logger->log("Command", Log::DEBUG, "Sending message to boxstack");
518 boxstack->processMessage(m);
522 void Command::handleCommand(int button)
524 if (isStandby && (button != Remote::POWER)
525 && (button != Remote::POWERON)
526 && (button != Remote::POWEROFF)) return;
528 if (!connLost && boxstack->handleCommand(button)) return; // don't send to boxstack if connLost
530 // command was not handled
534 case Remote::DF_LEFT:
535 case Remote::DF_RIGHT:
536 case Remote::VOLUMEUP:
537 case Remote::VOLUMEDOWN:
539 if (remote->handlesVolume())
541 if (button==Remote::DF_LEFT || button==Remote::VOLUMEDOWN)
542 remote->volumeDown();
548 VVolume* v = new VVolume();
550 v->handleCommand(button); // this will draw+show
556 if (remote->handlesVolume())
558 remote->volumeMute();
562 VMute* v = new VMute();
574 case Remote::POWERON:
579 case Remote::POWEROFF:
587 if (!connLost) return; // if connLost, handle Remote::OK
593 VSleeptimer* sleep = new VSleeptimer();
594 boxstack->add(sleep);
595 sleep->handleCommand(button); // this will draw+show
604 Message* m = new Message(); // break into master mutex
605 m->message = Message::SCREENSHOT;
611 void Command::doStandby()
624 void Command::doPowerOn()
628 Video::getInstance()->signalOn();
629 Led::getInstance()->on();
630 Remote::getInstance()->changePowerState(true);
633 VConnect* vconnect = new VConnect(server);
634 boxstack->add(vconnect);
639 void Command::doPowerOff()
643 VDR::getInstance()->shutdownVDR();
644 boxstack->removeAllExceptWallpaper();
645 Video::getInstance()->signalOff();
646 boxstack->update(wallpaper);
648 VDR::getInstance()->configSave("General", "Last Power State", "Off");
649 logger->unsetExternLogger();
650 VDR::getInstance()->disconnect();
651 Led::getInstance()->off();
652 Remote::getInstance()->changePowerState(false);
654 Sleeptimer::getInstance()->shutdown();
656 stop(); //different behavoiur on windows, we exit
661 void Command::doFromTheTop(bool which)
663 if (isStandby) return;
668 logger->log("Command", Log::NOTICE, "Connection lost dialog already present");
672 logger->log("Command", Log::NOTICE, "Doing connection lost dialog");
673 connLost = new VInfo();
674 connLost->setSize(360, 200);
675 connLost->createBuffer();
676 if (Video::getInstance()->getFormat() == Video::PAL)
677 connLost->setPosition(190, 170);
679 connLost->setPosition(180, 120);
680 connLost->setOneLiner(tr("Connection lost"));
681 connLost->setDropThrough();
682 connLost->setBorderOn(1);
683 connLost->setTitleBarColour(DrawStyle::DANGER);
684 connLost->okButton();
686 boxstack->add(connLost);
687 boxstack->update(connLost);
688 remote->clearBuffer();
692 logger->unsetExternLogger();
693 VDR::getInstance()->disconnect();
694 boxstack->removeAllExceptWallpaper();
695 boxstack->update(wallpaper);
699 remote->clearBuffer();
701 // at this point, everything should be reset to first-go
703 VConnect* vconnect = new VConnect(server);
704 boxstack->add(vconnect);
709 void Command::doReboot()
712 logger->unsetExternLogger();
713 VDR::getInstance()->disconnect();
715 logger->log("Command", Log::NOTICE, "Reboot");
717 #ifndef VOMP_HAS_EXIT
718 // some plattforms, want a proper deinitialisation of their hardware before reboot
719 Osd::getInstance()->shutdown();
720 Audio::getInstance()->shutdown();
721 Video::getInstance()->shutdown();
722 Remote::getInstance()->shutdown();
724 reboot(LINUX_REBOOT_CMD_RESTART);
725 // if reboot is not allowed -> stop
737 #endif //Would we support this on windows?
740 void Command::connectionLost()
742 logger->unsetExternLogger();
743 Message* m = new Message(); // break into master mutex
744 m->message = Message::CONNECTION_LOST;
746 postMessageFromOuterSpace(m);
749 void Command::buildCrashedBox()
751 VInfo* crash = new VInfo();
752 crash->setSize(360, 250);
753 crash->createBuffer();
754 if (Video::getInstance()->getFormat() == Video::PAL)
755 crash->setPosition(190, 146);
757 crash->setPosition(180, 96);
758 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.");
759 crash->setBorderOn(1);
760 crash->setTitleBarColour(DrawStyle::DANGER);
762 crash->setExitable();
764 boxstack->add(crash);
765 boxstack->update(crash);
768 int Command::getLangPref(bool subtitle, const char* langcode)
770 std::vector<struct ASLPref>::iterator itty=langcodes.begin();
771 char templangcode[4];
772 templangcode[0] = langcode[0];
773 templangcode[1] = langcode[1];
774 templangcode[2] = langcode[2];
775 templangcode[3] = '\0';
777 while (itty != langcodes.end())
779 size_t pos = (*itty).langcode.find(templangcode);
780 if (pos != std::string::npos)
782 //vector<struct ASLPref>::iterator itty2=langcodes.begin();
783 for (unsigned int i = 0; i < langcodes.size(); i++)
787 pref = langcodes[i].subtitlepref;
789 pref = langcodes[i].audiopref;
794 if (langcodes[i].subtitlepref==langpos) return i;
798 if (langcodes[i].audiopref==langpos) return i;
806 return langcodes.size(); //neutral
809 void Command::doJustConnected(VConnect* vconnect)
812 if (!VDR::getInstance()->isConnected()) { connectionLost(); return; }
813 logger->log("Command", Log::INFO, "Entering doJustConnected");
815 Video* video = Video::getInstance();
816 Audio* audio = Audio::getInstance();
817 boxstack->remove(vconnect);
819 VInfo* vi = new VInfo();
820 vi->setSize(400, 200);
822 if (video->getFormat() == Video::PAL)
823 vi->setPosition(170, 200);
825 vi->setPosition(160, 150);
826 vi->setOneLiner(tr("Connected, loading config"));
829 boxstack->update(vi);
831 VDR* vdr = VDR::getInstance();
834 // See if we're supposed to do network logging
835 config = vdr->configLoad("Advanced", "Network logging");
836 if (config && !STRCASECMP(config, "On"))
838 logger->log("Command", Log::INFO, "Turning on network logging");
839 logger->setExternLogger(vdr);
843 logger->unsetExternLogger();
844 logger->log("Command", Log::INFO, "Turned off network logging");
846 if (config) delete[] config;
848 config = vdr->configLoad("Advanced", "Skin Name");
851 const char **skinnames=SkinFactory::getSkinNames();
852 for (int i=0;i<SkinFactory::getNumberofSkins();i++)
854 if (!STRCASECMP(config, skinnames[i]))
856 SkinFactory::InitSkin(i);
862 if (wallpaper && wallpaper_pict)
864 if (DrawStyle::WALLPAPER.alpha)
865 wallpaper_pict->setVisible(true);
867 wallpaper_pict->setVisible(false);
870 boxstack->update(wallpaper);
875 SkinFactory::InitSkin(0);
878 // See if config says to override video format (PAL/NTSC)
879 config = vdr->configLoad("General", "Override Video Format");
882 logger->log("Command", Log::DEBUG, "Override Video Format is present");
884 if ( (!strcmp(config, "PAL") && (video->getFormat() != Video::PAL))
885 || (!strcmp(config, "NTSC") && (video->getFormat() != Video::NTSC))
886 || (!strcmp(config, "PAL_M") && (video->getFormat() != Video::PAL_M))
887 || (!strcmp(config, "NTSC_J") && (video->getFormat() != Video::NTSC_J))
890 // Oh sheesh, need to switch format. Bye bye TV...
892 // Take everything down
893 boxstack->removeAllExceptWallpaper();
894 boxstack->remove(wallpaper);
895 delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL;
897 Osd* osd = Osd::getInstance();
903 remote->shutdown(); // need on raspberry shut not do any harm, hopefully
904 remote->init(RemoteStartDev);
906 // Get video and osd back up with the new mode
907 if (!strcmp(config, "PAL"))
909 logger->log("Command", Log::DEBUG, "Switching to PAL");
910 video->init(Video::PAL);
912 else if (!strcmp(config, "NTSC"))
914 logger->log("Command", Log::DEBUG, "Switching to NTSC");
915 video->init(Video::NTSC);
916 } else if (!strcmp(config, "PAL_M"))
918 logger->log("Command", Log::DEBUG, "Switching to PAL_M");
919 video->init(Video::PAL_M);
920 } else if (!strcmp(config, "NTSC_J"))
922 logger->log("Command", Log::DEBUG, "Switching to NTSC_J");
923 video->init(Video::NTSC_J);
928 //we do not init twice
932 // Put the wallpaper back
937 vi->setSize(400, 200);
939 if (video->getFormat() == Video::PAL)
940 vi->setPosition(170, 200);
942 vi->setPosition(160, 150);
944 vi->setOneLiner(tr("Connected, loading config"));
947 boxstack->update(vi);
951 logger->log("Command", Log::DEBUG, "Already in requested mode, or request was not 'PAL' or 'NTSC'");
956 logger->log("Command", Log::DEBUG, "Phew, no dangerous on-the-fly mode switching to do!");
959 // Power off if first boot and config says so
964 logger->log("Command", Log::DEBUG, "Load power after boot");
966 config = vdr->configLoad("General", "Power After Boot");
970 if (!STRCASECMP(config, "On"))
972 logger->log("Command", Log::INFO, "Config says Power After Boot = On");
974 else if (!STRCASECMP(config, "Off"))
976 logger->log("Command", Log::INFO, "Config says Power After Boot = Off");
981 else if (!STRCASECMP(config, "Last state"))
983 char* lastPowerState = vdr->configLoad("General", "Last Power State");
986 if (!STRCASECMP(lastPowerState, "On"))
988 logger->log("Command", Log::INFO, "Config says Last Power State = On");
990 else if (!STRCASECMP(lastPowerState, "Off"))
992 logger->log("Command", Log::INFO, "Config says Last Power State = Off");
999 logger->log("Command", Log::INFO, "Config General/Last Power State not understood");
1004 logger->log("Command", Log::INFO, "Config General/Last Power State not found");
1009 logger->log("Command", Log::INFO, "Config/Power After Boot not understood");
1015 logger->log("Command", Log::INFO, "Config General/Power After Boot not found");
1020 // Go S-Video if config says so
1022 config = vdr->configLoad("TV", "Connection");
1026 if (!STRCASECMP(config, "S-Video"))
1028 logger->log("Command", Log::INFO, "Switching to S-Video as Connection=%s", config);
1029 video->setConnection(Video::SVIDEO);
1030 } else if (!STRCASECMP(config, "HDMI"))
1032 logger->log("Command", Log::INFO, "Switching to HDMI as Connection=%s", config);
1033 video->setConnection(Video::HDMI);
1034 } else if (!STRCASECMP(config, "HDMI3D"))
1036 logger->log("Command", Log::INFO, "Switching to HDMI3D as Connection=%s", config);
1037 video->setConnection(Video::HDMI3D);
1041 logger->log("Command", Log::INFO, "Switching to RGB/Composite as Connection=%s", config);
1042 video->setConnection(Video::COMPOSITERGB);
1048 logger->log("Command", Log::INFO, "Config TV/S-Video not found");
1051 // Set to shutdown VDR if config says
1053 config = vdr->configLoad("General", "VDR shutdown");
1056 if (!STRCASECMP(config, "On"))
1058 logger->log("Command", Log::INFO, "Shutdown VDR when shutting down vomp");
1059 vdr->setVDRShutdown(true);
1061 else if (!STRCASECMP(config, "Off"))
1063 logger->log("Command", Log::INFO, "Shutdown only vomp");
1064 vdr->setVDRShutdown(false);
1069 logger->log("Command", Log::INFO, "Default shutdown only vomp");
1070 vdr->setVDRShutdown(false); // Default
1075 config = vdr->configLoad("General", "Remote type");
1079 if (!STRCASECMP(config, "New"))
1081 logger->log("Command", Log::INFO, "Switching to New remote type");
1082 remote->setRemoteType(Remote::NEWREMOTE);
1086 logger->log("Command", Log::INFO, "Switching to Old remote type");
1087 remote->setRemoteType(Remote::OLDREMOTE);
1093 logger->log("Command", Log::INFO, "Config General/Remote type not found");
1094 remote->setRemoteType(Remote::OLDREMOTE);
1099 // Get TV aspect ratio
1101 config = vdr->configLoad("TV", "Aspect");
1104 if (!STRCASECMP(config, "16:9"))
1106 logger->log("Command", Log::INFO, "/// Switching to TV aspect 16:9");
1107 video->setTVsize(Video::ASPECT16X9);
1111 logger->log("Command", Log::INFO, "/// Switching to TV aspect 4:3");
1112 video->setTVsize(Video::ASPECT4X3);
1118 logger->log("Command", Log::INFO, "Config TV/Aspect type not found, going 4:3");
1119 video->setTVsize(Video::ASPECT4X3);
1122 config = vdr->configLoad("TV", "Widemode");
1125 if (!STRCASECMP(config, "Letterbox"))
1127 logger->log("Command", Log::INFO, "Setting letterbox mode");
1128 video->setMode(Video::LETTERBOX);
1132 logger->log("Command", Log::INFO, "Setting chop-sides mode");
1133 video->setMode(Video::NORMAL);
1140 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting letterbox mode");
1141 video->setMode(Video::LETTERBOX);
1143 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting chop-sides mode");
1144 video->setMode(Video::NORMAL);
1148 config = vdr->configLoad("Advanced", "TCP receive window");
1151 size_t newTCPsize = atoi(config);
1154 logger->log("Command", Log::INFO, "Setting TCP window size %i", newTCPsize);
1155 vdr->setReceiveWindow(newTCPsize);
1159 logger->log("Command", Log::INFO, "TCP window size not found, setting 2048");
1160 if (DEFAULT_TCP_WINDOWSIZE) vdr->setReceiveWindow(2048); // Default
1163 config = vdr->configLoad("Advanced", "Font Name");
1166 Osd::getInstance()->setFont(config);
1167 logger->log("Command", Log::INFO, "Setting Font to %s", config);
1173 // Set recording list type
1175 #ifdef ADVANCED_MENUES
1176 config = vdr->configLoad("Advanced", "Menu type");
1180 if (!STRCASECMP(config, "Advanced"))
1182 logger->log("Command", Log::INFO, "Switching to Advanced menu");
1187 logger->log("Command", Log::INFO, "Switching to Classic menu");
1194 logger->log("Command", Log::INFO, "Config General/menu type not found");
1199 config = vdr->configLoad("Advanced", "Disable WOL");
1202 if (!STRCASECMP(config, "Yes"))
1204 logger->log("Command", Log::INFO, "Config says disable WOL");
1205 Wol::getInstance()->setEnabled(false);
1209 logger->log("Command", Log::INFO, "Config says enable WOL");
1210 Wol::getInstance()->setEnabled(true);
1217 logger->log("Command", Log::INFO, "By default, enable WOL");
1218 Wol::getInstance()->setEnabled(true);
1220 /* device dependend config */
1221 audio->loadOptionsfromServer(vdr);
1222 video->loadOptionsfromServer(vdr);
1223 remote->loadOptionsfromServer(vdr);
1225 video->executePendingModeChanges();
1228 // Save power state = on
1230 vdr->configSave("General", "Last Power State", "On");
1232 // Make sure connection didn't die
1233 if (!vdr->isConnected())
1235 Command::getInstance()->connectionLost();
1239 boxstack->remove(vi);
1241 VWelcome* vw = new VWelcome();
1244 boxstack->update(vw);
1246 // Enter pre-keys here
1247 // handleCommand(Remote::OK);
1248 // handleCommand(Remote::THREE);
1249 // handleCommand(Remote::SIX);
1250 // handleCommand(Remote::OK);
1251 // handleCommand(Remote::UP);
1252 // handleCommand(Remote::PLAY);
1253 // handleCommand(Remote::DOWN);
1254 // handleCommand(Remote::DOWN);
1255 // handleCommand(Remote::DOWN);
1256 // handleCommand(Remote::OK);
1257 // handleCommand(Remote::RED);