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"
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)
280 if (signalReceived == SIGINT)
282 else if (signalReceived == SIGTERM)
284 else if (signalReceived == SIGUSR1)
286 else if (signalReceived == SIGUSR2)
288 else if (signalReceived == SIGURG)
293 void Command::processSignals()
296 if (signals & SIG_INT)
298 signals = signals & ~SIG_INT;
299 logger->log("Command", Log::NOTICE, "INT signal, shutting down...");
303 if (signals & SIG_TERM)
305 signals = signals & ~SIG_TERM;
306 logger->log("Command", Log::NOTICE, "TERM signal, shutting down...");
310 if (signals & SIG_USR1)
312 logger->log("Command", Log::NOTICE, "USR1 signal");
313 signals = signals & ~SIG_USR1;
316 if (signals & SIG_USR2)
318 logger->log("Command", Log::NOTICE, "USR2 signal");
319 signals = signals & ~SIG_USR2;
322 if (signals & SIG_URG)
324 logger->log("Command", Log::NOTICE, "URG signal"); // This is used to break from getButtonPress to process the message queue
325 signals = signals & ~SIG_URG;
330 void Command::postMessage(Message* m)
332 // This is locked here in case the main loop is not waiting for an event, but is processing one
333 // it could be killed but then not react to it because the signal wouldn't cause
334 // remote->getButtonPress to break
335 // locking the mutex ensures that the master thread is waiting on getButtonPress
338 //logger->log("Command", Log::DEBUG, "WANT LOCK");
340 pthread_mutex_lock(&masterLock);
342 WaitForSingleObject(masterLock, INFINITE );
344 //logger->log("Command", Log::DEBUG, "LOCK");
345 MessageQueue::postMessage(m);
349 kill(mainPid, SIGURG);
351 ((RemoteAndroid*)Remote::getInstance())->Signal();
353 pthread_mutex_unlock(&masterLock);
355 ((RemoteWin*)Remote::getInstance())->Signal();
356 ReleaseMutex(masterLock);
358 //logger->log("Command", Log::DEBUG, "UNLOCK");
361 void Command::postMessageNoLock(Message* m)
363 // As above but use this one if this message is being posted because of a button press
364 // the mutex is already locked, locking around postMessage is not needed as the
365 // queue is guaranteed to be run when the button has been processed
366 MessageQueue::postMessage(m);
369 bool Command::postMessageIfNotBusy(Message* m)
371 // Used for Windows mouse events
373 //logger->log("Command", Log::DEBUG, "TRY LOCK");
375 if (pthread_mutex_trylock(&masterLock) != EBUSY)
377 //logger->log("Command", Log::DEBUG, "LOCK");
378 MessageQueue::postMessage(m);
380 kill(mainPid, SIGURG);
382 ((RemoteAndroid*)Remote::getInstance())->Signal();
384 pthread_mutex_unlock(&masterLock);
385 //logger->log("Command", Log::DEBUG, "UNLOCK");
393 switch (WaitForSingleObject(masterLock, 0 ))
394 { //FIXME this is not "if not busy" check
395 case WAIT_OBJECT_0: //but with proper argument 0 this did not work
396 // case WAIT_ABANDONED:
397 MessageQueue::postMessage(m);
398 ((RemoteWin*)Remote::getInstance())->Signal();
399 ReleaseMutex(masterLock);
402 case WAIT_ABANDONED: return false;
403 case WAIT_TIMEOUT: return false;
409 void Command::postMessageFromOuterSpace(Message* m)
412 Yet another way of getting messages into Command. This one is for events that
413 are not standard button presses (or UDP generated buttons). It is also not for
414 events that are generated as a result of other events (events that can safely
415 call postMessageNoLock and be guaranteed that the message will be processed
416 because it is known that the queue is currently being processed).
417 This is for events that come from outer space and can occur when the master
418 mutex is locked or not, they need to be queued and executed but it doesn't
420 Actually so far it is for events caused by the video stream - aspect ratio
421 changes. These can occur when the master mutex is locked and so postMessage
422 doesn't work. postMessageNoLock doesn't work because if the mutex *isn't*
423 locked at the time then the message could be sat around a while before
425 The whole message system was at first supposed to prevent the problem of
426 calling a function on an object that had just been deleted, by ordering
427 messages such that all calls are done before object deletion. However,
428 because of the new centralised messaging system and the fact that BoxStack
429 locates the destination object before calling it, the messaging system now
430 allows the kind of sloppy calls it was supposed to stop. Weird huh. This
431 is mentioned here because the video stream might generate an event just as
432 the user hits stop. The mutex is locked, and by the time the message
433 is examined the vvideorec/live has been deleted. This doesn't matter because
434 boxstack will drop the message if it can't find the matching object to
436 Finally, all this is fine and dandy, except that I'm not 100% sure that
437 this sloppy postMessage and hope a queued signal will force it to be processed
438 thingy will actually work. Hmmm.
439 Lastly <g>, I will consider making the naming system a little more sane
443 logger->log("Command", Log::DEBUG, "PMFOS called");
444 MessageQueue::postMessage(m);
448 kill(mainPid, SIGURG);
450 ((RemoteAndroid*)Remote::getInstance())->Signal();
453 ((RemoteWin*)Remote::getInstance())->Signal();
457 void Command::processMessage(Message* m)
459 // FIXME - a slight modification - how if messagereceivers were to register
460 // themselves as receivers to avoid the calling-a-deleted-object problem
461 // then only deliver/register/unregister would have to be protected
463 logger->log("Command", Log::DEBUG, "processing message %i", m->message);
471 case Message::STOP_PLAYBACK:
473 handleCommand(Remote::STOP); // an odd way of doing it, but so simple
476 // Also connection_lost comes from player - anywhere else?
480 case Message::VDR_CONNECTED:
482 doJustConnected((VConnect*)m->from);
485 case Message::SCREENSHOT:
487 #ifdef VOMP_PLATTFORM_MVP
488 Osd::getInstance()->screenShot("/out.jpg");
490 logger->log("Osd", Log::NOTICE, "Screenshot Message arrived");
491 Osd::getInstance()->screenShot("out.jpg");
495 case Message::CONNECTION_LOST:
500 case Message::UDP_BUTTON:
502 handleCommand(m->parameter.num);
505 case Message::CHANGE_LANGUAGE:
507 boxstack->removeAllExceptWallpaper();
508 boxstack->update(wallpaper);
510 if (!VDR::getInstance()->isConnected()) { connectionLost(); break; }
511 VWelcome* vw = new VWelcome();
514 boxstack->update(vw);
517 case Message::LAST_VIEW_CLOSE:
519 // Shouldn't be done like this. Some generic message pass back from vinfo perhaps
526 // VWelcome* vw = new VWelcome();
528 // boxstack->add(vw);
529 // boxstack->update(vw);
533 case Message::NEW_PICTURE:
535 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE");
536 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
538 osdv->informPicture(m->tag,m->parameter.handle);
542 case Message::NEW_PICTURE_STATIC:
544 //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE %x %x",m->tag,m->parameter.num);
545 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
547 osdv->informPicture(((unsigned long long)m->tag)<<32LL,m->parameter.handle);
557 Instead of sending through the boxstack, implement a more generic MessageReceiver interface
558 and have potential receivers register with something
559 When a message needs to be delivered, check if the receiver is still registered, if so, deliver the message
560 This could all be done using the existing big command mutex to keep it simple
563 logger->log("Command", Log::DEBUG, "Sending message to boxstack");
564 boxstack->processMessage(m);
568 void Command::handleCommand(int button)
570 if (isStandby && (button != Remote::POWER)
571 && (button != Remote::POWERON) && (button != Remote::POWEROFF)) return;
572 if (!connLost && boxstack->handleCommand(button)) return; // don't send to boxstack if connLost
574 // command was not handled
578 case Remote::DF_LEFT:
579 case Remote::DF_RIGHT:
580 case Remote::VOLUMEUP:
581 case Remote::VOLUMEDOWN:
583 if (remote->handlesVolume()) {
584 if (button==Remote::DF_LEFT || button==Remote::VOLUMEDOWN)
585 remote->volumeDown();
586 else remote->volumeUp();
588 VVolume* v = new VVolume();
590 v->handleCommand(button); // this will draw+show
596 if (remote->handlesVolume()) {
597 remote->volumeMute();
599 VMute* v = new VMute();
611 case Remote::POWERON:
616 case Remote::POWEROFF:
624 if (!connLost) return; // if connLost, handle Remote::OK
630 VSleeptimer* sleep = new VSleeptimer();
631 boxstack->add(sleep);
632 sleep->handleCommand(button); // this will draw+show
641 Message* m = new Message(); // break into master mutex
642 m->message = Message::SCREENSHOT;
648 void Command::doStandby()
661 void Command::doPowerOn()
665 Video::getInstance()->signalOn();
666 Led::getInstance()->on();
667 Remote::getInstance()->changePowerState(true);
671 VConnect* vconnect = new VConnect(server);
672 boxstack->add(vconnect);
677 void Command::doPowerOff()
681 VDR::getInstance()->shutdownVDR();
682 boxstack->removeAllExceptWallpaper();
683 Video::getInstance()->signalOff();
684 boxstack->update(wallpaper);
686 VDR::getInstance()->configSave("General", "Last Power State", "Off");
687 logger->unsetExternLogger();
688 VDR::getInstance()->disconnect();
689 Led::getInstance()->off();
690 Remote::getInstance()->changePowerState(false);
692 Sleeptimer::getInstance()->shutdown();
694 stop(); //different behavoiur on windows, we exit
699 void Command::doFromTheTop(bool which)
701 if (isStandby) return;
706 logger->log("Command", Log::NOTICE, "Connection lost dialog already present");
710 logger->log("Command", Log::NOTICE, "Doing connection lost dialog");
711 connLost = new VInfo();
712 connLost->setSize(360, 200);
713 connLost->createBuffer();
714 if (Video::getInstance()->getFormat() == Video::PAL)
715 connLost->setPosition(190, 170);
717 connLost->setPosition(180, 120);
718 connLost->setOneLiner(tr("Connection lost"));
719 connLost->setDropThrough();
720 connLost->setBorderOn(1);
721 connLost->setTitleBarColour(DrawStyle::DANGER);
722 connLost->okButton();
724 boxstack->add(connLost);
725 boxstack->update(connLost);
726 remote->clearBuffer();
730 logger->unsetExternLogger();
731 VDR::getInstance()->disconnect();
732 boxstack->removeAllExceptWallpaper();
733 boxstack->update(wallpaper);
737 remote->clearBuffer();
739 // at this point, everything should be reset to first-go
741 VConnect* vconnect = new VConnect(server);
742 boxstack->add(vconnect);
747 void Command::doReboot()
750 logger->unsetExternLogger();
751 VDR::getInstance()->disconnect();
753 logger->log("Command", Log::NOTICE, "Reboot");
755 #ifndef VOMP_HAS_EXIT
756 // some plattforms, want a proper deinitialisation of their hardware before reboot
757 Osd::getInstance()->shutdown();
758 Audio::getInstance()->shutdown();
759 Video::getInstance()->shutdown();
760 Remote::getInstance()->shutdown();
762 reboot(LINUX_REBOOT_CMD_RESTART);
763 // if reboot is not allowed -> stop
775 #endif //Would we support this on windows?
778 void Command::connectionLost()
780 logger->unsetExternLogger();
781 Message* m = new Message(); // break into master mutex
782 m->message = Message::CONNECTION_LOST;
784 postMessageFromOuterSpace(m);
787 void Command::buildCrashedBox()
789 VInfo* crash = new VInfo();
790 crash->setSize(360, 250);
791 crash->createBuffer();
792 if (Video::getInstance()->getFormat() == Video::PAL)
793 crash->setPosition(190, 146);
795 crash->setPosition(180, 96);
796 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.");
797 crash->setBorderOn(1);
798 crash->setTitleBarColour(DrawStyle::DANGER);
800 crash->setExitable();
802 boxstack->add(crash);
803 boxstack->update(crash);
806 int Command::getLangPref(bool subtitle,const char* langcode)
808 vector<struct ASLPref>::iterator itty=langcodes.begin();
809 char templangcode[4];
810 templangcode[0]=langcode[0];
811 templangcode[1]=langcode[1];
812 templangcode[2]=langcode[2];
813 templangcode[3]='\0';
815 while (itty != langcodes.end()) {
816 size_t pos=(*itty).langcode.find(templangcode);
817 if (pos != string::npos) {
818 //vector<struct ASLPref>::iterator itty2=langcodes.begin();
819 for (unsigned int i=0; i<langcodes.size();i++) {
822 pref=langcodes[i].subtitlepref;
824 pref=langcodes[i].audiopref;
829 if (langcodes[i].subtitlepref==langpos) {
833 if (langcodes[i].audiopref==langpos) {
843 return langcodes.size(); //neutral
846 void Command::doJustConnected(VConnect* vconnect)
849 if (!VDR::getInstance()->isConnected()) { connectionLost(); return; }
850 logger->log("Command", Log::INFO, "Entering doJustConnected");
852 Video* video = Video::getInstance();
853 Audio* audio = Audio::getInstance();
854 boxstack->remove(vconnect);
856 VInfo* vi = new VInfo();
857 vi->setSize(400, 200);
859 if (video->getFormat() == Video::PAL)
860 vi->setPosition(170, 200);
862 vi->setPosition(160, 150);
863 vi->setOneLiner(tr("Connected, loading config"));
866 boxstack->update(vi);
868 VDR* vdr = VDR::getInstance();
871 // See if we're supposed to do network logging
872 config = vdr->configLoad("Advanced", "Network logging");
873 if (config && !STRCASECMP(config, "On"))
875 logger->log("Command", Log::INFO, "Turning on network logging");
876 logger->setExternLogger(vdr);
880 logger->unsetExternLogger();
881 logger->log("Command", Log::INFO, "Turned off network logging");
883 if (config) delete[] config;
885 config = vdr->configLoad("Advanced", "Skin Name");
887 const char **skinnames=SkinFactory::getSkinNames();
888 for (int i=0;i<SkinFactory::getNumberofSkins();i++) {
889 if (!STRCASECMP(config, skinnames[i])) {
890 SkinFactory::InitSkin(i);
895 if (wallpaper && wallpaper_pict) {
896 if (DrawStyle::WALLPAPER.alpha) {
897 wallpaper_pict->setVisible(true);
899 wallpaper_pict->setVisible(false);
902 boxstack->update(wallpaper);
906 SkinFactory::InitSkin(0);
909 // See if config says to override video format (PAL/NTSC)
910 config = vdr->configLoad("General", "Override Video Format");
913 logger->log("Command", Log::DEBUG, "Override Video Format is present");
915 if ( (!strcmp(config, "PAL") && (video->getFormat() != Video::PAL))
916 || (!strcmp(config, "NTSC") && (video->getFormat() != Video::NTSC))
917 || (!strcmp(config, "PAL_M") && (video->getFormat() != Video::PAL_M))
918 || (!strcmp(config, "NTSC_J") && (video->getFormat() != Video::NTSC_J))
921 // Oh sheesh, need to switch format. Bye bye TV...
923 // Take everything down
924 boxstack->removeAllExceptWallpaper();
925 boxstack->remove(wallpaper);
926 delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL;
928 Osd* osd = Osd::getInstance();
934 remote->shutdown(); // need on raspberry shut not do any harm, hopefully
935 remote->init(RemoteStartDev);
937 // Get video and osd back up with the new mode
938 if (!strcmp(config, "PAL"))
940 logger->log("Command", Log::DEBUG, "Switching to PAL");
941 video->init(Video::PAL);
943 else if (!strcmp(config, "NTSC"))
945 logger->log("Command", Log::DEBUG, "Switching to NTSC");
946 video->init(Video::NTSC);
947 } else if (!strcmp(config, "PAL_M"))
949 logger->log("Command", Log::DEBUG, "Switching to PAL_M");
950 video->init(Video::PAL_M);
951 } else if (!strcmp(config, "NTSC_J"))
953 logger->log("Command", Log::DEBUG, "Switching to NTSC_J");
954 video->init(Video::NTSC_J);
959 //we do not init twice
960 osd->init((char*)("/dev/stbgfx"));
963 // Put the wallpaper back
968 vi->setSize(400, 200);
970 if (video->getFormat() == Video::PAL)
971 vi->setPosition(170, 200);
973 vi->setPosition(160, 150);
975 vi->setOneLiner(tr("Connected, loading config"));
978 boxstack->update(vi);
982 logger->log("Command", Log::DEBUG, "Already in requested mode, or request was not 'PAL' or 'NTSC'");
987 logger->log("Command", Log::DEBUG, "Phew, no dangerous on-the-fly mode switching to do!");
990 // Power off if first boot and config says so
995 logger->log("Command", Log::DEBUG, "Load power after boot");
997 config = vdr->configLoad("General", "Power After Boot");
1001 if (!STRCASECMP(config, "On"))
1003 logger->log("Command", Log::INFO, "Config says Power After Boot = On");
1005 else if (!STRCASECMP(config, "Off"))
1007 logger->log("Command", Log::INFO, "Config says Power After Boot = Off");
1010 return; // quit here
1012 else if (!STRCASECMP(config, "Last state"))
1014 char* lastPowerState = vdr->configLoad("General", "Last Power State");
1017 if (!STRCASECMP(lastPowerState, "On"))
1019 logger->log("Command", Log::INFO, "Config says Last Power State = On");
1021 else if (!STRCASECMP(lastPowerState, "Off"))
1023 logger->log("Command", Log::INFO, "Config says Last Power State = Off");
1026 return; // quit here
1030 logger->log("Command", Log::INFO, "Config General/Last Power State not understood");
1035 logger->log("Command", Log::INFO, "Config General/Last Power State not found");
1040 logger->log("Command", Log::INFO, "Config/Power After Boot not understood");
1046 logger->log("Command", Log::INFO, "Config General/Power After Boot not found");
1051 // Go S-Video if config says so
1053 config = vdr->configLoad("TV", "Connection");
1057 if (!STRCASECMP(config, "S-Video"))
1059 logger->log("Command", Log::INFO, "Switching to S-Video as Connection=%s", config);
1060 video->setConnection(Video::SVIDEO);
1061 } else if (!STRCASECMP(config, "HDMI"))
1063 logger->log("Command", Log::INFO, "Switching to HDMI as Connection=%s", config);
1064 video->setConnection(Video::HDMI);
1065 } else if (!STRCASECMP(config, "HDMI3D"))
1067 logger->log("Command", Log::INFO, "Switching to HDMI3D as Connection=%s", config);
1068 video->setConnection(Video::HDMI3D);
1072 logger->log("Command", Log::INFO, "Switching to RGB/Composite as Connection=%s", config);
1073 video->setConnection(Video::COMPOSITERGB);
1079 logger->log("Command", Log::INFO, "Config TV/S-Video not found");
1082 // Set to shutdown VDR if config says
1084 config = vdr->configLoad("General", "VDR shutdown");
1087 if (!STRCASECMP(config, "On"))
1089 logger->log("Command", Log::INFO, "Shutdown VDR when shutting down vomp");
1090 vdr->setVDRShutdown(true);
1092 else if (!STRCASECMP(config, "Off"))
1094 logger->log("Command", Log::INFO, "Shutdown only vomp");
1095 vdr->setVDRShutdown(false);
1100 logger->log("Command", Log::INFO, "Default shutdown only vomp");
1101 vdr->setVDRShutdown(false); // Default
1106 config = vdr->configLoad("General", "Remote type");
1110 if (!STRCASECMP(config, "New"))
1112 logger->log("Command", Log::INFO, "Switching to New remote type");
1113 remote->setRemoteType(Remote::NEWREMOTE);
1117 logger->log("Command", Log::INFO, "Switching to Old remote type");
1118 remote->setRemoteType(Remote::OLDREMOTE);
1124 logger->log("Command", Log::INFO, "Config General/Remote type not found");
1125 remote->setRemoteType(Remote::OLDREMOTE);
1130 // Get TV aspect ratio
1132 config = vdr->configLoad("TV", "Aspect");
1135 if (!STRCASECMP(config, "16:9"))
1137 logger->log("Command", Log::INFO, "/// Switching to TV aspect 16:9");
1138 video->setTVsize(Video::ASPECT16X9);
1142 logger->log("Command", Log::INFO, "/// Switching to TV aspect 4:3");
1143 video->setTVsize(Video::ASPECT4X3);
1149 logger->log("Command", Log::INFO, "Config TV/Aspect type not found, going 4:3");
1150 video->setTVsize(Video::ASPECT4X3);
1153 config = vdr->configLoad("TV", "Widemode");
1156 if (!STRCASECMP(config, "Letterbox"))
1158 logger->log("Command", Log::INFO, "Setting letterbox mode");
1159 video->setMode(Video::LETTERBOX);
1163 logger->log("Command", Log::INFO, "Setting chop-sides mode");
1164 video->setMode(Video::NORMAL);
1171 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting letterbox mode");
1172 video->setMode(Video::LETTERBOX);
1174 logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting chop-sides mode");
1175 video->setMode(Video::NORMAL);
1179 config = vdr->configLoad("Advanced", "TCP receive window");
1182 size_t newTCPsize = atoi(config);
1185 logger->log("Command", Log::INFO, "Setting TCP window size %i", newTCPsize);
1186 vdr->setReceiveWindow(newTCPsize);
1190 logger->log("Command", Log::INFO, "TCP window size not found, setting 2048");
1191 if (DEFAULT_TCP_WINDOWSIZE) vdr->setReceiveWindow(2048); // Default
1194 config = vdr->configLoad("Advanced", "Font Name");
1197 Osd::getInstance()->setFont(config);
1198 logger->log("Command", Log::INFO, "Setting Font to %s", config);
1204 // Set recording list type
1207 #ifdef ADVANCED_MENUES
1208 config = vdr->configLoad("Advanced", "Menu type");
1212 if (!STRCASECMP(config, "Advanced"))
1214 logger->log("Command", Log::INFO, "Switching to Advanced menu");
1220 logger->log("Command", Log::INFO, "Switching to Classic menu");
1227 logger->log("Command", Log::INFO, "Config General/menu type not found");
1232 config = vdr->configLoad("Advanced", "Disable WOL");
1235 if (!STRCASECMP(config, "Yes"))
1237 logger->log("Command", Log::INFO, "Config says disable WOL");
1238 Wol::getInstance()->setEnabled(false);
1242 logger->log("Command", Log::INFO, "Config says enable WOL");
1243 Wol::getInstance()->setEnabled(true);
1250 logger->log("Command", Log::INFO, "By default, enable WOL");
1251 Wol::getInstance()->setEnabled(true);
1253 /* device dependend config */
1254 audio->loadOptionsfromServer(vdr);
1255 video->loadOptionsfromServer(vdr);
1256 remote->loadOptionsfromServer(vdr);
1258 video->executePendingModeChanges();
1261 // Save power state = on
1263 vdr->configSave("General", "Last Power State", "On");
1265 // Make sure connection didn't die
1266 if (!vdr->isConnected())
1268 Command::getInstance()->connectionLost();
1272 boxstack->remove(vi);
1274 VWelcome* vw = new VWelcome();
1277 boxstack->update(vw);
1279 // Enter pre-keys here
1280 // handleCommand(Remote::OK);
1281 // handleCommand(Remote::THREE);
1282 // handleCommand(Remote::SIX);
1283 // handleCommand(Remote::OK);
1284 // handleCommand(Remote::UP);
1285 // handleCommand(Remote::PLAY);
1286 // handleCommand(Remote::DOWN);
1287 // handleCommand(Remote::DOWN);
1288 // handleCommand(Remote::DOWN);
1289 // handleCommand(Remote::OK);
1290 // handleCommand(Remote::RED);