LibInsane
1.0.10
Cross-platform Cross-API Cross-driver Cross-image-scanner Image Scan Library
|
#include "capi.h"
Go to the source code of this file.
Functions | |
enum lis_error | lis_api_workaround_opt_names (struct lis_api *to_wrap, struct lis_api **out_impl) |
Fix options names. More... | |
enum lis_error | lis_api_workaround_opt_values (struct lis_api *to_wrap, struct lis_api **out_impl) |
Replace unusual option values by usual ones. More... | |
enum lis_error | lis_api_workaround_check_capabilities (struct lis_api *to_wrap, struct lis_api **out_impl) |
Prevent operations on options that are not allowed by capabilities. More... | |
enum lis_error | lis_api_workaround_hide_source_auto (struct lis_api *to_wrap, struct lis_api **out_impl) |
Disable source 'Auto'. More... | |
enum lis_error | lis_api_workaround_dedicated_thread (struct lis_api *to_wrap, struct lis_api **out_impl) |
Thread-safety. More... | |
enum lis_error | lis_api_workaround_one_page_flatbed (struct lis_api *to_wrap, struct lis_api **out_impl) |
Ensure Flatbeds return only one page. More... | |
enum lis_error | lis_api_workaround_cache (struct lis_api *to_wrap, struct lis_api **out_impl) |
Minimize calls to underlying API. More... | |
enum lis_error | lis_api_workaround_lamp (struct lis_api *to_wrap, struct lis_api **out_impl) |
Turns the lamp off at the end of the scan. More... | |
enum lis_error | lis_api_workaround_invalid_page_size (struct lis_api *to_wrap, struct lis_api **out_impl) |
Retuns TRUE to end_of_feed on invalid page size. More... | |
Minimize calls to underlying API.
Some drivers or combinations of drivers seem to be very touchy. This workaround aim to reduce to a strict minimum all the calls to list_options(), option->fn.set(), option->fn.get().
Assumes that the 'set_flags' when calling option->fn.set() is reliable.
Also keep track of the items. Return the same items as long as they haven't been closed. This reduce risk of programming error (even more when using the GObject layer).
enum lis_error lis_api_workaround_check_capabilities | ( | struct lis_api * | to_wrap, |
struct lis_api ** | out_impl | ||
) |
Prevent operations on options that are not allowed by capabilities.
Some drivers allows access to inactive options (even just for reading). Some may even crash if the user application tries to set a value on an inactive option.
Behavior is undefined when trying to set read-only values. This workaround makes it defined: it always returns an error.
When trying to set a value on a property that accept only one value (ex: source=ADF), Sane driver may return SANE_STATUS_INVAL instead of success. This workaround makes sure the value provided matches the only one possible and doesn't even set it.
[in] | to_wrap | Base implementation to wrap. |
[out] | out_impl | Implementation of the out_impl including the workaround. |
enum lis_error lis_api_workaround_dedicated_thread | ( | struct lis_api * | to_wrap, |
struct lis_api ** | out_impl | ||
) |
Thread-safety.
Most scanner APIs are not thread-safe. If you're lucky, they may work from different threads anyway. If you're not, they will crash your program.
This workaround works around this issue by creating a dedicated thread for the job and making all the request go through this thread.
[in] | to_wrap | Base implementation to wrap. |
[out] | out_impl | Implementation of the out_impl including the workaround. |
enum lis_error lis_api_workaround_hide_source_auto | ( | struct lis_api * | to_wrap, |
struct lis_api ** | out_impl | ||
) |
Disable source 'Auto'.
Flatbed can only contain one single page. However when requesting another page/image, some drivers keep saying "yeah sure no problem" instead of "no more pages", and keep returning the same page/image again and again. The workaround 'one_page_flatbed' work around this problem by looking at the source name and guessing whether we should expect only one page or more. Thing is, when using the source 'auto', this workaround has no way of guessing. So this workaround doesn't work with the source 'auto'.
Therefore, the simplest solution is to hide the source 'auto' when using Sane.
enum lis_error lis_api_workaround_invalid_page_size | ( | struct lis_api * | to_wrap, |
struct lis_api ** | out_impl | ||
) |
Retuns TRUE to end_of_feed on invalid page size.
When calling sane_start(), the Brother backend reports there is a next page. But when requesting the page size, we get something absurd like 2500x0.
This workaround makes sure that when it happens, end_of_feed() is correctly reported.
Remark: an height of -1 means there is still some paper to scan but we don't know the page size yet.
Turns the lamp off at the end of the scan.
When scanning with the Canon Lide 30, the driver doesn't turn off the lamp at the end of the scan. Without this workaround, the lamp remains on until the scanner is powered down.
enum lis_error lis_api_workaround_one_page_flatbed | ( | struct lis_api * | to_wrap, |
struct lis_api ** | out_impl | ||
) |
Ensure Flatbeds return only one page.
Flatbed can only contain one single page. However when requesting another page/image, some drivers keep saying "yeah sure no problem" instead of "no more pages", and keep returning the same page/image again and again.
Requires normalizer 'normalizer_source_types'.
[in] | to_wrap | Base implementation to wrap. |
[out] | out_impl | Implementation of the out_impl including the workaround. |
enum lis_error lis_api_workaround_opt_names | ( | struct lis_api * | to_wrap, |
struct lis_api ** | out_impl | ||
) |
Fix options names.
The option 'resolution' is mistakenly named 'scan-resolution'. This workaround replaces it by an option 'resolution'.
The option 'source' is mistakenly named 'doc-source'. This workaround replaces it by an option option 'source'.
[in] | to_wrap | Base implementation to wrap. |
[out] | out_impl | Implementation of the out_impl including the workaround. |
enum lis_error lis_api_workaround_opt_values | ( | struct lis_api * | to_wrap, |
struct lis_api ** | out_impl | ||
) |
Replace unusual option values by usual ones.
Override the option 'mode' so it changes the following possible values:
This workaround wraps a bunch of options, and try to revert the translations back to English.
[in] | to_wrap | Base implementation to wrap. |
[out] | out_impl | Implementation of the out_impl including the workaround. |