Merge branch 'dev' of http://192.168.10.5:8099/sane/code_device into dev
This commit is contained in:
commit
3ea35183ad
|
@ -8,6 +8,7 @@
|
|||
#include <direct.h>
|
||||
#endif
|
||||
|
||||
#define DYN_JSON_BETWEEN_PAPER_AND_DPI
|
||||
|
||||
#if defined(WIN32) || defined(_WIN64)
|
||||
static int load_dll(const wchar_t* path_dll, HMODULE* dll)
|
||||
|
@ -1650,6 +1651,22 @@ int hg_scanner::setting_paper(void* data, long* len)
|
|||
if(old != image_prc_param_.bits.paper)
|
||||
reset_custom_area_range(image_prc_param_.bits.paper);
|
||||
|
||||
#ifdef DYN_JSON_BETWEEN_PAPER_AND_DPI
|
||||
int max_papers[] = { PAPER_MAX_SIZE, PAPER_MAX_SIZE_CLIP, PAPER_TRIGEMINY }, max_dpi = 600;
|
||||
for (auto& v : max_papers)
|
||||
{
|
||||
if (paper_string(v) == (char*)data)
|
||||
{
|
||||
max_dpi = 499;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (setting_jsn_.at(SANE_STD_OPT_NAME_RESOLUTION).at("range").count("max"))
|
||||
{
|
||||
setting_jsn_.at(SANE_STD_OPT_NAME_RESOLUTION).at("range").at("max") = max_dpi;
|
||||
}
|
||||
#endif
|
||||
|
||||
return SCANNER_ERR_RELOAD_OPT_PARAM; // ret;
|
||||
}
|
||||
int hg_scanner::setting_paper_check(void* data, long* len)
|
||||
|
@ -1744,6 +1761,62 @@ int hg_scanner::setting_resolution(void* data, long* len)
|
|||
VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Change resolution from %d to %d = %s\n", old, *((int*)data), hg_scanner_err_name(ret));
|
||||
//*((int*)data) = resolution_;
|
||||
|
||||
#ifdef DYN_JSON_BETWEEN_PAPER_AND_DPI
|
||||
int max_papers[] = { PAPER_MAX_SIZE, PAPER_MAX_SIZE_CLIP, PAPER_TRIGEMINY };
|
||||
//std::string now(setting_jsn_.at(SANE_STD_OPT_NAME_PAPER).at("range").dump());
|
||||
|
||||
if (resolution_ >= 500)
|
||||
{
|
||||
// erase max papers ...
|
||||
for (auto& v : max_papers)
|
||||
{
|
||||
std::string str(paper_string(v));
|
||||
int id = lang_get_string_id(str.c_str(), false);
|
||||
if (id == -1)
|
||||
setting_jsn_.at(SANE_STD_OPT_NAME_PAPER).at("range").erase(str.c_str());
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < setting_jsn_.at(SANE_STD_OPT_NAME_PAPER).at("range").size(); ++i)
|
||||
{
|
||||
int val = 0;
|
||||
setting_jsn_.at(SANE_STD_OPT_NAME_PAPER).at("range").at(i).get_to(val);
|
||||
if (val == id)
|
||||
{
|
||||
setting_jsn_.at(SANE_STD_OPT_NAME_PAPER).at("range").erase(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto& v : max_papers)
|
||||
{
|
||||
std::string str(paper_string(v));
|
||||
int id = lang_get_string_id(str.c_str(), false), val = 0;
|
||||
bool add = true;
|
||||
for (int i = 0; i < setting_jsn_.at(SANE_STD_OPT_NAME_PAPER).at("range").size(); ++i)
|
||||
{
|
||||
setting_jsn_.at(SANE_STD_OPT_NAME_PAPER).at("range").at(i).get_to(val);
|
||||
if (val == id)
|
||||
{
|
||||
add = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (add)
|
||||
{
|
||||
if(id == -1)
|
||||
setting_jsn_.at(SANE_STD_OPT_NAME_PAPER).at("range").push_back(str);
|
||||
else
|
||||
setting_jsn_.at(SANE_STD_OPT_NAME_PAPER).at("range").push_back(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
// std::string last(setting_jsn_.at(SANE_STD_OPT_NAME_PAPER).at("range").dump());
|
||||
#endif
|
||||
|
||||
return SCANNER_ERR_RELOAD_OPT_PARAM; // ret;
|
||||
}
|
||||
int hg_scanner::setting_exchagnge(void* data, long* len)
|
||||
|
|
|
@ -532,7 +532,7 @@ hg_sane_middleware::hg_sane_middleware(void) : opt_0_(nullptr), init_ok_(false)
|
|||
|
||||
if (lang_get_cur_code_page() != DEFAULT_CODE_PAGE)
|
||||
lang_refresh_language();
|
||||
register_language_changed_notify(&hg_sane_middleware::language_changed, true);
|
||||
// register_language_changed_notify(&hg_sane_middleware::language_changed, true); - called when reload_option
|
||||
|
||||
#if !defined(WIN32) && !defined(_WIN64)
|
||||
char path[512] = { 0 };
|
||||
|
@ -559,15 +559,16 @@ hg_sane_middleware::~hg_sane_middleware()
|
|||
|
||||
void hg_sane_middleware::language_changed(int cp, void* param)
|
||||
{
|
||||
for (auto& v : hg_sane_middleware::instance()->openning_)
|
||||
{
|
||||
hg_sane_middleware::free_device_inst(v, false);
|
||||
|
||||
long count = 0;
|
||||
hg_scanner_get_parameter(v->dev, nullptr, NULL, &count);
|
||||
for (long ind = 1; ind < count; ++ind)
|
||||
hg_sane_middleware::instance()->get_option_descriptor(hg_sane_middleware::scanner_handle_to_sane(v->dev), (void*)ind);
|
||||
}
|
||||
hg_sane_middleware::instance()->reload_options();
|
||||
//for (auto& v : hg_sane_middleware::instance()->openning_)
|
||||
//{
|
||||
// hg_sane_middleware::free_device_inst(v, false);
|
||||
//
|
||||
// long count = 0;
|
||||
// hg_scanner_get_parameter(v->dev, nullptr, NULL, &count);
|
||||
// for (long ind = 1; ind < count; ++ind)
|
||||
// hg_sane_middleware::instance()->get_option_descriptor(hg_sane_middleware::scanner_handle_to_sane(v->dev), (void*)ind);
|
||||
//}
|
||||
}
|
||||
const SANE_Device** hg_sane_middleware::to_sane_device(ScannerInfo* hgscanner, int count)
|
||||
{
|
||||
|
@ -969,6 +970,21 @@ void hg_sane_middleware::clear(void)
|
|||
}
|
||||
}
|
||||
|
||||
void hg_sane_middleware::reload_options(scanner_handle dev)
|
||||
{
|
||||
for (auto& v : openning_)
|
||||
{
|
||||
if (dev && dev != v->dev)
|
||||
continue;
|
||||
|
||||
hg_sane_middleware::free_device_inst(v, false);
|
||||
|
||||
long count = 0;
|
||||
hg_scanner_get_parameter(v->dev, nullptr, NULL, &count);
|
||||
for (long ind = 1; ind < count; ++ind)
|
||||
get_option_descriptor(hg_sane_middleware::scanner_handle_to_sane(v->dev), (void*)ind);
|
||||
}
|
||||
}
|
||||
SANE_Status hg_sane_middleware::open(SANE_String_Const devicename, SANE_Handle* handle, const char* name, const char* pwd, const char* method, char* rsc)
|
||||
{
|
||||
scanner_handle h = NULL;
|
||||
|
@ -1960,7 +1976,8 @@ SANE_Status hg_sane_middleware::set_option(SANE_Handle h, const void* option, SA
|
|||
else if (err == SCANNER_ERR_CONFIGURATION_CHANGED)
|
||||
{
|
||||
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "the setting '%s' affects other options value, RELOAD ...\n", desc_title.c_str());
|
||||
on_SCANNER_ERR_CONFIGURATION_CHANGED(dev);
|
||||
//on_SCANNER_ERR_CONFIGURATION_CHANGED(dev);
|
||||
reload_options(handle);
|
||||
err = (scanner_err)SANE_INFO_RELOAD_OPTIONS;
|
||||
}
|
||||
else if(err == SCANNER_ERR_RELOAD_IMAGE_PARAM)
|
||||
|
@ -1971,7 +1988,8 @@ SANE_Status hg_sane_middleware::set_option(SANE_Handle h, const void* option, SA
|
|||
else if(err == SCANNER_ERR_RELOAD_OPT_PARAM)
|
||||
{
|
||||
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "the setting '%s' affects image parameter and options, APP should re-get image info and reload options...\n", desc_title.c_str());
|
||||
on_SCANNER_ERR_CONFIGURATION_CHANGED(dev);
|
||||
//on_SCANNER_ERR_CONFIGURATION_CHANGED(dev);
|
||||
reload_options(handle);
|
||||
err = (scanner_err)(SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS);
|
||||
}
|
||||
else if (err == SCANNER_ERR_ACCESS_DENIED)
|
||||
|
|
|
@ -141,6 +141,7 @@ class hg_sane_middleware
|
|||
static void set_value_to_var(void* val, size_t bytes, void* param);
|
||||
static void set_value_to_new(void* val, size_t bytes, void* param);
|
||||
|
||||
void reload_options(scanner_handle dev = nullptr);
|
||||
SANE_Status open(SANE_String_Const devicename, SANE_Handle* handle, const char* name, const char* pwd, const char* method, char* rsc);
|
||||
SANE_Option_Descriptor* from_json(scanner_handle h, const std::string& name, json* jsn);
|
||||
std::string get_option_json(scanner_handle handle, void* opt, std::string* key = nullptr, SANE_Int* id = nullptr);
|
||||
|
|
Loading…
Reference in New Issue