SANE_CAP_AUTOMATIC可通过配置auto(bool)属性来禁用,默认全部属性支持
This commit is contained in:
parent
2a9ae299ee
commit
6ba36aedc2
|
@ -1149,6 +1149,9 @@ SANE_Option_Descriptor* hg_sane_middleware::from_json(scanner_handle h, const st
|
|||
}
|
||||
ret->size = bytes;
|
||||
|
||||
if (jsn->get_value("auto", bv) && !bv)
|
||||
ret->cap &= ~SANE_CAP_AUTOMATIC;
|
||||
|
||||
if (jsn->get_value("readonly", bv) && bv)
|
||||
SET_CAP_READONLY(ret->cap)
|
||||
|
||||
|
@ -1478,7 +1481,7 @@ bool hg_sane_middleware::get_current_value(scanner_handle handle, const void* op
|
|||
|
||||
return ret;
|
||||
}
|
||||
void* hg_sane_middleware::get_default_value(scanner_handle handle, const void* option, int* bytes, bool log)
|
||||
void* hg_sane_middleware::get_default_value(scanner_handle handle, const void* option, int* bytes, bool log, bool* can_auto)
|
||||
{
|
||||
std::string val(get_option_json(handle, (void *)option));
|
||||
void* data = nullptr;
|
||||
|
@ -1487,6 +1490,15 @@ void* hg_sane_middleware::get_default_value(scanner_handle handle, const void* o
|
|||
if (jsn->attach_text(&val[0]) &&
|
||||
jsn->get_value("type", val))
|
||||
{
|
||||
if (can_auto)
|
||||
{
|
||||
bool yes = false;
|
||||
|
||||
*can_auto = true;
|
||||
if (jsn->get_value("auto", yes))
|
||||
*can_auto = yes;
|
||||
}
|
||||
|
||||
std::string title(hg_sane_middleware::get_string_in_json(jsn, "title"));
|
||||
if (val == "bool")
|
||||
{
|
||||
|
@ -1867,11 +1879,17 @@ SANE_Status hg_sane_middleware::set_option(SANE_Handle h, const void* option, SA
|
|||
{
|
||||
VLOG_MINI_2(LOG_LEVEL_WARNING, "Option %d(%s) call SANE_ACTION_SET_AUTO, we set default value.\n", option, desc->title);
|
||||
|
||||
int len = 0;
|
||||
void* val = get_default_value(handle, option, &len);
|
||||
int len = 0;
|
||||
bool can_auto = true;
|
||||
void* val = get_default_value(handle, option, &len, false, &can_auto);
|
||||
|
||||
if (!val || !can_auto)
|
||||
{
|
||||
if(val)
|
||||
local_utility::free_memory(val);
|
||||
|
||||
if (!val)
|
||||
return SANE_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (value)
|
||||
{
|
||||
|
|
|
@ -150,7 +150,7 @@ class hg_sane_middleware
|
|||
|
||||
void reload_current_value(scanner_handle handle, std::vector<std::string>* changed = NULL);
|
||||
bool get_current_value(scanner_handle handle, const void* option, void(*setv)(void*, size_t, void*), void* value, SANE_Value_Type* type = NULL);
|
||||
void* get_default_value(scanner_handle handle, const void* option, int* bytes = nullptr, bool log = false); // caller should call local_utility::free_memory to free the returned value
|
||||
void* get_default_value(scanner_handle handle, const void* option, int* bytes = nullptr, bool log = false, bool* can_auto = nullptr); // caller should call local_utility::free_memory to free the returned value
|
||||
|
||||
/// <summary>
|
||||
/// 关联项处理
|
||||
|
|
Loading…
Reference in New Issue