/*
 * (c) 2005 Research Group Dr. Fuhrmann, University of Karlsruhe, Germany
 * All rights reserved.
 *
 * Author:
 *         Roman Krenicky
 *
 * $Id: dvdrepg.cpp,v 1.23 2005/11/21 09:39:01 kutzner Exp $
 *
 */

/*
 * dvdrepg.cpp: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id: dvdrepg.cpp,v 1.23 2005/11/21 09:39:01 kutzner Exp $
 */
/*
  dvdrepg.c
  created: 29.11.2004
  last change: 12.6.2005
*/
/*! @file
    plugin interface class to the igorepg plugin which spreads EPG data across
    IGOR (and collects it from there, too)
*/

#include "globalheader.h"

#include "dvdrepg.h"


/*! just a constructor
*/
cPluginIgorepg::cPluginIgorepg (void)
{
   // Initialize any member variables here.
   // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
   // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!

   epg_access = NULL;
   igor_access = NULL;
   central = NULL;
} // cPluginIgorepg()


/*! just a destructor
*/
cPluginIgorepg::~cPluginIgorepg (void)
{
   // IMPORTANT: delete the controller (central) BEFORE the vdrepg_interface
   //            and epgigor_interface it's using
   if (central != NULL)
      delete central;
   if (igor_access != NULL)
      delete igor_access;
   if (epg_access != NULL)
      delete epg_access;
} // ~cPluginIgorepg()


//@{
/*! @fn const char* cPluginIgorepg::Version (void)
    derived from vdr's cPlugin, see there for documentation
*/


/*! @fn const char* cPluginIgorepg::Description (void)
*/


bool cPluginIgorepg::Start (void)
{
   // Start any background activities the plugin shall perform.
   igor_access = new epgigor_interface;
   if ( !igor_access->initialised() )
   {
      delete igor_access;
      igor_access = NULL;
      return false;
   } // if ( !igor_access->initialised() )
   epg_access = new vdrepg_interface;
   central = new controller(*epg_access, *igor_access);

   return true;
} // Start()


void cPluginIgorepg::Stop (void)
{
   // Stop any background activities the plugin shall perform.
   if (central != NULL)
      central->Stop();
   if (igor_access != NULL)
      igor_access->Stop();
} // Stop()


/*! @fn const char* cPluginIgorepg::MainMenuEntry (void)
*/


cOsdObject* cPluginIgorepg::MainMenuAction (void)
{
   // Perform the action when selected from the main VDR menu.
   if (central != NULL)
      return new cOsdMenuIgorepg(*central);
   return NULL;
} // MainMenuAction()
//@}


//! vdr's plugin glue code
VDRPLUGINCREATOR(cPluginIgorepg); // Don't touch this!
