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.
28 #include "remotewin.h"
32 #include "remoteandroid.h"
40 #include "vserverselect.h"
46 #include "timerreceiver.h"
56 #include "vsleeptimer.h"
58 #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 OsdVector* osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
188 osdv->updateBackgroundColor(DrawStyle::WALLPAPER);
197 if (!initted) return;
204 Video::getInstance()->signalOn();
205 Led::getInstance()->on();
209 // End of startup. Lock the mutex and put the first view up
210 // logger->log("Command", Log::DEBUG, "WANT LOCK");
212 pthread_mutex_lock(&masterLock);
214 WaitForSingleObject(masterLock, INFINITE );
216 //logger->log("Command", Log::DEBUG, "LOCKED");
224 VConnect* vconnect = new VConnect(server);
225 boxstack->add(vconnect);
229 // Start method 2 of getting commands in...
236 //logger->log("Command", Log::DEBUG, "UNLOCK");
238 pthread_mutex_unlock(&masterLock);
240 ReleaseMutex(masterLock);
242 button = remote->getButtonPress(2); // Don't block (0) in case a signal arrives after checking signals but before this line
243 // something happened, lock and process
244 if (signals) processSignals(); // If a signal arrived process now.
246 // logger->log("Command", Log::DEBUG, "WANT LOCK");
248 pthread_mutex_lock(&masterLock);
250 WaitForSingleObject(masterLock, INFINITE );
252 // logger->log("Command", Log::DEBUG, "LOCK");
254 if ((button == Remote::NA_NONE) /*|| (button == Remote::NA_UNKNOWN)*/) continue;
256 if (button != Remote::NA_SIGNAL) handleCommand(button);
257 processMessageQueue();
261 //logger->log("Command", Log::DEBUG, "UNLOCK");
263 pthread_mutex_unlock(&masterLock);
265 ReleaseMutex(masterLock);
270 boxstack->removeAllExceptWallpaper();
271 boxstack->remove(wallpaper);
272 delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL;
276 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)
292 void Command::processSignals()
295 if (signals & SIG_INT)
297 signals = signals & ~SIG_INT;
298 logger->log("Command", Log::NOTICE, "INT signal, shutting down...");
302 if (signals & SIG_TERM)
304 signals = signals & ~SIG_TERM;
305 logger->log("Command", Log::NOTICE, "TERM signal, shutting down...");
309 if (signals & SIG_USR1)
311 logger->log("Command", Log::NOTICE, "USR1 signal");
312 signals = signals & ~SIG_USR1;
315 if (signals & SIG_USR2)
317 logger->log("Command", Log::NOTICE, "USR2 signal");
318 signals = signals & ~SIG_USR2;
321 if (signals & SIG_URG)
323 logger->log("Command", Log::NOTICE, "URG signal"); // This is used to break from getButtonPress to process the message queue
324 signals = signals & ~SIG_URG;
329 void Command::postMessage(Message* m)
331 // This is locked here in case the main loop is not waiting for an event, but is processing one
332 // it could be killed but then not react to it because the signal wouldn't cause
333 // remote->getButtonPress to break
334 // locking the mutex ensures that the master thread is waiting on getButtonPress
337 //logger->log("Command", Log::DEBUG, "WANT LOCK");
339 pthread_mutex_lock(&masterLock);
341 WaitForSingleObject(masterLock, INFINITE );
343 //logger->log("Command", Log::DEBUG, "LOCK");
344 MessageQueue::postMessage(m);
348 kill(mainPid, SIGURG);
350 ((RemoteAndroid*)Remote::getInstance())->Signal();
352 pthread_mutex_unlock(&masterLock);
354 ((RemoteWin*)Remote::getInstance())->Signal();
355 ReleaseMutex(masterLock);
357 //logger->log("Command", Log::DEBUG, "UNLOCK");
360 void Command::postMessageNoLock(Message* m)
362 // As above but use this one if this message is being posted because of a button press
363 // the mutex is already locked, locking around postMessage is not needed as the
364 // queue is guaranteed to be run when the button has been processed
365 MessageQueue::postMessage(m);
368 bool Command::postMessageIfNotBusy(Message* m)
370 // Used for Windows mouse events
372 //logger->log("Command", Log::DEBUG, "TRY LOCK");
374 if (pthread_mutex_trylock(&masterLock) != EBUSY)
376 //logger->log("Command", Log::DEBUG, "LOCK");
377 MessageQueue::postMessage(m);
379 kill(mainPid, SIGURG);
381 ((RemoteAndroid*)Remote::getInstance())->Signal();
383 pthread_mutex_unlock(&masterLock);
384 //logger->log("Command", Log::DEBUG, "UNLOCK");
392 switch (WaitForSingleObject(masterLock, 0 ))
393 { //FIXME this is not "if not busy" check
394 case WAIT_OBJECT_0: //but with proper argument 0 this did not work
395 // case WAIT_ABANDONED:
396 MessageQueue::postMessage(m);
397 ((RemoteWin*)Remote::getInstance())->Signal();
398 ReleaseMutex(masterLock);
401 case WAIT_ABANDONED: return false;
402 case WAIT_TIMEOUT: return false;
408 void Command::postMessageFromOuterSpace(Message* m)
411 Yet another way of getting messages into Command. This one is for events that
412 are not standard button presses (or UDP generated buttons). It is also not for
413 events that are generated as a result of other events (events that can safely
414 call postMessageNoLock and be guaranteed that the message will be processed
415 because it is known that the queue is currently being processed).
416 This is for events that come from outer space and can occur when the master
417 mutex is locked or not, they need to be queued and executed but it doesn't
419 Actually so far it is for events caused by the video stream - aspect ratio
420 changes. These can occur when the master mutex is locked and so postMessage
421 doesn't work. postMessageNoLock doesn't work because if the mutex *isn't*
422 locked at the time then the message could be sat around a while before
424 The whole message system was at first supposed to prevent the problem of
425 calling a function on an object that had just been deleted, by ordering
426 messages such that all calls are done before object deletion. However,
427 because of the new centralised messaging system and the fact that BoxStack
428 locates the destination object before calling it, the messaging system now
429 allows the kind of sloppy calls it was supposed to stop. Weird huh. This
430 is mentioned here because the video stream might generate an event just as
431 the user hits stop. The mutex is locked, and by the time the message
432 is examined the vvideorec/live has been deleted. This doesn't matter because
433 boxstack will drop the message if it can't find the matching object to
435 Finally, all this is fine and dandy, except that I'm not 100% sure that
436 this sloppy postMessage and hope a queued signal will force it to be processed
437 thingy will actually work. Hmmm.
438 Lastly <g>, I will consider making the naming system a little more sane
442 logger->log("Command", Log::DEBUG, "PMFOS called");
443 MessageQueue::postMessage(m);
447 kill(mainPid, SIGURG);
449 ((RemoteAndroid*)Remote::getInstance())->Signal();
452 ((RemoteWin*)Remote::getInstance())->Signal();
456 void Command::processMessage(Message* m)
458 // FIXME - a slight modification - how if messagereceivers were to register
459 // themselves as receivers to avoid the calling-a-deleted-object problem
460 // then only deliver/register/unregister would have to be protected
462 logger->log("Command", Log::DEBUG, "processing message %i", m->message);
470 case Message::STOP_PLAYBACK:
472 handleCommand(Remote::STOP); // an odd way of doing it, but so simple
475 // Also connection_lost comes from player - anywhere else?
479 case Message::VDR_CONNECTED:
481 doJustConnected((VConnect*)m->from);
484 case Message::SCREENSHOT:
486 logger->log("Osd", Log::NOTICE, "Screenshot Message arrived");
487 Osd::getInstance()->screenShot("out.jpg");
490 case Message::CONNECTION_LOST:
495 case Message::UDP_BUTTON:
497 handleCommand(m->parameter.num);
500 case Message::CHANGE_LANGUAGE:
502 boxstack->removeAllExceptWallpaper();
503 boxstack->update(wallpaper);
505 if (!VDR::getInstance()->isConnected()) { connectionLost(); break; }
506 VWelcome* vw = new VWelcome();
509 boxstack->update(vw);
512 case Message::LAST_VIEW_CLOSE:
514 // Shouldn't be done like this. Some generic message pass back from vinfo perhaps
521 // VWelcome* vw = new VWelcome();
523 // boxstack->add(vw);
524 // boxstack->update(vw);
528 case Message::NEW_PICTURE:
530 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE");
531 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
533 osdv->informPicture(m->tag,m->parameter.handle);
537 case Message::NEW_PICTURE_STATIC:
539 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE %x %x",m->tag,m->parameter.num);
540 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
542 osdv->informPicture(((unsigned long long)m->tag)<<32LL,m->parameter.handle);
552 Instead of sending through the boxstack, implement a more generic MessageReceiver interface
553 and have potential receivers register with something
554 When a message needs to be delivered, check if the receiver is still registered, if so, deliver the message
555 This could all be done using the existing big command mutex to keep it simple
558 logger->log("Command", Log::DEBUG, "Sending message to boxstack");
559 boxstack->processMessage(m);
563 void Command::handleCommand(int button)
565 if (isStandby && (button != Remote::POWER)
566 && (button != Remote::POWERON) && (button != Remote::POWEROFF)) return;
567 if (!connLost && boxstack->handleCommand(button)) return; // don't send to boxstack if connLost
569 // command was not handled
573 case Remote::DF_LEFT:
574 case Remote::DF_RIGHT:
575 case Remote::VOLUMEUP:
576 case Remote::VOLUMEDOWN:
578 if (remote->handlesVolume()) {
579 if (button==Remote::DF_LEFT || button==Remote::VOLUMEDOWN)
580 remote->volumeDown();
581 else remote->volumeUp();
583 VVolume* v = new VVolume();
585 v->handleCommand(button); // this will draw+show
591 if (remote->handlesVolume()) {
592 remote->volumeMute();
594 VMute* v = new VMute();
606 case Remote::POWERON:
611 case Remote::POWEROFF:
619 if (!connLost) return; // if connLost, handle Remote::OK
625 VSleeptimer* sleep = new VSleeptimer();
626 boxstack->add(sleep);
627 sleep->handleCommand(button); // this will draw+show
636 Message* m = new Message(); // break into master mutex
637 m->message = Message::SCREENSHOT;
643 void Command::doStandby()
656 void Command::doPowerOn()
660 Video::getInstance()->signalOn();
661 Led::getInstance()->on();
662 Remote::getInstance()->changePowerState(true);
666 VConnect* vconnect = new VConnect(server);
667 boxstack->add(vconnect);
672 void Command::doPowerOff()
676 VDR::getInstance()->shutdownVDR();
677 boxstack->removeAllExceptWallpaper();
678 Video::getInstance()->signalOff();
679 boxstack->update(wallpaper);
681 VDR::getInstance()->configSave("General", "Last Power State", "Off");
682 logger->unsetExternLogger();
683 VDR::getInstance()->disconnect();
684 Led::getInstance()->off();
685 Remote::getInstance()->changePowerState(false);
687 Sleeptimer::getInstance()->shutdown();
689 stop(); //different behavoiur on windows, we exit
694 void Command::doFromTheTop(bool which)
696 if (isStandby) return;
701 logger->log("Command", Log::NOTICE, "Connection lost dialog already present");
705 logger->log("Command", Log::NOTICE, "Doing connection lost dialog");
706 connLost = new VInfo();
707 connLost->setSize(360, 200);
708 connLost->createBuffer();
709 if (Video::getInstance()->getFormat() == Video::PAL)
710 connLost->setPosition(190, 170);
712 connLost->setPosition(180, 120);
713 connLost->setOneLiner(tr("Connection lost"));
714 connLost->setDropThrough();
715 connLost->setBorderOn(1);
716 connLost->setTitleBarColour(DrawStyle::DANGER);
717 connLost->okButton();
719 boxstack->add(connLost);
720 boxstack->update(connLost);
721 remote->clearBuffer();
725 logger->unsetExternLogger();
726 VDR::getInstance()->disconnect();
727 boxstack->removeAllExceptWallpaper();
728 boxstack->update(wallpaper);
732 remote->clearBuffer();
734 // at this point, everything should be reset to first-go
736 VConnect* vconnect = new VConnect(server);
737 boxstack->add(vconnect);
742 void Command::doReboot()
745 logger->unsetExternLogger();
746 VDR::getInstance()->disconnect();
748 logger->log("Command", Log::NOTICE, "Reboot");
750 #ifndef VOMP_HAS_EXIT
751 // some plattforms, want a proper deinitialisation of their hardware before reboot
752 Osd::getInstance()->shutdown();
753 Audio::getInstance()->shutdown();
754 Video::getInstance()->shutdown();
755 Remote::getInstance()->shutdown();
757 reboot(LINUX_REBOOT_CMD_RESTART);
758 // if reboot is not allowed -> stop
770 #endif //Would we support this on windows?
773 void Command::connectionLost()
775 logger->unsetExternLogger();
776 Message* m = new Message(); // break into master mutex
777 m->message = Message::CONNECTION_LOST;
779 postMessageFromOuterSpace(m);
782 void Command::buildCrashedBox()
784 VInfo* crash = new VInfo();
785 crash->setSize(360, 250);
786 crash->createBuffer();
787 if (Video::getInstance()->getFormat() == Video::PAL)
788 crash->setPosition(190, 146);
790 crash->setPosition(180, 96);
791 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.");
792 crash->setBorderOn(1);
793 crash->setTitleBarColour(DrawStyle::DANGER);
795 crash->setExitable();
797 boxstack->add(crash);
798 boxstack->update(crash);
801 int Command::getLangPref(bool subtitle,const char* langcode)
803 vector<struct ASLPref>::iterator itty=langcodes.begin();
804 char templangcode[4];
805 templangcode[0]=langcode[0];
806 templangcode[1]=langcode[1];
807 templangcode[2]=langcode[2];
808 templangcode[3]='\0';
810 while (itty != langcodes.end()) {
811 size_t pos=(*itty).langcode.find(templangcode);
812 if (pos != string::npos) {
813 //vector<struct ASLPref>::iterator itty2=langcodes.begin();
814 for (unsigned int i=0; i<langcodes.size();i++) {
817 pref=langcodes[i].subtitlepref;
819 pref=langcodes[i].audiopref;
824 if (langcodes[i].subtitlepref==langpos) {
828 if (langcodes[i].audiopref==langpos) {
838 return langcodes.size(); //neutral
841 void Command::doJustConnected(VConnect* vconnect)
844 if (!VDR::getInstance()->isConnected()) { connectionLost(); return; }
845 logger->log("Command", Log::INFO, "Entering doJustConnected");
847 Video* video = Video::getInstance();
848 Audio* audio = Audio::getInstance();
849 boxstack->remove(vconnect);
851 VInfo* vi = new VInfo();
852 vi->setSize(400, 200);
854 if (video->getFormat() == Video::PAL)
855 vi->setPosition(170, 200);
857 vi->setPosition(160, 150);
858 vi->setOneLiner(tr("Connected, loading config"));
861 boxstack->update(vi);
863 VDR* vdr = VDR::getInstance();
866 // See if we're supposed to do network logging
867 config = vdr->configLoad("Advanced", "Network logging");
868 if (config && !STRCASECMP(config, "On"))
870 logger->log("Command", Log::INFO, "Turning on network logging");
871 logger->setExternLogger(vdr);
875 logger->unsetExternLogger();
876 logger->log("Command", Log::INFO, "Turned off network logging");
878 if (config) delete[] config;
880 config = vdr->configLoad("Advanced", "Skin Name");
882 const char **skinnames=SkinFactory::getSkinNames();
883 for (int i=0;i<SkinFactory::getNumberofSkins();i++) {
884 if (!STRCASECMP(config, skinnames[i])) {
885 SkinFactory::InitSkin(i);
890 if (wallpaper && wallpaper_pict) {
891 if (DrawStyle::WALLPAPER.alpha) {
892 wallpaper_pict->setVisible(true);
894 wallpaper_pict->setVisible(false);
897 boxstack->update(wallpaper);
901 SkinFactory::InitSkin(0);
904 // See if config says to override video format (PAL/NTSC)
905 config = vdr->configLoad("General", "Override Video Format");
908 logger->log("Command", Log::DEBUG, "Override Video Format is present");
910 if ( (!strcmp(config, "PAL") && (video->getFormat() != Video::PAL))
911 || (!strcmp(config, "NTSC") && (video->getFormat() != Video::NTSC))
912 || (!strcmp(config, "PAL_M") && (video->getFormat() != Video::PAL_M))
913 || (!strcmp(config, "NTSC_J") && (video->getFormat() != Video::NTSC_J))
916 // Oh sheesh, need to switch format. Bye bye TV...
918 // Take everything down
919 boxstack->removeAllExceptWallpaper();
920 boxstack->remove(wallpaper);
921 delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL;
923 Osd* osd = Osd::getInstance();
929 remote->shutdown(); // need on raspberry shut not do any harm, hopefully
930 remote->init(RemoteStartDev);
932 // Get video and osd back up with the new mode
933 if (!strcmp(config, "PAL"))
935 logger->log("Command", Log::DEBUG, "Switching to PAL");
936 video->init(Video::PAL);
938 else if (!strcmp(config, "NTSC"))
940 logger->log("Command", Log::DEBUG, "Switching to NTSC");
941 video->init(Video::NTSC);
942 } else if (!strcmp(config, "PAL_M"))
944 logger->log("Command", Log::DEBUG, "Switching to PAL_M");
945 video->init(Video::PAL_M);
946 } else if (!strcmp(config, "NTSC_J"))
948 logger->log("Command", Log::DEBUG, "Switching to NTSC_J");
949 video->init(Video::NTSC_J);
954 //we do not init twice
955 osd->init((char*)("/dev/stbgfx"));
958 // Put the wallpaper back
963 vi->setSize(400, 200);
965 if (video->getFormat() == Video::PAL)
966 vi->setPosition(170, 200);
968 vi->setPosition(160, 150);
970 vi->setOneLiner(tr("Connected, loading config"));
973 boxstack->update(vi);
977 logger->log("Command", Log::DEBUG, "Already in requested mode, or request was not 'PAL' or 'NTSC'");
982 logger->log("Command", Log::DEBUG, "Phew, no dangerous on-the-fly mode switching to do!");
985 // Power off if first boot and config says so
990 logger->log("Command", Log::DEBUG, "Load power after boot");
992 config = vdr->configLoad("General", "Power After Boot");
996 if (!STRCASECMP(config, "On"))
998 logger->log("Command", Log::INFO, "Config says Power After Boot = On");
1000 else if (!STRCASECMP(config, "Off"))
1002 logger->log("Command", Log::INFO, "Config says Power After Boot = Off");
1005 return; // quit here
1007 else if (!STRCASECMP(config, "Last state"))
1009 char* lastPowerState = vdr->configLoad("General", "Last Power State");
1012 if (!STRCASECMP(lastPowerState, "On"))
1014 logger->log("Command", Log::INFO, "Config says Last Power State = On");
1016 else if (!STRCASECMP(lastPowerState, "Off"))
1018 logger->log("Command", Log::INFO, "Config says Last Power State = Off");
1021 return; // quit here
1025 logger->log("Command", Log::INFO, "Config General/Last Power State not understood");
1030 logger->log("Command", Log::INFO, "Config General/Last Power State not found");
1035 logger->log("Command", Log::INFO, "Config/Power After Boot not understood");
1041 logger->log("Command", Log::INFO, "Config General/Power After Boot not found");
1046 // Go S-Video if config says so
1048 config = vdr->configLoad("TV", "Connection");
1052 if (!STRCASECMP(config, "S-Video"))
1054 logger->log("Command", Log::INFO, "Switching to S-Video as Connection=%s", config);
1055 video->setConnection(Video::SVIDEO);
1056 } else if (!STRCASECMP(config, "HDMI"))
1058 logger->log("Command", Log::INFO, "Switching to HDMI as Connection=%s", config);
1059 video->setConnection(Video::HDMI);
1060 } else if (!STRCASECMP(config, "HDMI3D"))
1062 logger->log("Command", Log::INFO, "Switching to HDMI3D as Connection=%s", config);
1063 video->setConnection(Video::HDMI3D);
1067 logger->log("Command", Log::INFO, "Switching to RGB/Composite as Connection=%s", config);
1068 video->setConnection(Video::COMPOSITERGB);
1074 logger->log("Command", Log::INFO, "Config TV/S-Video not found");
1077 // Set to shutdown VDR if config says
1079 config = vdr->configLoad("General", "VDR shutdown");
1082 if (!STRCASECMP(config, "On"))
1084 logger->log("Command", Log::INFO, "Shutdown VDR when shutting down vomp");
1085 vdr->setVDRShutdown(true);
1087 else if (!STRCASECMP(config, "Off"))
1089 logger->log("Command", Log::INFO, "Shutdown only vomp");
1090 vdr->setVDRShutdown(false);
1095 logger->log("Command", Log::INFO, "Default shutdown only vomp");
1096 vdr->setVDRShutdown(false); // Default
1101 config = vdr->configLoad("General", "Remote type");
1105 if (!STRCASECMP(config, "New"))
1107 logger->log("Command", Log::INFO, "Switching to New remote type");
1108 remote->setRemoteType(Remote::NEWREMOTE);
1112 logger->log("Command", Log::INFO, "Switching to Old remote type");
1113 remote->setRemoteType(Remote::OLDREMOTE);
1119 logger->log("Command", Log::INFO, "Config General/Remote type not found");
1120 remote->setRemoteType(Remote::OLDREMOTE);
1125 // Get TV aspect ratio
1127 config = vdr->configLoad("TV", "Aspect");
1130 if (!STRCASECMP(config, "16:9"))
1132 logger->log("Command", Log::INFO, "/// Switching to TV aspect 16:9");
1133 video->setTVsize(Video::ASPECT16X9);
1137 logger->log("Command", Log::INFO, "/// Switching to TV aspect 4:3");
1138 video->setTVsize(Video::ASPECT4X3);
1144 logger->log("Command", Log::INFO, "Config TV/Aspect type not found, going 4:3");
1145 video->setTVsize(Video::ASPECT4X3);
1148 config = vdr->configLoad("TV", "Widemode");
1151 if (!STRCASECMP(config, "Letterbox"))
1153 logger->log("Command", Log::INFO, "Setting letterbox mode");
1154 video->setMode(Video::LETTERBOX);
1158 logger->log("Command", Log::INFO, "Setting chop-sides mode");
1159 video->setMode(Video::NORMAL);
1166 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting letterbox mode");
1167 video->setMode(Video::LETTERBOX);
1169 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting chop-sides mode");
1170 video->setMode(Video::NORMAL);
1174 config = vdr->configLoad("Advanced", "TCP receive window");
1177 size_t newTCPsize = atoi(config);
1180 logger->log("Command", Log::INFO, "Setting TCP window size %i", newTCPsize);
1181 vdr->setReceiveWindow(newTCPsize);
1185 logger->log("Command", Log::INFO, "TCP window size not found, setting 2048");
1186 if (DEFAULT_TCP_WINDOWSIZE) vdr->setReceiveWindow(2048); // Default
1189 config = vdr->configLoad("Advanced", "Font Name");
1192 Osd::getInstance()->setFont(config);
1193 logger->log("Command", Log::INFO, "Setting Font to %s", config);
1199 // Set recording list type
1202 #ifdef ADVANCED_MENUES
1203 config = vdr->configLoad("Advanced", "Menu type");
1207 if (!STRCASECMP(config, "Advanced"))
1209 logger->log("Command", Log::INFO, "Switching to Advanced menu");
1215 logger->log("Command", Log::INFO, "Switching to Classic menu");
1222 logger->log("Command", Log::INFO, "Config General/menu type not found");
1227 config = vdr->configLoad("Advanced", "Disable WOL");
1230 if (!STRCASECMP(config, "Yes"))
1232 logger->log("Command", Log::INFO, "Config says disable WOL");
1233 Wol::getInstance()->setEnabled(false);
1237 logger->log("Command", Log::INFO, "Config says enable WOL");
1238 Wol::getInstance()->setEnabled(true);
1245 logger->log("Command", Log::INFO, "By default, enable WOL");
1246 Wol::getInstance()->setEnabled(true);
1248 /* device dependend config */
1249 audio->loadOptionsfromServer(vdr);
1250 video->loadOptionsfromServer(vdr);
1251 remote->loadOptionsfromServer(vdr);
1253 video->executePendingModeChanges();
1256 // Save power state = on
1258 vdr->configSave("General", "Last Power State", "On");
1260 // Make sure connection didn't die
1261 if (!vdr->isConnected())
1263 Command::getInstance()->connectionLost();
1267 boxstack->remove(vi);
1269 VWelcome* vw = new VWelcome();
1272 boxstack->update(vw);
1274 // Enter pre-keys here
1275 // handleCommand(Remote::OK);
1276 // handleCommand(Remote::THREE);
1277 // handleCommand(Remote::SIX);
1278 // handleCommand(Remote::OK);
1279 // handleCommand(Remote::UP);
1280 // handleCommand(Remote::PLAY);
1281 // handleCommand(Remote::DOWN);
1282 // handleCommand(Remote::DOWN);
1283 // handleCommand(Remote::DOWN);
1284 // handleCommand(Remote::OK);
1285 // handleCommand(Remote::RED);