/*
 * epgsearchonly.c: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id$
 */
#include <vdr/plugin.h>
#include <vdr/i18n.h>
#include "services.h"

static const char VERSION[]        = "0.0.1";
static const char DESCRIPTION[]    = "Direct access to epgsearch's search menu";
static const char MAINMENUENTRY[]  = "Search";

const tI18nPhrase Phrases[] = {
  { "Direct access to epgsearch's search menu",
    "Direkter Zugriff auf epgsearch's Suchenmenu",// Deutsch
    "",// TODO 
    "",// TODO
    "",// TODO
    "",// TODO 
    "",// TODO
    "",// TODO 
    "Suoratoiminto EPGSearch-laajennoksen haulle",
    "",// TODO Polski
    "",// TODO Español
    "",// TODO ÅëëçíéêÜ (Greek)
    "",// TODO Svenska
    "",// TODO Romaneste
    "",// TODO Magyar
    "",// TODO Català
    "",// TODO ÀãááÚØÙ (Russian)
    "",// TODO Hrvatski (Croatian)
#if VDRVERSNUM && VDRVERSNUM >= 10313
    "", // Eesti
#if VDRVERSNUM >= 10316
    "", // Dansk
#endif
#endif
  },
  { "Search",
    "Suche",
    "",// TODO
    "Ricerca",// TODO
    "Zoek",
    "",// TODO
    "Recherche",
    "",// TODO
    "Etsi",
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
#if VDRVERSNUM && VDRVERSNUM >= 10313
    "", // Eesti
#if VDRVERSNUM >= 10316
    "", // Dansk
#endif
#endif
  },
  { "This version of EPGSearch does not support this service!",
    "Diese Version von EPGSearch unterstützt diesen Dienst nicht!",
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "EPGSearch-laajennos ei tarjoa vaadittavaa palvelua!",
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
#if VDRVERSNUM && VDRVERSNUM >= 10313
    "", // Eesti
#if VDRVERSNUM >= 10316
    "", // Dansk
#endif
#endif
  },
  { "EPGSearch does not exist!",
    "EPGSearch nicht vorhanden!",
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "EPGSearch-laajennosta ei löydy!",
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
#if VDRVERSNUM && VDRVERSNUM >= 10313
    "", // Eesti
#if VDRVERSNUM >= 10316
    "", // Dansk
#endif
#endif
  },
  { "Plugin needs vdr-1.3.30 or above!",
    "Plugin benötigt vdr-1.3.30 oder höher!",
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "Laajennos tarvitsee toimiakseen vähintään vdr-1.3.30!",
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
    "",// TODO
#if VDRVERSNUM && VDRVERSNUM >= 10313
    "", // Eesti
#if VDRVERSNUM >= 10316
    "", // Dansk
#endif
#endif
  },
  { NULL }
  };
  
class cPluginEpgsearchonly : public cPlugin {
private:
  // Add any member variables or functions you may need here.
public:
  cPluginEpgsearchonly(void);
  virtual ~cPluginEpgsearchonly();
  virtual const char *Version(void) { return VERSION; }
  virtual const char *Description(void) { return tr(DESCRIPTION); }
  virtual const char *CommandLineHelp(void);
  virtual bool ProcessArgs(int argc, char *argv[]);
  virtual bool Initialize(void);
  virtual bool Start(void);
  virtual void Stop(void);
  virtual void Housekeeping(void);
  virtual const char *MainMenuEntry(void) { return tr(MAINMENUENTRY); }
  virtual cOsdObject *MainMenuAction(void);
  virtual cMenuSetupPage *SetupMenu(void);
  virtual bool SetupParse(const char *Name, const char *Value);
  };

cPluginEpgsearchonly::cPluginEpgsearchonly(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!
}

cPluginEpgsearchonly::~cPluginEpgsearchonly()
{
  // Clean up after yourself!
}

const char *cPluginEpgsearchonly::CommandLineHelp(void)
{
  // Return a string that describes all known command line options.
  return NULL;
}

bool cPluginEpgsearchonly::ProcessArgs(int argc, char *argv[])
{
  // Implement command line argument processing here if applicable.
  return true;
}

bool cPluginEpgsearchonly::Initialize(void)
{
  RegisterI18n(Phrases);
  return true;
}

bool cPluginEpgsearchonly::Start(void)
{
  return true;
}

void cPluginEpgsearchonly::Stop(void)
{
  // Stop any background activities the plugin shall perform.
}

void cPluginEpgsearchonly::Housekeeping(void)
{
  // Perform any cleanup or other regular tasks.
}

cOsdObject *cPluginEpgsearchonly::MainMenuAction(void)
{
#if VDRVERSNUM >= 10330 || defined(PATCH_CUSTOMSERVICES)
    cPlugin *p = cPluginManager::GetPlugin("epgsearch");
    if (p)
    {
 	Epgsearch_searchmenu_v1_0* serviceData = new Epgsearch_searchmenu_v1_0;
	serviceData->pSearchMenu = NULL;
	
	cOsdMenu* pMenu = NULL;
	if (p->Service("Epgsearch-searchmenu-v1.0", serviceData))
	    pMenu = serviceData->pSearchMenu;
	else
	    Skins.Message(mtError, tr("This version of EPGSearch does not support this service!"));
	
	delete serviceData;
	
	if (pMenu)
	    return pMenu;	
	else
	    return NULL;
    }
    else
    {
	Skins.Message(mtError, tr("EPGSearch does not exist!"));
	return NULL;
    }

  return NULL;
#else
    Skins.Message(mtError, tr("Plugin needs vdr-1.3.30 or above!")); 
    return NULL;
#endif
}

cMenuSetupPage *cPluginEpgsearchonly::SetupMenu(void)
{
  // Return a setup menu in case the plugin supports one.
  return NULL;
}

bool cPluginEpgsearchonly::SetupParse(const char *Name, const char *Value)
{
  // Parse your own setup parameters and store their values.
  return false;
}

VDRPLUGINCREATOR(cPluginEpgsearchonly); // Don't touch this!
