/*
 * status.c: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id: status.c 1.7 2002/12/13 15:01:53 kls Exp $
 */

#include "extb_status.h"



// ---
cExtBStatusMonitor::cExtBStatusMonitor(cExtBoardIO*    pExt)
: m_pExt(pExt)
{

}

void cExtBStatusMonitor::ChannelSwitch(const cDevice *pDevice, int nChannelNumber)
{
#ifdef MOREDEBUGMSG
  if (nChannelNumber)
    moredsyslog("extb: channel switched to %d on DVB %d", nChannelNumber, pDevice->CardIndex());
  else
    moredsyslog("extb: about to switch channel on DVB %d", pDevice->CardIndex());
#endif

  if (nChannelNumber > 0 && pDevice->IsPrimaryDevice()) {
    if (nChannelNumber == cDevice::CurrentChannel())
      m_pExt->Channel(nChannelNumber);
  }
}

void cExtBStatusMonitor::SetVolume(int Volume, bool Absolute)
{
  moredsyslog("extb: SetVolume  %d %d", Volume, Absolute);

  if(m_pExt->Volume(Volume))
    m_pExt->Update(false);
}

void cExtBStatusMonitor::Recording(const cDevice *pDevice, const char *szName, const char *szFileName, bool bOn)
{
  moredsyslog("extb: Recording  %d %s", pDevice->CardIndex(), szName);

  m_pExt->Recording(pDevice,szName,szFileName,bOn);
}

void cExtBStatusMonitor::Replaying(const cControl *pControl, const char *szName, const char *szFileName, bool bOn)
{
  moredsyslog("extb: Replaying  %s", szName);

  m_pExt->Replaying(pControl,szName,szFileName,bOn);
}

void cExtBStatusMonitor::OsdClear(void)
{
  moredsyslog("extb: OsdClear");
}

void cExtBStatusMonitor::OsdTitle(const char *Title)
{
  moredsyslog("extb: OsdTitle '%s'", Title);
}

void cExtBStatusMonitor::OsdStatusMessage(const char *szMessage)
{
  if(szMessage) {
    moredsyslog("extb: OsdStatusMessage '%s'", szMessage);
    m_pExt->StatusMessage(szMessage);
  }
}

void cExtBStatusMonitor::OsdHelpKeys(const char *Red, const char *Green, const char *Yellow, const char *Blue)
{
  moredsyslog("extb: OsdHelpKeys %s - %s - %s - %s", Red, Green, Yellow, Blue);
}

void cExtBStatusMonitor::OsdCurrentItem(const char *Text)
{
  moredsyslog("extb: OsdCurrentItem %s", Text);
}

void cExtBStatusMonitor::OsdTextItem(const char *Text, bool Scroll)
{
  moredsyslog("extb: OsdTextItem %s %d", Text, Scroll);
}

void cExtBStatusMonitor::OsdChannel(const char *Text)
{
  moredsyslog("extb: OsdChannel %s", Text);
}

void cExtBStatusMonitor::OsdProgramme(time_t PresentTime, const char *PresentTitle, const char *PresentSubtitle, time_t FollowingTime, const char *FollowingTitle, const char *FollowingSubtitle)
{
#ifdef MOREDEBUGMSG
  char buffer[25];
  struct tm tm_r;
  moredsyslog("extb: OsdProgramme");
  strftime(buffer, sizeof(buffer), "%R", localtime_r(&PresentTime, &tm_r));
  moredsyslog("%5s %s", buffer, PresentTitle);
  moredsyslog("%5s %s", "", PresentSubtitle);
  strftime(buffer, sizeof(buffer), "%R", localtime_r(&FollowingTime, &tm_r));
  moredsyslog("%5s %s", buffer, FollowingTitle);
  moredsyslog("%5s %s", "", FollowingSubtitle);
#endif
}
