]> git.vomp.tv Git - vompclient.git/commitdiff
Rename Command class to Control
authorChris Tallon <chris@vomp.tv>
Wed, 15 Apr 2020 17:16:50 +0000 (18:16 +0100)
committerChris Tallon <chris@vomp.tv>
Wed, 15 Apr 2020 17:16:50 +0000 (18:16 +0100)
41 files changed:
channel.cc
command.cc [deleted file]
command.h [deleted file]
control.cc [new file with mode: 0644]
control.h [new file with mode: 0644]
demuxerts.cc
event.cc
language-data.h
main.cc
message.h
objects.mk
osdopengl.cc
osdvector.cc
osdvector.h
osdwinpixel.cc
osdwinvector.cc
playervideolive.cc
playervideorec.cc
recording.cc
vconnect.cc
vdr.cc
vdr.h
vepgsettimer.cc
vepgsummary.cc
vmediaview.cc
vopts.cc
vradiorec.cc
vrecordinglist.cc
vrecordinglistadvanced.cc
vrecordinglistclassic.cc
vtimerlist.cc
vvideolivetv.cc
vvideomedia.cc
vvideorec.cc
vwelcome.cc
winmain.cc
wremoteconfig.cc
wwinaudiofilter.cc
wwinmp3audiofilter.cc
wwinvideofilter.cc
wwinvideoh264filter.cc

index 8cd2f909a5b9164178020393fef5a35c6445f11d..99941f8b41fa61d36086673a4850185b1296e8e4 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "vdr.h"
 #include "log.h"
