ReactOS 0.4.17-dev-966-gf06eace
dsm_ctrl.c File Reference
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "twain.h"
#include "twain_i.h"
#include "resource.h"
#include "wine/debug.h"
Include dependency graph for dsm_ctrl.c:

Go to the source code of this file.

Classes

struct  all_devices
 
struct  userselect_data
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (twain)
 
static void twain_add_onedriver (const WCHAR *dsname)
 
static void twain_autodetect (void)
 
TW_UINT16 TWAIN_ControlNull (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, activeDS *pSource, TW_UINT16 MSG, TW_MEMREF pData)
 
TW_UINT16 TWAIN_ProcessEvent (pTW_IDENTITY pOrigin, activeDS *pSource, TW_MEMREF pData)
 
TW_UINT16 TWAIN_CloseDS (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
TW_UINT16 TWAIN_IdentityGetDefault (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
TW_UINT16 TWAIN_IdentityGetFirst (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
TW_UINT16 TWAIN_IdentityGetNext (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
TW_UINT16 TWAIN_OpenDS (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
static INT_PTR CALLBACK userselect_dlgproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
TW_UINT16 TWAIN_UserSelect (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
TW_UINT16 TWAIN_CloseDSM (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
TW_UINT16 TWAIN_OpenDSM (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
TW_UINT16 TWAIN_GetDSMStatus (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 

Variables

static TW_UINT16 DSM_initialized
 
static TW_UINT32 DSM_sourceId
 
static TW_UINT16 DSM_currentDevice
 
static HWND DSM_parent
 
static UINT event_message
 
static int nrdevices = 0
 
static struct all_devices * devices = NULL
 
static BOOL detectionrun = FALSE
 

Function Documentation

◆ twain_add_onedriver()

static void twain_add_onedriver ( const WCHAR *  dsname)
static

Definition at line 51 of file dsm_ctrl.c.

51 {
53 DSENTRYPROC dsEntry;
54 TW_IDENTITY fakeOrigin;
55 TW_IDENTITY sourceId;
56 struct all_devices *new_devices;
59
60#ifdef __REACTOS__
61 swprintf( path, MAX_PATH, L"c:\\windows\\twain_%u\\%s", (int)(sizeof(void *) * 8), dsname );
62#else
63 swprintf( path, MAX_PATH, L"c:\\windows\\twain_%u\\%s", sizeof(void *) * 8, dsname );
64#endif
66 if (!hmod) {
67 ERR("Failed to load TWAIN Source %s\n", debugstr_w(path));
68 return;
69 }
70 dsEntry = (DSENTRYPROC)GetProcAddress(hmod, "DS_Entry");
71 if (!dsEntry) {
72 ERR("Failed to find DS_Entry() in TWAIN DS %s\n", debugstr_w(path));
73 return;
74 }
75 /* Loop to do multiple detects, mostly for sane.ds and gphoto2.ds */
76 do {
77 int i;
78
79 sourceId.Id = DSM_sourceId;
82 ret = dsEntry (&fakeOrigin, DG_CONTROL, DAT_IDENTITY, MSG_GET, &sourceId);
83 if (ret != TWRC_SUCCESS) {
84 ERR("Source->(DG_CONTROL,DAT_IDENTITY,MSG_GET) failed!\n");
85 break;
86 }
87 TRACE("Manufacturer: %s\n", debugstr_a(sourceId.Manufacturer));
88 TRACE("ProductFamily: %s\n", debugstr_a(sourceId.ProductFamily));
89 TRACE("ProductName: %s\n", debugstr_a(sourceId.ProductName));
90
91 for (i=0;i<nrdevices;i++) {
92 if (!strcmp(sourceId.ProductName,devices[i].identity.ProductName))
93 break;
94 }
95 if (i < nrdevices)
96 break;
97 new_devices = realloc( devices, sizeof(devices[0]) * (nrdevices + 1) );
98 if (!new_devices)
99 break;
100 devices = new_devices;
101 devices[nrdevices].modname = wcsdup( path );
102 devices[nrdevices].identity = sourceId;
103 nrdevices++;
104 DSM_sourceId++;
105 } while (1);
107}
#define ERR(fmt,...)
Definition: precomp.h:57
#define realloc
Definition: debug_ros.c:6
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
#define LoadLibraryW(x)
Definition: compat.h:747
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
static wchar_t * wcsdup(const wchar_t *str)
Definition: string.h:94
#define swprintf
Definition: precomp.h:40
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
static struct all_devices * devices
Definition: dsm_ctrl.c:48
static int nrdevices
Definition: dsm_ctrl.c:47
static TW_UINT32 DSM_sourceId
Definition: dsm_ctrl.c:37
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
static NTSTATUS *static PWSTR CURDIR *static HMODULE hmod
Definition: security.c:104
short WCHAR
Definition: pedump.c:58
#define TRACE(s)
Definition: solgame.cpp:4
TW_STR32 Manufacturer
Definition: twain.h:262
TW_STR32 ProductName
Definition: twain.h:264
TW_STR32 ProductFamily
Definition: twain.h:263
TW_UINT16 ProtocolMinor
Definition: twain.h:260
TW_UINT16 ProtocolMajor
Definition: twain.h:259
TW_UINT32 Id
Definition: twain.h:257
#define DAT_IDENTITY
Definition: twain.h:1337
#define TWON_PROTOCOLMINOR
Definition: twain.h:69
unsigned short TW_UINT16
Definition: twain.h:119
#define TWRC_SUCCESS
Definition: twain.h:1664
#define MSG_GET
Definition: twain.h:1385
#define DG_CONTROL
Definition: twain.h:1311
#define TWON_PROTOCOLMAJOR
Definition: twain.h:70

Referenced by twain_autodetect().

◆ twain_autodetect()

static void twain_autodetect ( void  )
static

Definition at line 112 of file dsm_ctrl.c.

112 {
113 if (detectionrun) return;
115
116 twain_add_onedriver(L"sane.ds");
117 twain_add_onedriver(L"gphoto2.ds");
118#if 0
119 twain_add_onedriver(L"Largan\\sp503a.ds");
120 twain_add_onedriver(L"vivicam10\\vivicam10.ds");
121 twain_add_onedriver(L"ws30slim\\sp500a.ds");
122#endif
123}
#define TRUE
Definition: types.h:120
static BOOL detectionrun
Definition: dsm_ctrl.c:109
static void twain_add_onedriver(const WCHAR *dsname)
Definition: dsm_ctrl.c:51

Referenced by TWAIN_IdentityGetDefault(), TWAIN_IdentityGetFirst(), TWAIN_OpenDS(), and TWAIN_UserSelect().

◆ TWAIN_CloseDS()

TW_UINT16 TWAIN_CloseDS ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 206 of file dsm_ctrl.c.

207{
208 TW_UINT16 twRC = TWRC_SUCCESS;
209 pTW_IDENTITY pIdentity = (pTW_IDENTITY) pData;
210 activeDS *currentDS = NULL, *prevDS = NULL;
211
212 TRACE ("DG_CONTROL/DAT_IDENTITY/MSG_CLOSEDS\n");
213
214 for (currentDS = activeSources; currentDS; currentDS = currentDS->next) {
215 if (currentDS->identity.Id == pIdentity->Id)
216 break;
217 prevDS = currentDS;
218 }
219 if (!currentDS) {
221 return TWRC_FAILURE;
222 }
223 twRC = currentDS->dsEntry (pOrigin, DG_CONTROL, DAT_IDENTITY, MSG_CLOSEDS, pData);
224 /* This causes crashes due to still open Windows, so leave out for now.
225 * FreeLibrary (currentDS->hmod);
226 */
227 if (prevDS)
228 prevDS->next = currentDS->next;
229 else
230 activeSources = currentDS->next;
231 HeapFree (GetProcessHeap(), 0, currentDS);
232 if (twRC == TWRC_SUCCESS)
234 else /* FIXME: unclear how to get TWCC */
236 return twRC;
237}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
DSENTRYPROC dsEntry
Definition: twain_i.h:42
struct tagActiveDS * next
Definition: twain_i.h:39
TW_IDENTITY identity
Definition: twain_i.h:40
TW_UINT16 DSM_twCC
Definition: twain32_main.c:32
activeDS * activeSources
Definition: twain32_main.c:33
#define TWRC_FAILURE
Definition: twain.h:1665
#define TWCC_SEQERROR
Definition: twain.h:1687
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
#define MSG_CLOSEDS
Definition: twain.h:1410
#define TWCC_NODS
Definition: twain.h:1681
struct TW_IDENTITY * pTW_IDENTITY
Definition: twain.h:1762
#define TWCC_SUCCESS
Definition: twain.h:1678

Referenced by TWAIN_SourceManagerHandler().

◆ TWAIN_CloseDSM()

TW_UINT16 TWAIN_CloseDSM ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 460 of file dsm_ctrl.c.

461{
462 activeDS *currentDS = activeSources, *nextDS;
463
464 TRACE("DG_CONTROL/DAT_PARENT/MSG_CLOSEDSM\n");
465
466 if (DSM_initialized)
467 {
469
470 /* If there are data sources still open, close them now. */
471 while (currentDS != NULL)
472 {
473 nextDS = currentDS->next;
474 currentDS->dsEntry (pOrigin, DG_CONTROL, DAT_IDENTITY, MSG_CLOSEDS, pData);
475 HeapFree (GetProcessHeap(), 0, currentDS);
476 currentDS = nextDS;
477 }
481 return TWRC_SUCCESS;
482 } else {
484 return TWRC_FAILURE;
485 }
486}
#define FALSE
Definition: types.h:117
static TW_UINT16 DSM_initialized
Definition: dsm_ctrl.c:36
static HWND DSM_parent
Definition: dsm_ctrl.c:39

Referenced by TWAIN_SourceManagerHandler().

◆ TWAIN_ControlNull()

TW_UINT16 TWAIN_ControlNull ( pTW_IDENTITY  pOrigin,
pTW_IDENTITY  pDest,
activeDS *  pSource,
TW_UINT16  MSG,
TW_MEMREF  pData 
)

Definition at line 126 of file dsm_ctrl.c.

127{
128 struct pending_message *message;
129
130 TRACE ("DG_CONTROL/DAT_NULL MSG=%i\n", MSG);
131
132 if (MSG != MSG_CLOSEDSREQ &&
133 MSG != MSG_DEVICEEVENT &&
135 {
137 return TWRC_FAILURE;
138 }
139
140 message = HeapAlloc(GetProcessHeap(), 0, sizeof(*message));
141 if (!message)
142 {
144 return TWRC_FAILURE;
145 }
146
147 message->msg = MSG;
149
150 /* Delphi twain only sends us messages from one window, and it
151 doesn't even give us the real handle to that window. Other
152 applications might decide to forward messages sent to DSM_parent
153 or to the one supplied to ENABLEDS. So let's try very hard to
154 find a window that will work. */
155 if (DSM_parent)
157 if (pSource->ui_window && pSource->ui_window != DSM_parent)
158 PostMessageW(pSource->ui_window, event_message, 0, 0);
159 if (pSource->event_window && pSource->event_window != pSource->ui_window &&
160 pSource->event_window != DSM_parent)
161 PostMessageW(pSource->event_window, event_message, 0, 0);
162 PostMessageW(0, event_message, 0, 0);
163
164 return TWRC_SUCCESS;
165}
#define MSG
Definition: Mailslot.c:11
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
#define HeapAlloc
Definition: compat.h:733
static UINT event_message
Definition: dsm_ctrl.c:40
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
Definition: tftpd.h:60
struct list entry
Definition: performance.c:91
DMUS_PMSG msg
Definition: performance.c:92
HWND ui_window
Definition: twain_i.h:44
struct list pending_messages
Definition: twain_i.h:43
HWND event_window
Definition: twain_i.h:45
#define MSG_XFERREADY
Definition: twain.h:1395
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define MSG_DEVICEEVENT
Definition: twain.h:1399
#define TWCC_BADPROTOCOL
Definition: twain.h:1685
#define MSG_CLOSEDSREQ
Definition: twain.h:1396
#define TWCC_LOWMEMORY
Definition: twain.h:1680

Referenced by DSM_Entry().

◆ TWAIN_GetDSMStatus()

TW_UINT16 TWAIN_GetDSMStatus ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 510 of file dsm_ctrl.c.

511{
512 pTW_STATUS pSourceStatus = (pTW_STATUS) pData;
513
514 TRACE ("DG_CONTROL/DAT_STATUS/MSG_GET\n");
515
516 pSourceStatus->ConditionCode = DSM_twCC;
517 DSM_twCC = TWCC_SUCCESS; /* clear the condition code */
518 return TWRC_SUCCESS;
519}
TW_UINT16 ConditionCode
Definition: twain.h:352
struct TW_STATUS * pTW_STATUS

Referenced by TWAIN_SourceManagerHandler().

◆ TWAIN_IdentityGetDefault()

TW_UINT16 TWAIN_IdentityGetDefault ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 240 of file dsm_ctrl.c.

241{
242 pTW_IDENTITY pSourceIdentity = (pTW_IDENTITY) pData;
243
244 TRACE("DG_CONTROL/DAT_IDENTITY/MSG_GETDEFAULT\n");
247 if (!nrdevices)
248 return TWRC_FAILURE;
249 *pSourceIdentity = devices[0].identity;
251 return TWRC_SUCCESS;
252}
static void twain_autodetect(void)
Definition: dsm_ctrl.c:112

Referenced by TWAIN_SourceManagerHandler().

◆ TWAIN_IdentityGetFirst()

TW_UINT16 TWAIN_IdentityGetFirst ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 255 of file dsm_ctrl.c.

256{
257 pTW_IDENTITY pSourceIdentity = (pTW_IDENTITY) pData;
258
259 TRACE ("DG_CONTROL/DAT_IDENTITY/MSG_GETFIRST\n");
261 if (!nrdevices) {
262 TRACE ("no entries found.\n");
264 return TWRC_FAILURE;
265 }
267 *pSourceIdentity = devices[DSM_currentDevice++].identity;
268 return TWRC_SUCCESS;
269}
static TW_UINT16 DSM_currentDevice
Definition: dsm_ctrl.c:38

Referenced by TWAIN_SourceManagerHandler().

◆ TWAIN_IdentityGetNext()

TW_UINT16 TWAIN_IdentityGetNext ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 272 of file dsm_ctrl.c.

273{
274 pTW_IDENTITY pSourceIdentity = (pTW_IDENTITY) pData;
275
276 TRACE("DG_CONTROL/DAT_IDENTITY/MSG_GETNEXT\n");
279 return TWRC_ENDOFLIST;
280 }
281 *pSourceIdentity = devices[DSM_currentDevice++].identity;
282 return TWRC_SUCCESS;
283}
#define TWRC_ENDOFLIST
Definition: twain.h:1671

Referenced by TWAIN_SourceManagerHandler().

◆ TWAIN_OpenDS()

TW_UINT16 TWAIN_OpenDS ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 286 of file dsm_ctrl.c.

287{
288 TW_UINT16 i = 0;
289 pTW_IDENTITY pIdentity = (pTW_IDENTITY) pData;
290 activeDS *newSource;
292
293 TRACE("DG_CONTROL/DAT_IDENTITY/MSG_OPENDS\n");
294 TRACE("pIdentity is %s\n", pIdentity->ProductName);
295 if (!DSM_initialized) {
296 FIXME("seq error\n");
298 return TWRC_FAILURE;
299 }
301 if (!nrdevices) {
302 FIXME("no devs.\n");
304 return TWRC_FAILURE;
305 }
306
307 if (pIdentity->ProductName[0] != '\0') {
308 /* Make sure the source to be opened exists in the device list */
309 for (i = 0; i<nrdevices; i++)
310 if (!strcmp (devices[i].identity.ProductName, pIdentity->ProductName))
311 break;
312 if (i == nrdevices)
313 i = 0;
314 } /* else use the first device */
315
316 /* the source is found in the device list */
317 newSource = HeapAlloc (GetProcessHeap(), 0, sizeof (activeDS));
318 if (!newSource) {
320 FIXME("Out of memory.\n");
321 return TWRC_FAILURE;
322 }
323 hmod = LoadLibraryW(devices[i].modname);
324 if (!hmod) {
325 ERR("Failed to load TWAIN Source %s\n", debugstr_w(devices[i].modname));
327 HeapFree(GetProcessHeap(), 0, newSource);
328 return TWRC_FAILURE;
329 }
330 newSource->hmod = hmod;
331 newSource->dsEntry = (DSENTRYPROC)GetProcAddress(hmod, "DS_Entry");
332 /* Assign id for the opened data source */
333 pIdentity->Id = DSM_sourceId ++;
334 if (TWRC_SUCCESS != newSource->dsEntry (pOrigin, DG_CONTROL, DAT_IDENTITY, MSG_OPENDS, pIdentity)) {
336 HeapFree(GetProcessHeap(), 0, newSource);
337 DSM_sourceId--;
338 return TWRC_FAILURE;
339 }
340 /* add the data source to an internal active source list */
341 newSource->next = activeSources;
342 newSource->identity.Id = pIdentity->Id;
343 strcpy (newSource->identity.ProductName, pIdentity->ProductName);
344 list_init(&newSource->pending_messages);
345 newSource->ui_window = NULL;
346 newSource->event_window = NULL;
347 activeSources = newSource;
349 return TWRC_SUCCESS;
350}
static void list_init(struct list_entry *head)
Definition: list.h:51
#define FIXME(fmt,...)
Definition: precomp.h:53
strcpy
Definition: string.h:131
HMODULE hmod
Definition: twain_i.h:41
#define TWCC_OPERATIONERROR
Definition: twain.h:1683
#define MSG_OPENDS
Definition: twain.h:1409

Referenced by TWAIN_SourceManagerHandler().

◆ TWAIN_OpenDSM()

TW_UINT16 TWAIN_OpenDSM ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 489 of file dsm_ctrl.c.

490{
491 TW_UINT16 twRC = TWRC_SUCCESS;
492
493 TRACE("DG_CONTROL/DAT_PARENT/MSG_OPENDSM\n");
494 if (!DSM_initialized) {
495 event_message = RegisterWindowMessageA("WINE TWAIN_32 EVENT");
499 twRC = TWRC_SUCCESS;
500 } else {
501 /* operation invoked in invalid state */
503 twRC = TWRC_FAILURE;
504 }
506 return twRC;
507}
HANDLE HWND
Definition: compat.h:19
UINT WINAPI RegisterWindowMessageA(_In_ LPCSTR)

Referenced by TWAIN_SourceManagerHandler().

◆ TWAIN_ProcessEvent()

TW_UINT16 TWAIN_ProcessEvent ( pTW_IDENTITY  pOrigin,
activeDS *  pSource,
TW_MEMREF  pData 
)

Definition at line 168 of file dsm_ctrl.c.

169{
170 TW_EVENT *event = (TW_EVENT*)pData;
171 MSG *msg = (MSG*)event->pEvent;
173
174 TRACE("%x,%x\n", msg->message, event_message);
175
176 if (msg->message == event_message)
177 {
178 if (!list_empty (&pSource->pending_messages))
179 {
180 struct list *entry = list_head (&pSource->pending_messages);
182 event->TWMessage = message->msg;
184 TRACE("<-- %x\n", event->TWMessage);
185 }
186 else
187 event->TWMessage = MSG_NULL;
189 }
190
191 if (msg->hwnd)
192 {
193 MSG dummy;
194 pSource->event_window = msg->hwnd;
195 if (!list_empty (&pSource->pending_messages) &&
197 {
198 PostMessageW(msg->hwnd, event_message, 0, 0);
199 }
200 }
201
202 return result;
203}
#define msg(x)
Definition: auth_time.c:54
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static int list_empty(struct list_entry *head)
Definition: list.h:58
Definition: list.h:39
GLuint64EXT * result
Definition: glext.h:11304
uint32_t entry
Definition: isohybrid.c:63
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_NOREMOVE
Definition: winuser.h:1206
Definition: filter.c:185
Definition: list.h:15
#define LIST_ENTRY(type)
Definition: queue.h:175
#define TWRC_DSEVENT
Definition: twain.h:1668
#define MSG_NULL
Definition: twain.h:1381
#define TWRC_NOTDSEVENT
Definition: twain.h:1669

Referenced by DSM_Entry().

◆ TWAIN_UserSelect()

TW_UINT16 TWAIN_UserSelect ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 433 of file dsm_ctrl.c.

434{
435 userselect_data param = {pOrigin, pData};
437
438 TRACE("DG_CONTROL/DAT_IDENTITY/MSG_USERSELECT SupportedGroups=0x%lx ProductName=%s\n",
439 pOrigin->SupportedGroups, wine_dbgstr_a(param.result->ProductName));
440
442
443 if (!IsWindow(parent))
444 parent = NULL;
445
448 {
449 TRACE("canceled\n");
451 return TWRC_CANCEL;
452 }
453
454 TRACE("<-- %s\n", wine_dbgstr_a(param.result->ProductName));
456 return TWRC_SUCCESS;
457}
#define DLG_USERSELECT
Definition: resource.h:22
r parent
Definition: btrfs.c:3010
static INT_PTR CALLBACK userselect_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: dsm_ctrl.c:357
GLfloat param
Definition: glext.h:5796
LONG_PTR LPARAM
Definition: minwindef.h:175
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
int int static __inline const char * wine_dbgstr_a(const char *s)
Definition: debug.h:160
TW_UINT32 SupportedGroups
Definition: twain.h:261
HINSTANCE DSM_hinstance
Definition: twain32_main.c:34
#define TWRC_CANCEL
Definition: twain.h:1667

Referenced by TWAIN_SourceManagerHandler().

◆ userselect_dlgproc()

static INT_PTR CALLBACK userselect_dlgproc ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 357 of file dsm_ctrl.c.

358{
359 switch (msg)
360 {
361 case WM_INITDIALOG:
362 {
364 int i;
365 HWND sourcelist;
366 BOOL any_devices = FALSE;
367
369
370 sourcelist = GetDlgItem(hwnd, IDC_LISTSOURCE);
371
372 for (i=0; i<nrdevices; i++)
373 {
374 TW_IDENTITY *id = &devices[i].identity;
376
377 if ((id->SupportedGroups & data->origin->SupportedGroups) == 0)
378 continue;
379
380 index = SendMessageA(sourcelist, LB_ADDSTRING, 0, (LPARAM)id->ProductName);
382 any_devices = TRUE;
383 }
384
385 if (any_devices)
386 {
388
389 /* FIXME: Select the supplied product name or default source. */
390 SendMessageW(sourcelist, LB_SETCURSEL, 0, 0);
391 }
392
393 return TRUE;
394 }
395 case WM_CLOSE:
396 EndDialog(hwnd, 0);
397 return TRUE;
398 case WM_COMMAND:
400 {
401 EndDialog(hwnd, 0);
402 return TRUE;
403 }
404 else if (wparam == MAKEWPARAM(IDOK, BN_CLICKED) ||
406 {
408 HWND sourcelist;
410
411 sourcelist = GetDlgItem(hwnd, IDC_LISTSOURCE);
412
413 index = SendMessageW(sourcelist, LB_GETCURSEL, 0, 0);
414
415 if (index == LB_ERR)
416 return TRUE;
417
418 index = SendMessageW(sourcelist, LB_GETITEMDATA, (WPARAM)index, 0);
419
420 *data->result = devices[index].identity;
421
422 /* FIXME: Save this as the default source */
423
424 EndDialog(hwnd, 1);
425 return TRUE;
426 }
427 break;
428 }
429 return FALSE;
430}
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
#define index(s, c)
Definition: various.h:29
#define IDC_LISTSOURCE
Definition: resource.h:24
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint index
Definition: glext.h:6031
GLuint id
Definition: glext.h:5910
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LB_ERR
Definition: winuser.h:2468
#define MAKEWPARAM(l, h)
Definition: winuser.h:4117
#define WM_CLOSE
Definition: winuser.h:1649
#define LB_GETITEMDATA
Definition: winuser.h:2070
#define DWLP_USER
Definition: winuser.h:883
#define GetWindowLongPtrW
Definition: winuser.h:4983
#define IDCANCEL
Definition: winuser.h:842
#define LBN_DBLCLK
Definition: winuser.h:2107
#define WM_COMMAND
Definition: winuser.h:1768
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_INITDIALOG
Definition: winuser.h:1767
#define LB_ADDSTRING
Definition: winuser.h:2060
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:841
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define LB_SETITEMDATA
Definition: winuser.h:2101
#define BN_CLICKED
Definition: winuser.h:1954
#define LB_SETCURSEL
Definition: winuser.h:2099
#define LB_GETCURSEL
Definition: winuser.h:2068
#define SetWindowLongPtrW
Definition: winuser.h:5512
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by TWAIN_UserSelect().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( twain  )

Variable Documentation

◆ detectionrun

BOOL detectionrun = FALSE
static

Definition at line 109 of file dsm_ctrl.c.

Referenced by twain_autodetect().

◆ devices

◆ DSM_currentDevice

TW_UINT16 DSM_currentDevice
static

Definition at line 38 of file dsm_ctrl.c.

Referenced by TWAIN_IdentityGetFirst(), TWAIN_IdentityGetNext(), and TWAIN_OpenDSM().

◆ DSM_initialized

TW_UINT16 DSM_initialized
static

Definition at line 36 of file dsm_ctrl.c.

Referenced by TWAIN_CloseDSM(), TWAIN_OpenDS(), and TWAIN_OpenDSM().

◆ DSM_parent

HWND DSM_parent
static

Definition at line 39 of file dsm_ctrl.c.

Referenced by TWAIN_CloseDSM(), TWAIN_ControlNull(), TWAIN_OpenDSM(), and TWAIN_UserSelect().

◆ DSM_sourceId

TW_UINT32 DSM_sourceId
static

Definition at line 37 of file dsm_ctrl.c.

Referenced by twain_add_onedriver(), and TWAIN_OpenDS().

◆ event_message

UINT event_message
static

Definition at line 40 of file dsm_ctrl.c.

Referenced by TWAIN_ControlNull(), TWAIN_OpenDSM(), and TWAIN_ProcessEvent().

◆ nrdevices