From a041c851e41ec9257247cfd6383b98d45c7d0a7e Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Fri, 26 May 2023 15:17:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0APP=E5=8F=96=E5=9B=BE?= =?UTF-8?q?=E8=AE=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sane/s2t_api.h | 1 + sane/scanner.cpp | 19 +++++++++++++++---- sane/scanner.h | 2 ++ twain/twain/huagaods.cpp | 7 +++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/sane/s2t_api.h b/sane/s2t_api.h index ffe4972..c1372a5 100644 --- a/sane/s2t_api.h +++ b/sane/s2t_api.h @@ -159,6 +159,7 @@ struct __declspec(novtable) ISaneInvoker : public IRef COM_API_DECLARE(bool, is_online(void)); COM_API_DECLARE(bool, is_paper_on(void)); COM_API_DECLARE(int, last_error(void)); + COM_API_DECLARE(int, image_fetched(IScanImg* tx)); // notify the image 'tx' has fetched by APP // Function: 获取配置项信息 // diff --git a/sane/scanner.cpp b/sane/scanner.cpp index 4a4e7c8..80b9063 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -2451,6 +2451,7 @@ COM_API_IMPLEMENT(scanner, int, start(void)) scan_msg_ = "OK"; scan_err_ = false; user_cancel_ = false; + fetch_imgs_ = 0; app_wnd_ = setting_.get() ? setting_->hwnd() : callback::find_main_wnd(); ret = hg_sane_middleware::instance()->start(handle_, NULL); @@ -2617,6 +2618,16 @@ COM_API_IMPLEMENT(scanner, int, last_error(void)) { return err_; } +COM_API_IMPLEMENT(scanner, int, image_fetched(IScanImg* tx)) +{ + fetch_imgs_++; + if (ui_notify) + ui_notify(SANE_EVENT_IMG_UPLOADED, NULL, fetch_imgs_); + else if (indicator_.get()) + indicator_->notify_data_arrived(false); + + return 0; +} COM_API_IMPLEMENT(scanner, bool, get_option_info(int sn, value_type* type, value_limit* limit, int* bytes)) { @@ -3295,10 +3306,10 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len) } else if (ev_code == SANE_EVENT_USB_DATA_RECEIVED) { - if (indicator_.get()) - indicator_->notify_data_arrived(false); - else if (ui_notify) - ui_notify(ev_code, data, 0); + //if (indicator_.get()) + // indicator_->notify_data_arrived(false); + //else if (ui_notify) + // ui_notify(ev_code, data, 0); } else if (ev_code == SANE_EVENT_SCAN_FINISHED) { diff --git a/sane/scanner.h b/sane/scanner.h index 661563d..79a3699 100644 --- a/sane/scanner.h +++ b/sane/scanner.h @@ -46,6 +46,7 @@ class scanner : public ISaneInvoker, virtual public refer int ex_id_; int prev_start_result_; int dpi_; + int fetch_imgs_ = 0; // count for images has fetched by APP bool is_bIndicator; bool is_show_setting_; unsigned int img_ind_; @@ -217,6 +218,7 @@ public: COM_API_OVERRIDE(bool, is_online(void)); COM_API_OVERRIDE(bool, is_paper_on(void)); COM_API_OVERRIDE(int, last_error(void)); + COM_API_OVERRIDE(int, image_fetched(IScanImg* tx)); COM_API_OVERRIDE(bool, get_option_info(int sn, value_type* type, value_limit* limit, int* bytes)); COM_API_OVERRIDE(bool, get_value(int sn, set_opt_value, void* param)); COM_API_OVERRIDE(bool, get_value(int sn, void* data, int* len)); // get operation with in-parameter diff --git a/twain/twain/huagaods.cpp b/twain/twain/huagaods.cpp index 44f93f1..f72c17f 100644 --- a/twain/twain/huagaods.cpp +++ b/twain/twain/huagaods.cpp @@ -1363,6 +1363,8 @@ Result huagao_ds::imageMemXferGet(const Identity& origin, ImageMemXfer& data) img->add_ref(); ret = success(); } + else + scanner_->image_fetched(img); } else if (img->read(dst, &want_read, off) == SCANNER_ERR_OK) { @@ -1378,6 +1380,8 @@ Result huagao_ds::imageMemXferGet(const Identity& origin, ImageMemXfer& data) img->add_ref(); ret = success(); } + else + scanner_->image_fetched(img); } else { @@ -1418,6 +1422,7 @@ Result huagao_ds::imageNativeXferGet(const Identity& id, ImageNativeXfer& data) total = img->bytes() - (unsigned int)off; src = img->data(off, &total); } + scanner_->image_fetched(img); img->release(); return { ReturnCode::XferDone, ConditionCode::Success }; @@ -1470,6 +1475,7 @@ Twpp::Result huagao_ds::imageFileXferGet(const Twpp::Identity& origin) } fclose(dst); + scanner_->image_fetched(img); } else { @@ -1487,6 +1493,7 @@ Twpp::Result huagao_ds::imageFileXferGet(const Twpp::Identity& origin) load_sane_util::log_info((L"Map file to " + load_sane_util::ansi2unic(m_fileXfer.filePath().string().c_str()) + L"\r\n").c_str(), 1); img->keep_file(true); + scanner_->image_fetched(img); img->release(); cv_e = load_sane_util::move_file(file.c_str(), m_fileXfer.filePath().string().c_str()); if (cv_e == 0)