Convert remaining source files to utf-8.
[wine/multimedia.git] / dlls / sane.ds / capability.c
blob6b6867e02a6171e236e92145d3ad2d6c3b45a6a3
1 /*
2 * Copyright 2000 Corel Corporation
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define NONAMELESSUNION
20 #define NONAMELESSSTRUCT
22 #include "config.h"
24 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "twain.h"
29 #include "sane_i.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(twain);
34 TW_UINT16 SANE_SaneCapability (pTW_CAPABILITY pCapability, TW_UINT16 action)
36 TW_UINT16 twCC = TWCC_SUCCESS;
38 TRACE("capability=%d action=%d\n", pCapability->Cap, action);
40 switch (pCapability->Cap)
42 case CAP_DEVICEEVENT:
43 case CAP_ALARMS:
44 case CAP_ALARMVOLUME:
45 case ACAP_AUDIOFILEFORMAT:
46 case ACAP_XFERMECH:
47 case ICAP_AUTOMATICBORDERDETECTION:
48 case ICAP_AUTOMATICDESKEW:
49 case ICAP_AUTODISCARDBLANKPAGES:
50 case ICAP_AUTOMATICROTATE:
51 case ICAP_FLIPROTATION:
52 case CAP_AUTOMATICCAPTURE:
53 case CAP_TIMEBEFOREFIRSTCAPTURE:
54 case CAP_TIMEBETWEENCAPTURES:
55 case CAP_AUTOSCAN:
56 case CAP_CLEARBUFFERS:
57 case CAP_MAXBATCHBUFFERS:
58 case ICAP_BARCODEDETECTIONENABLED:
59 case ICAP_SUPPORTEDBARCODETYPES:
60 case ICAP_BARCODEMAXSEARCHPRIORITIES:
61 case ICAP_BARCODESEARCHPRIORITIES:
62 case ICAP_BARCODESEARCHMODE:
63 case ICAP_BARCODEMAXRETRIES:
64 case ICAP_BARCODETIMEOUT:
65 case CAP_EXTENDEDCAPS:
66 case CAP_SUPPORTEDCAPS:
67 case ICAP_FILTER:
68 case ICAP_GAMMA:
69 case ICAP_PLANARCHUNKY:
70 case ICAP_BITORDERCODES:
71 case ICAP_CCITTKFACTOR:
72 case ICAP_COMPRESSION:
73 case ICAP_JPEGPIXELTYPE:
74 /*case ICAP_JPEGQUALITY:*/
75 case ICAP_PIXELFLAVORCODES:
76 case ICAP_TIMEFILL:
77 case CAP_DEVICEONLINE:
78 case CAP_DEVICETIMEDATE:
79 case CAP_SERIALNUMBER:
80 case ICAP_EXPOSURETIME:
81 case ICAP_FLASHUSED2:
82 case ICAP_IMAGEFILTER:
83 case ICAP_LAMPSTATE:
84 case ICAP_LIGHTPATH:
85 case ICAP_NOISEFILTER:
86 case ICAP_OVERSCAN:
87 case ICAP_PHYSICALHEIGHT:
88 case ICAP_PHYSICALWIDTH:
89 case ICAP_UNITS:
90 case ICAP_ZOOMFACTOR:
91 case CAP_PRINTER:
92 case CAP_PRINTERENABLED:
93 case CAP_PRINTERINDEX:
94 case CAP_PRINTERMODE:
95 case CAP_PRINTERSTRING:
96 case CAP_PRINTERSUFFIX:
97 case CAP_AUTHOR:
98 case CAP_CAPTION:
99 case CAP_TIMEDATE:
100 case ICAP_AUTOBRIGHT:
101 case ICAP_BRIGHTNESS:
102 case ICAP_CONTRAST:
103 case ICAP_HIGHLIGHT:
104 case ICAP_ORIENTATION:
105 case ICAP_ROTATION:
106 case ICAP_SHADOW:
107 case ICAP_XSCALING:
108 case ICAP_YSCALING:
109 case ICAP_BITDEPTH:
110 case ICAP_BITDEPTHREDUCTION:
111 case ICAP_BITORDER:
112 case ICAP_CUSTHALFTONE:
113 case ICAP_HALFTONES:
114 case ICAP_PIXELFLAVOR:
115 case ICAP_PIXELTYPE:
116 case ICAP_THRESHOLD:
117 case CAP_LANGUAGE:
118 case ICAP_FRAMES:
119 case ICAP_MAXFRAMES:
120 case ICAP_SUPPORTEDSIZES:
121 case CAP_AUTOFEED:
122 case CAP_CLEARPAGE:
123 case CAP_FEEDERALIGNMENT:
124 case CAP_FEEDERENABLED:
125 case CAP_FEEDERLOADED:
126 case CAP_FEEDERORDER:
127 case CAP_FEEDPAGE:
128 case CAP_PAPERBINDING:
129 case CAP_PAPERDETECTABLE:
130 case CAP_REACQUIREALLOWED:
131 case CAP_REWINDPAGE:
132 case ICAP_PATCHCODEDETECTIONENABLED:
133 case ICAP_SUPPORTEDPATCHCODETYPES:
134 case ICAP_PATCHCODEMAXSEARCHPRIORITIES:
135 case ICAP_PATCHCODESEARCHPRIORITIES:
136 case ICAP_PATCHCODESEARCHMODE:
137 case ICAP_PATCHCODEMAXRETRIES:
138 case ICAP_PATCHCODETIMEOUT:
139 case CAP_BATTERYMINUTES:
140 case CAP_BATTERYPERCENTAGE:
141 case CAP_POWERDOWNTIME:
142 case CAP_POWERSUPPLY:
143 case ICAP_XNATIVERESOLUTION:
144 case ICAP_XRESOLUTION:
145 case ICAP_YNATIVERESOLUTION:
146 case ICAP_YRESOLUTION:
147 twCC = TWCC_CAPUNSUPPORTED;
148 break;
149 case CAP_XFERCOUNT:
150 /* This is a required capability that every source needs to
151 support but we haven't implemented it yet. */
152 twCC = TWCC_SUCCESS;
153 break;
154 /*case ICAP_COMPRESSION:*/
155 case ICAP_IMAGEFILEFORMAT:
156 case ICAP_TILES:
157 twCC = TWCC_CAPUNSUPPORTED;
158 break;
159 case ICAP_XFERMECH:
160 twCC = SANE_ICAPXferMech (pCapability, action);
161 break;
162 case ICAP_UNDEFINEDIMAGESIZE:
163 case CAP_CAMERAPREVIEWUI:
164 case CAP_ENABLEDSUIONLY:
165 case CAP_INDICATORS:
166 case CAP_UICONTROLLABLE:
167 twCC = TWCC_CAPUNSUPPORTED;
168 break;
169 default:
170 twCC = TWRC_FAILURE;
174 return twCC;
177 static TW_BOOL TWAIN_OneValueSet (pTW_CAPABILITY pCapability, TW_UINT32 value)
179 pCapability->hContainer = GlobalAlloc (0, sizeof(TW_ONEVALUE));
181 if (pCapability->hContainer)
183 pTW_ONEVALUE pVal = GlobalLock (pCapability->hContainer);
184 pVal->ItemType = TWTY_UINT32;
185 pVal->Item = value;
186 GlobalUnlock (pCapability->hContainer);
187 return TRUE;
189 else
190 return FALSE;
193 static TW_BOOL TWAIN_OneValueGet (pTW_CAPABILITY pCapability, TW_UINT32 *pValue)
195 pTW_ONEVALUE pVal = GlobalLock (pCapability->hContainer);
197 if (pVal)
199 *pValue = pVal->Item;
200 GlobalUnlock (pCapability->hContainer);
201 return TRUE;
203 else
204 return FALSE;
207 /* ICAP_XFERMECH */
208 TW_UINT16 SANE_ICAPXferMech (pTW_CAPABILITY pCapability, TW_UINT16 action)
210 TRACE("ICAP_XFERMECH\n");
212 switch (action)
214 case MSG_GET:
215 if (pCapability->ConType == TWON_ONEVALUE)
217 if (!TWAIN_OneValueSet (pCapability, activeDS.capXferMech))
218 return TWCC_LOWMEMORY;
220 break;
221 case MSG_SET:
222 if (pCapability->ConType == TWON_ONEVALUE)
224 TW_UINT32 xfermechtemp = 0;
225 if (!TWAIN_OneValueGet (pCapability, &xfermechtemp))
226 return TWCC_LOWMEMORY;
227 activeDS.capXferMech = xfermechtemp;
229 else if (pCapability->ConType == TWON_ENUMERATION)
233 break;
234 case MSG_GETCURRENT:
235 if (!TWAIN_OneValueSet (pCapability, activeDS.capXferMech))
236 return TWCC_LOWMEMORY;
237 break;
238 case MSG_GETDEFAULT:
239 if (!TWAIN_OneValueSet (pCapability, TWSX_NATIVE))
240 return TWCC_LOWMEMORY;
241 break;
242 case MSG_RESET:
243 activeDS.capXferMech = TWSX_NATIVE;
244 break;
246 return TWCC_SUCCESS;