From 1ab3d035d0851fbff494a6d809305c5056fe26de Mon Sep 17 00:00:00 2001 From: yangjiaxuan <171295266@qq.com> Date: Tue, 13 Jun 2023 15:24:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=BB=9A=E8=BD=B4=E8=80=97?= =?UTF-8?q?=E6=9D=90=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/fwupgrade/main.cpp | 21 ++++++++++++++++++++- app/scanner/mainwindow.cpp | 2 -- app/scanner2/device_user.cpp | 7 +++++++ app/scanner2/device_user.h | 1 + app/scanner2/mainwindow.cpp | 16 ++++++++++++++++ app/scanner2/mainwindow.h | 1 + modules/sane_user/HGSane.cpp | 11 +++++++++++ modules/sane_user/HGSane.h | 2 ++ modules/sane_user/HGSaneImpl.cpp | 5 +++++ modules/sane_user/HGSaneImpl.hpp | 1 + 10 files changed, 64 insertions(+), 3 deletions(-) diff --git a/app/fwupgrade/main.cpp b/app/fwupgrade/main.cpp index eb0a83be..33fc88b0 100644 --- a/app/fwupgrade/main.cpp +++ b/app/fwupgrade/main.cpp @@ -7,7 +7,15 @@ #include #include #include "base/HGBase.h" + +#if defined(HG_CMP_MSC) #include +#else +#include +#include +#include +#include +#endif HGResult GetConfigPath(HGChar* configPath, HGUInt maxLen) { @@ -17,7 +25,7 @@ HGResult GetConfigPath(HGChar* configPath, HGUInt maxLen) } const char *appName = "HuaGoScan"; - +#if defined(HG_CMP_MSC) CHAR cfgPath[MAX_PATH] = { 0 }; BOOL ret = SHGetSpecialFolderPathA(NULL, cfgPath, CSIDL_APPDATA, FALSE); if (!ret) @@ -27,6 +35,17 @@ HGResult GetConfigPath(HGChar* configPath, HGUInt maxLen) strcat(cfgPath, appName); strcat(cfgPath, "\\Cfg\\"); +#else + char cfgPath[512] = { 0 }; + struct passwd* pw = getpwuid(getuid()); + strcpy(cfgPath, pw->pw_dir); + if (cfgPath[strlen(cfgPath) - 1] != '/') + strcat(cfgPath, "/"); + + strcat(cfgPath, "."); + strcat(cfgPath, appName); + strcat(cfgPath, "/Cfg/"); +#endif if (maxLen < strlen(cfgPath) + 1) return HGBASE_ERR_FAIL; diff --git a/app/scanner/mainwindow.cpp b/app/scanner/mainwindow.cpp index 28cfe793..dbe1af22 100644 --- a/app/scanner/mainwindow.cpp +++ b/app/scanner/mainwindow.cpp @@ -3273,8 +3273,6 @@ void MainWindow::on_act_help_triggered() filename = QApplication::applicationDirPath() + "/HuaGoScan_App_Help_manual.pdf"; #endif #else - QString filename; - std::string osName; FILE *file = popen("cat /etc/issue | cut -d\' \' -f1", "r"); if (NULL != file) diff --git a/app/scanner2/device_user.cpp b/app/scanner2/device_user.cpp index 6eb4f438..7f6b4cff 100644 --- a/app/scanner2/device_user.cpp +++ b/app/scanner2/device_user.cpp @@ -299,6 +299,13 @@ HGResult DeviceUser::ClearRollerCount() return HGSane_ClearRollerCount(m_saneDev); } +int DeviceUser::GetDeviceRollerLife() +{ + int rollerLife = 0; + HGSane_GetDeviceRollerLife(m_saneDev, &rollerLife); + return rollerLife; +} + QString DeviceUser::GetDriverLog() { QString fileName = QFileDialog::getSaveFileName(m_wnd, tr("Select log file path"), ".", tr("text(*.txt)")); diff --git a/app/scanner2/device_user.h b/app/scanner2/device_user.h index 47ec85c3..c61e5a91 100644 --- a/app/scanner2/device_user.h +++ b/app/scanner2/device_user.h @@ -106,6 +106,7 @@ public: HGResult Login(); HGResult Logout(); HGResult ClearRollerCount(); + int GetDeviceRollerLife(); QString GetDriverLog(); HGResult ClearDriverLog(); QString GetDeviceLog(); diff --git a/app/scanner2/mainwindow.cpp b/app/scanner2/mainwindow.cpp index 39fa5430..c9f62430 100644 --- a/app/scanner2/mainwindow.cpp +++ b/app/scanner2/mainwindow.cpp @@ -389,6 +389,7 @@ MainWindow::MainWindow(const QString& appLang, QWidget *parent) connect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent()), Qt::QueuedConnection); } + checkRollerLife(); updateSideBar(); updateActionStatus(); } @@ -3591,6 +3592,20 @@ void MainWindow::updateSideBar() m_propertyAnimation2->setDuration(600); } +void MainWindow::checkRollerLife() +{ + if (m_devUser != nullptr) + { + int life = m_devUser->GetDeviceRollerLife(); + HGSaneDeviceCustomInfo info = {0}; + m_devUser->GetDeviceCustomInfo(&info); + if (info.rollerCount >= life) + { + QMessageBox::information(this, tr("Prompt"), tr("The Device has reached roller life"), QMessageBox::Ok); + } + } +} + void MainWindow::on_act_sortPages_triggered() { if (m_isScanning) @@ -3825,6 +3840,7 @@ void MainWindow::on_act_selectDevice_triggered() connect(m_devUser, SIGNAL(newImage(void*)), this, SLOT(on_newImage(void*)), Qt::DirectConnection); connect(m_devUser, SIGNAL(scanWorkingEvent()), this, SLOT(on_scanWorkingEvent()), Qt::QueuedConnection); connect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent()), Qt::QueuedConnection); + checkRollerLife(); updateActionStatus(); } } diff --git a/app/scanner2/mainwindow.h b/app/scanner2/mainwindow.h index fb93429b..8dfb1b46 100644 --- a/app/scanner2/mainwindow.h +++ b/app/scanner2/mainwindow.h @@ -241,6 +241,7 @@ private: void deleteUpgradePkg(const QString& cfgFilePath); void initAcquireIntoComboBox(); void updateSideBar(); + void checkRollerLife(); private: Ui::MainWindow *ui; diff --git a/modules/sane_user/HGSane.cpp b/modules/sane_user/HGSane.cpp index f67b80c6..e5d4ba2e 100644 --- a/modules/sane_user/HGSane.cpp +++ b/modules/sane_user/HGSane.cpp @@ -276,6 +276,17 @@ HGResult HGAPI HGSane_ClearRollerCount(HGSaneDevice dev) return saneDeviceImpl->ClearRollerCount(); } +HGResult HGAPI HGSane_GetDeviceRollerLife(HGSaneDevice dev, HGInt *rollerLife) +{ + if (NULL == dev) + { + return HGBASE_ERR_INVALIDARG; + } + + HGSaneDeviceImpl* saneDeviceImpl = (HGSaneDeviceImpl*)dev; + return saneDeviceImpl->GetRollerLife(rollerLife); +} + HGResult HGAPI HGSane_GetDriverLog(HGSaneDevice dev, const HGChar *fileName) { if (NULL == dev) diff --git a/modules/sane_user/HGSane.h b/modules/sane_user/HGSane.h index 8089ea94..5704d60b 100644 --- a/modules/sane_user/HGSane.h +++ b/modules/sane_user/HGSane.h @@ -84,6 +84,8 @@ HGEXPORT HGResult HGAPI HGSane_Logout(HGSaneDevice dev); HGEXPORT HGResult HGAPI HGSane_ClearRollerCount(HGSaneDevice dev); +HGEXPORT HGResult HGAPI HGSane_GetDeviceRollerLife(HGSaneDevice dev, HGInt *rollerLife); + HGEXPORT HGResult HGAPI HGSane_GetDriverLog(HGSaneDevice dev, const HGChar *fileName); HGEXPORT HGResult HGAPI HGSane_ClearDriverLog(HGSaneDevice dev); diff --git a/modules/sane_user/HGSaneImpl.cpp b/modules/sane_user/HGSaneImpl.cpp index 7d94b408..f32a2afc 100644 --- a/modules/sane_user/HGSaneImpl.cpp +++ b/modules/sane_user/HGSaneImpl.cpp @@ -731,6 +731,11 @@ HGResult HGSaneDeviceImpl::ClearRollerCount() return SetValueInt32(0x9902, 0); } +HGResult HGSaneDeviceImpl::GetRollerLife(HGInt *rollerLife) +{ + return GetValueInt32(0x885B, rollerLife); +} + HGResult HGSaneDeviceImpl::GetDriverLog(const HGChar *fileName) { if (NULL == fileName || strlen(fileName) >= 256) diff --git a/modules/sane_user/HGSaneImpl.hpp b/modules/sane_user/HGSaneImpl.hpp index d2e76d12..1d983832 100644 --- a/modules/sane_user/HGSaneImpl.hpp +++ b/modules/sane_user/HGSaneImpl.hpp @@ -80,6 +80,7 @@ public: HGResult Login(const HGChar *user, const HGChar *pwd); HGResult Logout(); HGResult ClearRollerCount(); + HGResult GetRollerLife(HGInt *rollerLife); HGResult GetDriverLog(const HGChar *fileName); HGResult ClearDriverLog(); HGResult GetDeviceLog(const HGChar *fileName);