#ifndef __ALCD_THREAD_H
#define __ALCD_THREAD_H

#include <string>
#include <vector>
#include "activylcd.h"
#include <vdr/channels.h>
#include <vdr/thread.h>
#include <vdr/status.h>
using std::string;
using std::vector;

///////////////////////////////////////////////////
// activy300 LCD plugin for VDR
//
// Original written by:
//
// Meinrad Sauter <meinrad.sauter@gmx.de>
// andreas 'randy' weinberger <vdr@smue.org>
//
// rearranged, beautified and rewritten by:
//
// Markus Geisler <geisler@primusnetz.de>
//
// optimized by:
// Sascha Quint <sascha.quint@gmx.net>

///////////////////////////////////////////////////
// aLCD wrapper thread class

class cLCD : public cThread, cStatus
{
private:
   activyLCD *myLCD;

	struct RecordingInfo {
		string name;
		const cDevice *device;
	};
	typedef vector <RecordingInfo> Recordings;
	
   char szChannelName[ 256 ];
   char szProgName[ 256 ];
   char szRecName[ 256 ];
   char szRecStatus[ 256 ];
   char szReplayName[ 256 ];
   char szOsdTitle[ 256 ];
   char szOsdText[ 256 ];
   char szMsgText[ 256 ];
   char szVolText[ 21 ];

   char *szInfoLine[2];

   int currentChannel;
   bool stop;
   bool running;

   Recordings _recordings;
   cControl *PlayControl;

   int displayMode;
   int savedMode;
   int infoTimer;
	cMutex _mutex;
	cCondVar _doUpdate;

   bool StoppedTimer(const char *szName);
   void SetInfoTimer();
   void GetProgram();

protected:
   virtual void Action(void);
   virtual void ChannelSwitch(const cDevice *Device, int ChannelNumber);
   virtual void Recording(const cDevice *Device, const char *Name, const char *FileName, bool On);
   virtual void Replaying(const cControl *Control, const char *Name, const char *FileName, bool On);
   virtual void SetVolume(int Volume, bool mute);
   virtual void OsdProgramme(time_t PresentTime, const char *PresentTitle, const char *PresentSubtitle, time_t FollowingTime, const char *FollowingTitle, const char *FollowingSubtitle);
   virtual void OsdCurrentItem(const char *Text);
   virtual void OsdChannel(const char *Text);
   virtual void OsdClear(void);
   virtual void OsdStatusMessage(const char *Message);
   virtual void OsdTitle(const char *Title);

public:
   cLCD();
   ~cLCD();
};

#endif
