IBitDepth protocol can be enabled/disabled, Str255 to string by utils::ansi2utf8
This commit is contained in:
parent
759172d341
commit
aa762db140
|
@ -682,9 +682,10 @@ scanner_err hg_scanner_mgr::hg_scanner_enum(ScannerInfo* scanner_list, long* cou
|
|||
std::vector<OLSCANNER> devusbuf;
|
||||
long size = *count;
|
||||
scanner_err ret = SCANNER_ERR_OK;
|
||||
std::string g_vendor = GET_LANG(COMPANY_NAME, &islang);
|
||||
std::string g_vendor(from_default_language(COMPANY_NAME, nullptr));
|
||||
get_online_devices(devusbuf);
|
||||
*count = devusbuf.size();
|
||||
utils::to_log(LOG_LEVEL_ALL, "current language(%d) of '%s' is '%s'\n", lang_get_cur_code_page(), COMPANY_NAME, g_vendor.c_str());
|
||||
if (*count > size)
|
||||
{
|
||||
ret = SCANNER_ERR_INSUFFICIENT_MEMORY;
|
||||
|
|
|
@ -592,7 +592,7 @@ static void copy_type(Str255& to, std::string from)
|
|||
}
|
||||
static void copy_type(std::string& to, Str255 from)
|
||||
{
|
||||
to = from.data();
|
||||
to = std::move(utils::ansi2utf8(from.data()));
|
||||
}
|
||||
static void copy_type(Str64& to, std::string from)
|
||||
{
|
||||
|
@ -1030,6 +1030,22 @@ Result huagao_ds::identityOpenDs(const Identity& id)
|
|||
}
|
||||
utils::to_log(1, "Double check mode = %d\r\n", double_check_mode_);
|
||||
|
||||
int nobd = get_config_number("twain-app", "no-bitdepth", 0, -1);
|
||||
if (nobd == -1)
|
||||
{
|
||||
char pe[MAX_PATH] = { 0 }, * name = NULL;
|
||||
GetModuleFileNameA(NULL, pe, _countof(pe) - 1);
|
||||
name = strrchr(pe, '\\');
|
||||
if (name++ == NULL)
|
||||
name = pe;
|
||||
if (STRICMP(name, "\u519B\u961F\u626B\u63CF2.0.exe") == 0) // 军队扫描2.0.exe
|
||||
nobd = 1;
|
||||
else
|
||||
nobd = 0;
|
||||
}
|
||||
no_bitdepth_ = nobd == 1;
|
||||
utils::to_log(LOG_LEVEL_DEBUG, "BitDepth protocol enabled = %d\r\n", nobd);
|
||||
|
||||
m_compression = Compression::None;
|
||||
init_support_caps();
|
||||
m_fileXfer.setFormat(ImageFileFormat::Bmp);
|
||||
|
@ -1946,6 +1962,8 @@ void huagao_ds::init_support_caps(void)
|
|||
int val = 0;
|
||||
GET_SANE_OPT_EX(int, scanner_, ex_color_mode, NULL, &all);
|
||||
if (Msg::Set == msg || Msg::Reset == msg) {
|
||||
if (no_bitdepth_)
|
||||
return success();
|
||||
int ret = SCANNER_ERR_INVALID_PARAMETER;
|
||||
val = all[sane_opts::RANGE_POS_DEFAULT];
|
||||
if (Msg::Set == msg)
|
||||
|
@ -3682,14 +3700,14 @@ std::string huagao_ds::get_config_value(const char* sec, const char* key)
|
|||
|
||||
return v;
|
||||
}
|
||||
DWORD huagao_ds::get_config_number(const char* sec, const char* key)
|
||||
DWORD huagao_ds::get_config_number(const char* sec, const char* key, DWORD def, DWORD empty)
|
||||
{
|
||||
std::string cfg_f(get_config_file());
|
||||
|
||||
if (cfg_f.empty())
|
||||
return 0;
|
||||
return empty;
|
||||
else
|
||||
return GetPrivateProfileIntA(sec, key, 0, get_config_file().c_str());
|
||||
return GetPrivateProfileIntA(sec, key, def, get_config_file().c_str());
|
||||
}
|
||||
int huagao_ds::handle_scanner_event(int ev, bool from_event_proc)
|
||||
{
|
||||
|
|
|
@ -57,6 +57,7 @@ class huagao_ds : public Twpp::SourceFromThis<huagao_ds> {
|
|||
bool app_trigger_event_;
|
||||
bool bUiOnly_;
|
||||
bool show_setting_;
|
||||
bool no_bitdepth_ = false; // 军队扫描2.0.exe set this but sychronize to APP
|
||||
int count_;
|
||||
|
||||
volatile bool notfify_close_ = false;
|
||||
|
@ -80,7 +81,7 @@ class huagao_ds : public Twpp::SourceFromThis<huagao_ds> {
|
|||
void init_caps_from_sane_directly(void);
|
||||
std::string get_config_file(void);
|
||||
std::string get_config_value(const char* sec, const char* key);
|
||||
DWORD get_config_number(const char* sec, const char* key);
|
||||
DWORD get_config_number(const char* sec, const char* key, DWORD def = 0, DWORD empty = 0);
|
||||
int handle_scanner_event(int ev, bool from_event_proc = true);
|
||||
int get_scanned_image_count(DWORD timeout);
|
||||
void trigger_ProcessEvent(Twpp::DataGroup dg, Twpp::Dat dat, Twpp::Msg msg);
|
||||
|
|
Loading…
Reference in New Issue