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"
59 #include "osdvector.h"
62 Command* Command::instance = NULL;
75 wallpaper = wallpaper_pict = NULL;
83 Command* Command::getInstance()
88 int Command::init(bool tcrashed, char* tServer)
90 if (initted) return 0;
95 logger = Log::getInstance();
96 boxstack = BoxStack::getInstance();
97 remote = Remote::getInstance();
99 remote->InitHWCListwithDefaults();
101 if (!logger || !boxstack || !remote)
107 SkinFactory::InitSkin(0);
110 pthread_mutex_init(&masterLock, NULL);
112 masterLock=CreateMutex(NULL,FALSE,NULL);
118 int Command::shutdown()
120 if (!initted) return 0;
127 // VDR::getInstance()->cancelFindingServer();
128 logger->log("Command", Log::NOTICE, "Command stop1...");
131 logger->log("Command", Log::NOTICE, "Command stop2...");
135 void Command::doWallpaper()
137 Video* video = Video::getInstance();
140 Boxx* bbg = new Boxx();
141 bbg->setSize(video->getScreenWidth(), video->getScreenHeight());
143 bbg->fillColour(DrawStyle::WALLPAPER);
145 boxstack->update(bbg);
146 boxstack->remove(bbg);
149 wallpaper = new Boxx();
150 wallpaper->setSize(video->getScreenWidth(), video->getScreenHeight());
151 wallpaper->createBuffer();
152 wallpaper ->setBackgroundColour(DrawStyle::WALLPAPER);
157 wallpaper_pict = new WJpegTYPE();
158 wallpaper_pict->setSize(video->getScreenWidth(), video->getScreenHeight());
161 if (video->getFormat() == Video::PAL)
163 logger->log("Command", Log::DEBUG, "PAL wallpaper selected");
165 wallpaper_pict->init("/wallpaperPAL.jpg");
167 wallpaper_pict->init("wallpaperPAL.jpg");
172 logger->log("Command", Log::DEBUG, "NTSC wallpaper selected");
173 wallpaper_pict->init("/wallpaperNTSC.jpg");
175 if (DrawStyle::WALLPAPER.alpha) {
176 wallpaper_pict->setVisible(true);
178 wallpaper_pict->setVisible(false);
180 wallpaper->add(wallpaper_pict);
183 boxstack->add(wallpaper);
184 boxstack->update(wallpaper);
186 OsdVector* osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
189 osdv->updateBackgroundColor(DrawStyle::WALLPAPER);
198 if (!initted) return;
205 Video::getInstance()->signalOn();
206 Led::getInstance()->on();
210 // End of startup. Lock the mutex and put the first view up
211 // logger->log("Command", Log::DEBUG, "WANT LOCK");
213 pthread_mutex_lock(&masterLock);
215 WaitForSingleObject(masterLock, INFINITE );
217 //logger->log("Command", Log::DEBUG, "LOCKED");
225 VConnect* vconnect = new VConnect(server);
226 boxstack->add(vconnect);
230 // Start method 2 of getting commands in...
237 //logger->log("Command", Log::DEBUG, "UNLOCK");
239 pthread_mutex_unlock(&masterLock);
241 ReleaseMutex(masterLock);
243 button = remote->getButtonPress(2); // Don't block (0) in case a signal arrives after checking signals but before this line
244 // something happened, lock and process
245 if (signals) processSignals(); // If a signal arrived process now.
247 // logger->log("Command", Log::DEBUG, "WANT LOCK");
249 pthread_mutex_lock(&masterLock);
251 WaitForSingleObject(masterLock, INFINITE );
253 // logger->log("Command", Log::DEBUG, "LOCK");
255 if ((button == Remote::NA_NONE) /*|| (button == Remote::NA_UNKNOWN)*/) continue;
257 if (button != Remote::NA_SIGNAL) handleCommand(button);
258 processMessageQueue();
262 //logger->log("Command", Log::DEBUG, "UNLOCK");
264 pthread_mutex_unlock(&masterLock);
266 ReleaseMutex(masterLock);
271 boxstack->removeAllExceptWallpaper();
272 boxstack->remove(wallpaper);
273 delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL;
277 void Command::setSignal(int signalReceived)
279 if (signalReceived == SIGINT)
281 else if (signalReceived == SIGTERM)
283 else if (signalReceived == SIGUSR1)
285 else if (signalReceived == SIGUSR2)
287 else if (signalReceived == SIGURG)
291 void Command::processSignals()
293 if (signals & SIG_INT)
295 signals = signals & ~SIG_INT;
296 logger->log("Command", Log::NOTICE, "INT signal, shutting down...");
300 if (signals & SIG_TERM)
302 signals = signals & ~SIG_TERM;
303 logger->log("Command", Log::NOTICE, "TERM signal, shutting down...");
307 if (signals & SIG_USR1)
309 logger->log("Command", Log::NOTICE, "USR1 signal");
310 signals = signals & ~SIG_USR1;
313 if (signals & SIG_USR2)
315 logger->log("Command", Log::NOTICE, "USR2 signal");
316 signals = signals & ~SIG_USR2;
319 if (signals & SIG_URG)
321 logger->log("Command", Log::NOTICE, "URG signal"); // This is used to break from getButtonPress to process the message queue
322 signals = signals & ~SIG_URG;
326 void Command::postMessage(Message* m)
328 // This is locked here in case the main loop is not waiting for an event, but is processing one
329 // it could be killed but then not react to it because the signal wouldn't cause
330 // remote->getButtonPress to break
331 // locking the mutex ensures that the master thread is waiting on getButtonPress
334 //logger->log("Command", Log::DEBUG, "WANT LOCK");
336 pthread_mutex_lock(&masterLock);
338 WaitForSingleObject(masterLock, INFINITE );
340 //logger->log("Command", Log::DEBUG, "LOCK");
341 MessageQueue::postMessage(m);
345 kill(mainPid, SIGURG);
347 ((RemoteAndroid*)Remote::getInstance())->Signal();
349 pthread_mutex_unlock(&masterLock);
351 ((RemoteWin*)Remote::getInstance())->Signal();
352 ReleaseMutex(masterLock);
354 //logger->log("Command", Log::DEBUG, "UNLOCK");
357 void Command::postMessageNoLock(Message* m)
359 // As above but use this one if this message is being posted because of a button press
360 // the mutex is already locked, locking around postMessage is not needed as the
361 // queue is guaranteed to be run when the button has been processed
362 MessageQueue::postMessage(m);
365 bool Command::postMessageIfNotBusy(Message* m)
367 // Used for Windows mouse events
369 //logger->log("Command", Log::DEBUG, "TRY LOCK");
371 if (pthread_mutex_trylock(&masterLock) != EBUSY)
373 //logger->log("Command", Log::DEBUG, "LOCK");
374 MessageQueue::postMessage(m);
376 kill(mainPid, SIGURG);
378 ((RemoteAndroid*)Remote::getInstance())->Signal();
380 pthread_mutex_unlock(&masterLock);
381 //logger->log("Command", Log::DEBUG, "UNLOCK");
389 switch (WaitForSingleObject(masterLock, 0 ))
390 { //FIXME this is not "if not busy" check
391 case WAIT_OBJECT_0: //but with proper argument 0 this did not work
392 // case WAIT_ABANDONED:
393 MessageQueue::postMessage(m);
394 ((RemoteWin*)Remote::getInstance())->Signal();
395 ReleaseMutex(masterLock);
398 case WAIT_ABANDONED: return false;
399 case WAIT_TIMEOUT: return false;
405 void Command::postMessageFromOuterSpace(Message* m)
408 Yet another way of getting messages into Command. This one is for events that
409 are not standard button presses (or UDP generated buttons). It is also not for
410 events that are generated as a result of other events (events that can safely
411 call postMessageNoLock and be guaranteed that the message will be processed
412 because it is known that the queue is currently being processed).
413 This is for events that come from outer space and can occur when the master
414 mutex is locked or not, they need to be queued and executed but it doesn't
416 Actually so far it is for events caused by the video stream - aspect ratio
417 changes. These can occur when the master mutex is locked and so postMessage
418 doesn't work. postMessageNoLock doesn't work because if the mutex *isn't*
419 locked at the time then the message could be sat around a while before
421 The whole message system was at first supposed to prevent the problem of
422 calling a function on an object that had just been deleted, by ordering
423 messages such that all calls are done before object deletion. However,
424 because of the new centralised messaging system and the fact that BoxStack
425 locates the destination object before calling it, the messaging system now
426 allows the kind of sloppy calls it was supposed to stop. Weird huh. This
427 is mentioned here because the video stream might generate an event just as
428 the user hits stop. The mutex is locked, and by the time the message
429 is examined the vvideorec/live has been deleted. This doesn't matter because
430 boxstack will drop the message if it can't find the matching object to
432 Finally, all this is fine and dandy, except that I'm not 100% sure that
433 this sloppy postMessage and hope a queued signal will force it to be processed
434 thingy will actually work. Hmmm.
435 Lastly <g>, I will consider making the naming system a little more sane
439 logger->log("Command", Log::DEBUG, "PMFOS called");
440 MessageQueue::postMessage(m);
444 kill(mainPid, SIGURG);
446 ((RemoteAndroid*)Remote::getInstance())->Signal();
449 ((RemoteWin*)Remote::getInstance())->Signal();
453 void Command::processMessage(Message* m)
455 // FIXME - a slight modification - how if messagereceivers were to register
456 // themselves as receivers to avoid the calling-a-deleted-object problem
457 // then only deliver/register/unregister would have to be protected
459 logger->log("Command", Log::DEBUG, "processing message %i", m->message);
467 case Message::STOP_PLAYBACK:
469 handleCommand(Remote::STOP); // an odd way of doing it, but so simple
472 // Also connection_lost comes from player - anywhere else?
476 case Message::VDR_CONNECTED:
478 doJustConnected((VConnect*)m->from);
481 case Message::SCREENSHOT:
483 #ifdef VOMP_PLATTFORM_MVP
484 Osd::getInstance()->screenShot("/out.jpg");
486 logger->log("Osd", Log::NOTICE, "Screenshot Message arrived");
487 Osd::getInstance()->screenShot("out.jpg");
491 case Message::CONNECTION_LOST:
496 case Message::UDP_BUTTON:
498 handleCommand(m->parameter.num);
501 case Message::CHANGE_LANGUAGE:
503 boxstack->removeAllExceptWallpaper();
504 boxstack->update(wallpaper);
506 if (!VDR::getInstance()->isConnected()) { connectionLost(); break; }
507 VWelcome* vw = new VWelcome();
510 boxstack->update(vw);
513 case Message::LAST_VIEW_CLOSE:
515 // Shouldn't be done like this. Some generic message pass back from vinfo perhaps
522 // VWelcome* vw = new VWelcome();
524 // boxstack->add(vw);
525 // boxstack->update(vw);
529 case Message::NEW_PICTURE:
531 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE");
532 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
534 osdv->informPicture(m->tag,m->parameter.handle);
538 case Message::NEW_PICTURE_STATIC:
540 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE %x %x",m->tag,m->parameter.num);
541 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
543 osdv->informPicture(((unsigned long long)m->tag)<<32LL,m->parameter.handle);
553 Instead of sending through the boxstack, implement a more generic MessageReceiver interface
554 and have potential receivers register with something
555 When a message needs to be delivered, check if the receiver is still registered, if so, deliver the message
556 This could all be done using the existing big command mutex to keep it simple
559 logger->log("Command", Log::DEBUG, "Sending message to boxstack");
560 boxstack->processMessage(m);
564 void Command::handleCommand(int button)
566 if (isStandby && (button != Remote::POWER)
567 && (button != Remote::POWERON) && (button != Remote::POWEROFF)) return;
568 if (!connLost && boxstack->handleCommand(button)) return; // don't send to boxstack if connLost
570 // command was not handled
574 case Remote::DF_LEFT:
575 case Remote::DF_RIGHT:
576 case Remote::VOLUMEUP:
577 case Remote::VOLUMEDOWN:
579 if (remote->handlesVolume()) {
580 if (button==Remote::DF_LEFT || button==Remote::VOLUMEDOWN)
581 remote->volumeDown();
582 else remote->volumeUp();
584 VVolume* v = new VVolume();
586 v->handleCommand(button); // this will draw+show
592 if (remote->handlesVolume()) {
593 remote->volumeMute();
595 VMute* v = new VMute();
607 case Remote::POWERON:
612 case Remote::POWEROFF:
620 if (!connLost) return; // if connLost, handle Remote::OK
626 VSleeptimer* sleep = new VSleeptimer();
627 boxstack->add(sleep);
628 sleep->handleCommand(button); // this will draw+show
637 Message* m = new Message(); // break into master mutex
638 m->message = Message::SCREENSHOT;
644 void Command::doStandby()
657 void Command::doPowerOn()
661 Video::getInstance()->signalOn();
662 Led::getInstance()->on();
663 Remote::getInstance()->changePowerState(true);
667 VConnect* vconnect = new VConnect(server);
668 boxstack->add(vconnect);
673 void Command::doPowerOff()
677 VDR::getInstance()->shutdownVDR();
678 boxstack->removeAllExceptWallpaper();
679 Video::getInstance()->signalOff();
680 boxstack->update(wallpaper);
682 VDR::getInstance()->configSave("General", "Last Power State", "Off");
683 logger->unsetExternLogger();
684 VDR::getInstance()->disconnect();
685 Led::getInstance()->off();
686 Remote::getInstance()->changePowerState(false);
688 Sleeptimer::getInstance()->shutdown();
690 stop(); //different behavoiur on windows, we exit
695 void Command::doFromTheTop(bool which)
697 if (isStandby) return;
702 logger->log("Command", Log::NOTICE, "Connection lost dialog already present");
706 logger->log("Command", Log::NOTICE, "Doing connection lost dialog");
707 connLost = new VInfo();
708 connLost->setSize(360, 200);
709 connLost->createBuffer();
710 if (Video::getInstance()->getFormat() == Video::PAL)
711 connLost->setPosition(190, 170);
713 connLost->setPosition(180, 120);
714 connLost->setOneLiner(tr("Connection lost"));
715 connLost->setDropThrough();
716 connLost->setBorderOn(1);
717 connLost->setTitleBarColour(DrawStyle::DANGER);
718 connLost->okButton();
720 boxstack->add(connLost);
721 boxstack->update(connLost);
722 remote->clearBuffer();
726 logger->unsetExternLogger();
727 VDR::getInstance()->disconnect();
728 boxstack->removeAllExceptWallpaper();
729 boxstack->update(wallpaper);
733 remote->clearBuffer();
735 // at this point, everything should be reset to first-go
737 VConnect* vconnect = new VConnect(server);
738 boxstack->add(vconnect);
743 void Command::doReboot()
746 logger->unsetExternLogger();
747 VDR::getInstance()->disconnect();
749 logger->log("Command", Log::NOTICE, "Reboot");
751 #ifndef VOMP_HAS_EXIT
752 // some plattforms, want a proper deinitialisation of their hardware before reboot
753 Osd::getInstance()->shutdown();
754 Audio::getInstance()->shutdown();
755 Video::getInstance()->shutdown();
756 Remote::getInstance()->shutdown();
758 reboot(LINUX_REBOOT_CMD_RESTART);
759 // if reboot is not allowed -> stop
771 #endif //Would we support this on windows?
774 void Command::connectionLost()
776 logger->unsetExternLogger();
777 Message* m = new Message(); // break into master mutex
778 m->message = Message::CONNECTION_LOST;
780 postMessageFromOuterSpace(m);
783 void Command::buildCrashedBox()
785 VInfo* crash = new VInfo();
786 crash->setSize(360, 250);
787 crash->createBuffer();
788 if (Video::getInstance()->getFormat() == Video::PAL)
789 crash->setPosition(190, 146);
791 crash->setPosition(180, 96);
792 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.");
793 crash->setBorderOn(1);
794 crash->setTitleBarColour(DrawStyle::DANGER);
796 crash->setExitable();
798 boxstack->add(crash);
799 boxstack->update(crash);
802 int Command::getLangPref(bool subtitle,const char* langcode)
804 vector<struct ASLPref>::iterator itty=langcodes.begin();
805 char templangcode[4];
806 templangcode[0]=langcode[0];
807 templangcode[1]=langcode[1];
808 templangcode[2]=langcode[2];
809 templangcode[3]='\0';
811 while (itty != langcodes.end()) {
812 size_t pos=(*itty).langcode.find(templangcode);
813 if (pos != string::npos) {
814 vector<struct ASLPref>::iterator itty2=langcodes.begin();
815 for (int i=0; i<langcodes.size();i++) {
818 pref=langcodes[i].subtitlepref;
820 pref=langcodes[i].audiopref;
825 if (langcodes[i].subtitlepref==langpos) {
829 if (langcodes[i].audiopref==langpos) {
839 return langcodes.size(); //neutral
842 void Command::doJustConnected(VConnect* vconnect)
845 if (!VDR::getInstance()->isConnected()) { connectionLost(); return; }
846 logger->log("Command", Log::INFO, "Entering doJustConnected");
848 Video* video = Video::getInstance();
849 Audio* audio = Audio::getInstance();
850 boxstack->remove(vconnect);
852 VInfo* vi = new VInfo();
853 vi->setSize(400, 200);
855 if (video->getFormat() == Video::PAL)
856 vi->setPosition(170, 200);
858 vi->setPosition(160, 150);
859 vi->setOneLiner(tr("Connected, loading config"));
862 boxstack->update(vi);
864 VDR* vdr = VDR::getInstance();
867 // See if we're supposed to do network logging
868 config = vdr->configLoad("Advanced", "Network logging");
869 if (config && !STRCASECMP(config, "On"))
871 logger->log("Command", Log::INFO, "Turning on network logging");
872 logger->setExternLogger(vdr);
876 logger->unsetExternLogger();
877 logger->log("Command", Log::INFO, "Turned off network logging");
879 if (config) delete[] config;
881 config = vdr->configLoad("Advanced", "Skin Name");
883 const char **skinnames=SkinFactory::getSkinNames();
884 for (int i=0;i<SkinFactory::getNumberofSkins();i++) {
885 if (!STRCASECMP(config, skinnames[i])) {
886 SkinFactory::InitSkin(i);
891 if (wallpaper && wallpaper_pict) {
892 if (DrawStyle::WALLPAPER.alpha) {
893 wallpaper_pict->setVisible(true);
895 wallpaper_pict->setVisible(false);
898 boxstack->update(wallpaper);
902 SkinFactory::InitSkin(0);
905 // See if config says to override video format (PAL/NTSC)
906 config = vdr->configLoad("General", "Override Video Format");
909 logger->log("Command", Log::DEBUG, "Override Video Format is present");
911 if ( (!strcmp(config, "PAL") && (video->getFormat() != Video::PAL))
912 || (!strcmp(config, "NTSC") && (video->getFormat() != Video::NTSC))
913 || (!strcmp(config, "PAL_M") && (video->getFormat() != Video::PAL_M))
914 || (!strcmp(config, "NTSC_J") && (video->getFormat() != Video::NTSC_J))
917 // Oh sheesh, need to switch format. Bye bye TV...
919 // Take everything down
920 boxstack->removeAllExceptWallpaper();
921 boxstack->remove(wallpaper);
922 delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL;
924 Osd* osd = Osd::getInstance();
930 remote->shutdown(); // need on raspberry shut not do any harm, hopefully
931 remote->init(RemoteStartDev);
933 // Get video and osd back up with the new mode
934 if (!strcmp(config, "PAL"))
936 logger->log("Command", Log::DEBUG, "Switching to PAL");
937 video->init(Video::PAL);
939 else if (!strcmp(config, "NTSC"))
941 logger->log("Command", Log::DEBUG, "Switching to NTSC");
942 video->init(Video::NTSC);
943 } else if (!strcmp(config, "PAL_M"))
945 logger->log("Command", Log::DEBUG, "Switching to PAL_M");
946 video->init(Video::PAL_M);
947 } else if (!strcmp(config, "NTSC_J"))
949 logger->log("Command", Log::DEBUG, "Switching to NTSC_J");
950 video->init(Video::NTSC_J);
955 //we do not init twice
956 osd->init((char*)("/dev/stbgfx"));
959 // Put the wallpaper back
964 vi->setSize(400, 200);
966 if (video->getFormat() == Video::PAL)
967 vi->setPosition(170, 200);
969 vi->setPosition(160, 150);
971 vi->setOneLiner(tr("Connected, loading config"));
974 boxstack->update(vi);
978 logger->log("Command", Log::DEBUG, "Already in requested mode, or request was not 'PAL' or 'NTSC'");
983 logger->log("Command", Log::DEBUG, "Phew, no dangerous on-the-fly mode switching to do!");
986 // Power off if first boot and config says so
991 logger->log("Command", Log::DEBUG, "Load power after boot");
993 config = vdr->configLoad("General", "Power After Boot");
997 if (!STRCASECMP(config, "On"))
999 logger->log("Command", Log::INFO, "Config says Power After Boot = On");
1001 else if (!STRCASECMP(config, "Off"))
1003 logger->log("Command", Log::INFO, "Config says Power After Boot = Off");
1006 return; // quit here
1008 else if (!STRCASECMP(config, "Last state"))
1010 char* lastPowerState = vdr->configLoad("General", "Last Power State");
1013 if (!STRCASECMP(lastPowerState, "On"))
1015 logger->log("Command", Log::INFO, "Config says Last Power State = On");
1017 else if (!STRCASECMP(lastPowerState, "Off"))
1019 logger->log("Command", Log::INFO, "Config says Last Power State = Off");
1022 return; // quit here
1026 logger->log("Command", Log::INFO, "Config General/Last Power State not understood");
1031 logger->log("Command", Log::INFO, "Config General/Last Power State not found");
1036 logger->log("Command", Log::INFO, "Config/Power After Boot not understood");
1042 logger->log("Command", Log::INFO, "Config General/Power After Boot not found");
1047 // Go S-Video if config says so
1049 config = vdr->configLoad("TV", "Connection");
1053 if (!STRCASECMP(config, "S-Video"))
1055 logger->log("Command", Log::INFO, "Switching to S-Video as Connection=%s", config);
1056 video->setConnection(Video::SVIDEO);
1057 } else if (!STRCASECMP(config, "HDMI"))
1059 logger->log("Command", Log::INFO, "Switching to HDMI as Connection=%s", config);
1060 video->setConnection(Video::HDMI);
1061 } else if (!STRCASECMP(config, "HDMI3D"))
1063 logger->log("Command", Log::INFO, "Switching to HDMI3D as Connection=%s", config);
1064 video->setConnection(Video::HDMI3D);
1068 logger->log("Command", Log::INFO, "Switching to RGB/Composite as Connection=%s", config);
1069 video->setConnection(Video::COMPOSITERGB);
1075 logger->log("Command", Log::INFO, "Config TV/S-Video not found");
1078 // Set to shutdown VDR if config says
1080 config = vdr->configLoad("General", "VDR shutdown");
1083 if (!STRCASECMP(config, "On"))
1085 logger->log("Command", Log::INFO, "Shutdown VDR when shutting down vomp");
1086 vdr->setVDRShutdown(true);
1088 else if (!STRCASECMP(config, "Off"))
1090 logger->log("Command", Log::INFO, "Shutdown only vomp");
1091 vdr->setVDRShutdown(false);
1096 logger->log("Command", Log::INFO, "Default shutdown only vomp");
1097 vdr->setVDRShutdown(false); // Default
1102 config = vdr->configLoad("General", "Remote type");
1106 if (!STRCASECMP(config, "New"))
1108 logger->log("Command", Log::INFO, "Switching to New remote type");
1109 remote->setRemoteType(Remote::NEWREMOTE);
1113 logger->log("Command", Log::INFO, "Switching to Old remote type");
1114 remote->setRemoteType(Remote::OLDREMOTE);
1120 logger->log("Command", Log::INFO, "Config General/Remote type not found");
1121 remote->setRemoteType(Remote::OLDREMOTE);
1126 // Get TV aspect ratio
1128 config = vdr->configLoad("TV", "Aspect");
1131 if (!STRCASECMP(config, "16:9"))
1133 logger->log("Command", Log::INFO, "/// Switching to TV aspect 16:9");
1134 video->setTVsize(Video::ASPECT16X9);
1138 logger->log("Command", Log::INFO, "/// Switching to TV aspect 4:3");
1139 video->setTVsize(Video::ASPECT4X3);
1145 logger->log("Command", Log::INFO, "Config TV/Aspect type not found, going 4:3");
1146 video->setTVsize(Video::ASPECT4X3);
1149 config = vdr->configLoad("TV", "Widemode");
1152 if (!STRCASECMP(config, "Letterbox"))
1154 logger->log("Command", Log::INFO, "Setting letterbox mode");
1155 video->setMode(Video::LETTERBOX);
1159 logger->log("Command", Log::INFO, "Setting chop-sides mode");
1160 video->setMode(Video::NORMAL);
1167 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting letterbox mode");
1168 video->setMode(Video::LETTERBOX);
1170 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting chop-sides mode");
1171 video->setMode(Video::NORMAL);
1175 config = vdr->configLoad("Advanced", "TCP receive window");
1178 size_t newTCPsize = atoi(config);
1181 logger->log("Command", Log::INFO, "Setting TCP window size %i", newTCPsize);
1182 vdr->setReceiveWindow(newTCPsize);
1186 logger->log("Command", Log::INFO, "TCP window size not found, setting 2048");
1187 if (DEFAULT_TCP_WINDOWSIZE) vdr->setReceiveWindow(2048); // Default
1190 config = vdr->configLoad("Advanced", "Font Name");
1193 Osd::getInstance()->setFont(config);
1194 logger->log("Command", Log::INFO, "Setting Font to %s", config);
1200 // Set recording list type
1203 #ifdef ADVANCED_MENUES
1204 config = vdr->configLoad("Advanced", "Menu type");
1208 if (!STRCASECMP(config, "Advanced"))
1210 logger->log("Command", Log::INFO, "Switching to Advanced menu");
1216 logger->log("Command", Log::INFO, "Switching to Classic menu");
1223 logger->log("Command", Log::INFO, "Config General/menu type not found");
1228 config = vdr->configLoad("Advanced", "Disable WOL");
1231 if (!STRCASECMP(config, "Yes"))
1233 logger->log("Command", Log::INFO, "Config says disable WOL");
1234 Wol::getInstance()->setEnabled(false);
1238 logger->log("Command", Log::INFO, "Config says enable WOL");
1239 Wol::getInstance()->setEnabled(true);
1246 logger->log("Command", Log::INFO, "By default, enable WOL");
1247 Wol::getInstance()->setEnabled(true);
1249 /* device dependend config */
1250 audio->loadOptionsfromServer(vdr);
1251 video->loadOptionsfromServer(vdr);
1252 remote->loadOptionsfromServer(vdr);
1254 video->executePendingModeChanges();
1257 // Save power state = on
1259 vdr->configSave("General", "Last Power State", "On");
1261 // Make sure connection didn't die
1262 if (!vdr->isConnected())
1264 Command::getInstance()->connectionLost();
1268 boxstack->remove(vi);
1270 VWelcome* vw = new VWelcome();
1273 boxstack->update(vw);
1275 // Enter pre-keys here
1276 // handleCommand(Remote::OK);
1277 // handleCommand(Remote::THREE);
1278 // handleCommand(Remote::SIX);
1279 // handleCommand(Remote::OK);
1280 // handleCommand(Remote::UP);
1281 // handleCommand(Remote::PLAY);
1282 // handleCommand(Remote::DOWN);
1283 // handleCommand(Remote::DOWN);
1284 // handleCommand(Remote::DOWN);
1285 // handleCommand(Remote::OK);
1286 // handleCommand(Remote::RED);