From: Bernd Herd codeberg@herdsoft.com
They are the only functions to call sane_cancel and start_device --- dlls/sane.ds/ds_image.c | 69 +++++++++++++++++++++++++++++++++++++++++ dlls/sane.ds/sane_i.h | 2 ++ 2 files changed, 71 insertions(+)
diff --git a/dlls/sane.ds/ds_image.c b/dlls/sane.ds/ds_image.c index 032cc755bb4..534b512870c 100644 --- a/dlls/sane.ds/ds_image.c +++ b/dlls/sane.ds/ds_image.c @@ -26,6 +26,75 @@
WINE_DEFAULT_DEBUG_CHANNEL(twain);
+ +/* transition from state 6 to state 7. + * + * Called by either SANE_ImageMemXferGet, SANE_ImageInfoGet or + * SANE_ImageNativeXferGet, whatever the application calls first. + * + * - start the scan with a call to sane start_devince + * - open the progress dialog window + * - call get_sane_params to retrieve parameters of current scan frame + * + * @return TWAIN result code, TWRC_SUCCESS on success + */ +TW_UINT16 SANE_Start(void) +{ + TW_UINT16 twRC = TWRC_SUCCESS; + TRACE("SANE_Start currentState:%d\n", activeDS.currentState); + if (activeDS.currentState != 6) + { + twRC = TWRC_FAILURE; + activeDS.twCC = TWCC_SEQERROR; + } + else + { + /* Open progress dialog */ + activeDS.progressWnd = ScanningDialogBox(activeDS.progressWnd,0); + + /* Start the scan process in sane */ + if (SANE_CALL( start_device, NULL )) + { + activeDS.progressWnd = ScanningDialogBox(activeDS.progressWnd, -1); + activeDS.twCC = TWCC_OPERATIONERROR; + return TWRC_FAILURE; + } + + if (get_sane_params( &activeDS.frame_params )) + { + WARN("sane_get_parameters failed\n"); + SANE_CALL( cancel_device, NULL ); + activeDS.progressWnd = ScanningDialogBox(activeDS.progressWnd, -1); + activeDS.twCC = TWCC_OPERATIONERROR; + return TWRC_FAILURE; + } + + TRACE("Acquiring image %dx%dx%d bits (format=%d last=%d) from sane...\n" + , activeDS.frame_params.pixels_per_line, activeDS.frame_params.lines, + activeDS.frame_params.depth, activeDS.frame_params.format, + activeDS.frame_params.last_frame); + + activeDS.currentState = 7; + } + return twRC; +} + +/** transition from state 7 or 6 to state 5. + * + * Called when an error occurs or when the last frame + * has been transfered successfully. + * - call sane cancel_device to finish any open transfer + * - close the progress dialog box. + */ +void SANE_Cancel(void) +{ + SANE_CALL( cancel_device, NULL ); + activeDS.progressWnd = ScanningDialogBox(activeDS.progressWnd, -1); + activeDS.currentState = 5; +} + + + /* DG_IMAGE/DAT_IMAGEINFO/MSG_GET */ TW_UINT16 SANE_ImageInfoGet (pTW_IDENTITY pOrigin, TW_MEMREF pData) diff --git a/dlls/sane.ds/sane_i.h b/dlls/sane.ds/sane_i.h index 9d6f28d1e80..afcee445006 100644 --- a/dlls/sane.ds/sane_i.h +++ b/dlls/sane.ds/sane_i.h @@ -60,6 +60,8 @@ extern struct tagActiveDS activeDS; extern TW_UINT16 SANE_SaneCapability (pTW_CAPABILITY pCapability, TW_UINT16 action); extern TW_UINT16 SANE_SaneSetDefaults (void); extern void SANE_Notify (TW_UINT16 message); +extern TW_UINT16 SANE_Start(void); +extern void SANE_Cancel(void);
/* Implementation of operation triplets * From Application to Source (Control Information) */