This commit is contained in:
13038267101 2023-05-30 17:05:14 +08:00
commit 00f56eab54
3 changed files with 41 additions and 7 deletions

View File

@ -173,7 +173,7 @@ void shared_memory::init(void)
first_ = !(GetLastError() == ERROR_ALREADY_EXISTS); first_ = !(GetLastError() == ERROR_ALREADY_EXISTS);
obj_ = (void*)h; obj_ = (void*)h;
#else #else
int obj = shmget(key_, bytes_, IPC_EXCL | IPC_CREAT | 0600); int obj = shmget(key_, bytes_, IPC_EXCL | IPC_CREAT | 0666);
if (obj < 0) if (obj < 0)
{ {
unsigned int* v = (unsigned int*)&key_; unsigned int* v = (unsigned int*)&key_;

View File

@ -864,6 +864,9 @@ scanner_err hg_scanner_mgr::hg_scanner_get_parameter(scanner_handle h, const cha
else else
return SCANNER_ERR_ACCESS_DENIED; return SCANNER_ERR_ACCESS_DENIED;
} }
else if (strcmp(SANE_STD_OPT_NAME_CUSTOM_GAMMA, name) == 0)
return (scanner_err)SCAN_PTR(h)->device_io_control(IO_CTRL_CODE_GET_CUSTOM_GAMMA, data, (unsigned int*)len);
if (strcmp(SANE_STD_OPT_NAME_LOGIN, name) == 0 || if (strcmp(SANE_STD_OPT_NAME_LOGIN, name) == 0 ||
strcmp(SANE_STD_OPT_NAME_LOGOUT, name) == 0) strcmp(SANE_STD_OPT_NAME_LOGOUT, name) == 0)
return SCANNER_ERR_DEVICE_NOT_SUPPORT; return SCANNER_ERR_DEVICE_NOT_SUPPORT;
@ -943,6 +946,8 @@ scanner_err hg_scanner_mgr::hg_scanner_set_parameter(scanner_handle h, const cha
return SCANNER_ERR_ACCESS_DENIED; return SCANNER_ERR_ACCESS_DENIED;
} }
else if (strcmp(SANE_STD_OPT_NAME_CUSTOM_GAMMA, name) == 0)
return (scanner_err)SCAN_PTR(h)->device_io_control(IO_CTRL_CODE_SET_CUSTOM_GAMMA, data, (unsigned int*)len);
} }
return (scanner_err)SCAN_PTR(h)->set_setting(name, data, len); return (scanner_err)SCAN_PTR(h)->set_setting(name, data, len);

View File

@ -394,6 +394,8 @@ namespace local_utility
FIX_ID_TO_NAME(DEVICE_IP_ADDR, 255); FIX_ID_TO_NAME(DEVICE_IP_ADDR, 255);
FIX_ID_TO_NAME(DEVICE_MAC_ADDR, 255); FIX_ID_TO_NAME(DEVICE_MAC_ADDR, 255);
FIX_ID_TO_NAME(CUSTOM_GAMMA, sizeof(SANE_Gamma));
return ""; return "";
} }
@ -1357,17 +1359,21 @@ bool hg_sane_middleware::get_current_value(scanner_handle handle, const void* op
if(!name.empty()) if(!name.empty())
{ {
char buf[256] = { 0 }; char *buf = new char[l + 4];
long len = sizeof(buf) - 1; long len = l;
bool ret = false;
memcpy(buf, value, l); memcpy(buf, value, l);
buf[l] = 0;
if (hg_scanner_get_parameter(handle, name.c_str(), buf, &len) == SCANNER_ERR_OK) if (hg_scanner_get_parameter(handle, name.c_str(), buf, &len) == SCANNER_ERR_OK)
{ {
setv(buf, len, value); setv(buf, len, value);
return true; ret = true;
} }
delete[] buf;
return false; return ret;
} }
} }
@ -1732,7 +1738,11 @@ SANE_Status hg_sane_middleware::set_option(SANE_Handle h, const void* option, SA
else else
{ {
SANE_Int id = -1; SANE_Int id = -1;
find_stored_descriptor(handle, option, &id); SANE_Option_Descriptor* desc = find_stored_descriptor(handle, option);
if (desc &&
(desc->type == SANE_TYPE_BUTTON || desc->type == SANE_TYPE_GROUP))
return SANE_STATUS_UNSUPPORTED;
if (dev->std_opt && dev->std_opt->is_known_option(id)) if (dev->std_opt && dev->std_opt->is_known_option(id))
{ {
dev->std_opt->get_value(h, id, value); dev->std_opt->get_value(h, id, value);
@ -1744,7 +1754,24 @@ SANE_Status hg_sane_middleware::set_option(SANE_Handle h, const void* option, SA
return ret; return ret;
} }
else else if (action == SANE_ACTION_GET_DEFAULT_VALUE)
{
SANE_Option_Descriptor* desc = find_stored_descriptor(handle, option);
if (desc &&
(desc->type == SANE_TYPE_BUTTON || desc->type == SANE_TYPE_GROUP))
return SANE_STATUS_UNSUPPORTED;
int len = 0;
void* val = get_default_value(handle, option, &len);
if (!val)
return SANE_STATUS_UNSUPPORTED;
memcpy(value, val, len);
local_utility::free_memory(val);
return SANE_STATUS_GOOD;
}
else if(action == SANE_ACTION_SET_AUTO || action == SANE_ACTION_SET_VALUE)
{ {
SANE_Int id = -1; SANE_Int id = -1;
SANE_Option_Descriptor* desc = find_stored_descriptor(handle, option, &id); SANE_Option_Descriptor* desc = find_stored_descriptor(handle, option, &id);
@ -1891,6 +1918,8 @@ SANE_Status hg_sane_middleware::set_option(SANE_Handle h, const void* option, SA
return status; return status;
} }
return SANE_STATUS_INVAL;
} }
bool hg_sane_middleware::get_cur_value(SANE_Handle handle, void* option, void* value, SANE_Value_Type* type) bool hg_sane_middleware::get_cur_value(SANE_Handle handle, void* option, void* value, SANE_Value_Type* type)
{ {