添加IP/序列号/固件版本……扩展属性(8800后)访问接口;设备未连接时增加提示
This commit is contained in:
parent
7fbda30161
commit
df75ae1e18
|
@ -434,7 +434,7 @@ extern "C"
|
||||||
#else
|
#else
|
||||||
__declspec(dllimport)
|
__declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
int __stdcall open_scanner(SCANNERID scanner_id, ISaneInvoker** invoker);
|
int __stdcall open_scanner(SCANNERID scanner_id, ISaneInvoker** invoker, bool last_try);
|
||||||
#ifdef EXPORT_SANE_API
|
#ifdef EXPORT_SANE_API
|
||||||
__declspec(dllexport)
|
__declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -3431,13 +3431,27 @@ extern "C"
|
||||||
#else
|
#else
|
||||||
__declspec(dllimport)
|
__declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
int __stdcall open_scanner(SCANNERID scanner_id, ISaneInvoker** invoker)
|
int __stdcall open_scanner(SCANNERID scanner_id, ISaneInvoker** invoker, bool last_try)
|
||||||
{
|
{
|
||||||
if (!invoker)
|
if (!invoker)
|
||||||
return SCANNER_ERR_INVALID_PARAMETER;
|
return SCANNER_ERR_INVALID_PARAMETER;
|
||||||
|
|
||||||
if (!is_scanner_online(scanner_id))
|
if (!is_scanner_online(scanner_id))
|
||||||
|
{
|
||||||
|
if (last_try)
|
||||||
|
{
|
||||||
|
HWND parent = callback::find_main_wnd();
|
||||||
|
std::string msg(callback::language_trans("\xE6\xB2\xA1\xE6\x9C\x89\xE6\x89\xBE\xE5\x88\xB0\xE6\x89\xAB\xE6\x8F\x8F\xE4\xBB\xAA\xEF\xBC\x81", true, NULL)),
|
||||||
|
title(callback::language_trans("\xE9\x94\x99\xE8\xAF\xAF", true, NULL));
|
||||||
|
|
||||||
|
if (callback::show_messagebox_ui)
|
||||||
|
callback::show_messagebox_ui(parent, 0, &msg[0], SCANNER_ERR_DEVICE_NOT_FOUND);
|
||||||
|
else
|
||||||
|
MessageBoxW(parent, local_trans::a2u(msg.c_str(), CP_UTF8).c_str(), local_trans::a2u(title.c_str(), CP_UTF8).c_str(), MB_OK);
|
||||||
|
}
|
||||||
|
|
||||||
return SCANNER_ERR_DEVICE_NOT_FOUND;
|
return SCANNER_ERR_DEVICE_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
scanner* scn = new scanner(scanner_id);
|
scanner* scn = new scanner(scanner_id);
|
||||||
if (scn->last_error() == SCANNER_ERR_OK)
|
if (scn->last_error() == SCANNER_ERR_OK)
|
||||||
|
@ -3448,10 +3462,20 @@ extern "C"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int ret = scn->last_error();
|
int ret = scn->last_error();
|
||||||
|
|
||||||
scn->release();
|
scn->release();
|
||||||
*invoker = NULL;
|
*invoker = NULL;
|
||||||
|
if (last_try)
|
||||||
|
{
|
||||||
|
HWND parent = callback::find_main_wnd();
|
||||||
|
std::string msg(callback::language_trans("\xE6\x89\x93\xE5\xBC\x80\xE6\x89\xAB\xE6\x8F\x8F\xE4\xBB\xAA\xE5\xA4\xB1\xE8\xB4\xA5\xE3\x80\x82", true, NULL)),
|
||||||
|
title(callback::language_trans("\xE9\x94\x99\xE8\xAF\xAF", true, NULL));
|
||||||
|
if (callback::show_messagebox_ui)
|
||||||
|
callback::show_messagebox_ui(parent, 0, &msg[0], ret);
|
||||||
|
else
|
||||||
|
MessageBoxW(parent, local_trans::a2u(msg.c_str(), CP_UTF8).c_str(), local_trans::a2u(title.c_str(), CP_UTF8).c_str(), MB_OK);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace load_sane_util
|
||||||
{
|
{
|
||||||
static std::wstring sane_path(L"");
|
static std::wstring sane_path(L"");
|
||||||
static HMODULE sane_module(NULL);
|
static HMODULE sane_module(NULL);
|
||||||
static int (__stdcall* sane_inst)(SCANNERID, ISaneInvoker**) = NULL;
|
static int (__stdcall* sane_inst)(SCANNERID, ISaneInvoker**, bool) = NULL;
|
||||||
static int(__stdcall* is_on)(SCANNERID) = NULL;
|
static int(__stdcall* is_on)(SCANNERID) = NULL;
|
||||||
static int(__stdcall* init)(void*) = NULL;
|
static int(__stdcall* init)(void*) = NULL;
|
||||||
static int(__stdcall* uninit)(void*) = NULL;
|
static int(__stdcall* uninit)(void*) = NULL;
|
||||||
|
@ -87,6 +87,25 @@ namespace load_sane_util
|
||||||
|
|
||||||
return reg_read(HKEY_LOCAL_MACHINE, path.c_str(), key.c_str());
|
return reg_read(HKEY_LOCAL_MACHINE, path.c_str(), key.c_str());
|
||||||
}
|
}
|
||||||
|
std::string to_web_utf(const std::wstring& unic)
|
||||||
|
{
|
||||||
|
std::string webu("");
|
||||||
|
char buf[20] = { 0 };
|
||||||
|
|
||||||
|
for (size_t i = 0; i < unic.length(); ++i)
|
||||||
|
{
|
||||||
|
wchar_t v = unic[i];
|
||||||
|
if (v <= 0x7f)
|
||||||
|
webu.append(1, (char)v);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf_s(buf, _countof(buf) - 1, "\\u%04X", v);
|
||||||
|
webu += buf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return webu;
|
||||||
|
}
|
||||||
static int load_dll(const wchar_t* path_dll, HMODULE* dll)
|
static int load_dll(const wchar_t* path_dll, HMODULE* dll)
|
||||||
{
|
{
|
||||||
HMODULE h = LoadLibraryW(path_dll);
|
HMODULE h = LoadLibraryW(path_dll);
|
||||||
|
@ -166,7 +185,7 @@ namespace load_sane_util
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ISaneInvoker* open(SCANNERID guid, int* err)
|
ISaneInvoker* open(SCANNERID guid, int* err, bool last_try)
|
||||||
{
|
{
|
||||||
ISaneInvoker* ret = NULL;
|
ISaneInvoker* ret = NULL;
|
||||||
int code = 0;
|
int code = 0;
|
||||||
|
@ -175,7 +194,7 @@ namespace load_sane_util
|
||||||
err = &code;
|
err = &code;
|
||||||
|
|
||||||
if (sane_inst)
|
if (sane_inst)
|
||||||
*err = sane_inst(guid, &ret);
|
*err = sane_inst(guid, &ret, last_try);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -244,3 +263,4 @@ namespace load_sane_util
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace load_sane_util
|
||||||
bool initialize(HMODULE me);
|
bool initialize(HMODULE me);
|
||||||
bool is_ok(void);
|
bool is_ok(void);
|
||||||
bool is_online(SCANNERID guid);
|
bool is_online(SCANNERID guid);
|
||||||
ISaneInvoker* open(SCANNERID guid, int* err);
|
ISaneInvoker* open(SCANNERID guid, int* err, bool last_try);
|
||||||
void uninitialize(void);
|
void uninitialize(void);
|
||||||
void log_info(const wchar_t* info, int level);
|
void log_info(const wchar_t* info, int level);
|
||||||
|
|
||||||
|
@ -20,5 +20,15 @@ namespace load_sane_util
|
||||||
|
|
||||||
int move_file(const char* from, const char* to);
|
int move_file(const char* from, const char* to);
|
||||||
int move_file(const wchar_t* from, const wchar_t* to);
|
int move_file(const wchar_t* from, const wchar_t* to);
|
||||||
|
|
||||||
|
template<typename ... Args>
|
||||||
|
void to_log(const wchar_t* fmt, Args ... args)
|
||||||
|
{
|
||||||
|
size_t size = swprintf(nullptr, 0, fmt, args ...) + 2;
|
||||||
|
std::unique_ptr<wchar_t[]> buf(new wchar_t[size]);
|
||||||
|
|
||||||
|
swprintf(buf.get(), size, fmt, args ...);
|
||||||
|
log_info(buf.get(), 0);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -963,10 +963,10 @@ Result huagao_ds::identityOpenDs(const Identity& id)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int err = 0, attempt = 0;
|
int err = 0, attempt = 0, max_try = 100;
|
||||||
// Sleep(500);
|
// Sleep(500);
|
||||||
scanner_.reset(load_sane_util::open(scanner_guid, &err));
|
scanner_.reset(load_sane_util::open(scanner_guid, &err, false));
|
||||||
while (err == SCANNER_ERR_DEVICE_NOT_FOUND && attempt++ < 100)
|
while (err == SCANNER_ERR_DEVICE_NOT_FOUND && attempt++ < max_try)
|
||||||
{
|
{
|
||||||
if (attempt == 1)
|
if (attempt == 1)
|
||||||
{
|
{
|
||||||
|
@ -974,7 +974,7 @@ Result huagao_ds::identityOpenDs(const Identity& id)
|
||||||
}
|
}
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||||
err = 0;
|
err = 0;
|
||||||
scanner_.reset(load_sane_util::open(scanner_guid, &err));
|
scanner_.reset(load_sane_util::open(scanner_guid, &err, attempt >= max_try));
|
||||||
}
|
}
|
||||||
if (!scanner_.get())
|
if (!scanner_.get())
|
||||||
{
|
{
|
||||||
|
@ -3057,6 +3057,16 @@ void huagao_ds::init_support_caps(void)
|
||||||
SET_EXISTING_EXTENSION(BKG_COLOR_RANGE, CapTypeEx::CAP_TYPE_EX_FADE_BKG_VALUE);
|
SET_EXISTING_EXTENSION(BKG_COLOR_RANGE, CapTypeEx::CAP_TYPE_EX_FADE_BKG_VALUE);
|
||||||
SET_EXISTING_EXTENSION(SIZE_CHECK, CapTypeEx::CAP_TYPE_EX_SIZE_DETECT);
|
SET_EXISTING_EXTENSION(SIZE_CHECK, CapTypeEx::CAP_TYPE_EX_SIZE_DETECT);
|
||||||
SET_EXISTING_EXTENSION(IS_MULTI_OUT, CapTypeEx::CAP_TYPE_EX_MULTI_OUT);
|
SET_EXISTING_EXTENSION(IS_MULTI_OUT, CapTypeEx::CAP_TYPE_EX_MULTI_OUT);
|
||||||
|
|
||||||
|
m_query[(CapType)SANE_OPT_ID_DEVICE_SERIAL_NO] = m_query[CapType::SerialNumber];
|
||||||
|
m_caps[(CapType)SANE_OPT_ID_DEVICE_SERIAL_NO] = m_caps[CapType::SerialNumber];
|
||||||
|
|
||||||
|
m_query[(CapType)SANE_OPT_ID_FIRMWARE_VERSION] = m_query[(CapType)CapTypeEx::CAP_TYPE_EX_HARDWARE_VERSION];
|
||||||
|
m_caps[(CapType)SANE_OPT_ID_FIRMWARE_VERSION] = m_caps[(CapType)CapTypeEx::CAP_TYPE_EX_HARDWARE_VERSION];
|
||||||
|
|
||||||
|
m_query[(CapType)SANE_OPT_ID_DEVICE_IP_ADDR] = m_query[(CapType)CapTypeEx::CAP_TYPE_EX_IP];
|
||||||
|
m_caps[(CapType)SANE_OPT_ID_DEVICE_IP_ADDR] = m_caps[(CapType)CapTypeEx::CAP_TYPE_EX_IP];
|
||||||
|
|
||||||
}
|
}
|
||||||
void huagao_ds::init_support_caps_ex(void)
|
void huagao_ds::init_support_caps_ex(void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue