aboutsummaryrefslogtreecommitdiff
path: root/backend/model-info.h
blob: 349e80775d01bace2676e29419d1df1ac8b80995 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*  model-info.h -- per model information objects and cache
 *  Copyright (C) 2010  SEIKO EPSON CORPORATION
 *
 *  License: GPLv2+|iscan
 *  Authors: AVASYS CORPORATION
 *
 *  This file is part of the SANE backend distributed with Image Scan!
 *
 *  Image Scan!'s SANE backend is free software.
 *  You can redistribute it and/or modify it under the terms of the GNU
 *  General Public License as published by the Free Software Foundation;
 *  either version 2 of the License or at your option any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *  You ought to have received a copy of the GNU General Public License
 *  along with this package.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 *  Linking Image Scan!'s SANE backend statically or dynamically with
 *  other modules is making a combined work based on this SANE backend.
 *  Thus, the terms and conditions of the GNU General Public License
 *  cover the whole combination.
 *
 *  As a special exception, the copyright holders of Image Scan!'s SANE
 *  backend give you permission to link Image Scan!'s SANE backend with
 *  SANE frontends that communicate with Image Scan!'s SANE backend
 *  solely through the SANE Application Programming Interface,
 *  regardless of the license terms of these SANE frontends, and to
 *  copy and distribute the resulting combined work under terms of your
 *  choice, provided that every copy of the combined work is
 *  accompanied by a complete copy of the source code of Image Scan!'s
 *  SANE backend (the version of Image Scan!'s SANE backend used to
 *  produce the combined work), being distributed under the terms of
 *  the GNU General Public License plus this exception.  An independent
 *  module is a module which is not derived from or based on Image
 *  Scan!'s SANE backend.
 *
 *  As a special exception, the copyright holders of Image Scan!'s SANE
 *  backend give you permission to link Image Scan!'s SANE backend with
 *  independent modules that communicate with Image Scan!'s SANE
 *  backend solely through the "Interpreter" interface, regardless of
 *  the license terms of these independent modules, and to copy and
 *  distribute the resulting combined work under terms of your choice,
 *  provided that every copy of the combined work is accompanied by a
 *  complete copy of the source code of Image Scan!'s SANE backend (the
 *  version of Image Scan!'s SANE backend used to produce the combined
 *  work), being distributed under the terms of the GNU General Public
 *  License plus this exception.  An independent module is a module
 *  which is not derived from or based on Image Scan!'s SANE backend.
 *
 *  Note that people who make modified versions of Image Scan!'s SANE
 *  backend are not obligated to grant special exceptions for their
 *  modified versions; it is their choice whether to do so.  The GNU
 *  General Public License gives permission to release a modified
 *  version without this exception; this exception also makes it
 *  possible to release a modified version which carries forward this
 *  exception.
 */


#ifndef model_info_h_included
#define model_info_h_included

/*! \file
 *  \brief  Model specific information.
 *
 *  There is a fair bit of device information that does not change
 *  during the life-time of the device.  The ESC/I scanner protocol
 *  provides support to query the device to get a significant part of
 *  this information.  However, some of the information we would like
 *  to use is not available from the device.  In addition, the device
 *  sometimes returns incorrect information.
 *
 *  For a long time we have been working around this by putting the
 *  additional information and the corrections directly in our code.
 *  The model info support provided here implements a unified API to
 *  the device information allowing us to move it out of the code and
 *  into per model resource files.
 *
 *  The API aims for on-demand, cached data retrieval.  In order to
 *  support that, the sane_init() and sane_exit() functions need to
 *  handle cache initialisation and clean-up.  They can do so through
 *  the model_info_cache_init() and model_cache_exit() functions.
 *
 *  The sane_get_devices() and sane_open() functions can get access to
 *  per model information through the model_info_cache_get_info() API
 *  and use its return value in calls to the model info accessors.  Of
 *  course, other SANE API entries may do so as well, though we cannot
 *  think of a good need for them to do so (as the information can be
 *  stored in the SANE_Handle during sane_open()).
 *
 *  The number of model info accessors is still quite limited but we
 *  expect that to change when the implementation proceeds.
 *
 *  There is also convenience API meant to make initialisation of the
 *  SANE_Device structure marginally less verbose.
 */

#include <stdbool.h>
#include <sane/sane.h>

#include "defines.h"
#include "device.h"

#ifdef __cplusplus
extern "C"
{
#endif

  struct ScanArea
  {
    SANE_Fixed width;
    SANE_Fixed height;
  };
  typedef struct ScanArea scan_area_t;

  /* Model info cache creation and destruction */
  void * model_info_cache_init (const char *pkgdatadir, SANE_Status *status);
  void * model_info_cache_exit (void *self);

  /* Model info cache accessors */
  const void * model_info_cache_get_info (const char *fw_name,
                                          SANE_Status *status);

  /* Model info cache convenience methods */
  char * model_info_cache_get_model (const char *fw_name);
  /* ?FIXME? add convenience methods for vendor and type? */

  /* Model info accessors */
  const char * model_info_get_name (const void *self);
  const EpsonScanHard model_info_get_profile (const void *self);
  bool model_info_customise_commands (const void *self, EpsonCmd cmd);
  bool model_info_has_lock_commands (const void *self);

  scan_area_t model_info_max_scan_area(const void *self, const char *option, const char *mode);
  /* :FIXME: add more accessors */

#ifdef __cplusplus
}       /* extern "C" */
#endif

#endif  /* !defined (model_info_h_included) */