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);
272 void Command::setSignal(int signalReceived)
274 if (signalReceived == SIGINT)
276 else if (signalReceived == SIGTERM)
278 else if (signalReceived == SIGUSR1)
280 else if (signalReceived == SIGUSR2)
282 else if (signalReceived == SIGURG)
286 void Command::processSignals()
288 if (signals & SIG_INT)
290 signals = signals & ~SIG_INT;
291 logger->log("Command", Log::NOTICE, "INT signal, shutting down...");
295 if (signals & SIG_TERM)
297 signals = signals & ~SIG_TERM;
298 logger->log("Command", Log::NOTICE, "TERM signal, shutting down...");
302 if (signals & SIG_USR1)
304 logger->log("Command", Log::NOTICE, "USR1 signal");
305 signals = signals & ~SIG_USR1;
308 if (signals & SIG_USR2)
310 logger->log("Command", Log::NOTICE, "USR2 signal");
311 signals = signals & ~SIG_USR2;
314 if (signals & SIG_URG)
316 logger->log("Command", Log::NOTICE, "URG signal"); // This is used to break from getButtonPress to process the message queue
317 signals = signals & ~SIG_URG;
321 void Command::postMessage(Message* m)
323 // This is locked here in case the main loop is not waiting for an event, but is processing one
324 // it could be killed but then not react to it because the signal wouldn't cause
325 // remote->getButtonPress to break
326 // locking the mutex ensures that the master thread is waiting on getButtonPress
329 //logger->log("Command", Log::DEBUG, "WANT LOCK");
331 pthread_mutex_lock(&masterLock);
333 WaitForSingleObject(masterLock, INFINITE );
335 //logger->log("Command", Log::DEBUG, "LOCK");
336 MessageQueue::postMessage(m);
340 kill(mainPid, SIGURG);
342 ((RemoteAndroid*)Remote::getInstance())->Signal();
344 pthread_mutex_unlock(&masterLock);
346 ((RemoteWin*)Remote::getInstance())->Signal();
347 ReleaseMutex(masterLock);
349 //logger->log("Command", Log::DEBUG, "UNLOCK");
352 void Command::postMessageNoLock(Message* m)
354 // As above but use this one if this message is being posted because of a button press
355 // the mutex is already locked, locking around postMessage is not needed as the
356 // queue is guaranteed to be run when the button has been processed
357 MessageQueue::postMessage(m);
360 bool Command::postMessageIfNotBusy(Message* m)
362 // Used for Windows mouse events
364 //logger->log("Command", Log::DEBUG, "TRY LOCK");
366 if (pthread_mutex_trylock(&masterLock) != EBUSY)
368 //logger->log("Command", Log::DEBUG, "LOCK");
369 MessageQueue::postMessage(m);
371 kill(mainPid, SIGURG);
373 ((RemoteAndroid*)Remote::getInstance())->Signal();
375 pthread_mutex_unlock(&masterLock);
376 //logger->log("Command", Log::DEBUG, "UNLOCK");
384 switch (WaitForSingleObject(masterLock, 0 ))
385 { //FIXME this is not "if not busy" check
386 case WAIT_OBJECT_0: //but with proper argument 0 this did not work
387 // case WAIT_ABANDONED:
388 MessageQueue::postMessage(m);
389 ((RemoteWin*)Remote::getInstance())->Signal();
390 ReleaseMutex(masterLock);
393 case WAIT_ABANDONED: return false;
394 case WAIT_TIMEOUT: return false;
400 void Command::postMessageFromOuterSpace(Message* m)
403 Yet another way of getting messages into Command. This one is for events that
404 are not standard button presses (or UDP generated buttons). It is also not for
405 events that are generated as a result of other events (events that can safely
406 call postMessageNoLock and be guaranteed that the message will be processed
407 because it is known that the queue is currently being processed).
408 This is for events that come from outer space and can occur when the master
409 mutex is locked or not, they need to be queued and executed but it doesn't
411 Actually so far it is for events caused by the video stream - aspect ratio
412 changes. These can occur when the master mutex is locked and so postMessage
413 doesn't work. postMessageNoLock doesn't work because if the mutex *isn't*
414 locked at the time then the message could be sat around a while before
416 The whole message system was at first supposed to prevent the problem of
417 calling a function on an object that had just been deleted, by ordering
418 messages such that all calls are done before object deletion. However,
419 because of the new centralised messaging system and the fact that BoxStack
420 locates the destination object before calling it, the messaging system now
421 allows the kind of sloppy calls it was supposed to stop. Weird huh. This
422 is mentioned here because the video stream might generate an event just as
423 the user hits stop. The mutex is locked, and by the time the message
424 is examined the vvideorec/live has been deleted. This doesn't matter because
425 boxstack will drop the message if it can't find the matching object to
427 Finally, all this is fine and dandy, except that I'm not 100% sure that
428 this sloppy postMessage and hope a queued signal will force it to be processed
429 thingy will actually work. Hmmm.
430 Lastly <g>, I will consider making the naming system a little more sane
434 logger->log("Command", Log::DEBUG, "PMFOS called");
435 MessageQueue::postMessage(m);
439 kill(mainPid, SIGURG);
441 ((RemoteAndroid*)Remote::getInstance())->Signal();
444 ((RemoteWin*)Remote::getInstance())->Signal();
448 void Command::processMessage(Message* m)
450 // FIXME - a slight modification - how if messagereceivers were to register
451 // themselves as receivers to avoid the calling-a-deleted-object problem
452 // then only deliver/register/unregister would have to be protected
454 logger->log("Command", Log::DEBUG, "processing message %i", m->message);
462 case Message::STOP_PLAYBACK:
464 handleCommand(Remote::STOP); // an odd way of doing it, but so simple
467 // Also connection_lost comes from player - anywhere else?
471 case Message::VDR_CONNECTED:
473 doJustConnected((VConnect*)m->from);
476 case Message::SCREENSHOT:
478 #ifdef VOMP_PLATTFORM_MVP
479 Osd::getInstance()->screenShot("/out.jpg");
481 logger->log("Osd", Log::NOTICE, "Screenshot Message arrived");
482 Osd::getInstance()->screenShot("out.jpg");
486 case Message::CONNECTION_LOST:
491 case Message::UDP_BUTTON:
493 handleCommand(m->parameter.num);
496 case Message::CHANGE_LANGUAGE:
498 boxstack->removeAll();
499 boxstack->update(wallpaper);
501 if (!VDR::getInstance()->isConnected()) { connectionLost(); break; }
502 VWelcome* vw = new VWelcome();
505 boxstack->update(vw);
508 case Message::LAST_VIEW_CLOSE:
510 // Shouldn't be done like this. Some generic message pass back from vinfo perhaps
517 // VWelcome* vw = new VWelcome();
519 // boxstack->add(vw);
520 // boxstack->update(vw);
524 case Message::NEW_PICTURE:
526 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE");
527 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
529 osdv->informPicture(m->tag,m->parameter.handle);
533 case Message::NEW_PICTURE_STATIC:
535 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE %x %x",m->tag,m->parameter.num);
536 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
538 osdv->informPicture(((unsigned long long)m->tag)<<32LL,m->parameter.handle);
548 Instead of sending through the boxstack, implement a more generic MessageReceiver interface
549 and have potential receivers register with something
550 When a message needs to be delivered, check if the receiver is still registered, if so, deliver the message
551 This could all be done using the existing big command mutex to keep it simple
554 logger->log("Command", Log::DEBUG, "Sending message to boxstack");
555 boxstack->processMessage(m);
559 void Command::handleCommand(int button)
561 if (isStandby && (button != Remote::POWER)
562 && (button != Remote::POWERON) && (button != Remote::POWEROFF)) return;
563 if (!connLost && boxstack->handleCommand(button)) return; // don't send to boxstack if connLost
565 // command was not handled
569 case Remote::DF_LEFT:
570 case Remote::DF_RIGHT:
571 case Remote::VOLUMEUP:
572 case Remote::VOLUMEDOWN:
574 if (remote->handlesVolume()) {
575 if (button==Remote::DF_LEFT || button==Remote::VOLUMEDOWN)
576 remote->volumeDown();
577 else remote->volumeUp();
579 VVolume* v = new VVolume();
581 v->handleCommand(button); // this will draw+show
587 if (remote->handlesVolume()) {
588 remote->volumeMute();
590 VMute* v = new VMute();
602 case Remote::POWERON:
607 case Remote::POWEROFF:
615 if (!connLost) return; // if connLost, handle Remote::OK
621 VSleeptimer* sleep = new VSleeptimer();
622 boxstack->add(sleep);
623 sleep->handleCommand(button); // this will draw+show
632 Message* m = new Message(); // break into master mutex
633 m->message = Message::SCREENSHOT;
639 void Command::doStandby()
652 void Command::doPowerOn()
656 Video::getInstance()->signalOn();
657 Led::getInstance()->on();
658 Remote::getInstance()->changePowerState(true);
662 VConnect* vconnect = new VConnect(server);
663 boxstack->add(vconnect);
668 void Command::doPowerOff()
672 VDR::getInstance()->shutdownVDR();
673 boxstack->removeAll();
674 Video::getInstance()->signalOff();
675 boxstack->update(wallpaper);
677 VDR::getInstance()->configSave("General", "Last Power State", "Off");
678 logger->unsetExternLogger();
679 VDR::getInstance()->disconnect();
680 Led::getInstance()->off();
681 Remote::getInstance()->changePowerState(false);
683 Sleeptimer::getInstance()->shutdown();
685 stop(); //different behavoiur on windows, we exit
690 void Command::doFromTheTop(bool which)
692 if (isStandby) return;
697 logger->log("Command", Log::NOTICE, "Connection lost dialog already present");
701 logger->log("Command", Log::NOTICE, "Doing connection lost dialog");
702 connLost = new VInfo();
703 connLost->setSize(360, 200);
704 connLost->createBuffer();
705 if (Video::getInstance()->getFormat() == Video::PAL)
706 connLost->setPosition(190, 170);
708 connLost->setPosition(180, 120);
709 connLost->setOneLiner(tr("Connection lost"));
710 connLost->setDropThrough();
711 connLost->setBorderOn(1);
712 connLost->setTitleBarColour(DrawStyle::DANGER);
713 connLost->okButton();
715 boxstack->add(connLost);
716 boxstack->update(connLost);
717 remote->clearBuffer();
721 logger->unsetExternLogger();
722 VDR::getInstance()->disconnect();
723 boxstack->removeAll();
724 boxstack->update(wallpaper);
728 remote->clearBuffer();
730 // at this point, everything should be reset to first-go
732 VConnect* vconnect = new VConnect(server);
733 boxstack->add(vconnect);
738 void Command::doReboot()
741 logger->unsetExternLogger();
742 VDR::getInstance()->disconnect();
744 logger->log("Command", Log::NOTICE, "Reboot");
746 #ifndef VOMP_HAS_EXIT
747 // some plattforms, want a proper deinitialisation of their hardware before reboot
748 Osd::getInstance()->shutdown();
749 Audio::getInstance()->shutdown();
750 Video::getInstance()->shutdown();
751 Remote::getInstance()->shutdown();
753 reboot(LINUX_REBOOT_CMD_RESTART);
754 // if reboot is not allowed -> stop
766 #endif //Would we support this on windows?
769 void Command::connectionLost()
771 logger->unsetExternLogger();
772 Message* m = new Message(); // break into master mutex
773 m->message = Message::CONNECTION_LOST;
775 postMessageFromOuterSpace(m);
778 void Command::buildCrashedBox()
780 VInfo* crash = new VInfo();
781 crash->setSize(360, 250);
782 crash->createBuffer();
783 if (Video::getInstance()->getFormat() == Video::PAL)
784 crash->setPosition(190, 146);
786 crash->setPosition(180, 96);
787 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.");
788 crash->setBorderOn(1);
789 crash->setTitleBarColour(DrawStyle::DANGER);
791 crash->setExitable();
793 boxstack->add(crash);
794 boxstack->update(crash);
797 int Command::getLangPref(bool subtitle,const char* langcode)
799 vector<struct ASLPref>::iterator itty=langcodes.begin();
800 char templangcode[4];
801 templangcode[0]=langcode[0];
802 templangcode[1]=langcode[1];
803 templangcode[2]=langcode[2];
804 templangcode[3]='\0';
806 while (itty != langcodes.end()) {
807 size_t pos=(*itty).langcode.find(templangcode);
808 if (pos != string::npos) {
809 vector<struct ASLPref>::iterator itty2=langcodes.begin();
810 for (int i=0; i<langcodes.size();i++) {
813 pref=langcodes[i].subtitlepref;
815 pref=langcodes[i].audiopref;
820 if (langcodes[i].subtitlepref==langpos) {
824 if (langcodes[i].audiopref==langpos) {
834 return langcodes.size(); //neutral
837 void Command::doJustConnected(VConnect* vconnect)
840 if (!VDR::getInstance()->isConnected()) { connectionLost(); return; }
841 logger->log("Command", Log::INFO, "Entering doJustConnected");
843 Video* video = Video::getInstance();
844 Audio* audio = Audio::getInstance();
845 boxstack->remove(vconnect);
847 VInfo* vi = new VInfo();
848 vi->setSize(400, 200);
850 if (video->getFormat() == Video::PAL)
851 vi->setPosition(170, 200);
853 vi->setPosition(160, 150);
854 vi->setOneLiner(tr("Connected, loading config"));
857 boxstack->update(vi);
859 VDR* vdr = VDR::getInstance();
862 // See if we're supposed to do network logging
863 config = vdr->configLoad("Advanced", "Network logging");
864 if (config && !STRCASECMP(config, "On"))
866 logger->log("Command", Log::INFO, "Turning on network logging");
867 logger->setExternLogger(vdr);
871 logger->unsetExternLogger();
872 logger->log("Command", Log::INFO, "Turned off network logging");
874 if (config) delete[] config;
876 config = vdr->configLoad("Advanced", "Skin Name");
878 const char **skinnames=SkinFactory::getSkinNames();
879 for (int i=0;i<SkinFactory::getNumberofSkins();i++) {
880 if (!STRCASECMP(config, skinnames[i])) {
881 SkinFactory::InitSkin(i);
886 if (wallpaper && wallpaper_pict) {
887 if (DrawStyle::WALLPAPER.alpha) {
888 wallpaper_pict->setVisible(true);
890 wallpaper_pict->setVisible(false);
893 boxstack->update(wallpaper);
897 SkinFactory::InitSkin(0);
900 // See if config says to override video format (PAL/NTSC)
901 config = vdr->configLoad("General", "Override Video Format");
904 logger->log("Command", Log::DEBUG, "Override Video Format is present");
906 if ( (!strcmp(config, "PAL") && (video->getFormat() != Video::PAL))
907 || (!strcmp(config, "NTSC") && (video->getFormat() != Video::NTSC))
908 || (!strcmp(config, "PAL_M") && (video->getFormat() != Video::PAL_M))
909 || (!strcmp(config, "NTSC_J") && (video->getFormat() != Video::NTSC_J))
912 // Oh sheesh, need to switch format. Bye bye TV...
914 // Take everything down
915 boxstack->removeAll();
916 boxstack->remove(wallpaper);
917 Osd* osd = Osd::getInstance();
923 remote->shutdown(); // need on raspberry shut not do any harm, hopefully
924 remote->init(RemoteStartDev);
926 // Get video and osd back up with the new mode
927 if (!strcmp(config, "PAL"))
929 logger->log("Command", Log::DEBUG, "Switching to PAL");
930 video->init(Video::PAL);
932 else if (!strcmp(config, "NTSC"))
934 logger->log("Command", Log::DEBUG, "Switching to NTSC");
935 video->init(Video::NTSC);
936 } else if (!strcmp(config, "PAL_M"))
938 logger->log("Command", Log::DEBUG, "Switching to PAL_M");
939 video->init(Video::PAL_M);
940 } else if (!strcmp(config, "NTSC_J"))
942 logger->log("Command", Log::DEBUG, "Switching to NTSC_J");
943 video->init(Video::NTSC_J);
948 //we do not init twice
949 osd->init((char*)("/dev/stbgfx"));
952 // Put the wallpaper back
957 vi->setSize(400, 200);
959 if (video->getFormat() == Video::PAL)
960 vi->setPosition(170, 200);
962 vi->setPosition(160, 150);
964 vi->setOneLiner(tr("Connected, loading config"));
967 boxstack->update(vi);
971 logger->log("Command", Log::DEBUG, "Already in requested mode, or request was not 'PAL' or 'NTSC'");
976 logger->log("Command", Log::DEBUG, "Phew, no dangerous on-the-fly mode switching to do!");
979 // Power off if first boot and config says so
984 logger->log("Command", Log::DEBUG, "Load power after boot");
986 config = vdr->configLoad("General", "Power After Boot");
990 if (!STRCASECMP(config, "On"))
992 logger->log("Command", Log::INFO, "Config says Power After Boot = On");
994 else if (!STRCASECMP(config, "Off"))
996 logger->log("Command", Log::INFO, "Config says Power After Boot = Off");
1001 else if (!STRCASECMP(config, "Last state"))
1003 char* lastPowerState = vdr->configLoad("General", "Last Power State");
1006 if (!STRCASECMP(lastPowerState, "On"))
1008 logger->log("Command", Log::INFO, "Config says Last Power State = On");
1010 else if (!STRCASECMP(lastPowerState, "Off"))
1012 logger->log("Command", Log::INFO, "Config says Last Power State = Off");
1015 return; // quit here
1019 logger->log("Command", Log::INFO, "Config General/Last Power State not understood");
1024 logger->log("Command", Log::INFO, "Config General/Last Power State not found");
1029 logger->log("Command", Log::INFO, "Config/Power After Boot not understood");
1035 logger->log("Command", Log::INFO, "Config General/Power After Boot not found");
1040 // Go S-Video if config says so
1042 config = vdr->configLoad("TV", "Connection");
1046 if (!STRCASECMP(config, "S-Video"))
1048 logger->log("Command", Log::INFO, "Switching to S-Video as Connection=%s", config);
1049 video->setConnection(Video::SVIDEO);
1050 } else if (!STRCASECMP(config, "HDMI"))
1052 logger->log("Command", Log::INFO, "Switching to HDMI as Connection=%s", config);
1053 video->setConnection(Video::HDMI);
1054 } else if (!STRCASECMP(config, "HDMI3D"))
1056 logger->log("Command", Log::INFO, "Switching to HDMI3D as Connection=%s", config);
1057 video->setConnection(Video::HDMI3D);
1061 logger->log("Command", Log::INFO, "Switching to RGB/Composite as Connection=%s", config);
1062 video->setConnection(Video::COMPOSITERGB);
1068 logger->log("Command", Log::INFO, "Config TV/S-Video not found");
1071 // Set to shutdown VDR if config says
1073 config = vdr->configLoad("General", "VDR shutdown");
1076 if (!STRCASECMP(config, "On"))
1078 logger->log("Command", Log::INFO, "Shutdown VDR when shutting down vomp");
1079 vdr->setVDRShutdown(true);
1081 else if (!STRCASECMP(config, "Off"))
1083 logger->log("Command", Log::INFO, "Shutdown only vomp");
1084 vdr->setVDRShutdown(false);
1089 logger->log("Command", Log::INFO, "Default shutdown only vomp");
1090 vdr->setVDRShutdown(false); // Default
1095 config = vdr->configLoad("General", "Remote type");
1099 if (!STRCASECMP(config, "New"))
1101 logger->log("Command", Log::INFO, "Switching to New remote type");
1102 remote->setRemoteType(Remote::NEWREMOTE);
1106 logger->log("Command", Log::INFO, "Switching to Old remote type");
1107 remote->setRemoteType(Remote::OLDREMOTE);
1113 logger->log("Command", Log::INFO, "Config General/Remote type not found");
1114 remote->setRemoteType(Remote::OLDREMOTE);
1119 // Get TV aspect ratio
1121 config = vdr->configLoad("TV", "Aspect");
1124 if (!STRCASECMP(config, "16:9"))
1126 logger->log("Command", Log::INFO, "/// Switching to TV aspect 16:9");
1127 video->setTVsize(Video::ASPECT16X9);
1131 logger->log("Command", Log::INFO, "/// Switching to TV aspect 4:3");
1132 video->setTVsize(Video::ASPECT4X3);
1138 logger->log("Command", Log::INFO, "Config TV/Aspect type not found, going 4:3");
1139 video->setTVsize(Video::ASPECT4X3);
1142 config = vdr->configLoad("TV", "Widemode");
1145 if (!STRCASECMP(config, "Letterbox"))
1147 logger->log("Command", Log::INFO, "Setting letterbox mode");
1148 video->setMode(Video::LETTERBOX);
1152 logger->log("Command", Log::INFO, "Setting chop-sides mode");
1153 video->setMode(Video::NORMAL);
1160 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting letterbox mode");
1161 video->setMode(Video::LETTERBOX);
1163 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting chop-sides mode");
1164 video->setMode(Video::NORMAL);
1168 config = vdr->configLoad("Advanced", "TCP receive window");
1171 size_t newTCPsize = atoi(config);
1174 logger->log("Command", Log::INFO, "Setting TCP window size %i", newTCPsize);
1175 vdr->setReceiveWindow(newTCPsize);
1179 logger->log("Command", Log::INFO, "TCP window size not found, setting 2048");
1180 if (DEFAULT_TCP_WINDOWSIZE) vdr->setReceiveWindow(2048); // Default
1183 config = vdr->configLoad("Advanced", "Font Name");
1186 Osd::getInstance()->setFont(config);
1187 logger->log("Command", Log::INFO, "Setting Font to %s", config);
1193 // Set recording list type
1196 #ifdef ADVANCED_MENUES
1197 config = vdr->configLoad("Advanced", "Menu type");
1201 if (!STRCASECMP(config, "Advanced"))
1203 logger->log("Command", Log::INFO, "Switching to Advanced menu");
1209 logger->log("Command", Log::INFO, "Switching to Classic menu");
1216 logger->log("Command", Log::INFO, "Config General/menu type not found");
1221 config = vdr->configLoad("Advanced", "Disable WOL");
1224 if (!STRCASECMP(config, "Yes"))
1226 logger->log("Command", Log::INFO, "Config says disable WOL");
1227 Wol::getInstance()->setEnabled(false);
1231 logger->log("Command", Log::INFO, "Config says enable WOL");
1232 Wol::getInstance()->setEnabled(true);
1239 logger->log("Command", Log::INFO, "By default, enable WOL");
1240 Wol::getInstance()->setEnabled(true);
1242 /* device dependend config */
1243 audio->loadOptionsfromServer(vdr);
1244 video->loadOptionsfromServer(vdr);
1245 remote->loadOptionsfromServer(vdr);
1247 video->executePendingModeChanges();
1250 // Save power state = on
1252 vdr->configSave("General", "Last Power State", "On");
1254 // Make sure connection didn't die
1255 if (!vdr->isConnected())
1257 Command::getInstance()->connectionLost();
1261 boxstack->remove(vi);
1263 VWelcome* vw = new VWelcome();
1266 boxstack->update(vw);
1268 // Enter pre-keys here
1269 // handleCommand(Remote::OK);
1270 // handleCommand(Remote::THREE);
1271 // handleCommand(Remote::SIX);
1272 // handleCommand(Remote::OK);
1273 // handleCommand(Remote::UP);
1274 // handleCommand(Remote::PLAY);
1275 // handleCommand(Remote::DOWN);
1276 // handleCommand(Remote::DOWN);
1277 // handleCommand(Remote::DOWN);
1278 // handleCommand(Remote::OK);
1279 // handleCommand(Remote::RED);