/*
 * See the files COPYING and README for copyright information and how to reach
 * the author.
 *
 *  $Id: vdr_compat.h,v 1.2 2006/01/21 19:37:28 lordjaxom Exp $
 */

#ifndef VDR_BURN_COMPAT_H
#define VDR_BURN_COMPAT_H

#include <vdr/config.h>

#if VDRVERSNUM >= 10300

#include <vdr/osdbase.h>

#else

#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <vdr/keys.h>
#include <vdr/recording.h>
#include <vdr/osd.h>

#define MAXAPIDS 2
#define MAXDPIDS 1

// --- cString ---------------------------------------------------------------

class cString {
private:
  char *s;
public:
  cString(const char *S = NULL, bool TakePointer = false);
  virtual ~cString();
  operator const char * () const { return s; } // for use in (const char *) context
  const char * operator*() const { return s; } // for use in (const void *) context (printf() etc.)
  cString &operator=(const cString &String);
  static cString sprintf(const char *fmt, ...);
  };

// --- cSkins ----------------------------------------------------------------

enum eMessageType { mtStatus = 0, mtInfo, mtWarning, mtError }; // will be used to calculate color offsets!

class cSkins {
public:
  eKeys Message(eMessageType Type, const char *s, int Seconds = 0);
       ///< Displays the given message, either through a currently visible
       ///< display object that is capable of doing so, or by creating a
       ///< temporary cSkinDisplayMessage object.
  void Flush(void);
       ///< Flushes the currently active cSkinDisplay, if any.
  };

extern cSkins Skins;

// --- cRecordings -----------------------------------------------------------

extern cRecordings Recordings;

// --- cOsdItem --------------------------------------------------------------

#define Selectable() HasUserColor()
#define SetSelectable(true) SetColor(clrWhite) // XXX+
#define SetFresh(boolean) // XXX+

// --- cReadDir --------------------------------------------------------------

class cReadDir {
private:
  DIR *directory;
  struct dirent *result;
  union { // according to "The GNU C Library Reference Manual"
    struct dirent d;
    char b[offsetof(struct dirent, d_name) + NAME_MAX + 1];
    } u;
public:
  cReadDir(const char *Directory);
  ~cReadDir();
  bool Ok(void) { return directory != NULL; }
  struct dirent *Next(void);
  };

#endif

#endif // VDR_BURN_COMPAT_H
