修复初始化未恢复到默认设置的BUG;添加离线属性管理类

This commit is contained in:
gb 2023-09-22 15:43:53 +08:00
parent 5c17d26304
commit 936201824f
10 changed files with 113 additions and 153 deletions

View File

@ -1384,10 +1384,9 @@ int hg_scanner::setting_sharpen(void* data, long* len)
std::string str((char*)data); std::string str((char*)data);
int ret = SCANNER_ERR_OK; int ret = SCANNER_ERR_OK;
utils::to_log(LOG_LEVEL_DEBUG, "Change sharpen from %s to %s = ", sharpen_string(image_prc_param_.bits.sharpen).c_str(), (char*)data); utils::to_log(LOG_LEVEL_DEBUG, "Change sharpen from %s to %s\n", sharpen_string(image_prc_param_.bits.sharpen).c_str(), (char*)data);
image_prc_param_.bits.sharpen = match_best_sharpen(str, NULL); image_prc_param_.bits.sharpen = match_best_sharpen(str, NULL);
utils::to_log(LOG_LEVEL_DEBUG, "%d\n", ret);
return ret; return ret;
} }
@ -1446,9 +1445,8 @@ int hg_scanner::setting_is_permeate_lv(void* data, long* len)
int ret = SCANNER_ERR_OK; int ret = SCANNER_ERR_OK;
std::string str((char*)data); std::string str((char*)data);
utils::to_log(LOG_LEVEL_DEBUG, "Change is_permeate_lv from %s to %s = ", is_permaeate_string(image_prc_param_.bits.is_permeate_lv_).c_str(), (char*)data); utils::to_log(LOG_LEVEL_DEBUG, "Change is_permeate_lv from %s to %s\n", is_permaeate_string(image_prc_param_.bits.is_permeate_lv_).c_str(), (char*)data);
image_prc_param_.bits.is_permeate_lv_ = match_best_permaeate_lv(str, NULL); image_prc_param_.bits.is_permeate_lv_ = match_best_permaeate_lv(str, NULL);
utils::to_log(LOG_LEVEL_DEBUG, "%d\n", ret);
return ret; return ret;
@ -2250,17 +2248,13 @@ void hg_scanner::init_settings(const char* json_setting_text)
jsn_reorganize(); jsn_reorganize();
utils::to_log(LOG_LEVEL_ALL, "Initialize %d settings ...\n", setting_jsn_->count()); utils::to_log(LOG_LEVEL_ALL, "------>Initialize %d settings ...<------\n", setting_jsn_->count());
notify_setting_result_ = false; notify_setting_result_ = false;
utils::to_log(LOG_LEVEL_ALL, "Initialize %d settings ... OK\n", setting_jsn_->count()); setting_restore(nullptr, nullptr); // restore to default value
utils::to_log(LOG_LEVEL_ALL, "------>Initialize %d settings ... OK<------\n", setting_jsn_->count());
if (lang_get_cur_code_page() != DEFAULT_CODE_PAGE) if (lang_get_cur_code_page() != DEFAULT_CODE_PAGE)
on_language_changed(); on_language_changed();
notify_setting_result_ = true; notify_setting_result_ = true;
//setting_jsn_
} }
int hg_scanner::init_settings(int pid) int hg_scanner::init_settings(int pid)
{ {
@ -2715,7 +2709,10 @@ int hg_scanner::set_setting(const char* name, void* data, bool to_default)
if (to_default) if (to_default)
{ {
int size = 0; if (!setting_jsn_->is_auto_restore_default(name))
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
int size = 0;
std::string val(setting_jsn_->get_option_value(name, OPT_VAL_DEFAULT, &size)); std::string val(setting_jsn_->get_option_value(name, OPT_VAL_DEFAULT, &size));
if (!data) if (!data)
@ -4170,7 +4167,7 @@ int hg_scanner::image_configuration(SCANCONF& ic)
utils::to_log(LOG_LEVEL_DEBUG, "ic.gamma=%f\r\n", ic.gamma); utils::to_log(LOG_LEVEL_DEBUG, "ic.gamma=%f\r\n", ic.gamma);
utils::to_log(LOG_LEVEL_DEBUG, "ic.hardwarecaps.capturepixtype=%d\r\n", ic.hardwarecaps.capturepixtype); utils::to_log(LOG_LEVEL_DEBUG, "ic.hardwarecaps.capturepixtype=%d\r\n", ic.hardwarecaps.capturepixtype);
utils::to_log(LOG_LEVEL_DEBUG, "ic.hardwarecaps.en_doublefeed=%d\r\n", ic.hardwarecaps.en_doublefeed); utils::to_log(LOG_LEVEL_DEBUG, "ic.hardwarecaps.en_doublefeed=%d\r\n", ic.hardwarecaps.en_doublefeed);
utils::to_log(LOG_LEVEL_DEBUG, "ic.hsvcorrect=%d", ic.hsvcorrect); utils::to_log(LOG_LEVEL_DEBUG, "ic.hsvcorrect=%d\n", ic.hsvcorrect);
utils::to_log(LOG_LEVEL_DEBUG, "ic.imageRotateDegree=%f\r\n", ic.imageRotateDegree); utils::to_log(LOG_LEVEL_DEBUG, "ic.imageRotateDegree=%f\r\n", ic.imageRotateDegree);
utils::to_log(LOG_LEVEL_DEBUG, "ic.indent=%d\r\n", 5); utils::to_log(LOG_LEVEL_DEBUG, "ic.indent=%d\r\n", 5);
utils::to_log(LOG_LEVEL_DEBUG, "ic.is_autocontrast=%d\r\n", ic.is_autocontrast); utils::to_log(LOG_LEVEL_DEBUG, "ic.is_autocontrast=%d\r\n", ic.is_autocontrast);
@ -4200,7 +4197,7 @@ int hg_scanner::image_configuration(SCANCONF& ic)
utils::to_log(LOG_LEVEL_DEBUG, "ic.errorExtention=%d\r\n", ic.errorExtention); utils::to_log(LOG_LEVEL_DEBUG, "ic.errorExtention=%d\r\n", ic.errorExtention);
utils::to_log(LOG_LEVEL_DEBUG, "ic.textureRemove=%d\r\n", ic.refuseInflow); utils::to_log(LOG_LEVEL_DEBUG, "ic.textureRemove=%d\r\n", ic.refuseInflow);
utils::to_log(LOG_LEVEL_DEBUG, "ic.fillhole.is_fillhole=%d\r\n", ic.fillhole.is_fillhole); utils::to_log(LOG_LEVEL_DEBUG, "ic.fillhole.is_fillhole=%d\r\n", ic.fillhole.is_fillhole);
utils::to_log(LOG_LEVEL_DEBUG, "ic.ic.fillhole.fillholeratio=%d\r\n ", ic.fillhole.fillholeratio); utils::to_log(LOG_LEVEL_DEBUG, "ic.ic.fillhole.fillholeratio=%d\r\n", ic.fillhole.fillholeratio);
utils::to_log(LOG_LEVEL_DEBUG, "ic.fadeback=%d\r\n", ic.fadeback); utils::to_log(LOG_LEVEL_DEBUG, "ic.fadeback=%d\r\n", ic.fadeback);
utils::to_log(LOG_LEVEL_DEBUG, "ic.cropRect.enable=%d\r\n", ic.cropRect.enable); utils::to_log(LOG_LEVEL_DEBUG, "ic.cropRect.enable=%d\r\n", ic.cropRect.enable);
utils::to_log(LOG_LEVEL_DEBUG, "ic.cropRect.width=%d\r\n", ic.cropRect.width); utils::to_log(LOG_LEVEL_DEBUG, "ic.cropRect.width=%d\r\n", ic.cropRect.width);

File diff suppressed because one or more lines are too long

View File

@ -7,6 +7,9 @@
#include "raw_src.h" #include "raw_src.h"
#include "../../../sdk/include/huagao/brand.h" #include "../../../sdk/include/huagao/brand.h"
#include "user-opt/user.h"
#include "user-opt/offline_opt.h"
#if !defined(WIN32) && !defined(_WIN64) #if !defined(WIN32) && !defined(_WIN64)
#endif #endif
@ -146,7 +149,7 @@ bool hg_scanner_mgr::read_over_with_eof_ = true;
uint32_t hg_scanner_mgr::unique_img_id_ = 0;; uint32_t hg_scanner_mgr::unique_img_id_ = 0;;
std::mutex hg_scanner_mgr::mutex_img_id; std::mutex hg_scanner_mgr::mutex_img_id;
hg_scanner_mgr::hg_scanner_mgr() : same_ind_(1), user_(""), pwd_(""), cf_name("") hg_scanner_mgr::hg_scanner_mgr() : same_ind_(1), cf_name("")
{ {
std::string cfgf(utils::get_local_data_path() + PATH_SEPARATOR + "config" + PATH_SEPARATOR + "debug.cfg"); std::string cfgf(utils::get_local_data_path() + PATH_SEPARATOR + "config" + PATH_SEPARATOR + "debug.cfg");
char buf[260] = {0}; char buf[260] = {0};
@ -163,6 +166,9 @@ hg_scanner_mgr::hg_scanner_mgr() : same_ind_(1), user_(""), pwd_(""), cf_name(""
url_en = BRAND_COMPANY_URL_EN; url_en = BRAND_COMPANY_URL_EN;
url_link_en = BRAND_URL_COMPANY_URL_EN; url_link_en = BRAND_URL_COMPANY_URL_EN;
} }
user_ = new hguser();
offline_ = new offline_opts(user_);
} }
hg_scanner_mgr::~hg_scanner_mgr() hg_scanner_mgr::~hg_scanner_mgr()
{ {
@ -174,6 +180,8 @@ hg_scanner_mgr::~hg_scanner_mgr()
online_devices_.clear(); online_devices_.clear();
} }
usb_manager::clear(); usb_manager::clear();
offline_->release();
delete user_;
} }
int hg_scanner_mgr::ui_default_callback(scanner_handle h, int ev, void* data, unsigned int* len, void* param) int hg_scanner_mgr::ui_default_callback(scanner_handle h, int ev, void* data, unsigned int* len, void* param)
@ -226,6 +234,17 @@ void hg_scanner_mgr::set_version(int hh, int hl, int lh, int ll)
hg_scanner_mgr::ver_build_ = lh; hg_scanner_mgr::ver_build_ = lh;
hg_scanner_mgr::ver_patch_ = ll; hg_scanner_mgr::ver_patch_ = ll;
} }
void hg_scanner_mgr::get_version(int* hh, int* hl, int* lh, int* ll)
{
if(hh)
*hh = hg_scanner_mgr::ver_major_;
if(hl)
*hl = hg_scanner_mgr::ver_minor_;
if(lh)
*lh = hg_scanner_mgr::ver_build_;
if(ll)
*ll = hg_scanner_mgr::ver_patch_;
}
void hg_scanner_mgr::set_exe_name(const char* path, const char* name) void hg_scanner_mgr::set_exe_name(const char* path, const char* name)
{ {
std::string cfgf(utils::get_local_data_path() + PATH_SEPARATOR + "config" + PATH_SEPARATOR + "debug.cfg"); std::string cfgf(utils::get_local_data_path() + PATH_SEPARATOR + "config" + PATH_SEPARATOR + "debug.cfg");
@ -823,61 +842,43 @@ scanner_err hg_scanner_mgr::hg_scanner_close(scanner_handle h, bool force)
} }
scanner_err hg_scanner_mgr::hg_scanner_get_parameter(scanner_handle h, const char* name, char* data, long* len, int type) scanner_err hg_scanner_mgr::hg_scanner_get_parameter(scanner_handle h, const char* name, char* data, long* len, int type)
{ {
scanner_err err = SCANNER_ERR_OK;
if (!len) if (!len)
return SCANNER_ERR_INVALID_PARAMETER; return SCANNER_ERR_INVALID_PARAMETER;
if (!h) if (!h)
{ {
*len = 0; if (name == PARAM_ALL)
{
std::string all(offline_->get_json_text());
if (*len <= all.length())
{
*len = all.length() + 1;
return SCANNER_ERR_OK; err = SCANNER_ERR_INSUFFICIENT_MEMORY;
}
else
{
strcpy(data, all.c_str());
*len = all.length();
}
}
else
err = (scanner_err)offline_->get_value(name, data, (int*)len, type == OPT_VAL_CURRENT);
return err;
}
else if (name && name != PARAM_ALL)
{
err = (scanner_err)offline_->get_value(name, data, (int*)len, type == OPT_VAL_CURRENT);
if (err != SCANNER_ERR_NO_DATA)
return err;
} }
// global options ... // global options ...
if (!IS_PTR_NUMBER(name)) if (!IS_PTR_NUMBER(name))
{ {
if (strcmp(name, SANE_STD_OPT_NAME_DRIVER_VERSION) == 0)
{
char buf[40] = { 0 };
sprintf(buf, "%d.%d.%d.%d", hg_scanner_mgr::ver_major_, hg_scanner_mgr::ver_minor_, hg_scanner_mgr::ver_build_, hg_scanner_mgr::ver_patch_);
if (*len <= strlen(buf))
{
*len = strlen(buf) + 1;
return SCANNER_ERR_INSUFFICIENT_MEMORY;
}
strcpy(data, buf);
*len = strlen(buf);
return SCANNER_ERR_OK;
}
#define TRY_STR_OPT(n, optn) \
if (strcmp(name, SANE_STD_OPT_NAME_##n) == 0) \
{ \
std::string n(GET_LANG(optn, nullptr)); \
if (*len <= n.length()) \
{ \
*len = n.length() + 1; \
\
return SCANNER_ERR_INSUFFICIENT_MEMORY; \
} \
\
strcpy(data, n.c_str()); \
*len = n.length(); \
\
return SCANNER_ERR_OK; \
}
TRY_STR_OPT(MANUFACTURER, COMPANY_NAME);
TRY_STR_OPT(COPYRIGHT, BRAND_COPYRIGHT);
TRY_STR_OPT(CO_URL, url_link_en.c_str());
TRY_STR_OPT(CO_TEL, BRAND_COMPANY_TEL);
TRY_STR_OPT(CO_ADDR, BRAND_COMPANY_ADDRESS);
TRY_STR_OPT(CO_GPS, BRAND_URL_GPS);
// following options getting operation is implemented in 'set' ... // following options getting operation is implemented in 'set' ...
{ {
if (strcmp(SANE_STD_OPT_NAME_DEVICE_VID, name) == 0 || if (strcmp(SANE_STD_OPT_NAME_DEVICE_VID, name) == 0 ||
@ -894,24 +895,12 @@ scanner_err hg_scanner_mgr::hg_scanner_get_parameter(scanner_handle h, const cha
return (scanner_err)SCAN_PTR(h)->set_setting(name, data, false); return (scanner_err)SCAN_PTR(h)->set_setting(name, data, false);
} }
if (strcmp(SANE_STD_OPT_NAME_DRIVER_LOG, name) == 0) if (strcmp(SANE_STD_OPT_NAME_DEVICE_LOG, name) == 0)
{ {
if (!data) if (!data)
return SCANNER_ERR_INVALID_PARAMETER; return SCANNER_ERR_INVALID_PARAMETER;
if (user_ == ADMIN_NAME && pwd_ == ADMIN_PWD) if (user_->has_privilege(USER_PRIVILEGE_LOCAL_MGR))
{
return (scanner_err)utils::copy_log_file_to(data);
}
else
return SCANNER_ERR_ACCESS_DENIED;
}
else if (strcmp(SANE_STD_OPT_NAME_DEVICE_LOG, name) == 0)
{
if (!data)
return SCANNER_ERR_INVALID_PARAMETER;
if (user_ == ADMIN_NAME && pwd_ == ADMIN_PWD)
{ {
char path[300] = { 0 }; char path[300] = { 0 };
int l = LOG_FILE_DEVICE, int l = LOG_FILE_DEVICE,
@ -934,9 +923,7 @@ scanner_err hg_scanner_mgr::hg_scanner_get_parameter(scanner_handle h, const cha
else if (strcmp(SANE_STD_OPT_NAME_CUSTOM_GAMMA, name) == 0) else if (strcmp(SANE_STD_OPT_NAME_CUSTOM_GAMMA, name) == 0)
return (scanner_err)SCAN_PTR(h)->device_io_control(IO_CTRL_CODE_GET_CUSTOM_GAMMA, data, (unsigned int*)len); return (scanner_err)SCAN_PTR(h)->device_io_control(IO_CTRL_CODE_GET_CUSTOM_GAMMA, data, (unsigned int*)len);
if (strcmp(SANE_STD_OPT_NAME_LOGIN, name) == 0 || if (strcmp(SANE_STD_OPT_NAME_TRANSFORM_IMAGE_FORMAT, name) == 0 ||
strcmp(SANE_STD_OPT_NAME_LOGOUT, name) == 0 ||
strcmp(SANE_STD_OPT_NAME_TRANSFORM_IMAGE_FORMAT, name) == 0 ||
strcmp(SANE_STD_OPT_NAME_FREE_BUFFER, name) == 0) strcmp(SANE_STD_OPT_NAME_FREE_BUFFER, name) == 0)
return SCANNER_ERR_DEVICE_NOT_SUPPORT; return SCANNER_ERR_DEVICE_NOT_SUPPORT;
@ -955,63 +942,36 @@ scanner_err hg_scanner_mgr::hg_scanner_get_parameter(scanner_handle h, const cha
} }
} }
int l = *len, int l = *len;
err = SCAN_PTR(h)->get_setting(name, data, &l, type);
err = (scanner_err)SCAN_PTR(h)->get_setting(name, data, &l, type);
*len = l; *len = l;
return (scanner_err)err; return err;
} }
scanner_err hg_scanner_mgr::hg_scanner_set_parameter(scanner_handle h, const char* name, void* data, bool to_default) scanner_err hg_scanner_mgr::hg_scanner_set_parameter(scanner_handle h, const char* name, void* data, bool to_default)
{ {
scanner_err err = SCANNER_ERR_INVALID_PARAMETER;
if (!h)
{
if (name)
err = (scanner_err)offline_->set_value(name, data);
return err;
}
else if (name)
{
err = (scanner_err)offline_->set_value(name, data);
if (err != SCANNER_ERR_NO_DATA)
return err;
}
if (!IS_PTR_NUMBER(name)) if (!IS_PTR_NUMBER(name))
{ {
if (strcmp(SANE_STD_OPT_NAME_CO_GPS, name) == 0 || if (strcmp(SANE_STD_OPT_NAME_DEVICE_LOG, name) == 0)
strcmp(SANE_STD_OPT_NAME_CO_ADDR, name) == 0 ||
strcmp(SANE_STD_OPT_NAME_CO_TEL, name) == 0 ||
strcmp(SANE_STD_OPT_NAME_CO_URL, name) == 0 ||
strcmp(SANE_STD_OPT_NAME_COPYRIGHT, name) == 0 ||
strcmp(SANE_STD_OPT_NAME_MANUFACTURER, name) == 0 ||
strcmp(SANE_STD_OPT_NAME_DRIVER_VERSION, name) == 0)
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
if (strcmp(SANE_STD_OPT_NAME_LOGIN, name) == 0)
{ {
// str32 + 32 if (user_->has_privilege(USER_PRIVILEGE_LOCAL_MGR))
char* n = (char*)data,
* p = n + 32;
user_ = n;
pwd_ = p;
return SCANNER_ERR_OK; SCANNER_ERR_ACCESS_DENIED;
}
else if (strcmp(SANE_STD_OPT_NAME_LOGOUT, name) == 0)
{
// str32 + 32
char* n = (char*)data,
* p = n + 32;
if (user_ == n && pwd_ == p)
{
user_ = "";
pwd_ = "";
return SCANNER_ERR_OK;
}
return SCANNER_ERR_ACCESS_DENIED;
}
else if (strcmp(SANE_STD_OPT_NAME_DRIVER_LOG, name) == 0)
{
if (user_ == ADMIN_NAME && pwd_ == ADMIN_PWD)
{
return (scanner_err)utils::clear_log_file();
}
return SCANNER_ERR_ACCESS_DENIED;
}
else if (strcmp(SANE_STD_OPT_NAME_DEVICE_LOG, name) == 0)
{
if (user_ == ADMIN_NAME && pwd_ == ADMIN_PWD)
{ {
return SCANNER_ERR_DEVICE_NOT_SUPPORT; return SCANNER_ERR_DEVICE_NOT_SUPPORT;
} }
@ -1020,7 +980,7 @@ scanner_err hg_scanner_mgr::hg_scanner_set_parameter(scanner_handle h, const cha
} }
else if (strcmp(SANE_STD_OPT_NAME_ROLLER_COUNT, name) == 0) else if (strcmp(SANE_STD_OPT_NAME_ROLLER_COUNT, name) == 0)
{ {
if (user_ == ADMIN_NAME && pwd_ == ADMIN_PWD) if (user_->has_privilege(USER_PRIVILEGE_LOCAL_MGR))
{ {
int* len = nullptr; int* len = nullptr;
return (scanner_err)SCAN_PTR(h)->device_io_control(IO_CTRL_CODE_SET_CLEAR_ROLLER_COUNT, data, (unsigned*)len); return (scanner_err)SCAN_PTR(h)->device_io_control(IO_CTRL_CODE_SET_CLEAR_ROLLER_COUNT, data, (unsigned*)len);

View File

@ -37,6 +37,8 @@
//#define hg_scanner_mgr cts_scanner_mgr //#define hg_scanner_mgr cts_scanner_mgr
//#endif //#endif
class hg_scanner; class hg_scanner;
class hguser;
class offline_opts;
class hg_scanner_mgr class hg_scanner_mgr
{ {
@ -64,8 +66,8 @@ class hg_scanner_mgr
std::mutex mutex_dev_; std::mutex mutex_dev_;
unsigned int same_ind_; unsigned int same_ind_;
std::string user_; hguser* user_;
std::string pwd_; offline_opts* offline_;
static sane_callback event_callback_; static sane_callback event_callback_;
static bool async_io_enabled_; static bool async_io_enabled_;
@ -104,6 +106,7 @@ public:
static hg_scanner_mgr* instance(sane_callback cb = NULL); static hg_scanner_mgr* instance(sane_callback cb = NULL);
static void clear(void); static void clear(void);
static void set_version(int hh, int hl, int lh, int ll); static void set_version(int hh, int hl, int lh, int ll);
static void get_version(int* hh, int* hl, int* lh, int* ll);
static void set_exe_name(const char* path, const char* name); static void set_exe_name(const char* path, const char* name);
static std::string get_pe_name(std::string* path = nullptr); static std::string get_pe_name(std::string* path = nullptr);
enum enum

View File

@ -1434,6 +1434,21 @@ int device_option::count(void)
else else
return 0; return 0;
} }
bool device_option::is_auto_restore_default(const char* name)
{
gb_json* jsn = now_ ? now_ : origin_,
* child = nullptr;
bool support = true;
jsn->get_value(name, child);
if (child)
{
child->get_value("auto", support);
child->release();
}
return support;
}
std::string device_option::get_name_by_sane_id(int sane_ind) std::string device_option::get_name_by_sane_id(int sane_ind)
{ {
std::string value(""); std::string value("");
@ -1442,7 +1457,8 @@ std::string device_option::get_name_by_sane_id(int sane_ind)
if (sane_ind > 0 && sane_ind - 1 < jsn->children()) if (sane_ind > 0 && sane_ind - 1 < jsn->children())
{ {
gb_json* child = now_->child(sane_ind - 1); gb_json* child = now_->child(sane_ind - 1);
child->get_value("name", value); //child->get_value("name", value);
value = child->key();
child->release(); child->release();
} }

View File

@ -215,6 +215,7 @@ public:
int update_data(const char* name, void* value); // return scanner_err. name and value would be null if invoked for language changed int update_data(const char* name, void* value); // return scanner_err. name and value would be null if invoked for language changed
int count(void); // return option count int count(void); // return option count
bool is_auto_restore_default(const char* name);
std::string get_name_by_sane_id(int sane_ind); std::string get_name_by_sane_id(int sane_ind);
std::string get_option_value_type(const char* name); std::string get_option_value_type(const char* name);
std::string get_option_value(const char* name, int type/*OPT_VAL_xxx*/, int* size = nullptr); // return whole json-text if name was null std::string get_option_value(const char* name, int type/*OPT_VAL_xxx*/, int* size = nullptr); // return whole json-text if name was null

View File

@ -6,9 +6,6 @@
static std::string device_opt_json[] = {
"{\"login\":{\"cat\":\"base\",\"group\":\"\\u9ad8\\u7ea7\\u8bbe\\u7f6e\",\"title\":\"\\u7528\\u6237\\u767b\\u5f55\",\"desc\":\"\\u767b\\u5f55\\u7528\\u6237\\u8d26\\u53f7\",\"ver\":0,\"pos\":0,\"fix-id\":39168,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"visible\":false,\"enabled\":false,\"size\":64,\"cur\":\"\",\"default\":\"\"},\"logout\":{\"cat\":\"base\",\"group\":\"\\u9ad8\\u7ea7\\u8bbe\\u7f6e\",\"title\":\"\\u7528\\u6237\\u767b\\u51fa\",\"desc\":\"\\u9000\\u51fa\\u767b\\u5f55\\u7528\\u6237\\u8d26\\u53f7\",\"ver\":0,\"pos\":0,\"fix-id\":39169,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"visible\":false,\"enabled\":false,\"size\":64,\"cur\":\"\",\"default\":\"\"}}"
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// memory management ... // memory management ...
@ -30,7 +27,7 @@ int hguser::login(const char* name, const char* pwd)
// higher privilege checks must be more complex, to be implementing ... // higher privilege checks must be more complex, to be implementing ...
} }
return 0; return SCANNER_ERR_OK;
} }
int hguser::logout(const char* name, const char* pwd) int hguser::logout(const char* name, const char* pwd)
{ {
@ -50,5 +47,5 @@ int hguser::logout(const char* name, const char* pwd)
bool hguser::has_privilege(int priv) bool hguser::has_privilege(int priv)
{ {
return priv & priv_ == priv; return (priv & priv_) == priv;
} }

View File

@ -7,22 +7,6 @@
#include <string> #include <string>
class sane_opt_provider
{
public:
sane_opt_provider();
protected:
virtual ~sane_opt_provider();
public:
virtual std::string get_json_text(void) = 0;
virtual int set_value(const char* name, void* value) = 0;
virtual void enable(const char* name, bool enabled) = 0;
virtual bool is_enable(const char* name) = 0;
virtual bool has(const char* name) = 0;
};
class hguser class hguser
{ {
std::string name_; std::string name_;

View File

@ -398,7 +398,8 @@ SANE_Option_Descriptor* device_opts::get_opt_descriptor(const void* opt, int* fi
if (IS_PTR_NUMBER(opt)) if (IS_PTR_NUMBER(opt))
{ {
int sn = (int)opt; int sn = (int)opt;
sn -= ind_base; if(sn < SANE_OPT_ID_BASE)
sn -= ind_base;
if (opts_.count(sn)) if (opts_.count(sn))
{ {
if (fix_id) if (fix_id)

View File

@ -558,6 +558,7 @@ int scanner::open(void)
scanner::get_scanner_name(model_.c_str(), que); scanner::get_scanner_name(model_.c_str(), que);
init_options_id();
scanner_name_ = ""; scanner_name_ = "";
if (que.empty()) if (que.empty())
return SCANNER_ERR_DEVICE_NOT_FOUND; return SCANNER_ERR_DEVICE_NOT_FOUND;