/*
 * $Id: pim.c,v 1.2 2006/05/11 20:00:34 sundin Exp $
 *
 * Tag: $Name:  $
 *
 * See the file COPYRIGHT for copyright information
 *
 * $Log: pim.c,v $
 * Revision 1.2  2006/05/11 20:00:34  sundin
 * Introduced APIVERSION for VDR-1.4, version bumped to 0.0.6
 *
 * Revision 1.1.1.1  2005/02/17 05:45:53  sundin
 * initial import ver0.0.5
 *
 * Revision 1.2  2005/01/17 18:29:49  ksltuf
 * added finnish translations
 *
 * Revision 1.1.1.1  2005/01/17 18:06:31  ksltuf
 * PIM-Plugin 0.0.4
 *
 * Revision 1.5  2004/12/13 07:59:04  ksltuf
 * bugfix setup parsing; new option firstIsMonday
 *
 * Revision 1.4  2004/11/24 21:29:51  ksltuf
 * Changed order of include-Statements - VDR-includes come last
 * (problems with STL under gcc 2.95)
 *
 * Revision 1.3  2004/08/21 12:33:17  ksltuf
 * set version to 0.0.2
 *
 * Revision 1.2  2004/07/05 19:00:26  ksltuf
 * Added COPYRIGHT and cvs information
 *
 *
 */


#include "i18n.h"
#include "eventListMenu.h"
#include "eventSetupMenu.h"
#include "pimOsdMenu.h"
#include "pimSetup.h"

#include <vdr/plugin.h>

static const char *VERSION        = "0.0.6";
static const char *DESCRIPTION    = "Simple Personal Information Manager";
static const char *MAINMENUENTRY  = "PIM Calendar";

class cPluginPim : public cPlugin {
private:

public:
  cPluginPim(void);
  virtual ~cPluginPim();
  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 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);
  };

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

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

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

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

  return true;
}

bool cPluginPim::Initialize(void)
{
  // Initialize any background activities the plugin shall perform.

  RegisterI18n(pimPhrases);

  return true;
}

bool cPluginPim::Start(void)
{
  // Start any background activities the plugin shall perform.
  return true;
}

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

cOsdObject *cPluginPim::MainMenuAction(void)
{
  // Perform the action when selected from the main VDR menu.
  return new cPimOsdMenu();
}

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

bool cPluginPim::SetupParse(const char *Name, const char *Value)
{
  // Parse your own setup parameters and store their values.
  
  if ( !strcasecmp(Name, "OsdOffsetX") )
    globalSetup.osdOffsetX = atoi(Value);
  else
  if ( !strcasecmp(Name, "OsdOffsetY") )
    globalSetup.osdOffsetY = atoi(Value);
  else
  if ( !strcasecmp(Name, "FirstIsMonday") )
    globalSetup.firstIsMonday = atoi(Value);
  else
  if ( !strcasecmp(Name, "CalCommand") )
    strcpy(globalSetup.calCmd, Value);
  else
    return false;

  return true;
}

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