封装获取HGVersion函数,调整linux下的链接动态库名

This commit is contained in:
yangjiaxuan 2022-07-14 13:48:33 +08:00
parent e2f53a4bd0
commit eb77299e86
3 changed files with 90 additions and 59 deletions

View File

@ -86,13 +86,17 @@ void Dialog_updateProgress::ThreadFunc(HGThread thread, HGPointer param)
QString curPath = QDir::currentPath();
QString tmpPath = QDir::tempPath();
QFile file(curPath);
file.copy("HuagoScanUpgrade.exe", tmpPath);
file.copy("HGUpgrade.exe", tmpPath);
file.copy("libHGBase.so", tmpPath);
file.copy("libHGVersion.so", tmpPath);
#if defined(HG_CMP_MSC)
file.copy("msvcp140.dll", tmpPath);
file.copy("Qt5Core.dll", tmpPath);
file.copy("Qt5Gui.dll", tmpPath);
file.copy("Qt5Widgets.dll", tmpPath);
file.copy("vcruntime140.dll", tmpPath);
file.copy("HGBase.dll", tmpPath);
file.copy("HGBase.dll", tmpPath);
#endif
emit p->finish();

View File

@ -48,8 +48,13 @@
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
, m_versionDllName("")
, m_curVersion("")
, m_selectVersionNum("")
, m_versionDll(NULL)
, m_versionMgr(NULL)
, m_versionInfo(NULL)
, m_versionListCount(0)
, m_admin_loggedIn(false)
, m_dpi(200)
, m_currFilePath("")
@ -68,45 +73,33 @@ MainWindow::MainWindow(QWidget *parent)
{
ui->setupUi(this);
std::string versionDllName;
#if defined(OEM_HANWANG)
this->setWindowIcon(QIcon(":images/image_rsc/logo/Hanvon_logo1.ico"));
this->setWindowTitle(tr("HanvonScan"));
#if defined(HG_CMP_MSC)
versionDllName = "HWVersion.dll";
m_versionDllName = "HWVersion.dll";
#else
versionDllName = "HWVersion.so";
m_versionDllName = "libHWVersion.so";
#endif
#elif defined(OEM_LISICHENG)
this->setWindowIcon(QIcon(":images/image_rsc/logo/Lanxum_logo.ico"));
this->setWindowTitle(tr("LanxumScan"));
#if defined(HG_CMP_MSC)
versionDllName = "LSCVersion.dll";
m_versionDllName = "LSCVersion.dll";
#else
versionDllName = "LSCVersion.so";
m_versionDllName = "libLSCVersion.so";
#endif
#else
this->setWindowIcon(QIcon(":images/image_rsc/logo/logo.ico"));
this->setWindowTitle(tr("HuaGoScan"));
#if defined(HG_CMP_MSC)
versionDllName = "HGVersion.dll";
m_versionDllName = "HGVersion.dll";
#else
versionDllName = "HGVersion.so";
m_versionDllName = "libHGVersion.so";
#endif
#endif
HGBase_CreateDll(versionDllName.c_str(), &m_versionDll);
if (NULL != m_versionDll)
{
typedef HGResult (HGAPI *Func)(HGVersionMgr *);
Func func = NULL;
HGBase_GetDllProcAddress(m_versionDll, "HGVersion_CreateMgr", (HGPointer *)&func);
if (NULL != func)
{
func(&m_versionMgr);
}
}
getHGVersionInfo(false);
this->setAutoFillBackground(true);
this->setPalette(QPalette(QColor(230, 230, 230)));
@ -1131,30 +1124,11 @@ void MainWindow::on_statusInfoDblClick()
void MainWindow::on_update(QListWidgetItem *item)
{
std::string curVersion;
typedef HGResult (HGAPI *Func)(const HGChar*, HGChar*, HGUInt);
Func func = NULL;
HGBase_GetDllProcAddress(m_versionDll, "HGVersion_GetCurrVersion", (HGPointer *)&func);
if (NULL != func)
{
HGChar ver[256] = {0};
func(HGVERSION_APPNAME_SCANNER, ver, 256);
curVersion = ver;
}
HGInt result = 0;
typedef HGResult (HGAPI *Func2)(const HGChar*, const HGChar*, HGInt*);
Func2 func2 = NULL;
HGBase_GetDllProcAddress(m_versionDll, "HGVersion_CompareVersion", (HGPointer *)&func2);
if (NULL != func2)
{
func2(curVersion.c_str(), item->text().toStdString().c_str(), &result);
}
getHGVersionInfo(false);
m_selectVersionNum = item->text().toStdString().c_str();
m_listwidget->close();
if(0 == result)
if(0 == getHGVersionInfo(false))
{
QMessageBox::information(this, "tip", "Already in current version");
return;
@ -3078,6 +3052,62 @@ bool MainWindow::judgeDiskSpace(QString currentPath)
return true;
}
int MainWindow::getHGVersionInfo(bool releaseVersionInfo)
{
HGBase_CreateDll(m_versionDllName.c_str(), &m_versionDll);
if (NULL != m_versionDll)
{
typedef HGResult (HGAPI *Func)(HGVersionMgr *);
Func func = NULL;
HGBase_GetDllProcAddress(m_versionDll, "HGVersion_CreateMgr", (HGPointer *)&func);
if (NULL != func)
{
func(&m_versionMgr);
}
typedef HGResult (HGAPI *Func2)(HGVersionMgr, const HGChar*, HGVersionInfo **, HGUInt *);
Func2 func2 = NULL;
HGBase_GetDllProcAddress(m_versionDll, "HGVersion_GetVersionList", (HGPointer *)&func2);
if (NULL != func2)
{
func2(m_versionMgr, HGVERSION_APPNAME_SCANNER, &m_versionInfo, &m_versionListCount);
}
if(releaseVersionInfo)
{
typedef HGResult (HGAPI *Func3)(HGVersionInfo*, HGUInt);
Func3 func3 = NULL;
HGBase_GetDllProcAddress(m_versionDll, "HGVersion_ReleaseVersionList", (HGPointer *)&func3);
if (NULL != func3)
{
func3(m_versionInfo, m_versionListCount);
}
}
typedef HGResult (HGAPI *Func4)(const HGChar*, HGChar*, HGUInt);
Func4 func4 = NULL;
HGBase_GetDllProcAddress(m_versionDll, "HGVersion_GetCurrVersion", (HGPointer *)&func4);
if (NULL != func4)
{
HGChar ver[256] = {0};
func4(HGVERSION_APPNAME_SCANNER, ver, 256);
m_curVersion = ver;
}
HGInt result = 0;
typedef HGResult (HGAPI *Func5)(const HGChar*, const HGChar*, HGInt*);
Func5 func5 = NULL;
HGBase_GetDllProcAddress(m_versionDll, "HGVersion_CompareVersion", (HGPointer *)&func5);
if (NULL != func5)
{
func5(m_curVersion.c_str(), m_selectVersionNum.c_str(), &result);
}
return result;
}
return 1;
}
void MainWindow::on_scanOptions_changed(const QString &device, const QString &option, bool checked_now)
{
QString title(tr("app name"));
@ -3181,33 +3211,24 @@ void MainWindow::on_act_sortPages_triggered()
void MainWindow::on_actionact_update_triggered()
{
getHGVersionInfo(false);
m_listwidget = new QListWidget;
m_listwidget->setWindowTitle("chose the version");
HGVersionInfo versionInfo[64];
HGUInt count = 0;
typedef HGResult (HGAPI *Func)(HGVersionMgr, const HGChar*, HGVersionInfo *, HGUInt, HGUInt *);
Func func = NULL;
HGBase_GetDllProcAddress(m_versionDll, "HGVersion_GetVersionList", (HGPointer *)&func);
if (NULL != func)
if(m_versionListCount > 0)
{
func(m_versionMgr, HGVERSION_APPNAME_SCANNER, versionInfo, 64, &count);
}
if(count > 0)
{
for(HGUInt i = 0; i < count; ++i)
for(HGUInt i = 0; i < m_versionListCount; ++i)
{
QListWidgetItem *listwidgetItem = new QListWidgetItem;
listwidgetItem->setText(QString(versionInfo[i].version));
listwidgetItem->setData(Qt::UserRole, versionInfo[i].url);
listwidgetItem->setData(Qt::UserRole+1, versionInfo[i].md5);
listwidgetItem->setToolTip(versionInfo[i].desc + tr(" buginfo: ") + versionInfo[i].bugInfo);
listwidgetItem->setText(QString(m_versionInfo[i].version));
listwidgetItem->setData(Qt::UserRole, m_versionInfo[i].url);
listwidgetItem->setData(Qt::UserRole+1, m_versionInfo[i].md5);
listwidgetItem->setToolTip(m_versionInfo[i].desc + tr(" buginfo: ") + m_versionInfo[i].bugInfo);
m_listwidget->addItem(listwidgetItem);
}
m_listwidget->show();
connect(m_listwidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(on_update(QListWidgetItem*)), Qt::QueuedConnection);
getHGVersionInfo(true);
}
else
{

View File

@ -227,11 +227,17 @@ private:
QString passwordDecrypt(const QString& transcode);
bool open_scanner(const QString& name, OPTSCHEME* schm);
bool judgeDiskSpace(QString currentPath);
int getHGVersionInfo(bool releaseVersionInfo);
private:
Ui::MainWindow *ui;
std::string m_versionDllName;
std::string m_curVersion;
std::string m_selectVersionNum;
HGDll m_versionDll;
HGVersionMgr m_versionMgr;
HGVersionInfo *m_versionInfo;
HGUInt m_versionListCount;
QString m_password;
bool m_admin_loggedIn;
HGImgView *m_view;