Report win2k service pack 4 instead of 3.
[wine/multimedia.git] / dlls / twain / capability.c
blobfb0fdfa29f27db1687d0fe2f8efd68adcc7f35e2
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #define NONAMELESSUNION
20 #define NONAMELESSSTRUCT
22 #include <stdarg.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "twain.h"
27 #include "twain_i.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(twain);
32 TW_UINT16 TWAIN_SaneCapability (activeDS *pSource, pTW_CAPABILITY pCapability,
33 TW_UINT16 action)
35 TW_UINT16 twCC = TWCC_SUCCESS;
37 TRACE("capability=%d action=%d\n", pCapability->Cap, action);
39 switch (pCapability->Cap)
41 case CAP_DEVICEEVENT:
42 case CAP_ALARMS:
43 case CAP_ALARMVOLUME:
44 case ACAP_AUDIOFILEFORMAT:
45 case ACAP_XFERMECH:
46 case ICAP_AUTOMATICBORDERDETECTION:
47 case ICAP_AUTOMATICDESKEW:
48 case ICAP_AUTODISCARDBLANKPAGES:
49 case ICAP_AUTOMATICROTATE:
50 case ICAP_FLIPROTATION:
51 case CAP_AUTOMATICCAPTURE:
52 case CAP_TIMEBEFOREFIRSTCAPTURE:
53 case CAP_TIMEBETWEENCAPTURES:
54 case CAP_AUTOSCAN:
55 case CAP_CLEARBUFFERS:
56 case CAP_MAXBATCHBUFFERS:
57 case ICAP_BARCODEDETECTIONENABLED:
58 case ICAP_SUPPORTEDBARCODETYPES:
59 case ICAP_BARCODEMAXSEARCHPRIORITIES:
60 case ICAP_BARCODESEARCHPRIORITIES:
61 case ICAP_BARCODESEARCHMODE:
62 case ICAP_BARCODEMAXRETRIES:
63 case ICAP_BARCODETIMEOUT:
64 case CAP_EXTENDEDCAPS:
65 case CAP_SUPPORTEDCAPS:
66 case ICAP_FILTER:
67 case ICAP_GAMMA:
68 case ICAP_PLANARCHUNKY:
69 case ICAP_BITORDERCODES:
70 case ICAP_CCITTKFACTOR:
71 case ICAP_COMPRESSION:
72 case ICAP_JPEGPIXELTYPE:
73 /*case ICAP_JPEGQUALITY:*/
74 case ICAP_PIXELFLAVORCODES:
75 case ICAP_TIMEFILL:
76 case CAP_DEVICEONLINE:
77 case CAP_DEVICETIMEDATE:
78 case CAP_SERIALNUMBER:
79 case ICAP_EXPOSURETIME:
80 case ICAP_FLASHUSED2:
81 case ICAP_IMAGEFILTER:
82 case ICAP_LAMPSTATE:
83 case ICAP_LIGHTPATH:
84 case ICAP_NOISEFILTER:
85 case ICAP_OVERSCAN:
86 case ICAP_PHYSICALHEIGHT:
87 case ICAP_PHYSICALWIDTH:
88 case ICAP_UNITS:
89 case ICAP_ZOOMFACTOR:
90 case CAP_PRINTER:
91 case CAP_PRINTERENABLED:
92 case CAP_PRINTERINDEX:
93 case CAP_PRINTERMODE:
94 case CAP_PRINTERSTRING:
95 case CAP_PRINTERSUFFIX:
96 case CAP_AUTHOR:
97 case CAP_CAPTION:
98 case CAP_TIMEDATE:
99 case ICAP_AUTOBRIGHT:
100 case ICAP_BRIGHTNESS:
101 case ICAP_CONTRAST:
102 case ICAP_HIGHLIGHT:
103 case ICAP_ORIENTATION:
104 case ICAP_ROTATION:
105 case ICAP_SHADOW:
106 case ICAP_XSCALING:
107 case ICAP_YSCALING:
108 case ICAP_BITDEPTH:
109 case ICAP_BITDEPTHREDUCTION:
110 case ICAP_BITORDER:
111 case ICAP_CUSTHALFTONE:
112 case ICAP_HALFTONES:
113 case ICAP_PIXELFLAVOR:
114 case ICAP_PIXELTYPE:
115 case ICAP_THRESHOLD:
116 case CAP_LANGUAGE:
117 case ICAP_FRAMES:
118 case ICAP_MAXFRAMES:
119 case ICAP_SUPPORTEDSIZES:
120 case CAP_AUTOFEED:
121 case CAP_CLEARPAGE:
122 case CAP_FEEDERALIGNMENT:
123 case CAP_FEEDERENABLED:
124 case CAP_FEEDERLOADED:
125 case CAP_FEEDERORDER:
126 case CAP_FEEDPAGE:
127 case CAP_PAPERBINDING:
128 case CAP_PAPERDETECTABLE:
129 case CAP_REACQUIREALLOWED:
130 case CAP_REWINDPAGE:
131 case ICAP_PATCHCODEDETECTIONENABLED:
132 case ICAP_SUPPORTEDPATCHCODETYPES:
133 case ICAP_PATCHCODEMAXSEARCHPRIORITIES:
134 case ICAP_PATCHCODESEARCHPRIORITIES:
135 case ICAP_PATCHCODESEARCHMODE:
136 case ICAP_PATCHCODEMAXRETRIES:
137 case ICAP_PATCHCODETIMEOUT:
138 case CAP_BATTERYMINUTES:
139 case CAP_BATTERYPERCENTAGE:
140 case CAP_POWERDOWNTIME:
141 case CAP_POWERSUPPLY:
142 case ICAP_XNATIVERESOLUTION:
143 case ICAP_XRESOLUTION:
144 case ICAP_YNATIVERESOLUTION:
145 case ICAP_YRESOLUTION:
146 twCC = TWCC_CAPUNSUPPORTED;
147 break;
148 case CAP_XFERCOUNT:
149 /* This is a required capability that every source need to
150 support but we havev't implemented yet. */
151 twCC = TWCC_SUCCESS;
152 break;
153 /*case ICAP_COMPRESSION:*/
154 case ICAP_IMAGEFILEFORMAT:
155 case ICAP_TILES:
156 twCC = TWCC_CAPUNSUPPORTED;
157 break;
158 case ICAP_XFERMECH:
159 twCC = TWAIN_ICAPXferMech (pSource, pCapability, action);
160 break;
161 case ICAP_UNDEFINEDIMAGESIZE:
162 case CAP_CAMERAPREVIEWUI:
163 case CAP_ENABLEDSUIONLY:
164 case CAP_INDICATORS:
165 case CAP_UICONTROLLABLE:
166 twCC = TWCC_CAPUNSUPPORTED;
167 break;
168 default:
169 twCC = TWRC_FAILURE;
173 return twCC;
176 TW_BOOL TWAIN_OneValueSet (pTW_CAPABILITY pCapability, TW_UINT32 value)
178 pCapability->hContainer = (TW_HANDLE)GlobalAlloc (0, sizeof(TW_ONEVALUE));
180 if (pCapability->hContainer)
182 pTW_ONEVALUE pVal = GlobalLock ((HGLOBAL) pCapability->hContainer);
183 pVal->ItemType = TWTY_UINT32;
184 pVal->Item = value;
185 GlobalUnlock ((HGLOBAL) pCapability->hContainer);
186 return TRUE;
188 else
189 return FALSE;
192 TW_BOOL TWAIN_OneValueGet (pTW_CAPABILITY pCapability, TW_UINT32 *pValue)
194 pTW_ONEVALUE pVal = GlobalLock ((HGLOBAL) pCapability->hContainer);
196 if (pVal)
198 *pValue = pVal->Item;
199 GlobalUnlock ((HGLOBAL) pCapability->hContainer);
200 return TRUE;
202 else
203 return FALSE;
206 /* ICAP_XFERMECH */
207 TW_UINT16 TWAIN_ICAPXferMech (activeDS *pSource, pTW_CAPABILITY pCapability,
208 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, pSource->capXferMech))
218 return TWCC_LOWMEMORY;
220 break;
221 case MSG_SET:
222 if (pCapability->ConType == TWON_ONEVALUE)
224 TW_UINT32 xfermechtemp;
225 if (!TWAIN_OneValueGet (pCapability, &xfermechtemp))
226 return TWCC_LOWMEMORY;
227 pSource->capXferMech = xfermechtemp;
229 else if (pCapability->ConType == TWON_ENUMERATION)
233 break;
234 case MSG_GETCURRENT:
235 if (!TWAIN_OneValueSet (pCapability, pSource->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 pSource->capXferMech = TWSX_NATIVE;
244 break;
246 return TWCC_SUCCESS;