修正语言切换相关BUG
This commit is contained in:
parent
e6a51ba329
commit
d0f7278090
|
@ -3717,6 +3717,20 @@ int hg_scanner::get_setting(const char* name, char* json_txt_buf, int* len, int*
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// language can be set outer:
|
||||||
|
if (real_n == SANE_STD_OPT_NAME_LANGUAGE && setting_jsn_.contains(SANE_STD_OPT_NAME_LANGUAGE))
|
||||||
|
{
|
||||||
|
LANATTR** lang = lang_get_supported_languages();
|
||||||
|
for (int i = 0; lang[i]; ++i)
|
||||||
|
{
|
||||||
|
if (lang[i]->cp == lang_get_cur_code_page())
|
||||||
|
{
|
||||||
|
setting_jsn_.at(SANE_STD_OPT_NAME_LANGUAGE).at("cur") = lang[i]->id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//json_name.find(real_n)
|
//json_name.find(real_n)
|
||||||
//auto it = json_name.find(real_n);
|
//auto it = json_name.find(real_n);
|
||||||
//if (it != json_name.end())
|
//if (it != json_name.end())
|
||||||
|
|
|
@ -99,17 +99,24 @@ extern "C"
|
||||||
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Module sane : [%s] - %s\n", g_sane_ver.c_str(), sane.c_str());
|
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Module sane : [%s] - %s\n", g_sane_ver.c_str(), sane.c_str());
|
||||||
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Module exe : %s\n", (pe + path + name).c_str());
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Module exe : %s\n", (pe + path + name).c_str());
|
||||||
|
|
||||||
if (lang_initialize() == -1)
|
|
||||||
{
|
|
||||||
VLOG_MINI_1(LOG_LEVEL_FATAL, "No language package found(%d)!\n", -1);
|
|
||||||
return SCANNER_ERR_LANG_PAK_LOST;
|
|
||||||
}
|
|
||||||
register_language_changed_notify(language_changed, true);
|
|
||||||
|
|
||||||
hg_scanner_mgr::set_version(VERSION_MAJOR, VERSION_MINOR, VERSION_YEAR, GET_BUILD_VER);
|
hg_scanner_mgr::set_version(VERSION_MAJOR, VERSION_MINOR, VERSION_YEAR, GET_BUILD_VER);
|
||||||
hg_scanner_mgr::set_exe_name(pe.c_str(), name.c_str());
|
hg_scanner_mgr::set_exe_name(pe.c_str(), name.c_str());
|
||||||
hg_scanner_mgr::instance(callback);
|
hg_scanner_mgr::instance(callback);
|
||||||
|
|
||||||
|
register_language_changed_notify(language_changed, true);
|
||||||
|
std::string lang(hg_log::ini_get("language", "code-page"));
|
||||||
|
if (lang.empty() && STRICMP(name.c_str(), "qtsane") == 0)
|
||||||
|
{
|
||||||
|
lang = "20127"; // qtsane can not support chinese !!! we change language to English :(
|
||||||
|
hg_log::log(LOG_LEVEL_DEBUG_INFO, "Change the default language to English while qtsane does not support Chinese!\n");
|
||||||
|
}
|
||||||
|
if (!lang.empty())
|
||||||
|
{
|
||||||
|
lang_set_code_page(atoi(lang.c_str()));
|
||||||
|
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Found the language specified by user: %s, code-page after set = %d\n", lang.c_str(), lang_get_cur_code_page());
|
||||||
|
}
|
||||||
|
|
||||||
return SCANNER_ERR_OK;
|
return SCANNER_ERR_OK;
|
||||||
}
|
}
|
||||||
void hg_scanner_uninitialize(void)
|
void hg_scanner_uninitialize(void)
|
||||||
|
|
|
@ -518,11 +518,6 @@ const SANE_Device** hg_sane_middleware::dev_list_ = NULL;
|
||||||
|
|
||||||
hg_sane_middleware::hg_sane_middleware(void) : opt_0_(nullptr), init_ok_(false)
|
hg_sane_middleware::hg_sane_middleware(void) : opt_0_(nullptr), init_ok_(false)
|
||||||
{
|
{
|
||||||
if (lang_initialize() == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char sane_ver[40] = { 0 };
|
char sane_ver[40] = { 0 };
|
||||||
|
|
||||||
init_ok_ = true;
|
init_ok_ = true;
|
||||||
|
@ -531,9 +526,6 @@ hg_sane_middleware::hg_sane_middleware(void) : opt_0_(nullptr), init_ok_(false)
|
||||||
signal(SIGUSR1, &hg_sane_middleware::device_pnp);
|
signal(SIGUSR1, &hg_sane_middleware::device_pnp);
|
||||||
hg_scanner_set_sane_info(g_sane_name.c_str(), sane_ver);
|
hg_scanner_set_sane_info(g_sane_name.c_str(), sane_ver);
|
||||||
hg_scanner_initialize(local_utility::ui_cb, NULL);
|
hg_scanner_initialize(local_utility::ui_cb, NULL);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
#if !defined(WIN32) && !defined(_WIN64)
|
#if !defined(WIN32) && !defined(_WIN64)
|
||||||
|
@ -1016,6 +1008,7 @@ SANE_Option_Descriptor* hg_sane_middleware::from_json(scanner_handle h, const st
|
||||||
std::vector<std::string> constraints;
|
std::vector<std::string> constraints;
|
||||||
double lower = .0f, upper = .0f, step = .0f;
|
double lower = .0f, upper = .0f, step = .0f;
|
||||||
bool db_val = false;
|
bool db_val = false;
|
||||||
|
int opt_val_size = 0;
|
||||||
|
|
||||||
if (!jsn->get_value("type", val))
|
if (!jsn->get_value("type", val))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1031,27 +1024,15 @@ SANE_Option_Descriptor* hg_sane_middleware::from_json(scanner_handle h, const st
|
||||||
{
|
{
|
||||||
if (range->first_child(val))
|
if (range->first_child(val))
|
||||||
{
|
{
|
||||||
size_t pos = val.find(".");
|
local_utility::trans_language_if_was_word_id(val);
|
||||||
if (pos != std::string::npos)
|
|
||||||
{
|
|
||||||
for (size_t i = val.length() - 1; i > pos; --i)
|
|
||||||
{
|
|
||||||
if (val[i] != '0')
|
|
||||||
{
|
|
||||||
pos = i + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val.erase(pos);
|
|
||||||
}
|
|
||||||
if (std::to_string(atoi(val.c_str())) == val)
|
|
||||||
constraints.push_back(lang_load_string(atoi(val.c_str()), (int*)&lower));
|
|
||||||
else
|
|
||||||
constraints.push_back(val);
|
constraints.push_back(val);
|
||||||
|
opt_val_size = val.length();
|
||||||
while (range->next_child(val))
|
while (range->next_child(val))
|
||||||
{
|
{
|
||||||
local_utility::trans_language_if_was_word_id(val);
|
local_utility::trans_language_if_was_word_id(val);
|
||||||
constraints.push_back(val);
|
constraints.push_back(val);
|
||||||
|
if (opt_val_size < val.length())
|
||||||
|
opt_val_size = val.length();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete range;
|
delete range;
|
||||||
|
@ -1157,6 +1138,12 @@ SANE_Option_Descriptor* hg_sane_middleware::from_json(scanner_handle h, const st
|
||||||
bool bv = false;
|
bool bv = false;
|
||||||
|
|
||||||
jsn->get_value("size", bytes);
|
jsn->get_value("size", bytes);
|
||||||
|
if (bytes < opt_val_size)
|
||||||
|
{
|
||||||
|
opt_val_size = ALIGN_INT(opt_val_size + 4);
|
||||||
|
VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Resize size of '%s' from %d to %d\n", name.c_str(), bytes, opt_val_size);
|
||||||
|
bytes = opt_val_size;
|
||||||
|
}
|
||||||
ret->size = bytes;
|
ret->size = bytes;
|
||||||
|
|
||||||
if (jsn->get_value("readonly", bv) && bv)
|
if (jsn->get_value("readonly", bv) && bv)
|
||||||
|
|
Loading…
Reference in New Issue