-#include "command.h"
+#include "control.h"
 
 Channel::Channel()
 {
@@ -51,7 +51,7 @@ void Channel::loadPids()
   VDR::getInstance()->getChannelPids(this); // FIXME sort out this system
   if (!VDR::getInstance()->isConnected())
   {
-    Command::getInstance()->connectionLost();
+    Control::getInstance()->connectionLost();
     return;
   }
         
diff --git a/command.cc b/command.cc
deleted file mode 100644 (file)
index 54dee97..0000000
+++ /dev/null
@@ -1,1065 +0,0 @@
-/*
-    Copyright 2004-2020 Chris Tallon
-
-    This file is part of VOMP.
-
-    VOMP is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    VOMP is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
-*/
-
-// FIXME rename to Control and move stuff from main to here
-
-
-#include "command.h"
-
-#ifdef WIN32
-#include "inputwin.h"
-#endif
-
-#ifdef __ANDROID__
-#include "inputandroid.h"
-#endif
-
-#include "led.h"
-#include "video.h"
-#include "audio.h"
-#include "vdr.h"
-#include "vvolume.h"
-#include "vserverselect.h"
-#include "vwelcome.h"
-#include "vmute.h"
-#include "colour.h"
-#include "osd.h"
-#include "i18n.h"
-#include "timers.h"
-#include "wol.h"
-#include "vconnect.h"
-#include "message.h"
-#include "inputman.h"
-#include "input.h"
-#include "vinfo.h"
-#include "boxx.h"
-#include "boxstack.h"
-#include "log.h"
-#include "vsleeptimer.h"
-#include "wjpeg.h"
-#include "osdvector.h"
-
-
-Command* Command::instance = NULL;
-
-Command::Command()
-{
-  if (instance) return;
-  instance = this;
-}
-
-Command::~Command()
-{
-  flushMessageQueue();
-  instance = NULL;
-}
-
-Command* Command::getInstance()
-{
-  return instance;
-}
-
-int Command::init(bool tcrashed)
-{
-  if (initted) return 0;
-  initted = true;
-  crashed = tcrashed;
-
-  logger = Log::getInstance();
-  boxstack = BoxStack::getInstance();
-  inputMan = InputMan::getInstance();
-  
-  if (!logger || !boxstack || !inputMan)
-  {
-    initted = false;
-    return 0;
-  }
-
-  SkinFactory::InitSkin(0);
-
-  return 1;
-}
-
-int Command::shutdown()
-{
-  if (!initted) return 0;
-  initted = false;
-  return 1;
-}
-
-void Command::stop()
-{
-  logger->log("Command", Log::NOTICE, "Request stop");
-
-  Message* m = new Message(); // break master loop
-  m->message = Message::SHUTDOWN;
-  m->p_to = Message::CONTROL;
-  postMessage(m);
-}
-
-void Command::doWallpaper()
-{
-  Video* video = Video::getInstance();
-
-  // Blue background
-  Boxx* bbg = new Boxx();
-  bbg->setSize(video->getScreenWidth(), video->getScreenHeight());
-  bbg->createBuffer();
-  bbg->fillColour(DrawStyle::WALLPAPER);
-  boxstack->add(bbg);
-  boxstack->update(bbg);
-  boxstack->remove(bbg);
-
-  // Wallpaper
-  wallpaper = new Boxx();
-  wallpaper->setSize(video->getScreenWidth(), video->getScreenHeight());
-  wallpaper->createBuffer();
-  wallpaper->setBackgroundColour(DrawStyle::WALLPAPER);
-
-  wallpaper_pict = new WJpegTYPE();
-  wallpaper_pict->setSize(video->getScreenWidth(), video->getScreenHeight());
-
-  if (video->getFormat() == Video::PAL)
-  {
-    logger->log("Command", Log::DEBUG, "PAL wallpaper selected");
-#ifndef _MIPS_ARCH    
-    wallpaper_pict->init("/wallpaperPAL.jpg");
-#else
-    wallpaper_pict->init("wallpaperPAL.jpg");
-#endif
-  }
-  else
-  {
-    logger->log("Command", Log::DEBUG, "NTSC wallpaper selected");
-    wallpaper_pict->init("/wallpaperNTSC.jpg");
-  }
-
-  if (DrawStyle::WALLPAPER.alpha)
-    wallpaper_pict->setVisible(true);
-  else
-    wallpaper_pict->setVisible(false);
-
-  wallpaper->add(wallpaper_pict);
-  wallpaper->draw();
-
-  boxstack->add(wallpaper);
-  boxstack->update(wallpaper);
-
-  OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
-  if (osdv) osdv->updateBackgroundColor(DrawStyle::WALLPAPER);
-}
-
-void Command::run()
-{
-  if (!initted) return;
-  irun = true;
-
-  // just in case
-  Video::getInstance()->signalOn();
-  Led::getInstance()->on();
-
-  doWallpaper();
-
-  if (crashed)
-  {
-    buildCrashedBox();
-  }
-  else
-  {
-    VConnect* vconnect = new VConnect();
-    boxstack->add(vconnect);
-    vconnect->run();
-  }
-
-
-  // FIXME Input::NA_SIGNAL is possibly obsolete now
-
-  std::unique_lock<std::mutex> lockWrapper(messageQueueMutex);  // locks. unlocks on out-of-scope
-
-  inputMan->start();
-
-  while(irun)
-  {
-    messageQueueCond.wait(lockWrapper, [&] { return !irun || !messages.empty(); });
-    logger->log("Command", Log::DEBUG, "woke");
-
-    if (!irun) break;
-
-    while(!messages.empty())
-    {
-      Message* m = messages.front();
-      messages.pop_front();
-
-      lockWrapper.unlock();
-
-      processMessage(m);
-      delete m;
-
-      lockWrapper.lock();
-    }
-  }
-
-  inputMan->stop();
-
-  boxstack->removeAllExceptWallpaper();
-  boxstack->remove(wallpaper);
-  delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL;
-}
-
-void Command::processMessage(Message* m)
-{
-    // FIXME - a slight modification - how if messagereceivers were to register
-    // themselves as receivers to avoid the calling-a-deleted-object problem
-    // then only deliver/register/unregister would have to be protected
-
-  logger->log("Command", Log::DEBUG, "processing message %i", m->message);
-
-
-  if ((m->p_to == Message::CONTROL) || (m->to == this)) // Maybe don't check m->to here? Always use predefined?
-  {
-    switch(m->message)
-    {
-      case Message::SHUTDOWN:
-      {
-        irun = false;
-        break;
-      }
-      // << FIXME OBSELETE
-      case Message::STOP_PLAYBACK:
-      {
-        handleCommand(Input::STOP); // an odd way of doing it, but so simple
-        break;
-      }
-      // Also connection_lost comes from player - anywhere else?
-      // FIXME OBSELETE >>
-
-
-      case Message::VDR_CONNECTED:
-      {
-        doJustConnected(static_cast<VConnect*>(m->from));
-        break;
-      }
-      case Message::SCREENSHOT:
-      {
-        logger->log("Osd", Log::NOTICE, "Screenshot Message arrived");
-        Osd::getInstance()->screenShot("out.jpg");
-        break;
-      }
-      case Message::CONNECTION_LOST:
-      {
-        doFromTheTop(true);
-        break;
-      }
-      case Message::INPUT_EVENT:
-      {
-        logger->log("Command", Log::NOTICE, "INPUT_EVENT %i", m->parameter);
-
-        handleCommand(m->parameter);
-        break;
-      }
-      case Message::CHANGE_LANGUAGE:
-      {
-        boxstack->removeAllExceptWallpaper();
-        boxstack->update(wallpaper);
-        I18n::initialize();
-        if (!VDR::getInstance()->isConnected()) { connectionLost(); break; }
-        VWelcome* vw = new VWelcome();
-        vw->draw();
-        boxstack->add(vw);
-        boxstack->update(vw);
-        break;
-      }
-      case Message::LAST_VIEW_CLOSE:
-      {
-        // Shouldn't be done like this. Some generic message pass back from vinfo perhaps
-        if (crashed)
-        {
-          crashed = false;
-          doFromTheTop(false);        
-        }
-      
-//        VWelcome* vw = new VWelcome();
-//        vw->draw();
-//        boxstack->add(vw);
-//        boxstack->update(vw);
-
-        break;
-      }
-      case Message::NEW_PICTURE:
-      {
-        //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE");
-        OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
-        if (osdv) osdv->informPicture(m->tag, reinterpret_cast<ImageIndex>(m->data));
-        break;
-      }
-      case Message::NEW_PICTURE_STATIC:
-      {
-        //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE %x %x",m->tag,m->parameter);
-        OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
-        if (osdv) osdv->informPicture(static_cast<unsigned long long>(m->tag) << 32LL, reinterpret_cast<ImageIndex>(m->data));
-        break;
-      }
-    }
-  }
-  else
-  {
-    /* FIXME
-    
-    Instead of sending through the boxstack, implement a more generic MessageReceiver interface
-    and have potential receivers register with something
-    When a message needs to be delivered, check if the receiver is still registered, if so, deliver the message
-    This could all be done using the existing big command mutex to keep it simple
-    */
-  
-    logger->log("Command", Log::DEBUG, "Sending message to boxstack");
-    boxstack->processMessage(m);
-  }
-}
-
-void Command::handleCommand(int button)
-{
-  if (isStandby && (button != Input::POWER)
-                && (button != Input::POWERON)
-                && (button != Input::POWEROFF))  return;
-
-  if (!connLost && boxstack->handleCommand(button)) return; // don't send to boxstack if connLost
-
-  // command was not handled
-
-  switch(button)
-  {
-    case Input::VOLUMEUP:
-    case Input::VOLUMEDOWN:
-    {
-      if (inputMan->handlesVolume()) // CEC volume handler?
-      {
-        if (button == Input::VOLUMEDOWN)
-          inputMan->volumeDown();
-        else
-          inputMan->volumeUp();
-      }
-      else
-      {
-        VVolume* v = new VVolume();
-        boxstack->add(v);
-        v->handleCommand(button); // this will draw+show
-      }
-      return;
-    }
-    case Input::MUTE:
-    {
-      if (inputMan->handlesVolume())
-      {
-        inputMan->volumeMute();
-      }
-      else
-      {
-        VMute* v = new VMute();
-        v->draw();
-        boxstack->add(v);
-        boxstack->update(v);
-      }
-      return;
-    }
-    case Input::POWER:
-    {
-      doStandby();
-      return;
-    }
-    case Input::POWERON:
-    {
-      doPowerOn();
-      return;
-    }
-    case Input::POWEROFF:
-    {
-      doPowerOff();
-      return;
-    }
-    case Input::OK:
-    {
-      // FIXME
-      if (!connLost) return; // if connLost, handle Input::OK
-      doFromTheTop(false);
-      return;
-    }
-    case Input::GO:
-    {
-      VSleeptimer* sleep = new VSleeptimer();
-      boxstack->add(sleep);
-      sleep->handleCommand(button); // this will draw+show
-      return;
-    }
-  }
-}
-
-/*
-void Command::sig1()
-{
-#ifdef DEV
-  Message* m = new Message(); // break into master mutex
-  m->message = Message::SCREENSHOT;
-  m->to = this;
-  postMessage(m);
-#endif
-}
-*/
-
-void Command::doStandby()
-{
-  if (isStandby)
-  {
-    doPowerOn();
-  }
-  else
-  {
-    doPowerOff();
-  }
-}
-
-
-void Command::doPowerOn()
-{
-  if (isStandby)
-  {
-    Video::getInstance()->signalOn();
-    Led::getInstance()->on();
-    InputMan::getInstance()->changePowerState(true);
-    isStandby = false;
-
-    VConnect* vconnect = new VConnect();
-    boxstack->add(vconnect);
-    vconnect->run();
-  }
-}
-
-void Command::doPowerOff()
-{
-  if (!isStandby)
-  {
-    VDR::getInstance()->shutdownVDR();
-    boxstack->removeAllExceptWallpaper();
-    Video::getInstance()->signalOff();
-    boxstack->update(wallpaper);
-
-    VDR::getInstance()->configSave("General", "Last Power State", "Off");
-    logger->unsetExternLogger();
-    VDR::getInstance()->disconnect();
-    Led::getInstance()->off();
-    InputMan::getInstance()->changePowerState(false);
-    isStandby = true;
-    Sleeptimer::getInstance()->shutdown();
-  }
-}
-
-void Command::doFromTheTop(bool which)
-{
-  if (isStandby) return;
-  if (which)
-  {
-    if (connLost)
-    {
-      logger->log("Command", Log::NOTICE, "Connection lost dialog already present");
-      return;
-    }
-  
-    logger->log("Command", Log::NOTICE, "Doing connection lost dialog");
-    connLost = new VInfo();
-    connLost->setSize(360, 200);
-    connLost->createBuffer();
-    if (Video::getInstance()->getFormat() == Video::PAL)
-      connLost->setPosition(190, 170);
-    else
-      connLost->setPosition(180, 120);
-    connLost->setOneLiner(tr("Connection lost"));
-    connLost->setDropThrough();
-    connLost->setBorderOn(1);
-    connLost->setTitleBarColour(DrawStyle::DANGER);
-    connLost->okButton();
-    connLost->draw();
-    boxstack->add(connLost);
-    boxstack->update(connLost);
-
-    clearMQInputEvents();
-  }
-  else
-  {
-    logger->unsetExternLogger();
-    VDR::getInstance()->disconnect();
-    boxstack->removeAllExceptWallpaper();
-    boxstack->update(wallpaper);
-    connLost = NULL;
-    
-    flushMessageQueue();
-    
-    // at this point, everything should be reset to first-go
-    
-    VConnect* vconnect = new VConnect();
-    boxstack->add(vconnect);
-    vconnect->run();
-  }
-}
-
-void Command::clearMQInputEvents()
-{
-  std::lock_guard<std::mutex> lg(messageQueueMutex); // Get the lock
-
-  MQueueI i = messages.begin();
-  while(i != messages.end())
-  {
-    Message* m = *i;
-    if (m->message == Message::INPUT_EVENT)
-    {
-      delete m;
-      i = messages.erase(i);
-    }
-    else
-    {
-      ++i;
-    }
-  }
-}
-
-void Command::doReboot()
-{
-
-  logger->unsetExternLogger();
-  VDR::getInstance()->disconnect();
-  // just kill it...
-  logger->log("Command", Log::NOTICE, "Reboot");
-#ifndef WIN32
-#ifndef VOMP_HAS_EXIT
-  // some plattforms, want a proper deinitialisation of their hardware before reboot
-  Osd::getInstance()->shutdown();
-  Audio::getInstance()->shutdown();
-  Video::getInstance()->shutdown();
-  InputMan::getInstance()->shutdown();
-
-  reboot(LINUX_REBOOT_CMD_RESTART);
-  // if  reboot is not allowed -> stop
-  stop();
-
-
-#else
-  stop();
-
-#ifdef __ANDROID__
-  exit(0);
-#endif
-
-#endif
-#endif //Would we support this on windows?
-}
-
-void Command::connectionLost()
-{
-  logger->unsetExternLogger();
-  Message* m = new Message(); // break into master mutex
-  m->message = Message::CONNECTION_LOST;
-  m->p_to = Message::CONTROL;
-  postMessage(m);
-}
-
-void Command::buildCrashedBox()
-{
-  VInfo* crash = new VInfo();
-  crash->setSize(360, 250);
-  crash->createBuffer();
-  if (Video::getInstance()->getFormat() == Video::PAL)
-    crash->setPosition(190, 146);
-  else
-    crash->setPosition(180, 96);
-  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.");
-  crash->setBorderOn(1);
-  crash->setTitleBarColour(DrawStyle::DANGER);
-  crash->okButton();
-  crash->setExitable();
-  crash->draw();
-  boxstack->add(crash);
-  boxstack->update(crash);
-}
-
-int Command::getLangPref(bool subtitle, const char* langcode)
-{
-  std::vector<struct ASLPref>::iterator itty=langcodes.begin();
-  char templangcode[4];
-  templangcode[0] = langcode[0];
-  templangcode[1] = langcode[1];
-  templangcode[2] = langcode[2];
-  templangcode[3] = '\0';
-  int langpos = 0;
-  while (itty != langcodes.end())
-  {
-    size_t pos = (*itty).langcode.find(templangcode);
-    if (pos != std::string::npos)
-    {
-      //vector<struct ASLPref>::iterator itty2=langcodes.begin();
-      for (unsigned int i = 0; i < langcodes.size(); i++)
-      {
-        int pref = 0;
-        if (subtitle)
-          pref = langcodes[i].subtitlepref;
-        else
-          pref = langcodes[i].audiopref;
-        if (pref < 0) break;
-
-        if (subtitle)
-        {
-          if (langcodes[i].subtitlepref==langpos) return i;
-        }
-        else
-        {
-          if (langcodes[i].audiopref==langpos) return i;
-        }
-      }
-      break;
-    }
-    itty++;
-    langpos++;
-  }
-  return langcodes.size(); //neutral
-}
-
-void Command::doJustConnected(VConnect* vconnect)
-{
-  I18n::initialize();
-  if (!VDR::getInstance()->isConnected()) { connectionLost(); return; }
-  logger->log("Command", Log::INFO, "Entering doJustConnected");
-  
-  Video* video = Video::getInstance();
-  Audio* audio = Audio::getInstance();  
-  boxstack->remove(vconnect);
-
-  VInfo* vi = new VInfo();
-  vi->setSize(400, 200);
-  vi->createBuffer();
-  if (video->getFormat() == Video::PAL)
-    vi->setPosition(170, 200);
-  else
-    vi->setPosition(160, 150);
-  vi->setOneLiner(tr("Connected, loading config"));
-  vi->draw();
-  boxstack->add(vi);
-  boxstack->update(vi);
-
-  // FIXME make config system
-
-  VDR* vdr = VDR::getInstance();
-  char* config;
-
-  // See if we're supposed to do network logging
-  config = vdr->configLoad("Advanced", "Network logging");
-  if (config && !STRCASECMP(config, "On"))
-  {
-    logger->log("Command", Log::INFO, "Turning on network logging");
-    logger->setExternLogger(vdr);
-  }  
-  else
-  {
-         logger->unsetExternLogger();
-    logger->log("Command", Log::INFO, "Turned off network logging");
-  }
-  if (config) delete[] config;
-
-  config = vdr->configLoad("Advanced", "Skin Name");
-  if (config)
-  {
-    const char **skinnames=SkinFactory::getSkinNames();
-    for (int i=0;i<SkinFactory::getNumberofSkins();i++)
-    {
-      if (!STRCASECMP(config, skinnames[i]))
-      {
-        SkinFactory::InitSkin(i);
-        break;
-      }
-    }
-    delete[] config;
-
-    if (wallpaper && wallpaper_pict)
-    {
-      if (DrawStyle::WALLPAPER.alpha)
-        wallpaper_pict->setVisible(true);
-      else
-        wallpaper_pict->setVisible(false);
-
-      wallpaper->draw();
-      boxstack->update(wallpaper);
-    }
-  }
-  else
-  {
-    SkinFactory::InitSkin(0);
-  }
-
-  // See if config says to override video format (PAL/NTSC)
-  config = vdr->configLoad("General", "Override Video Format");
-  if (config)
-  {
-    logger->log("Command", Log::DEBUG, "Override Video Format is present");
-
-    if (   (!strcmp(config, "PAL") && (video->getFormat() != Video::PAL))
-        || (!strcmp(config, "NTSC") && (video->getFormat() != Video::NTSC))
-        || (!strcmp(config, "PAL_M") && (video->getFormat() != Video::PAL_M))
-        || (!strcmp(config, "NTSC_J") && (video->getFormat() != Video::NTSC_J))
-        )
-    {
-      // Oh sheesh, need to switch format. Bye bye TV...
-
-      // Take everything down
-      boxstack->removeAllExceptWallpaper();
-      boxstack->remove(wallpaper);
-      delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL;
-
-      Osd* osd = Osd::getInstance();
-#ifndef __ANDROID__
-      osd->shutdown();
-#endif
-      video->shutdown();
-
-      inputMan->shutdown(); // need on raspberry shut not do any harm, hopefully
-      inputMan->init(); // FIXME this breaks badly now
-
-      // Get video and osd back up with the new mode
-      if (!strcmp(config, "PAL"))
-      {
-        logger->log("Command", Log::DEBUG, "Switching to PAL");
-        video->init(Video::PAL);
-      }
-      else if (!strcmp(config, "NTSC"))
-      {
-        logger->log("Command", Log::DEBUG, "Switching to NTSC");
-        video->init(Video::NTSC);
-      } else if (!strcmp(config, "PAL_M"))
-      {
-        logger->log("Command", Log::DEBUG, "Switching to PAL_M");
-        video->init(Video::PAL_M);
-      } else if (!strcmp(config, "NTSC_J"))
-      {
-        logger->log("Command", Log::DEBUG, "Switching to NTSC_J");
-        video->init(Video::NTSC_J);
-      }
-      delete[] config;
-
-#ifndef __ANDROID__
-      //we do not init twice
-      osd->init();
-#endif
-
-      // Put the wallpaper back
-      doWallpaper();
-
-      // Re add the vinfo
-      vi = new VInfo();
-      vi->setSize(400, 200);
-      vi->createBuffer();
-      if (video->getFormat() == Video::PAL)
-        vi->setPosition(170, 200);
-      else
-        vi->setPosition(160, 150);
-
-      vi->setOneLiner(tr("Connected, loading config"));
-      vi->draw();
-      boxstack->add(vi);
-      boxstack->update(vi);
-    }
-    else
-    {
-      logger->log("Command", Log::DEBUG, "Already in requested mode, or request was not 'PAL' or 'NTSC'");
-    }
-  }
-  else
-  {
-    logger->log("Command", Log::DEBUG, "Phew, no dangerous on-the-fly mode switching to do!");
-  }
-
-  // Power off if first boot and config says so
-  if (firstBoot)
-  {
-    firstBoot = false;
-
-    logger->log("Command", Log::DEBUG, "Load power after boot");
-
-    config = vdr->configLoad("General", "Power After Boot");
-
-    if (config)
-    {
-      if (!STRCASECMP(config, "On"))
-      {
-        logger->log("Command", Log::INFO, "Config says Power After Boot = On");
-      }
-      else if (!STRCASECMP(config, "Off"))
-      {
-        logger->log("Command", Log::INFO, "Config says Power After Boot = Off");
-        doStandby();
-        delete[] config;
-        return; // quit here
-      }
-      else if (!STRCASECMP(config, "Last state"))
-      {
-        char* lastPowerState = vdr->configLoad("General", "Last Power State");
-        if (lastPowerState)
-        {
-          if (!STRCASECMP(lastPowerState, "On"))
-          {
-            logger->log("Command", Log::INFO, "Config says Last Power State = On");
-          }
-          else if (!STRCASECMP(lastPowerState, "Off"))
-          {
-            logger->log("Command", Log::INFO, "Config says Last Power State = Off");
-            doStandby();
-            delete[] config;
-            return; // quit here
-          }
-          else
-          {
-            logger->log("Command", Log::INFO, "Config General/Last Power State not understood");
-          }
-        }
-        else
-        {
-          logger->log("Command", Log::INFO, "Config General/Last Power State not found");
-        }
-      }
-      else
-      {
-        logger->log("Command", Log::INFO, "Config/Power After Boot not understood");
-      }
-      delete[] config;
-    }
-    else
-    {
-      logger->log("Command", Log::INFO, "Config General/Power After Boot not found");
-    }
-  }
-
-
-  // Go S-Video if config says so
-
-  config = vdr->configLoad("TV", "Connection");
-
-  if (config)
-  {
-    if (!STRCASECMP(config, "S-Video"))
-    {
-      logger->log("Command", Log::INFO, "Switching to S-Video as Connection=%s", config);
-      video->setConnection(Video::SVIDEO);
-    } else  if (!STRCASECMP(config, "HDMI"))
-    {
-      logger->log("Command", Log::INFO, "Switching to HDMI as Connection=%s", config);
-      video->setConnection(Video::HDMI);
-    } else  if (!STRCASECMP(config, "HDMI3D"))
-    {
-      logger->log("Command", Log::INFO, "Switching to HDMI3D as Connection=%s", config);
-      video->setConnection(Video::HDMI3D);
-    }
-    else
-    {
-      logger->log("Command", Log::INFO, "Switching to RGB/Composite as Connection=%s", config);
-      video->setConnection(Video::COMPOSITERGB);
-    }
-    delete[] config;
-  }
-  else
-  {
-    logger->log("Command", Log::INFO, "Config TV/S-Video not found");
-  }
-
-  // Set to shutdown VDR if config says
-  
-  config = vdr->configLoad("General", "VDR shutdown");
-  if (config)
-  {
-    if (!STRCASECMP(config, "On"))
-    {
-      logger->log("Command", Log::INFO, "Shutdown VDR when shutting down vomp");
-      vdr->setVDRShutdown(true);
-    }
-    else if (!STRCASECMP(config, "Off"))
-    {
-      logger->log("Command", Log::INFO, "Shutdown only vomp");
-      vdr->setVDRShutdown(false);
-    }
-  }
-  else
-  {
-    logger->log("Command", Log::INFO, "Default shutdown only vomp");
-    vdr->setVDRShutdown(false); // Default
-  }
-          
-  // Get TV aspect ratio
-
-  config = vdr->configLoad("TV", "Aspect");
-  if (config)
-  {
-    if (!STRCASECMP(config, "16:9"))
-    {
-      logger->log("Command", Log::INFO, "/// Switching to TV aspect 16:9");
-      video->setTVsize(Video::ASPECT16X9);
-    }
-    else
-    {
-      logger->log("Command", Log::INFO, "/// Switching to TV aspect 4:3");
-      video->setTVsize(Video::ASPECT4X3);
-    }
-    delete[] config;
-  }
-  else
-  {
-    logger->log("Command", Log::INFO, "Config TV/Aspect type not found, going 4:3");
-    video->setTVsize(Video::ASPECT4X3);
-  }
-
-  config = vdr->configLoad("TV", "Widemode");
-  if (config)
-  {
-    if (!STRCASECMP(config, "Letterbox"))
-    {
-      logger->log("Command", Log::INFO, "Setting letterbox mode");
-      video->setMode(Video::LETTERBOX);
-    }
-    else
-    {
-      logger->log("Command", Log::INFO, "Setting chop-sides mode");
-      video->setMode(Video::NORMAL);
-    }
-    delete[] config;
-  }
-  else
-  {
-#ifdef __ANDROID__
-        logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting letterbox mode");
-        video->setMode(Video::LETTERBOX);
-#else
-    logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting chop-sides mode");
-    video->setMode(Video::NORMAL);
-#endif
-  }
-
-  config = vdr->configLoad("Advanced", "TCP receive window");
-  if (config)
-  {
-    size_t newTCPsize = atoi(config);
-    delete[] config;
-
-    logger->log("Command", Log::INFO, "Setting TCP window size %i", newTCPsize);
-    vdr->setReceiveWindow(newTCPsize);
-  }
-  else
-  {
-    logger->log("Command", Log::INFO, "TCP window size not found, setting 2048");
-    if (DEFAULT_TCP_WINDOWSIZE) vdr->setReceiveWindow(2048); // Default
-  }
-
-  config = vdr->configLoad("Advanced", "Font Name");
-  if (config)
-  {
-       Osd::getInstance()->setFont(config);
-    logger->log("Command", Log::INFO, "Setting Font to %s", config);
-    delete[] config;
-
-  }
-
-
-  // Set recording list type
-
-#ifdef ADVANCED_MENUES
-  config = vdr->configLoad("Advanced", "Menu type");
-
-  if (config)
-  {
-    if (!STRCASECMP(config, "Advanced"))
-    {
-      logger->log("Command", Log::INFO, "Switching to Advanced menu");
-      advMenus = true;
-    }
-    else
-    {
-      logger->log("Command", Log::INFO, "Switching to Classic menu");
-      advMenus = false;
-    }
-    delete[] config;
-  }
-  else
-  {
-    logger->log("Command", Log::INFO, "Config General/menu type not found");
-    advMenus = true;
-  }
-#endif
-
-  config = vdr->configLoad("Advanced", "Disable WOL");
-  if (config)
-  {
-    if (!STRCASECMP(config, "Yes"))
-    {
-      logger->log("Command", Log::INFO, "Config says disable WOL");
-      Wol::getInstance()->setEnabled(false);
-    }
-    else
-    {
-      logger->log("Command", Log::INFO, "Config says enable WOL");
-      Wol::getInstance()->setEnabled(true);
-    }
-
-    delete[] config;
-  }
-  else
-  {
-    logger->log("Command", Log::INFO, "By default, enable WOL");
-    Wol::getInstance()->setEnabled(true);
-  }
-  /* device dependend config */
-  audio->loadOptionsFromServer(vdr);
-  video->loadOptionsFromServer(vdr);
-  inputMan->loadOptionsFromServer(vdr);
-
-  video->executePendingModeChanges();
-  // config done
-
-  // Save power state = on
-
-  vdr->configSave("General", "Last Power State", "On");
-
-  // Make sure connection didn't die
-  if (!vdr->isConnected())
-  {
-    Command::getInstance()->connectionLost();
-  }
-  else
-  {
-    boxstack->remove(vi);
-
-    VWelcome* vw = new VWelcome();
-    vw->draw();
-    boxstack->add(vw);
-    boxstack->update(vw);
-
-    // Enter pre-keys here
-//    handleCommand(Input::OK);
-//    handleCommand(Input::THREE);
-//    handleCommand(Input::SIX);
-//    handleCommand(Input::OK);
-//    handleCommand(Input::UP);
-//    handleCommand(Input::PLAY);
-//    handleCommand(Input::DOWN);
-//    handleCommand(Input::DOWN);
-//    handleCommand(Input::DOWN);
-//    handleCommand(Input::RIGHT);
-//    handleCommand(Input::RED);
-  }
-}
diff --git a/command.h b/command.h
deleted file mode 100644 (file)
index 62fb740..0000000
--- a/command.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
-    Copyright 2004-2020 Chris Tallon
-
-    This file is part of VOMP.
-
-    VOMP is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    VOMP is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
-*/
-
-#ifndef COMMAND_H
-#define COMMAND_H
-
-#ifndef WIN32
-#include <unistd.h> // for reboot
-#include <linux/reboot.h>
-#include <sys/reboot.h>
-#endif
-
-#include <time.h>
-#ifndef WIN32
-#include <pthread.h>   // why?
-#endif
-
-#include <string>
-#include <vector>
-
-#include "defines.h"
-#include "messagequeue.h"
-
-class VConnect;
-class Message;
-class InputMan;
-class Boxx;
-class BoxStack;
-class Log;
-class VInfo;
-class WJpeg;
-
-struct ASLPref
-{
-  std::string langcode;
-  int audiopref;
-  int subtitlepref;
-};
-
-typedef std::vector<struct ASLPref> ASLPrefList;
-
-class Command : public MessageQueue
-{
-  public:
-    Command();
-    ~Command();
-    static Command* getInstance();
-
-    int init(bool crashed = false);
-    int shutdown();
-    void run();
-    void stop();
-    void doReboot();
-    void connectionLost();
-
-    void setAdvMenus(bool adv) { advMenus = adv; };
-    bool isAdvMenus() { return advMenus; };
-    int getLangPref(bool subtitle,const char* langcode);
-    void setSubDefault(int subon) { subdefault = subon; };
-    int getSubDefault() { return subdefault; };
-    ASLPrefList &getASLList() { return langcodes; };
-
-  private:
-    void handleCommand(int);
-    void doStandby();
-    void doPowerOn();
-    void doPowerOff();
-    void doJustConnected(VConnect* vconnect);
-    void doWallpaper();
-    void doFromTheTop(bool which);  // true - show vinfo,wait. false - del vinfo,restart
-    void buildCrashedBox();
-//    void sig1();
-    void clearMQInputEvents();
-
-    static Command* instance;
-
-    Log* logger;
-    BoxStack* boxstack;
-    InputMan* inputMan;
-
-    bool initted{};
-    bool irun{};
-    bool isStandby{};
-    bool firstBoot{true};
-    Boxx* wallpaper{};
-    WJpeg* wallpaper_pict{};
-    VInfo* connLost{};
-    bool crashed{};
-
-    bool advMenus{};
-    ASLPrefList langcodes;
-    int subdefault;
-        
-    void processMessage(Message* m);
-};
-
-#endif
diff --git a/control.cc b/control.cc
new file mode 100644 (file)
index 0000000..e4802a4
--- /dev/null
@@ -0,0 +1,1065 @@
+/*
+    Copyright 2004-2020 Chris Tallon
+
+    This file is part of VOMP.
+
+    VOMP is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    VOMP is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
+*/
+
+// FIXME rename to Control and move stuff from main to here
+
+
+#include "control.h"
+
+#ifdef WIN32
+#include "inputwin.h"
+#endif
+
+#ifdef __ANDROID__
+#include "inputandroid.h"
+#endif
+
+#include "led.h"
+#include "video.h"
+#include "audio.h"
+#include "vdr.h"
+#include "vvolume.h"
+#include "vserverselect.h"
+#include "vwelcome.h"
+#include "vmute.h"
+#include "colour.h"
+#include "osd.h"
+#include "i18n.h"
+#include "timers.h"
+#include "wol.h"
+#include "vconnect.h"
+#include "message.h"
+#include "inputman.h"
+#include "input.h"
+#include "vinfo.h"
+#include "boxx.h"
+#include "boxstack.h"
+#include "log.h"
+#include "vsleeptimer.h"
+#include "wjpeg.h"
+#include "osdvector.h"
+
+
+Control* Control::instance = NULL;
+
+Control::Control()
+{
+  if (instance) return;
+  instance = this;
+}
+
+Control::~Control()
+{
+  flushMessageQueue();
+  instance = NULL;
+}
+
+Control* Control::getInstance()
+{
+  return instance;
+}
+
+int Control::init(bool tcrashed)
+{
+  if (initted) return 0;
+  initted = true;
+  crashed = tcrashed;
+
+  logger = Log::getInstance();
+  boxstack = BoxStack::getInstance();
+  inputMan = InputMan::getInstance();
+  
+  if (!logger || !boxstack || !inputMan)
+  {
+    initted = false;
+    return 0;
+  }
+
+  SkinFactory::InitSkin(0);
+
+  return 1;
+}
+
+int Control::shutdown()
+{
+  if (!initted) return 0;
+  initted = false;
+  return 1;
+}
+
+void Control::stop()
+{
+  logger->log("Control", Log::NOTICE, "Request stop");
+
+  Message* m = new Message(); // break master loop
+  m->message = Message::SHUTDOWN;
+  m->p_to = Message::CONTROL;
+  postMessage(m);
+}
+
+void Control::doWallpaper()
+{
+  Video* video = Video::getInstance();
+
+  // Blue background
+  Boxx* bbg = new Boxx();
+  bbg->setSize(video->getScreenWidth(), video->getScreenHeight());
+  bbg->createBuffer();
+  bbg->fillColour(DrawStyle::WALLPAPER);
+  boxstack->add(bbg);
+  boxstack->update(bbg);
+  boxstack->remove(bbg);
+
+  // Wallpaper
+  wallpaper = new Boxx();
+  wallpaper->setSize(video->getScreenWidth(), video->getScreenHeight());
+  wallpaper->createBuffer();
+  wallpaper->setBackgroundColour(DrawStyle::WALLPAPER);
+
+  wallpaper_pict = new WJpegTYPE();
+  wallpaper_pict->setSize(video->getScreenWidth(), video->getScreenHeight());
+
+  if (video->getFormat() == Video::PAL)
+  {
+    logger->log("Control", Log::DEBUG, "PAL wallpaper selected");
+#ifndef _MIPS_ARCH    
+    wallpaper_pict->init("/wallpaperPAL.jpg");
+#else
+    wallpaper_pict->init("wallpaperPAL.jpg");
+#endif
+  }
+  else
+  {
+    logger->log("Control", Log::DEBUG, "NTSC wallpaper selected");
+    wallpaper_pict->init("/wallpaperNTSC.jpg");
+  }
+
+  if (DrawStyle::WALLPAPER.alpha)
+    wallpaper_pict->setVisible(true);
+  else
+    wallpaper_pict->setVisible(false);
+
+  wallpaper->add(wallpaper_pict);
+  wallpaper->draw();
+
+  boxstack->add(wallpaper);
+  boxstack->update(wallpaper);
+
+  OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
+  if (osdv) osdv->updateBackgroundColor(DrawStyle::WALLPAPER);
+}
+
+void Control::run()
+{
+  if (!initted) return;
+  irun = true;
+
+  // just in case
+  Video::getInstance()->signalOn();
+  Led::getInstance()->on();
+
+  doWallpaper();
+
+  if (crashed)
+  {
+    buildCrashedBox();
+  }
+  else
+  {
+    VConnect* vconnect = new VConnect();
+    boxstack->add(vconnect);
+    vconnect->run();
+  }
+
+
+  // FIXME Input::NA_SIGNAL is possibly obsolete now
+
+  std::unique_lock<std::mutex> lockWrapper(messageQueueMutex);  // locks. unlocks on out-of-scope
+
+  inputMan->start();
+
+  while(irun)
+  {
+    messageQueueCond.wait(lockWrapper, [&] { return !irun || !messages.empty(); });
+    logger->log("Control", Log::DEBUG, "woke");
+
+    if (!irun) break;
+
+    while(!messages.empty())
+    {
+      Message* m = messages.front();
+      messages.pop_front();
+
+      lockWrapper.unlock();
+
+      processMessage(m);
+      delete m;
+
+      lockWrapper.lock();
+    }
+  }
+
+  inputMan->stop();
+
+  boxstack->removeAllExceptWallpaper();
+  boxstack->remove(wallpaper);
+  delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL;
+}
+
+void Control::processMessage(Message* m)
+{
+    // FIXME - a slight modification - how if messagereceivers were to register
+    // themselves as receivers to avoid the calling-a-deleted-object problem
+    // then only deliver/register/unregister would have to be protected
+
+  logger->log("Control", Log::DEBUG, "processing message %i", m->message);
+
+
+  if ((m->p_to == Message::CONTROL) || (m->to == this)) // Maybe don't check m->to here? Always use predefined?
+  {
+    switch(m->message)
+    {
+      case Message::SHUTDOWN:
+      {
+        irun = false;
+        break;
+      }
+      // << FIXME OBSELETE
+      case Message::STOP_PLAYBACK:
+      {
+        handleCommand(Input::STOP); // an odd way of doing it, but so simple
+        break;
+      }
+      // Also connection_lost comes from player - anywhere else?
+      // FIXME OBSELETE >>
+
+
+      case Message::VDR_CONNECTED:
+      {
+        doJustConnected(static_cast<VConnect*>(m->from));
+        break;
+      }
+      case Message::SCREENSHOT:
+      {
+        logger->log("Osd", Log::NOTICE, "Screenshot Message arrived");
+        Osd::getInstance()->screenShot("out.jpg");
+        break;
+      }
+      case Message::CONNECTION_LOST:
+      {
+        doFromTheTop(true);
+        break;
+      }
+      case Message::INPUT_EVENT:
+      {
+        logger->log("Control", Log::NOTICE, "INPUT_EVENT %i", m->parameter);
+
+        handleCommand(m->parameter);
+        break;
+      }
+      case Message::CHANGE_LANGUAGE:
+      {
+        boxstack->removeAllExceptWallpaper();
+        boxstack->update(wallpaper);
+        I18n::initialize();
+        if (!VDR::getInstance()->isConnected()) { connectionLost(); break; }
+        VWelcome* vw = new VWelcome();
+        vw->draw();
+        boxstack->add(vw);
+        boxstack->update(vw);
+        break;
+      }
+      case Message::LAST_VIEW_CLOSE:
+      {
+        // Shouldn't be done like this. Some generic message pass back from vinfo perhaps
+        if (crashed)
+        {
+          crashed = false;
+          doFromTheTop(false);        
+        }
+      
+//        VWelcome* vw = new VWelcome();
+//        vw->draw();
+//        boxstack->add(vw);
+//        boxstack->update(vw);
+
+        break;
+      }
+      case Message::NEW_PICTURE:
+      {
+        //Log::getInstance()->log("Control", Log::DEBUG, "TVMedia NEW_PICTURE");
+        OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
+        if (osdv) osdv->informPicture(m->tag, reinterpret_cast<ImageIndex>(m->data));
+        break;
+      }
+      case Message::NEW_PICTURE_STATIC:
+      {
+        //Log::getInstance()->log("Control", Log::DEBUG, "TVMedia NEW_PICTURE %x %x",m->tag,m->parameter);
+        OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
+        if (osdv) osdv->informPicture(static_cast<unsigned long long>(m->tag) << 32LL, reinterpret_cast<ImageIndex>(m->data));
+        break;
+      }
+    }
+  }
+  else
+  {
+    /* FIXME
+    
+    Instead of sending through the boxstack, implement a more generic MessageReceiver interface
+    and have potential receivers register with something
+    When a message needs to be delivered, check if the receiver is still registered, if so, deliver the message
+    This could all be done using the existing big control mutex to keep it simple
+    */
+  
+    logger->log("Control", Log::DEBUG, "Sending message to boxstack");
+    boxstack->processMessage(m);
+  }
+}
+
+void Control::handleCommand(int button)
+{
+  if (isStandby && (button != Input::POWER)
+                && (button != Input::POWERON)
+                && (button != Input::POWEROFF))  return;
+
+  if (!connLost && boxstack->handleCommand(button)) return; // don't send to boxstack if connLost
+
+  // command was not handled
+
+  switch(button)
+  {
+    case Input::VOLUMEUP:
+    case Input::VOLUMEDOWN:
+    {
+      if (inputMan->handlesVolume()) // CEC volume handler?
+      {
+        if (button == Input::VOLUMEDOWN)
+          inputMan->volumeDown();
+        else
+          inputMan->volumeUp();
+      }
+      else
+      {
+        VVolume* v = new VVolume();
+        boxstack->add(v);
+        v->handleCommand(button); // this will draw+show
+      }
+      return;
+    }
+    case Input::MUTE:
+    {
+      if (inputMan->handlesVolume())
+      {
+        inputMan->volumeMute();
+      }
+      else
+      {
+        VMute* v = new VMute();
+        v->draw();
+        boxstack->add(v);
+        boxstack->update(v);
+      }
+      return;
+    }
+    case Input::POWER:
+    {
+      doStandby();
+      return;
+    }
+    case Input::POWERON:
+    {
+      doPowerOn();
+      return;
+    }
+    case Input::POWEROFF:
+    {
+      doPowerOff();
+      return;
+    }
+    case Input::OK:
+    {
+      // FIXME
+      if (!connLost) return; // if connLost, handle Input::OK
+      doFromTheTop(false);
+      return;
+    }
+    case Input::GO:
+    {
+      VSleeptimer* sleep = new VSleeptimer();
+      boxstack->add(sleep);
+      sleep->handleCommand(button); // this will draw+show
+      return;
+    }
+  }
+}
+
+/*
+void Control::sig1()
+{
+#ifdef DEV
+  Message* m = new Message(); // break into master mutex
+  m->message = Message::SCREENSHOT;
+  m->to = this;
+  postMessage(m);
+#endif
+}
+*/
+
+void Control::doStandby()
+{
+  if (isStandby)
+  {
+    doPowerOn();
+  }
+  else
+  {
+    doPowerOff();
+  }
+}
+
+
+void Control::doPowerOn()
+{
+  if (isStandby)
+  {
+    Video::getInstance()->signalOn();
+    Led::getInstance()->on();
+    InputMan::getInstance()->changePowerState(true);
+    isStandby = false;
+
+    VConnect* vconnect = new VConnect();
+    boxstack->add(vconnect);
+    vconnect->run();
+  }
+}
+
+void Control::doPowerOff()
+{
+  if (!isStandby)
+  {
+    VDR::getInstance()->shutdownVDR();
+    boxstack->removeAllExceptWallpaper();
+    Video::getInstance()->signalOff();
+    boxstack->update(wallpaper);
+
+    VDR::getInstance()->configSave("General", "Last Power State", "Off");
+    logger->unsetExternLogger();
+    VDR::getInstance()->disconnect();
+    Led::getInstance()->off();
+    InputMan::getInstance()->changePowerState(false);
+    isStandby = true;
+    Sleeptimer::getInstance()->shutdown();
+  }
+}
+
+void Control::doFromTheTop(bool which)
+{
+  if (isStandby) return;
+  if (which)
+  {
+    if (connLost)
+    {
+      logger->log("Control", Log::NOTICE, "Connection lost dialog already present");
+      return;
+    }
+  
+    logger->log("Control", Log::NOTICE, "Doing connection lost dialog");
+    connLost = new VInfo();
+    connLost->setSize(360, 200);
+    connLost->createBuffer();
+    if (Video::getInstance()->getFormat() == Video::PAL)
+      connLost->setPosition(190, 170);
+    else
+      connLost->setPosition(180, 120);
+    connLost->setOneLiner(tr("Connection lost"));
+    connLost->setDropThrough();
+    connLost->setBorderOn(1);
+    connLost->setTitleBarColour(DrawStyle::DANGER);
+    connLost->okButton();
+    connLost->draw();
+    boxstack->add(connLost);
+    boxstack->update(connLost);
+
+    clearMQInputEvents();
+  }
+  else
+  {
+    logger->unsetExternLogger();
+    VDR::getInstance()->disconnect();
+    boxstack->removeAllExceptWallpaper();
+    boxstack->update(wallpaper);
+    connLost = NULL;
+    
+    flushMessageQueue();
+    
+    // at this point, everything should be reset to first-go
+    
+    VConnect* vconnect = new VConnect();
+    boxstack->add(vconnect);
+    vconnect->run();
+  }
+}
+
+void Control::clearMQInputEvents()
+{
+  std::lock_guard<std::mutex> lg(messageQueueMutex); // Get the lock
+
+  MQueueI i = messages.begin();
+  while(i != messages.end())
+  {
+    Message* m = *i;
+    if (m->message == Message::INPUT_EVENT)
+    {
+      delete m;
+      i = messages.erase(i);
+    }
+    else
+    {
+      ++i;
+    }
+  }
+}
+
+void Control::doReboot()
+{
+
+  logger->unsetExternLogger();
+  VDR::getInstance()->disconnect();
+  // just kill it...
+  logger->log("Control", Log::NOTICE, "Reboot");
+#ifndef WIN32
+#ifndef VOMP_HAS_EXIT
+  // some plattforms, want a proper deinitialisation of their hardware before reboot
+  Osd::getInstance()->shutdown();
+  Audio::getInstance()->shutdown();
+  Video::getInstance()->shutdown();
+  InputMan::getInstance()->shutdown();
+
+  reboot(LINUX_REBOOT_CMD_RESTART);
+  // if  reboot is not allowed -> stop
+  stop();
+
+
+#else
+  stop();
+
+#ifdef __ANDROID__
+  exit(0);
+#endif
+
+#endif
+#endif //Would we support this on windows?
+}
+
+void Control::connectionLost()
+{
+  logger->unsetExternLogger();
+  Message* m = new Message(); // break into master mutex
+  m->message = Message::CONNECTION_LOST;
+  m->p_to = Message::CONTROL;
+  postMessage(m);
+}
+
+void Control::buildCrashedBox()
+{
+  VInfo* crash = new VInfo();
+  crash->setSize(360, 250);
+  crash->createBuffer();
+  if (Video::getInstance()->getFormat() == Video::PAL)
+    crash->setPosition(190, 146);
+  else
+    crash->setPosition(180, 96);
+  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.");
+  crash->setBorderOn(1);
+  crash->setTitleBarColour(DrawStyle::DANGER);
+  crash->okButton();
+  crash->setExitable();
+  crash->draw();
+  boxstack->add(crash);
+  boxstack->update(crash);
+}
+
+int Control::getLangPref(bool subtitle, const char* langcode)
+{
+  std::vector<struct ASLPref>::iterator itty=langcodes.begin();
+  char templangcode[4];
+  templangcode[0] = langcode[0];
+  templangcode[1] = langcode[1];
+  templangcode[2] = langcode[2];
+  templangcode[3] = '\0';
+  int langpos = 0;
+  while (itty != langcodes.end())
+  {
+    size_t pos = (*itty).langcode.find(templangcode);
+    if (pos != std::string::npos)
+    {
+      //vector<struct ASLPref>::iterator itty2=langcodes.begin();
+      for (unsigned int i = 0; i < langcodes.size(); i++)
+      {
+        int pref = 0;
+        if (subtitle)
+          pref = langcodes[i].subtitlepref;
+        else
+          pref = langcodes[i].audiopref;
+        if (pref < 0) break;
+
+        if (subtitle)
+        {
+          if (langcodes[i].subtitlepref==langpos) return i;
+        }
+        else
+        {
+          if (langcodes[i].audiopref==langpos) return i;
+        }
+      }
+      break;
+    }
+    itty++;
+    langpos++;
+  }
+  return langcodes.size(); //neutral
+}
+
+void Control::doJustConnected(VConnect* vconnect)
+{
+  I18n::initialize();
+  if (!VDR::getInstance()->isConnected()) { connectionLost(); return; }
+  logger->log("Control", Log::INFO, "Entering doJustConnected");
+  
+  Video* video = Video::getInstance();
+  Audio* audio = Audio::getInstance();  
+  boxstack->remove(vconnect);
+
+  VInfo* vi = new VInfo();
+  vi->setSize(400, 200);
+  vi->createBuffer();
+  if (video->getFormat() == Video::PAL)
+    vi->setPosition(170, 200);
+  else
+    vi->setPosition(160, 150);
+  vi->setOneLiner(tr("Connected, loading config"));
+  vi->draw();
+  boxstack->add(vi);
+  boxstack->update(vi);
+
+  // FIXME make config system
+
+  VDR* vdr = VDR::getInstance();
+  char* config;
+
+  // See if we're supposed to do network logging
+  config = vdr->configLoad("Advanced", "Network logging");
+  if (config && !STRCASECMP(config, "On"))
+  {
+    logger->log("Control", Log::INFO, "Turning on network logging");
+    logger->setExternLogger(vdr);
+  }  
+  else
+  {
+         logger->unsetExternLogger();
+    logger->log("Control", Log::INFO, "Turned off network logging");
+  }
+  if (config) delete[] config;
+
+  config = vdr->configLoad("Advanced", "Skin Name");
+  if (config)
+  {
+    const char **skinnames=SkinFactory::getSkinNames();
+    for (int i=0;i<SkinFactory::getNumberofSkins();i++)
+    {
+      if (!STRCASECMP(config, skinnames[i]))
+      {
+        SkinFactory::InitSkin(i);
+        break;
+      }
+    }
+    delete[] config;
+
+    if (wallpaper && wallpaper_pict)
+    {
+      if (DrawStyle::WALLPAPER.alpha)
+        wallpaper_pict->setVisible(true);
+      else
+        wallpaper_pict->setVisible(false);
+
+      wallpaper->draw();
+      boxstack->update(wallpaper);
+    }
+  }
+  else
+  {
+    SkinFactory::InitSkin(0);
+  }
+
+  // See if config says to override video format (PAL/NTSC)
+  config = vdr->configLoad("General", "Override Video Format");
+  if (config)
+  {
+    logger->log("Control", Log::DEBUG, "Override Video Format is present");
+
+    if (   (!strcmp(config, "PAL") && (video->getFormat() != Video::PAL))
+        || (!strcmp(config, "NTSC") && (video->getFormat() != Video::NTSC))
+        || (!strcmp(config, "PAL_M") && (video->getFormat() != Video::PAL_M))
+        || (!strcmp(config, "NTSC_J") && (video->getFormat() != Video::NTSC_J))
+        )
+    {
+      // Oh sheesh, need to switch format. Bye bye TV...
+
+      // Take everything down
+      boxstack->removeAllExceptWallpaper();
+      boxstack->remove(wallpaper);
+      delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL;
+
+      Osd* osd = Osd::getInstance();
+#ifndef __ANDROID__
+      osd->shutdown();
+#endif
+      video->shutdown();
+
+      inputMan->shutdown(); // need on raspberry shut not do any harm, hopefully
+      inputMan->init(); // FIXME this breaks badly now
+
+      // Get video and osd back up with the new mode
+      if (!strcmp(config, "PAL"))
+      {
+        logger->log("Control", Log::DEBUG, "Switching to PAL");
+        video->init(Video::PAL);
+      }
+      else if (!strcmp(config, "NTSC"))
+      {
+        logger->log("Control", Log::DEBUG, "Switching to NTSC");
+        video->init(Video::NTSC);
+      } else if (!strcmp(config, "PAL_M"))
+      {
+        logger->log("Control", Log::DEBUG, "Switching to PAL_M");
+        video->init(Video::PAL_M);
+      } else if (!strcmp(config, "NTSC_J"))
+      {
+        logger->log("Control", Log::DEBUG, "Switching to NTSC_J");
+        video->init(Video::NTSC_J);
+      }
+      delete[] config;
+
+#ifndef __ANDROID__
+      //we do not init twice
+      osd->init();
+#endif
+
+      // Put the wallpaper back
+      doWallpaper();
+
+      // Re add the vinfo
+      vi = new VInfo();
+      vi->setSize(400, 200);
+      vi->createBuffer();
+      if (video->getFormat() == Video::PAL)
+        vi->setPosition(170, 200);
+      else
+        vi->setPosition(160, 150);
+
+      vi->setOneLiner(tr("Connected, loading config"));
+      vi->draw();
+      boxstack->add(vi);
+      boxstack->update(vi);
+    }
+    else
+    {
+      logger->log("Control", Log::DEBUG, "Already in requested mode, or request was not 'PAL' or 'NTSC'");
+    }
+  }
+  else
+  {
+    logger->log("Control", Log::DEBUG, "Phew, no dangerous on-the-fly mode switching to do!");
+  }
+
+  // Power off if first boot and config says so
+  if (firstBoot)
+  {
+    firstBoot = false;
+
+    logger->log("Control", Log::DEBUG, "Load power after boot");
+
+    config = vdr->configLoad("General", "Power After Boot");
+
+    if (config)
+    {
+      if (!STRCASECMP(config, "On"))
+      {
+        logger->log("Control", Log::INFO, "Config says Power After Boot = On");
+      }
+      else if (!STRCASECMP(config, "Off"))
+      {
+        logger->log("Control", Log::INFO, "Config says Power After Boot = Off");
+        doStandby();
+        delete[] config;
+        return; // quit here
+      }
+      else if (!STRCASECMP(config, "Last state"))
+      {
+        char* lastPowerState = vdr->configLoad("General", "Last Power State");
+        if (lastPowerState)
+        {
+          if (!STRCASECMP(lastPowerState, "On"))
+          {
+            logger->log("Control", Log::INFO, "Config says Last Power State = On");
+          }
+          else if (!STRCASECMP(lastPowerState, "Off"))
+          {
+            logger->log("Control", Log::INFO, "Config says Last Power State = Off");
+            doStandby();
+            delete[] config;
+            return; // quit here
+          }
+          else
+          {
+            logger->log("Control", Log::INFO, "Config General/Last Power State not understood");
+          }
+        }
+        else
+        {
+          logger->log("Control", Log::INFO, "Config General/Last Power State not found");
+        }
+      }
+      else
+      {
+        logger->log("Control", Log::INFO, "Config/Power After Boot not understood");
+      }
+      delete[] config;
+    }
+    else
+    {
+      logger->log("Control", Log::INFO, "Config General/Power After Boot not found");
+    }
+  }
+
+
+  // Go S-Video if config says so
+
+  config = vdr->configLoad("TV", "Connection");
+
+  if (config)
+  {
+    if (!STRCASECMP(config, "S-Video"))
+    {
+      logger->log("Control", Log::INFO, "Switching to S-Video as Connection=%s", config);
+      video->setConnection(Video::SVIDEO);
+    } else  if (!STRCASECMP(config, "HDMI"))
+    {
+      logger->log("Control", Log::INFO, "Switching to HDMI as Connection=%s", config);
+      video->setConnection(Video::HDMI);
+    } else  if (!STRCASECMP(config, "HDMI3D"))
+    {
+      logger->log("Control", Log::INFO, "Switching to HDMI3D as Connection=%s", config);
+      video->setConnection(Video::HDMI3D);
+    }
+    else
+    {
+      logger->log("Control", Log::INFO, "Switching to RGB/Composite as Connection=%s", config);
+      video->setConnection(Video::COMPOSITERGB);
+    }
+    delete[] config;
+  }
+  else
+  {
+    logger->log("Control", Log::INFO, "Config TV/S-Video not found");
+  }
+
+  // Set to shutdown VDR if config says
+  
+  config = vdr->configLoad("General", "VDR shutdown");
+  if (config)
+  {
+    if (!STRCASECMP(config, "On"))
+    {
+      logger->log("Control", Log::INFO, "Shutdown VDR when shutting down vomp");
+      vdr->setVDRShutdown(true);
+    }
+    else if (!STRCASECMP(config, "Off"))
+    {
+      logger->log("Control", Log::INFO, "Shutdown only vomp");
+      vdr->setVDRShutdown(false);
+    }
+  }
+  else
+  {
+    logger->log("Control", Log::INFO, "Default shutdown only vomp");
+    vdr->setVDRShutdown(false); // Default
+  }
+          
+  // Get TV aspect ratio
+
+  config = vdr->configLoad("TV", "Aspect");
+  if (config)
+  {
+    if (!STRCASECMP(config, "16:9"))
+    {
+      logger->log("Control", Log::INFO, "/// Switching to TV aspect 16:9");
+      video->setTVsize(Video::ASPECT16X9);
+    }
+    else
+    {
+      logger->log("Control", Log::INFO, "/// Switching to TV aspect 4:3");
+      video->setTVsize(Video::ASPECT4X3);
+    }
+    delete[] config;
+  }
+  else
+  {
+    logger->log("Control", Log::INFO, "Config TV/Aspect type not found, going 4:3");
+    video->setTVsize(Video::ASPECT4X3);
+  }
+
+  config = vdr->configLoad("TV", "Widemode");
+  if (config)
+  {
+    if (!STRCASECMP(config, "Letterbox"))
+    {
+      logger->log("Control", Log::INFO, "Setting letterbox mode");
+      video->setMode(Video::LETTERBOX);
+    }
+    else
+    {
+      logger->log("Control", Log::INFO, "Setting chop-sides mode");
+      video->setMode(Video::NORMAL);
+    }
+    delete[] config;
+  }
+  else
+  {
+#ifdef __ANDROID__
+        logger->log("Control", Log::INFO, "Config TV/Widemode not found, Setting letterbox mode");
+        video->setMode(Video::LETTERBOX);
+#else
+    logger->log("Control", Log::INFO, "Config TV/Widemode not found, Setting chop-sides mode");
+    video->setMode(Video::NORMAL);
+#endif
+  }
+
+  config = vdr->configLoad("Advanced", "TCP receive window");
+  if (config)
+  {
+    size_t newTCPsize = atoi(config);
+    delete[] config;
+
+    logger->log("Control", Log::INFO, "Setting TCP window size %i", newTCPsize);
+    vdr->setReceiveWindow(newTCPsize);
+  }
+  else
+  {
+    logger->log("Control", Log::INFO, "TCP window size not found, setting 2048");
+    if (DEFAULT_TCP_WINDOWSIZE) vdr->setReceiveWindow(2048); // Default
+  }
+
+  config = vdr->configLoad("Advanced", "Font Name");
+  if (config)
+  {
+       Osd::getInstance()->setFont(config);
+    logger->log("Control", Log::INFO, "Setting Font to %s", config);
+    delete[] config;
+
+  }
+
+
+  // Set recording list type
+
+#ifdef ADVANCED_MENUES
+  config = vdr->configLoad("Advanced", "Menu type");
+
+  if (config)
+  {
+    if (!STRCASECMP(config, "Advanced"))
+    {
+      logger->log("Control", Log::INFO, "Switching to Advanced menu");
+      advMenus = true;
+    }
+    else
+    {
+      logger->log("Control", Log::INFO, "Switching to Classic menu");
+      advMenus = false;
+    }
+    delete[] config;
+  }
+  else
+  {
+    logger->log("Control", Log::INFO, "Config General/menu type not found");
+    advMenus = true;
+  }
+#endif
+
+  config = vdr->configLoad("Advanced", "Disable WOL");
+  if (config)
+  {
+    if (!STRCASECMP(config, "Yes"))
+    {
+      logger->log("Control", Log::INFO, "Config says disable WOL");
+      Wol::getInstance()->setEnabled(false);
+    }
+    else
+    {
+      logger->log("Control", Log::INFO, "Config says enable WOL");
+      Wol::getInstance()->setEnabled(true);
+    }
+
+    delete[] config;
+  }
+  else
+  {
+    logger->log("Control", Log::INFO, "By default, enable WOL");
+    Wol::getInstance()->setEnabled(true);
+  }
+  /* device dependend config */
+  audio->loadOptionsFromServer(vdr);
+  video->loadOptionsFromServer(vdr);
+  inputMan->loadOptionsFromServer(vdr);
+
+  video->executePendingModeChanges();
+  // config done
+
+  // Save power state = on
+
+  vdr->configSave("General", "Last Power State", "On");
+
+  // Make sure connection didn't die
+  if (!vdr->isConnected())
+  {
+    Control::getInstance()->connectionLost();
+  }
+  else
+  {
+    boxstack->remove(vi);
+
+    VWelcome* vw = new VWelcome();
+    vw->draw();
+    boxstack->add(vw);
+    boxstack->update(vw);
+
+    // Enter pre-keys here
+//    handleCommand(Input::OK);
+//    handleCommand(Input::THREE);
+//    handleCommand(Input::SIX);
+//    handleCommand(Input::OK);
+//    handleCommand(Input::UP);
+//    handleCommand(Input::PLAY);
+//    handleCommand(Input::DOWN);
+//    handleCommand(Input::DOWN);
+//    handleCommand(Input::DOWN);
+//    handleCommand(Input::RIGHT);
+//    handleCommand(Input::RED);
+  }
+}
diff --git a/control.h b/control.h
new file mode 100644 (file)
index 0000000..6ed82be
--- /dev/null
+++ b/control.h
@@ -0,0 +1,113 @@
+/*
+    Copyright 2004-2020 Chris Tallon
+
+    This file is part of VOMP.
+
+    VOMP is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    VOMP is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
+*/
+
+#ifndef COMMAND_H
+#define COMMAND_H
+
+#ifndef WIN32
+#include <unistd.h> // for reboot
+#include <linux/reboot.h>
+#include <sys/reboot.h>
+#endif
+
+#include <time.h>
+#ifndef WIN32
+#include <pthread.h>   // why?
+#endif
+
+#include <string>
+#include <vector>
+
+#include "defines.h"
+#include "messagequeue.h"
+
+class VConnect;
+class Message;
+class InputMan;
+class Boxx;
+class BoxStack;
+class Log;
+class VInfo;
+class WJpeg;
+
+struct ASLPref
+{
+  std::string langcode;
+  int audiopref;
+  int subtitlepref;
+};
+
+typedef std::vector<struct ASLPref> ASLPrefList;
+
+class Control : public MessageQueue
+{
+  public:
+    Control();
+    ~Control();
+    static Control* getInstance();
+
+    int init(bool crashed = false);
+    int shutdown();
+    void run();
+    void stop();
+    void doReboot();
+    void connectionLost();
+
+    void setAdvMenus(bool adv) { advMenus = adv; };
+    bool isAdvMenus() { return advMenus; };
+    int getLangPref(bool subtitle,const char* langcode);
+    void setSubDefault(int subon) { subdefault = subon; };
+    int getSubDefault() { return subdefault; };
+    ASLPrefList &getASLList() { return langcodes; };
+
+  private:
+    void handleCommand(int);
+    void doStandby();
+    void doPowerOn();
+    void doPowerOff();
+    void doJustConnected(VConnect* vconnect);
+    void doWallpaper();
+    void doFromTheTop(bool which);  // true - show vinfo,wait. false - del vinfo,restart
+    void buildCrashedBox();
+//    void sig1();
+    void clearMQInputEvents();
+
+    static Control* instance;
+
+    Log* logger;
+    BoxStack* boxstack;
+    InputMan* inputMan;
+
+    bool initted{};
+    bool irun{};
+    bool isStandby{};
+    bool firstBoot{true};
+    Boxx* wallpaper{};
+    WJpeg* wallpaper_pict{};
+    VInfo* connLost{};
+    bool crashed{};
+
+    bool advMenus{};
+    ASLPrefList langcodes;
+    int subdefault;
+        
+    void processMessage(Message* m);
+};
+
+#endif
index 7f2d4c14bb26124365024bac1821a5f2c0ab5c7e..b7059c5150f70dcd16dbe6f8f2c031037414cd29 100644 (file)
@@ -533,14 +533,14 @@ int DemuxerTS::processTS(UCHAR* buf)
             bool dolby=false;
             int selected=-1;
             int prefered=-1;
-            Command* command = Command::getInstance();
+            Control* control = Control::getInstance();
 
             if (channelinfo.numDPids > 0 && Audio::getInstance()->maysupportAc3())
             {
                ULONG j = 0;
                while (j < channelinfo.numDPids)
                {
-                       int newpref = command->getLangPref(false, channelinfo.dpids[j].desc);
+                       int newpref = control->getLangPref(false, channelinfo.dpids[j].desc);
                        if (Audio::getInstance()->streamTypeSupported(channelinfo.dpids[j].type)
                                        && (prefered < 0 || newpref < prefered))
                        {
@@ -557,7 +557,7 @@ int DemuxerTS::processTS(UCHAR* buf)
                ULONG j = 0;
                while (j < channelinfo.numAPids)
                {
-                       int newpref = command->getLangPref(false, channelinfo.apids[j].desc);
+                       int newpref = control->getLangPref(false, channelinfo.apids[j].desc);
                        if (Audio::getInstance()->streamTypeSupported(channelinfo.apids[j].type)
                                        && (prefered < 0 || newpref < prefered))
                        {
@@ -585,7 +585,7 @@ int DemuxerTS::processTS(UCHAR* buf)
                ULONG j = 0;
                while (j < channelinfo.numSPids)
                {
-                       int newpref = command->getLangPref(true, channelinfo.spids[j].desc);
+                       int newpref = control->getLangPref(true, channelinfo.spids[j].desc);
                        if ( (prefered < 0 || newpref < prefered))
                        {
                                selected = j;
index 930605cbe66af2ed372bb2bb343fda4ad7f710a2..b11547b0ff9c21c5c2f269151e55edb306866dcc 100644 (file)
--- a/event.cc
+++ b/event.cc
@@ -20,7 +20,7 @@
 
 #include "event.h"
 #include "log.h"
-#include "command.h"
+#include "control.h"
 #include "movieinfo.h"
 #include "seriesinfo.h"
 #include "vdr.h"
@@ -44,7 +44,7 @@ void Event::loadinfos(UINT channelid)
                             id, channelid, movieID, seriesID, episodeID);
   }
 
-  if (!vdr->isConnected()) Command::getInstance()->connectionLost();
+  if (!vdr->isConnected()) Control::getInstance()->connectionLost();
 
   if (movieID != 0)
   {
@@ -57,5 +57,5 @@ void Event::loadinfos(UINT channelid)
     Log::getInstance()->log("Event", Log::DEBUG, "Got Scraper SeriesInfo");
   }
 
-  if (!vdr->isConnected()) Command::getInstance()->connectionLost();
+  if (!vdr->isConnected()) Control::getInstance()->connectionLost();
 }
index 528f8837a01ef53f726b5b277b69b32914e40a0d..e3b14296e90851cdd215f52ca06f06d1d474212c 100644 (file)
@@ -783,7 +783,7 @@ const I18n::tI18nPhrase I18n::Phrases[] =
     "Verbinding mislukt",
     "55",
   },
-  // Command
+  // Control
   { "Connected, loading config",
     "Verbunden, lade Einstellungen",
     "Ansluten, laddar konfigurering",
diff --git a/main.cc b/main.cc
index aca7fa156ab7be90cff790a3657f827285dbdb53..34531007f1361de779f06ca2c946f497aeaf1cee 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -43,7 +43,7 @@
 #include "timers.h"
 #include "vdr.h"
 #include "boxstack.h"
-#include "command.h"
+#include "control.h"
 #include "inputman.h"
 #include "wol.h"
 #include "vsleeptimer.h"
@@ -80,7 +80,7 @@ Led* led;
 Osd* osd;
 Timers* timers;
 BoxStack* boxstack;
-Command* command;
+Control* control;
 VDR* vdr;
 Video* video;
 Audio* audio;
@@ -141,11 +141,11 @@ int main(int argc, char** argv)
   video      = new Video_TYPE();
 
   boxstack   = new BoxStack();
-  command    = new Command();
+  control    = new Control();
   wol        = new Wol();
   sleeptimer = new Sleeptimer();
 
-  if (!logger || !timers || !inputMan || !led || !osd || !video || !audio || !boxstack || !command || !wol || !sleeptimer)
+  if (!logger || !timers || !inputMan || !led || !osd || !video || !audio || !boxstack || !control || !wol || !sleeptimer)
   {
     printf("Could not create objects. Memory problems?\n");
     shutdown(1);
@@ -323,14 +323,14 @@ int main(int argc, char** argv)
     shutdown(1);
   }
 
-  success = command->init(crashed);
+  success = control->init(crashed);
   if (success)
   {
-    logger->log("Core", Log::INFO, "Command module initialised");
+    logger->log("Core", Log::INFO, "Control module initialised");
   }
   else
   {
-    logger->log("Core", Log::EMERG, "Command module failed to initialise");
+    logger->log("Core", Log::EMERG, "Control module failed to initialise");
     shutdown(1);
   }
 
@@ -341,7 +341,7 @@ int main(int argc, char** argv)
   // Run main loop ---------------------------------------------------------------------------------------------------
 
   // Ok, all major device components and other bits are loaded and ready
-  command->run();
+  control->run();
 
   // When that returns quit ------------------------------------------------------------------------------------------
   shutdown(0);
@@ -365,7 +365,7 @@ void threadSignalReceiverFunction()
 
     logger->log("Core", Log::NOTICE, "Signal received: %i", sig);
 
-    if ((sig == SIGINT) || (sig == SIGTERM)) command->stop();
+    if ((sig == SIGINT) || (sig == SIGTERM)) control->stop();
   }
 }
 
@@ -382,13 +382,13 @@ void shutdown(int code)
     logger->log("Core", Log::NOTICE, "BoxStack module shut down");
   }
 
-  // FIXME, send a del all to boxstack first, then get rid of it after command?
-  if (command) // shut down command here in case views have posted messages
+  // FIXME, send a del all to boxstack first, then get rid of it after control?
+  if (control) // shut down control here in case views have posted messages
   {
-    command->shutdown();
-    delete command;
-    command = NULL;
-    logger->log("Core", Log::NOTICE, "Command module shut down");
+    control->shutdown();
+    delete control;
+    control = NULL;
+    logger->log("Core", Log::NOTICE, "Control module shut down");
   }
 
   if (vdr)
index e362ec266be68b3b37d783f065e0a22764e52c81..9b442f5907517d927da35ef9defa9751e5b953c2 100644 (file)
--- a/message.h
+++ b/message.h
@@ -94,7 +94,3 @@ class Message
 };
 
 #endif
-
-// FIXME idea - instead of always having to specify a real pointer in the "to" variable (meaning clients may have to
-// run Command::getInstance() for e.g.), how about having some constant values for well known targets. Then
-// clients may not need the #include "command.h"
index ee66ea4827586acb2d619492ae7163ad3d16d915..88aedcfbe3f8139366a4ed134d12eeb989c8c47f 100644 (file)
@@ -1,4 +1,4 @@
-OBJ_COMMON = command.o thread.o timers.o i18n.o udp4.o udp6.o vdpc.o tcp.o         \
+OBJ_COMMON = control.o thread.o timers.o i18n.o udp4.o udp6.o vdpc.o tcp.o         \
              message.o messagequeue.o wol.o audio.o video.o log.o                  \
              vdr.o recman.o recording.o recinfo.o channel.o rectimer.o event.o     \
              directory.o mark.o option.o vfeed.o afeed.o                           \
index 2b18a3570562f02e33c1acb33daa46b9f4d8edff..2ad47c5e6f7736ced9896133b244e24ad36b0dfb 100644 (file)
@@ -20,7 +20,7 @@
 #include "videoomx.h"
 #include "surfaceopengl.h"
 #include "message.h"
-#include "command.h"
+#include "control.h"
 
 #include "osdopengl.h"
 
index b0bd6e14c31e9c4e458b4dccda27d68c4f6906cf..c09bba44cc168df5ce58fb93e8e28ac1fbae783d 100644 (file)
@@ -21,7 +21,7 @@
 #include "surfacevector.h"
 #include "vdr.h"
 #include "vdrresponsepacket.h"
-#include "command.h"
+#include "control.h"
 #include "message.h"
 
 // The next section is activated, if the magick++ PictureReader is provided, it should be available for many POSIX platforms
index a901cda6df39c852a7db09fee56a8c4281627c56..1cbaae7347ae9222bdc8e2dbd21f91d915f96bb2 100644 (file)
@@ -247,7 +247,7 @@ class OsdVector : public Osd
        virtual void getScreenSize(int &width, int &height)=0;
        virtual void getRealScreenSize(int &width, int &height)=0;
 
-       // should be only called from command thread
+       // should be only called from control thread
        void informPicture(LoadIndex index, ImageIndex i_index);
 
 
@@ -312,7 +312,7 @@ class OsdVector : public Osd
 
        bool processReceivedPictures();
 
-       // should be called from command thread
+       // should be called from control thread
        void receivePicture(VDR_ResponsePacket *vresp);
 
        void addStaticImage(unsigned int id);
index 16983323956eb32969d77b768e8e8cdcc6308663..2b6977831e2e15dceb96083a61dad8e84d0154f7 100644 (file)
@@ -27,7 +27,7 @@
 
 
 #include "message.h"
-#include "command.h"
+#include "control.h"
 
 
 
index 5e86c4ab6768cc8a68275e79299f2caa65317921..dd48b6cab0734044f3f2286290305ab5fb6b095a 100644 (file)
@@ -1246,7 +1246,7 @@ void  OsdWinVector::createPicture(struct PictureInfo& pict_inf)
                        m->message = Message::NEW_PICTURE_STATIC;
                        m->tag = pict_inf.lindex >> 32LL;
                }
