// -*-c++-*-

#ifndef _SANE_INTERFACE_H_
#define _SANE_INTERFACE_H_

extern "C" {
#include <sane/sane.h>
#include <sane/saneopts.h>
#include <sane/sanei.h>
};

#include <cstring>

#include "smart_ptr.h"

// what options am I going to have
enum EpsonOption {
  OPT_NUM_OPTS,
  
  OPT_MODE_GROUP,
  OPT_RESOLUTION,
  OPT_SPEED,
  OPT_PREVIEW,
  OPT_IMAGE_TYPE,
  
  OPT_GEOMETRY_GROUP,
  OPT_TL_X,                   /* top-left x */
  OPT_TL_Y,                   /* top-left y */
  OPT_BR_X,                   /* bottom-right x */
  OPT_BR_Y,                   /* bottom-right y */
  OPT_ZOOM,
  
  OPT_ENHANCEMENT_GROUP,
  OPT_BRIGHTNESS,
  OPT_GAMMA,
  OPT_HALFTONE,
  OPT_COLOR_CORRECT,
  
  /* must come last: */
  NUM_OPTIONS
};

enum ImageType {
  IMTYPE_COLOR,
  IMTYPE_GRAY,
  IMTYPE_BW,

  NUM_IMTYPES
};

struct ListItem {
  SANE_String_Const name;
  SANE_Int val;
  int level;			// what level scanner supports it
};

union OptValue {
  SANE_Word wrd;
  SANE_String_Const str;
};

struct MySANE_Device : public SANE_Device {
  MySANE_Device() {
    name = model = vendor = type = NULL;
  }

  MySANE_Device(const char *name, const char *model, const char *vendor,
		const char *type);

  MySANE_Device(const MySANE_Device& d) {
    *this = d;
  }
    
  ~MySANE_Device() {
    delete[] name;
    delete[] model;
    delete[] vendor;
    delete[] type;
  }
  
  MySANE_Device& operator=(const MySANE_Device& d);
};
  
struct OpenDevice {
  OpenDevice() {
    memset(options, 0, sizeof(options));
  }
  ~OpenDevice();
  smart_ptr<Scanner> scanner;
  ScanNewSettings settings;
  ScanNewIdentity identity;
  SANE_Option_Descriptor options[NUM_OPTIONS];
  OptValue values[NUM_OPTIONS];
};

#endif // _SANE_INTERFACE_H_
