/* DG_CONTROL/DAT_PENDINGXFERS/MSG_ENDXFER */ TW_UINT16 SANE_PendingXfersEndXfer (pTW_IDENTITY pOrigin, TW_MEMREF pData) { #ifndef SONAME_LIBSANE return TWRC_FAILURE; #else TW_UINT16 twRC = TWRC_SUCCESS; pTW_PENDINGXFERS pPendingXfers = (pTW_PENDINGXFERS) pData; SANE_Status status; TRACE("DG_CONTROL/DAT_PENDINGXFERS/MSG_ENDXFER\n"); if (activeDS.currentState != 6 && activeDS.currentState != 7) { twRC = TWRC_FAILURE; activeDS.twCC = TWCC_SEQERROR; } else { pPendingXfers->Count = -1; activeDS.currentState = 6; if (! activeDS.sane_started) { status = psane_start (activeDS.deviceHandle); if (status != SANE_STATUS_GOOD) { TRACE("PENDINGXFERS/MSG_ENDXFER sane_start returns %s\n", psane_strstatus(status)); pPendingXfers->Count = 0; activeDS.currentState = 5; /* Notify the application that it can close the data source */ if (activeDS.windowMessage) PostMessageA(activeDS.hwndOwner, activeDS.windowMessage, MSG_CLOSEDSREQ, 0); } else activeDS.sane_started = TRUE; } twRC = TWRC_SUCCESS; activeDS.twCC = TWCC_SUCCESS; } return twRC; #endif }
/* DG_CONTROL/DAT_PENDINGXFERS/MSG_GET */ TW_UINT16 SANE_PendingXfersGet (pTW_IDENTITY pOrigin, TW_MEMREF pData) { #ifndef SONAME_LIBSANE return TWRC_FAILURE; #else TW_UINT16 twRC = TWRC_SUCCESS; pTW_PENDINGXFERS pPendingXfers = (pTW_PENDINGXFERS) pData; SANE_Status status; TRACE("DG_CONTROL/DAT_PENDINGXFERS/MSG_GET\n"); if (activeDS.currentState < 4 || activeDS.currentState > 7) { twRC = TWRC_FAILURE; activeDS.twCC = TWCC_SEQERROR; } else { pPendingXfers->Count = -1; if (! activeDS.sane_started) { status = psane_start (activeDS.deviceHandle); if (status != SANE_STATUS_GOOD) { TRACE("PENDINGXFERS/MSG_GET sane_start returns %s\n", psane_strstatus(status)); pPendingXfers->Count = 0; } else activeDS.sane_started = TRUE; } twRC = TWRC_SUCCESS; activeDS.twCC = TWCC_SUCCESS; } return twRC; #endif }
/* CAP_AUTOFEED */ static TW_UINT16 SANE_CAPAutofeed (pTW_CAPABILITY pCapability, TW_UINT16 action) { TW_UINT16 twCC = TWCC_BADCAP; #ifdef SONAME_LIBSANE TW_UINT32 val; SANE_Bool autofeed; SANE_Status status; TRACE("CAP_AUTOFEED\n"); if (sane_option_get_bool(activeDS.deviceHandle, "batch-scan", &autofeed, NULL) != SANE_STATUS_GOOD) return TWCC_BADCAP; switch (action) { case MSG_QUERYSUPPORT: twCC = set_onevalue(pCapability, TWTY_INT32, TWQC_GET | TWQC_SET | TWQC_GETDEFAULT | TWQC_GETCURRENT | TWQC_RESET ); break; case MSG_GET: twCC = set_onevalue(pCapability, TWTY_BOOL, autofeed); break; case MSG_SET: twCC = msg_set(pCapability, &val); if (twCC == TWCC_SUCCESS) { if (val) autofeed = SANE_TRUE; else autofeed = SANE_FALSE; status = sane_option_set_bool(activeDS.deviceHandle, "batch-scan", autofeed, NULL); if (status != SANE_STATUS_GOOD) { ERR("Error %s: Could not set batch-scan to %d\n", psane_strstatus(status), autofeed); return sane_status_to_twcc(status); } } break; case MSG_GETDEFAULT: twCC = set_onevalue(pCapability, TWTY_BOOL, SANE_TRUE); break; case MSG_RESET: autofeed = SANE_TRUE; status = sane_option_set_bool(activeDS.deviceHandle, "batch-scan", autofeed, NULL); if (status != SANE_STATUS_GOOD) { ERR("Error %s: Could not reset batch-scan to SANE_TRUE\n", psane_strstatus(status)); return sane_status_to_twcc(status); } /* .. fall through intentional .. */ case MSG_GETCURRENT: twCC = set_onevalue(pCapability, TWTY_BOOL, autofeed); break; } #endif return twCC; }
/* CAP_FEEDERENABLED */ static TW_UINT16 SANE_CAPFeederEnabled (pTW_CAPABILITY pCapability, TW_UINT16 action) { TW_UINT16 twCC = TWCC_BADCAP; #ifdef SONAME_LIBSANE TW_UINT32 val; TW_BOOL enabled; SANE_Status status; SANE_Char source[64]; TRACE("CAP_FEEDERENABLED\n"); if (sane_option_get_str(activeDS.deviceHandle, SANE_NAME_SCAN_SOURCE, source, sizeof(source), NULL) != SANE_STATUS_GOOD) return TWCC_BADCAP; if (strcmp(source, "Auto") == 0 || strcmp(source, "ADF") == 0) enabled = TRUE; else enabled = FALSE; switch (action) { case MSG_QUERYSUPPORT: twCC = set_onevalue(pCapability, TWTY_INT32, TWQC_GET | TWQC_SET | TWQC_GETDEFAULT | TWQC_GETCURRENT | TWQC_RESET ); break; case MSG_GET: twCC = set_onevalue(pCapability, TWTY_BOOL, enabled); break; case MSG_SET: twCC = msg_set(pCapability, &val); if (twCC == TWCC_SUCCESS) { if (val) enabled = TRUE; else enabled = FALSE; strcpy(source, "ADF"); status = sane_option_set_str(activeDS.deviceHandle, SANE_NAME_SCAN_SOURCE, source, NULL); if (status != SANE_STATUS_GOOD) { strcpy(source, "Auto"); status = sane_option_set_str(activeDS.deviceHandle, SANE_NAME_SCAN_SOURCE, source, NULL); } if (status != SANE_STATUS_GOOD) { ERR("Error %s: Could not set source to either ADF or Auto\n", psane_strstatus(status)); return sane_status_to_twcc(status); } } break; case MSG_GETDEFAULT: twCC = set_onevalue(pCapability, TWTY_BOOL, TRUE); break; case MSG_RESET: strcpy(source, "Auto"); if (sane_option_set_str(activeDS.deviceHandle, SANE_NAME_SCAN_SOURCE, source, NULL) == SANE_STATUS_GOOD) enabled = TRUE; twCC = TWCC_SUCCESS; /* .. fall through intentional .. */ case MSG_GETCURRENT: twCC = set_onevalue(pCapability, TWTY_BOOL, enabled); break; } #endif return twCC; }