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"
61 Command* Command::instance = NULL;
74 wallpaper = wallpaper_pict = NULL;
82 Command* Command::getInstance()
87 int Command::init(bool tcrashed, char* tServer)
89 if (initted) return 0;
94 logger = Log::getInstance();
95 boxstack = BoxStack::getInstance();
96 remote = Remote::getInstance();
98 remote->InitHWCListwithDefaults();
100 if (!logger || !boxstack || !remote)
106 SkinFactory::InitSkin(0);
109 pthread_mutex_init(&masterLock, NULL);
111 masterLock=CreateMutex(NULL,FALSE,NULL);
117 int Command::shutdown()
119 if (!initted) return 0;
126 // VDR::getInstance()->cancelFindingServer();
127 logger->log("Command", Log::NOTICE, "Command stop1...");
130 logger->log("Command", Log::NOTICE, "Command stop2...");
134 void Command::doWallpaper()
136 Video* video = Video::getInstance();
139 Boxx* bbg = new Boxx();
140 bbg->setSize(video->getScreenWidth(), video->getScreenHeight());
142 bbg->fillColour(DrawStyle::WALLPAPER);
144 boxstack->update(bbg);
145 boxstack->remove(bbg);
148 wallpaper = new Boxx();
149 wallpaper->setSize(video->getScreenWidth(), video->getScreenHeight());
150 wallpaper->createBuffer();
151 wallpaper ->setBackgroundColour(DrawStyle::WALLPAPER);
156 wallpaper_pict = new WJpegTYPE();
157 wallpaper_pict->setSize(video->getScreenWidth(), video->getScreenHeight());
160 if (video->getFormat() == Video::PAL)
162 logger->log("Command", Log::DEBUG, "PAL wallpaper selected");
164 wallpaper_pict->init("/wallpaperPAL.jpg");
166 wallpaper_pict->init("wallpaperPAL.jpg");
171 logger->log("Command", Log::DEBUG, "NTSC wallpaper selected");
172 wallpaper_pict->init("/wallpaperNTSC.jpg");
174 if (DrawStyle::WALLPAPER.alpha) {
175 wallpaper_pict->setVisible(true);
177 wallpaper_pict->setVisible(false);
179 wallpaper->add(wallpaper_pict);
182 boxstack->add(wallpaper);
183 boxstack->update(wallpaper);
185 #ifndef VOMP_PLATTFORM_MVP
187 OsdVector* osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
190 osdv->updateBackgroundColor(DrawStyle::WALLPAPER);
199 if (!initted) return;
206 Video::getInstance()->signalOn();
207 Led::getInstance()->on();
211 // End of startup. Lock the mutex and put the first view up
212 // logger->log("Command", Log::DEBUG, "WANT LOCK");
214 pthread_mutex_lock(&masterLock);
216 WaitForSingleObject(masterLock, INFINITE );
218 //logger->log("Command", Log::DEBUG, "LOCKED");
226 VConnect* vconnect = new VConnect(server);
227 boxstack->add(vconnect);
231 // Start method 2 of getting commands in...
238 //logger->log("Command", Log::DEBUG, "UNLOCK");
240 pthread_mutex_unlock(&masterLock);
242 ReleaseMutex(masterLock);
244 button = remote->getButtonPress(2); // Don't block (0) in case a signal arrives after checking signals but before this line
245 // something happened, lock and process
246 if (signals) processSignals(); // If a signal arrived process now.
248 // logger->log("Command", Log::DEBUG, "WANT LOCK");
250 pthread_mutex_lock(&masterLock);
252 WaitForSingleObject(masterLock, INFINITE );
254 // logger->log("Command", Log::DEBUG, "LOCK");
256 if ((button == Remote::NA_NONE) /*|| (button == Remote::NA_UNKNOWN)*/) continue;
258 if (button != Remote::NA_SIGNAL) handleCommand(button);
259 processMessageQueue();
263 //logger->log("Command", Log::DEBUG, "UNLOCK");
265 pthread_mutex_unlock(&masterLock);
267 ReleaseMutex(masterLock);
273 void Command::setSignal(int signalReceived)
275 if (signalReceived == SIGINT)
277 else if (signalReceived == SIGTERM)
279 else if (signalReceived == SIGUSR1)
281 else if (signalReceived == SIGUSR2)
283 else if (signalReceived == SIGURG)
287 void Command::processSignals()
289 if (signals & SIG_INT)
291 signals = signals & ~SIG_INT;
292 logger->log("Command", Log::NOTICE, "INT signal, shutting down...");
296 if (signals & SIG_TERM)
298 signals = signals & ~SIG_TERM;
299 logger->log("Command", Log::NOTICE, "TERM signal, shutting down...");
303 if (signals & SIG_USR1)
305 logger->log("Command", Log::NOTICE, "USR1 signal");
306 signals = signals & ~SIG_USR1;
309 if (signals & SIG_USR2)
311 logger->log("Command", Log::NOTICE, "USR2 signal");
312 signals = signals & ~SIG_USR2;
315 if (signals & SIG_URG)
317 logger->log("Command", Log::NOTICE, "URG signal"); // This is used to break from getButtonPress to process the message queue
318 signals = signals & ~SIG_URG;
322 void Command::postMessage(Message* m)
324 // This is locked here in case the main loop is not waiting for an event, but is processing one
325 // it could be killed but then not react to it because the signal wouldn't cause
326 // remote->getButtonPress to break
327 // locking the mutex ensures that the master thread is waiting on getButtonPress
330 //logger->log("Command", Log::DEBUG, "WANT LOCK");
332 pthread_mutex_lock(&masterLock);
334 WaitForSingleObject(masterLock, INFINITE );
336 //logger->log("Command", Log::DEBUG, "LOCK");
337 MessageQueue::postMessage(m);
341 kill(mainPid, SIGURG);
343 ((RemoteAndroid*)Remote::getInstance())->Signal();
345 pthread_mutex_unlock(&masterLock);
347 ((RemoteWin*)Remote::getInstance())->Signal();
348 ReleaseMutex(masterLock);
350 //logger->log("Command", Log::DEBUG, "UNLOCK");
353 void Command::postMessageNoLock(Message* m)
355 // As above but use this one if this message is being posted because of a button press
356 // the mutex is already locked, locking around postMessage is not needed as the
357 // queue is guaranteed to be run when the button has been processed
358 MessageQueue::postMessage(m);
361 bool Command::postMessageIfNotBusy(Message* m)
363 // Used for Windows mouse events
365 //logger->log("Command", Log::DEBUG, "TRY LOCK");
367 if (pthread_mutex_trylock(&masterLock) != EBUSY)
369 //logger->log("Command", Log::DEBUG, "LOCK");
370 MessageQueue::postMessage(m);
372 kill(mainPid, SIGURG);
374 ((RemoteAndroid*)Remote::getInstance())->Signal();
376 pthread_mutex_unlock(&masterLock);
377 //logger->log("Command", Log::DEBUG, "UNLOCK");
385 switch (WaitForSingleObject(masterLock, 0 ))
386 { //FIXME this is not "if not busy" check
387 case WAIT_OBJECT_0: //but with proper argument 0 this did not work
388 // case WAIT_ABANDONED:
389 MessageQueue::postMessage(m);
390 ((RemoteWin*)Remote::getInstance())->Signal();
391 ReleaseMutex(masterLock);
394 case WAIT_ABANDONED: return false;
395 case WAIT_TIMEOUT: return false;
401 void Command::postMessageFromOuterSpace(Message* m)
404 Yet another way of getting messages into Command. This one is for events that
405 are not standard button presses (or UDP generated buttons). It is also not for
406 events that are generated as a result of other events (events that can safely
407 call postMessageNoLock and be guaranteed that the message will be processed
408 because it is known that the queue is currently being processed).
409 This is for events that come from outer space and can occur when the master
410 mutex is locked or not, they need to be queued and executed but it doesn't
412 Actually so far it is for events caused by the video stream - aspect ratio
413 changes. These can occur when the master mutex is locked and so postMessage
414 doesn't work. postMessageNoLock doesn't work because if the mutex *isn't*
415 locked at the time then the message could be sat around a while before
417 The whole message system was at first supposed to prevent the problem of
418 calling a function on an object that had just been deleted, by ordering
419 messages such that all calls are done before object deletion. However,
420 because of the new centralised messaging system and the fact that BoxStack
421 locates the destination object before calling it, the messaging system now
422 allows the kind of sloppy calls it was supposed to stop. Weird huh. This
423 is mentioned here because the video stream might generate an event just as
424 the user hits stop. The mutex is locked, and by the time the message
425 is examined the vvideorec/live has been deleted. This doesn't matter because
426 boxstack will drop the message if it can't find the matching object to
428 Finally, all this is fine and dandy, except that I'm not 100% sure that
429 this sloppy postMessage and hope a queued signal will force it to be processed
430 thingy will actually work. Hmmm.
431 Lastly <g>, I will consider making the naming system a little more sane
435 logger->log("Command", Log::DEBUG, "PMFOS called");
436 MessageQueue::postMessage(m);
440 kill(mainPid, SIGURG);
442 ((RemoteAndroid*)Remote::getInstance())->Signal();
445 ((RemoteWin*)Remote::getInstance())->Signal();
449 void Command::processMessage(Message* m)
451 // FIXME - a slight modification - how if messagereceivers were to register
452 // themselves as receivers to avoid the calling-a-deleted-object problem
453 // then only deliver/register/unregister would have to be protected
455 logger->log("Command", Log::DEBUG, "processing message %i", m->message);
463 case Message::STOP_PLAYBACK:
465 handleCommand(Remote::STOP); // an odd way of doing it, but so simple
468 // Also connection_lost comes from player - anywhere else?
472 case Message::VDR_CONNECTED:
474 doJustConnected((VConnect*)m->from);
477 case Message::SCREENSHOT:
479 #ifdef VOMP_PLATTFORM_MVP
480 Osd::getInstance()->screenShot("/out.jpg");
482 logger->log("Osd", Log::NOTICE, "Screenshot Message arrived");
483 Osd::getInstance()->screenShot("out.jpg");
487 case Message::CONNECTION_LOST:
492 case Message::UDP_BUTTON:
494 handleCommand(m->parameter.num);
497 case Message::CHANGE_LANGUAGE:
499 boxstack->removeAll();
500 boxstack->update(wallpaper);
502 if (!VDR::getInstance()->isConnected()) { connectionLost(); break; }
503 VWelcome* vw = new VWelcome();
506 boxstack->update(vw);
509 case Message::LAST_VIEW_CLOSE:
511 // Shouldn't be done like this. Some generic message pass back from vinfo perhaps
518 // VWelcome* vw = new VWelcome();
520 // boxstack->add(vw);
521 // boxstack->update(vw);
525 case Message::NEW_PICTURE:
527 #ifndef VOMP_PLATTFORM_MVP
529 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE");
530 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
532 osdv->informPicture(m->tag,m->parameter.handle);
536 case Message::NEW_PICTURE_STATIC:
538 #ifndef VOMP_PLATTFORM_MVP
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->removeAll();
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->removeAll();
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->removeAll();
921 boxstack->remove(wallpaper);
922 Osd* osd = Osd::getInstance();
928 remote->shutdown(); // need on raspberry shut not do any harm, hopefully
929 remote->init(RemoteStartDev);
931 // Get video and osd back up with the new mode
932 if (!strcmp(config, "PAL"))
934 logger->log("Command", Log::DEBUG, "Switching to PAL");
935 video->init(Video::PAL);
937 else if (!strcmp(config, "NTSC"))
939 logger->log("Command", Log::DEBUG, "Switching to NTSC");
940 video->init(Video::NTSC);
941 } else if (!strcmp(config, "PAL_M"))
943 logger->log("Command", Log::DEBUG, "Switching to PAL_M");
944 video->init(Video::PAL_M);
945 } else if (!strcmp(config, "NTSC_J"))
947 logger->log("Command", Log::DEBUG, "Switching to NTSC_J");
948 video->init(Video::NTSC_J);
953 //we do not init twice
954 osd->init((char*)("/dev/stbgfx"));
957 // Put the wallpaper back
962 vi->setSize(400, 200);
964 if (video->getFormat() == Video::PAL)
965 vi->setPosition(170, 200);
967 vi->setPosition(160, 150);
969 vi->setOneLiner(tr("Connected, loading config"));
972 boxstack->update(vi);
976 logger->log("Command", Log::DEBUG, "Already in requested mode, or request was not 'PAL' or 'NTSC'");
981 logger->log("Command", Log::DEBUG, "Phew, no dangerous on-the-fly mode switching to do!");
984 // Power off if first boot and config says so
989 logger->log("Command", Log::DEBUG, "Load power after boot");
991 config = vdr->configLoad("General", "Power After Boot");
995 if (!STRCASECMP(config, "On"))
997 logger->log("Command", Log::INFO, "Config says Power After Boot = On");
999 else if (!STRCASECMP(config, "Off"))
1001 logger->log("Command", Log::INFO, "Config says Power After Boot = Off");
1004 return; // quit here
1006 else if (!STRCASECMP(config, "Last state"))
1008 char* lastPowerState = vdr->configLoad("General", "Last Power State");
1011 if (!STRCASECMP(lastPowerState, "On"))
1013 logger->log("Command", Log::INFO, "Config says Last Power State = On");
1015 else if (!STRCASECMP(lastPowerState, "Off"))
1017 logger->log("Command", Log::INFO, "Config says Last Power State = Off");
1020 return; // quit here
1024 logger->log("Command", Log::INFO, "Config General/Last Power State not understood");
1029 logger->log("Command", Log::INFO, "Config General/Last Power State not found");
1034 logger->log("Command", Log::INFO, "Config/Power After Boot not understood");
1040 logger->log("Command", Log::INFO, "Config General/Power After Boot not found");
1045 // Go S-Video if config says so
1047 config = vdr->configLoad("TV", "Connection");
1051 if (!STRCASECMP(config, "S-Video"))
1053 logger->log("Command", Log::INFO, "Switching to S-Video as Connection=%s", config);
1054 video->setConnection(Video::SVIDEO);
1055 } else if (!STRCASECMP(config, "HDMI"))
1057 logger->log("Command", Log::INFO, "Switching to HDMI as Connection=%s", config);
1058 video->setConnection(Video::HDMI);
1059 } else if (!STRCASECMP(config, "HDMI3D"))
1061 logger->log("Command", Log::INFO, "Switching to HDMI3D as Connection=%s", config);
1062 video->setConnection(Video::HDMI3D);
1066 logger->log("Command", Log::INFO, "Switching to RGB/Composite as Connection=%s", config);
1067 video->setConnection(Video::COMPOSITERGB);
1073 logger->log("Command", Log::INFO, "Config TV/S-Video not found");
1076 // Set to shutdown VDR if config says
1078 config = vdr->configLoad("General", "VDR shutdown");
1081 if (!STRCASECMP(config, "On"))
1083 logger->log("Command", Log::INFO, "Shutdown VDR when shutting down vomp");
1084 vdr->setVDRShutdown(true);
1086 else if (!STRCASECMP(config, "Off"))
1088 logger->log("Command", Log::INFO, "Shutdown only vomp");
1089 vdr->setVDRShutdown(false);
1094 logger->log("Command", Log::INFO, "Default shutdown only vomp");
1095 vdr->setVDRShutdown(false); // Default
1100 config = vdr->configLoad("General", "Remote type");
1104 if (!STRCASECMP(config, "New"))
1106 logger->log("Command", Log::INFO, "Switching to New remote type");
1107 remote->setRemoteType(Remote::NEWREMOTE);
1111 logger->log("Command", Log::INFO, "Switching to Old remote type");
1112 remote->setRemoteType(Remote::OLDREMOTE);
1118 logger->log("Command", Log::INFO, "Config General/Remote type not found");
1119 remote->setRemoteType(Remote::OLDREMOTE);
1124 // Get TV aspect ratio
1126 config = vdr->configLoad("TV", "Aspect");
1129 if (!STRCASECMP(config, "16:9"))
1131 logger->log("Command", Log::INFO, "/// Switching to TV aspect 16:9");
1132 video->setTVsize(Video::ASPECT16X9);
1136 logger->log("Command", Log::INFO, "/// Switching to TV aspect 4:3");
1137 video->setTVsize(Video::ASPECT4X3);
1143 logger->log("Command", Log::INFO, "Config TV/Aspect type not found, going 4:3");
1144 video->setTVsize(Video::ASPECT4X3);
1147 config = vdr->configLoad("TV", "Widemode");
1150 if (!STRCASECMP(config, "Letterbox"))
1152 logger->log("Command", Log::INFO, "Setting letterbox mode");
1153 video->setMode(Video::LETTERBOX);
1157 logger->log("Command", Log::INFO, "Setting chop-sides mode");
1158 video->setMode(Video::NORMAL);
1165 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting letterbox mode");
1166 video->setMode(Video::LETTERBOX);
1168 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting chop-sides mode");
1169 video->setMode(Video::NORMAL);
1173 config = vdr->configLoad("Advanced", "TCP receive window");
1176 size_t newTCPsize = atoi(config);
1179 logger->log("Command", Log::INFO, "Setting TCP window size %i", newTCPsize);
1180 vdr->setReceiveWindow(newTCPsize);
1184 logger->log("Command", Log::INFO, "TCP window size not found, setting 2048");
1185 if (DEFAULT_TCP_WINDOWSIZE) vdr->setReceiveWindow(2048); // Default
1188 config = vdr->configLoad("Advanced", "Font Name");
1191 Osd::getInstance()->setFont(config);
1192 logger->log("Command", Log::INFO, "Setting Font to %s", config);
1198 // Set recording list type
1201 #ifdef ADVANCED_MENUES
1202 config = vdr->configLoad("Advanced", "Menu type");
1206 if (!STRCASECMP(config, "Advanced"))
1208 logger->log("Command", Log::INFO, "Switching to Advanced menu");
1214 logger->log("Command", Log::INFO, "Switching to Classic menu");
1221 logger->log("Command", Log::INFO, "Config General/menu type not found");
1226 config = vdr->configLoad("Advanced", "Disable WOL");
1229 if (!STRCASECMP(config, "Yes"))
1231 logger->log("Command", Log::INFO, "Config says disable WOL");
1232 Wol::getInstance()->setEnabled(false);
1236 logger->log("Command", Log::INFO, "Config says enable WOL");
1237 Wol::getInstance()->setEnabled(true);
1244 logger->log("Command", Log::INFO, "By default, enable WOL");
1245 Wol::getInstance()->setEnabled(true);
1247 /* device dependend config */
1248 audio->loadOptionsfromServer(vdr);
1249 video->loadOptionsfromServer(vdr);
1250 remote->loadOptionsfromServer(vdr);
1252 video->executePendingModeChanges();
1255 // Save power state = on
1257 vdr->configSave("General", "Last Power State", "On");
1259 // Make sure connection didn't die
1260 if (!vdr->isConnected())
1262 Command::getInstance()->connectionLost();
1266 boxstack->remove(vi);
1268 VWelcome* vw = new VWelcome();
1271 boxstack->update(vw);
1273 // Enter pre-keys here
1274 // handleCommand(Remote::OK);
1275 // handleCommand(Remote::THREE);
1276 // handleCommand(Remote::SIX);
1277 // handleCommand(Remote::OK);
1278 // handleCommand(Remote::UP);
1279 // handleCommand(Remote::PLAY);
1280 // handleCommand(Remote::DOWN);
1281 // handleCommand(Remote::DOWN);
1282 // handleCommand(Remote::DOWN);
1283 // handleCommand(Remote::OK);
1284 // handleCommand(Remote::RED);