-               MessageQueue::getInstance()->postMessage(m); // inform command about new picture
+               MessageQueue::getInstance()->postMessage(m); // inform control about new picture
 
        } else {
                pict_inf.decoder->freeReference(pict_inf.reference);
index 06d0dfc181225f98f2c707ef1f35f23a30d905cc..b4111c05e1639522992630789dfd1ef48c58c238 100644 (file)
@@ -35,7 +35,7 @@
 #include "channel.h"
 #include "dvbsubtitles.h"
 #include "osdreceiver.h"
-#include "command.h"
+#include "control.h"
 
 #include "playervideolive.h"
 
@@ -735,14 +735,14 @@ void PlayerVideoLive::threadMethod()
           int selected = -1;
           int prefered = -1;
 
-          Command* command = Command::getInstance();
+          Control* control = Control::getInstance();
 
           if (chan->numDPids > 0 && audio->maysupportAc3())
           {
             ULONG j = 0;
             while (j < chan->numDPids)
             {
-              int newpref = command->getLangPref(false, chan->dpids[j].desc);
+              int newpref = control->getLangPref(false, chan->dpids[j].desc);
               if (Audio::getInstance()->streamTypeSupported(chan->dpids[j].type) && (prefered < 0 || newpref < prefered))
               {
                 selected = j;
@@ -758,7 +758,7 @@ void PlayerVideoLive::threadMethod()
             ULONG j = 0;
             while (j < chan->numAPids)
             {
-              int newpref = command->getLangPref(false, chan->apids[j].desc);
+              int newpref = control->getLangPref(false, chan->apids[j].desc);
               if (Audio::getInstance()->streamTypeSupported(chan->apids[j].type) && (prefered < 0 || newpref < prefered))
               {
                 selected = j;
@@ -798,7 +798,7 @@ void PlayerVideoLive::threadMethod()
             ULONG j = 0;
             while (j < chan->numSPids)
             {
-              int newpref = command->getLangPref(true, chan->spids[j].desc);
+              int newpref = control->getLangPref(true, chan->spids[j].desc);
               if ((prefered < 0 || newpref < prefered))
               {
                 selected = j;
@@ -816,7 +816,7 @@ void PlayerVideoLive::threadMethod()
             {
               firstStart = false;
 
-              if (command->getSubDefault())
+              if (control->getSubDefault())
                 turnSubtitlesOn(true);
               else
                 turnSubtitlesOn(false);
index 74e22f227eff4220bc1e5f6ade91bee910ebbba7..96b7d78bb589a856a9e52735b38b51f6b3d8c5d9 100644 (file)
@@ -91,7 +91,7 @@ int PlayerVideoRec::init(bool p_isPesRecording, double framespersecond)
   video->blank();
   audio->stop();
 
-  if (Command::getInstance()->getSubDefault())
+  if (Control::getInstance()->getSubDefault())
     turnSubtitlesOn(true);
   else
     turnSubtitlesOn(false);
index 908f4ee633d799de40b3307f1a55248fa74700d1..21985681eba4e2f7f003b9afcee5be060b10360d 100644 (file)
@@ -23,7 +23,7 @@
 #include "log.h"
 #include "demuxer.h"
 #include "demuxerts.h"
-#include "command.h"
+#include "control.h"
 #include "seriesinfo.h"
 #include "movieinfo.h"
 
@@ -109,7 +109,7 @@ void Recording::loadRecInfo()
   recInfo = vdr->getRecInfo(fileName);
   Log::getInstance()->log("Recording", Log::DEBUG, "Recording has loaded recInfo %p", recInfo);
   
-  if (!vdr->isConnected()) Command::getInstance()->connectionLost();
+  if (!vdr->isConnected()) Control::getInstance()->connectionLost();
 
   if (movieInfo) delete movieInfo;
   if (seriesInfo) delete seriesInfo;
@@ -122,7 +122,7 @@ void Recording::loadRecInfo()
   Log::getInstance()->log("Recording", Log::DEBUG, "Got Scraper EventType %d %d %d",
                  movieID, seriesID, episodeID);
 
-  if (!vdr->isConnected()) Command::getInstance()->connectionLost();
+  if (!vdr->isConnected()) Control::getInstance()->connectionLost();
 
   if (movieID != 0)
   {
@@ -136,7 +136,7 @@ void Recording::loadRecInfo()
   }
 
 
-  if (!vdr->isConnected()) Command::getInstance()->connectionLost();
+  if (!vdr->isConnected()) Control::getInstance()->connectionLost();
 
 }
 
@@ -155,7 +155,7 @@ void Recording::dropRecInfo()
 void Recording::loadMarks()
 {
   markList = vdr->getMarks(fileName);
-  if (!VDR::getInstance()->isConnected()) Command::getInstance()->connectionLost();
+  if (!VDR::getInstance()->isConnected()) Control::getInstance()->connectionLost();
 }
 
 bool Recording::isRadio(bool &h264)
@@ -186,7 +186,7 @@ bool Recording::isRadio(bool &h264)
   free(buffer);
 
   vdr->stopStreaming();
-  if (!VDR::getInstance()->isConnected()) Command::getInstance()->connectionLost();
+  if (!VDR::getInstance()->isConnected()) Control::getInstance()->connectionLost();
   
   Log::getInstance()->log("Recording", Log::DEBUG, "Recording has messed about and worked out radio = %u", !hasVideo);
 
index a13d9038d1d14ef55df0bc40551899ba36ce7e5b..2874e02519c4a8091a9f2d5175a4db818bc03d85 100644 (file)
@@ -20,7 +20,7 @@
 #include "defines.h"
 #include "video.h"
 #include "colour.h"
-#include "command.h"
+#include "control.h"
 #include "i18n.h"
 #include "boxstack.h"
 #include "message.h"
@@ -163,8 +163,8 @@ void VConnect::threadMethod()
       logger->log("VConnect", Log::DEBUG, "Connected ok, doing login");
       unsigned int version_server_min, version_server_max, version_client;
       int subtitles;
-      success = vdr->doLogin(&version_server_min, &version_server_max, &version_client, Command::getInstance()->getASLList(), subtitles);
-      Command::getInstance()->setSubDefault(subtitles);
+      success = vdr->doLogin(&version_server_min, &version_server_max, &version_client, Control::getInstance()->getASLList(), subtitles);
+      Control::getInstance()->setSubDefault(subtitles);
 
       if (!success)
       {
diff --git a/vdr.cc b/vdr.cc
index d2d1dc085ea62e29c39b79a3a63573b331b4cc75..632a6b8eb26360c5c020bf8b0cf039e57795c574 100644 (file)
--- a/vdr.cc
+++ b/vdr.cc
@@ -26,7 +26,7 @@
 #include "wol.h"
 #include "vdrrequestpacket.h"
 #include "vdrresponsepacket.h"
-#include "command.h"
+#include "control.h"
 #ifdef VOMP_MEDIAPLAYER
 #include "media.h"
 #include "mediaprovider.h"
@@ -442,10 +442,10 @@ void VDR::connectionDied()
     }
   }
   edMutex.unlock();
-  // Ok, all event receviers should be dealt with. just in case there weren't any, inform command
+  // Ok, all event receviers should be dealt with. just in case there weren't any, inform control
   logger->log("VDR", Log::DEBUG, "edUnlock at end of connectionDied");
 
-  Command::getInstance()->connectionLost();
+  Control::getInstance()->connectionLost();
 }
 
 bool VDR::ed_cb_find(EDReceiver* edr, void* userTag)
@@ -1374,7 +1374,7 @@ MediaList* VDR::getMediaList(const MediaURI * root)
     
   SerializeBuffer* vresp = doRequestResponse(vrp,request.command);
   if (!vresp) {
-    Command::getInstance()->connectionLost();
+    Control::getInstance()->connectionLost();
     return NULL;
   }
   
@@ -1406,7 +1406,7 @@ int VDR::openMedium(ULONG channel,const MediaURI *uri,  ULLONG * size, ULONG x,
   }
   SerializeBuffer* vresp = doRequestResponse(vrp,request.command);
   if (!vresp) {
-    Command::getInstance()->connectionLost();
+    Control::getInstance()->connectionLost();
     return -1;
   }
   ULONG flags=0;
@@ -1434,7 +1434,7 @@ int VDR::getMediaBlock(ULONG channel, ULLONG position, ULONG maxAmount, ULONG* a
   }
   SerializeBuffer* vresp = doRequestResponse(vrp,request.command);
   if (!vresp) {
-    Command::getInstance()->connectionLost();
+    Control::getInstance()->connectionLost();
     return -1;
   }
   
@@ -1463,7 +1463,7 @@ int VDR::getMediaInfo(ULONG channel, MediaInfo * result) {
   }
   SerializeBuffer* vresp = doRequestResponse(vrp,request.command);
   if (!vresp) {
-    Command::getInstance()->connectionLost();
+    Control::getInstance()->connectionLost();
     return -1;
   }
 
@@ -1491,7 +1491,7 @@ int VDR::closeMediaChannel(ULONG channel) {
   }
   SerializeBuffer* vresp = doRequestResponse(vrp,request.command);
   if (!vresp) {
-    Command::getInstance()->connectionLost();
+    Control::getInstance()->connectionLost();
     return -1;
   }
   ULONG flags;
diff --git a/vdr.h b/vdr.h
index a7bc8d0a6a69a71844eba47bed98dd65328c7f1a..ad00955af3d091412af439443bf0a46b57221b2c 100644 (file)
--- a/vdr.h
+++ b/vdr.h
@@ -41,7 +41,7 @@
 #include "eventdispatcher.h"
 #include "i18n.h"
 #include "log.h"
-#include "command.h"
+#include "control.h"
 #include "tcp.h"
 
 class RecInfo;
index a9412937ea5f6025346fb4206ed311d7290bb53f..b6f74b37ae4fd7b47b1529786b404f5d66ce712e 100644 (file)
@@ -26,7 +26,7 @@
 #include "log.h"
 #include "vinfo.h"
 #include "message.h"
-#include "command.h"
+#include "control.h"
 #include "messagequeue.h"
 #include "video.h"
 #include "input.h"
@@ -251,7 +251,7 @@ void VEpgSetTimer::doit()
 
   if (!vdr->isConnected())
   {
-    Command::getInstance()->connectionLost();
+    Control::getInstance()->connectionLost();
   }
 
   if (ret == 0) logger->log("VEPGST", Log::DEBUG, "Success");
index d56dae8a211771166d333b62c6c6efcf2586ae38..4262dc98fe98c3feff7ca3a06c221194a1dbff0e 100644 (file)
@@ -27,7 +27,7 @@
 #include "colour.h"
 #include "video.h"
 #include "i18n.h"
-#include "command.h"
+#include "control.h"
 #include "boxstack.h"
 #include "event.h"
 #include "channel.h"
index 6aca5b8a4202c9756c1c0def97fe4e7483eb19eb..f1fff11258aa1c95e0422499dc07b891bbd59f56 100644 (file)
@@ -35,7 +35,7 @@
 #include "vinfo.h"
 #include "i18n.h"
 #include "message.h"
-#include "command.h"
+#include "control.h"
 #include "mediaoptions.h"
 #include "mediaplayer.h"
 #include "log.h"
@@ -761,7 +761,7 @@ void VMediaView::processMessage(Message* m)
           player->shutdown();
           player=NULL;
         }
-        Command::getInstance()->connectionLost();
+        Control::getInstance()->connectionLost();
         break;
     }
   }
index 20b9be979c3ba8b7a8df8aa8f95f3488e90db772..95c5fbf2e2baeaec2f6b549de08397d078ea0c39 100644 (file)
--- a/vopts.cc
+++ b/vopts.cc
@@ -32,7 +32,7 @@
 #include "vdr.h"
 #include "messagequeue.h"
 #include "message.h"
-#include "command.h"
+#include "control.h"
 #include "staticartwork.h"
 
 #ifdef VOMP_PLATTFORM_MVP
@@ -464,12 +464,12 @@ void VOpts::doSave()
                if (options[i]->userSetChoice == 1)
                {
                        Log::getInstance()->log("Options", Log::DEBUG, "Setting classic menu");
-                       Command::getInstance()->setAdvMenus(false);
+                       Control::getInstance()->setAdvMenus(false);
                }
                else
                {
                        Log::getInstance()->log("Options", Log::DEBUG, "Setting advanced menu");
-                       Command::getInstance()->setAdvMenus(true);
+                       Control::getInstance()->setAdvMenus(true);
                }
                break;
         }
index deacb62793805b448d876b6bb25fc76d93370afb..71d243c8502d163fe6670af87cc541e3ad64680e 100644 (file)
@@ -17,7 +17,7 @@
     along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
 */
 
-#include "command.h"
+#include "control.h"
 #include "osd.h"
 #include "wsymbol.h"
 #include "recording.h"
@@ -46,7 +46,7 @@ VRadioRec::VRadioRec(Recording* rec)
   startMargin = 0;
   endMargin = 0;
 
-  player = new PlayerRadioRec(Command::getInstance(), this);
+  player = new PlayerRadioRec(Control::getInstance(), this);
 
   char* cstartMargin = vdr->configLoad("Timers", "Start margin");
   char* cendMargin = vdr->configLoad("Timers", "End margin");
@@ -148,7 +148,7 @@ void VRadioRec::go(bool resume)
 
     if (!vdr->isConnected())
     {
-      Command::getInstance()->connectionLost();
+      Control::getInstance()->connectionLost();
       return;
     }
 
@@ -313,7 +313,7 @@ void VRadioRec::processMessage(Message* m)
     {
       case PlayerRadioRec::CONNECTION_LOST: // connection lost detected
       {
-        // I can't handle this, send it to command
+        // I can't handle this, send it to control
         Message* m2 = new Message();
         m2->p_to = Message::CONTROL;
         m2->message = Message::CONNECTION_LOST;
@@ -344,7 +344,7 @@ void VRadioRec::stopPlay()
 
   playing = false;
 
-  if (!vdr->isConnected()) { Command::getInstance()->connectionLost(); return; }
+  if (!vdr->isConnected()) { Control::getInstance()->connectionLost(); return; }
   Log::getInstance()->log("VRadioRec", Log::DEBUG, "Post stopPlay");
 }
 
index 64641b982475a1beb10d583f6ba61a910e8b6856..cbbfe9b6e8822ba842bb04c50f30b063cc481fcc 100644 (file)
@@ -33,7 +33,7 @@
 #include "colour.h"
 #include "video.h"
 #include "i18n.h"
-#include "command.h"
+#include "control.h"
 #include "vinfo.h"
 #include "log.h"
 
@@ -109,7 +109,7 @@ void VRecordingList::doDeleteSelected()
   int success = recman->deleteRecording(toDelete);
   if (!VDR::getInstance()->isConnected())
   {
-    Command::getInstance()->connectionLost();
+    Control::getInstance()->connectionLost();
     return;
   }
 
@@ -149,7 +149,7 @@ void VRecordingList::doMoveRecording(Directory* toDir)
   int success = recman->moveRecording(toMove, toDir);
   if (!VDR::getInstance()->isConnected())
   {
-    Command::getInstance()->connectionLost();
+    Control::getInstance()->connectionLost();
     return;
   }
 
index 9ed10d85b2fb6235f856082d139c92f0656795f5..e5570290c6cd5de435c1c0633adf18803d2a82e8 100644 (file)
@@ -35,7 +35,7 @@
 #include "colour.h"
 #include "video.h"
 #include "i18n.h"
-#include "command.h"
+#include "control.h"
 #include "vinfo.h"
 #include "log.h"
 #include "movieinfo.h"
index b5775961002aa8de067bbc64ff3668afd96d81eb..fc1b7faedb246c42d6600f41318695b8788ec57f 100644 (file)
@@ -31,7 +31,7 @@
 #include "colour.h"
 #include "video.h"
 #include "i18n.h"
-#include "command.h"
+#include "control.h"
 #include "vinfo.h"
 #include "log.h"
 
index 59bdd218e110e68790fde1ccba52f8270ec22045..4b35947724979fcda254735ffe4a98fa8ce41c70 100644 (file)
@@ -29,7 +29,7 @@
 #include "video.h"
 #include "i18n.h"
 #include "vtimeredit.h"
-#include "command.h"
+#include "control.h"
 #include "boxstack.h"
 #include "vinfo.h"
 #include "log.h"
@@ -342,7 +342,7 @@ void VTimerList::processMessage(Message* m)
 
   
     ULONG retval = VDR::getInstance()->deleteTimer(recTimer);
-    if (!VDR::getInstance()->isConnected()) { Command::getInstance()->connectionLost(); return; }
+    if (!VDR::getInstance()->isConnected()) { Control::getInstance()->connectionLost(); return; }
     Log::getInstance()->log("VTimerList", Log::DEBUG, "Got return fron delete timer: %lu", retval);
     
     if (retval != 10)
index b7bd885bf26d8eeaf11444c4769b24f4f478f29e..2f3bb7465d1918b7ee1a398ca7edd836c89f5868 100644 (file)
@@ -29,7 +29,7 @@
 #include "boxstack.h"
 #include "colour.h"
 #include "osd.h"
-#include "command.h"
+#include "control.h"
 #include "i18n.h"
 #include "wtextbox.h"
 #include "input.h"
@@ -88,12 +88,12 @@ VVideoLiveTV::VVideoLiveTV(ChannelList* tchanList, ULONG initialChannelNumber, V
   if ((*chanList)[currentChannelIndex]->type == VDR::VIDEO)
   {
     streamType = VDR::VIDEO;
-    player = new PlayerVideoLive(Command::getInstance(), this, this, chanList);
+    player = new PlayerVideoLive(Control::getInstance(), this, this, chanList);
   }
   else
   {
     streamType = VDR::RADIO;
-    player = new PlayerRadioLive(Command::getInstance(), this, chanList);
+    player = new PlayerRadioLive(Control::getInstance(), this, chanList);
   }
   player->init();
 
@@ -699,7 +699,7 @@ void VVideoLiveTV::doEPG()
 {
   if (osd.getVisible()) clearScreen();
 
-  if (!Command::getInstance()->isAdvMenus())
+  if (!Control::getInstance()->isAdvMenus())
   {
     VEpg* vepg = new VEpg(this, currentChannelIndex, chanList);
     vepg->draw();
@@ -1119,7 +1119,7 @@ void VVideoLiveTV::processMessage(Message* m)
       case PlayerVideoLive::CONNECTION_LOST: // connection lost detected
       {
         Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received connection lost from player");
-        Command::getInstance()->connectionLost();
+        Control::getInstance()->connectionLost();
         break;
       }
       
index 13ffe3c95f1a2ec727db527d07b5060006206434..03d85584f416444130f3dff0e4ed73dafeeb1bf4 100644 (file)
@@ -368,7 +368,7 @@ void VVideoMedia::processMessage(Message* m)
     {
       case PlayerMedia::CONNECTION_LOST: // connection lost detected
       {
-        // I can't handle this, send it to command
+        // I can't handle this, send it to control
         Message* m2 = new Message();
         m2->p_to = Message::CONTROL;
         m2->message = Message::CONNECTION_LOST;
index 792f3181f07c49d4812a1d00bed97035286b76b4..0be40e126e4512f382e2d60beba7b08e998b4f2b 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <math.h>
 
-#include "command.h"
+#include "control.h"
 #include "osd.h"
 #include "wsymbol.h"
 #include "audio.h"
@@ -56,7 +56,7 @@ VVideoRec::VVideoRec(Recording* rec, bool ish264)
 
   video->seth264mode(ish264);
 
-  player = new PlayerVideoRec(Command::getInstance(), this, this);
+  player = new PlayerVideoRec(Control::getInstance(), this, this);
   player->init(myRec->IsPesRecording,myRec->recInfo->fps);
 
   char* cstartMargin = vdr->configLoad("Timers", "Start margin");
@@ -181,7 +181,7 @@ void VVideoRec::go(bool resume)
 
     if (!vdr->isConnected())
     {
-      Command::getInstance()->connectionLost();
+      Control::getInstance()->connectionLost();
       return;
     }
 
@@ -520,7 +520,7 @@ void VVideoRec::processMessage(Message* m)
     {
       case PlayerVideoRec::CONNECTION_LOST: // connection lost detected
       {
-        // I can't handle this, send it to command
+        // I can't handle this, send it to control
         Message* m2 = new Message();
         m2->p_to = Message::CONTROL;
         m2->message = Message::CONNECTION_LOST;
@@ -611,7 +611,7 @@ void VVideoRec::stopPlay()
 
   playing = false;
 
-  if (!vdr->isConnected()) { Command::getInstance()->connectionLost(); return; }
+  if (!vdr->isConnected()) { Control::getInstance()->connectionLost(); return; }
   Log::getInstance()->log("VVideoRec", Log::DEBUG, "Post stopPlay");
 }
 
index 4cfaa24e3d8212f1d3d4e5c20592b04eab0b2bb3..dc3655ba9b808c297126425a8fa5286885968263 100644 (file)
@@ -25,7 +25,7 @@
 #include "vrecordinglistclassic.h"
 #include "vrecordinglistadvanced.h"
 #include "vtimerlist.h"
-#include "command.h"
+#include "control.h"
 #include "message.h"
 #include "colour.h"
 #include "video.h"
@@ -235,7 +235,7 @@ int VWelcome::handleCommand(int command)
     }
     case Input::SEVEN:
     {
-      Command::getInstance()->doReboot();
+      Control::getInstance()->doReboot();
       return 2;
     }
     case Input::OK:
@@ -273,7 +273,7 @@ int VWelcome::handleCommand(int command)
       }
       else if (option == 7)
       {
-        Command::getInstance()->doReboot();
+        Control::getInstance()->doReboot();
         return 2;
       }
       return 2; // never gets here
@@ -315,7 +315,7 @@ void VWelcome::doChannelsList()
   }
   else
   {
-    Command::getInstance()->connectionLost();
+    Control::getInstance()->connectionLost();
   }
 }
 
@@ -334,14 +334,14 @@ void VWelcome::doRadioList()
   }
   else
   {
-    Command::getInstance()->connectionLost();
+    Control::getInstance()->connectionLost();
   }
 }
 
 void VWelcome::doRecordingsList()
 {
        VRecordingList* vrec;
-       if (Command::getInstance()->isAdvMenus())
+       if (Control::getInstance()->isAdvMenus())
           vrec = new VRecordingListAdvanced();
        else
           vrec = new VRecordingListClassic();
@@ -352,7 +352,7 @@ void VWelcome::doRecordingsList()
 
        if (!vrec->load())
        {
-               Command::getInstance()->connectionLost();
+               Control::getInstance()->connectionLost();
        }
 }
 
@@ -369,7 +369,7 @@ void VWelcome::doTimersList()
   if (!vtl->load())
   {
     delete vtl;
-    Command::getInstance()->connectionLost();
+    Control::getInstance()->connectionLost();
     return;
   }
   
index 631c70c75c38fe1dd6bccc5f48ea4c2d6ff1f052..726eb25a88313beabb5b00a6dec39fa4d4d766c7 100644 (file)
@@ -46,7 +46,7 @@
 #include "osdwinvector.h"
 #endif
 #include "boxstack.h"
-#include "command.h"
+#include "control.h"
 #include "wol.h"
 #include "vsleeptimer.h"
 #include "messagequeue.h"
@@ -63,7 +63,7 @@ Led* led;
 Osd* osd;
 Timers* timers;
 BoxStack* boxstack;
-Command* command;
+Control* control;
 VDR* vdr;
 Video* video;
 Audio* audio;
@@ -110,9 +110,9 @@ int getClockRealTime(struct timespec *tp){
        return 0;
 }
 
-DWORD WINAPI commandthreadStart(void *arg)
+DWORD WINAPI controlthreadStart(void *arg)
 {
-   command->run();
+   control->run();
    return 0;
 }
 
@@ -170,11 +170,11 @@ INT WINAPI WinMain( HINSTANCE hinst , HINSTANCE previnst, LPSTR cmdline, int cmd
   video      = new VideoWin();
   audio      = new AudioWin();
   boxstack   = new BoxStack();
-  command    = new Command();
+  control    = new Control();
   wol        = new Wol();
   sleeptimer = new Sleeptimer();
 
-  if (!logger || !remote || !led || !osd || !video || !audio || !boxstack || !command || !sleeptimer)
+  if (!logger || !remote || !led || !osd || !video || !audio || !boxstack || !control || !sleeptimer)
   {
     ERROR_MSG("Could not create objects. Memory problems?\n");
     shutdown(1);
@@ -182,7 +182,7 @@ INT WINAPI WinMain( HINSTANCE hinst , HINSTANCE previnst, LPSTR cmdline, int cmd
   return 0;
   }
 
-  messageQueue = command;
+  messageQueue = control;
 
   // Get logging module started --------------------------------------------------------------------------------------
 
@@ -311,14 +311,14 @@ INT WINAPI WinMain( HINSTANCE hinst , HINSTANCE previnst, LPSTR cmdline, int cmd
   return 0;
   }
 
-  success = command->init();
+  success = control->init();
   if (success)
   {
-    logger->log("Core", Log::INFO, "Command module initialised");
+    logger->log("Core", Log::INFO, "Control module initialised");
   }
   else
   {
-    logger->log("Core", Log::EMERG, "Command module failed to initialise");
+    logger->log("Core", Log::EMERG, "Control module failed to initialise");
     shutdown(1);
   WSACleanup();
   return 0;
@@ -333,20 +333,20 @@ INT WINAPI WinMain( HINSTANCE hinst , HINSTANCE previnst, LPSTR cmdline, int cmd
   // Ok, all major device components and other bits are loaded and ready
   lastmousemove=timeGetTime();
 
-  HANDLE commandthread;
- commandthread= CreateThread(NULL, 0, commandthreadStart, NULL,0,
+  HANDLE controlthread;
+ controlthread= CreateThread(NULL, 0, controlthreadStart, NULL,0,
     NULL);
   MSG message;
   message.message=WM_NULL;
   bool run=true;
-  while(run && WaitForSingleObject(commandthread,0)==WAIT_TIMEOUT) {
+  while(run && WaitForSingleObject(controlthread,0)==WAIT_TIMEOUT) {
     if (PeekMessage(&message, NULL, 0,0,PM_REMOVE)!=0) {
       if (TranslateAccelerator(win_main,acc,&message)==NULL) {
         TranslateMessage(&message);
         DispatchMessage(&message);
         switch (message.message) {
         case WM_QUIT:
-          run=false; //TODO post exit to command Messages
+          run=false; //TODO post exit to control Messages
         };
       }
     } else {
@@ -356,7 +356,7 @@ INT WINAPI WinMain( HINSTANCE hinst , HINSTANCE previnst, LPSTR cmdline, int cmd
     }
   }
   // When that returns quit ------------------------------------------------------------------------------------------
-  WaitForSingleObject(commandthread,INFINITE);
+  WaitForSingleObject(controlthread,INFINITE);
   shutdown(0);
   WSACleanup();
   if (user32dll) FreeModule(user32dll);
@@ -567,9 +567,9 @@ LONG FAR PASCAL WindowProc(HWND wind, UINT msg, WPARAM wparam, LPARAM lparam)
 
    switch (msg) {
    case WM_DESTROY: {
-     //TODO: call command
+     //TODO: call control
      logger->log("Core", Log::NOTICE, "Window closed, shutting down...");
-     command->stop();
+     control->stop();
      PostQuitMessage(0);
   }break;
    case WM_SIZING: {
@@ -837,11 +837,11 @@ void shutdown(int code)
     logger->log("Core", Log::NOTICE, "BoxStack module shut down");
   }
 
-  if (command) // shut down command here in case views have posted messages
+  if (control) // shut down control here in case views have posted messages
   {
-    command->shutdown();
-    delete command;
-    logger->log("Core", Log::NOTICE, "Command module shut down");
+    control->shutdown();
+    delete control;
+    logger->log("Core", Log::NOTICE, "Control module shut down");
   }
 
   if (vdr)
index 24e032c1c57ee1e8d7646addee8bbf76085e5338..fa5a13f6558a738bfaa93a5345ddd0d214490804 100644 (file)
@@ -172,7 +172,7 @@ void WRemoteConfig::doSave()
     m->message = Message::CHANGED_REMOTECONTROL;
     m->to = parent;
     m->parameter = 0;
-    //Command::getInstance()->postMessage(m);
+    //Control::getInstance()->postMessage(m);
     
 }
 */
@@ -250,7 +250,7 @@ int WRemoteConfig::handleCommand(int command)
       m->message = Message::CLOSE_ME;
       m->from = this;
       m->to = viewman;
-      //Command::getInstance()->postMessage(m);
+      //Control::getInstance()->postMessage(m);
       return 2;
 */      
     }
index bfa48a2fa44dc831343147568cb41dff1986ea03..9e1737c7e6aba85b8d420bce3e553ca6d827cc56 100644 (file)
@@ -170,7 +170,7 @@ void WWinAudioFilter::doSave()
     m->message = Message::CHANGED_DEVICEOPTIONS;
     m->to = parent;
     m->parameter = 0;
-    //Command::getInstance()->postMessage(m);
+    //Control::getInstance()->postMessage(m);
     
 }*/
 
index 751cc1edde4ee6ba6343f7313584592f7e191f5e..68e70195992cc009d64df408c3b50a5c07c6839a 100644 (file)
@@ -178,7 +178,7 @@ void WWinMp3AudioFilter::processMessage(Message* m)
     m->message = Message::CHANGED_DEVICEOPTIONS;
     m->to = parent;
     m->parameter = 0;
-    //Command::getInstance()->postMessage(m);
+    //Control::getInstance()->postMessage(m);
     
 }*/
 
index d3a759f7e708666f5b077ba4c61b2c738aa6c2e8..8dd34e6cc2b54e905439f0d53625f557c14000f0 100644 (file)
@@ -170,7 +170,7 @@ void WWinVideoFilter::doSave()
     m->message = Message::CHANGED_DEVICEOPTIONS;
     m->to = parent;
     m->parameter = 0;
-    //Command::getInstance()->postMessage(m);
+    //Control::getInstance()->postMessage(m);
     
 }*/
 
index c0c4e188690815eae04c9eb761ba126b9159072b..b82ccace17461bb7e335a037d3795117388b22d8 100644 (file)
@@ -170,7 +170,7 @@ void WWinVideoH264Filter::doSave()
     m->message = Message::CHANGED_DEVICEOPTIONS;
     m->to = parent;
     m->parameter = 0;
-    //Command::getInstance()->postMessage(m);
+    //Control::getInstance()->postMessage(m);
     
 }*/