/**
 *  TouchTFT plugin for the Video Disk Recorder 
 * 
 *  TouchTFT.c - A plugin for the Video Disk Recorder
 *
 *  (c) 2004 Lars Tegeler, Sascha Volkenandt  
 *
 * This code is distributed under the terms and conditions of the
 * GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
 *
 * $Id: TouchTFT.c,v 1.12 2004/05/26 11:34:33 tegeler Exp $
 *
 **/
#include "touch.h"
#include "debug.h"
#include "setup.h"
#include "i18n.h"
#include <vdr/plugin.h>
#include <vdr/config.h>

static const char *VERSION        = "0.0.4a";
static const char *DESCRIPTION    = "Enhancing graphTFT with a touchdevice";
//static const char *MAINMENUENTRY  = "";

class cPluginTouchTFT : public cPlugin {

// Add any member variables or functions you may need here.
private:

  char *_cfgDir;

  cTouchScreenEnhancer* mTouchScreenEnhancer;
public:
  cPluginTouchTFT(void);
  virtual ~cPluginTouchTFT();
  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 NULL; 
    }
  virtual cOsdObject *MainMenuAction(void);
  virtual cMenuSetupPage *SetupMenu(void);
  virtual bool SetupParse(const char *Name, const char *Value);
};

cPluginTouchTFT::cPluginTouchTFT(void) 
{
  _cfgDir = NULL;
}

cPluginTouchTFT::~cPluginTouchTFT()
{
  // Clean up after yourself!
  free( _cfgDir );
}

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

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

bool cPluginTouchTFT::Initialize(void)
{
  // Initialize any background activities the plugin shall perform.
  d(4,"cPluginTouchTFT::Initialize\n");
  return true;
}

bool cPluginTouchTFT::Start(void)
{
  // Start any background activities the plugin shall perform.
  d(4,"cPluginTouchTFT::Start\n");

  // try to get the config dir
  const char* str = ConfigDirectory();
  if (!str)
    {
      d(4, "vdr: TouchTFT - ConfigDirectory not found!\n");
      return false;
    }
  _cfgDir = strdup(str);
  TouchTFTSetup.PluginConfPath = strdup(str);

  // first register the translations
  RegisterI18n(Phrases);

  // Starting the TouchTFT-Eventthread
  mTouchScreenEnhancer =  new cTouchScreenEnhancer();
  mTouchScreenEnhancer->Initialize();

  return mTouchScreenEnhancer->IsOk();
}

void cPluginTouchTFT::Stop(void)
{
  mTouchScreenEnhancer->Stop();
  delete mTouchScreenEnhancer;
}

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

cOsdObject *cPluginTouchTFT::MainMenuAction(void)
{
  return NULL;
}

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

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

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