server: Allow the main exe to be registered as a normal dll before
[wine] / dlls / twain / ds_ctrl.c
1 /*
2  * Copyright 2000 Corel Corporation
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include "config.h"
20
21 #ifdef HAVE_UNISTD_H
22 # include <unistd.h>
23 #endif
24 #include <stdlib.h>
25 #include "twain.h"
26 #include "twain_i.h"
27 #include "wine/debug.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(twain);
30
31 /* DG_CONTROL/DAT_CAPABILITY/MSG_GET */
32 TW_UINT16 TWAIN_CapabilityGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
33                                TW_MEMREF pData)
34 {
35     TW_UINT16 twRC = TWRC_SUCCESS, twCC = TWCC_SUCCESS;
36     pTW_CAPABILITY pCapability = (pTW_CAPABILITY) pData;
37     activeDS *pSource = TWAIN_LookupSource (pDest);
38
39     TRACE("DG_CONTROL/DAT_CAPABILITY/MSG_GET\n");
40
41     if (!pDest)
42     {
43         twRC = TWRC_FAILURE;
44         DSM_twCC = TWCC_BADDEST;
45     }
46     else if (pSource->currentState < 4 || pSource->currentState > 7)
47     {
48         twRC = TWRC_FAILURE;
49         pSource->twCC = TWCC_SEQERROR;
50     }
51     else
52     {
53         twCC = TWAIN_SaneCapability (pSource, pCapability, MSG_GET);
54         twRC = (twCC == TWCC_SUCCESS)?TWRC_SUCCESS:TWRC_FAILURE;
55         pSource->twCC = twCC;
56     }
57
58     return twRC;
59 }
60
61 /* DG_CONTROL/DAT_CAPABILITY/MSG_GETCURRENT */
62 TW_UINT16 TWAIN_CapabilityGetCurrent (pTW_IDENTITY pOrigin,
63                                       pTW_IDENTITY pDest,TW_MEMREF pData)
64 {
65     TW_UINT16 twRC = TWRC_SUCCESS, twCC = TWCC_SUCCESS;
66     pTW_CAPABILITY pCapability = (pTW_CAPABILITY) pData;
67     activeDS *pSource = TWAIN_LookupSource (pDest);
68
69     TRACE("DG_CONTROL/DAT_CAPABILITY/MSG_GETCURRENT\n");
70
71     if (!pSource)
72     {
73         twRC = TWRC_FAILURE;
74         DSM_twCC = TWCC_BADDEST;
75     }
76     else if (pSource->currentState < 4 || pSource->currentState > 7)
77     {
78         twRC = TWRC_FAILURE;
79         pSource->twCC = TWCC_SEQERROR;
80     }
81     else
82     {
83         twCC = TWAIN_SaneCapability (pSource, pCapability, MSG_GETCURRENT);
84         twRC = (twCC == TWCC_SUCCESS)?TWRC_SUCCESS:TWRC_FAILURE;
85         pSource->twCC = twCC;
86     }
87
88     return twRC;
89 }
90
91 /* DG_CONTROL/DAT_CAPABILITY/MSG_GETDEFAULT */
92 TW_UINT16 TWAIN_CapabilityGetDefault (pTW_IDENTITY pOrigin,
93                                       pTW_IDENTITY pDest, TW_MEMREF pData)
94 {
95     TW_UINT16 twRC = TWRC_SUCCESS, twCC = TWCC_SUCCESS;
96     pTW_CAPABILITY pCapability = (pTW_CAPABILITY) pData;
97     activeDS *pSource = TWAIN_LookupSource (pDest);
98
99     TRACE("DG_CONTROL/DAT_CAPABILITY/MSG_GETDEFAULT\n");
100
101     if (!pDest)
102     {
103         twRC = TWRC_FAILURE;
104         DSM_twCC = TWCC_BADDEST;
105     }
106     else if (pSource->currentState < 4 || pSource->currentState > 7)
107     {
108         twRC = TWRC_FAILURE;
109         pSource->twCC = TWCC_SEQERROR;
110     }
111     else
112     {
113         twCC = TWAIN_SaneCapability (pSource, pCapability, MSG_GETDEFAULT);
114         twRC = (twCC == TWCC_SUCCESS)?TWRC_SUCCESS:TWRC_FAILURE;
115         pSource->twCC = twCC;
116     }
117
118     return twRC;
119 }
120
121 /* DG_CONTROL/DAT_CAPABILITY/MSG_QUERYSUPPORT */
122 TW_UINT16 TWAIN_CapabilityQuerySupport (pTW_IDENTITY pOrigin,
123                                         pTW_IDENTITY pDest, TW_MEMREF pData)
124 {
125     FIXME ("stub!\n");
126
127     return TWRC_FAILURE;
128 }
129
130 /* DG_CONTROL/DAT_CAPABILITY/MSG_RESET */
131 TW_UINT16 TWAIN_CapabilityReset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
132                                  TW_MEMREF pData)
133 {
134     TW_UINT16 twRC = TWRC_SUCCESS, twCC = TWCC_SUCCESS;
135     pTW_CAPABILITY pCapability = (pTW_CAPABILITY) pData;
136     activeDS *pSource = TWAIN_LookupSource (pDest);
137
138     TRACE("DG_CONTROL/DAT_CAPABILITY/MSG_RESET\n");
139
140     if (!pDest)
141     {
142         twRC = TWRC_FAILURE;
143         DSM_twCC = TWCC_BADDEST;
144     }
145     else if (pSource->currentState < 4 || pSource->currentState > 7)
146     {
147         twRC = TWRC_FAILURE;
148         pSource->twCC = TWCC_SEQERROR;
149     }
150     else
151     {
152         twCC = TWAIN_SaneCapability (pSource, pCapability, MSG_RESET);
153         twRC = (twCC == TWCC_SUCCESS)?TWRC_SUCCESS:TWRC_FAILURE;
154         pSource->twCC = twCC;
155     }
156
157     return twRC;
158 }
159
160 /* DG_CONTROL/DAT_CAPABILITY/MSG_SET */
161 TW_UINT16 TWAIN_CapabilitySet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
162                                TW_MEMREF pData)
163 {
164     TW_UINT16 twRC = TWRC_SUCCESS, twCC = TWCC_SUCCESS;
165     pTW_CAPABILITY pCapability = (pTW_CAPABILITY) pData;
166     activeDS *pSource = TWAIN_LookupSource (pDest);
167
168     TRACE ("DG_CONTROL/DAT_CAPABILITY/MSG_SET\n");
169
170     if (!pSource)
171     {
172         twRC = TWRC_FAILURE;
173         DSM_twCC = TWCC_BADDEST;
174     }
175     else if (pSource->currentState != 4)
176     {
177         twRC = TWRC_FAILURE;
178         pSource->twCC = TWCC_SEQERROR;
179     }
180     else
181     {
182         twCC = TWAIN_SaneCapability (pSource, pCapability, MSG_SET);
183         twRC = (twCC == TWCC_SUCCESS)?TWRC_SUCCESS:TWRC_FAILURE;
184         pSource->twCC = twCC;
185     }
186     return twRC;
187 }
188
189 /* DG_CONTROL/DAT_CUSTOMDSDATA/MSG_GET */
190 TW_UINT16 TWAIN_CustomDSDataGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
191                                 TW_MEMREF pData)
192 {
193     FIXME ("stub!\n");
194
195     return TWRC_FAILURE;
196 }
197
198 /* DG_CONTROL/DAT_CUSTOMDSDATA/MSG_SET */
199 TW_UINT16 TWAIN_CustomDSDataSet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
200                                  TW_MEMREF pData)
201 {
202     FIXME ("stub!\n");
203
204     return TWRC_FAILURE;
205 }
206
207 /* DG_CONTROL/DAT_FILESYSTEM/MSG_AUTOMATICCAPTUREDIRECTORY */
208 TW_UINT16 TWAIN_AutomaticCaptureDirectory (pTW_IDENTITY pOrigin,
209                                            pTW_IDENTITY pDest,
210                                            TW_MEMREF pData)
211 {
212     FIXME ("stub!\n");
213
214     return TWRC_FAILURE;
215 }
216
217 /* DG_CONTROL/DAT_FILESYSTEM/MSG_CHANGEDIRECTORY */
218 TW_UINT16 TWAIN_ChangeDirectory (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
219                                  TW_MEMREF pData)
220 {
221     FIXME ("stub!\n");
222
223     return TWRC_FAILURE;
224 }
225
226 /* DG_CONTROL/DAT_FILESYSTEM/MSG_COPY */
227 TW_UINT16 TWAIN_FileSystemCopy (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
228                                 TW_MEMREF pData)
229 {
230     FIXME ("stub!\n");
231
232     return TWRC_FAILURE;
233 }
234
235 /* DG_CONTROL/DAT_FILESYSTEM/MSG_CREATEDIRECTORY */
236 TW_UINT16 TWAIN_CreateDirectory (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
237                                  TW_MEMREF pData)
238 {
239     FIXME ("stub!\n");
240
241     return TWRC_FAILURE;
242 }
243
244 /* DG_CONTROL/DAT_FILESYSTEM/MSG_DELETE */
245 TW_UINT16 TWAIN_FileSystemDelete (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
246                                   TW_MEMREF pData)
247 {
248     FIXME ("stub!\n");
249
250     return TWRC_FAILURE;
251 }
252
253 /* DG_CONTROL/DAT_FILESYSTEM/MSG_FORMATMEDIA */
254 TW_UINT16 TWAIN_FormatMedia (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
255                              TW_MEMREF pData)
256 {
257     FIXME ("stub!\n");
258
259     return TWRC_FAILURE;
260 }
261
262 /* DG_CONTROL/DAT_FILESYSTEM/MSG_GETCLOSE */
263 TW_UINT16 TWAIN_FileSystemGetClose (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
264                                     TW_MEMREF pData)
265 {
266     FIXME ("stub!\n");
267
268     return TWRC_FAILURE;
269 }
270
271 /* DG_CONTROL/DAT_FILESYSTEM/MSG_GETFIRSTFILE */
272 TW_UINT16 TWAIN_FileSystemGetFirstFile (pTW_IDENTITY pOrigin,
273                                         pTW_IDENTITY pDest,
274                                         TW_MEMREF pData)
275 {
276     FIXME ("stub!\n");
277
278     return TWRC_FAILURE;
279 }
280
281 /* DG_CONTROL/DAT_FILESYSTEM/MSG_GETINFO */
282 TW_UINT16 TWAIN_FileSystemGetInfo (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
283                                    TW_MEMREF pData)
284 {
285     FIXME ("stub!\n");
286
287     return TWRC_FAILURE;
288 }
289
290 /* DG_CONTROL/DAT_FILESYSTEM/MSG_GETNEXTFILE */
291 TW_UINT16 TWAIN_FileSystemGetNextFile (pTW_IDENTITY pOrigin,
292                                        pTW_IDENTITY pDest,
293                                        TW_MEMREF pData)
294 {
295     FIXME ("stub!\n");
296
297     return TWRC_FAILURE;
298 }
299
300 /* DG_CONTROL/DAT_FILESYSTEM/MSG_RENAME */
301 TW_UINT16 TWAIN_FileSystemRename (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
302                                   TW_MEMREF pData)
303 {
304     FIXME ("stub!\n");
305
306     return TWRC_FAILURE;
307 }
308
309 /* DG_CONTROL/DAT_EVENT/MSG_PROCESSEVENT */
310 TW_UINT16 TWAIN_ProcessEvent (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
311                               TW_MEMREF pData)
312 {
313     TW_UINT16 twRC = TWRC_SUCCESS;
314     pTW_EVENT pEvent = (pTW_EVENT) pData;
315     activeDS *pSource = TWAIN_LookupSource (pDest);
316
317     TRACE("DG_CONTROL/DAT_EVENT/MSG_PROCESSEVENT\n");
318
319     if (!pSource)
320     {
321          twRC = TWRC_FAILURE;
322          DSM_twCC = TWCC_BADDEST;
323     }
324     else if (pSource->currentState < 5 || pSource->currentState > 7)
325     {
326         twRC = TWRC_FAILURE;
327         pSource->twCC = TWCC_SEQERROR;
328     }
329     else
330     {
331         if (pSource->pendingEvent.TWMessage != MSG_NULL)
332         {
333             pEvent->TWMessage = pSource->pendingEvent.TWMessage;
334             pSource->pendingEvent.TWMessage = MSG_NULL;
335             twRC = TWRC_DSEVENT;
336         }
337         else
338         {
339             pEvent->TWMessage = MSG_NULL;  /* no message to the application */
340             twRC = TWRC_NOTDSEVENT;
341         }
342         pSource->twCC = TWCC_SUCCESS;
343     }
344
345     return twRC;
346 }
347
348 /* DG_CONTROL/DAT_PASSTHRU/MSG_PASSTHRU */
349 TW_UINT16 TWAIN_PassThrough (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
350                              TW_MEMREF pData)
351 {
352     FIXME ("stub!\n");
353
354     return TWRC_FAILURE;
355 }
356
357 /* DG_CONTROL/DAT_PENDINGXFERS/MSG_ENDXFER */
358 TW_UINT16 TWAIN_PendingXfersEndXfer (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
359                                      TW_MEMREF pData)
360 {
361     TW_UINT16 twRC = TWRC_SUCCESS;
362     pTW_PENDINGXFERS pPendingXfers = (pTW_PENDINGXFERS) pData;
363     activeDS *pSource = TWAIN_LookupSource (pData);
364
365     TRACE("DG_CONTROL/DAT_PENDINGXFERS/MSG_ENDXFER\n");
366
367     if (!pSource)
368     {
369         twRC = TWRC_FAILURE;
370         DSM_twCC = TWCC_BADDEST;
371     }
372     else if (pSource->currentState != 6 && pSource->currentState != 7)
373     {
374         twRC = TWRC_FAILURE;
375         pSource->twCC = TWCC_SEQERROR;
376     }
377     else
378     {
379         if (pPendingXfers->Count != 0)
380         {
381             pPendingXfers->Count --;
382             pSource->currentState = 6;
383         }
384         else
385         {
386             pSource->currentState = 5;
387             /* Notify the application that it can close the data source */
388             pSource->pendingEvent.TWMessage = MSG_CLOSEDSREQ;
389         }
390         twRC = TWRC_SUCCESS;
391         pSource->twCC = TWCC_SUCCESS;
392     }
393
394     return twRC;
395 }
396
397 /* DG_CONTROL/DAT_PENDINGXFERS/MSG_GET */
398 TW_UINT16 TWAIN_PendingXfersGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
399                                  TW_MEMREF pData)
400 {
401     TW_UINT16 twRC = TWRC_SUCCESS;
402     pTW_PENDINGXFERS pPendingXfers = (pTW_PENDINGXFERS) pData;
403     activeDS *pSource = TWAIN_LookupSource (pDest);
404
405     TRACE("DG_CONTROL/DAT_PENDINGXFERS/MSG_GET\n");
406
407     if (!pSource)
408     {
409         twRC = TWRC_FAILURE;
410         DSM_twCC = TWCC_BADDEST;
411     }
412     else if (pSource->currentState < 4 || pSource->currentState > 7)
413     {
414         twRC = TWRC_FAILURE;
415         DSM_twCC = TWCC_SEQERROR;
416     }
417     else
418     {
419         /* FIXME: we shouldn't return 1 here */
420         pPendingXfers->Count = 1;
421         twRC = TWRC_SUCCESS;
422         pSource->twCC = TWCC_SUCCESS;
423     }
424
425     return twRC;
426 }
427
428 /* DG_CONTROL/DAT_PENDINGXFERS/MSG_RESET */
429 TW_UINT16 TWAIN_PendingXfersReset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
430                                    TW_MEMREF pData)
431 {
432     TW_UINT16 twRC = TWRC_SUCCESS;
433     pTW_PENDINGXFERS pPendingXfers = (pTW_PENDINGXFERS) pData;
434     activeDS *pSource = TWAIN_LookupSource (pDest);
435
436     TRACE("DG_CONTROL/DAT_PENDINGXFERS/MSG_RESET\n");
437
438     if (!pSource)
439     {
440         twRC = TWRC_FAILURE;
441         DSM_twCC = TWCC_BADDEST;
442     }
443     else if (pSource->currentState != 6)
444     {
445         twRC = TWRC_FAILURE;
446         DSM_twCC = TWCC_SEQERROR;
447     }
448     else
449     {
450         pPendingXfers->Count = 0;
451         pSource->currentState = 5;
452         twRC = TWRC_SUCCESS;
453         pSource->twCC = TWCC_SUCCESS;
454     }
455
456     return twRC;
457 }
458
459 /* DG_CONTROL/DAT_PENDINGXFERS/MSG_STOPFEEDER */
460 TW_UINT16 TWAIN_PendingXfersStopFeeder (pTW_IDENTITY pOrigin,
461                                         pTW_IDENTITY pDest, TW_MEMREF pData)
462 {
463     FIXME ("stub!\n");
464
465     return TWRC_FAILURE;
466 }
467
468 /* DG_CONTROL/DAT_SETUPFILEXFER/MSG_GET */
469 TW_UINT16 TWAIN_SetupFileXferGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
470                                   TW_MEMREF pData)
471 {
472     FIXME ("stub!\n");
473
474     return TWRC_FAILURE;
475 }
476
477 /* DG_CONTROL/DAT_SETUPXFER/MSG_GETDEFAULT */
478 TW_UINT16 TWAIN_SetupFileXferGetDefault (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
479                                          TW_MEMREF pData)
480 {
481     FIXME ("stub!\n");
482
483     return TWRC_FAILURE;
484 }
485
486
487 /* DG_CONTROL/DAT_SETUPFILEXFER/MSG_RESET */
488 TW_UINT16 TWAIN_SetupFileXferReset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
489                                     TW_MEMREF pData)
490 {
491     FIXME ("stub!\n");
492
493     return TWRC_FAILURE;
494 }
495
496 /* DG_CONTROL/DAT_SETUPFILEXFER/MSG_SET */
497 TW_UINT16 TWAIN_SetupFileXferSet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
498                                   TW_MEMREF pData)
499 {
500     FIXME ("stub!\n");
501
502     return TWRC_FAILURE;
503 }
504
505 /* DG_CONTROL/DAT_SETUPFILEXFER2/MSG_GET */
506 TW_UINT16 TWAIN_SetupFileXfer2Get (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
507                                    TW_MEMREF pData)
508 {
509     FIXME ("stub!\n");
510
511     return TWRC_FAILURE;
512 }
513
514 /* DG_CONTROL/DAT_SETUPFILEXFER2/MSG_GETDEFAULT */
515 TW_UINT16 TWAIN_SetupFileXfer2GetDefault (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
516                                          TW_MEMREF pData)
517 {
518     FIXME ("stub!\n");
519
520     return TWRC_FAILURE;
521 }
522
523 /* DG_CONTROL/DAT_SETUPFILEXFER2/MSG_RESET */
524 TW_UINT16 TWAIN_SetupFileXfer2Reset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
525                                   TW_MEMREF pData)
526 {
527     FIXME ("stub!\n");
528
529     return TWRC_FAILURE;
530 }
531
532 /* DG_CONTROL/DAT_SETUPFILEXFER2/MSG_SET */
533 TW_UINT16 TWAIN_SetupFileXfer2Set (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
534                                   TW_MEMREF pData)
535 {
536     FIXME ("stub!\n");
537
538     return TWRC_FAILURE;
539 }
540
541 /* DG_CONTROL/DAT_SETUPMEMXFER/MSG_GET */
542 TW_UINT16 TWAIN_SetupMemXferGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
543                                   TW_MEMREF pData)
544 {
545     FIXME ("stub!\n");
546
547     return TWRC_FAILURE;
548 }
549
550 /* DG_CONTROL/DAT_STATUS/MSG_GET */
551 TW_UINT16 TWAIN_GetDSStatus (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
552                              TW_MEMREF pData)
553 {
554     TW_UINT16 twRC = TWRC_FAILURE;
555     pTW_STATUS pSourceStatus = (pTW_STATUS) pData;
556     activeDS *pSource = TWAIN_LookupSource (pDest);
557
558     TRACE ("DG_CONTROL/DAT_STATUS/MSG_GET\n");
559
560     if (!pSource)
561     {
562         twRC = TWRC_FAILURE;
563         DSM_twCC = TWCC_BADDEST;
564         pSourceStatus->ConditionCode = TWCC_BADDEST;
565     }
566     else
567     {
568         twRC = TWRC_SUCCESS;
569         pSourceStatus->ConditionCode = pSource->twCC;
570         /* Reset the condition code */
571         pSource->twCC = TWCC_SUCCESS;
572     }
573
574     return twRC;
575 }
576
577 /* DG_CONTROL/DAT_USERINTERFACE/MSG_DISABLEDS */
578 TW_UINT16 TWAIN_DisableDSUserInterface (pTW_IDENTITY pOrigin,
579                                         pTW_IDENTITY pDest, TW_MEMREF pData)
580 {
581     TW_UINT16 twRC = TWRC_SUCCESS;
582     activeDS *pSource = TWAIN_LookupSource (pDest);
583
584     TRACE ("DG_CONTROL/DAT_USERINTERFACE/MSG_DISABLEDS\n");
585
586     if (!pSource)
587     {
588         twRC = TWRC_FAILURE;
589         DSM_twCC = TWCC_BADDEST;
590     }
591     else if (pSource->currentState != 5)
592     {
593         twRC = TWRC_FAILURE;
594         pSource->twCC = TWCC_SEQERROR;
595     }
596     else
597     {
598         pSource->currentState = 4;
599         twRC = TWRC_SUCCESS;
600         pSource->twCC = TWCC_SUCCESS;
601     }
602
603     return twRC;
604 }
605
606 /* DG_CONTROL/DAT_USERINTERFACE/MSG_ENABLEDS */
607 TW_UINT16 TWAIN_EnableDSUserInterface (pTW_IDENTITY pOrigin,
608                                        pTW_IDENTITY pDest, TW_MEMREF pData)
609 {
610     TW_UINT16 twRC = TWRC_SUCCESS;
611     pTW_USERINTERFACE pUserInterface = (pTW_USERINTERFACE) pData;
612     activeDS *pSource = TWAIN_LookupSource (pDest);
613
614     TRACE ("DG_CONTROL/DAT_USERINTERFACE/MSG_ENABLEDS\n");
615
616     if (!pSource)
617     {
618         twRC = TWRC_FAILURE;
619         DSM_twCC = TWCC_BADDEST;
620     }
621     else if (pSource->currentState != 4)
622     {
623         twRC = TWRC_FAILURE;
624         pSource->twCC = TWCC_SEQERROR;
625     }
626     else
627     {
628         if (pUserInterface->ShowUI)
629         {
630             pSource->currentState = 5; /* Transitions to state 5 */
631             /* FIXME: we should replace xscanimage with our own device UI */
632             system ("xscanimage");
633             pSource->currentState = 6;
634             pSource->pendingEvent.TWMessage = MSG_XFERREADY;
635         }
636         else
637         {
638             /* no UI will be displayed, so source is ready to transfer data */
639             pSource->pendingEvent.TWMessage = MSG_XFERREADY;
640             pSource->currentState = 6; /* Transitions to state 6 directly */
641         }
642
643         pSource->hwndOwner = pUserInterface->hParent;
644         twRC = TWRC_SUCCESS;
645         pSource->twCC = TWCC_SUCCESS;
646     }
647
648     return twRC;
649 }
650
651 /* DG_CONTROL/DAT_USERINTERFACE/MSG_ENABLEDSUIONLY */
652 TW_UINT16 TWAIN_EnableDSUIOnly (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
653                                 TW_MEMREF pData)
654 {
655     TW_UINT16 twRC = TWRC_SUCCESS;
656     activeDS *pSource = TWAIN_LookupSource (pDest);
657
658     TRACE("DG_CONTROL/DAT_USERINTERFACE/MSG_ENABLEDSUIONLY\n");
659
660     if (!pSource)
661     {
662         twRC = TWRC_FAILURE;
663         DSM_twCC = TWCC_BADDEST;
664     }
665     else if (pSource->currentState != 4)
666     {
667         twRC = TWRC_FAILURE;
668         pSource->twCC = TWCC_SEQERROR;
669     }
670     else
671     {
672         /* FIXME: we should replace xscanimage with our own UI */
673         system ("xscanimage");
674         pSource->currentState = 5;
675         twRC = TWRC_SUCCESS;
676         pSource->twCC = TWCC_SUCCESS;
677     }
678
679     return twRC;
680 }
681
682 /* DG_CONTROL/DAT_XFERGROUP/MSG_GET */
683 TW_UINT16 TWAIN_XferGroupGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
684                               TW_MEMREF pData)
685 {
686     FIXME ("stub!\n");
687
688     return TWRC_FAILURE;
689 }
690
691 /* DG_CONTROL/DAT_XFERGROUP/MSG_SET */
692 TW_UINT16 TWAIN_XferGroupSet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
693                                   TW_MEMREF pData)
694 {
695     FIXME ("stub!\n");
696
697     return TWRC_FAILURE;
698 }