/*
 * Least Cost Routing plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id$
 */

#ifndef __LCROSD_H
#define __LCROSD_H

#include <sys/time.h>
#include <sys/ioctl.h>
#include <vdr/osd.h>
#include <vdr/thread.h>
#include <vdr/status.h>
#include <vdr/channels.h>
#include <vdr/transfer.h>
#include <vdr/tools.h>

#ifndef RATES_FILE_NAME
#define RATES_FILE_NAME /tmp/rates%d.txt
#endif

#define LOADABLE_DATA_ENTRIES     17

#include "lcr.h"

// LcrData
struct LcrService_v1_0 {
  cString destination;
  cString price;
  cString pulse;
};

extern cString destinationData[7], priceData[7], pulseData[7];

class cLcrOsd : public cOsdObject, public cThread, public cStatus {
private:
  bool m_Active;
  cOsd *m_Osd;
  int m_Number;
  int m_OldNumber;

  bool firstRun;
  int displayWindowNr; // -1 = "normal" window, 0-9 = according top-5-entries for chosen destination[0-9]
  const cFont *m_Font;
  char fileName[128];
  char buf[256];
  cTimeMs m_InputTime;
  cMutex* m_Mutex;
  static cBitmap bmLogo;
  int inc;
  int logoOffset;
  int selectedData;
  int entriesNr;
  char rates[LOADABLE_DATA_ENTRIES+1][50][100];
  
  void DrawWindow(void);

protected:
  virtual void Action(void);

public:
  cLcrOsd(void);
  ~cLcrOsd();

  virtual void Show(void);
  virtual eOSState ProcessKey(eKeys Key);
  virtual void getServiceData( LcrService_v1_0 *data );
  virtual void resetServiceData();
  virtual void getData();
};

#endif //__LCROSD_H

